@contentful/experience-design-system-cli 2.35.1-dev-build-36aa669d.0 → 2.35.1-dev-build-c518de8c.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.
@@ -164,12 +164,11 @@ var init_render_with_goodbye = __esm({
164
164
  function isAgentName(value) {
165
165
  return AGENT_NAMES.includes(value);
166
166
  }
167
- var AGENT_NAMES, DEFAULT_AGENT_NAME, AGENT_BINARIES;
167
+ var AGENT_NAMES, AGENT_BINARIES;
168
168
  var init_agent_names = __esm({
169
169
  "packages/experience-design-system-generation/dist/src/agent-names.js"() {
170
170
  "use strict";
171
171
  AGENT_NAMES = ["claude", "codex", "opencode", "cursor", "copilot"];
172
- DEFAULT_AGENT_NAME = "claude";
173
172
  AGENT_BINARIES = {
174
173
  claude: "claude",
175
174
  codex: "codex",
@@ -181,23 +180,6 @@ var init_agent_names = __esm({
181
180
  });
182
181
 
183
182
  // packages/experience-design-system-generation/dist/src/controller/helpers/validate-generation-request.js
184
- function validateGenerationRequest(request2) {
185
- if (request2 === null || typeof request2 !== "object") {
186
- throw new TypeError("createGenerationEndpoint requires a request object");
187
- }
188
- if (!isAgentName(request2.agent)) {
189
- throw new TypeError(`createGenerationEndpoint requires agent to be a valid agent name, got: ${String(request2.agent)}`);
190
- }
191
- if (typeof request2.timeoutMs !== "number" || request2.timeoutMs <= 0) {
192
- throw new TypeError("createGenerationEndpoint requires timeoutMs to be a positive number");
193
- }
194
- if (request2.promptOptions === null || typeof request2.promptOptions !== "object") {
195
- throw new TypeError("createGenerationEndpoint requires promptOptions to be an object");
196
- }
197
- if (request2.onOutput !== void 0 && typeof request2.onOutput !== "function") {
198
- throw new TypeError("createGenerationEndpoint requires onOutput to be a function when provided");
199
- }
200
- }
201
183
  var init_validate_generation_request = __esm({
202
184
  "packages/experience-design-system-generation/dist/src/controller/helpers/validate-generation-request.js"() {
203
185
  "use strict";
@@ -630,17 +612,6 @@ var init_build_prompt = __esm({
630
612
  });
631
613
 
632
614
  // packages/experience-design-system-generation/dist/src/orchestrator/execute-generation-orchestrator.js
633
- async function executeGenerationOrchestrator(request2) {
634
- const prompt = await buildPrompt(request2.promptOptions);
635
- return request2.invoker.invoke({
636
- agent: request2.agent,
637
- model: request2.model,
638
- bedrock: request2.bedrock,
639
- prompt,
640
- timeoutMs: request2.timeoutMs,
641
- onOutput: request2.onOutput
642
- });
643
- }
644
615
  var init_execute_generation_orchestrator = __esm({
645
616
  "packages/experience-design-system-generation/dist/src/orchestrator/execute-generation-orchestrator.js"() {
646
617
  "use strict";
@@ -741,22 +712,6 @@ var init_describe_agent_failure = __esm({
741
712
  });
742
713
 
743
714
  // packages/experience-design-system-generation/dist/src/services/agent/helpers/extract-sentinel-output.js
744
- function extractSentinelOutput(stdout) {
745
- const START = "<<<EDS_OUTPUT_START>>>";
746
- const END = "<<<EDS_OUTPUT_END>>>";
747
- const startIdx = stdout.indexOf(START);
748
- const endIdx = stdout.indexOf(END);
749
- if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx)
750
- return null;
751
- const secondStart = stdout.indexOf(START, startIdx + START.length);
752
- if (secondStart !== -1 && secondStart < endIdx)
753
- return "multiple";
754
- const afterStart = stdout.indexOf(END, startIdx);
755
- const secondEnd = stdout.indexOf(END, afterStart + END.length);
756
- if (secondEnd !== -1)
757
- return "multiple";
758
- return stdout.slice(startIdx + START.length, endIdx).trim();
759
- }
760
715
  var init_extract_sentinel_output = __esm({
761
716
  "packages/experience-design-system-generation/dist/src/services/agent/helpers/extract-sentinel-output.js"() {
762
717
  "use strict";
@@ -781,7 +736,7 @@ async function runAgent(options) {
781
736
  promptLen: prompt.length,
782
737
  promptHead: prompt.slice(0, 500)
783
738
  });
784
- return new Promise((resolve21) => {
739
+ return new Promise((resolve20) => {
785
740
  const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
786
741
  const child = spawn(binary, args, {
787
742
  stdio: ["pipe", "pipe", "pipe"],
@@ -830,7 +785,7 @@ async function runAgent(options) {
830
785
  stderrLen: stderr.length,
831
786
  stderrTail: stderr.slice(-1e3)
832
787
  });
833
- resolve21(result);
788
+ resolve20(result);
834
789
  });
835
790
  });
836
791
  }
@@ -847,7 +802,7 @@ var init_run_agent = __esm({
847
802
  // packages/experience-design-system-generation/dist/src/services/agent/helpers/check-claude-auth.js
848
803
  import { spawn as spawn2 } from "node:child_process";
849
804
  function checkClaudeAuth(binary) {
850
- return new Promise((resolve21) => {
805
+ return new Promise((resolve20) => {
851
806
  const child = spawn2(binary, ["auth", "status", "--json"], {
852
807
  stdio: ["ignore", "pipe", "pipe"]
853
808
  });
@@ -857,7 +812,7 @@ function checkClaudeAuth(binary) {
857
812
  if (!done) {
858
813
  done = true;
859
814
  child.kill("SIGTERM");
860
- resolve21("unauthenticated");
815
+ resolve20("unauthenticated");
861
816
  }
862
817
  }, 5e3);
863
818
  child.stdout?.on("data", (chunk) => {
@@ -869,14 +824,14 @@ function checkClaudeAuth(binary) {
869
824
  done = true;
870
825
  clearTimeout(timer);
871
826
  if (code !== 0) {
872
- resolve21("unauthenticated");
827
+ resolve20("unauthenticated");
873
828
  return;
874
829
  }
875
830
  try {
876
831
  const status = JSON.parse(stdout);
877
- resolve21(status.loggedIn ? "ok" : "unauthenticated");
832
+ resolve20(status.loggedIn ? "ok" : "unauthenticated");
878
833
  } catch {
879
- resolve21("unauthenticated");
834
+ resolve20("unauthenticated");
880
835
  }
881
836
  });
882
837
  });
@@ -891,13 +846,13 @@ var init_check_claude_auth = __esm({
891
846
  import { spawn as spawn3 } from "node:child_process";
892
847
  async function checkAgentAuth(agent) {
893
848
  const binary = resolveAgentBinary(agent);
894
- const binaryExists2 = await new Promise((resolve21) => {
849
+ const binaryExists2 = await new Promise((resolve20) => {
895
850
  if (binary.startsWith("/")) {
896
- import("node:fs/promises").then((fs2) => fs2.access(binary).then(() => resolve21(true), () => resolve21(false)));
851
+ import("node:fs/promises").then((fs2) => fs2.access(binary).then(() => resolve20(true), () => resolve20(false)));
897
852
  return;
898
853
  }
899
854
  const child = spawn3(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
900
- child.on("close", (code) => resolve21(code === 0));
855
+ child.on("close", (code) => resolve20(code === 0));
901
856
  });
902
857
  if (!binaryExists2)
903
858
  return "not-found";
@@ -934,20 +889,6 @@ var init_local_cli_agent_invoker = __esm({
934
889
  });
935
890
 
936
891
  // packages/experience-design-system-generation/dist/src/controller/create-generation-endpoint.js
937
- function createGenerationEndpoint(options = {}) {
938
- const invoker2 = createLocalCliAgentInvoker({
939
- onDebugEvent: options.onDebugEvent
940
- });
941
- return {
942
- async run(request2) {
943
- validateGenerationRequest(request2);
944
- return executeGenerationOrchestrator({ ...request2, invoker: invoker2 });
945
- },
946
- checkAuth(agent) {
947
- return invoker2.checkAuth(agent);
948
- }
949
- };
950
- }
951
892
  var init_create_generation_endpoint = __esm({
952
893
  "packages/experience-design-system-generation/dist/src/controller/create-generation-endpoint.js"() {
953
894
  "use strict";
@@ -1332,32 +1273,6 @@ var init_progress = __esm({
1332
1273
  });
1333
1274
 
1334
1275
  // packages/experience-design-system-generation/dist/src/index.js
1335
- var src_exports = {};
1336
- __export(src_exports, {
1337
- AGENT_BINARIES: () => AGENT_BINARIES,
1338
- AGENT_NAMES: () => AGENT_NAMES,
1339
- DEFAULT_AGENT_NAME: () => DEFAULT_AGENT_NAME,
1340
- agentSupportsBedrock: () => agentSupportsBedrock,
1341
- buildArgs: () => buildAgentArgs,
1342
- buildPrompt: () => buildPrompt,
1343
- checkAgentAuth: () => checkAgentAuth,
1344
- createGenerationEndpoint: () => createGenerationEndpoint,
1345
- createLocalCliAgentInvoker: () => createLocalCliAgentInvoker,
1346
- describeAgentFailure: () => describeAgentFailure,
1347
- executeGenerationOrchestrator: () => executeGenerationOrchestrator,
1348
- extractSentinelOutput: () => extractSentinelOutput,
1349
- formatCustomPromptBanner: () => formatCustomPromptBanner,
1350
- formatGenerateProgressLine: () => formatGenerateProgressLine,
1351
- isAgentName: () => isAgentName,
1352
- parseMapTokenPropToolCallLines: () => parseMapTokenPropToolCallLines,
1353
- parseSelectToolCallLines: () => parseSelectToolCallLines,
1354
- parseTokenToolCallLines: () => parseTokenToolCallLines,
1355
- parseToolCallLines: () => parsePropToolCallLines,
1356
- resolveAgentModel: () => resolveAgentModel,
1357
- resolveBinary: () => resolveAgentBinary,
1358
- resolveSkillPath: () => resolveSkillPath,
1359
- runAgent: () => runAgent
1360
- });
1361
1276
  var init_src = __esm({
1362
1277
  "packages/experience-design-system-generation/dist/src/index.js"() {
1363
1278
  "use strict";
@@ -10365,41 +10280,6 @@ var init_read3 = __esm({
10365
10280
  }
10366
10281
  });
10367
10282
 
10368
- // packages/experience-design-system-cli-legacy/src/session/core/components/hash-component-shape.ts
10369
- import { createHash as createHash2 } from "node:crypto";
10370
- function hashComponentShape(component) {
10371
- const payload = {
10372
- framework: component.framework,
10373
- name: component.name,
10374
- source: component.source,
10375
- props: component.props.map((p) => ({
10376
- name: p.name,
10377
- type: p.type
10378
- })),
10379
- slots: component.slots.map((s) => ({
10380
- name: s.name,
10381
- isDefault: s.isDefault
10382
- }))
10383
- };
10384
- return createHash2("sha256").update(JSON.stringify(payload)).digest("hex");
10385
- }
10386
- var init_hash_component_shape = __esm({
10387
- "packages/experience-design-system-cli-legacy/src/session/core/components/hash-component-shape.ts"() {
10388
- "use strict";
10389
- }
10390
- });
10391
-
10392
- // packages/experience-design-system-cli-legacy/src/session/core/tokens/hash-token-content.ts
10393
- import { createHash as createHash3 } from "node:crypto";
10394
- function hashTokenContent(rawTokenContent) {
10395
- return createHash3("sha256").update(rawTokenContent.trim()).digest("hex");
10396
- }
10397
- var init_hash_token_content = __esm({
10398
- "packages/experience-design-system-cli-legacy/src/session/core/tokens/hash-token-content.ts"() {
10399
- "use strict";
10400
- }
10401
- });
10402
-
10403
10283
  // packages/experience-design-system-cli-legacy/src/session/repositories/tokens/write.ts
10404
10284
  function deleteRawTokensForSession(db, sessionId2) {
10405
10285
  db.prepare("DELETE FROM raw_token_groups WHERE session_id = ?").run(sessionId2);
@@ -10563,47 +10443,17 @@ var init_replace_raw_prop_token_paths = __esm({
10563
10443
  }
10564
10444
  });
10565
10445
 
10566
- // packages/experience-design-system-cli-legacy/src/session/cache-keys.ts
10567
- var cache_keys_exports = {};
10568
- __export(cache_keys_exports, {
10569
- hashContent: () => hashContent,
10570
- hashFile: () => hashFile,
10571
- hashPromptForSkill: () => hashPromptForSkill
10572
- });
10573
- import { createHash as createHash4 } from "node:crypto";
10574
- import { readFile as readFile7 } from "node:fs/promises";
10575
- import { resolve as resolve8 } from "node:path";
10576
- function hashContent(content) {
10577
- return createHash4("sha256").update(content).digest("hex");
10578
- }
10579
- async function hashFile(filePath) {
10580
- const content = await readFile7(filePath, "utf8");
10581
- return hashContent(content);
10582
- }
10583
- async function hashPromptForSkill(skill, agent, model, skillPathOverride, extraInputs = [], skillContentOverride) {
10584
- const promptHash = skillContentOverride ? hashContent(skillContentOverride) : skillPathOverride ? await hashFile(resolve8(skillPathOverride)) : await hashFile(resolveSkillPath(skill));
10585
- const extraSegment = extraInputs.length > 0 ? `|${extraInputs.join("|")}` : "";
10586
- return hashContent(`${promptHash}|${agent}|${model ?? ""}${extraSegment}`);
10587
- }
10588
- var init_cache_keys = __esm({
10589
- "packages/experience-design-system-cli-legacy/src/session/cache-keys.ts"() {
10590
- "use strict";
10591
- init_src();
10592
- }
10593
- });
10594
-
10595
10446
  // packages/experience-design-system-cli-legacy/src/session/db.ts
10596
10447
  import { DatabaseSync } from "node:sqlite";
10597
10448
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync5 } from "node:fs";
10598
- import { readFile as readFile8 } from "node:fs/promises";
10599
- import { createHash as createHash5 } from "node:crypto";
10449
+ import { readFile as readFile7 } from "node:fs/promises";
10600
10450
  import { homedir as homedir3 } from "node:os";
10601
- import { dirname as dirname14, resolve as resolve9 } from "node:path";
10451
+ import { dirname as dirname14, resolve as resolve8 } from "node:path";
10602
10452
  function getPipelineDbPath() {
10603
10453
  if (process.env.EDS_PIPELINE_DB_PATH) {
10604
- return resolve9(process.env.EDS_PIPELINE_DB_PATH);
10454
+ return resolve8(process.env.EDS_PIPELINE_DB_PATH);
10605
10455
  }
10606
- return resolve9(homedir3(), ".contentful", "experience-design-system-cli", "pipeline.db");
10456
+ return resolve8(homedir3(), ".contentful", "experience-design-system-cli", "pipeline.db");
10607
10457
  }
10608
10458
  function openPipelineDb(dbPath) {
10609
10459
  const path = dbPath ?? getPipelineDbPath();
@@ -10737,134 +10587,8 @@ function applyDbMigrations(db) {
10737
10587
  if (!rawSlotColsForRationale.some((c2) => c2.name === "rationale")) {
10738
10588
  db.exec("ALTER TABLE raw_slots ADD COLUMN rationale TEXT");
10739
10589
  }
10740
- const hasExtractCache = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='extract_cache'`).all();
10741
- if (hasExtractCache.length === 0) {
10742
- db.exec(`
10743
- CREATE TABLE extract_cache (
10744
- file_path TEXT NOT NULL,
10745
- file_hash TEXT NOT NULL,
10746
- cli_version TEXT NOT NULL,
10747
- created_at TEXT NOT NULL,
10748
- updated_at TEXT NOT NULL,
10749
- components_json TEXT NOT NULL,
10750
- PRIMARY KEY (file_hash, cli_version)
10751
- );
10752
- CREATE INDEX idx_extract_cache_file ON extract_cache(file_path);
10753
- `);
10754
- }
10755
- const hasSelectCache = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='select_cache'`).all();
10756
- if (hasSelectCache.length === 0) {
10757
- db.exec(`
10758
- CREATE TABLE select_cache (
10759
- component_hash TEXT NOT NULL,
10760
- prompt_hash TEXT NOT NULL,
10761
- cli_version TEXT NOT NULL,
10762
- decision TEXT NOT NULL CHECK (decision IN ('accepted','rejected')),
10763
- reason TEXT,
10764
- created_at TEXT NOT NULL,
10765
- updated_at TEXT NOT NULL,
10766
- PRIMARY KEY (component_hash, prompt_hash, cli_version)
10767
- );
10768
- `);
10769
- }
10770
- const tables = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='generation_cache'`).all();
10771
- if (tables.length === 0) {
10772
- db.exec(`
10773
- CREATE TABLE generation_cache (
10774
- input_hash TEXT NOT NULL,
10775
- entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
10776
- entity_id TEXT NOT NULL,
10777
- source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
10778
- human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
10779
- created_at TEXT NOT NULL,
10780
- updated_at TEXT NOT NULL,
10781
- PRIMARY KEY (input_hash, entity_type, entity_id)
10782
- );
10783
- CREATE INDEX idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
10784
- CREATE INDEX idx_generation_cache_session ON generation_cache(source_session_id);
10785
- `);
10786
- }
10787
- const genCacheCols = db.prepare(`PRAGMA table_info(generation_cache)`).all();
10788
- const hasPromptHash = genCacheCols.some((c2) => c2.name === "prompt_hash");
10789
- const oldPkCols = genCacheCols.filter((c2) => c2.pk > 0).map((c2) => c2.name);
10790
- const promptHashInPk = oldPkCols.includes("prompt_hash");
10791
- if (!hasPromptHash) {
10792
- db.exec(`ALTER TABLE generation_cache ADD COLUMN prompt_hash TEXT NOT NULL DEFAULT ''`);
10793
- }
10794
- if (!promptHashInPk) {
10795
- db.exec("BEGIN");
10796
- try {
10797
- db.exec(`
10798
- CREATE TABLE generation_cache__new (
10799
- input_hash TEXT NOT NULL,
10800
- entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
10801
- entity_id TEXT NOT NULL,
10802
- source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
10803
- human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
10804
- created_at TEXT NOT NULL,
10805
- updated_at TEXT NOT NULL,
10806
- prompt_hash TEXT NOT NULL DEFAULT '',
10807
- PRIMARY KEY (input_hash, prompt_hash, entity_type, entity_id)
10808
- );
10809
- INSERT INTO generation_cache__new
10810
- (input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash)
10811
- SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
10812
- FROM generation_cache;
10813
- DROP TABLE generation_cache;
10814
- ALTER TABLE generation_cache__new RENAME TO generation_cache;
10815
- CREATE INDEX IF NOT EXISTS idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
10816
- CREATE INDEX IF NOT EXISTS idx_generation_cache_session ON generation_cache(source_session_id);
10817
- `);
10818
- db.exec("COMMIT");
10819
- } catch (e) {
10820
- db.exec("ROLLBACK");
10821
- throw e;
10822
- }
10823
- }
10824
- const genCacheTableSql = db.prepare(`SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'generation_cache'`).get();
10825
- const hasTokenMappingEntityType = genCacheTableSql?.sql.includes("'token_mapping'") ?? true;
10826
- if (!hasTokenMappingEntityType) {
10827
- db.exec("BEGIN");
10828
- try {
10829
- db.exec(`
10830
- CREATE TABLE generation_cache__new2 (
10831
- input_hash TEXT NOT NULL,
10832
- entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
10833
- entity_id TEXT NOT NULL,
10834
- source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
10835
- human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
10836
- created_at TEXT NOT NULL,
10837
- updated_at TEXT NOT NULL,
10838
- prompt_hash TEXT NOT NULL DEFAULT '',
10839
- PRIMARY KEY (input_hash, prompt_hash, entity_type, entity_id)
10840
- );
10841
- INSERT INTO generation_cache__new2
10842
- (input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash)
10843
- SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
10844
- FROM generation_cache;
10845
- DROP TABLE generation_cache;
10846
- ALTER TABLE generation_cache__new2 RENAME TO generation_cache;
10847
- CREATE INDEX IF NOT EXISTS idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
10848
- CREATE INDEX IF NOT EXISTS idx_generation_cache_session ON generation_cache(source_session_id);
10849
- `);
10850
- db.exec("COMMIT");
10851
- } catch (e) {
10852
- db.exec("ROLLBACK");
10853
- throw e;
10854
- }
10855
- }
10856
- const hasCompositionCache = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='composition_cache'`).all();
10857
- if (hasCompositionCache.length === 0) {
10858
- db.exec(`
10859
- CREATE TABLE composition_cache (
10860
- input_hash TEXT NOT NULL,
10861
- cli_version TEXT NOT NULL,
10862
- agent_output TEXT NOT NULL,
10863
- created_at TEXT NOT NULL,
10864
- updated_at TEXT NOT NULL,
10865
- PRIMARY KEY (input_hash, cli_version)
10866
- );
10867
- `);
10590
+ for (const table of REMOVED_CACHE_TABLES) {
10591
+ db.exec(`DROP TABLE IF EXISTS ${table}`);
10868
10592
  }
10869
10593
  }
10870
10594
  function loadComponentReviewMetadata(db, sessionId2, componentName) {
@@ -11404,16 +11128,16 @@ function extractRelativeImportPaths(sourceText) {
11404
11128
  return [...specifiers];
11405
11129
  }
11406
11130
  async function resolveRelativeImport(specifier, fromDir) {
11407
- const basePath = resolve9(fromDir, specifier);
11131
+ const basePath = resolve8(fromDir, specifier);
11408
11132
  const candidates = [
11409
11133
  basePath,
11410
11134
  ...rewrittenSourcePaths(basePath),
11411
11135
  ...SIBLING_FILE_EXTENSIONS.map((ext) => `${basePath}${ext}`),
11412
- ...SIBLING_FILE_EXTENSIONS.map((ext) => resolve9(basePath, `index${ext}`))
11136
+ ...SIBLING_FILE_EXTENSIONS.map((ext) => resolve8(basePath, `index${ext}`))
11413
11137
  ];
11414
11138
  for (const candidate of candidates) {
11415
11139
  try {
11416
- await readFile8(candidate, "utf8");
11140
+ await readFile7(candidate, "utf8");
11417
11141
  return candidate;
11418
11142
  } catch {
11419
11143
  }
@@ -11429,7 +11153,7 @@ async function resolveImportSpecifiers(sourceText, fromDir) {
11429
11153
  return resolvedPaths;
11430
11154
  }
11431
11155
  async function loadSiblingFiles(sourceText, sourcePath, propNames, candidateTypeNames = []) {
11432
- const visited = /* @__PURE__ */ new Set([resolve9(sourcePath)]);
11156
+ const visited = /* @__PURE__ */ new Set([resolve8(sourcePath)]);
11433
11157
  const discovered = [];
11434
11158
  let frontier = [{ text: sourceText, dir: dirname14(sourcePath) }];
11435
11159
  for (let hop = 0; hop < MAX_SIBLING_DEPTH && discovered.length < MAX_SIBLING_CANDIDATES_EXPLORED; hop++) {
@@ -11443,7 +11167,7 @@ async function loadSiblingFiles(sourceText, sourcePath, propNames, candidateType
11443
11167
  if (discovered.length >= MAX_SIBLING_CANDIDATES_EXPLORED) break;
11444
11168
  let content;
11445
11169
  try {
11446
- content = await readFile8(resolvedPath, "utf8");
11170
+ content = await readFile7(resolvedPath, "utf8");
11447
11171
  } catch {
11448
11172
  continue;
11449
11173
  }
@@ -11480,7 +11204,7 @@ async function loadComponentSourceRef(name, sourcePath, propNames = [], propType
11480
11204
  let truncatedSiblingCount = 0;
11481
11205
  const usesNotShown = /* @__PURE__ */ new Set();
11482
11206
  try {
11483
- const rawText = await readFile8(sourcePath, "utf8");
11207
+ const rawText = await readFile7(sourcePath, "utf8");
11484
11208
  let siblingUsesNotShown;
11485
11209
  let declaredTypeNames;
11486
11210
  ({
@@ -11916,108 +11640,6 @@ function backfillUnclassifiedProps(db, sessionId2) {
11916
11640
  ).run(sessionId2, sessionId2);
11917
11641
  return Number(withCategory.changes) + Number(withoutCategory.changes);
11918
11642
  }
11919
- function computeMapTokensInputHash(db, sessionId2, componentSourceRefs = []) {
11920
- const props = db.prepare(
11921
- `SELECT rc.name AS component_name, rp.name AS prop_name, rp.cdf_token_kind, rp.default_value
11922
- FROM raw_props rp
11923
- JOIN raw_components rc ON rc.session_id = rp.session_id AND rc.component_id = rp.component_id
11924
- WHERE rp.session_id = ? AND rp.cdf_type = 'token' AND rp.cdf_category = 'design'
11925
- ORDER BY rc.name, rp.name`
11926
- ).all(sessionId2);
11927
- const tokens = db.prepare(`SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path`).all(sessionId2);
11928
- const defaultMappings = db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId2);
11929
- const payload = {
11930
- props: props.map((p) => ({
11931
- component: p.component_name,
11932
- prop: p.prop_name,
11933
- tokenKind: p.cdf_token_kind,
11934
- rawDefault: p.default_value
11935
- })),
11936
- tokens,
11937
- defaultMappings,
11938
- // The agent's evidence, not just its inputs: a comment or allowlist edit
11939
- // in a source file (or a sibling it reads) changes the correct answer
11940
- // without touching props or tokens, so it must invalidate the cache too.
11941
- sourceRefs: [...componentSourceRefs].sort((a, b) => a.component.localeCompare(b.component)).map((ref) => ({
11942
- component: ref.component,
11943
- content: ref.content,
11944
- siblingFiles: (ref.siblingFiles ?? []).map((s) => ({ path: s.path, content: s.content })).sort((a, b) => a.path.localeCompare(b.path)),
11945
- usesNotShown: [...ref.usesNotShown ?? []].sort()
11946
- }))
11947
- };
11948
- return createHash5("sha256").update(JSON.stringify(payload)).digest("hex");
11949
- }
11950
- function lookupCache(db, inputHash, entityType, entityId, promptHash = "") {
11951
- const row = db.prepare(
11952
- `SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
11953
- FROM generation_cache
11954
- WHERE input_hash = ? AND entity_type = ? AND entity_id = ? AND prompt_hash = ?`
11955
- ).get(inputHash, entityType, entityId, promptHash);
11956
- if (!row) return null;
11957
- return {
11958
- inputHash: row.input_hash,
11959
- entityType: row.entity_type,
11960
- entityId: row.entity_id,
11961
- sourceSessionId: row.source_session_id,
11962
- humanEdited: row.human_edited === 1,
11963
- promptHash: row.prompt_hash,
11964
- createdAt: row.created_at,
11965
- updatedAt: row.updated_at
11966
- };
11967
- }
11968
- function lookupCacheByEntity(db, entityType, entityId) {
11969
- const row = db.prepare(
11970
- `SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
11971
- FROM generation_cache
11972
- WHERE entity_type = ? AND entity_id = ?
11973
- ORDER BY updated_at DESC LIMIT 1`
11974
- ).get(entityType, entityId);
11975
- if (!row) return null;
11976
- return {
11977
- inputHash: row.input_hash,
11978
- entityType: row.entity_type,
11979
- entityId: row.entity_id,
11980
- sourceSessionId: row.source_session_id,
11981
- humanEdited: row.human_edited === 1,
11982
- promptHash: row.prompt_hash,
11983
- createdAt: row.created_at,
11984
- updatedAt: row.updated_at
11985
- };
11986
- }
11987
- function storeCache(db, inputHash, entityType, entityId, sourceSessionId, humanEdited, promptHash = "") {
11988
- storeCaches(db, [{ inputHash, entityType, entityId, sourceSessionId, humanEdited, promptHash }]);
11989
- }
11990
- function storeCaches(db, entries) {
11991
- if (entries.length === 0) return;
11992
- const now = (/* @__PURE__ */ new Date()).toISOString();
11993
- const insert = db.prepare(
11994
- `INSERT INTO generation_cache (input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash)
11995
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
11996
- ON CONFLICT(input_hash, prompt_hash, entity_type, entity_id) DO UPDATE SET
11997
- source_session_id = excluded.source_session_id,
11998
- human_edited = CASE WHEN generation_cache.human_edited = 1 THEN 1 ELSE excluded.human_edited END,
11999
- updated_at = excluded.updated_at`
12000
- );
12001
- db.exec("BEGIN");
12002
- try {
12003
- for (const entry of entries) {
12004
- insert.run(
12005
- entry.inputHash,
12006
- entry.entityType,
12007
- entry.entityId,
12008
- entry.sourceSessionId,
12009
- entry.humanEdited ? 1 : 0,
12010
- now,
12011
- now,
12012
- entry.promptHash ?? ""
12013
- );
12014
- }
12015
- db.exec("COMMIT");
12016
- } catch (e) {
12017
- db.exec("ROLLBACK");
12018
- throw e;
12019
- }
12020
- }
12021
11643
  function storeScannedFiles(db, sessionId2, filePaths) {
12022
11644
  db.exec("BEGIN");
12023
11645
  try {
@@ -12100,105 +11722,7 @@ function filterUnknownSlotAllowedComponents(db, sessionId2, allowedComponentName
12100
11722
  }
12101
11723
  return unknown;
12102
11724
  }
12103
- function copyComponentFromCache(db, sourceSessionId, targetSessionId, componentId, manageTransaction = true, options = {}) {
12104
- const now = (/* @__PURE__ */ new Date()).toISOString();
12105
- if (manageTransaction) db.exec("BEGIN");
12106
- try {
12107
- const srcComp = db.prepare(
12108
- `SELECT description, status, component_description_rationale, props_rationale, slots_rationale
12109
- FROM raw_components WHERE session_id = ? AND component_id = ?`
12110
- ).get(sourceSessionId, componentId);
12111
- if (srcComp) {
12112
- db.prepare(
12113
- `UPDATE raw_components
12114
- SET description = ?, status = ?, component_description_rationale = ?, props_rationale = ?, slots_rationale = ?, extracted_at = ?
12115
- WHERE session_id = ? AND component_id = ?`
12116
- ).run(
12117
- srcComp.description,
12118
- srcComp.status,
12119
- srcComp.component_description_rationale,
12120
- srcComp.props_rationale,
12121
- srcComp.slots_rationale,
12122
- now,
12123
- targetSessionId,
12124
- componentId
12125
- );
12126
- }
12127
- const srcProps = db.prepare(
12128
- `SELECT name, cdf_type, cdf_category, cdf_token_kind, required, description, default_value, rationale
12129
- FROM raw_props WHERE session_id = ? AND component_id = ?`
12130
- ).all(sourceSessionId, componentId);
12131
- for (const p of srcProps) {
12132
- db.prepare(
12133
- `UPDATE raw_props SET cdf_type = ?, cdf_category = ?, cdf_token_kind = ?, required = ?, description = ?, default_value = ?, rationale = ?
12134
- WHERE session_id = ? AND component_id = ? AND name = ?`
12135
- ).run(
12136
- p.cdf_type,
12137
- p.cdf_category,
12138
- p.cdf_token_kind,
12139
- p.required,
12140
- p.description,
12141
- p.default_value,
12142
- p.rationale,
12143
- targetSessionId,
12144
- componentId,
12145
- p.name
12146
- );
12147
- }
12148
- db.prepare(`DELETE FROM raw_prop_allowed_values WHERE session_id = ? AND component_id = ?`).run(
12149
- targetSessionId,
12150
- componentId
12151
- );
12152
- const srcAV = db.prepare(
12153
- `SELECT prop_name, position, value FROM raw_prop_allowed_values WHERE session_id = ? AND component_id = ?`
12154
- ).all(sourceSessionId, componentId);
12155
- const insertAV = db.prepare(
12156
- `INSERT INTO raw_prop_allowed_values (session_id, component_id, prop_name, position, value) VALUES (?, ?, ?, ?, ?)`
12157
- );
12158
- for (const av of srcAV) {
12159
- insertAV.run(targetSessionId, componentId, av.prop_name, av.position, av.value);
12160
- }
12161
- const srcSlots = db.prepare(`SELECT name, required, description, rationale FROM raw_slots WHERE session_id = ? AND component_id = ?`).all(sourceSessionId, componentId);
12162
- for (const s of srcSlots) {
12163
- db.prepare(
12164
- `UPDATE raw_slots SET required = ?, description = ?, rationale = ? WHERE session_id = ? AND component_id = ? AND name = ?`
12165
- ).run(s.required, s.description, s.rationale, targetSessionId, componentId, s.name);
12166
- }
12167
- db.prepare(`DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ?`).run(
12168
- targetSessionId,
12169
- componentId
12170
- );
12171
- const srcSAC = db.prepare(
12172
- `SELECT slot_name, position, allowed_component FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ?`
12173
- ).all(sourceSessionId, componentId);
12174
- const insertSAC = db.prepare(
12175
- `INSERT INTO raw_slot_allowed_components (session_id, component_id, slot_name, allowed_component, position) VALUES (?, ?, ?, ?, ?)`
12176
- );
12177
- const allowedSAC = options.allowedComponentNames ? srcSAC.filter((sac) => options.allowedComponentNames.has(sac.allowed_component)) : srcSAC;
12178
- for (const sac of allowedSAC) {
12179
- insertSAC.run(targetSessionId, componentId, sac.slot_name, sac.allowed_component, sac.position);
12180
- }
12181
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, targetSessionId);
12182
- if (manageTransaction) db.exec("COMMIT");
12183
- } catch (e) {
12184
- if (manageTransaction) db.exec("ROLLBACK");
12185
- throw e;
12186
- }
12187
- }
12188
- function copyComponentsFromCache(db, entries, options = {}) {
12189
- if (entries.length === 0) return;
12190
- db.exec("BEGIN");
12191
- try {
12192
- for (const entry of entries) {
12193
- copyComponentFromCache(db, entry.sourceSessionId, entry.targetSessionId, entry.componentId, false, options);
12194
- }
12195
- db.exec("COMMIT");
12196
- } catch (e) {
12197
- db.exec("ROLLBACK");
12198
- throw e;
12199
- }
12200
- }
12201
- function copyTokensFromCache(db, sourceSessionId, targetSessionId) {
11725
+ function copyTokensBetweenSessions(db, sourceSessionId, targetSessionId) {
12202
11726
  const now = (/* @__PURE__ */ new Date()).toISOString();
12203
11727
  db.exec("BEGIN");
12204
11728
  try {
@@ -12219,139 +11743,7 @@ function copyTokensFromCache(db, sourceSessionId, targetSessionId) {
12219
11743
  throw e;
12220
11744
  }
12221
11745
  }
12222
- function copyMapTokensFromCache(db, sourceSessionId, targetSessionId) {
12223
- const now = (/* @__PURE__ */ new Date()).toISOString();
12224
- let copiedCount = 0;
12225
- db.exec("BEGIN");
12226
- try {
12227
- const sourceRows = db.prepare(
12228
- `SELECT rc.name AS component_name, rptp.prop_name, rptp.source, rptp.position, rptp.path
12229
- FROM raw_prop_token_paths rptp
12230
- JOIN raw_components rc ON rc.session_id = rptp.session_id AND rc.component_id = rptp.component_id
12231
- WHERE rptp.session_id = ?
12232
- ORDER BY rc.name, rptp.prop_name, rptp.position`
12233
- ).all(sourceSessionId);
12234
- const targetComponents = db.prepare(`SELECT component_id, name FROM raw_components WHERE session_id = ?`).all(targetSessionId);
12235
- const targetIdByName = new Map(targetComponents.map((c2) => [c2.name, c2.component_id]));
12236
- const targetProps = new Set(
12237
- db.prepare(`SELECT component_id, name FROM raw_props WHERE session_id = ?`).all(targetSessionId).map((p) => `${p.component_id}::${p.name}`)
12238
- );
12239
- const insertPath = db.prepare(
12240
- `INSERT INTO raw_prop_token_paths (session_id, component_id, prop_name, source, position, path)
12241
- VALUES (?, ?, ?, ?, ?, ?)`
12242
- );
12243
- const clearedProps = /* @__PURE__ */ new Set();
12244
- const copiedProps = /* @__PURE__ */ new Set();
12245
- for (const row of sourceRows) {
12246
- const targetComponentId = targetIdByName.get(row.component_name);
12247
- if (!targetComponentId) continue;
12248
- if (!targetProps.has(`${targetComponentId}::${row.prop_name}`)) continue;
12249
- const propKey = `${targetComponentId}::${row.prop_name}`;
12250
- if (!clearedProps.has(propKey)) {
12251
- clearedProps.add(propKey);
12252
- db.prepare(`DELETE FROM raw_prop_token_paths WHERE session_id = ? AND component_id = ? AND prop_name = ?`).run(
12253
- targetSessionId,
12254
- targetComponentId,
12255
- row.prop_name
12256
- );
12257
- }
12258
- insertPath.run(targetSessionId, targetComponentId, row.prop_name, row.source, row.position, row.path);
12259
- copiedProps.add(propKey);
12260
- }
12261
- copiedCount = copiedProps.size;
12262
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, targetSessionId);
12263
- db.exec("COMMIT");
12264
- } catch (e) {
12265
- db.exec("ROLLBACK");
12266
- throw e;
12267
- }
12268
- return copiedCount;
12269
- }
12270
- async function getCliCacheVersion() {
12271
- if (_cliCacheVersionCache) return _cliCacheVersionCache;
12272
- try {
12273
- const { hashContent: hashContent2 } = await Promise.resolve().then(() => (init_cache_keys(), cache_keys_exports));
12274
- const { resolveSkillPath: resolveSkillPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
12275
- const skills = ["components", "tokens", "select"];
12276
- const parts = [];
12277
- for (const s of skills) {
12278
- try {
12279
- const p = resolveSkillPath2(s);
12280
- parts.push(readFileSync5(p, "utf8"));
12281
- } catch {
12282
- parts.push(`<missing:${s}>`);
12283
- }
12284
- }
12285
- _cliCacheVersionCache = hashContent2(parts.join("\n---\n"));
12286
- return _cliCacheVersionCache;
12287
- } catch {
12288
- _cliCacheVersionCache = "fallback";
12289
- return _cliCacheVersionCache;
12290
- }
12291
- }
12292
- function storeExtractCache(db, filePath, fileHash, cliVersion2, components) {
12293
- const now = (/* @__PURE__ */ new Date()).toISOString();
12294
- const componentsJson = JSON.stringify(components);
12295
- db.prepare(
12296
- `INSERT INTO extract_cache (file_path, file_hash, cli_version, created_at, updated_at, components_json)
12297
- VALUES (?, ?, ?, ?, ?, ?)
12298
- ON CONFLICT(file_hash, cli_version) DO UPDATE SET
12299
- file_path = excluded.file_path,
12300
- updated_at = excluded.updated_at,
12301
- components_json = excluded.components_json`
12302
- ).run(filePath, fileHash, cliVersion2, now, now, componentsJson);
12303
- }
12304
- function lookupExtractCache(db, fileHash, cliVersion2) {
12305
- const row = db.prepare(
12306
- `SELECT file_path, file_hash, cli_version, created_at, updated_at, components_json
12307
- FROM extract_cache
12308
- WHERE file_hash = ? AND cli_version = ?`
12309
- ).get(fileHash, cliVersion2);
12310
- if (!row) return null;
12311
- let components = [];
12312
- try {
12313
- components = JSON.parse(row.components_json);
12314
- } catch {
12315
- return null;
12316
- }
12317
- return {
12318
- filePath: row.file_path,
12319
- fileHash: row.file_hash,
12320
- cliVersion: row.cli_version,
12321
- createdAt: row.created_at,
12322
- updatedAt: row.updated_at,
12323
- components
12324
- };
12325
- }
12326
- function storeSelectCache(db, componentHash, promptHash, cliVersion2, decision, reason) {
12327
- const now = (/* @__PURE__ */ new Date()).toISOString();
12328
- db.prepare(
12329
- `INSERT INTO select_cache (component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at)
12330
- VALUES (?, ?, ?, ?, ?, ?, ?)
12331
- ON CONFLICT(component_hash, prompt_hash, cli_version) DO UPDATE SET
12332
- decision = excluded.decision,
12333
- reason = excluded.reason,
12334
- updated_at = excluded.updated_at`
12335
- ).run(componentHash, promptHash, cliVersion2, decision, reason, now, now);
12336
- }
12337
- function lookupSelectCache(db, componentHash, promptHash, cliVersion2) {
12338
- const row = db.prepare(
12339
- `SELECT component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at
12340
- FROM select_cache
12341
- WHERE component_hash = ? AND prompt_hash = ? AND cli_version = ?`
12342
- ).get(componentHash, promptHash, cliVersion2);
12343
- if (!row) return null;
12344
- return {
12345
- componentHash: row.component_hash,
12346
- promptHash: row.prompt_hash,
12347
- cliVersion: row.cli_version,
12348
- decision: row.decision,
12349
- reason: row.reason,
12350
- createdAt: row.created_at,
12351
- updatedAt: row.updated_at
12352
- };
12353
- }
12354
- var SCHEMA, MAX_COMPONENT_SOURCE_CHARS, MAX_SIBLING_FILES, MAX_SIBLING_SNIPPET_CHARS, MAX_TYPE_DECLARING_SIBLING_CHARS, MAX_ENLARGED_SIBLINGS, MAX_SIBLING_DEPTH, MAX_SIBLING_CANDIDATES_EXPLORED, RELATIVE_IMPORT_PATTERN, SIBLING_FILE_EXTENSIONS, TS_ESM_EXTENSION_REWRITES, IDENTIFIER_PATTERN, _cliCacheVersionCache;
11746
+ var SCHEMA, REMOVED_CACHE_TABLES, MAX_COMPONENT_SOURCE_CHARS, MAX_SIBLING_FILES, MAX_SIBLING_SNIPPET_CHARS, MAX_TYPE_DECLARING_SIBLING_CHARS, MAX_ENLARGED_SIBLINGS, MAX_SIBLING_DEPTH, MAX_SIBLING_CANDIDATES_EXPLORED, RELATIVE_IMPORT_PATTERN, SIBLING_FILE_EXTENSIONS, TS_ESM_EXTENSION_REWRITES, IDENTIFIER_PATTERN;
12355
11747
  var init_db = __esm({
12356
11748
  "packages/experience-design-system-cli-legacy/src/session/db.ts"() {
12357
11749
  "use strict";
@@ -12365,8 +11757,6 @@ var init_db = __esm({
12365
11757
  init_write2();
12366
11758
  init_session_resolver();
12367
11759
  init_read3();
12368
- init_hash_component_shape();
12369
- init_hash_token_content();
12370
11760
  init_read3();
12371
11761
  init_store_dtcg_tokens();
12372
11762
  init_apply_tool_calls();
@@ -12490,17 +11880,6 @@ CREATE TABLE IF NOT EXISTS raw_tokens (
12490
11880
  FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
12491
11881
  );
12492
11882
 
12493
- CREATE TABLE IF NOT EXISTS generation_cache (
12494
- input_hash TEXT NOT NULL,
12495
- entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
12496
- entity_id TEXT NOT NULL,
12497
- source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
12498
- human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
12499
- created_at TEXT NOT NULL,
12500
- updated_at TEXT NOT NULL,
12501
- PRIMARY KEY (input_hash, entity_type, entity_id)
12502
- );
12503
-
12504
11883
  CREATE TABLE IF NOT EXISTS scanned_files (
12505
11884
  session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
12506
11885
  path TEXT NOT NULL,
@@ -12546,10 +11925,9 @@ CREATE INDEX IF NOT EXISTS idx_raw_props_session ON raw_props(session_id,
12546
11925
  CREATE INDEX IF NOT EXISTS idx_raw_slots_session ON raw_slots(session_id, component_id);
12547
11926
  CREATE INDEX IF NOT EXISTS idx_raw_tokens_session ON raw_tokens(session_id);
12548
11927
  CREATE INDEX IF NOT EXISTS idx_raw_token_groups_session ON raw_token_groups(session_id);
12549
- CREATE INDEX IF NOT EXISTS idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
12550
- CREATE INDEX IF NOT EXISTS idx_generation_cache_session ON generation_cache(source_session_id);
12551
11928
  CREATE INDEX IF NOT EXISTS idx_scanned_files_session ON scanned_files(session_id);
12552
11929
  `;
11930
+ REMOVED_CACHE_TABLES = ["generation_cache", "extract_cache", "composition_cache", "select_cache"];
12553
11931
  MAX_COMPONENT_SOURCE_CHARS = 8e3;
12554
11932
  MAX_SIBLING_FILES = 5;
12555
11933
  MAX_SIBLING_SNIPPET_CHARS = 1200;
@@ -12566,16 +11944,15 @@ CREATE INDEX IF NOT EXISTS idx_scanned_files_session ON scanned_files(session
12566
11944
  [".cjs", [".cts", ".cjs"]]
12567
11945
  ];
12568
11946
  IDENTIFIER_PATTERN = /[A-Za-z_$][A-Za-z0-9_$]*/g;
12569
- _cliCacheVersionCache = null;
12570
11947
  }
12571
11948
  });
12572
11949
 
12573
11950
  // packages/experience-design-system-cli-legacy/src/helpers/read-existing-contentful-entities-from-session.ts
12574
- import { readFile as readFile9 } from "node:fs/promises";
11951
+ import { readFile as readFile8 } from "node:fs/promises";
12575
11952
  async function readExistingContentfulEntitiesFromSession(path) {
12576
11953
  if (!path) return void 0;
12577
11954
  try {
12578
- const raw = await readFile9(path, "utf8");
11955
+ const raw = await readFile8(path, "utf8");
12579
11956
  const parsed = JSON.parse(raw);
12580
11957
  if (!Array.isArray(parsed.components) || !Array.isArray(parsed.tokens)) return void 0;
12581
11958
  return parsed;
@@ -12699,21 +12076,21 @@ var init_resolve_session_id = __esm({
12699
12076
  });
12700
12077
 
12701
12078
  // packages/experience-design-system-cli-legacy/src/analyze/select/persistence.ts
12702
- import { access, appendFile, mkdir as mkdir2, readFile as readFile10, writeFile as writeFile2 } from "node:fs/promises";
12079
+ import { access, appendFile, mkdir as mkdir2, readFile as readFile9, writeFile as writeFile2 } from "node:fs/promises";
12703
12080
  import { homedir as homedir4 } from "node:os";
12704
- import { resolve as resolve10 } from "node:path";
12081
+ import { resolve as resolve9 } from "node:path";
12705
12082
  function getRefineArtifactsRoot() {
12706
12083
  if (process.env.EDS_REVIEW_ARTIFACTS_DIR) {
12707
- return resolve10(process.env.EDS_REVIEW_ARTIFACTS_DIR);
12084
+ return resolve9(process.env.EDS_REVIEW_ARTIFACTS_DIR);
12708
12085
  }
12709
- return resolve10(homedir4(), ".contentful", "experience-design-system-cli", "reviews");
12086
+ return resolve9(homedir4(), ".contentful", "experience-design-system-cli", "reviews");
12710
12087
  }
12711
12088
  async function getRefineSessionPaths(sessionId2, artifactsRoot) {
12712
- const sessionDir = resolve10(artifactsRoot, sessionId2);
12089
+ const sessionDir = resolve9(artifactsRoot, sessionId2);
12713
12090
  return {
12714
12091
  sessionDir,
12715
- eventsPath: resolve10(sessionDir, "events.jsonl"),
12716
- statePath: resolve10(sessionDir, "current-review-state.json")
12092
+ eventsPath: resolve9(sessionDir, "events.jsonl"),
12093
+ statePath: resolve9(sessionDir, "current-review-state.json")
12717
12094
  };
12718
12095
  }
12719
12096
  async function saveReviewState(statePath, session) {
@@ -12724,7 +12101,7 @@ async function ensureRefineSession(sessionId2, artifactsRoot, initialSnapshot) {
12724
12101
  await mkdir2(paths.sessionDir, { recursive: true });
12725
12102
  try {
12726
12103
  await access(paths.statePath);
12727
- const savedState = await readFile10(paths.statePath, "utf8");
12104
+ const savedState = await readFile9(paths.statePath, "utf8");
12728
12105
  return JSON.parse(savedState);
12729
12106
  } catch {
12730
12107
  await writeFile2(paths.statePath, JSON.stringify(initialSnapshot, null, 2), "utf8");
@@ -13209,8 +12586,8 @@ var init_path_exists = __esm({
13209
12586
  });
13210
12587
 
13211
12588
  // packages/experience-design-system-cli-legacy/src/lib/prompt-overrides.ts
13212
- import { readFile as readFile11 } from "node:fs/promises";
13213
- import { resolve as resolve11 } from "node:path";
12589
+ import { readFile as readFile10 } from "node:fs/promises";
12590
+ import { resolve as resolve10 } from "node:path";
13214
12591
  function looksLikePath(value) {
13215
12592
  if (value.includes("/") || value.includes("\\")) return true;
13216
12593
  if (value.startsWith("~")) return true;
@@ -13242,9 +12619,9 @@ function parsePromptOverrides(inputs) {
13242
12619
  }
13243
12620
  async function resolvePromptOverride(override) {
13244
12621
  if (override.kind === "text") return override.value;
13245
- const abs = resolve11(override.value);
12622
+ const abs = resolve10(override.value);
13246
12623
  try {
13247
- return await readFile11(abs, "utf8");
12624
+ return await readFile10(abs, "utf8");
13248
12625
  } catch {
13249
12626
  throw new Error(`--prompt: could not read prompt file: ${abs}`);
13250
12627
  }
@@ -13259,21 +12636,21 @@ var init_prompt_overrides = __esm({
13259
12636
 
13260
12637
  // packages/experience-design-system-cli-legacy/src/generate/command.ts
13261
12638
  import { createElement } from "react";
13262
- import { readFile as readFile12, readdir, stat } from "node:fs/promises";
13263
- import { join as join14, resolve as resolve12 } from "node:path";
12639
+ import { readFile as readFile11, readdir, stat } from "node:fs/promises";
12640
+ import { join as join14, resolve as resolve11 } from "node:path";
13264
12641
  async function assertFileExists(flag, p) {
13265
12642
  if (!await pathExists(p)) die(`Error: file not found: ${p} (from ${flag})`);
13266
12643
  }
13267
12644
  async function readFileInline(path) {
13268
12645
  if (!path) return void 0;
13269
- const resolved = resolve12(path);
12646
+ const resolved = resolve11(path);
13270
12647
  let s;
13271
12648
  try {
13272
12649
  s = await stat(resolved);
13273
12650
  } catch {
13274
12651
  return void 0;
13275
12652
  }
13276
- if (!s.isDirectory()) return readFile12(resolved, "utf8");
12653
+ if (!s.isDirectory()) return readFile11(resolved, "utf8");
13277
12654
  const files = [];
13278
12655
  async function walk(dir) {
13279
12656
  let entries;
@@ -13299,7 +12676,7 @@ async function readFileInline(path) {
13299
12676
  }
13300
12677
  await walk(resolved);
13301
12678
  if (files.length === 0) return void 0;
13302
- const parts = await Promise.all(files.map((f) => readFile12(f, "utf8").catch(() => "")));
12679
+ const parts = await Promise.all(files.map((f) => readFile11(f, "utf8").catch(() => "")));
13303
12680
  return parts.filter(Boolean).join("\n\n");
13304
12681
  }
13305
12682
  function printFallbackInstructions(options) {
@@ -13321,23 +12698,6 @@ function printFallbackInstructions(options) {
13321
12698
  lines.push(` Re-run the generate command with the agent available, or use --dry-run to inspect the prompt.`);
13322
12699
  process.stderr.write(lines.join("\n") + "\n");
13323
12700
  }
13324
- function createCachedComponentResult(componentName, warnings = []) {
13325
- return {
13326
- componentName,
13327
- classified: 0,
13328
- excluded: 0,
13329
- slots: 0,
13330
- warnings,
13331
- failed: false,
13332
- cached: true,
13333
- renamedSlotsCount: 0
13334
- };
13335
- }
13336
- function writeCachedComponentStatus(position, componentName, pinned) {
13337
- const status = pinned ? c.cyan("pinned (human-edited)") : c.green("cached");
13338
- process.stderr.write(` ${position} ${c.bold(componentName)} ${status}
13339
- `);
13340
- }
13341
12701
  async function showGenerateView(result) {
13342
12702
  if (process.stdout.isTTY) {
13343
12703
  const { waitUntilExit } = renderWithGoodbye(
@@ -13358,29 +12718,6 @@ session=${result.sessionId}
13358
12718
  );
13359
12719
  await exitWithAnalytics(0);
13360
12720
  }
13361
- function normalizeComponentForCache(component) {
13362
- const slots = component.slots.map((slot, index, allSlots) => ({
13363
- ...slot,
13364
- name: slot.name.trim() || (allSlots.length === 1 ? "children" : `slot_${index}`)
13365
- }));
13366
- return { ...component, slots };
13367
- }
13368
- function lookupComponentCache(db, component, promptHash) {
13369
- const normalized = normalizeComponentForCache(component);
13370
- const inputHash = hashComponentShape(normalized);
13371
- const cached = lookupCache(db, inputHash, "component", component.component_id, promptHash);
13372
- if (cached) return cached;
13373
- const legacyInputHash = hashComponentShape(component);
13374
- return legacyInputHash === inputHash ? null : lookupCache(db, legacyInputHash, "component", component.component_id, promptHash);
13375
- }
13376
- function resolveComponentCache(db, component, promptHash, allowedComponentNames2) {
13377
- const cached = lookupComponentCache(db, component, promptHash);
13378
- if (cached && findUnknownSlotAllowedComponents(db, cached.sourceSessionId, allowedComponentNames2, component.component_id).length === 0) {
13379
- return { entry: cached, humanEdited: cached.humanEdited };
13380
- }
13381
- const pinned = lookupCacheByEntity(db, "component", component.component_id);
13382
- return pinned?.humanEdited && findUnknownSlotAllowedComponents(db, pinned.sourceSessionId, allowedComponentNames2, component.component_id).length === 0 ? { entry: pinned, humanEdited: true } : null;
13383
- }
13384
12721
  async function runOneComponent(options, component, index, total) {
13385
12722
  const {
13386
12723
  agent,
@@ -13390,13 +12727,10 @@ async function runOneComponent(options, component, index, total) {
13390
12727
  tokensInline,
13391
12728
  tokenMapInline,
13392
12729
  verbose,
13393
- noCache,
13394
12730
  skillPathOverride,
13395
12731
  skillContentOverride,
13396
- promptHash,
13397
12732
  existingContentfulEntities,
13398
12733
  existingTokensInline,
13399
- precomputedCachedNames,
13400
12734
  allowedComponentNames: allowedComponentNames2
13401
12735
  } = options;
13402
12736
  const pos = c.dim(`[${index + 1}/${total}]`);
@@ -13421,40 +12755,6 @@ async function runOneComponent(options, component, index, total) {
13421
12755
  allowedComponents: slot.allowedComponents.filter((name) => allowedComponentNames2.has(name))
13422
12756
  };
13423
12757
  });
13424
- const cacheComponent = normalizeComponentForCache(component);
13425
- if (!noCache && precomputedCachedNames.has(component.name)) {
13426
- writeCachedComponentStatus(pos, component.name, false);
13427
- return createCachedComponentResult(component.name);
13428
- }
13429
- if (!noCache) {
13430
- const inputHash = hashComponentShape(cacheComponent);
13431
- const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
13432
- if (resolution && !resolution.humanEdited) {
13433
- copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId2, component.component_id, true, {
13434
- allowedComponentNames: allowedComponentNames2
13435
- });
13436
- storeCache(
13437
- db,
13438
- inputHash,
13439
- "component",
13440
- component.component_id,
13441
- resolution.entry.sourceSessionId,
13442
- resolution.entry.humanEdited,
13443
- promptHash
13444
- );
13445
- writeCachedComponentStatus(pos, component.name, false);
13446
- return createCachedComponentResult(component.name);
13447
- }
13448
- if (resolution?.humanEdited) {
13449
- copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId2, component.component_id, true, {
13450
- allowedComponentNames: allowedComponentNames2
13451
- });
13452
- writeCachedComponentStatus(pos, component.name, true);
13453
- return createCachedComponentResult(`${component.name}`, [
13454
- `${component.name}: source changed but human edits preserved`
13455
- ]);
13456
- }
13457
- }
13458
12758
  const componentBuckets = bucketComponentProps(component);
13459
12759
  getDebugLogger().event("analyze", "prop-buckets.generate", { ...componentBuckets });
13460
12760
  const rawComponentsInline = JSON.stringify(
@@ -13529,10 +12829,6 @@ ${outputBuf}`);
13529
12829
  const applied = applyToolCalls(db, sessionId2, component.component_id, component.name, calls, warnings, {
13530
12830
  allowedComponentNames: allowedComponentNames2
13531
12831
  });
13532
- if (!noCache) {
13533
- const inputHash = hashComponentShape(cacheComponent);
13534
- storeCache(db, inputHash, "component", component.component_id, sessionId2, false, promptHash);
13535
- }
13536
12832
  return {
13537
12833
  componentName: component.name,
13538
12834
  classified: applied.classified,
@@ -13584,7 +12880,7 @@ async function loadAcceptedNames(sessionId2) {
13584
12880
  try {
13585
12881
  const artifactsRoot = getRefineArtifactsRoot();
13586
12882
  const paths = await getRefineSessionPaths(sessionId2, artifactsRoot);
13587
- const raw = await readFile12(paths.statePath, "utf8");
12883
+ const raw = await readFile11(paths.statePath, "utf8");
13588
12884
  const snapshot = JSON.parse(raw);
13589
12885
  const accepted = snapshot.components.filter((c2) => c2.status === "accepted").map((c2) => c2.name);
13590
12886
  if (accepted.length === 0) return null;
@@ -13593,15 +12889,6 @@ async function loadAcceptedNames(sessionId2) {
13593
12889
  return null;
13594
12890
  }
13595
12891
  }
13596
- function parsePrecomputedCachedNames(value) {
13597
- if (!value) return /* @__PURE__ */ new Set();
13598
- try {
13599
- const parsed = JSON.parse(value);
13600
- return new Set(Array.isArray(parsed) ? parsed.filter((name) => typeof name === "string") : []);
13601
- } catch {
13602
- return /* @__PURE__ */ new Set();
13603
- }
13604
- }
13605
12892
  async function runGenerateSkill(skill, opts, verbose = false) {
13606
12893
  const savedCreds = await readExperiencesCredentials();
13607
12894
  const agentName = opts.agent ?? savedCreds.agent;
@@ -13630,8 +12917,8 @@ async function runGenerateSkill(skill, opts, verbose = false) {
13630
12917
  }
13631
12918
  const generatePromptPath = generatePrompt === void 0 ? configuredGeneratePromptPath : void 0;
13632
12919
  if (generatePromptPath) {
13633
- if (!await pathExists(resolve12(generatePromptPath))) {
13634
- die(`Error: custom prompt path not found: ${resolve12(generatePromptPath)}`);
12920
+ if (!await pathExists(resolve11(generatePromptPath))) {
12921
+ die(`Error: custom prompt path not found: ${resolve11(generatePromptPath)}`);
13635
12922
  }
13636
12923
  if (!generatePromptPath.toLowerCase().endsWith(".md")) {
13637
12924
  process.stderr.write(
@@ -13639,7 +12926,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
13639
12926
  `
13640
12927
  );
13641
12928
  }
13642
- process.stderr.write(formatCustomPromptBanner("components", resolve12(generatePromptPath)));
12929
+ process.stderr.write(formatCustomPromptBanner("components", resolve11(generatePromptPath)));
13643
12930
  }
13644
12931
  if (skill === "tokens" && !opts.rawTokens) {
13645
12932
  die("Error: --raw-tokens is required when using generate tokens");
@@ -13655,7 +12942,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
13655
12942
  let existingContentfulEntities;
13656
12943
  let existingTokensInline;
13657
12944
  if (opts.existingEntitiesPath) {
13658
- existingContentfulEntities = await readExistingContentfulEntitiesFromSession(resolve12(opts.existingEntitiesPath));
12945
+ existingContentfulEntities = await readExistingContentfulEntitiesFromSession(resolve11(opts.existingEntitiesPath));
13659
12946
  if (existingContentfulEntities) {
13660
12947
  existingTokensInline = JSON.stringify(summarizeForMapTokens(existingContentfulEntities));
13661
12948
  } else {
@@ -13756,7 +13043,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
13756
13043
  rawComponentsInline: sampleInline ?? rawTokensInline,
13757
13044
  propBucketsInline: sampleBuckets ? JSON.stringify(sampleBuckets) : void 0,
13758
13045
  rawTokensInline: skill === "tokens" ? rawTokensInline : void 0,
13759
- rawTokensFilename: opts.rawTokens ? resolve12(opts.rawTokens).split("/").pop() : void 0,
13046
+ rawTokensFilename: opts.rawTokens ? resolve11(opts.rawTokens).split("/").pop() : void 0,
13760
13047
  tokensInline,
13761
13048
  tokenMapInline,
13762
13049
  outDir: process.cwd(),
@@ -13782,64 +13069,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
13782
13069
  if (skill === "components" && allComponents && sessionId2) {
13783
13070
  const db = openPipelineDb();
13784
13071
  let componentResults;
13785
- const precomputedCachedNames = parsePrecomputedCachedNames(opts.cachedComponents);
13786
13072
  try {
13787
- const existingContentfulEntitiesHashInputs = [];
13788
- if (existingTokensInline) existingContentfulEntitiesHashInputs.push(hashContent(existingTokensInline));
13789
- const promptHash = await hashPromptForSkill(
13790
- "components",
13791
- agent,
13792
- model,
13793
- generatePromptPath,
13794
- existingContentfulEntitiesHashInputs,
13795
- generatePrompt
13796
- );
13797
- if (opts.cacheStatus) {
13798
- const cacheEnabled = opts.cache !== false && process.env.EDS_NO_CACHE !== "1";
13799
- const cachedComponents = cacheEnabled ? allComponents.flatMap((component) => {
13800
- const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
13801
- return resolution ? [{ component, resolution }] : [];
13802
- }) : [];
13803
- if (cacheEnabled && opts.restoreCache) {
13804
- const restorations = [];
13805
- const rekeyed = [];
13806
- const componentStatus = db.prepare(
13807
- "SELECT status FROM raw_components WHERE session_id = ? AND component_id = ?"
13808
- );
13809
- for (const { component, resolution } of cachedComponents) {
13810
- const current = componentStatus.get(sessionId2, component.component_id);
13811
- if (current?.status === "generated") continue;
13812
- renameEmptySlots(db, sessionId2, component.component_id, component.name, component.slots.length);
13813
- restorations.push({
13814
- sourceSessionId: resolution.entry.sourceSessionId,
13815
- targetSessionId: sessionId2,
13816
- componentId: component.component_id
13817
- });
13818
- rekeyed.push({ component, cached: resolution.entry });
13819
- }
13820
- copyComponentsFromCache(db, restorations, { allowedComponentNames: allowedComponentNames2 });
13821
- storeCaches(
13822
- db,
13823
- rekeyed.map(({ component, cached }) => ({
13824
- inputHash: hashComponentShape(normalizeComponentForCache(component)),
13825
- entityType: "component",
13826
- entityId: component.component_id,
13827
- sourceSessionId: cached.sourceSessionId,
13828
- humanEdited: cached.humanEdited,
13829
- promptHash
13830
- }))
13831
- );
13832
- }
13833
- const fullyCached = cacheEnabled && cachedComponents.length === allComponents.length;
13834
- process.stdout.write(`cache-status=${fullyCached ? "hit" : "miss"}
13835
- `);
13836
- process.stdout.write(
13837
- `cache-components=${JSON.stringify(cachedComponents.map(({ component }) => component.name))}
13838
- `
13839
- );
13840
- await exitWithAnalytics(0);
13841
- return;
13842
- }
13843
13073
  componentResults = await runAllComponents(
13844
13074
  {
13845
13075
  agent,
@@ -13849,13 +13079,10 @@ async function runGenerateSkill(skill, opts, verbose = false) {
13849
13079
  tokensInline,
13850
13080
  tokenMapInline,
13851
13081
  verbose,
13852
- noCache: opts.cache === false || process.env.EDS_NO_CACHE === "1",
13853
13082
  skillPathOverride: generatePromptPath,
13854
13083
  skillContentOverride: generatePrompt,
13855
- promptHash,
13856
13084
  existingContentfulEntities,
13857
13085
  existingTokensInline,
13858
- precomputedCachedNames,
13859
13086
  allowedComponentNames: allowedComponentNames2
13860
13087
  },
13861
13088
  allComponents
@@ -13864,8 +13091,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
13864
13091
  db.close();
13865
13092
  }
13866
13093
  const failed = componentResults.filter((r) => r.failed);
13867
- const cachedResults = componentResults.filter((r) => r.cached);
13868
- const generated = componentResults.filter((r) => !r.failed && !r.cached);
13094
+ const generated = componentResults.filter((r) => !r.failed);
13869
13095
  const allWarnings = componentResults.flatMap((r) => r.warnings.map((w) => ` ${r.componentName}: ${w}`));
13870
13096
  if (allWarnings.length > 0) {
13871
13097
  process.stderr.write(c.yellow("Warnings:") + "\n" + allWarnings.join("\n") + "\n");
@@ -13881,21 +13107,17 @@ async function runGenerateSkill(skill, opts, verbose = false) {
13881
13107
  const totalExcluded = generated.reduce((s, r) => s + r.excluded, 0);
13882
13108
  const totalRenamedSlots = componentResults.reduce((s, r) => s + r.renamedSlotsCount, 0);
13883
13109
  const allOk = failed.length === 0;
13884
- const cachedNote = cachedResults.length > 0 ? c.dim(` (${cachedResults.length} cached)`) : "";
13885
13110
  process.stderr.write(
13886
- (allOk ? c.green("\u2713") : c.yellow("\u26A0")) + ` ${generated.length + cachedResults.length}/${componentResults.length} components` + cachedNote + c.dim(` ${totalClassified} classified, ${totalExcluded} unattached`) + "\n"
13111
+ (allOk ? c.green("\u2713") : c.yellow("\u26A0")) + ` ${generated.length}/${componentResults.length} components` + c.dim(` ${totalClassified} classified, ${totalExcluded} unattached`) + "\n"
13887
13112
  );
13888
13113
  process.stdout.write(`renamed-slots: ${totalRenamedSlots}
13889
13114
  `);
13890
- if (generated.length === 0 && cachedResults.length === 0) {
13115
+ if (generated.length === 0) {
13891
13116
  die(
13892
13117
  `Error: all ${componentResults.length} component(s) failed to generate \u2014 see the per-component errors above.`
13893
13118
  );
13894
13119
  }
13895
13120
  } else if (skill === "tokens") {
13896
- const noCache = opts.cache === false || process.env.EDS_NO_CACHE === "1";
13897
- const tokenInputContent = rawTokensInline ?? "";
13898
- const tokenInputHash = hashTokenContent(tokenInputContent);
13899
13121
  const db = openPipelineDb();
13900
13122
  try {
13901
13123
  let resolvedSessionId = opts.session;
@@ -13922,26 +13144,11 @@ async function runGenerateSkill(skill, opts, verbose = false) {
13922
13144
  }
13923
13145
  sessionId2 = resolvedSessionId;
13924
13146
  await bindAnalyticsSessionId(resolvedSessionId);
13925
- const tokenPromptHash = await hashPromptForSkill("tokens", agent, model);
13926
- if (!noCache) {
13927
- const tokenCached = lookupCache(db, tokenInputHash, "token_set", "__tokens__", tokenPromptHash);
13928
- if (tokenCached) {
13929
- copyTokensFromCache(db, tokenCached.sourceSessionId, resolvedSessionId);
13930
- sessionId2 = resolvedSessionId;
13931
- process.stderr.write(
13932
- `Done: tokens reused from cache ${c.dim(`(source: ${tokenCached.sourceSessionId.slice(0, 12)})`)}
13933
- `
13934
- );
13935
- db.close();
13936
- await showGenerateView({ skill, agent, sessionId: sessionId2 ?? "" });
13937
- return;
13938
- }
13939
- }
13940
13147
  const prompt = await buildPrompt({
13941
13148
  skill,
13942
13149
  mode: "autonomous",
13943
13150
  rawTokensInline,
13944
- rawTokensFilename: opts.rawTokens ? resolve12(opts.rawTokens).split("/").pop() : void 0,
13151
+ rawTokensFilename: opts.rawTokens ? resolve11(opts.rawTokens).split("/").pop() : void 0,
13945
13152
  tokensInline,
13946
13153
  tokenMapInline,
13947
13154
  outDir: process.cwd()
@@ -13978,9 +13185,6 @@ ${tokenWarnings.map((w) => ` ${w}`).join("\n")}
13978
13185
  `);
13979
13186
  }
13980
13187
  applyTokenToolCalls(db, resolvedSessionId, tokenCalls, []);
13981
- if (!noCache) {
13982
- storeCache(db, tokenInputHash, "token_set", "__tokens__", resolvedSessionId, false, tokenPromptHash);
13983
- }
13984
13188
  sessionId2 = resolvedSessionId;
13985
13189
  const groupCount = tokenCalls.filter((tc) => tc.tool === "set_group").length;
13986
13190
  process.stderr.write(`Done: ${tokenCount} tokens, ${groupCount} groups stored
@@ -13992,10 +13196,7 @@ ${tokenWarnings.map((w) => ` ${w}`).join("\n")}
13992
13196
  await showGenerateView({ skill, agent, sessionId: sessionId2 ?? "" });
13993
13197
  }
13994
13198
  function addAgentFlags(cmd) {
13995
- return addAgentModelOptions(cmd).option("--verbose", "Show full agent output including reasoning text").option("--dry-run", "Print the prompt without invoking the agent").option(
13996
- "--no-cache",
13997
- "Bypass ALL fine-grained caches (extract, select, generate) and force AI re-run. Cache keys now factor in prompt content \u2014 changing the prompt file via --generate-prompt-path or --select-prompt-path will already bust the corresponding stage. Use --no-cache to force a full re-run."
13998
- );
13199
+ return addAgentModelOptions(cmd).option("--verbose", "Show full agent output including reasoning text").option("--dry-run", "Print the prompt without invoking the agent");
13999
13200
  }
14000
13201
  function registerInternalGenerateCommand(program) {
14001
13202
  const generate = program.command("__generate", { hidden: true }).description("Internal import pipeline generation command");
@@ -14011,12 +13212,6 @@ function registerInternalGenerateCommand(program) {
14011
13212
  "--existing-entities-path <path>",
14012
13213
  "Path to the .existing-entities.json file written after CMA credentials are supplied. When present, per-component prompts include a summary of the target space so classifications can align to existing prop names/tokens. Missing/malformed files are treated as no-op."
14013
13214
  );
14014
- componentsCmd.option("--cache-status", "Check whether all selected component definitions are cached");
14015
- componentsCmd.option("--restore-cache", "Restore cached component definitions into the current session");
14016
- componentsCmd.option(
14017
- "--cached-components <json>",
14018
- "Component names already restored by a prior cache-status lookup; skip per-component cache lookup"
14019
- );
14020
13215
  addAgentFlags(componentsCmd).action(async (opts) => {
14021
13216
  await runGenerateSkill("components", opts, opts.verbose ?? false);
14022
13217
  });
@@ -14042,7 +13237,6 @@ var init_command = __esm({
14042
13237
  init_agent_output();
14043
13238
  init_GenerateView();
14044
13239
  init_db();
14045
- init_cache_keys();
14046
13240
  init_read_existing_contentful_entities_from_session();
14047
13241
  init_summarize_existing_contentful_entities();
14048
13242
  init_resolve_session_id();
@@ -14758,7 +13952,7 @@ var init_user_agent = __esm({
14758
13952
  // packages/experience-design-system-cli-legacy/src/apply/api-client.ts
14759
13953
  import { parseCDFComponents } from "@contentful/experience-design-system-types";
14760
13954
  function defaultSleep(delayMs) {
14761
- return new Promise((resolve21) => setTimeout(resolve21, delayMs));
13955
+ return new Promise((resolve20) => setTimeout(resolve20, delayMs));
14762
13956
  }
14763
13957
  function isTransientStatus(status) {
14764
13958
  return status >= 500 && status <= 599;
@@ -15148,7 +14342,7 @@ ${trimmed}`;
15148
14342
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
15149
14343
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
15150
14344
  const jitter = Math.random() * baseDelay * 0.15;
15151
- await new Promise((resolve21) => setTimeout(resolve21, baseDelay + jitter));
14345
+ await new Promise((resolve20) => setTimeout(resolve20, baseDelay + jitter));
15152
14346
  }
15153
14347
  }
15154
14348
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -15958,7 +15152,7 @@ var init_terminal_capabilities = __esm({
15958
15152
 
15959
15153
  // packages/experience-design-system-cli-legacy/src/apply/command.ts
15960
15154
  import { createElement as createElement2 } from "react";
15961
- import { readFile as readFile13, readdir as readdir2, stat as stat2 } from "node:fs/promises";
15155
+ import { readFile as readFile12, readdir as readdir2, stat as stat2 } from "node:fs/promises";
15962
15156
  import { join as join16 } from "node:path";
15963
15157
  import {
15964
15158
  validateCDF,
@@ -15979,7 +15173,7 @@ function dieWithApiError(error) {
15979
15173
  async function readJsonFile(flag, p) {
15980
15174
  let text;
15981
15175
  try {
15982
- text = await readFile13(p, "utf8");
15176
+ text = await readFile12(p, "utf8");
15983
15177
  } catch {
15984
15178
  return await die2(`Error: file not found: ${p} (from ${flag})`);
15985
15179
  }
@@ -16033,7 +15227,7 @@ async function readTokensFromPath(flag, p) {
16033
15227
  for (const file of files.sort()) {
16034
15228
  let text;
16035
15229
  try {
16036
- text = await readFile13(file, "utf8");
15230
+ text = await readFile12(file, "utf8");
16037
15231
  } catch {
16038
15232
  continue;
16039
15233
  }
@@ -16402,11 +15596,11 @@ var init_command2 = __esm({
16402
15596
  });
16403
15597
 
16404
15598
  // packages/experience-design-system-cli-legacy/src/print/validate/validators/read-json-file.ts
16405
- import { readFile as readFile14 } from "node:fs/promises";
15599
+ import { readFile as readFile13 } from "node:fs/promises";
16406
15600
  async function readJsonFile2(filePath) {
16407
15601
  let content;
16408
15602
  try {
16409
- content = await readFile14(filePath, "utf-8");
15603
+ content = await readFile13(filePath, "utf-8");
16410
15604
  } catch (err) {
16411
15605
  return {
16412
15606
  ok: false,
@@ -16817,7 +16011,7 @@ var init_ValidateView = __esm({
16817
16011
  // packages/experience-design-system-cli-legacy/src/print/command.ts
16818
16012
  import { createElement as createElement3 } from "react";
16819
16013
  import { access as access3, mkdir as mkdir3, stat as stat3, writeFile as writeFile3 } from "node:fs/promises";
16820
- import { basename as basename5, resolve as resolve13 } from "node:path";
16014
+ import { basename as basename5, resolve as resolve12 } from "node:path";
16821
16015
  import { CDF_SCHEMA_URL } from "@contentful/experience-design-system-types";
16822
16016
  async function die3(message) {
16823
16017
  process.stderr.write(`${message}
@@ -16884,7 +16078,7 @@ function registerPrintCommand(program) {
16884
16078
  "--allow-empty",
16885
16079
  "Write an empty-but-present CDF file when no components are accepted (a subsequent push then removes ALL components from the target space). Without this, an empty accepted set is an error."
16886
16080
  ).action(async (opts) => {
16887
- const outPath = resolve13(opts.out);
16081
+ const outPath = resolve12(opts.out);
16888
16082
  await assertOutIsNotDirectory(outPath);
16889
16083
  const sessionId2 = await resolveSession(opts.session, "generate components");
16890
16084
  await bindAnalyticsSessionId(sessionId2);
@@ -16932,7 +16126,7 @@ function registerPrintCommand(program) {
16932
16126
  `
16933
16127
  );
16934
16128
  }
16935
- await mkdir3(resolve13(outPath, ".."), { recursive: true });
16129
+ await mkdir3(resolve12(outPath, ".."), { recursive: true });
16936
16130
  await writeFile3(outPath, `${JSON.stringify(cdfObj, null, 2)}
16937
16131
  `);
16938
16132
  process.stdout.write(
@@ -16941,7 +16135,7 @@ function registerPrintCommand(program) {
16941
16135
  );
16942
16136
  });
16943
16137
  print.command("tokens").description("Write generated tokens to a DTCG JSON file").option("--session <id>", "Session ID to print from (default: most recent generate tokens session)").option("--out <path>", "Output file path", "tokens.json").action(async (opts) => {
16944
- const outPath = resolve13(opts.out);
16138
+ const outPath = resolve12(opts.out);
16945
16139
  await assertOutIsNotDirectory(outPath);
16946
16140
  const sessionId2 = await resolveSession(opts.session, "generate tokens");
16947
16141
  await bindAnalyticsSessionId(sessionId2);
@@ -16956,7 +16150,7 @@ function registerPrintCommand(program) {
16956
16150
  await die3(`Error: no generated tokens in session '${sessionId2}'. Run generate tokens first.`);
16957
16151
  }
16958
16152
  const tree = rebuildDTCGTree(result.groups, result.tokens);
16959
- await mkdir3(resolve13(outPath, ".."), { recursive: true });
16153
+ await mkdir3(resolve12(outPath, ".."), { recursive: true });
16960
16154
  await writeFile3(outPath, `${JSON.stringify(tree, null, 2)}
16961
16155
  `);
16962
16156
  process.stdout.write(
@@ -17105,7 +16299,7 @@ function MapTokensView({ result, onExit }) {
17105
16299
  const timer = setTimeout(onExit, 100);
17106
16300
  return () => clearTimeout(timer);
17107
16301
  }, [onExit]);
17108
- const summary = result.cached ? "reused from cache" : `${result.applied} mapping${result.applied === 1 ? "" : "s"} applied`;
16302
+ const summary = `${result.applied} mapping${result.applied === 1 ? "" : "s"} applied`;
17109
16303
  return /* @__PURE__ */ jsx8(
17110
16304
  CommandCompletionView,
17111
16305
  {
@@ -17239,8 +16433,8 @@ var init_resolve_defaults = __esm({
17239
16433
 
17240
16434
  // packages/experience-design-system-cli-legacy/src/map-tokens/command.ts
17241
16435
  import { createElement as createElement4 } from "react";
17242
- import { readFile as readFile15 } from "node:fs/promises";
17243
- import { resolve as resolve14 } from "node:path";
16436
+ import { readFile as readFile14 } from "node:fs/promises";
16437
+ import { resolve as resolve13 } from "node:path";
17244
16438
  async function renderResult(result) {
17245
16439
  if (process.stdout.isTTY) {
17246
16440
  const { waitUntilExit } = renderWithGoodbye(
@@ -17248,12 +16442,13 @@ async function renderResult(result) {
17248
16442
  );
17249
16443
  await waitUntilExit();
17250
16444
  } else {
17251
- const summary = result.cached ? "cached" : `${result.applied} mapping(s) applied`;
17252
- process.stdout.write(`map tokens complete
16445
+ process.stdout.write(
16446
+ `map tokens complete
17253
16447
  agent: ${result.agent}
17254
16448
  session=${result.sessionId}
17255
- ${summary}
17256
- `);
16449
+ ${result.applied} mapping(s) applied
16450
+ `
16451
+ );
17257
16452
  await exitWithAnalytics(0);
17258
16453
  }
17259
16454
  }
@@ -17275,7 +16470,7 @@ async function runMapTokens(opts) {
17275
16470
  let mapPromptPath;
17276
16471
  if (mapPromptOverride?.kind === "text") mapPromptText = mapPromptOverride.value;
17277
16472
  if (mapPromptOverride?.kind === "path") {
17278
- mapPromptPath = resolve14(mapPromptOverride.value);
16473
+ mapPromptPath = resolve13(mapPromptOverride.value);
17279
16474
  try {
17280
16475
  await resolvePromptOverride(mapPromptOverride);
17281
16476
  } catch (error) {
@@ -17295,7 +16490,7 @@ async function runMapTokens(opts) {
17295
16490
  const knownTokenPaths = new Set(tokenLeaves.map((t) => t.path));
17296
16491
  const tokenMapDiagnostics = [];
17297
16492
  if (opts.tokenMap) {
17298
- const fileMappings = JSON.parse(await readFile15(opts.tokenMap, "utf8"));
16493
+ const fileMappings = JSON.parse(await readFile14(opts.tokenMap, "utf8"));
17299
16494
  const validMappings = {};
17300
16495
  for (const [rawName, path] of Object.entries(fileMappings)) {
17301
16496
  if (knownTokenPaths.has(path)) {
@@ -17373,7 +16568,7 @@ ${defaultDiagnostics.map((diagnostic) => ` ${diagnostic}`).join("\n")}
17373
16568
  let existingTokensInline;
17374
16569
  if (opts.existingEntitiesPath) {
17375
16570
  const existingContentfulEntities = await readExistingContentfulEntitiesFromSession(
17376
- resolve14(opts.existingEntitiesPath)
16571
+ resolve13(opts.existingEntitiesPath)
17377
16572
  );
17378
16573
  if (existingContentfulEntities) {
17379
16574
  existingTokensInline = JSON.stringify(summarizeForMapTokens(existingContentfulEntities));
@@ -17408,30 +16603,10 @@ ${defaultDiagnostics.map((diagnostic) => ` ${diagnostic}`).join("\n")}
17408
16603
  skipAgent: "true"
17409
16604
  });
17410
16605
  updateStep(db, stepId2, "complete", { applied: "0", skipAgent: "true" });
17411
- await renderResult({ agent: resultAgent, sessionId: sessionId2, applied: 0, cached: false });
16606
+ await renderResult({ agent: resultAgent, sessionId: sessionId2, applied: 0 });
17412
16607
  return;
17413
16608
  }
17414
16609
  const agent = configuredAgent;
17415
- const noCache = opts.cache === false || process.env.EDS_NO_CACHE === "1";
17416
- const promptHash = await hashPromptForSkill(
17417
- "map-tokens",
17418
- agent,
17419
- model,
17420
- void 0,
17421
- existingTokensInline ? [hashContent(existingTokensInline)] : [],
17422
- mapPromptText
17423
- );
17424
- const inputHash = computeMapTokensInputHash(db, sessionId2, componentSourceRefs);
17425
- if (!noCache) {
17426
- const cached = lookupCache(db, inputHash, "token_mapping", "__map_tokens__", promptHash);
17427
- if (cached) {
17428
- const appliedFromCache = copyMapTokensFromCache(db, cached.sourceSessionId, sessionId2);
17429
- const stepId2 = createStep(db, sessionId2, "map tokens", { agent, model: model ?? "" });
17430
- updateStep(db, stepId2, "complete", { cached: "true", applied: String(appliedFromCache) });
17431
- await renderResult({ agent, sessionId: sessionId2, applied: appliedFromCache, cached: true });
17432
- return;
17433
- }
17434
- }
17435
16610
  const binary = resolveAgentBinary(agent);
17436
16611
  if (!await assertBinaryInPath(binary)) {
17437
16612
  die(
@@ -17451,23 +16626,20 @@ Install it, choose another agent with --agent, or use --print-prompt to run the
17451
16626
  }
17452
16627
  const { calls, warnings: parseWarnings } = parseMapTokenPropToolCallLines(result.stdout);
17453
16628
  const { applied, warnings } = applyMapTokenPropCalls(db, sessionId2, calls, parseWarnings);
17454
- if (!noCache) {
17455
- storeCache(db, inputHash, "token_mapping", "__map_tokens__", sessionId2, false, promptHash);
17456
- }
17457
16629
  updateStep(db, stepId, "complete", { applied: String(applied), warnings: String(warnings.length) });
17458
16630
  if (warnings.length > 0) {
17459
16631
  process.stderr.write(`Warnings:
17460
16632
  ${warnings.map((w) => ` ${w}`).join("\n")}
17461
16633
  `);
17462
16634
  }
17463
- await renderResult({ agent, sessionId: sessionId2, applied, cached: false });
16635
+ await renderResult({ agent, sessionId: sessionId2, applied });
17464
16636
  } finally {
17465
16637
  db.close();
17466
16638
  }
17467
16639
  }
17468
16640
  function registerMapTokensCommand(program) {
17469
16641
  const map = program.command("map", { hidden: true }).description("Suggest token restrictions for generated design-token props");
17470
- const tokensCmd = map.command("tokens").description("Invoke a coding agent to suggest $token.allowed for design-category token props").option("--session <id>", "Session ID from generate components (defaults to most recent)").option("--print-prompt", "Print the prompt without invoking the agent").option("--skip-agent", "Resolve token defaults without agentic $token.allowed inference").option("--no-cache", "Bypass the map-tokens cache and force a re-run").option(
16642
+ const tokensCmd = map.command("tokens").description("Invoke a coding agent to suggest $token.allowed for design-category token props").option("--session <id>", "Session ID from generate components (defaults to most recent)").option("--print-prompt", "Print the prompt without invoking the agent").option("--skip-agent", "Resolve token defaults without agentic $token.allowed inference").option(
17471
16643
  "--prompt <stage=value>",
17472
16644
  "Override a stage prompt (repeatable). Used here for the map-tokens stage.",
17473
16645
  (v, acc) => [...acc, v],
@@ -17487,7 +16659,6 @@ var init_command4 = __esm({
17487
16659
  init_render_with_goodbye();
17488
16660
  init_src();
17489
16661
  init_db();
17490
- init_cache_keys();
17491
16662
  init_read_existing_contentful_entities_from_session();
17492
16663
  init_summarize_existing_contentful_entities();
17493
16664
  init_command3();
@@ -17504,7 +16675,7 @@ var init_command4 = __esm({
17504
16675
  });
17505
16676
 
17506
16677
  // packages/experience-design-system-cli-legacy/src/import/path-utils.ts
17507
- import { resolve as resolve15 } from "node:path";
16678
+ import { resolve as resolve14 } from "node:path";
17508
16679
  import { homedir as homedir5 } from "node:os";
17509
16680
  function expandTilde(input) {
17510
16681
  if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
@@ -17518,7 +16689,7 @@ function normalizePath(input) {
17518
16689
  p = p.slice(1, -1);
17519
16690
  }
17520
16691
  p = expandTilde(p);
17521
- return resolve15(p);
16692
+ return resolve14(p);
17522
16693
  }
17523
16694
  var init_path_utils = __esm({
17524
16695
  "packages/experience-design-system-cli-legacy/src/import/path-utils.ts"() {
@@ -17743,7 +16914,7 @@ var init_save_path_resolver = __esm({
17743
16914
  });
17744
16915
 
17745
16916
  // packages/experience-design-system-cli-legacy/src/runs/store.ts
17746
- import { readFile as readFile16, writeFile as writeFile4, mkdir as mkdir4, rename } from "node:fs/promises";
16917
+ import { readFile as readFile15, writeFile as writeFile4, mkdir as mkdir4, rename } from "node:fs/promises";
17747
16918
  import { join as join20 } from "node:path";
17748
16919
  import { homedir as homedir6 } from "node:os";
17749
16920
  import { randomBytes as randomBytes2 } from "node:crypto";
@@ -17783,7 +16954,7 @@ function migrateRecord(rec) {
17783
16954
  }
17784
16955
  async function readFileMaybe() {
17785
16956
  try {
17786
- const raw = await readFile16(RUNS_PATH, "utf8");
16957
+ const raw = await readFile15(RUNS_PATH, "utf8");
17787
16958
  const parsed = JSON.parse(raw);
17788
16959
  if (!READABLE_VERSIONS.has(parsed.version)) {
17789
16960
  throw new Error(
@@ -17847,15 +17018,15 @@ var init_store = __esm({
17847
17018
  });
17848
17019
 
17849
17020
  // packages/experience-design-system-cli-legacy/src/runs/fingerprint.ts
17850
- import { createHash as createHash6 } from "node:crypto";
17851
- import { readFile as readFile17, stat as stat4 } from "node:fs/promises";
17852
- import { resolve as resolve16 } from "node:path";
17021
+ import { createHash as createHash2 } from "node:crypto";
17022
+ import { readFile as readFile16, stat as stat4 } from "node:fs/promises";
17023
+ import { resolve as resolve15 } from "node:path";
17853
17024
  function rowField(row, key) {
17854
17025
  const v = row[key];
17855
17026
  return typeof v === "string" ? v : null;
17856
17027
  }
17857
17028
  function sha256Hex(buf) {
17858
- return createHash6("sha256").update(buf).digest("hex");
17029
+ return createHash2("sha256").update(buf).digest("hex");
17859
17030
  }
17860
17031
  async function buildSourceFingerprint(opts) {
17861
17032
  const rows = opts.db.prepare("SELECT name, source_path FROM raw_components WHERE session_id = ?").all(opts.extractSessionId);
@@ -17865,7 +17036,7 @@ async function buildSourceFingerprint(opts) {
17865
17036
  const sourcePath = rowField(row, "source_path");
17866
17037
  const name = rowField(row, "name");
17867
17038
  if (!sourcePath) continue;
17868
- const abs = resolve16(sourcePath);
17039
+ const abs = resolve15(sourcePath);
17869
17040
  if (seen.has(abs)) continue;
17870
17041
  seen.add(abs);
17871
17042
  try {
@@ -17880,10 +17051,10 @@ async function buildSourceFingerprint(opts) {
17880
17051
  let rawTokensMtime = null;
17881
17052
  let rawTokensContentHash = null;
17882
17053
  if (opts.rawTokensPath) {
17883
- const abs = resolve16(opts.rawTokensPath);
17054
+ const abs = resolve15(opts.rawTokensPath);
17884
17055
  rawTokensPath = abs;
17885
17056
  try {
17886
- const [st, buf] = await Promise.all([stat4(abs), readFile17(abs)]);
17057
+ const [st, buf] = await Promise.all([stat4(abs), readFile16(abs)]);
17887
17058
  rawTokensMtime = st.mtime.toISOString();
17888
17059
  rawTokensContentHash = sha256Hex(buf);
17889
17060
  } catch {
@@ -19638,11 +18809,11 @@ var init_slot_graph = __esm({
19638
18809
  });
19639
18810
 
19640
18811
  // packages/experience-design-system-cli-legacy/src/analyze/select/parser.ts
19641
- import { createHash as createHash7 } from "node:crypto";
18812
+ import { createHash as createHash3 } from "node:crypto";
19642
18813
  import { access as access5 } from "node:fs/promises";
19643
- import { isAbsolute, relative, resolve as resolve17 } from "node:path";
18814
+ import { isAbsolute, relative, resolve as resolve16 } from "node:path";
19644
18815
  function createComponentId(name, resolvedSourcePath) {
19645
- const sourceHash = createHash7("sha256").update(`${name}:${resolvedSourcePath}`).digest("hex").slice(0, 12);
18816
+ const sourceHash = createHash3("sha256").update(`${name}:${resolvedSourcePath}`).digest("hex").slice(0, 12);
19646
18817
  return `${name}-${sourceHash}`;
19647
18818
  }
19648
18819
  async function resolveComponentSourcePath(source, reviewRoot) {
@@ -19654,7 +18825,7 @@ async function resolveComponentSourcePath(source, reviewRoot) {
19654
18825
  throw new Error(`Unable to access component source at ${source}`);
19655
18826
  }
19656
18827
  }
19657
- const candidate = resolve17(reviewRoot, source);
18828
+ const candidate = resolve16(reviewRoot, source);
19658
18829
  const relativeToRoot = relative(reviewRoot, candidate);
19659
18830
  if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || isAbsolute(relativeToRoot)) {
19660
18831
  throw new Error(
@@ -19669,7 +18840,7 @@ async function resolveComponentSourcePath(source, reviewRoot) {
19669
18840
  }
19670
18841
  }
19671
18842
  async function loadReviewInput(components, options = {}) {
19672
- const reviewRoot = resolve17(options.reviewRoot ?? process.cwd());
18843
+ const reviewRoot = resolve16(options.reviewRoot ?? process.cwd());
19673
18844
  const records = await Promise.all(
19674
18845
  components.map(async (component) => {
19675
18846
  let resolvedSourcePath;
@@ -19700,7 +18871,7 @@ var init_parser = __esm({
19700
18871
  });
19701
18872
 
19702
18873
  // packages/experience-design-system-cli-legacy/src/analyze/select/command.ts
19703
- import { access as access6, readFile as readFile18 } from "node:fs/promises";
18874
+ import { access as access6, readFile as readFile17 } from "node:fs/promises";
19704
18875
  async function loadAndValidateForReview(sessionId2, projectRoot) {
19705
18876
  const db = openPipelineDb();
19706
18877
  let rawComponents;
@@ -19718,7 +18889,7 @@ async function patchReviewStateWithValidationErrors(sessionId2, errors, opts = {
19718
18889
  let snapshot;
19719
18890
  try {
19720
18891
  await access6(paths.statePath);
19721
- snapshot = JSON.parse(await readFile18(paths.statePath, "utf8"));
18892
+ snapshot = JSON.parse(await readFile17(paths.statePath, "utf8"));
19722
18893
  } catch {
19723
18894
  snapshot = await loadAndValidateForReview(sessionId2, void 0);
19724
18895
  snapshot = await ensureRefineSession(sessionId2, artifactsRoot, snapshot);
@@ -19769,7 +18940,7 @@ async function rejectComponentsByName(sessionId2, names, opts = {}) {
19769
18940
  const nameSet = new Set(names);
19770
18941
  let snapshot;
19771
18942
  try {
19772
- snapshot = JSON.parse(await readFile18(paths.statePath, "utf8"));
18943
+ snapshot = JSON.parse(await readFile17(paths.statePath, "utf8"));
19773
18944
  } catch {
19774
18945
  return;
19775
18946
  }
@@ -19868,9 +19039,9 @@ function spawnGenerateChild(opts) {
19868
19039
  stderr += chunk;
19869
19040
  opts.onStderr?.(chunk);
19870
19041
  });
19871
- const donePromise = new Promise((resolve21) => {
19042
+ const donePromise = new Promise((resolve20) => {
19872
19043
  child.on("close", (code, signal) => {
19873
- resolve21({
19044
+ resolve20({
19874
19045
  exitCode: code ?? 0,
19875
19046
  signal: signal ?? null,
19876
19047
  stdout,
@@ -19878,7 +19049,7 @@ function spawnGenerateChild(opts) {
19878
19049
  });
19879
19050
  });
19880
19051
  child.on("error", (err) => {
19881
- resolve21({
19052
+ resolve20({
19882
19053
  exitCode: 1,
19883
19054
  signal: null,
19884
19055
  stdout,
@@ -28016,9 +27187,6 @@ function shouldGenerateAfterCredentialsValidated(opts) {
28016
27187
  function shouldSkipFinalReviewAfterCredentials(state) {
28017
27188
  return state.finalReviewPassed && state.generateSessionId != null;
28018
27189
  }
28019
- function resolveNoCacheForGenerate(opts) {
28020
- return opts.cliNoCache;
28021
- }
28022
27190
  function shouldBypassPreview(state) {
28023
27191
  return state.credentialsSkipped === true;
28024
27192
  }
@@ -28045,70 +27213,43 @@ var init_wizard_state_transitions = __esm({
28045
27213
  async function runSelectionAgent(options) {
28046
27214
  const db = openPipelineDb();
28047
27215
  let components;
28048
- const cachedDecisions = /* @__PURE__ */ new Map();
28049
- const cliVersion2 = await getCliCacheVersion();
28050
- const promptHash = await hashPromptForSkill(
28051
- "select",
28052
- options.agent,
28053
- options.model,
28054
- options.promptPath,
28055
- [SELECT_PAYLOAD_FORMAT],
28056
- options.promptText
28057
- );
28058
27216
  try {
28059
27217
  components = loadRawComponents(db, options.sessionId);
28060
- if (!options.noCache) {
28061
- for (const component of components) {
28062
- const componentHash = hashComponentShape(component);
28063
- const cached = lookupSelectCache(db, componentHash, promptHash, cliVersion2);
28064
- if (cached) {
28065
- cachedDecisions.set(component.name, {
28066
- decision: cached.decision,
28067
- reason: cached.reason
28068
- });
28069
- }
28070
- }
28071
- }
28072
27218
  } finally {
28073
27219
  db.close();
28074
27220
  }
28075
27221
  if (components.length === 0) return;
28076
- const componentsToRun = components.filter((component) => !cachedDecisions.has(component.name));
28077
- let calls = [];
28078
- if (componentsToRun.length > 0) {
28079
- const invoker2 = createLocalCliAgentInvoker({
28080
- onDebugEvent: (name, payload) => getDebugLogger().event("agent", name, payload)
28081
- });
28082
- const selectBuckets = bucketComponentsProps(componentsToRun);
28083
- for (const assignment of selectBuckets) {
28084
- getDebugLogger().event("analyze", "prop-buckets.select", { ...assignment });
28085
- }
28086
- const prompt = await buildPrompt({
28087
- skill: "select",
28088
- mode: "autonomous",
28089
- rawComponentsInline: JSON.stringify(
28090
- componentsToRun.map((component) => ({ ...component, props: component.props.map(stripPropProvenance) })),
28091
- null,
28092
- 2
28093
- ),
28094
- propBucketsInline: JSON.stringify(selectBuckets),
28095
- outDir: process.cwd(),
28096
- ...options.promptText !== void 0 ? { skillContentOverride: options.promptText } : {},
28097
- ...options.promptText === void 0 && options.promptPath ? { skillPathOverride: options.promptPath } : {}
28098
- });
28099
- const { result } = await invokeAgentWithOutput(
28100
- invoker2,
28101
- { agent: options.agent, model: options.model, prompt, timeoutMs: DEFAULT_TIMEOUT_MS4 },
28102
- false
28103
- );
28104
- if (result.timedOut) throw new Error("selection agent timed out");
28105
- if (result.exitCode !== 0) throw new Error(`selection agent exited with code ${result.exitCode}`);
28106
- const parsed = parseSelectToolCallLines(result.stdout);
28107
- for (const warning of parsed.warnings) process.stderr.write(`Warning: selection agent: ${warning}
28108
- `);
28109
- calls = parsed.calls;
27222
+ const invoker2 = createLocalCliAgentInvoker({
27223
+ onDebugEvent: (name, payload) => getDebugLogger().event("agent", name, payload)
27224
+ });
27225
+ const selectBuckets = bucketComponentsProps(components);
27226
+ for (const assignment of selectBuckets) {
27227
+ getDebugLogger().event("analyze", "prop-buckets.select", { ...assignment });
28110
27228
  }
28111
- const byName = new Map(calls.map((call) => [call.name, call]));
27229
+ const prompt = await buildPrompt({
27230
+ skill: "select",
27231
+ mode: "autonomous",
27232
+ rawComponentsInline: JSON.stringify(
27233
+ components.map((component) => ({ ...component, props: component.props.map(stripPropProvenance) })),
27234
+ null,
27235
+ 2
27236
+ ),
27237
+ propBucketsInline: JSON.stringify(selectBuckets),
27238
+ outDir: process.cwd(),
27239
+ ...options.promptText !== void 0 ? { skillContentOverride: options.promptText } : {},
27240
+ ...options.promptText === void 0 && options.promptPath ? { skillPathOverride: options.promptPath } : {}
27241
+ });
27242
+ const { result } = await invokeAgentWithOutput(
27243
+ invoker2,
27244
+ { agent: options.agent, model: options.model, prompt, timeoutMs: DEFAULT_TIMEOUT_MS4 },
27245
+ false
27246
+ );
27247
+ if (result.timedOut) throw new Error("selection agent timed out");
27248
+ if (result.exitCode !== 0) throw new Error(`selection agent exited with code ${result.exitCode}`);
27249
+ const parsed = parseSelectToolCallLines(result.stdout);
27250
+ for (const warning of parsed.warnings) process.stderr.write(`Warning: selection agent: ${warning}
27251
+ `);
27252
+ const byName = new Map(parsed.calls.map((call) => [call.name, call]));
28112
27253
  const writeDb = openPipelineDb();
28113
27254
  try {
28114
27255
  writeDb.exec("BEGIN");
@@ -28116,27 +27257,15 @@ async function runSelectionAgent(options) {
28116
27257
  `UPDATE raw_components SET status = ?, reject_reason = ? WHERE session_id = ? AND component_id = ?`
28117
27258
  );
28118
27259
  for (const component of components) {
28119
- const cached = cachedDecisions.get(component.name);
28120
27260
  const call = byName.get(component.name);
28121
- if (!cached && !call) continue;
28122
- const rejected = cached ? cached.decision === "rejected" : call.tool === "reject_component";
28123
- const reason = cached ? cached.reason : call.reason ?? null;
27261
+ if (!call) continue;
27262
+ const rejected = call.tool === "reject_component";
28124
27263
  update.run(
28125
27264
  rejected ? "rejected" : "accepted",
28126
- rejected ? reason : null,
27265
+ rejected ? call.reason ?? null : null,
28127
27266
  options.sessionId,
28128
27267
  component.component_id
28129
27268
  );
28130
- if (!cached) {
28131
- storeSelectCache(
28132
- writeDb,
28133
- hashComponentShape(component),
28134
- promptHash,
28135
- cliVersion2,
28136
- rejected ? "rejected" : "accepted",
28137
- rejected ? reason : null
28138
- );
28139
- }
28140
27269
  }
28141
27270
  writeDb.exec("COMMIT");
28142
27271
  } catch (error) {
@@ -28146,7 +27275,7 @@ async function runSelectionAgent(options) {
28146
27275
  writeDb.close();
28147
27276
  }
28148
27277
  }
28149
- var SELECT_PAYLOAD_FORMAT, DEFAULT_TIMEOUT_MS4;
27278
+ var DEFAULT_TIMEOUT_MS4;
28150
27279
  var init_run_selection_agent = __esm({
28151
27280
  "packages/experience-design-system-cli-legacy/src/import/tui/run-selection-agent.ts"() {
28152
27281
  "use strict";
@@ -28155,8 +27284,6 @@ var init_run_selection_agent = __esm({
28155
27284
  init_debug_logger();
28156
27285
  init_agent_output();
28157
27286
  init_db();
28158
- init_cache_keys();
28159
- SELECT_PAYLOAD_FORMAT = "prop-buckets-v1";
28160
27287
  DEFAULT_TIMEOUT_MS4 = Number(process.env.EDS_AGENT_TIMEOUT_MS ?? 5 * 60 * 1e3);
28161
27288
  }
28162
27289
  });
@@ -28175,7 +27302,7 @@ __export(WizardApp_exports, {
28175
27302
  });
28176
27303
  import { useEffect as useEffect15, useRef as useRef10, useState as useState23 } from "react";
28177
27304
  import { Box as Box42, Text as Text46 } from "ink";
28178
- import { join as join23, resolve as resolve18 } from "node:path";
27305
+ import { join as join23, resolve as resolve17 } from "node:path";
28179
27306
  import { appendFileSync as appendFileSync2, writeFileSync } from "node:fs";
28180
27307
  import { access as access7, stat as stat5, writeFile as writeFile6 } from "node:fs/promises";
28181
27308
  import { tmpdir } from "node:os";
@@ -28188,28 +27315,21 @@ function buildGenerateComponentsArgs(opts) {
28188
27315
  if (opts.tokensPath) args.push("--tokens", opts.tokensPath);
28189
27316
  if (opts.model) args.push("--model", opts.model);
28190
27317
  if (opts.bedrock) args.push("--bedrock");
28191
- if (opts.noCache) args.push("--no-cache");
28192
27318
  if (opts.generatePromptPath) args.push("--generate-prompt-path", opts.generatePromptPath);
28193
27319
  for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
28194
27320
  if (opts.existingEntitiesPath) args.push("--existing-entities-path", opts.existingEntitiesPath);
28195
- if (opts.restoreCache) args.push("--restore-cache");
28196
- if (opts.cachedComponents && opts.cachedComponents.length > 0) {
28197
- args.push("--cached-components", JSON.stringify(opts.cachedComponents));
28198
- }
28199
27321
  return args;
28200
27322
  }
28201
27323
  function buildGenerateTokensArgs(opts) {
28202
27324
  const args = [findCliPath(), "__generate", "tokens", "--agent", opts.agent, "--raw-tokens", opts.rawTokensPath];
28203
27325
  if (opts.model) args.push("--model", opts.model);
28204
27326
  if (opts.bedrock) args.push("--bedrock");
28205
- if (opts.noCache) args.push("--no-cache");
28206
27327
  for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
28207
27328
  return args;
28208
27329
  }
28209
27330
  function buildMapTokensArgs(opts) {
28210
27331
  const args = ["map", "tokens", "--session", opts.sessionId, "--agent", opts.agent];
28211
27332
  if (opts.model) args.push("--model", opts.model);
28212
- if (opts.noCache) args.push("--no-cache");
28213
27333
  if (opts.skipAgent) args.push("--skip-agent");
28214
27334
  for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
28215
27335
  if (opts.existingEntitiesPath) args.push("--existing-entities-path", opts.existingEntitiesPath);
@@ -28301,7 +27421,6 @@ function WizardApp({
28301
27421
  initialProjectPath,
28302
27422
  host,
28303
27423
  promptOverrides,
28304
- noCache = false,
28305
27424
  livePreview = true,
28306
27425
  generatePromptPath,
28307
27426
  skipMapTokens = false,
@@ -28326,7 +27445,6 @@ function WizardApp({
28326
27445
  });
28327
27446
  const allowEmptyDeleteAllRef = useRef10(false);
28328
27447
  const generateChildRef = useRef10(null);
28329
- const generationCachePreflightRef = useRef10(null);
28330
27448
  const selectionToReviewStartedAtRef = useRef10(null);
28331
27449
  const credentialsValidationIdRef = useRef10(0);
28332
27450
  const pendingCredentialValidationRef = useRef10(null);
@@ -28341,9 +27459,8 @@ function WizardApp({
28341
27459
  const existingEntitiesPromiseRef = useRef10(null);
28342
27460
  const generatePromiseRef = useRef10(null);
28343
27461
  const rawTokensEntryReady = !!initialRawTokensPath;
28344
- const effectiveNoCache = resolveNoCacheForGenerate({ cliNoCache: noCache });
28345
27462
  const initialStepResolved = rawTokensEntryReady ? initialProjectPath ? "path-validation" : "credentials" : initialProjectPath ? "token-input" : "welcome";
28346
- const initialOutDir = initialProjectPath ? join23(resolve18(initialProjectPath), ".contentful") : "";
27463
+ const initialOutDir = initialProjectPath ? join23(resolve17(initialProjectPath), ".contentful") : "";
28347
27464
  const [state, setState] = useState23({
28348
27465
  step: initialStepResolved,
28349
27466
  agent: initialAgent ?? "claude",
@@ -28519,14 +27636,13 @@ If you are using AWS Bedrock, run:
28519
27636
  if (!deferStep) update({ step: nextStep });
28520
27637
  return true;
28521
27638
  };
28522
- const runGenerateTokens = async (rawTokensPath, outDir, forceRegenerate = false) => {
27639
+ const runGenerateTokens = async (rawTokensPath, outDir) => {
28523
27640
  update({ tokenGenerationStatus: "running" });
28524
27641
  const tokenArgs = buildGenerateTokensArgs({
28525
27642
  rawTokensPath,
28526
27643
  agent: state.agent,
28527
27644
  ...state.agentModel ? { model: state.agentModel } : {},
28528
27645
  ...state.bedrock ? { bedrock: true } : {},
28529
- noCache: effectiveNoCache || forceRegenerate,
28530
27646
  promptOverrides
28531
27647
  });
28532
27648
  const result = await runSpawnedCli(tokenArgs);
@@ -28575,7 +27691,6 @@ If you are using AWS Bedrock, run:
28575
27691
  const timer = startWizardTimer("token-mapping", {
28576
27692
  sessionId: sessionId2,
28577
27693
  silent,
28578
- noCache: effectiveNoCache,
28579
27694
  skipAgent: skipMapTokens
28580
27695
  });
28581
27696
  let mappablePropCount = 0;
@@ -28584,7 +27699,7 @@ If you are using AWS Bedrock, run:
28584
27699
  const db = openPipelineDb();
28585
27700
  try {
28586
27701
  if (state.tokenSessionId && state.tokenSessionId !== sessionId2) {
28587
- copyTokensFromCache(db, state.tokenSessionId, sessionId2);
27702
+ copyTokensBetweenSessions(db, state.tokenSessionId, sessionId2);
28588
27703
  } else if (!state.tokenSessionId && state.tokensPath) {
28589
27704
  const tokens = await readTokensFromPath("tokens", state.tokensPath);
28590
27705
  storeDtcgTokens(db, sessionId2, [], tokens);
@@ -28624,7 +27739,6 @@ If you are using AWS Bedrock, run:
28624
27739
  sessionId: sessionId2,
28625
27740
  agent: state.agent,
28626
27741
  ...state.agentModel ? { model: state.agentModel } : {},
28627
- noCache: effectiveNoCache,
28628
27742
  skipAgent: skipMapTokens,
28629
27743
  promptOverrides,
28630
27744
  ...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {}
@@ -28704,7 +27818,7 @@ If you are using AWS Bedrock, run:
28704
27818
  return promise;
28705
27819
  };
28706
27820
  const runExtract = async (projectPath, showProgress = true) => {
28707
- const outDir = join23(resolve18(projectPath), ".contentful");
27821
+ const outDir = join23(resolve17(projectPath), ".contentful");
28708
27822
  const existingEntitiesExpected = !state.credentialsSkipped && Boolean(state.spaceId && state.environmentId && state.cmaToken && projectPath);
28709
27823
  update({
28710
27824
  ...showProgress ? { step: "extracting" } : {},
@@ -28719,7 +27833,6 @@ If you are using AWS Bedrock, run:
28719
27833
  });
28720
27834
  const existingEntitiesPromise = startExistingEntitiesFetch(projectPath, outDir);
28721
27835
  const extractArgs = [findCliPath(), "__extract", "--project", projectPath];
28722
- if (effectiveNoCache) extractArgs.push("--no-cache");
28723
27836
  let selectionPromptText;
28724
27837
  let selectionPromptPath;
28725
27838
  try {
@@ -28728,7 +27841,7 @@ If you are using AWS Bedrock, run:
28728
27841
  const selectOverride = overrides.get("select");
28729
27842
  if (selectOverride?.kind === "text") selectionPromptText = selectOverride.value;
28730
27843
  if (selectOverride?.kind === "path") {
28731
- selectionPromptPath = resolve18(selectOverride.value);
27844
+ selectionPromptPath = resolve17(selectOverride.value);
28732
27845
  await resolvePromptOverride(selectOverride);
28733
27846
  }
28734
27847
  } catch (error) {
@@ -28752,8 +27865,7 @@ If you are using AWS Bedrock, run:
28752
27865
  agent: state.agent,
28753
27866
  ...state.agentModel ? { model: state.agentModel } : {},
28754
27867
  ...selectionPromptText !== void 0 ? { promptText: selectionPromptText } : {},
28755
- ...selectionPromptPath ? { promptPath: selectionPromptPath } : {},
28756
- noCache: effectiveNoCache
27868
+ ...selectionPromptPath ? { promptPath: selectionPromptPath } : {}
28757
27869
  });
28758
27870
  })().catch((error) => {
28759
27871
  selectionError = error;
@@ -28898,136 +28010,17 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
28898
28010
  generateProgress: null
28899
28011
  }));
28900
28012
  };
28901
- const buildGenerateOptions = (extractSessionId, tokensPath, generatePromptPath2, cachedComponents) => ({
28013
+ const buildGenerateOptions = (extractSessionId, tokensPath, generatePromptPath2) => ({
28902
28014
  sessionId: extractSessionId,
28903
28015
  tokensPath,
28904
28016
  agent: state.agent,
28905
28017
  ...state.agentModel ? { model: state.agentModel } : {},
28906
28018
  ...state.bedrock ? { bedrock: true } : {},
28907
- noCache: effectiveNoCache,
28908
28019
  ...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {},
28909
28020
  ...generatePromptPath2 ? { generatePromptPath: generatePromptPath2 } : {},
28910
- promptOverrides,
28911
- ...cachedComponents && cachedComponents.length > 0 ? { cachedComponents } : {}
28021
+ promptOverrides
28912
28022
  });
28913
- const buildGenerateArgs = (extractSessionId, tokensPath, generatePromptPath2, cachedComponents) => buildGenerateProcessArgs(buildGenerateOptions(extractSessionId, tokensPath, generatePromptPath2, cachedComponents));
28914
- const buildGenerateCliArgs = (extractSessionId, tokensPath, generatePromptPath2, cachedComponents) => buildGenerateComponentsArgs(
28915
- buildGenerateOptions(extractSessionId, tokensPath, generatePromptPath2, cachedComponents)
28916
- );
28917
- const checkGenerateCache = async (extractSessionId, tokensPath) => {
28918
- const timer = startWizardTimer("generation-cache-status", {
28919
- sessionId: extractSessionId,
28920
- noCache: effectiveNoCache
28921
- });
28922
- if (effectiveNoCache) {
28923
- finishWizardTimer("generation-cache-status", timer, { status: "skipped" });
28924
- return false;
28925
- }
28926
- const result = await runCli([...buildGenerateCliArgs(extractSessionId, tokensPath), "--cache-status"]);
28927
- const hit = result.exitCode === 0 && /^cache-status=hit$/m.test(result.stdout);
28928
- finishWizardTimer("generation-cache-status", timer, {
28929
- status: hit ? "hit" : "miss",
28930
- exitCode: result.exitCode,
28931
- ...result.exitCode !== 0 ? { stderrTail: result.stderr.trim().slice(-500) } : {}
28932
- });
28933
- return hit;
28934
- };
28935
- const checkGenerateCacheComponents = async (extractSessionId, tokensPath, restoreCache = false) => {
28936
- const timer = startWizardTimer("generation-cache-components", {
28937
- sessionId: extractSessionId,
28938
- restoreCache,
28939
- noCache: effectiveNoCache
28940
- });
28941
- if (effectiveNoCache) {
28942
- finishWizardTimer("generation-cache-components", timer, { status: "skipped" });
28943
- return /* @__PURE__ */ new Set();
28944
- }
28945
- const args = [...buildGenerateCliArgs(extractSessionId, tokensPath), "--cache-status"];
28946
- if (restoreCache) args.push("--restore-cache");
28947
- const result = await runCli(args);
28948
- if (result.exitCode !== 0) {
28949
- finishWizardTimer("generation-cache-components", timer, {
28950
- status: "error",
28951
- exitCode: result.exitCode,
28952
- stderrTail: result.stderr.trim().slice(-500)
28953
- });
28954
- return /* @__PURE__ */ new Set();
28955
- }
28956
- const line = /^cache-components=(.+)$/m.exec(result.stdout)?.[1];
28957
- if (!line) {
28958
- finishWizardTimer("generation-cache-components", timer, {
28959
- status: "missing-output",
28960
- exitCode: result.exitCode,
28961
- cachedCount: 0
28962
- });
28963
- return /* @__PURE__ */ new Set();
28964
- }
28965
- try {
28966
- const names = JSON.parse(line);
28967
- const cachedNames = new Set(
28968
- Array.isArray(names) ? names.filter((name) => typeof name === "string") : []
28969
- );
28970
- finishWizardTimer("generation-cache-components", timer, {
28971
- status: "complete",
28972
- exitCode: result.exitCode,
28973
- cachedCount: cachedNames.size
28974
- });
28975
- return cachedNames;
28976
- } catch {
28977
- finishWizardTimer("generation-cache-components", timer, {
28978
- status: "invalid-output",
28979
- exitCode: result.exitCode,
28980
- cachedCount: 0
28981
- });
28982
- return /* @__PURE__ */ new Set();
28983
- }
28984
- };
28985
- useEffect15(() => {
28986
- if (state.step !== "extracting" && state.step !== "scope-gate" || !state.extractSessionId || state.existingEntitiesStatus === "running" || state.existingEntitiesStatus === "idle" || state.selectionAgentStatus !== "complete" || state.compositionPhase !== "done" || state.rawTokensPath && state.tokenGenerationStatus !== "complete" || effectiveNoCache) {
28987
- return;
28988
- }
28989
- const sessionId2 = state.extractSessionId;
28990
- if (generationCachePreflightRef.current?.sessionId === sessionId2) return;
28991
- const timer = startWizardTimer("generation-cache-preflight", { sessionId: sessionId2 });
28992
- const db = openPipelineDb();
28993
- let generatedNames = null;
28994
- try {
28995
- const rows = db.prepare("SELECT name, status FROM raw_components WHERE session_id = ?").all(sessionId2);
28996
- if (rows.length > 0 && rows.every((row) => row.status === "generated")) {
28997
- generatedNames = new Set(rows.map((row) => row.name));
28998
- }
28999
- } finally {
29000
- db.close();
29001
- }
29002
- if (generatedNames) {
29003
- generationCachePreflightRef.current = { sessionId: sessionId2, promise: Promise.resolve(generatedNames) };
29004
- finishWizardTimer("generation-cache-preflight", timer, {
29005
- status: "complete",
29006
- source: "session-db",
29007
- cachedCount: generatedNames.size
29008
- });
29009
- return;
29010
- }
29011
- const promise = checkGenerateCacheComponents(sessionId2, state.tokensPath, true);
29012
- generationCachePreflightRef.current = { sessionId: sessionId2, promise };
29013
- void promise.then((cachedNames) => {
29014
- finishWizardTimer("generation-cache-preflight", timer, {
29015
- status: "complete",
29016
- source: "cache-status",
29017
- cachedCount: cachedNames.size
29018
- });
29019
- });
29020
- }, [
29021
- state.step,
29022
- state.extractSessionId,
29023
- state.tokensPath,
29024
- state.rawTokensPath,
29025
- state.tokenGenerationStatus,
29026
- state.selectionAgentStatus,
29027
- state.compositionPhase,
29028
- state.existingEntitiesStatus,
29029
- state.existingEntitiesPath
29030
- ]);
28023
+ const buildGenerateArgs = (extractSessionId, tokensPath, generatePromptPath2) => buildGenerateProcessArgs(buildGenerateOptions(extractSessionId, tokensPath, generatePromptPath2));
29031
28024
  const startGeneratePrefetch = (extractSessionId, tokensPath) => {
29032
28025
  const args = buildGenerateArgs(extractSessionId, tokensPath);
29033
28026
  let progressCursor = null;
@@ -29082,14 +28075,13 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
29082
28075
  });
29083
28076
  return donePromise;
29084
28077
  };
29085
- const runGenerate = async (extractSessionId, tokensPath, acceptedCount, suppressScreen = false, cachedComponents = []) => {
28078
+ const runGenerate = async (extractSessionId, tokensPath, acceptedCount, suppressScreen = false) => {
29086
28079
  const timer = startWizardTimer("component-generation", {
29087
28080
  sessionId: extractSessionId,
29088
28081
  acceptedCount,
29089
- suppressScreen,
29090
- noCache: effectiveNoCache
28082
+ suppressScreen
29091
28083
  });
29092
- const args = buildGenerateArgs(extractSessionId, tokensPath, generatePromptPath, cachedComponents);
28084
+ const args = buildGenerateArgs(extractSessionId, tokensPath, generatePromptPath);
29093
28085
  let progressCursor = state.generateProgress;
29094
28086
  const { donePromise } = spawnGenerateChild({
29095
28087
  command: "node",
@@ -29159,25 +28151,6 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
29159
28151
  finishSelectionToReviewTimer("error");
29160
28152
  }
29161
28153
  };
29162
- const finishCachedGeneration = async (sessionId2, acceptedCount) => {
29163
- if (await runMapTokens2(sessionId2, true)) {
29164
- finishSelectionToReviewTimer("cached");
29165
- update(
29166
- {
29167
- acceptedCount,
29168
- autoRejectedCount: 0,
29169
- generateSessionId: sessionId2,
29170
- generatedCount: acceptedCount,
29171
- generateProgress: null,
29172
- mapTokensStatus: "complete",
29173
- step: "final-review"
29174
- },
29175
- { clearScreen: false }
29176
- );
29177
- } else {
29178
- finishSelectionToReviewTimer("error");
29179
- }
29180
- };
29181
28154
  const advanceToPushFlow = (generatedAcceptedCount) => {
29182
28155
  update({ generatedAcceptedCount });
29183
28156
  void runSaveAndPush();
@@ -29362,14 +28335,8 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
29362
28335
  }
29363
28336
  }
29364
28337
  if (await runAgentAuthCheck("generating", true)) {
29365
- const cacheHit = await checkGenerateCache(sid, state.tokensPath);
29366
- if (cacheHit) {
29367
- update({ step: "generating" });
29368
- void finishCachedGeneration(sid, state.acceptedCount);
29369
- } else {
29370
- update({ step: "generating" });
29371
- void runGenerate(sid, state.tokensPath, state.acceptedCount);
29372
- }
28338
+ update({ step: "generating" });
28339
+ void runGenerate(sid, state.tokensPath, state.acceptedCount);
29373
28340
  }
29374
28341
  return;
29375
28342
  }
@@ -29733,7 +28700,7 @@ If using a custom host configuration, make sure the space exists on that host.`
29733
28700
  });
29734
28701
  return { ok: false };
29735
28702
  }
29736
- await new Promise((resolve21) => setTimeout(resolve21, SAVE_CONFIRMATION_DELAY_MS));
28703
+ await new Promise((resolve20) => setTimeout(resolve20, SAVE_CONFIRMATION_DELAY_MS));
29737
28704
  update(nextStateAfterPrint({ skipGate: opts.skipGate, componentsPath }));
29738
28705
  return { ok: true };
29739
28706
  };
@@ -29810,12 +28777,6 @@ If using a custom host configuration, make sure the space exists on that host.`
29810
28777
  tokenReuseChecked.current = true;
29811
28778
  const tokenNextStep = state.projectPath ? "path-validation" : "credentials";
29812
28779
  const existingTokensPath = join23(state.outDir, "tokens.json");
29813
- if (effectiveNoCache) {
29814
- tokenGenerationPromiseRef.current = runAgentAuthCheck(tokenNextStep).then(
29815
- (ok2) => ok2 ? runGenerateTokens(state.rawTokensPath, state.outDir) : false
29816
- );
29817
- return;
29818
- }
29819
28780
  (async () => {
29820
28781
  try {
29821
28782
  await access7(existingTokensPath);
@@ -29899,7 +28860,7 @@ If using a custom host configuration, make sure the space exists on that host.`
29899
28860
  const tokenNextStep = state.projectPath ? "path-validation" : "credentials";
29900
28861
  update({ step: tokenNextStep });
29901
28862
  if (await runAgentAuthCheck(tokenNextStep)) {
29902
- tokenGenerationPromiseRef.current = runGenerateTokens(state.rawTokensPath, state.outDir, true);
28863
+ tokenGenerationPromiseRef.current = runGenerateTokens(state.rawTokensPath, state.outDir);
29903
28864
  }
29904
28865
  },
29905
28866
  onQuit: () => process.exit(0)
@@ -29998,29 +28959,6 @@ If using a custom host configuration, make sure the space exists on that host.`
29998
28959
  acceptedCount: decisions.accepted.length,
29999
28960
  rejectedCount: decisions.rejected.length
30000
28961
  }) : null;
30001
- const preflight = generationCachePreflightRef.current;
30002
- const cachePromise = preflight?.sessionId === sessionId2 ? preflight.promise : checkGenerateCacheComponents(sessionId2, state.tokensPath, true);
30003
- if (!preflight || preflight.sessionId !== sessionId2) {
30004
- generationCachePreflightRef.current = { sessionId: sessionId2, promise: cachePromise };
30005
- }
30006
- const cacheWaitStartedAt = startWizardTimer("selection-cache-restoration-wait", {
30007
- sessionId: sessionId2,
30008
- preflight: Boolean(preflight?.sessionId === sessionId2)
30009
- });
30010
- try {
30011
- const cachedNames = await cachePromise;
30012
- finishWizardTimer("selection-cache-restoration-wait", cacheWaitStartedAt, {
30013
- status: "complete",
30014
- cachedCount: cachedNames.size
30015
- });
30016
- } catch (error) {
30017
- finishWizardTimer("selection-cache-restoration-wait", cacheWaitStartedAt, {
30018
- status: "error",
30019
- error: error instanceof Error ? error.message : String(error)
30020
- });
30021
- finishSelectionToReviewTimer("error");
30022
- throw error;
30023
- }
30024
28962
  await runScopeGate({
30025
28963
  sessionId: sessionId2,
30026
28964
  decisions,
@@ -30029,35 +28967,12 @@ If using a custom host configuration, make sure the space exists on that host.`
30029
28967
  if (shouldGenerateAfterScopeGate({ acceptedCount })) {
30030
28968
  const authPromise = runAgentAuthCheck("generating", true);
30031
28969
  if (await authPromise) {
30032
- const comparisonStartedAt = startWizardTimer("generation-cache-set-comparison", {
30033
- sessionId: sid,
30034
- acceptedCount: decisions?.accepted.length ?? 0
30035
- });
30036
- let cachedNames = await cachePromise;
30037
- const acceptedNames = decisions?.accepted ?? [];
30038
- let cacheHit = !effectiveNoCache && acceptedNames.length > 0 && acceptedNames.every((name) => cachedNames.has(name));
30039
- if (!cacheHit && !effectiveNoCache && acceptedNames.length > 0) {
30040
- cachedNames = await checkGenerateCacheComponents(sid, state.tokensPath, true);
30041
- cacheHit = acceptedNames.every((name) => cachedNames.has(name));
30042
- }
30043
- finishWizardTimer("generation-cache-set-comparison", comparisonStartedAt, {
30044
- status: "complete",
30045
- cacheHit,
30046
- cachedCount: cachedNames.size,
30047
- acceptedCount: acceptedNames.length
28970
+ update({
28971
+ step: "generating",
28972
+ generateProgress: null,
28973
+ acceptedCount
30048
28974
  });
30049
- if (cacheHit) {
30050
- void finishCachedGeneration(sid, acceptedCount);
30051
- } else {
30052
- const acceptedNameSet = new Set(acceptedNames);
30053
- const restoredCachedNames = [...cachedNames].filter((name) => acceptedNameSet.has(name));
30054
- update({
30055
- step: "generating",
30056
- generateProgress: null,
30057
- acceptedCount
30058
- });
30059
- void runGenerate(sid, state.tokensPath, acceptedCount, false, restoredCachedNames);
30060
- }
28975
+ void runGenerate(sid, state.tokensPath, acceptedCount);
30061
28976
  } else {
30062
28977
  finishSelectionToReviewTimer("error");
30063
28978
  }
@@ -30423,7 +29338,7 @@ function registerImportCommand(program) {
30423
29338
  "Override a composition, selection, token, generation, or token-mapping prompt (repeatable). value is a file path or literal text, e.g. --prompt select=./p.md",
30424
29339
  (v, acc) => [...acc, v],
30425
29340
  []
30426
- ).option("--no-cache", "Re-run all steps even if output already exists").action(async (opts) => {
29341
+ ).action(async (opts) => {
30427
29342
  const interactiveTerminalSupported = getInteractiveTerminalSupport().supported;
30428
29343
  if (opts.tokens !== void 0) {
30429
29344
  const { access: access9 } = await import("node:fs/promises");
@@ -30460,7 +29375,6 @@ function registerImportCommand(program) {
30460
29375
  ...resolvedModel ? { initialModel: resolvedModel } : {},
30461
29376
  initialProjectPath: opts.project !== "." ? normalizePath(opts.project) : void 0,
30462
29377
  ...buildCompositionForwardingOptions(opts),
30463
- noCache: opts.cache === false,
30464
29378
  skipMapTokens: false,
30465
29379
  livePreview: true,
30466
29380
  generatePromptPath: creds.generatePromptPath,
@@ -30548,7 +29462,7 @@ async function pathExists3(path) {
30548
29462
  return access8(path).then(() => true).catch(() => false);
30549
29463
  }
30550
29464
  function runSpawn(cmd, args, opts = {}) {
30551
- return new Promise((resolve21) => {
29465
+ return new Promise((resolve20) => {
30552
29466
  const child = spawn6(cmd, args, {
30553
29467
  cwd: opts.cwd,
30554
29468
  env: opts.env ?? process.env,
@@ -30560,7 +29474,7 @@ function runSpawn(cmd, args, opts = {}) {
30560
29474
  const settle = (result) => {
30561
29475
  if (settled) return;
30562
29476
  settled = true;
30563
- resolve21(result);
29477
+ resolve20(result);
30564
29478
  };
30565
29479
  child.on("error", (err) => settle({ exitCode: 1, stdout: "", stderr: err.message }));
30566
29480
  child.stdout.on("data", (d) => {
@@ -31761,13 +30675,13 @@ function PrerequisitesScreen({
31761
30675
  const driver = {
31762
30676
  ...base,
31763
30677
  emit: (event) => setEvents((current) => [...current, event]),
31764
- confirm: (question, defaultYes = true) => new Promise((resolve21) => {
30678
+ confirm: (question, defaultYes = true) => new Promise((resolve20) => {
31765
30679
  setConfirm({
31766
30680
  question,
31767
30681
  defaultYes,
31768
30682
  resolve: (answer) => {
31769
30683
  setConfirm(null);
31770
- resolve21(answer);
30684
+ resolve20(answer);
31771
30685
  }
31772
30686
  });
31773
30687
  })
@@ -31842,8 +30756,8 @@ function SetupScreen({
31842
30756
  useEffect21(() => {
31843
30757
  if (startedRef.current) return;
31844
30758
  startedRef.current = true;
31845
- const runScreen = (build) => new Promise((resolve21) => {
31846
- setScreen(build(resolve21));
30759
+ const runScreen = (build) => new Promise((resolve20) => {
30760
+ setScreen(build(resolve20));
31847
30761
  });
31848
30762
  void (async () => {
31849
30763
  const results = [];
@@ -32451,11 +31365,8 @@ var init_source_call_site_evidence = __esm({
32451
31365
  });
32452
31366
 
32453
31367
  // packages/experience-design-system-cli-legacy/src/analyze/extract-command.ts
32454
- import { mkdir as mkdir6, readdir as readdir3, readFile as readFile19, stat as stat6 } from "node:fs/promises";
32455
- import { isAbsolute as isAbsolute2, join as join27, relative as relative2, resolve as resolve19 } from "node:path";
32456
- function resolveExtractNoCache(opts) {
32457
- return opts.noCache === true || opts.cache === false;
32458
- }
31368
+ import { mkdir as mkdir6, readdir as readdir3, readFile as readFile18, stat as stat6 } from "node:fs/promises";
31369
+ import { isAbsolute as isAbsolute2, join as join27, relative as relative2, resolve as resolve18 } from "node:path";
32459
31370
  function isDenylistedNoiseFile(name) {
32460
31371
  return DENYLISTED_EXACT_FILE_NAMES.has(name) || DENYLISTED_FILE_NAME_PATTERNS.some((pattern) => pattern.test(name));
32461
31372
  }
@@ -32469,12 +31380,12 @@ async function retryDatabaseWrite(operation, attempts = 8) {
32469
31380
  } catch (error) {
32470
31381
  const message = error instanceof Error ? error.message : String(error);
32471
31382
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts) throw error;
32472
- await new Promise((resolve21) => setTimeout(resolve21, Math.min(250 * attempt, 2e3)));
31383
+ await new Promise((resolve20) => setTimeout(resolve20, Math.min(250 * attempt, 2e3)));
32473
31384
  }
32474
31385
  }
32475
31386
  }
32476
31387
  function resolveFromProjectRoot(projectRoot, inputPath) {
32477
- return isAbsolute2(inputPath) ? inputPath : resolve19(projectRoot, inputPath);
31388
+ return isAbsolute2(inputPath) ? inputPath : resolve18(projectRoot, inputPath);
32478
31389
  }
32479
31390
  async function pathExists4(path) {
32480
31391
  return Boolean(await stat6(path).catch(() => null));
@@ -32521,7 +31432,7 @@ async function readCandidateFiles(components, extraFiles = []) {
32521
31432
  await Promise.all(
32522
31433
  [...paths].map(async (p) => {
32523
31434
  try {
32524
- const content = await readFile19(p, "utf8");
31435
+ const content = await readFile18(p, "utf8");
32525
31436
  out.push({ path: p, content });
32526
31437
  } catch {
32527
31438
  }
@@ -32534,8 +31445,7 @@ function registerInternalExtractCommand(program) {
32534
31445
  "--resolve-unreachable <mode>",
32535
31446
  "Retry pass for unresolved Svelte Props types: 'auto' (default), 'always', or 'never'",
32536
31447
  "auto"
32537
- ).option("--no-cache", "Re-run extraction even when all source files are unchanged").action(async (opts) => {
32538
- const noCache = resolveExtractNoCache(opts);
31448
+ ).action(async (opts) => {
32539
31449
  const resolveUnreachable = (() => {
32540
31450
  const v = opts.resolveUnreachable ?? "auto";
32541
31451
  if (v !== "auto" && v !== "always" && v !== "never") {
@@ -32545,7 +31455,7 @@ function registerInternalExtractCommand(program) {
32545
31455
  }
32546
31456
  return v;
32547
31457
  })();
32548
- const projectRoot = resolve19(opts.project);
31458
+ const projectRoot = resolve18(opts.project);
32549
31459
  const outDir = join27(projectRoot, ".contentful");
32550
31460
  let sourceDirectory;
32551
31461
  if (opts.dir !== void 0) {
@@ -32569,50 +31479,16 @@ function registerInternalExtractCommand(program) {
32569
31479
  process.stderr.write(`progress=scan-done:${sourceFiles.length}
32570
31480
  `);
32571
31481
  }
32572
- const extractionCacheDb = openPipelineDb();
32573
- let extraction;
32574
- let extractionCacheHits = 0;
32575
- try {
32576
- const cacheVersion = await getCliCacheVersion();
32577
- const cachedByPath = /* @__PURE__ */ new Map();
32578
- if (!noCache && sourceFiles.length > 0) {
32579
- const hashes = await Promise.all(
32580
- sourceFiles.map(async (filePath) => [filePath, await hashFile(filePath)])
32581
- );
32582
- for (const [filePath, fileHash] of hashes) {
32583
- cachedByPath.set(filePath, lookupExtractCache(extractionCacheDb, fileHash, cacheVersion));
32584
- }
32585
- }
32586
- const allFilesCached = !noCache && sourceFiles.length > 0 && sourceFiles.every((filePath) => cachedByPath.get(filePath) !== null);
32587
- if (allFilesCached) {
32588
- const cachedComponents = sourceFiles.flatMap((filePath) => cachedByPath.get(filePath).components);
32589
- extractionCacheHits = sourceFiles.length;
32590
- extraction = { components: cachedComponents, warnings: [], exclusions: [] };
31482
+ const extraction = await extractComponents(
31483
+ sourceFiles,
31484
+ ({ filesProcessed, componentsFound }) => {
32591
31485
  if (!process.stdout.isTTY) {
32592
- process.stderr.write(
32593
- `progress=extract:${sourceFiles.length}/${sourceFiles.length}:${cachedComponents.length}
32594
- `
32595
- );
32596
- }
32597
- getDebugLogger().event("analyze", "extract.cache-hit", {
32598
- files: sourceFiles.length,
32599
- components: cachedComponents.length
32600
- });
32601
- } else {
32602
- extraction = await extractComponents(
32603
- sourceFiles,
32604
- ({ filesProcessed, componentsFound }) => {
32605
- if (!process.stdout.isTTY) {
32606
- process.stderr.write(`progress=extract:${filesProcessed}/${sourceFiles.length}:${componentsFound}
31486
+ process.stderr.write(`progress=extract:${filesProcessed}/${sourceFiles.length}:${componentsFound}
32607
31487
  `);
32608
- }
32609
- },
32610
- { resolveUnreachable, projectRoot }
32611
- );
32612
- }
32613
- } finally {
32614
- extractionCacheDb.close();
32615
- }
31488
+ }
31489
+ },
31490
+ { resolveUnreachable, projectRoot }
31491
+ );
32616
31492
  await mkdir6(outDir, { recursive: true });
32617
31493
  const db = openPipelineDb();
32618
31494
  const { sessionId: sessionId2 } = getOrCreateSession(db, void 0, void 0, {
@@ -32627,25 +31503,6 @@ function registerInternalExtractCommand(program) {
32627
31503
  const stepId = createStep(db, sessionId2, "analyze extract", {
32628
31504
  project: projectRoot
32629
31505
  });
32630
- if (extractionCacheHits === 0 && !noCache) {
32631
- const cacheVersion = await getCliCacheVersion();
32632
- const componentsBySourcePath = /* @__PURE__ */ new Map();
32633
- for (const component of extraction.components) {
32634
- if (!component.sourcePath) continue;
32635
- const components = componentsBySourcePath.get(component.sourcePath) ?? [];
32636
- components.push(component);
32637
- componentsBySourcePath.set(component.sourcePath, components);
32638
- }
32639
- for (const filePath of sourceFiles) {
32640
- storeExtractCache(
32641
- db,
32642
- filePath,
32643
- await hashFile(filePath),
32644
- cacheVersion,
32645
- componentsBySourcePath.get(filePath) ?? []
32646
- );
32647
- }
32648
- }
32649
31506
  const classifiedComponents = extraction.components.map(preClassifyComponent);
32650
31507
  for (const exclusion of extraction.exclusions ?? []) {
32651
31508
  getDebugLogger().event("filter", "extract.excluded", { ...exclusion });
@@ -32750,7 +31607,6 @@ var init_extract_command = __esm({
32750
31607
  "use strict";
32751
31608
  init_src2();
32752
31609
  init_db();
32753
- init_cache_keys();
32754
31610
  init_cycle_detection();
32755
31611
  init_resolve_mapping();
32756
31612
  init_manifest_doc_evidence();
@@ -32849,7 +31705,7 @@ __export(program_exports, {
32849
31705
  });
32850
31706
  import { spawn as spawn7 } from "node:child_process";
32851
31707
  import { fileURLToPath as fileURLToPath3 } from "node:url";
32852
- import { dirname as dirname18, join as join28, resolve as resolve20 } from "node:path";
31708
+ import { dirname as dirname18, join as join28, resolve as resolve19 } from "node:path";
32853
31709
  import { readFileSync as readFileSync10 } from "node:fs";
32854
31710
  import { Command } from "commander";
32855
31711
  async function runBuild(opts) {
@@ -32879,7 +31735,7 @@ function resolveBedrockFromAncestors(actionCommand) {
32879
31735
  }
32880
31736
  function registerBuildCommand(program) {
32881
31737
  program.command("build").description("Rebuild from source and re-link exo/experiences binaries to this build").helpOption(false).action(async () => {
32882
- const pkgRoot = resolve20(dirname18(fileURLToPath3(import.meta.url)), "..", "..");
31738
+ const pkgRoot = resolve19(dirname18(fileURLToPath3(import.meta.url)), "..", "..");
32883
31739
  process.stderr.write("\u2699 Building from source...\n");
32884
31740
  const { exitCode } = await runBuild({
32885
31741
  spawnFn: () => spawn7("pnpm", ["build"], { cwd: pkgRoot, stdio: "inherit" }),