@contentful/experience-design-system-cli 2.37.1-dev-build-36f90a5a.0 → 2.37.1-dev-build-34dbca05.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js CHANGED
@@ -8,71 +8,6 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
- // packages/experience-design-system-cli/src/tui/package-root.ts
12
- import { existsSync, readFileSync } from "node:fs";
13
- import { dirname, join } from "node:path";
14
- import { fileURLToPath } from "node:url";
15
- function findPackageRoot(startUrl, packageName) {
16
- let dir = dirname(fileURLToPath(startUrl));
17
- let found;
18
- while (true) {
19
- const manifestPath = join(dir, "package.json");
20
- if (existsSync(manifestPath)) {
21
- const pkg = JSON.parse(readFileSync(manifestPath, "utf8"));
22
- if (pkg.name === packageName) found = dir;
23
- }
24
- const parent = dirname(dir);
25
- if (parent === dir) return found ?? dir;
26
- dir = parent;
27
- }
28
- }
29
- var init_package_root = __esm({
30
- "packages/experience-design-system-cli/src/tui/package-root.ts"() {
31
- "use strict";
32
- }
33
- });
34
-
35
- // packages/experience-design-system-cli/src/tui/upgrade/version.ts
36
- import { readFileSync as readFileSync2 } from "node:fs";
37
- import { join as join2 } from "node:path";
38
- import semver from "semver";
39
- function readPackageVersion() {
40
- const root = findPackageRoot(import.meta.url, PACKAGE_NAME);
41
- const pkg = JSON.parse(readFileSync2(join2(root, "package.json"), "utf8"));
42
- return pkg.version ?? "unknown";
43
- }
44
- function parseVersionTag(tag) {
45
- const match2 = /^v(\d+\.\d+\.\d+)$/.exec(tag);
46
- return match2 ? match2[1] : void 0;
47
- }
48
- async function checkForUpgrade() {
49
- const current = readPackageVersion();
50
- try {
51
- const response = await fetch(TAGS_URL);
52
- if (!response.ok) return { status: "error" };
53
- const tags = await response.json();
54
- const versions = tags.map((tag) => tag.name ? parseVersionTag(tag.name) : void 0).filter((v) => v !== void 0);
55
- if (versions.length === 0) return { status: "error" };
56
- const latest = versions.reduce((best, v) => semver.gt(v, best) ? v : best);
57
- if (!semver.valid(current)) return { status: "error" };
58
- if (semver.gt(latest, current)) {
59
- return { status: "update-available", current, latest };
60
- }
61
- return { status: "up-to-date", current };
62
- } catch {
63
- return { status: "error" };
64
- }
65
- }
66
- var PACKAGE_NAME, TAGS_URL;
67
- var init_version = __esm({
68
- "packages/experience-design-system-cli/src/tui/upgrade/version.ts"() {
69
- "use strict";
70
- init_package_root();
71
- PACKAGE_NAME = "@contentful/experience-design-system-cli";
72
- TAGS_URL = "https://api.github.com/repos/contentful/experience-design-system-sdk-public/tags?per_page=10";
73
- }
74
- });
75
-
76
11
  // packages/experience-design-system-backend-pipeline/dist/src/agents/types/agent-name.js
77
12
  var AGENT_NAMES;
78
13
  var init_agent_name = __esm({
@@ -837,7 +772,7 @@ async function runAgent(options) {
837
772
  promptLen: prompt.length,
838
773
  promptHead: prompt.slice(0, 500)
839
774
  });
840
- return new Promise((resolve26) => {
775
+ return new Promise((resolve25) => {
841
776
  const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
842
777
  const child = spawn(binary, args, {
843
778
  stdio: ["pipe", "pipe", "pipe"],
@@ -886,7 +821,7 @@ async function runAgent(options) {
886
821
  stderrLen: stderr.length,
887
822
  stderrTail: stderr.slice(-1e3)
888
823
  });
889
- resolve26(result);
824
+ resolve25(result);
890
825
  });
891
826
  });
892
827
  }
@@ -908,7 +843,7 @@ async function checkAgentAuth(agent) {
908
843
  return "not-found";
909
844
  if (agent !== "claude")
910
845
  return "ok";
911
- return new Promise((resolve26) => {
846
+ return new Promise((resolve25) => {
912
847
  const child = spawn2(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
913
848
  let stdout = "";
914
849
  let done = false;
@@ -917,7 +852,7 @@ async function checkAgentAuth(agent) {
917
852
  return;
918
853
  done = true;
919
854
  child.kill("SIGTERM");
920
- resolve26("unauthenticated");
855
+ resolve25("unauthenticated");
921
856
  }, 5e3);
922
857
  child.stdout?.on("data", (chunk) => {
923
858
  stdout += chunk.toString();
@@ -928,14 +863,14 @@ async function checkAgentAuth(agent) {
928
863
  done = true;
929
864
  clearTimeout(timer);
930
865
  if (code !== 0) {
931
- resolve26("unauthenticated");
866
+ resolve25("unauthenticated");
932
867
  return;
933
868
  }
934
869
  try {
935
870
  const status = JSON.parse(stdout);
936
- resolve26(status.loggedIn ? "ok" : "unauthenticated");
871
+ resolve25(status.loggedIn ? "ok" : "unauthenticated");
937
872
  } catch {
938
- resolve26("unauthenticated");
873
+ resolve25("unauthenticated");
939
874
  }
940
875
  });
941
876
  });
@@ -945,9 +880,9 @@ async function binaryIsOnPath(binary) {
945
880
  const fs = await import("node:fs/promises");
946
881
  return fs.access(binary).then(() => true, () => false);
947
882
  }
948
- return new Promise((resolve26) => {
883
+ return new Promise((resolve25) => {
949
884
  const child = spawn2(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
950
- child.on("close", (code) => resolve26(code === 0));
885
+ child.on("close", (code) => resolve25(code === 0));
951
886
  });
952
887
  }
953
888
  var init_check_agent_auth = __esm({
@@ -2081,233 +2016,6 @@ var init_cache_keys = __esm({
2081
2016
  }
2082
2017
  });
2083
2018
 
2084
- // packages/experience-design-system-types/dist/src/config/index.js
2085
- import { randomBytes as randomBytes3 } from "node:crypto";
2086
- import { mkdir as mkdir6, readFile as readFile18, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
2087
- import { homedir as homedir3 } from "node:os";
2088
- import { dirname as dirname13, join as join17 } from "node:path";
2089
- function configRoot2() {
2090
- return process.env["EDS_HOME"] || join17(homedir3(), ".contentful", "experience-design-system-cli");
2091
- }
2092
- async function readSettings2() {
2093
- try {
2094
- return JSON.parse(await readFile18(configFilePath2(), "utf8"));
2095
- } catch {
2096
- return {};
2097
- }
2098
- }
2099
- async function writeSettings2(settings) {
2100
- const path5 = configFilePath2();
2101
- await mkdir6(dirname13(path5), { recursive: true });
2102
- const tmp = `${path5}.${process.pid}.${randomBytes3(4).toString("hex")}.tmp`;
2103
- await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
2104
- `, { mode: 384 });
2105
- await rename2(tmp, path5);
2106
- }
2107
- async function updateSettings2(patch) {
2108
- await writeSettings2({ ...await readSettings2(), ...patch });
2109
- }
2110
- var configFilePath2;
2111
- var init_config = __esm({
2112
- "packages/experience-design-system-types/dist/src/config/index.js"() {
2113
- "use strict";
2114
- configFilePath2 = () => join17(configRoot2(), "config.json");
2115
- }
2116
- });
2117
-
2118
- // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
2119
- async function readDebugModeSetting() {
2120
- const { debugMode } = await readSettings2();
2121
- return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
2122
- }
2123
- async function writeDebugModeSetting(setting) {
2124
- await updateSettings2({ debugMode: setting });
2125
- }
2126
- var DEFAULT_DEBUG_MODE_SETTING;
2127
- var init_debug_mode_store = __esm({
2128
- "packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
2129
- "use strict";
2130
- init_config();
2131
- DEFAULT_DEBUG_MODE_SETTING = {
2132
- enabled: true
2133
- };
2134
- }
2135
- });
2136
-
2137
- // packages/experience-design-system-cli/src/tui/debug-store.ts
2138
- var debug_store_exports = {};
2139
- __export(debug_store_exports, {
2140
- currentDebugSessionDir: () => currentDebugSessionDir,
2141
- finishDebugRun: () => finishDebugRun,
2142
- startDebugRun: () => startDebugRun,
2143
- startDebugSessionIn: () => startDebugSessionIn
2144
- });
2145
- import { mkdir as mkdir8, writeFile as writeFile7 } from "node:fs/promises";
2146
- import { existsSync as existsSync9, readdirSync as readdirSync3 } from "node:fs";
2147
- import { join as join20, resolve as resolve23 } from "node:path";
2148
- function generateRunId() {
2149
- const now = /* @__PURE__ */ new Date();
2150
- const pad = (n) => String(n).padStart(2, "0");
2151
- return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
2152
- }
2153
- function datePrefix(now = /* @__PURE__ */ new Date()) {
2154
- const pad = (n) => String(n).padStart(2, "0");
2155
- return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
2156
- }
2157
- function slugify(value) {
2158
- return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
2159
- }
2160
- async function readBaseDir() {
2161
- try {
2162
- const dir = (await readSettings2())["contentfulBaseDir"];
2163
- return typeof dir === "string" && dir !== "" ? resolve23(dir) : void 0;
2164
- } catch {
2165
- return void 0;
2166
- }
2167
- }
2168
- function nextSessionId(contentfulDir) {
2169
- const today = datePrefix();
2170
- const existing = existsSync9(contentfulDir) ? readdirSync3(contentfulDir) : [];
2171
- const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
2172
- const maxSeq = existing.reduce((max, entry) => {
2173
- const match2 = seqPattern.exec(entry);
2174
- return match2 ? Math.max(max, Number(match2[1])) : max;
2175
- }, 0);
2176
- return `${today}-session-${maxSeq + 1}`;
2177
- }
2178
- function startSession(base) {
2179
- const contentfulDir = join20(base, ".contentful");
2180
- sessionDir ??= join20(contentfulDir, nextSessionId(contentfulDir));
2181
- return sessionDir;
2182
- }
2183
- function currentDebugSessionDir() {
2184
- return sessionDir && join20(sessionDir, "debug");
2185
- }
2186
- async function startDebugSessionIn(base) {
2187
- try {
2188
- if (!await isDebugModeEnabled()) return;
2189
- await mkdir8(join20(startSession(resolve23(base)), "debug"), { recursive: true });
2190
- } catch {
2191
- }
2192
- }
2193
- async function isDebugModeEnabled() {
2194
- try {
2195
- return (await readDebugModeSetting()).enabled;
2196
- } catch {
2197
- return true;
2198
- }
2199
- }
2200
- function redact(value) {
2201
- const clone = { ...value };
2202
- if ("cma_token" in clone) {
2203
- const raw = clone.cma_token;
2204
- clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
2205
- }
2206
- return clone;
2207
- }
2208
- function startDebugRun({
2209
- flow,
2210
- step,
2211
- menuOption,
2212
- inputs
2213
- }) {
2214
- const runId = generateRunId();
2215
- const startedAt = Date.now();
2216
- const redactedInputs = redact(inputs);
2217
- isDebugModeEnabled().then((enabled) => {
2218
- if (!enabled) return;
2219
- pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
2220
- });
2221
- }
2222
- async function finishDebugRun({
2223
- outputs,
2224
- status,
2225
- exitMethod
2226
- }) {
2227
- const run = pendingRun;
2228
- if (!run) return;
2229
- pendingRun = void 0;
2230
- const durationMs = Date.now() - run.startedAt;
2231
- const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
2232
- const root = currentDebugSessionDir();
2233
- if (!root) return;
2234
- const flowSegments = run.flow.split("/");
2235
- const dir = join20(root, ...flowSegments);
2236
- await mkdir8(dir, { recursive: true });
2237
- const filename = nextAttemptFilename(dir, run.menuOption);
2238
- await writeFile7(join20(dir, filename), content, { mode: 384 });
2239
- }
2240
- function nextAttemptFilename(dir, menuOption) {
2241
- const today = datePrefix();
2242
- const optionSlug = slugify(menuOption);
2243
- const existing = existsSync9(dir) ? readdirSync3(dir) : [];
2244
- const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
2245
- const maxAttempt = existing.reduce((max, entry) => {
2246
- const match2 = attemptPattern.exec(entry);
2247
- return match2 ? Math.max(max, Number(match2[1])) : max;
2248
- }, 0);
2249
- return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
2250
- }
2251
- function renderMarkdown(run, finish) {
2252
- const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
2253
- const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
2254
- const flowSlug = run.flow.split("/").join("-");
2255
- return `# Debug Log
2256
-
2257
- - Run ID: ${run.runId}
2258
- - Flow: ${flowSlug}
2259
- - Step: ${stepLabel2}
2260
- - Menu option: ${run.menuOption}
2261
- - Date: ${(/* @__PURE__ */ new Date()).toISOString()}
2262
- - CLI version: ${readPackageVersion()}
2263
- - Platform: ${process.platform} / Node ${process.version}
2264
- - Duration on screen: ${finish.durationMs}ms
2265
- - Status: ${finish.status}
2266
- - Exit method: ${finish.exitMethod}
2267
-
2268
- ## Inputs
2269
- \`\`\`json
2270
- ${JSON.stringify(run.inputs, null, 2)}
2271
- \`\`\`
2272
-
2273
- ## Outputs
2274
- \`\`\`json
2275
- ${JSON.stringify(finish.outputs, null, 2)}
2276
- \`\`\`
2277
- `;
2278
- }
2279
- function handleCrash() {
2280
- return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
2281
- }
2282
- var pendingRun, sessionDir;
2283
- var init_debug_store = __esm({
2284
- "packages/experience-design-system-cli/src/tui/debug-store.ts"() {
2285
- "use strict";
2286
- init_config();
2287
- init_version();
2288
- init_debug_mode_store();
2289
- void Promise.all([isDebugModeEnabled(), readBaseDir()]).then(([enabled, base]) => {
2290
- if (!enabled || !base) return void 0;
2291
- return mkdir8(join20(startSession(base), "debug"), { recursive: true });
2292
- });
2293
- process.once("uncaughtException", (err) => {
2294
- void handleCrash().finally(() => {
2295
- throw err;
2296
- });
2297
- });
2298
- process.once("unhandledRejection", (reason) => {
2299
- void handleCrash().finally(() => {
2300
- throw reason;
2301
- });
2302
- });
2303
- process.once("SIGINT", () => {
2304
- void handleCrash().finally(() => {
2305
- process.exit(130);
2306
- });
2307
- });
2308
- }
2309
- });
2310
-
2311
2019
  // packages/experience-design-system-cli/app.tsx
2312
2020
  import { join as join25 } from "node:path";
2313
2021
  import { useEffect as useEffect27, useState as useState33 } from "react";
@@ -2345,10 +2053,62 @@ function brandBar(width, ramp = BRAND_RAMP) {
2345
2053
  color
2346
2054
  })).filter((segment) => segment.text.length > 0);
2347
2055
  }
2348
- var FOCUS_MARKER = "\u276F";
2349
-
2350
- // packages/experience-design-system-cli/src/tui/home/home.tsx
2351
- init_version();
2056
+ var FOCUS_MARKER = "\u276F";
2057
+
2058
+ // packages/experience-design-system-cli/src/tui/upgrade/version.ts
2059
+ import { readFileSync as readFileSync2 } from "node:fs";
2060
+ import { join as join2 } from "node:path";
2061
+ import semver from "semver";
2062
+
2063
+ // packages/experience-design-system-cli/src/tui/package-root.ts
2064
+ import { existsSync, readFileSync } from "node:fs";
2065
+ import { dirname, join } from "node:path";
2066
+ import { fileURLToPath } from "node:url";
2067
+ function findPackageRoot(startUrl, packageName) {
2068
+ let dir = dirname(fileURLToPath(startUrl));
2069
+ let found;
2070
+ while (true) {
2071
+ const manifestPath = join(dir, "package.json");
2072
+ if (existsSync(manifestPath)) {
2073
+ const pkg = JSON.parse(readFileSync(manifestPath, "utf8"));
2074
+ if (pkg.name === packageName) found = dir;
2075
+ }
2076
+ const parent = dirname(dir);
2077
+ if (parent === dir) return found ?? dir;
2078
+ dir = parent;
2079
+ }
2080
+ }
2081
+
2082
+ // packages/experience-design-system-cli/src/tui/upgrade/version.ts
2083
+ var PACKAGE_NAME = "@contentful/experience-design-system-cli";
2084
+ var TAGS_URL = "https://api.github.com/repos/contentful/experience-design-system-sdk-public/tags?per_page=10";
2085
+ function readPackageVersion() {
2086
+ const root = findPackageRoot(import.meta.url, PACKAGE_NAME);
2087
+ const pkg = JSON.parse(readFileSync2(join2(root, "package.json"), "utf8"));
2088
+ return pkg.version ?? "unknown";
2089
+ }
2090
+ function parseVersionTag(tag) {
2091
+ const match2 = /^v(\d+\.\d+\.\d+)$/.exec(tag);
2092
+ return match2 ? match2[1] : void 0;
2093
+ }
2094
+ async function checkForUpgrade() {
2095
+ const current = readPackageVersion();
2096
+ try {
2097
+ const response = await fetch(TAGS_URL);
2098
+ if (!response.ok) return { status: "error" };
2099
+ const tags = await response.json();
2100
+ const versions = tags.map((tag) => tag.name ? parseVersionTag(tag.name) : void 0).filter((v) => v !== void 0);
2101
+ if (versions.length === 0) return { status: "error" };
2102
+ const latest = versions.reduce((best, v) => semver.gt(v, best) ? v : best);
2103
+ if (!semver.valid(current)) return { status: "error" };
2104
+ if (semver.gt(latest, current)) {
2105
+ return { status: "update-available", current, latest };
2106
+ }
2107
+ return { status: "up-to-date", current };
2108
+ } catch {
2109
+ return { status: "error" };
2110
+ }
2111
+ }
2352
2112
 
2353
2113
  // packages/experience-design-system-cli/src/tui/use-terminal-width.ts
2354
2114
  import { useEffect, useState } from "react";
@@ -2939,8 +2699,8 @@ function indexRowsByKey(items, key) {
2939
2699
  }
2940
2700
 
2941
2701
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/sessions/read.js
2942
- function getSessionById(db, sessionId) {
2943
- const row = db.prepare("SELECT id FROM sessions WHERE id = ?").get(sessionId);
2702
+ function getSessionById(db, sessionId2) {
2703
+ const row = db.prepare("SELECT id FROM sessions WHERE id = ?").get(sessionId2);
2944
2704
  return row ?? null;
2945
2705
  }
2946
2706
  function getLatestCompletedSessionForCommand(db, command) {
@@ -2956,8 +2716,8 @@ function getLatestCompletedSessionForCommand(db, command) {
2956
2716
  function createSession(db, id, name, timestamp) {
2957
2717
  db.prepare("INSERT INTO sessions (id, name, created_at, updated_at) VALUES (?, ?, ?, ?)").run(id, name, timestamp, timestamp);
2958
2718
  }
2959
- function updateSessionTimestamp(db, sessionId, timestamp) {
2960
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(timestamp, sessionId);
2719
+ function updateSessionTimestamp(db, sessionId2, timestamp) {
2720
+ db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(timestamp, sessionId2);
2961
2721
  }
2962
2722
 
2963
2723
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/steps/read.js
@@ -2967,13 +2727,13 @@ function getSessionIdForStep(db, stepId) {
2967
2727
  }
2968
2728
 
2969
2729
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/steps/write.js
2970
- function updatePendingStepsToInterrupted(db, sessionId, command, timestamp) {
2730
+ function updatePendingStepsToInterrupted(db, sessionId2, command, timestamp) {
2971
2731
  db.prepare(`UPDATE steps SET status = 'interrupted', completed_at = ?, updated_at = ?
2972
- WHERE session_id = ? AND command = ? AND status = 'pending'`).run(timestamp, timestamp, sessionId, command);
2732
+ WHERE session_id = ? AND command = ? AND status = 'pending'`).run(timestamp, timestamp, sessionId2, command);
2973
2733
  }
2974
- function createPendingStep(db, sessionId, command, inputs, timestamp) {
2734
+ function createPendingStep(db, sessionId2, command, inputs, timestamp) {
2975
2735
  const result = db.prepare(`INSERT INTO steps (session_id, command, status, started_at, inputs, outputs, updated_at)
2976
- VALUES (?, ?, 'pending', ?, ?, '{}', ?)`).run(sessionId, command, timestamp, JSON.stringify(inputs), timestamp);
2736
+ VALUES (?, ?, 'pending', ?, ?, '{}', ?)`).run(sessionId2, command, timestamp, JSON.stringify(inputs), timestamp);
2977
2737
  return Number(result.lastInsertRowid);
2978
2738
  }
2979
2739
  function updateStepStatus(db, stepId, status, outputs, error, timestamp) {
@@ -3235,12 +2995,12 @@ function buildDtcgTokens(tokenRows) {
3235
2995
  }
3236
2996
 
3237
2997
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/tokens/read.js
3238
- function getDtcgTokensForSession(db, sessionId) {
3239
- const groupRows = db.prepare("SELECT path, description FROM raw_token_groups WHERE session_id = ? ORDER BY path").all(sessionId).map((row) => ({
2998
+ function getDtcgTokensForSession(db, sessionId2) {
2999
+ const groupRows = db.prepare("SELECT path, description FROM raw_token_groups WHERE session_id = ? ORDER BY path").all(sessionId2).map((row) => ({
3240
3000
  path: String(row.path),
3241
3001
  description: row.description === null ? null : String(row.description)
3242
3002
  }));
3243
- const tokenRows = db.prepare("SELECT path, type, value, description FROM raw_tokens WHERE session_id = ? ORDER BY path").all(sessionId).map((row) => ({
3003
+ const tokenRows = db.prepare("SELECT path, type, value, description FROM raw_tokens WHERE session_id = ? ORDER BY path").all(sessionId2).map((row) => ({
3244
3004
  path: String(row.path),
3245
3005
  type: String(row.type),
3246
3006
  value: String(row.value),
@@ -3251,12 +3011,12 @@ function getDtcgTokensForSession(db, sessionId) {
3251
3011
  tokens: buildDtcgTokens(tokenRows)
3252
3012
  };
3253
3013
  }
3254
- function getRawTokenNamePaths(db, sessionId) {
3255
- const rows = db.prepare("SELECT raw_name, path FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId);
3014
+ function getRawTokenNamePaths(db, sessionId2) {
3015
+ const rows = db.prepare("SELECT raw_name, path FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId2);
3256
3016
  return Object.fromEntries(rows.map((row) => [String(row.raw_name), String(row.path)]));
3257
3017
  }
3258
- function getRawTokenNamePathRows(db, sessionId) {
3259
- return db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId).map((row) => ({
3018
+ function getRawTokenNamePathRows(db, sessionId2) {
3019
+ return db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId2).map((row) => ({
3260
3020
  rawName: String(row.raw_name),
3261
3021
  path: String(row.path),
3262
3022
  source: String(row.source)
@@ -3289,49 +3049,49 @@ function hashTokenContent(rawTokenContent) {
3289
3049
  }
3290
3050
 
3291
3051
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/tokens/write.js
3292
- function deleteRawTokensForSession(db, sessionId) {
3293
- db.prepare("DELETE FROM raw_token_groups WHERE session_id = ?").run(sessionId);
3294
- db.prepare("DELETE FROM raw_tokens WHERE session_id = ?").run(sessionId);
3052
+ function deleteRawTokensForSession(db, sessionId2) {
3053
+ db.prepare("DELETE FROM raw_token_groups WHERE session_id = ?").run(sessionId2);
3054
+ db.prepare("DELETE FROM raw_tokens WHERE session_id = ?").run(sessionId2);
3295
3055
  }
3296
- function createRawTokenGroups(db, sessionId, groups) {
3056
+ function createRawTokenGroups(db, sessionId2, groups) {
3297
3057
  const insertGroup = db.prepare(`INSERT INTO raw_token_groups (session_id, path, description) VALUES (?, ?, ?)`);
3298
3058
  for (const group of groups) {
3299
- insertGroup.run(sessionId, group.path, group.$description ?? null);
3059
+ insertGroup.run(sessionId2, group.path, group.$description ?? null);
3300
3060
  }
3301
3061
  }
3302
- function createRawTokens(db, sessionId, tokens) {
3062
+ function createRawTokens(db, sessionId2, tokens) {
3303
3063
  const insertToken = db.prepare(`INSERT INTO raw_tokens (session_id, path, type, value, description) VALUES (?, ?, ?, ?, ?)`);
3304
3064
  for (const token of tokens) {
3305
- insertToken.run(sessionId, token.path, token.$type, JSON.stringify(token.$value), token.$description ?? null);
3065
+ insertToken.run(sessionId2, token.path, token.$type, JSON.stringify(token.$value), token.$description ?? null);
3306
3066
  }
3307
3067
  }
3308
- function upsertRawToken(db, sessionId, call) {
3068
+ function upsertRawToken(db, sessionId2, call) {
3309
3069
  db.prepare(`INSERT INTO raw_tokens (session_id, path, type, value, description) VALUES (?, ?, ?, ?, ?)
3310
- ON CONFLICT(session_id, path) DO UPDATE SET type = excluded.type, value = excluded.value, description = excluded.description`).run(sessionId, call.path, call.type, JSON.stringify(call.value), call.description ?? null);
3070
+ ON CONFLICT(session_id, path) DO UPDATE SET type = excluded.type, value = excluded.value, description = excluded.description`).run(sessionId2, call.path, call.type, JSON.stringify(call.value), call.description ?? null);
3311
3071
  }
3312
- function upsertRawTokenGroup(db, sessionId, call) {
3072
+ function upsertRawTokenGroup(db, sessionId2, call) {
3313
3073
  db.prepare(`INSERT INTO raw_token_groups (session_id, path, description) VALUES (?, ?, ?)
3314
- ON CONFLICT(session_id, path) DO UPDATE SET description = excluded.description`).run(sessionId, call.path, call.description ?? null);
3074
+ ON CONFLICT(session_id, path) DO UPDATE SET description = excluded.description`).run(sessionId2, call.path, call.description ?? null);
3315
3075
  }
3316
- function updateRawTokenNamePaths(db, sessionId, tokenNamePaths, source) {
3076
+ function updateRawTokenNamePaths(db, sessionId2, tokenNamePaths, source) {
3317
3077
  const entries = Object.entries(tokenNamePaths);
3318
3078
  const deletePaths = db.prepare("DELETE FROM raw_token_name_paths WHERE session_id = ? AND source = ?");
3319
3079
  const insertPath = db.prepare("INSERT OR IGNORE INTO raw_token_name_paths (session_id, raw_name, path, source) VALUES (?, ?, ?, ?)");
3320
3080
  const deleteAutomaticByName = db.prepare("DELETE FROM raw_token_name_paths WHERE session_id = ? AND raw_name = ? AND source = 'automatic'");
3321
- deletePaths.run(sessionId, source);
3081
+ deletePaths.run(sessionId2, source);
3322
3082
  for (const [rawName, path5] of entries) {
3323
3083
  if (source === "manual")
3324
- deleteAutomaticByName.run(sessionId, rawName);
3325
- insertPath.run(sessionId, rawName, path5, source);
3084
+ deleteAutomaticByName.run(sessionId2, rawName);
3085
+ insertPath.run(sessionId2, rawName, path5, source);
3326
3086
  }
3327
3087
  }
3328
- function updateRawPropTokenPaths(db, sessionId, componentId, propName, paths, source) {
3088
+ function updateRawPropTokenPaths(db, sessionId2, componentId, propName, paths, source) {
3329
3089
  db.prepare(`DELETE FROM raw_prop_token_paths
3330
- WHERE session_id = ? AND component_id = ? AND prop_name = ?`).run(sessionId, componentId, propName);
3090
+ WHERE session_id = ? AND component_id = ? AND prop_name = ?`).run(sessionId2, componentId, propName);
3331
3091
  const insertPath = db.prepare(`INSERT INTO raw_prop_token_paths (session_id, component_id, prop_name, source, position, path)
3332
3092
  VALUES (?, ?, ?, ?, ?, ?)`);
3333
3093
  paths.forEach((path5, position) => {
3334
- insertPath.run(sessionId, componentId, propName, source, position, path5);
3094
+ insertPath.run(sessionId2, componentId, propName, source, position, path5);
3335
3095
  });
3336
3096
  }
3337
3097
 
@@ -3349,18 +3109,18 @@ function withTransaction(db, fn) {
3349
3109
  }
3350
3110
 
3351
3111
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/services/tokens/store-dtcg-tokens.js
3352
- function storeDtcgTokens(db, sessionId, groups, tokens) {
3112
+ function storeDtcgTokens(db, sessionId2, groups, tokens) {
3353
3113
  const now = (/* @__PURE__ */ new Date()).toISOString();
3354
3114
  withTransaction(db, () => {
3355
- deleteRawTokensForSession(db, sessionId);
3356
- createRawTokenGroups(db, sessionId, groups);
3357
- createRawTokens(db, sessionId, tokens);
3358
- updateSessionTimestamp(db, sessionId, now);
3115
+ deleteRawTokensForSession(db, sessionId2);
3116
+ createRawTokenGroups(db, sessionId2, groups);
3117
+ createRawTokens(db, sessionId2, tokens);
3118
+ updateSessionTimestamp(db, sessionId2, now);
3359
3119
  });
3360
3120
  }
3361
3121
 
3362
3122
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/services/tokens/apply-tool-calls.js
3363
- function applyTokenToolCalls(db, sessionId, calls, incomingWarnings) {
3123
+ function applyTokenToolCalls(db, sessionId2, calls, incomingWarnings) {
3364
3124
  const now = (/* @__PURE__ */ new Date()).toISOString();
3365
3125
  const warnings = [...incomingWarnings];
3366
3126
  let tokens = 0;
@@ -3368,31 +3128,31 @@ function applyTokenToolCalls(db, sessionId, calls, incomingWarnings) {
3368
3128
  withTransaction(db, () => {
3369
3129
  for (const call of calls) {
3370
3130
  if (call.tool === "set_token") {
3371
- upsertRawToken(db, sessionId, call);
3131
+ upsertRawToken(db, sessionId2, call);
3372
3132
  tokens++;
3373
3133
  } else if (call.tool === "set_group") {
3374
- upsertRawTokenGroup(db, sessionId, call);
3134
+ upsertRawTokenGroup(db, sessionId2, call);
3375
3135
  groups++;
3376
3136
  }
3377
3137
  }
3378
- updateSessionTimestamp(db, sessionId, now);
3138
+ updateSessionTimestamp(db, sessionId2, now);
3379
3139
  });
3380
3140
  return { tokens, groups, warnings };
3381
3141
  }
3382
3142
 
3383
3143
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/services/tokens/replace-raw-token-name-paths.js
3384
- function replaceRawTokenNamePaths(db, sessionId, tokenNamePaths, source = "automatic") {
3144
+ function replaceRawTokenNamePaths(db, sessionId2, tokenNamePaths, source = "automatic") {
3385
3145
  withTransaction(db, () => {
3386
- updateRawTokenNamePaths(db, sessionId, tokenNamePaths, source);
3387
- updateSessionTimestamp(db, sessionId, (/* @__PURE__ */ new Date()).toISOString());
3146
+ updateRawTokenNamePaths(db, sessionId2, tokenNamePaths, source);
3147
+ updateSessionTimestamp(db, sessionId2, (/* @__PURE__ */ new Date()).toISOString());
3388
3148
  });
3389
3149
  }
3390
3150
 
3391
3151
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/services/tokens/replace-raw-prop-token-paths.js
3392
- function replaceRawPropTokenPaths(db, sessionId, componentId, propName, paths, source) {
3152
+ function replaceRawPropTokenPaths(db, sessionId2, componentId, propName, paths, source) {
3393
3153
  withTransaction(db, () => {
3394
- updateRawPropTokenPaths(db, sessionId, componentId, propName, paths, source);
3395
- updateSessionTimestamp(db, sessionId, (/* @__PURE__ */ new Date()).toISOString());
3154
+ updateRawPropTokenPaths(db, sessionId2, componentId, propName, paths, source);
3155
+ updateSessionTimestamp(db, sessionId2, (/* @__PURE__ */ new Date()).toISOString());
3396
3156
  });
3397
3157
  }
3398
3158
 
@@ -3836,11 +3596,11 @@ function applyDbMigrations(db) {
3836
3596
  `);
3837
3597
  }
3838
3598
  }
3839
- function loadComponentReviewMetadata(db, sessionId, componentName) {
3840
- const compRow = db.prepare(`SELECT component_id, source, source_path FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId, componentName);
3599
+ function loadComponentReviewMetadata(db, sessionId2, componentName) {
3600
+ const compRow = db.prepare(`SELECT component_id, source, source_path FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId2, componentName);
3841
3601
  if (!compRow)
3842
3602
  return null;
3843
- const propRows = db.prepare(`SELECT name, rationale, source_start_line, source_end_line FROM raw_props WHERE session_id = ? AND component_id = ?`).all(sessionId, compRow.component_id);
3603
+ const propRows = db.prepare(`SELECT name, rationale, source_start_line, source_end_line FROM raw_props WHERE session_id = ? AND component_id = ?`).all(sessionId2, compRow.component_id);
3844
3604
  const props = {};
3845
3605
  for (const r of propRows) {
3846
3606
  props[r.name] = {
@@ -3862,15 +3622,15 @@ function loadComponentReviewMetadata(db, sessionId, componentName) {
3862
3622
  props
3863
3623
  };
3864
3624
  }
3865
- function loadComponentRationale(db, sessionId, componentName) {
3625
+ function loadComponentRationale(db, sessionId2, componentName) {
3866
3626
  const compRow = db.prepare(`SELECT component_id, name, description, component_description_rationale, props_rationale, slots_rationale
3867
- FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId, componentName);
3627
+ FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId2, componentName);
3868
3628
  if (!compRow)
3869
3629
  return null;
3870
3630
  const propRows = db.prepare(`SELECT name, cdf_category, category, description, rationale FROM raw_props
3871
- WHERE session_id = ? AND component_id = ? ORDER BY position`).all(sessionId, compRow.component_id);
3631
+ WHERE session_id = ? AND component_id = ? ORDER BY position`).all(sessionId2, compRow.component_id);
3872
3632
  const slotRows = db.prepare(`SELECT name, description, rationale FROM raw_slots
3873
- WHERE session_id = ? AND component_id = ? ORDER BY position`).all(sessionId, compRow.component_id);
3633
+ WHERE session_id = ? AND component_id = ? ORDER BY position`).all(sessionId2, compRow.component_id);
3874
3634
  return {
3875
3635
  name: compRow.name,
3876
3636
  description: compRow.description,
@@ -3890,7 +3650,7 @@ function loadComponentRationale(db, sessionId, componentName) {
3890
3650
  }))
3891
3651
  };
3892
3652
  }
3893
- function applyToolCalls(db, sessionId, componentId, componentName, calls, incomingWarnings, options = {}) {
3653
+ function applyToolCalls(db, sessionId2, componentId, componentName, calls, incomingWarnings, options = {}) {
3894
3654
  const now = (/* @__PURE__ */ new Date()).toISOString();
3895
3655
  const warnings = [...incomingWarnings];
3896
3656
  let classified = 0;
@@ -3918,58 +3678,58 @@ function applyToolCalls(db, sessionId, componentId, componentName, calls, incomi
3918
3678
  for (const call of calls) {
3919
3679
  if (call.tool === "classify_component") {
3920
3680
  if (call.description !== void 0) {
3921
- db.prepare("UPDATE raw_components SET description = ? WHERE session_id = ? AND component_id = ?").run(call.description, sessionId, componentId);
3681
+ db.prepare("UPDATE raw_components SET description = ? WHERE session_id = ? AND component_id = ?").run(call.description, sessionId2, componentId);
3922
3682
  }
3923
3683
  if (call.rationale) {
3924
3684
  if (call.rationale.description !== void 0) {
3925
- db.prepare("UPDATE raw_components SET component_description_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.description, sessionId, componentId);
3685
+ db.prepare("UPDATE raw_components SET component_description_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.description, sessionId2, componentId);
3926
3686
  }
3927
3687
  if (call.rationale.props !== void 0) {
3928
- db.prepare("UPDATE raw_components SET props_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.props, sessionId, componentId);
3688
+ db.prepare("UPDATE raw_components SET props_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.props, sessionId2, componentId);
3929
3689
  }
3930
3690
  if (call.rationale.slots !== void 0) {
3931
- db.prepare("UPDATE raw_components SET slots_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.slots, sessionId, componentId);
3691
+ db.prepare("UPDATE raw_components SET slots_rationale = ? WHERE session_id = ? AND component_id = ?").run(call.rationale.slots, sessionId2, componentId);
3932
3692
  }
3933
3693
  }
3934
3694
  } else if (call.tool === "classify_prop") {
3935
- const changes = updateProp.run(call.cdf_type, call.cdf_category, call.token_kind ?? null, call.required !== void 0 ? call.required ? 1 : 0 : 0, call.description ?? null, call.reason ?? null, sessionId, componentId, call.prop);
3695
+ const changes = updateProp.run(call.cdf_type, call.cdf_category, call.token_kind ?? null, call.required !== void 0 ? call.required ? 1 : 0 : 0, call.description ?? null, call.reason ?? null, sessionId2, componentId, call.prop);
3936
3696
  if (changes.changes === 0) {
3937
3697
  warnings.push(`${componentName}: classify_prop '${call.prop}' \u2014 prop not found, skipped`);
3938
3698
  continue;
3939
3699
  }
3940
3700
  if (call.cdf_type === "token") {
3941
- deleteAllowedValues.run(sessionId, componentId, call.prop);
3701
+ deleteAllowedValues.run(sessionId2, componentId, call.prop);
3942
3702
  if (call.values && call.values.length > 0) {
3943
3703
  const count = call.values.length;
3944
3704
  warnings.push(`${componentName}: classify_prop '${call.prop}' \u2014 dropped ${count} value${count === 1 ? "" : "s"} on a token property; its options list is $token.allowed, not $values`);
3945
3705
  }
3946
3706
  } else {
3947
- deleteTokenPaths.run(sessionId, componentId, call.prop);
3707
+ deleteTokenPaths.run(sessionId2, componentId, call.prop);
3948
3708
  if (call.values && call.values.length > 0) {
3949
- deleteAllowedValues.run(sessionId, componentId, call.prop);
3950
- call.values.forEach((v, i) => insertAllowedValue.run(sessionId, componentId, call.prop, v, i));
3709
+ deleteAllowedValues.run(sessionId2, componentId, call.prop);
3710
+ call.values.forEach((v, i) => insertAllowedValue.run(sessionId2, componentId, call.prop, v, i));
3951
3711
  }
3952
3712
  }
3953
3713
  if (call.default !== void 0) {
3954
3714
  const storedDefault = typeof call.default === "boolean" ? String(call.default) : call.default;
3955
- db.prepare(`UPDATE raw_props SET default_value = ? WHERE session_id = ? AND component_id = ? AND name = ?`).run(storedDefault, sessionId, componentId, call.prop);
3715
+ db.prepare(`UPDATE raw_props SET default_value = ? WHERE session_id = ? AND component_id = ? AND name = ?`).run(storedDefault, sessionId2, componentId, call.prop);
3956
3716
  }
3957
3717
  classified++;
3958
3718
  } else if (call.tool === "exclude_prop") {
3959
- clearProp.run(call.reason || null, sessionId, componentId, call.prop);
3719
+ clearProp.run(call.reason || null, sessionId2, componentId, call.prop);
3960
3720
  excluded++;
3961
3721
  } else if (call.tool === "classify_slot") {
3962
3722
  const slotRequired = call.required !== void 0 ? call.required ? 1 : 0 : 1;
3963
- const slotChanges = updateSlot.run(slotRequired, call.description ?? null, sessionId, componentId, call.slot);
3723
+ const slotChanges = updateSlot.run(slotRequired, call.description ?? null, sessionId2, componentId, call.slot);
3964
3724
  if (slotChanges.changes === 0) {
3965
3725
  warnings.push(`${componentName}: classify_slot '${call.slot}' \u2014 slot not found, skipped`);
3966
3726
  continue;
3967
3727
  }
3968
3728
  if (call.rationale !== void 0) {
3969
- db.prepare("UPDATE raw_slots SET rationale = ? WHERE session_id = ? AND component_id = ? AND name = ?").run(call.rationale, sessionId, componentId, call.slot);
3729
+ db.prepare("UPDATE raw_slots SET rationale = ? WHERE session_id = ? AND component_id = ? AND name = ?").run(call.rationale, sessionId2, componentId, call.slot);
3970
3730
  }
3971
3731
  if (call.allowed_components !== void 0) {
3972
- deleteAllowedComponents.run(sessionId, componentId, call.slot);
3732
+ deleteAllowedComponents.run(sessionId2, componentId, call.slot);
3973
3733
  const allowedComponents = options.allowedComponentNames ? call.allowed_components.filter((allowedComponent) => options.allowedComponentNames.has(allowedComponent)) : call.allowed_components;
3974
3734
  if (options.allowedComponentNames) {
3975
3735
  const dropped = [
@@ -3979,13 +3739,13 @@ function applyToolCalls(db, sessionId, componentId, componentName, calls, incomi
3979
3739
  warnings.push(`${componentName}: classify_slot '${call.slot}' \u2014 dropped unknown allowed component '${allowedComponent}'`);
3980
3740
  }
3981
3741
  }
3982
- allowedComponents.forEach((ac, i) => insertAllowedComponent.run(sessionId, componentId, call.slot, ac, i));
3742
+ allowedComponents.forEach((ac, i) => insertAllowedComponent.run(sessionId2, componentId, call.slot, ac, i));
3983
3743
  }
3984
3744
  slots++;
3985
3745
  }
3986
3746
  }
3987
- db.prepare(`UPDATE raw_components SET status = 'generated', extracted_at = ? WHERE session_id = ? AND component_id = ?`).run(now, sessionId, componentId);
3988
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId);
3747
+ db.prepare(`UPDATE raw_components SET status = 'generated', extracted_at = ? WHERE session_id = ? AND component_id = ?`).run(now, sessionId2, componentId);
3748
+ db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId2);
3989
3749
  db.exec("COMMIT");
3990
3750
  } catch (e) {
3991
3751
  db.exec("ROLLBACK");
@@ -3996,13 +3756,13 @@ function applyToolCalls(db, sessionId, componentId, componentName, calls, incomi
3996
3756
  function getOrCreateSession(db, sessionFlag, sessionName, hints) {
3997
3757
  return getOrCreateSessionForCommand(db, sessionFlag, sessionName, hints);
3998
3758
  }
3999
- function createStep(db, sessionId, command, inputs) {
3759
+ function createStep(db, sessionId2, command, inputs) {
4000
3760
  const now = (/* @__PURE__ */ new Date()).toISOString();
4001
3761
  db.exec("BEGIN");
4002
3762
  try {
4003
- updatePendingStepsToInterrupted(db, sessionId, command, now);
4004
- const stepId = createPendingStep(db, sessionId, command, inputs, now);
4005
- updateSessionTimestamp(db, sessionId, now);
3763
+ updatePendingStepsToInterrupted(db, sessionId2, command, now);
3764
+ const stepId = createPendingStep(db, sessionId2, command, inputs, now);
3765
+ updateSessionTimestamp(db, sessionId2, now);
4006
3766
  db.exec("COMMIT");
4007
3767
  return stepId;
4008
3768
  } catch (e) {
@@ -4025,7 +3785,7 @@ function updateStep(db, stepId, status, outputs, error) {
4025
3785
  throw e;
4026
3786
  }
4027
3787
  }
4028
- function storeRawComponents(db, sessionId, components, options) {
3788
+ function storeRawComponents(db, sessionId2, components, options) {
4029
3789
  const now = (/* @__PURE__ */ new Date()).toISOString();
4030
3790
  const insertComp = db.prepare(`INSERT INTO raw_components (session_id, component_id, name, source, framework, extracted_at, extraction_confidence, review_reasons, needs_review, source_path)
4031
3791
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
@@ -4046,34 +3806,34 @@ function storeRawComponents(db, sessionId, components, options) {
4046
3806
  let statusSnapshot = [];
4047
3807
  if (options?.preserveCDF) {
4048
3808
  cdfSnapshot = db.prepare(`SELECT component_id, name, position, cdf_type, cdf_category, cdf_token_kind
4049
- FROM raw_props WHERE session_id = ? AND cdf_type IS NOT NULL`).all(sessionId);
3809
+ FROM raw_props WHERE session_id = ? AND cdf_type IS NOT NULL`).all(sessionId2);
4050
3810
  descSnapshot = db.prepare(`SELECT component_id, description
4051
- FROM raw_components WHERE session_id = ? AND description IS NOT NULL`).all(sessionId);
3811
+ FROM raw_components WHERE session_id = ? AND description IS NOT NULL`).all(sessionId2);
4052
3812
  if (cdfSnapshot.length > 0) {
4053
3813
  avSnapshot = db.prepare(`SELECT component_id, prop_name, position, value
4054
- FROM raw_prop_allowed_values WHERE session_id = ?`).all(sessionId);
3814
+ FROM raw_prop_allowed_values WHERE session_id = ?`).all(sessionId2);
4055
3815
  }
4056
3816
  }
4057
3817
  if (options?.preserveStatus) {
4058
3818
  statusSnapshot = db.prepare(`SELECT component_id, status, reject_reason
4059
- FROM raw_components WHERE session_id = ?`).all(sessionId);
3819
+ FROM raw_components WHERE session_id = ?`).all(sessionId2);
4060
3820
  }
4061
- db.prepare("DELETE FROM raw_components WHERE session_id = ?").run(sessionId);
3821
+ db.prepare("DELETE FROM raw_components WHERE session_id = ?").run(sessionId2);
4062
3822
  for (const comp of components) {
4063
3823
  const componentId = deriveComponentId(comp.name, comp.source);
4064
- insertComp.run(sessionId, componentId, comp.name, comp.source, comp.framework, now, comp.extractionConfidence ?? null, JSON.stringify(comp.reviewReasons ?? []), comp.needsReview ? 1 : 0, comp.sourcePath ?? null);
3824
+ insertComp.run(sessionId2, componentId, comp.name, comp.source, comp.framework, now, comp.extractionConfidence ?? null, JSON.stringify(comp.reviewReasons ?? []), comp.needsReview ? 1 : 0, comp.sourcePath ?? null);
4065
3825
  for (let i = 0; i < comp.props.length; i++) {
4066
3826
  const prop = comp.props[i];
4067
- insertProp.run(sessionId, componentId, prop.name, prop.type, prop.required ? 1 : 0, prop.category ?? null, prop.defaultValue ?? null, prop.description ?? null, prop.tokenReference ?? null, i, prop.sourceStartLine ?? null, prop.sourceEndLine ?? null);
3827
+ insertProp.run(sessionId2, componentId, prop.name, prop.type, prop.required ? 1 : 0, prop.category ?? null, prop.defaultValue ?? null, prop.description ?? null, prop.tokenReference ?? null, i, prop.sourceStartLine ?? null, prop.sourceEndLine ?? null);
4068
3828
  if (prop.allowedValues) {
4069
- prop.allowedValues.forEach((v, j) => insertAllowedValue.run(sessionId, componentId, prop.name, j, v));
3829
+ prop.allowedValues.forEach((v, j) => insertAllowedValue.run(sessionId2, componentId, prop.name, j, v));
4070
3830
  }
4071
3831
  }
4072
3832
  for (let i = 0; i < comp.slots.length; i++) {
4073
3833
  const slot = comp.slots[i];
4074
- insertSlot.run(sessionId, componentId, slot.name, slot.isDefault ? 1 : 0, slot.description ?? null, i);
3834
+ insertSlot.run(sessionId2, componentId, slot.name, slot.isDefault ? 1 : 0, slot.description ?? null, i);
4075
3835
  if (slot.allowedComponents) {
4076
- slot.allowedComponents.forEach((ac, j) => insertAllowedComponent.run(sessionId, componentId, slot.name, j, ac));
3836
+ slot.allowedComponents.forEach((ac, j) => insertAllowedComponent.run(sessionId2, componentId, slot.name, j, ac));
4077
3837
  }
4078
3838
  }
4079
3839
  }
@@ -4085,7 +3845,7 @@ function storeRawComponents(db, sessionId, components, options) {
4085
3845
  const restoredPropKeys = /* @__PURE__ */ new Set();
4086
3846
  const unmatchedSnaps = [];
4087
3847
  for (const snap of cdfSnapshot) {
4088
- const result = updateCDFByName.run(snap.cdf_type, snap.cdf_category, snap.cdf_token_kind, sessionId, snap.component_id, snap.name);
3848
+ const result = updateCDFByName.run(snap.cdf_type, snap.cdf_category, snap.cdf_token_kind, sessionId2, snap.component_id, snap.name);
4089
3849
  if (Number(result.changes) > 0) {
4090
3850
  restoredPropKeys.add(`${snap.component_id}::${snap.name}`);
4091
3851
  } else {
@@ -4093,9 +3853,9 @@ function storeRawComponents(db, sessionId, components, options) {
4093
3853
  }
4094
3854
  }
4095
3855
  for (const snap of unmatchedSnaps) {
4096
- const result = updateCDFByPosition.run(snap.cdf_type, snap.cdf_category, snap.cdf_token_kind, sessionId, snap.component_id, snap.position);
3856
+ const result = updateCDFByPosition.run(snap.cdf_type, snap.cdf_category, snap.cdf_token_kind, sessionId2, snap.component_id, snap.position);
4097
3857
  if (Number(result.changes) > 0) {
4098
- const matched = db.prepare(`SELECT name FROM raw_props WHERE session_id = ? AND component_id = ? AND position = ?`).get(sessionId, snap.component_id, snap.position);
3858
+ const matched = db.prepare(`SELECT name FROM raw_props WHERE session_id = ? AND component_id = ? AND position = ?`).get(sessionId2, snap.component_id, snap.position);
4099
3859
  if (matched) {
4100
3860
  restoredPropKeys.add(`${snap.component_id}::${matched.name}`);
4101
3861
  }
@@ -4103,7 +3863,7 @@ function storeRawComponents(db, sessionId, components, options) {
4103
3863
  }
4104
3864
  const updateDesc = db.prepare(`UPDATE raw_components SET description = ? WHERE session_id = ? AND component_id = ?`);
4105
3865
  for (const snap of descSnapshot) {
4106
- updateDesc.run(snap.description, sessionId, snap.component_id);
3866
+ updateDesc.run(snap.description, sessionId2, snap.component_id);
4107
3867
  }
4108
3868
  const relevantAV = avSnapshot.filter((av) => restoredPropKeys.has(`${av.component_id}::${av.prop_name}`));
4109
3869
  if (relevantAV.length > 0) {
@@ -4114,10 +3874,10 @@ function storeRawComponents(db, sessionId, components, options) {
4114
3874
  for (const av of relevantAV) {
4115
3875
  const key = `${av.component_id}::${av.prop_name}`;
4116
3876
  if (!deletedKeys.has(key)) {
4117
- deleteAV.run(sessionId, av.component_id, av.prop_name);
3877
+ deleteAV.run(sessionId2, av.component_id, av.prop_name);
4118
3878
  deletedKeys.add(key);
4119
3879
  }
4120
- insertAV.run(sessionId, av.component_id, av.prop_name, av.position, av.value);
3880
+ insertAV.run(sessionId2, av.component_id, av.prop_name, av.position, av.value);
4121
3881
  }
4122
3882
  }
4123
3883
  }
@@ -4125,33 +3885,33 @@ function storeRawComponents(db, sessionId, components, options) {
4125
3885
  const restoreStatus = db.prepare(`UPDATE raw_components SET status = ?, reject_reason = ?
4126
3886
  WHERE session_id = ? AND component_id = ?`);
4127
3887
  for (const snapshot of statusSnapshot) {
4128
- restoreStatus.run(snapshot.status, snapshot.reject_reason, sessionId, snapshot.component_id);
3888
+ restoreStatus.run(snapshot.status, snapshot.reject_reason, sessionId2, snapshot.component_id);
4129
3889
  }
4130
3890
  }
4131
3891
  if (options?.status) {
4132
- db.prepare("UPDATE raw_components SET status = ? WHERE session_id = ?").run(options.status, sessionId);
3892
+ db.prepare("UPDATE raw_components SET status = ? WHERE session_id = ?").run(options.status, sessionId2);
4133
3893
  }
4134
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId);
3894
+ db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId2);
4135
3895
  db.exec("COMMIT");
4136
3896
  } catch (e) {
4137
3897
  db.exec("ROLLBACK");
4138
3898
  throw e;
4139
3899
  }
4140
3900
  }
4141
- function loadRawComponents(db, sessionId, allowedNames) {
4142
- const all = db.prepare("SELECT component_id, name, source, framework, extraction_confidence, review_reasons, needs_review, source_path FROM raw_components WHERE session_id = ? ORDER BY rowid").all(sessionId);
3901
+ function loadRawComponents(db, sessionId2, allowedNames) {
3902
+ const all = db.prepare("SELECT component_id, name, source, framework, extraction_confidence, review_reasons, needs_review, source_path FROM raw_components WHERE session_id = ? ORDER BY rowid").all(sessionId2);
4143
3903
  const components = allowedNames ? all.filter((c2) => allowedNames.has(c2.name)) : all;
4144
3904
  if (components.length === 0)
4145
3905
  return [];
4146
3906
  const props = db.prepare(`SELECT component_id, name, type, required, category, default_value, description, token_reference, position,
4147
3907
  rationale, source_start_line, source_end_line
4148
- FROM raw_props WHERE session_id = ? ORDER BY component_id, position`).all(sessionId);
3908
+ FROM raw_props WHERE session_id = ? ORDER BY component_id, position`).all(sessionId2);
4149
3909
  const allowedValues = db.prepare(`SELECT component_id, prop_name, position, value
4150
- FROM raw_prop_allowed_values WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(sessionId);
3910
+ FROM raw_prop_allowed_values WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(sessionId2);
4151
3911
  const slots = db.prepare(`SELECT component_id, name, is_default, description, position
4152
- FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(sessionId);
3912
+ FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(sessionId2);
4153
3913
  const allowedComponents = db.prepare(`SELECT component_id, slot_name, position, allowed_component
4154
- FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(sessionId);
3914
+ FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(sessionId2);
4155
3915
  const propsByComponent = indexRowsByKey(props, (p) => p.component_id);
4156
3916
  const allowedValuesByProp = indexRowsByKey(allowedValues, (av) => `${av.component_id}::${av.prop_name}`);
4157
3917
  const slotsByComponent = indexRowsByKey(slots, (s) => s.component_id);
@@ -4356,18 +4116,18 @@ async function loadComponentSourceRef(name, sourcePath, propNames = [], propType
4356
4116
  ref.usesNotShown = notShown;
4357
4117
  return ref;
4358
4118
  }
4359
- async function loadComponentSourceRefs(db, sessionId) {
4360
- const rows = db.prepare(`SELECT component_id, name, source, source_path FROM raw_components WHERE session_id = ? AND status = 'generated' ORDER BY rowid`).all(sessionId);
4119
+ async function loadComponentSourceRefs(db, sessionId2) {
4120
+ const rows = db.prepare(`SELECT component_id, name, source, source_path FROM raw_components WHERE session_id = ? AND status = 'generated' ORDER BY rowid`).all(sessionId2);
4361
4121
  const propsFor = db.prepare(`SELECT name, type FROM raw_props WHERE session_id = ? AND component_id = ? ORDER BY position`);
4362
4122
  return Promise.all(rows.map((r) => {
4363
- const props = propsFor.all(sessionId, r.component_id);
4123
+ const props = propsFor.all(sessionId2, r.component_id);
4364
4124
  return loadComponentSourceRef(r.name, r.source_path ?? r.source, props.map((p) => p.name), props.map((p) => p.type));
4365
4125
  }));
4366
4126
  }
4367
- function renameEmptySlots(db, sessionId, componentId, componentName, slotCount) {
4127
+ function renameEmptySlots(db, sessionId2, componentId, componentName, slotCount) {
4368
4128
  const emptySlots = db.prepare(`SELECT name, position FROM raw_slots
4369
4129
  WHERE session_id = ? AND component_id = ? AND trim(name) = ''
4370
- ORDER BY position`).all(sessionId, componentId);
4130
+ ORDER BY position`).all(sessionId2, componentId);
4371
4131
  if (emptySlots.length === 0)
4372
4132
  return { renames: [], warnings: [] };
4373
4133
  const renames = [];
@@ -4377,7 +4137,7 @@ function renameEmptySlots(db, sessionId, componentId, componentName, slotCount)
4377
4137
  try {
4378
4138
  for (const slot of emptySlots) {
4379
4139
  const newName = slotCount === 1 ? "children" : `slot_${slot.position}`;
4380
- rename3.run(newName, sessionId, componentId, slot.name, slot.position);
4140
+ rename3.run(newName, sessionId2, componentId, slot.name, slot.position);
4381
4141
  renames.push({ oldName: slot.name, newName });
4382
4142
  warnings.push(`${componentName}: slot at position ${slot.position} had empty name \u2014 renamed to "${newName}" for classification`);
4383
4143
  }
@@ -4396,7 +4156,7 @@ function parseReviewReasons(raw) {
4396
4156
  return [];
4397
4157
  }
4398
4158
  }
4399
- function storeCDFComponents(db, sessionId, components) {
4159
+ function storeCDFComponents(db, sessionId2, components) {
4400
4160
  const now = (/* @__PURE__ */ new Date()).toISOString();
4401
4161
  const updateComp = db.prepare(`UPDATE raw_components SET status = 'generated', description = ? WHERE session_id = ? AND name = ?`);
4402
4162
  const updateProp = db.prepare(`UPDATE raw_props SET cdf_type = ?, cdf_category = ?, cdf_token_kind = ?, required = ? WHERE session_id = ? AND component_id = ? AND name = ?`);
@@ -4409,8 +4169,8 @@ function storeCDFComponents(db, sessionId, components) {
4409
4169
  const insertTokenPath = db.prepare(`INSERT INTO raw_prop_token_paths (session_id, component_id, prop_name, source, position, path)
4410
4170
  VALUES (?, ?, ?, ?, ?, ?)`);
4411
4171
  const writeTokenPaths = (componentId, propName, paths) => {
4412
- deleteTokenPaths.run(sessionId, componentId, propName);
4413
- paths.forEach((path5, position) => insertTokenPath.run(sessionId, componentId, propName, "review", position, path5));
4172
+ deleteTokenPaths.run(sessionId2, componentId, propName);
4173
+ paths.forEach((path5, position) => insertTokenPath.run(sessionId2, componentId, propName, "review", position, path5));
4414
4174
  };
4415
4175
  const deleteSlots = db.prepare(`DELETE FROM raw_slots WHERE session_id = ? AND component_id = ?`);
4416
4176
  const deleteSlotAllowedComponents = db.prepare(`DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ?`);
@@ -4420,42 +4180,42 @@ function storeCDFComponents(db, sessionId, components) {
4420
4180
  db.exec("BEGIN");
4421
4181
  try {
4422
4182
  for (const { key, entry } of components) {
4423
- const row = db.prepare("SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?").get(sessionId, key);
4183
+ const row = db.prepare("SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?").get(sessionId2, key);
4424
4184
  if (row) {
4425
4185
  const { component_id: componentId } = row;
4426
- updateComp.run(entry.$description ?? null, sessionId, key);
4186
+ updateComp.run(entry.$description ?? null, sessionId2, key);
4427
4187
  for (const [propName, prop] of Object.entries(entry.$properties)) {
4428
- updateProp.run(prop.$type, prop.$category, prop["$token.kind"] ?? null, prop.$required ? 1 : 0, sessionId, componentId, propName);
4188
+ updateProp.run(prop.$type, prop.$category, prop["$token.kind"] ?? null, prop.$required ? 1 : 0, sessionId2, componentId, propName);
4429
4189
  if (prop.$values && prop.$values.length > 0) {
4430
- deleteAllowedValues.run(sessionId, componentId, propName);
4431
- prop.$values.forEach((v, i) => insertAllowedValue.run(sessionId, componentId, propName, v, i));
4190
+ deleteAllowedValues.run(sessionId2, componentId, propName);
4191
+ prop.$values.forEach((v, i) => insertAllowedValue.run(sessionId2, componentId, propName, v, i));
4432
4192
  }
4433
4193
  if (prop.$type === "token" && prop.$category === "design") {
4434
4194
  writeTokenPaths(componentId, propName, prop["$token.allowed"] ?? []);
4435
4195
  }
4436
4196
  }
4437
- const existingDefaults = new Map(readExistingSlotDefaults.all(sessionId, componentId).map((r) => [r.name, r.is_default]));
4438
- deleteSlotAllowedComponents.run(sessionId, componentId);
4439
- deleteSlots.run(sessionId, componentId);
4197
+ const existingDefaults = new Map(readExistingSlotDefaults.all(sessionId2, componentId).map((r) => [r.name, r.is_default]));
4198
+ deleteSlotAllowedComponents.run(sessionId2, componentId);
4199
+ deleteSlots.run(sessionId2, componentId);
4440
4200
  let slotPos = 0;
4441
4201
  for (const [slotName, slot] of Object.entries(entry.$slots ?? {})) {
4442
4202
  const isDefault = existingDefaults.get(slotName) ?? 0;
4443
- insertSlotOnUpdate.run(sessionId, componentId, slotName, isDefault, slot.$required ? 1 : 0, slot.$description ?? null, slotPos++);
4203
+ insertSlotOnUpdate.run(sessionId2, componentId, slotName, isDefault, slot.$required ? 1 : 0, slot.$description ?? null, slotPos++);
4444
4204
  if (slot.$allowedComponents && slot.$allowedComponents.length > 0) {
4445
- slot.$allowedComponents.forEach((ac, i) => insertAllowedComponent.run(sessionId, componentId, slotName, ac, i));
4205
+ slot.$allowedComponents.forEach((ac, i) => insertAllowedComponent.run(sessionId2, componentId, slotName, ac, i));
4446
4206
  }
4447
4207
  }
4448
4208
  } else {
4449
4209
  const componentId = deriveComponentId(key, "generated");
4450
4210
  db.prepare(`INSERT INTO raw_components (session_id, component_id, name, source, framework, extracted_at, status, description)
4451
- VALUES (?, ?, ?, '', 'react', ?, 'generated', ?)`).run(sessionId, componentId, key, now, entry.$description ?? null);
4211
+ VALUES (?, ?, ?, '', 'react', ?, 'generated', ?)`).run(sessionId2, componentId, key, now, entry.$description ?? null);
4452
4212
  let position = 0;
4453
4213
  for (const [propName, prop] of Object.entries(entry.$properties)) {
4454
4214
  db.prepare(`INSERT OR REPLACE INTO raw_props
4455
4215
  (session_id, component_id, name, type, required, category, default_value, description, token_reference, position, cdf_type, cdf_category, cdf_token_kind)
4456
- VALUES (?, ?, ?, '', ?, NULL, NULL, NULL, NULL, ?, ?, ?, ?)`).run(sessionId, componentId, propName, prop.$required ? 1 : 0, position++, prop.$type, prop.$category, prop["$token.kind"] ?? null);
4216
+ VALUES (?, ?, ?, '', ?, NULL, NULL, NULL, NULL, ?, ?, ?, ?)`).run(sessionId2, componentId, propName, prop.$required ? 1 : 0, position++, prop.$type, prop.$category, prop["$token.kind"] ?? null);
4457
4217
  if (prop.$values && prop.$values.length > 0) {
4458
- prop.$values.forEach((v, i) => insertAllowedValue.run(sessionId, componentId, propName, v, i));
4218
+ prop.$values.forEach((v, i) => insertAllowedValue.run(sessionId2, componentId, propName, v, i));
4459
4219
  }
4460
4220
  if (prop.$type === "token" && prop.$category === "design") {
4461
4221
  writeTokenPaths(componentId, propName, prop["$token.allowed"] ?? []);
@@ -4465,39 +4225,39 @@ function storeCDFComponents(db, sessionId, components) {
4465
4225
  for (const [slotName, slot] of Object.entries(entry.$slots ?? {})) {
4466
4226
  db.prepare(`INSERT OR REPLACE INTO raw_slots
4467
4227
  (session_id, component_id, name, is_default, required, description, position)
4468
- VALUES (?, ?, ?, 0, ?, ?, ?)`).run(sessionId, componentId, slotName, slot.$required ? 1 : 0, slot.$description ?? null, slotPos++);
4228
+ VALUES (?, ?, ?, 0, ?, ?, ?)`).run(sessionId2, componentId, slotName, slot.$required ? 1 : 0, slot.$description ?? null, slotPos++);
4469
4229
  if (slot.$allowedComponents && slot.$allowedComponents.length > 0) {
4470
- slot.$allowedComponents.forEach((ac, i) => insertAllowedComponent.run(sessionId, componentId, slotName, ac, i));
4230
+ slot.$allowedComponents.forEach((ac, i) => insertAllowedComponent.run(sessionId2, componentId, slotName, ac, i));
4471
4231
  }
4472
4232
  }
4473
4233
  }
4474
4234
  }
4475
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId);
4235
+ db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId2);
4476
4236
  db.exec("COMMIT");
4477
4237
  } catch (e) {
4478
4238
  db.exec("ROLLBACK");
4479
4239
  throw e;
4480
4240
  }
4481
4241
  }
4482
- function loadCDFComponents(db, sessionId) {
4242
+ function loadCDFComponents(db, sessionId2) {
4483
4243
  const components = db.prepare(`SELECT component_id, name, description FROM raw_components
4484
- WHERE session_id = ? AND status = 'generated' ORDER BY rowid`).all(sessionId);
4244
+ WHERE session_id = ? AND status = 'generated' ORDER BY rowid`).all(sessionId2);
4485
4245
  if (components.length === 0)
4486
4246
  return [];
4487
4247
  const props = db.prepare(`SELECT component_id, name, required, default_value, description,
4488
4248
  cdf_type, cdf_category, cdf_token_kind, position
4489
4249
  FROM raw_props
4490
4250
  WHERE session_id = ? AND cdf_type IS NOT NULL
4491
- ORDER BY component_id, position`).all(sessionId);
4251
+ ORDER BY component_id, position`).all(sessionId2);
4492
4252
  const allowedValues = db.prepare(`SELECT component_id, prop_name, value, position
4493
- FROM raw_prop_allowed_values WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(sessionId);
4494
- const slots = db.prepare(`SELECT component_id, name, description, required FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(sessionId);
4253
+ FROM raw_prop_allowed_values WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(sessionId2);
4254
+ const slots = db.prepare(`SELECT component_id, name, description, required FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(sessionId2);
4495
4255
  const allowedComponents = db.prepare(`SELECT component_id, slot_name, allowed_component
4496
- FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(sessionId);
4256
+ FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(sessionId2);
4497
4257
  const tokenPaths = db.prepare(`SELECT component_id, prop_name, position, path
4498
- FROM raw_prop_token_paths WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(sessionId);
4499
- const resolvedDefaultPaths = getRawTokenNamePaths(db, sessionId);
4500
- const tokenTypeByPath = new Map(db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ?").all(sessionId).map((token) => [token.path, token.type]));
4258
+ FROM raw_prop_token_paths WHERE session_id = ? ORDER BY component_id, prop_name, position`).all(sessionId2);
4259
+ const resolvedDefaultPaths = getRawTokenNamePaths(db, sessionId2);
4260
+ const tokenTypeByPath = new Map(db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ?").all(sessionId2).map((token) => [token.path, token.type]));
4501
4261
  const propsByComponent = indexRowsByKey(props, (p) => p.component_id);
4502
4262
  const allowedValuesByProp = indexRowsByKey(allowedValues, (av) => `${av.component_id}::${av.prop_name}`);
4503
4263
  const slotsByComponent = indexRowsByKey(slots, (s) => s.component_id);
@@ -4564,16 +4324,16 @@ function loadCDFComponents(db, sessionId) {
4564
4324
  return { key: name, entry };
4565
4325
  });
4566
4326
  }
4567
- function loadScopeComponents(db, sessionId) {
4327
+ function loadScopeComponents(db, sessionId2) {
4568
4328
  const rows = db.prepare(`SELECT name, component_id, status, reject_reason, review_reasons, needs_review FROM raw_components
4569
4329
  WHERE session_id = ? AND status IN ('extracted', 'accepted', 'rejected')
4570
- ORDER BY name`).all(sessionId);
4330
+ ORDER BY name`).all(sessionId2);
4571
4331
  if (rows.length === 0)
4572
4332
  return [];
4573
4333
  const slotRows = db.prepare(`SELECT component_id, name, position
4574
- FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(sessionId);
4334
+ FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`).all(sessionId2);
4575
4335
  const allowedRows = db.prepare(`SELECT component_id, slot_name, position, allowed_component
4576
- FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(sessionId);
4336
+ FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`).all(sessionId2);
4577
4337
  const slotsByComponent = indexRowsByKey(slotRows, (s) => s.component_id);
4578
4338
  const allowedBySlot = indexRowsByKey(allowedRows, (a) => `${a.component_id}::${a.slot_name}`);
4579
4339
  return rows.map((r) => {
@@ -4592,25 +4352,25 @@ function loadScopeComponents(db, sessionId) {
4592
4352
  };
4593
4353
  });
4594
4354
  }
4595
- function applyScopeDecisions(db, sessionId, decisions) {
4355
+ function applyScopeDecisions(db, sessionId2, decisions) {
4596
4356
  const now = (/* @__PURE__ */ new Date()).toISOString();
4597
4357
  const acceptedSet = new Set(decisions.accepted);
4598
4358
  const accepted = [...acceptedSet];
4599
4359
  const rejected = [...new Set(decisions.rejected)].filter((n) => !acceptedSet.has(n));
4600
4360
  if (rejected.length > 0) {
4601
4361
  const placeholders = rejected.map(() => "?").join(",");
4602
- db.prepare(`UPDATE raw_components SET status = 'rejected' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId, ...rejected);
4362
+ db.prepare(`UPDATE raw_components SET status = 'rejected' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId2, ...rejected);
4603
4363
  }
4604
4364
  if (accepted.length > 0) {
4605
4365
  const placeholders = accepted.map(() => "?").join(",");
4606
- db.prepare(`UPDATE raw_components SET status = 'generated' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId, ...accepted);
4366
+ db.prepare(`UPDATE raw_components SET status = 'generated' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId2, ...accepted);
4607
4367
  }
4608
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId);
4368
+ db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId2);
4609
4369
  }
4610
4370
  function findLatestSessionForCommand(db, command) {
4611
4371
  return getLatestCompletedSessionForCommand(db, command);
4612
4372
  }
4613
- function seedCDFFromPreviewResponse(db, sessionId, removedItems) {
4373
+ function seedCDFFromPreviewResponse(db, sessionId2, removedItems) {
4614
4374
  if (removedItems.length === 0)
4615
4375
  return 0;
4616
4376
  let totalSeeded = 0;
@@ -4620,7 +4380,7 @@ function seedCDFFromPreviewResponse(db, sessionId, removedItems) {
4620
4380
  for (const item of removedItems) {
4621
4381
  if (!item.fullProperties)
4622
4382
  continue;
4623
- const localComponent = db.prepare(`SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId, item.name);
4383
+ const localComponent = db.prepare(`SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId2, item.name);
4624
4384
  if (!localComponent)
4625
4385
  continue;
4626
4386
  const contentProps = new Set(item.contentProperties);
@@ -4628,13 +4388,13 @@ function seedCDFFromPreviewResponse(db, sessionId, removedItems) {
4628
4388
  for (const [propName, propSummary] of Object.entries(item.fullProperties)) {
4629
4389
  const cdfType = mapContentfulTypeToCdfType(propSummary.type);
4630
4390
  const cdfCategory = resolveCdfCategory(propSummary.category, propName, contentProps, designProps);
4631
- const result = updateStmt.run(cdfType, cdfCategory, sessionId, localComponent.component_id, propName);
4391
+ const result = updateStmt.run(cdfType, cdfCategory, sessionId2, localComponent.component_id, propName);
4632
4392
  totalSeeded += Number(result.changes);
4633
4393
  }
4634
4394
  }
4635
4395
  return totalSeeded;
4636
4396
  }
4637
- function seedDefaultsFromChangedItems(db, sessionId, changedItems) {
4397
+ function seedDefaultsFromChangedItems(db, sessionId2, changedItems) {
4638
4398
  if (changedItems.length === 0)
4639
4399
  return 0;
4640
4400
  let totalSeeded = 0;
@@ -4645,7 +4405,7 @@ function seedDefaultsFromChangedItems(db, sessionId, changedItems) {
4645
4405
  for (const { current } of changedItems) {
4646
4406
  if (!current.fullProperties)
4647
4407
  continue;
4648
- const localComponent = db.prepare(`SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId, current.name);
4408
+ const localComponent = db.prepare(`SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId2, current.name);
4649
4409
  if (!localComponent)
4650
4410
  continue;
4651
4411
  const contentProps = new Set(current.contentProperties);
@@ -4653,38 +4413,38 @@ function seedDefaultsFromChangedItems(db, sessionId, changedItems) {
4653
4413
  for (const [propName, propSummary] of Object.entries(current.fullProperties)) {
4654
4414
  if (propSummary.default !== void 0 && propSummary.default !== null) {
4655
4415
  const defaultStr = typeof propSummary.default === "string" ? propSummary.default : JSON.stringify(propSummary.default);
4656
- const result2 = updateDefaultStmt.run(defaultStr, sessionId, localComponent.component_id, propName);
4416
+ const result2 = updateDefaultStmt.run(defaultStr, sessionId2, localComponent.component_id, propName);
4657
4417
  totalSeeded += Number(result2.changes);
4658
4418
  }
4659
4419
  const cdfType = mapContentfulTypeToCdfType(propSummary.type);
4660
4420
  const cdfCategory = resolveCdfCategory(propSummary.category, propName, contentProps, designProps);
4661
- const result = updateCDFStmt.run(cdfType, cdfCategory, sessionId, localComponent.component_id, propName);
4421
+ const result = updateCDFStmt.run(cdfType, cdfCategory, sessionId2, localComponent.component_id, propName);
4662
4422
  totalSeeded += Number(result.changes);
4663
4423
  }
4664
4424
  }
4665
4425
  return totalSeeded;
4666
4426
  }
4667
- function backfillUnclassifiedProps(db, sessionId) {
4427
+ function backfillUnclassifiedProps(db, sessionId2) {
4668
4428
  const withCategory = db.prepare(`UPDATE raw_props SET cdf_type = 'string', cdf_category = category
4669
4429
  WHERE session_id = ? AND cdf_type IS NULL AND category IS NOT NULL
4670
4430
  AND component_id IN (
4671
4431
  SELECT component_id FROM raw_components WHERE session_id = ? AND status = 'generated'
4672
- )`).run(sessionId, sessionId);
4432
+ )`).run(sessionId2, sessionId2);
4673
4433
  const withoutCategory = db.prepare(`UPDATE raw_props SET cdf_type = 'string', cdf_category = 'content'
4674
4434
  WHERE session_id = ? AND cdf_type IS NULL AND category IS NULL
4675
4435
  AND component_id IN (
4676
4436
  SELECT component_id FROM raw_components WHERE session_id = ? AND status = 'generated'
4677
- )`).run(sessionId, sessionId);
4437
+ )`).run(sessionId2, sessionId2);
4678
4438
  return Number(withCategory.changes) + Number(withoutCategory.changes);
4679
4439
  }
4680
- function computeMapTokensInputHash(db, sessionId, componentSourceRefs = []) {
4440
+ function computeMapTokensInputHash(db, sessionId2, componentSourceRefs = []) {
4681
4441
  const props = db.prepare(`SELECT rc.name AS component_name, rp.name AS prop_name, rp.cdf_token_kind, rp.default_value
4682
4442
  FROM raw_props rp
4683
4443
  JOIN raw_components rc ON rc.session_id = rp.session_id AND rc.component_id = rp.component_id
4684
4444
  WHERE rp.session_id = ? AND rp.cdf_type = 'token' AND rp.cdf_category = 'design'
4685
- ORDER BY rc.name, rp.name`).all(sessionId);
4686
- const tokens = db.prepare(`SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path`).all(sessionId);
4687
- const defaultMappings = db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId);
4445
+ ORDER BY rc.name, rp.name`).all(sessionId2);
4446
+ const tokens = db.prepare(`SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path`).all(sessionId2);
4447
+ const defaultMappings = db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId2);
4688
4448
  const payload = {
4689
4449
  props: props.map((p) => ({
4690
4450
  component: p.component_name,
@@ -4765,13 +4525,13 @@ function storeCaches(db, entries) {
4765
4525
  throw e;
4766
4526
  }
4767
4527
  }
4768
- function storeScannedFiles(db, sessionId, filePaths) {
4528
+ function storeScannedFiles(db, sessionId2, filePaths) {
4769
4529
  db.exec("BEGIN");
4770
4530
  try {
4771
- db.prepare("DELETE FROM scanned_files WHERE session_id = ?").run(sessionId);
4531
+ db.prepare("DELETE FROM scanned_files WHERE session_id = ?").run(sessionId2);
4772
4532
  const insert = db.prepare("INSERT INTO scanned_files (session_id, path) VALUES (?, ?)");
4773
4533
  for (const path5 of filePaths) {
4774
- insert.run(sessionId, path5);
4534
+ insert.run(sessionId2, path5);
4775
4535
  }
4776
4536
  db.exec("COMMIT");
4777
4537
  } catch (e) {
@@ -4779,15 +4539,15 @@ function storeScannedFiles(db, sessionId, filePaths) {
4779
4539
  throw e;
4780
4540
  }
4781
4541
  }
4782
- function storeSlotCycles(db, sessionId, cycles) {
4542
+ function storeSlotCycles(db, sessionId2, cycles) {
4783
4543
  db.exec("BEGIN");
4784
4544
  try {
4785
- db.prepare("DELETE FROM slot_cycles WHERE session_id = ?").run(sessionId);
4545
+ db.prepare("DELETE FROM slot_cycles WHERE session_id = ?").run(sessionId2);
4786
4546
  const insert = db.prepare(`INSERT INTO slot_cycles (session_id, cycle_index, path_json, edges_json, suggested_break_json)
4787
4547
  VALUES (?, ?, ?, ?, ?)`);
4788
4548
  for (let i = 0; i < cycles.length; i += 1) {
4789
4549
  const cycle = cycles[i];
4790
- insert.run(sessionId, i, JSON.stringify(cycle.path), JSON.stringify(cycle.edges), cycle.suggestedBreak ? JSON.stringify(cycle.suggestedBreak) : null);
4550
+ insert.run(sessionId2, i, JSON.stringify(cycle.path), JSON.stringify(cycle.edges), cycle.suggestedBreak ? JSON.stringify(cycle.suggestedBreak) : null);
4791
4551
  }
4792
4552
  db.exec("COMMIT");
4793
4553
  } catch (e) {
@@ -4795,20 +4555,20 @@ function storeSlotCycles(db, sessionId, cycles) {
4795
4555
  throw e;
4796
4556
  }
4797
4557
  }
4798
- function loadSlotCycles(db, sessionId) {
4799
- const rows = db.prepare("SELECT cycle_index, path_json, edges_json, suggested_break_json FROM slot_cycles WHERE session_id = ? ORDER BY cycle_index").all(sessionId);
4558
+ function loadSlotCycles(db, sessionId2) {
4559
+ const rows = db.prepare("SELECT cycle_index, path_json, edges_json, suggested_break_json FROM slot_cycles WHERE session_id = ? ORDER BY cycle_index").all(sessionId2);
4800
4560
  return rows.map((r) => ({
4801
4561
  path: JSON.parse(r.path_json),
4802
4562
  edges: JSON.parse(r.edges_json),
4803
4563
  suggestedBreak: r.suggested_break_json ? JSON.parse(r.suggested_break_json) : null
4804
4564
  }));
4805
4565
  }
4806
- function findUnknownSlotAllowedComponents(db, sessionId, allowedComponentNames2, componentId) {
4566
+ function findUnknownSlotAllowedComponents(db, sessionId2, allowedComponentNames2, componentId) {
4807
4567
  const rows = db.prepare(`SELECT a.component_id, c.name AS component_name, a.slot_name, a.allowed_component
4808
4568
  FROM raw_slot_allowed_components a
4809
4569
  JOIN raw_components c ON c.session_id = a.session_id AND c.component_id = a.component_id
4810
4570
  WHERE a.session_id = ? AND (? IS NULL OR a.component_id = ?)
4811
- ORDER BY a.component_id, a.slot_name, a.position`).all(sessionId, componentId ?? null, componentId ?? null);
4571
+ ORDER BY a.component_id, a.slot_name, a.position`).all(sessionId2, componentId ?? null, componentId ?? null);
4812
4572
  return rows.filter((row) => !allowedComponentNames2.has(row.allowed_component)).map((row) => ({
4813
4573
  componentId: row.component_id,
4814
4574
  componentName: row.component_name,
@@ -4816,8 +4576,8 @@ function findUnknownSlotAllowedComponents(db, sessionId, allowedComponentNames2,
4816
4576
  allowedComponent: row.allowed_component
4817
4577
  }));
4818
4578
  }
4819
- function filterUnknownSlotAllowedComponents(db, sessionId, allowedComponentNames2) {
4820
- const unknown5 = findUnknownSlotAllowedComponents(db, sessionId, allowedComponentNames2);
4579
+ function filterUnknownSlotAllowedComponents(db, sessionId2, allowedComponentNames2) {
4580
+ const unknown5 = findUnknownSlotAllowedComponents(db, sessionId2, allowedComponentNames2);
4821
4581
  if (unknown5.length === 0)
4822
4582
  return unknown5;
4823
4583
  db.exec("BEGIN");
@@ -4825,7 +4585,7 @@ function filterUnknownSlotAllowedComponents(db, sessionId, allowedComponentNames
4825
4585
  const remove = db.prepare(`DELETE FROM raw_slot_allowed_components
4826
4586
  WHERE session_id = ? AND component_id = ? AND slot_name = ? AND allowed_component = ?`);
4827
4587
  for (const row of unknown5) {
4828
- remove.run(sessionId, row.componentId, row.slotName, row.allowedComponent);
4588
+ remove.run(sessionId2, row.componentId, row.slotName, row.allowedComponent);
4829
4589
  }
4830
4590
  db.exec("COMMIT");
4831
4591
  } catch (e) {
@@ -4973,7 +4733,7 @@ async function getCliCacheVersion() {
4973
4733
  return _cliCacheVersionCache;
4974
4734
  }
4975
4735
  }
4976
- function storeExtractCache(db, filePath, fileHash, cliVersion, components) {
4736
+ function storeExtractCache(db, filePath, fileHash, cliVersion2, components) {
4977
4737
  const now = (/* @__PURE__ */ new Date()).toISOString();
4978
4738
  const componentsJson = JSON.stringify(components);
4979
4739
  db.prepare(`INSERT INTO extract_cache (file_path, file_hash, cli_version, created_at, updated_at, components_json)
@@ -4981,12 +4741,12 @@ function storeExtractCache(db, filePath, fileHash, cliVersion, components) {
4981
4741
  ON CONFLICT(file_hash, cli_version) DO UPDATE SET
4982
4742
  file_path = excluded.file_path,
4983
4743
  updated_at = excluded.updated_at,
4984
- components_json = excluded.components_json`).run(filePath, fileHash, cliVersion, now, now, componentsJson);
4744
+ components_json = excluded.components_json`).run(filePath, fileHash, cliVersion2, now, now, componentsJson);
4985
4745
  }
4986
- function lookupExtractCache(db, fileHash, cliVersion) {
4746
+ function lookupExtractCache(db, fileHash, cliVersion2) {
4987
4747
  const row = db.prepare(`SELECT file_path, file_hash, cli_version, created_at, updated_at, components_json
4988
4748
  FROM extract_cache
4989
- WHERE file_hash = ? AND cli_version = ?`).get(fileHash, cliVersion);
4749
+ WHERE file_hash = ? AND cli_version = ?`).get(fileHash, cliVersion2);
4990
4750
  if (!row)
4991
4751
  return null;
4992
4752
  let components = [];
@@ -5004,31 +4764,31 @@ function lookupExtractCache(db, fileHash, cliVersion) {
5004
4764
  components
5005
4765
  };
5006
4766
  }
5007
- function storeCompositionCache(db, inputHash, cliVersion, agentOutput) {
4767
+ function storeCompositionCache(db, inputHash, cliVersion2, agentOutput) {
5008
4768
  const now = (/* @__PURE__ */ new Date()).toISOString();
5009
4769
  db.prepare(`INSERT INTO composition_cache (input_hash, cli_version, agent_output, created_at, updated_at)
5010
4770
  VALUES (?, ?, ?, ?, ?)
5011
4771
  ON CONFLICT(input_hash, cli_version) DO UPDATE SET
5012
4772
  agent_output = excluded.agent_output,
5013
- updated_at = excluded.updated_at`).run(inputHash, cliVersion, agentOutput, now, now);
4773
+ updated_at = excluded.updated_at`).run(inputHash, cliVersion2, agentOutput, now, now);
5014
4774
  }
5015
- function lookupCompositionCache(db, inputHash, cliVersion) {
5016
- const row = db.prepare(`SELECT agent_output FROM composition_cache WHERE input_hash = ? AND cli_version = ?`).get(inputHash, cliVersion);
4775
+ function lookupCompositionCache(db, inputHash, cliVersion2) {
4776
+ const row = db.prepare(`SELECT agent_output FROM composition_cache WHERE input_hash = ? AND cli_version = ?`).get(inputHash, cliVersion2);
5017
4777
  return row ? row.agent_output : null;
5018
4778
  }
5019
- function storeSelectCache(db, componentHash, promptHash, cliVersion, decision, reason) {
4779
+ function storeSelectCache(db, componentHash, promptHash, cliVersion2, decision, reason) {
5020
4780
  const now = (/* @__PURE__ */ new Date()).toISOString();
5021
4781
  db.prepare(`INSERT INTO select_cache (component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at)
5022
4782
  VALUES (?, ?, ?, ?, ?, ?, ?)
5023
4783
  ON CONFLICT(component_hash, prompt_hash, cli_version) DO UPDATE SET
5024
4784
  decision = excluded.decision,
5025
4785
  reason = excluded.reason,
5026
- updated_at = excluded.updated_at`).run(componentHash, promptHash, cliVersion, decision, reason, now, now);
4786
+ updated_at = excluded.updated_at`).run(componentHash, promptHash, cliVersion2, decision, reason, now, now);
5027
4787
  }
5028
- function lookupSelectCache(db, componentHash, promptHash, cliVersion) {
4788
+ function lookupSelectCache(db, componentHash, promptHash, cliVersion2) {
5029
4789
  const row = db.prepare(`SELECT component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at
5030
4790
  FROM select_cache
5031
- WHERE component_hash = ? AND prompt_hash = ? AND cli_version = ?`).get(componentHash, promptHash, cliVersion);
4791
+ WHERE component_hash = ? AND prompt_hash = ? AND cli_version = ?`).get(componentHash, promptHash, cliVersion2);
5032
4792
  if (!row)
5033
4793
  return null;
5034
4794
  return {
@@ -12526,11 +12286,11 @@ async function loadReviewInput(components, options = {}) {
12526
12286
  }
12527
12287
 
12528
12288
  // packages/experience-design-system-backend-pipeline/dist/src/steps/selection/src/controller/review/load-and-validate-for-review.js
12529
- async function loadAndValidateForReview(sessionId, projectRoot) {
12289
+ async function loadAndValidateForReview(sessionId2, projectRoot) {
12530
12290
  const db = openPipelineDb();
12531
12291
  let rawComponents;
12532
12292
  try {
12533
- rawComponents = loadRawComponents(db, sessionId);
12293
+ rawComponents = loadRawComponents(db, sessionId2);
12534
12294
  } finally {
12535
12295
  db.close();
12536
12296
  }
@@ -12546,18 +12306,18 @@ import { access as access2, mkdir, readFile as readFile7, writeFile } from "node
12546
12306
 
12547
12307
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
12548
12308
  import { resolve as resolve15 } from "node:path";
12549
- async function getRefineSessionPaths(sessionId, artifactsRoot) {
12550
- const sessionDir2 = resolve15(artifactsRoot, sessionId);
12309
+ async function getRefineSessionPaths(sessionId2, artifactsRoot) {
12310
+ const sessionDir = resolve15(artifactsRoot, sessionId2);
12551
12311
  return {
12552
- sessionDir: sessionDir2,
12553
- eventsPath: resolve15(sessionDir2, "events.jsonl"),
12554
- statePath: resolve15(sessionDir2, "current-review-state.json")
12312
+ sessionDir,
12313
+ eventsPath: resolve15(sessionDir, "events.jsonl"),
12314
+ statePath: resolve15(sessionDir, "current-review-state.json")
12555
12315
  };
12556
12316
  }
12557
12317
 
12558
12318
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/ensure-review-session.js
12559
- async function ensureRefineSession(sessionId, artifactsRoot, initialSnapshot) {
12560
- const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
12319
+ async function ensureRefineSession(sessionId2, artifactsRoot, initialSnapshot) {
12320
+ const paths = await getRefineSessionPaths(sessionId2, artifactsRoot);
12561
12321
  await mkdir(paths.sessionDir, { recursive: true });
12562
12322
  try {
12563
12323
  await access2(paths.statePath);
@@ -12586,16 +12346,16 @@ async function saveReviewState(statePath, session) {
12586
12346
  }
12587
12347
 
12588
12348
  // packages/experience-design-system-backend-pipeline/dist/src/steps/selection/src/controller/review/merge-preview-validation-errors-into-review-session.js
12589
- async function mergePreviewValidationErrorsIntoReviewSession(sessionId, errors, opts = {}) {
12349
+ async function mergePreviewValidationErrorsIntoReviewSession(sessionId2, errors, opts = {}) {
12590
12350
  const artifactsRoot = opts.artifactsRoot ?? getRefineArtifactsRoot();
12591
- const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
12351
+ const paths = await getRefineSessionPaths(sessionId2, artifactsRoot);
12592
12352
  let snapshot;
12593
12353
  try {
12594
12354
  await access3(paths.statePath);
12595
12355
  snapshot = JSON.parse(await readFile8(paths.statePath, "utf8"));
12596
12356
  } catch {
12597
- snapshot = await loadAndValidateForReview(sessionId, void 0);
12598
- snapshot = await ensureRefineSession(sessionId, artifactsRoot, snapshot);
12357
+ snapshot = await loadAndValidateForReview(sessionId2, void 0);
12358
+ snapshot = await ensureRefineSession(sessionId2, artifactsRoot, snapshot);
12599
12359
  }
12600
12360
  const errorsByName = /* @__PURE__ */ new Map();
12601
12361
  for (const err of errors) {
@@ -12631,18 +12391,18 @@ async function mergePreviewValidationErrorsIntoReviewSession(sessionId, errors,
12631
12391
 
12632
12392
  // packages/experience-design-system-backend-pipeline/dist/src/steps/selection/src/controller/review/reject-components-by-name.js
12633
12393
  import { readFile as readFile9 } from "node:fs/promises";
12634
- async function rejectComponentsByName(sessionId, names, opts = {}) {
12394
+ async function rejectComponentsByName(sessionId2, names, opts = {}) {
12635
12395
  if (names.length === 0)
12636
12396
  return;
12637
12397
  const db = openPipelineDb();
12638
12398
  try {
12639
12399
  const placeholders = names.map(() => "?").join(",");
12640
- db.prepare(`UPDATE raw_components SET status = 'generate-rejected' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId, ...names);
12400
+ db.prepare(`UPDATE raw_components SET status = 'generate-rejected' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId2, ...names);
12641
12401
  } finally {
12642
12402
  db.close();
12643
12403
  }
12644
12404
  const artifactsRoot = opts.artifactsRoot ?? getRefineArtifactsRoot();
12645
- const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
12405
+ const paths = await getRefineSessionPaths(sessionId2, artifactsRoot);
12646
12406
  const nameSet = new Set(names);
12647
12407
  let snapshot;
12648
12408
  try {
@@ -13070,9 +12830,9 @@ function buildTimestampedSubdir(base, now = /* @__PURE__ */ new Date()) {
13070
12830
 
13071
12831
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/services/write-scope-decisions-snapshot.js
13072
12832
  import { mkdir as mkdir3 } from "node:fs/promises";
13073
- async function writeScopeDecisionsSnapshot(db, sessionId, decisions) {
12833
+ async function writeScopeDecisionsSnapshot(db, sessionId2, decisions) {
13074
12834
  const acceptedSet = new Set(decisions.accepted);
13075
- const rawComponents = loadRawComponents(db, sessionId);
12835
+ const rawComponents = loadRawComponents(db, sessionId2);
13076
12836
  const records = rawComponents.map((c2) => {
13077
12837
  const status = acceptedSet.has(c2.name) ? "accepted" : "rejected";
13078
12838
  const proposal = {
@@ -13095,17 +12855,17 @@ async function writeScopeDecisionsSnapshot(db, sessionId, decisions) {
13095
12855
  status
13096
12856
  };
13097
12857
  });
13098
- const paths = await getRefineSessionPaths(sessionId, getRefineArtifactsRoot());
12858
+ const paths = await getRefineSessionPaths(sessionId2, getRefineArtifactsRoot());
13099
12859
  await mkdir3(paths.sessionDir, { recursive: true });
13100
12860
  await saveReviewState(paths.statePath, { components: records });
13101
12861
  }
13102
12862
 
13103
12863
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/load-accepted-names.js
13104
12864
  import { readFile as readFile12 } from "node:fs/promises";
13105
- async function loadAcceptedNames(sessionId) {
12865
+ async function loadAcceptedNames(sessionId2) {
13106
12866
  try {
13107
12867
  const artifactsRoot = getRefineArtifactsRoot();
13108
- const paths = await getRefineSessionPaths(sessionId, artifactsRoot);
12868
+ const paths = await getRefineSessionPaths(sessionId2, artifactsRoot);
13109
12869
  const raw = await readFile12(paths.statePath, "utf8");
13110
12870
  const snapshot = JSON.parse(raw);
13111
12871
  const accepted = snapshot.components.filter((c2) => c2.status === "accepted").map((c2) => c2.name);
@@ -13120,6 +12880,60 @@ async function loadAcceptedNames(sessionId) {
13120
12880
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/index.js
13121
12881
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
13122
12882
 
12883
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/helpers/generate-session-id.js
12884
+ import { randomBytes as randomBytes3 } from "node:crypto";
12885
+ var ADJECTIVES2 = [
12886
+ "bright",
12887
+ "calm",
12888
+ "dark",
12889
+ "fast",
12890
+ "green",
12891
+ "happy",
12892
+ "keen",
12893
+ "light",
12894
+ "long",
12895
+ "loud",
12896
+ "pale",
12897
+ "quick",
12898
+ "sharp",
12899
+ "slow",
12900
+ "soft",
12901
+ "warm",
12902
+ "wild",
12903
+ "wise"
12904
+ ];
12905
+ var NOUNS2 = [
12906
+ "cloud",
12907
+ "creek",
12908
+ "dawn",
12909
+ "dusk",
12910
+ "field",
12911
+ "flame",
12912
+ "frost",
12913
+ "grove",
12914
+ "hill",
12915
+ "lake",
12916
+ "leaf",
12917
+ "moon",
12918
+ "peak",
12919
+ "rain",
12920
+ "river",
12921
+ "rock",
12922
+ "snow",
12923
+ "star",
12924
+ "storm",
12925
+ "tide",
12926
+ "tree",
12927
+ "wave",
12928
+ "wind"
12929
+ ];
12930
+ function generateSessionId2() {
12931
+ const adj = ADJECTIVES2[Math.floor(Math.random() * ADJECTIVES2.length)];
12932
+ const noun = NOUNS2[Math.floor(Math.random() * NOUNS2.length)];
12933
+ const hex = randomBytes3(2).toString("hex");
12934
+ return `${adj}-${noun}-${hex}`;
12935
+ }
12936
+
13123
12937
  // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/migration.js
13124
12938
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
13125
12939
 
@@ -13750,7 +13564,7 @@ function errorMessage(error) {
13750
13564
  return error instanceof Error && error.message ? error.message : String(error);
13751
13565
  }
13752
13566
  function defaultSleep(delayMs) {
13753
- return new Promise((resolve26) => setTimeout(resolve26, delayMs));
13567
+ return new Promise((resolve25) => setTimeout(resolve25, delayMs));
13754
13568
  }
13755
13569
 
13756
13570
  // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
@@ -13991,7 +13805,7 @@ var ApiClient = class {
13991
13805
  const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
13992
13806
  const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
13993
13807
  const jitter = Math.random() * baseDelay * 0.15;
13994
- await new Promise((resolve26) => setTimeout(resolve26, baseDelay + jitter));
13808
+ await new Promise((resolve25) => setTimeout(resolve25, baseDelay + jitter));
13995
13809
  }
13996
13810
  }
13997
13811
  throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
@@ -14822,33 +14636,33 @@ function filterAllowedPaths(args) {
14822
14636
  }
14823
14637
 
14824
14638
  // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/map-tokens/is-prop-reviewed.js
14825
- function isPropReviewed(db, sessionId, componentId, propName) {
14639
+ function isPropReviewed(db, sessionId2, componentId, propName) {
14826
14640
  const row = db.prepare(`SELECT COUNT(*) AS count FROM raw_prop_token_paths
14827
14641
  WHERE session_id = ? AND component_id = ? AND prop_name = ?
14828
- AND source = 'review'`).get(sessionId, componentId, propName);
14642
+ AND source = 'review'`).get(sessionId2, componentId, propName);
14829
14643
  return row.count > 0;
14830
14644
  }
14831
14645
 
14832
14646
  // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/map-tokens/load-token-type-by-path.js
14833
- function loadTokenTypeByPath(db, sessionId) {
14834
- const rows = db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ?").all(sessionId);
14647
+ function loadTokenTypeByPath(db, sessionId2) {
14648
+ const rows = db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ?").all(sessionId2);
14835
14649
  return new Map(rows.map((r) => [r.path, r.type]));
14836
14650
  }
14837
14651
 
14838
14652
  // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/map-tokens/apply-map-token-prop-calls.js
14839
- function applyMapTokenPropCalls(db, sessionId, calls, incomingWarnings) {
14653
+ function applyMapTokenPropCalls(db, sessionId2, calls, incomingWarnings) {
14840
14654
  const warnings = [...incomingWarnings];
14841
14655
  let applied = 0;
14842
- const tokenTypeByPath = loadTokenTypeByPath(db, sessionId);
14656
+ const tokenTypeByPath = loadTokenTypeByPath(db, sessionId2);
14843
14657
  const findComponent = db.prepare("SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?");
14844
14658
  const findProp = db.prepare("SELECT cdf_type, cdf_category, cdf_token_kind FROM raw_props WHERE session_id = ? AND component_id = ? AND name = ?");
14845
14659
  for (const call of calls) {
14846
- const component = findComponent.get(sessionId, call.component);
14660
+ const component = findComponent.get(sessionId2, call.component);
14847
14661
  if (!component) {
14848
14662
  warnings.push(`map_token_prop: unknown component '${call.component}' \u2014 skipped`);
14849
14663
  continue;
14850
14664
  }
14851
- const prop = findProp.get(sessionId, component.component_id, call.prop);
14665
+ const prop = findProp.get(sessionId2, component.component_id, call.prop);
14852
14666
  if (!prop) {
14853
14667
  warnings.push(`map_token_prop '${call.component}.${call.prop}': unknown prop \u2014 skipped`);
14854
14668
  continue;
@@ -14857,7 +14671,7 @@ function applyMapTokenPropCalls(db, sessionId, calls, incomingWarnings) {
14857
14671
  warnings.push(`map_token_prop '${call.component}.${call.prop}': target is not a design-category token prop \u2014 skipped`);
14858
14672
  continue;
14859
14673
  }
14860
- if (isPropReviewed(db, sessionId, component.component_id, call.prop)) {
14674
+ if (isPropReviewed(db, sessionId2, component.component_id, call.prop)) {
14861
14675
  warnings.push(`map_token_prop '${call.component}.${call.prop}': a reviewer already set this restriction \u2014 skipped`);
14862
14676
  continue;
14863
14677
  }
@@ -14873,7 +14687,7 @@ function applyMapTokenPropCalls(db, sessionId, calls, incomingWarnings) {
14873
14687
  warnings.push(`map_token_prop '${call.component}.${call.prop}': no valid token_allowed remain \u2014 skipped`);
14874
14688
  continue;
14875
14689
  }
14876
- replaceRawPropTokenPaths(db, sessionId, component.component_id, call.prop, filteredAllowed, "agent");
14690
+ replaceRawPropTokenPaths(db, sessionId2, component.component_id, call.prop, filteredAllowed, "agent");
14877
14691
  applied++;
14878
14692
  }
14879
14693
  return { applied, warnings };
@@ -14911,18 +14725,176 @@ function countMappableProps(cdfEntries) {
14911
14725
  }
14912
14726
 
14913
14727
  // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/map-tokens/load-raw-defaults.js
14914
- function loadRawDefaults(db, sessionId) {
14728
+ function loadRawDefaults(db, sessionId2) {
14915
14729
  return db.prepare(`SELECT rp.default_value AS default_reference, rp.cdf_token_kind
14916
14730
  FROM raw_props rp
14917
14731
  JOIN raw_components rc ON rc.session_id = rp.session_id AND rc.component_id = rp.component_id
14918
14732
  WHERE rp.session_id = ? AND rc.status = 'generated'
14919
14733
  AND rp.cdf_type = 'token' AND rp.cdf_category = 'design'
14920
- AND rp.default_value IS NOT NULL`).all(sessionId);
14734
+ AND rp.default_value IS NOT NULL`).all(sessionId2);
14921
14735
  }
14922
14736
 
14923
14737
  // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/map-tokens/load-token-leaves.js
14924
- function loadTokenLeaves(db, sessionId) {
14925
- return db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path").all(sessionId);
14738
+ function loadTokenLeaves(db, sessionId2) {
14739
+ return db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path").all(sessionId2);
14740
+ }
14741
+
14742
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/client.js
14743
+ import { Analytics } from "@segment/analytics-node";
14744
+ var DEFAULT_WRITE_KEY = "6DmxiEPN3SV1vbRTTMcNqDzCvkfwT06N";
14745
+ var analyticsClient = null;
14746
+ var persistedDisabled = false;
14747
+ var cliVersionString = "0.0.0-unknown";
14748
+ function cliVersion() {
14749
+ return cliVersionString;
14750
+ }
14751
+ function analyticsEnabled() {
14752
+ return !persistedDisabled && !process.env["DISABLE_ANALYTICS"];
14753
+ }
14754
+ function resolveWriteKey() {
14755
+ const key = (process.env["SEGMENT_WRITE_KEY"] ?? "").trim();
14756
+ return key.length > 0 ? key : DEFAULT_WRITE_KEY;
14757
+ }
14758
+ function getClient() {
14759
+ if (!analyticsEnabled())
14760
+ return null;
14761
+ const writeKey = resolveWriteKey();
14762
+ if (!writeKey)
14763
+ return null;
14764
+ if (!analyticsClient) {
14765
+ analyticsClient = new Analytics({ writeKey });
14766
+ analyticsClient.on("error", () => {
14767
+ });
14768
+ }
14769
+ return analyticsClient;
14770
+ }
14771
+ async function trackEvent(event, properties, anonymousId, options) {
14772
+ const client2 = getClient();
14773
+ if (!client2)
14774
+ return;
14775
+ try {
14776
+ client2.track({
14777
+ event,
14778
+ properties,
14779
+ anonymousId,
14780
+ timestamp: /* @__PURE__ */ new Date()
14781
+ });
14782
+ if (options?.flush)
14783
+ await flushAnalytics();
14784
+ } catch {
14785
+ }
14786
+ }
14787
+ async function flushAnalytics() {
14788
+ if (!analyticsClient)
14789
+ return;
14790
+ try {
14791
+ await analyticsClient.closeAndFlush();
14792
+ } catch {
14793
+ } finally {
14794
+ analyticsClient = null;
14795
+ }
14796
+ }
14797
+
14798
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/constants.js
14799
+ var ANALYTICS_SESSION_ENV = "EDS_ANALYTICS_SESSION_ID";
14800
+ var IMPORT_PIPELINE_ENV = "EDS_IMPORT_PIPELINE";
14801
+
14802
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/session.js
14803
+ function resolveAnalyticsSessionId(explicit) {
14804
+ const inherited = process.env[ANALYTICS_SESSION_ENV]?.trim();
14805
+ if (inherited)
14806
+ return inherited;
14807
+ const passed = explicit?.trim();
14808
+ if (passed)
14809
+ return passed;
14810
+ return generateSessionId2();
14811
+ }
14812
+ function isPipelineAnalyticsChild() {
14813
+ return Boolean(process.env[ANALYTICS_SESSION_ENV]?.trim());
14814
+ }
14815
+
14816
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/os.js
14817
+ var OS_NAMES2 = {
14818
+ android: "Android",
14819
+ aix: "Linux",
14820
+ darwin: "macOS",
14821
+ freebsd: "Linux",
14822
+ linux: "Linux",
14823
+ openbsd: "Linux",
14824
+ sunos: "Linux",
14825
+ win32: "Windows"
14826
+ };
14827
+ function getOsName() {
14828
+ return OS_NAMES2[process.platform] ?? "other";
14829
+ }
14830
+
14831
+ // packages/experience-design-system-backend-pipeline/dist/src/analytics/tracker.js
14832
+ var pending = null;
14833
+ var sessionId;
14834
+ var sessionStartedEmitted = false;
14835
+ function isPipelineStep() {
14836
+ return process.env[IMPORT_PIPELINE_ENV] === "1";
14837
+ }
14838
+ function buildBaseProps(command) {
14839
+ return {
14840
+ dsi_session_id: sessionId,
14841
+ command,
14842
+ ...isPipelineStep() ? { is_pipeline_step: true } : {}
14843
+ };
14844
+ }
14845
+ function mergeContext(target, source) {
14846
+ if (source.space_key !== void 0)
14847
+ target.space_key = source.space_key;
14848
+ if (source.environment_key !== void 0)
14849
+ target.environment_key = source.environment_key;
14850
+ if (source.x_contentful_request_id !== void 0) {
14851
+ target.x_contentful_request_id = source.x_contentful_request_id;
14852
+ }
14853
+ }
14854
+ async function bindAnalyticsSessionId(explicit, context) {
14855
+ const id = resolveAnalyticsSessionId(explicit);
14856
+ await bindAnalyticsSession(id, context);
14857
+ return id;
14858
+ }
14859
+ function setCommandContext(context) {
14860
+ if (!pending)
14861
+ return;
14862
+ mergeContext(pending.context, context);
14863
+ mergeContext(pending.completion, context);
14864
+ }
14865
+ function enrichCommandResult(fields) {
14866
+ if (!pending)
14867
+ return;
14868
+ Object.assign(pending.completion, fields);
14869
+ mergeContext(pending.context, fields);
14870
+ }
14871
+ async function bindAnalyticsSession(id, context) {
14872
+ sessionId = id;
14873
+ if (context)
14874
+ setCommandContext(context);
14875
+ await emitInvokedIfReady();
14876
+ }
14877
+ async function emitSessionStarted(entryCommand) {
14878
+ if (!sessionId || sessionStartedEmitted)
14879
+ return;
14880
+ sessionStartedEmitted = true;
14881
+ await trackEvent("dsi_cli_session_started", {
14882
+ dsi_session_id: sessionId,
14883
+ entry_command: entryCommand,
14884
+ cli_version: cliVersion(),
14885
+ node_version: process.version,
14886
+ os_name: getOsName()
14887
+ }, sessionId, { flush: true });
14888
+ await emitInvokedIfReady();
14889
+ }
14890
+ async function emitInvokedIfReady() {
14891
+ if (!pending || pending.invoked || !sessionId)
14892
+ return;
14893
+ pending.invoked = true;
14894
+ await trackEvent("dsi_cli_command_invoked", {
14895
+ ...buildBaseProps(pending.command),
14896
+ ...pending.context
14897
+ }, sessionId, { flush: true });
14926
14898
  }
14927
14899
 
14928
14900
  // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/map-tokens/run-map-tokens.js
@@ -14950,42 +14922,53 @@ async function runMapTokens(request) {
14950
14922
  const timeoutMs = request.agentTimeoutMs ?? DEFAULT_TIMEOUT_MS2;
14951
14923
  const db = openPipelineDb();
14952
14924
  try {
14953
- const sessionId = request.sessionId ?? findLatestSessionForCommand(db, "generate components");
14954
- if (!sessionId) {
14925
+ const sessionId2 = request.sessionId ?? findLatestSessionForCommand(db, "generate components");
14926
+ if (!sessionId2) {
14955
14927
  throw new MapTokensRunFailure({ type: "no-session" });
14956
14928
  }
14957
- const tokenLeaves = loadTokenLeaves(db, sessionId);
14929
+ await bindAnalyticsSessionId(sessionId2);
14930
+ const tokenLeaves = loadTokenLeaves(db, sessionId2);
14958
14931
  const knownTokenPaths = new Set(tokenLeaves.map((t) => t.path));
14932
+ const diagnostics = [];
14959
14933
  if (request.tokenMapInline) {
14960
14934
  const validMappings = {};
14961
14935
  for (const [rawName, path5] of Object.entries(request.tokenMapInline)) {
14962
- if (knownTokenPaths.has(path5))
14936
+ if (knownTokenPaths.has(path5)) {
14963
14937
  validMappings[rawName] = path5;
14938
+ } else {
14939
+ diagnostics.push(`Token map '${rawName}' -> '${path5}': path not found in session tokens \u2014 skipped.`);
14940
+ }
14964
14941
  }
14965
- replaceRawTokenNamePaths(db, sessionId, validMappings, "manual");
14942
+ replaceRawTokenNamePaths(db, sessionId2, validMappings, "manual");
14966
14943
  }
14967
- const rawDefaults = loadRawDefaults(db, sessionId);
14944
+ const rawDefaults = loadRawDefaults(db, sessionId2);
14968
14945
  const defaultResolution = resolveTokenDefaults(rawDefaults.map((row) => ({ rawDefault: row.default_reference, tokenKind: row.cdf_token_kind })), tokenLeaves);
14969
- const manualMappings = new Map(getRawTokenNamePathRows(db, sessionId).filter((row) => row.source === "manual").map((row) => [row.rawName, row.path]));
14946
+ for (const diagnostic of defaultResolution.diagnostics)
14947
+ diagnostics.push(diagnostic.message);
14948
+ const manualMappings = new Map(getRawTokenNamePathRows(db, sessionId2).filter((row) => row.source === "manual").map((row) => [row.rawName, row.path]));
14970
14949
  const automaticMappings = {};
14971
14950
  for (const [rawName, path5] of Object.entries(defaultResolution.mappings)) {
14972
- if (manualMappings.get(rawName) === void 0)
14951
+ const manualPath = manualMappings.get(rawName);
14952
+ if (manualPath === void 0) {
14973
14953
  automaticMappings[rawName] = path5;
14954
+ } else if (manualPath !== path5) {
14955
+ diagnostics.push(`Token default '${rawName}' automatically resolves to '${path5}', but manual mapping '${manualPath}' is retained.`);
14956
+ }
14974
14957
  }
14975
- replaceRawTokenNamePaths(db, sessionId, automaticMappings, "automatic");
14976
- const cdfEntries = loadCDFComponents(db, sessionId);
14958
+ replaceRawTokenNamePaths(db, sessionId2, automaticMappings, "automatic");
14959
+ const cdfEntries = loadCDFComponents(db, sessionId2);
14977
14960
  if (cdfEntries.length === 0) {
14978
- throw new MapTokensRunFailure({ type: "no-components", sessionId });
14961
+ throw new MapTokensRunFailure({ type: "no-components", sessionId: sessionId2 });
14979
14962
  }
14980
14963
  const mappablePropCount = countMappableProps(cdfEntries);
14981
- const { groups, tokens } = getDtcgTokensForSession(db, sessionId);
14964
+ const { groups, tokens } = getDtcgTokensForSession(db, sessionId2);
14982
14965
  const tokenCount = tokens.length;
14983
14966
  if (mappablePropCount === 0 || tokenCount === 0) {
14984
- return { type: "nothing-to-map", sessionId, mappablePropCount, tokenCount };
14967
+ return { type: "nothing-to-map", sessionId: sessionId2, mappablePropCount, tokenCount, diagnostics };
14985
14968
  }
14986
14969
  const generatedCdf = Object.fromEntries(cdfEntries.map((c2) => [c2.key, c2.entry]));
14987
14970
  const tokenTree = rebuildDTCGTree(groups, tokens);
14988
- const componentSourceRefs = await loadComponentSourceRefs(db, sessionId);
14971
+ const componentSourceRefs = await loadComponentSourceRefs(db, sessionId2);
14989
14972
  const buildMapPrompt = () => buildPrompt({
14990
14973
  skill: "map-tokens",
14991
14974
  mode: "autonomous",
@@ -14999,28 +14982,28 @@ async function runMapTokens(request) {
14999
14982
  });
15000
14983
  if (request.printPrompt) {
15001
14984
  const prompt2 = await buildMapPrompt();
15002
- return { type: "printed-prompt", sessionId, prompt: prompt2 };
14985
+ return { type: "printed-prompt", sessionId: sessionId2, prompt: prompt2, diagnostics };
15003
14986
  }
15004
14987
  if (request.skipAgent) {
15005
- const stepId2 = createStep(db, sessionId, "map tokens", {
14988
+ const stepId2 = createStep(db, sessionId2, "map tokens", {
15006
14989
  agent: request.agent,
15007
14990
  model: request.model ?? "",
15008
14991
  skipAgent: "true"
15009
14992
  });
15010
14993
  updateStep(db, stepId2, "complete", { applied: "0", skipAgent: "true" });
15011
- return { type: "skipped", sessionId, stepId: stepId2 };
14994
+ return { type: "skipped", sessionId: sessionId2, stepId: stepId2, diagnostics };
15012
14995
  }
15013
14996
  const agent = request.agent;
15014
14997
  const noCache = request.cache === false || process.env["EDS_NO_CACHE"] === "1";
15015
14998
  const promptHash = await hashPromptForSkill("map-tokens", agent, request.model, request.skillPathOverride, request.existingEntitiesInline ? [hashContent(request.existingEntitiesInline)] : [], request.skillContentOverride);
15016
- const inputHash = computeMapTokensInputHash(db, sessionId, componentSourceRefs);
14999
+ const inputHash = computeMapTokensInputHash(db, sessionId2, componentSourceRefs);
15017
15000
  if (!noCache) {
15018
15001
  const cached = lookupCache(db, inputHash, "token_mapping", "__map_tokens__", promptHash);
15019
15002
  if (cached) {
15020
- const applied2 = copyMapTokensFromCache(db, cached.sourceSessionId, sessionId);
15021
- const stepId2 = createStep(db, sessionId, "map tokens", { agent, model: request.model ?? "" });
15003
+ const applied2 = copyMapTokensFromCache(db, cached.sourceSessionId, sessionId2);
15004
+ const stepId2 = createStep(db, sessionId2, "map tokens", { agent, model: request.model ?? "" });
15022
15005
  updateStep(db, stepId2, "complete", { cached: "true", applied: String(applied2) });
15023
- return { type: "cached", sessionId, applied: applied2, stepId: stepId2 };
15006
+ return { type: "cached", sessionId: sessionId2, applied: applied2, stepId: stepId2, diagnostics };
15024
15007
  }
15025
15008
  }
15026
15009
  const binary = resolveBinary(agent);
@@ -15032,22 +15015,22 @@ async function runMapTokens(request) {
15032
15015
  skillPath: resolveSkillPath("map-tokens")
15033
15016
  });
15034
15017
  }
15035
- const stepId = createStep(db, sessionId, "map tokens", { agent, model: request.model ?? "" });
15018
+ const stepId = createStep(db, sessionId2, "map tokens", { agent, model: request.model ?? "" });
15036
15019
  const prompt = await buildMapPrompt();
15037
15020
  const invoker = createLocalCliAgentInvoker();
15038
15021
  const result = await invoker.invoke({ agent, model: request.model, prompt, timeoutMs });
15039
15022
  if (result.timedOut || result.exitCode !== 0) {
15040
15023
  const error = result.timedOut ? `timed out after ${timeoutMs / 6e4} minutes` : describeAgentFailure(result);
15041
15024
  updateStep(db, stepId, "failed", {}, error);
15042
- throw new MapTokensRunFailure({ type: "agent-failed", sessionId, stepId, error });
15025
+ throw new MapTokensRunFailure({ type: "agent-failed", sessionId: sessionId2, stepId, error });
15043
15026
  }
15044
15027
  const { calls, warnings: parseWarnings } = parseMapTokenPropToolCalls(result.stdout);
15045
- const { applied, warnings } = applyMapTokenPropCalls(db, sessionId, calls, parseWarnings);
15028
+ const { applied, warnings } = applyMapTokenPropCalls(db, sessionId2, calls, parseWarnings);
15046
15029
  if (!noCache) {
15047
- storeCache(db, inputHash, "token_mapping", "__map_tokens__", sessionId, false, promptHash);
15030
+ storeCache(db, inputHash, "token_mapping", "__map_tokens__", sessionId2, false, promptHash);
15048
15031
  }
15049
15032
  updateStep(db, stepId, "complete", { applied: String(applied), warnings: String(warnings.length) });
15050
- return { type: "applied", sessionId, applied, warnings, stepId };
15033
+ return { type: "applied", sessionId: sessionId2, applied, warnings, stepId, diagnostics };
15051
15034
  } finally {
15052
15035
  db.close();
15053
15036
  }
@@ -16104,20 +16087,20 @@ async function retryDatabaseWrite(operation, attempts = 8) {
16104
16087
  const message = error instanceof Error ? error.message : String(error);
16105
16088
  if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
16106
16089
  throw error;
16107
- await new Promise((resolve26) => setTimeout(resolve26, Math.min(250 * attempt, 2e3)));
16090
+ await new Promise((resolve25) => setTimeout(resolve25, Math.min(250 * attempt, 2e3)));
16108
16091
  }
16109
16092
  }
16110
16093
  }
16111
16094
 
16112
16095
  // packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-extract-and-compose-session/helpers/persist-slot-cycles.js
16113
- async function persistSlotCycles(db, sessionId, components) {
16096
+ async function persistSlotCycles(db, sessionId2, components) {
16114
16097
  const graph = components.map((c2) => ({
16115
16098
  name: c2.name,
16116
16099
  slots: c2.slots.map((s) => ({ name: s.name, allowedComponents: s.allowedComponents }))
16117
16100
  }));
16118
16101
  const cycles = findSlotCycles(graph);
16119
16102
  const withBreaks = cycles.map((cycle) => ({ ...cycle, suggestedBreak: suggestCycleBreakEdge(cycle, cycles) }));
16120
- await retryDatabaseWrite(() => storeSlotCycles(db, sessionId, withBreaks));
16103
+ await retryDatabaseWrite(() => storeSlotCycles(db, sessionId2, withBreaks));
16121
16104
  }
16122
16105
 
16123
16106
  // packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-extract-and-compose-session/helpers/resolve-composition.js
@@ -16261,20 +16244,23 @@ async function runExtractAndComposeSession(request) {
16261
16244
  onDebugEvent
16262
16245
  });
16263
16246
  await mkdir4(outDir, { recursive: true });
16264
- const { sessionId } = getOrCreateSession(db, void 0, void 0, {
16247
+ const { sessionId: sessionId2 } = getOrCreateSession(db, void 0, void 0, {
16265
16248
  command: "analyze extract",
16266
16249
  inputPath: projectPath,
16267
16250
  outDir
16268
16251
  });
16269
- await onSessionCreated?.(sessionId);
16270
- const stepId = createStep(db, sessionId, "analyze extract", { project: projectPath });
16252
+ await onSessionCreated?.(sessionId2);
16253
+ await bindAnalyticsSessionId(sessionId2);
16254
+ if (!isPipelineAnalyticsChild())
16255
+ await emitSessionStarted("analyze_extract");
16256
+ const stepId = createStep(db, sessionId2, "analyze extract", { project: projectPath });
16271
16257
  if (cacheHits === 0 && !noCache) {
16272
16258
  await persistExtractCache(db, sourceFiles, extraction.components, cacheVersion);
16273
16259
  }
16274
16260
  emitPreClassificationExclusions(extraction, onExclusion);
16275
16261
  const classifiedComponents = extraction.components.map(preClassifyComponent);
16276
16262
  const { components: initialValidatedComponents, warnings: filterWarnings } = await evaluateExtractionQuality(classifiedComponents);
16277
- storeRawComponents(db, sessionId, initialValidatedComponents);
16263
+ storeRawComponents(db, sessionId2, initialValidatedComponents);
16278
16264
  const sources = resolveCompositionSources({ noCache, compositionRefresh });
16279
16265
  const composition = await resolveComposition({
16280
16266
  db,
@@ -16290,12 +16276,13 @@ async function runExtractAndComposeSession(request) {
16290
16276
  onProgress,
16291
16277
  onDebugEvent
16292
16278
  });
16293
- await retryDatabaseWrite(() => storeRawComponents(db, sessionId, composition.components, { preserveStatus: true }));
16294
- await persistSlotCycles(db, sessionId, composition.components);
16295
- storeScannedFiles(db, sessionId, sourceFiles.map((f) => relative2(projectPath, f)));
16296
- await retryDatabaseWrite(() => updateStep(db, stepId, "complete", { sessionId }));
16279
+ await retryDatabaseWrite(() => storeRawComponents(db, sessionId2, composition.components, { preserveStatus: true }));
16280
+ await persistSlotCycles(db, sessionId2, composition.components);
16281
+ storeScannedFiles(db, sessionId2, sourceFiles.map((f) => relative2(projectPath, f)));
16282
+ await retryDatabaseWrite(() => updateStep(db, stepId, "complete", { sessionId: sessionId2 }));
16283
+ enrichCommandResult({ extracted_component_count: composition.components.length });
16297
16284
  return {
16298
- sessionId,
16285
+ sessionId: sessionId2,
16299
16286
  compositionPhase: composition.phase,
16300
16287
  components: composition.components,
16301
16288
  warnings: [...extraction.warnings, ...filterWarnings],
@@ -16322,11 +16309,11 @@ init_resolve_prompt_override();
16322
16309
  // packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-tokens-session/helpers/write-tokens-file.js
16323
16310
  import { mkdir as mkdir5, writeFile as writeFile5 } from "node:fs/promises";
16324
16311
  import { join as join15 } from "node:path";
16325
- async function writeTokensFile(db, sessionId, outDir, onProgress) {
16312
+ async function writeTokensFile(db, sessionId2, outDir, onProgress) {
16326
16313
  onProgress?.({ kind: "writing-file" });
16327
- const result = getDtcgTokensForSession(db, sessionId);
16314
+ const result = getDtcgTokensForSession(db, sessionId2);
16328
16315
  if (result.tokens.length === 0) {
16329
- throw new Error(`generate tokens: no tokens persisted for session ${sessionId}`);
16316
+ throw new Error(`generate tokens: no tokens persisted for session ${sessionId2}`);
16330
16317
  }
16331
16318
  const tree = rebuildDTCGTree(result.groups, result.tokens);
16332
16319
  const tokensPath = join15(outDir, "tokens.json");
@@ -16356,6 +16343,7 @@ async function runGenerateTokensSession(request) {
16356
16343
  outDir
16357
16344
  });
16358
16345
  await onSessionCreated?.(tokenSessionId);
16346
+ await bindAnalyticsSessionId(tokenSessionId);
16359
16347
  const tokenPromptHash = await hashPromptForSkill("tokens", agent, agentModel, skillPath);
16360
16348
  const warnings = [];
16361
16349
  onProgress?.({ kind: "resolving" });
@@ -16419,9 +16407,9 @@ init_create_local_cli_agent_invoker();
16419
16407
  init_cache_keys();
16420
16408
 
16421
16409
  // packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/build-empty-session-response.js
16422
- function buildEmptySessionResponse(sessionId) {
16410
+ function buildEmptySessionResponse(sessionId2) {
16423
16411
  return {
16424
- sessionId,
16412
+ sessionId: sessionId2,
16425
16413
  results: [],
16426
16414
  allOk: true,
16427
16415
  renamedSlotsCount: 0,
@@ -16443,11 +16431,11 @@ function collectDuplicateNames(components) {
16443
16431
  }
16444
16432
 
16445
16433
  // packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/filter-dropped-allowed-components.js
16446
- function filterDroppedAllowedComponents(db, sessionId, components, allowedComponentNames2, acceptedNames) {
16447
- const dropped = filterUnknownSlotAllowedComponents(db, sessionId, allowedComponentNames2);
16434
+ function filterDroppedAllowedComponents(db, sessionId2, components, allowedComponentNames2, acceptedNames) {
16435
+ const dropped = filterUnknownSlotAllowedComponents(db, sessionId2, allowedComponentNames2);
16448
16436
  if (dropped.length === 0)
16449
16437
  return { components, dropped: [] };
16450
- return { components: loadRawComponents(db, sessionId, acceptedNames), dropped };
16438
+ return { components: loadRawComponents(db, sessionId2, acceptedNames), dropped };
16451
16439
  }
16452
16440
 
16453
16441
  // packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/read-existing-entities.js
@@ -16515,8 +16503,8 @@ function buildFailedComponentResult(componentName, error, renamedSlotsCount) {
16515
16503
  var DEFAULT_TIMEOUT_MS4 = Number(process.env["EDS_AGENT_TIMEOUT_MS"] ?? 5 * 60 * 1e3);
16516
16504
  var RETRY_BACKOFF_MS = Number(process.env["EDS_RETRY_BACKOFF_MS"] ?? 5e3);
16517
16505
  async function runOneGenerateComponent(options, component, index, total) {
16518
- const { db, sessionId, invoker, agent, model, tokensInline, tokenMapInline, verbose, noCache, skillPathOverride, skillContentOverride, promptHash, existingContentfulEntities, existingTokensInline, precomputedCachedNames, allowedComponentNames: allowedComponentNames2, onProgress } = options;
16519
- const { renames } = renameEmptySlots(db, sessionId, component.component_id, component.name, component.slots.length);
16506
+ const { db, sessionId: sessionId2, invoker, agent, model, tokensInline, tokenMapInline, verbose, noCache, skillPathOverride, skillContentOverride, promptHash, existingContentfulEntities, existingTokensInline, precomputedCachedNames, allowedComponentNames: allowedComponentNames2, onProgress } = options;
16507
+ const { renames } = renameEmptySlots(db, sessionId2, component.component_id, component.name, component.slots.length);
16520
16508
  let effectiveSlots = component.slots;
16521
16509
  if (renames.length > 0) {
16522
16510
  const renameMap = new Map(renames.map((r) => [r.oldName, r.newName]));
@@ -16539,7 +16527,7 @@ async function runOneGenerateComponent(options, component, index, total) {
16539
16527
  if (!noCache) {
16540
16528
  const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
16541
16529
  if (resolution && !resolution.humanEdited) {
16542
- copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId, component.component_id, true, {
16530
+ copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId2, component.component_id, true, {
16543
16531
  allowedComponentNames: allowedComponentNames2
16544
16532
  });
16545
16533
  storeCache(db, hashComponentShape(cacheComponent), "component", component.component_id, resolution.entry.sourceSessionId, resolution.entry.humanEdited, promptHash);
@@ -16547,7 +16535,7 @@ async function runOneGenerateComponent(options, component, index, total) {
16547
16535
  return buildCachedComponentResult(component.name);
16548
16536
  }
16549
16537
  if (resolution?.humanEdited) {
16550
- copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId, component.component_id, true, {
16538
+ copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId2, component.component_id, true, {
16551
16539
  allowedComponentNames: allowedComponentNames2
16552
16540
  });
16553
16541
  onProgress?.({ kind: "component:cached", index, total, name: component.name, pinned: true });
@@ -16603,11 +16591,11 @@ async function runOneGenerateComponent(options, component, index, total) {
16603
16591
  lastError = describeAgentFailure(result);
16604
16592
  continue;
16605
16593
  }
16606
- const applied = applyToolCalls(db, sessionId, component.component_id, component.name, calls, warnings, {
16594
+ const applied = applyToolCalls(db, sessionId2, component.component_id, component.name, calls, warnings, {
16607
16595
  allowedComponentNames: allowedComponentNames2
16608
16596
  });
16609
16597
  if (!noCache) {
16610
- storeCache(db, hashComponentShape(cacheComponent), "component", component.component_id, sessionId, false, promptHash);
16598
+ storeCache(db, hashComponentShape(cacheComponent), "component", component.component_id, sessionId2, false, promptHash);
16611
16599
  }
16612
16600
  onProgress?.({
16613
16601
  kind: "component:completed",
@@ -16652,18 +16640,18 @@ async function runWithPool(items, concurrency, worker) {
16652
16640
  init_cache_keys();
16653
16641
 
16654
16642
  // packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/restore-cached-components.js
16655
- async function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, allowedComponentNames2) {
16643
+ async function restoreCachedComponents(db, sessionId2, cachedComponents, promptHash, allowedComponentNames2) {
16656
16644
  const restorations = [];
16657
16645
  const rekeyed = [];
16658
16646
  const componentStatus = db.prepare("SELECT status FROM raw_components WHERE session_id = ? AND component_id = ?");
16659
16647
  for (const { component, resolution } of cachedComponents) {
16660
- const current = componentStatus.get(sessionId, component.component_id);
16648
+ const current = componentStatus.get(sessionId2, component.component_id);
16661
16649
  if (current?.status === "generated")
16662
16650
  continue;
16663
- renameEmptySlots(db, sessionId, component.component_id, component.name, component.slots.length);
16651
+ renameEmptySlots(db, sessionId2, component.component_id, component.name, component.slots.length);
16664
16652
  restorations.push({
16665
16653
  sourceSessionId: resolution.entry.sourceSessionId,
16666
- targetSessionId: sessionId,
16654
+ targetSessionId: sessionId2,
16667
16655
  componentId: component.component_id
16668
16656
  });
16669
16657
  rekeyed.push({ component, cached: resolution.entry });
@@ -16732,6 +16720,7 @@ async function runGenerateComponentsSession(request) {
16732
16720
  const existingTokensHash = existingTokensInline ? [hashContent(existingTokensInline)] : [];
16733
16721
  const agent = request.agent;
16734
16722
  const promptHash = await hashPromptForSkill("components", agent, request.agentModel, effectiveSkillPath, existingTokensHash, prompt.text);
16723
+ await bindAnalyticsSessionId(request.sessionId);
16735
16724
  const db = openPipelineDb();
16736
16725
  try {
16737
16726
  const acceptedNames = await loadAcceptedNames(request.sessionId);
@@ -16931,7 +16920,6 @@ function useCredentialsControls(handlers) {
16931
16920
  }
16932
16921
 
16933
16922
  // packages/experience-design-system-cli/src/tui/user-agent.ts
16934
- init_version();
16935
16923
  function cliUserAgent() {
16936
16924
  return buildUserAgent(readPackageVersion());
16937
16925
  }
@@ -17431,8 +17419,34 @@ function ExtractionScreen({
17431
17419
  );
17432
17420
  }
17433
17421
 
17434
- // packages/experience-design-system-cli/app.tsx
17435
- init_config();
17422
+ // packages/experience-design-system-types/dist/src/config/index.js
17423
+ import { randomBytes as randomBytes4 } from "node:crypto";
17424
+ import { mkdir as mkdir6, readFile as readFile18, rename as rename2, writeFile as writeFile6 } from "node:fs/promises";
17425
+ import { homedir as homedir3 } from "node:os";
17426
+ import { dirname as dirname13, join as join17 } from "node:path";
17427
+ function configRoot2() {
17428
+ return process.env["EDS_HOME"] || join17(homedir3(), ".contentful", "experience-design-system-cli");
17429
+ }
17430
+ var configFilePath2 = () => join17(configRoot2(), "config.json");
17431
+ var debugSessionsDir2 = () => join17(configRoot2(), "debug", "sessions");
17432
+ async function readSettings2() {
17433
+ try {
17434
+ return JSON.parse(await readFile18(configFilePath2(), "utf8"));
17435
+ } catch {
17436
+ return {};
17437
+ }
17438
+ }
17439
+ async function writeSettings2(settings) {
17440
+ const path5 = configFilePath2();
17441
+ await mkdir6(dirname13(path5), { recursive: true });
17442
+ const tmp = `${path5}.${process.pid}.${randomBytes4(4).toString("hex")}.tmp`;
17443
+ await writeFile6(tmp, `${JSON.stringify(settings, null, 2)}
17444
+ `, { mode: 384 });
17445
+ await rename2(tmp, path5);
17446
+ }
17447
+ async function updateSettings2(patch) {
17448
+ await writeSettings2({ ...await readSettings2(), ...patch });
17449
+ }
17436
17450
 
17437
17451
  // packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
17438
17452
  import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
@@ -17471,13 +17485,13 @@ async function runSelection(options) {
17471
17485
  const db = openPipelineDb();
17472
17486
  let components;
17473
17487
  const cachedDecisions = /* @__PURE__ */ new Map();
17474
- const cliVersion = await getCliCacheVersion();
17488
+ const cliVersion2 = await getCliCacheVersion();
17475
17489
  const promptHash = await hashSelectPrompt(options);
17476
17490
  try {
17477
17491
  components = loadRawComponents(db, options.sessionId);
17478
17492
  if (!options.noCache) {
17479
17493
  for (const component of components) {
17480
- const cached = lookupSelectCache(db, hashComponentShape(component), promptHash, cliVersion);
17494
+ const cached = lookupSelectCache(db, hashComponentShape(component), promptHash, cliVersion2);
17481
17495
  if (cached) cachedDecisions.set(component.name, { decision: cached.decision, reason: cached.reason });
17482
17496
  }
17483
17497
  }
@@ -17532,7 +17546,7 @@ async function runSelection(options) {
17532
17546
  writeDb,
17533
17547
  hashComponentShape(component),
17534
17548
  promptHash,
17535
- cliVersion,
17549
+ cliVersion2,
17536
17550
  rejected ? "rejected" : "accepted",
17537
17551
  rejected ? reason : null
17538
17552
  );
@@ -17613,12 +17627,12 @@ async function runExtraction(input, onProgress, deps = realDeps) {
17613
17627
  }) : null;
17614
17628
  let selection = null;
17615
17629
  let selectionError;
17616
- const startSelection = (sessionId) => {
17630
+ const startSelection = (sessionId2) => {
17617
17631
  if (selection) return;
17618
17632
  selection = (async () => {
17619
17633
  if (entities) await entities;
17620
17634
  await deps.runSelection({
17621
- sessionId,
17635
+ sessionId: sessionId2,
17622
17636
  agent: input.agent,
17623
17637
  model: input.agentModel,
17624
17638
  ...selectionPrompt,
@@ -17639,7 +17653,7 @@ async function runExtraction(input, onProgress, deps = realDeps) {
17639
17653
  promptOverrides: input.promptOverrides,
17640
17654
  noCache: input.noCache,
17641
17655
  onProgress: (event) => update(applyProgressEvent(progress, event)),
17642
- onSessionCreated: (sessionId) => startSelection(sessionId)
17656
+ onSessionCreated: (sessionId2) => startSelection(sessionId2)
17643
17657
  });
17644
17658
  } catch (error) {
17645
17659
  return fail("analyze extract", errorMessage2(error));
@@ -17708,7 +17722,6 @@ function useExtraction(input) {
17708
17722
  reuseTokens: input.tokenStrategy === "reuse"
17709
17723
  })
17710
17724
  });
17711
- void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then((store) => store.startDebugSessionIn(input.projectPath));
17712
17725
  void runExtraction(input, (progress) => {
17713
17726
  if (current.current === input) setState({ status: "running", progress });
17714
17727
  }).then((result) => {
@@ -17981,11 +17994,11 @@ function CyclesPanel({ cycles, cursor }) {
17981
17994
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/panels/reject-prompt.tsx
17982
17995
  import { Box as Box13, Text as Text14 } from "ink";
17983
17996
  import { jsx as jsx16, jsxs as jsxs13 } from "react/jsx-runtime";
17984
- function RejectPrompt({ pending }) {
17997
+ function RejectPrompt({ pending: pending2 }) {
17985
17998
  return /* @__PURE__ */ jsxs13(Box13, { flexDirection: "column", borderStyle: "single", borderColor: PALETTE2.warning, paddingX: 1, marginTop: 1, children: [
17986
- /* @__PURE__ */ jsx16(Text14, { bold: true, color: PALETTE2.warning, children: `Rejecting ${pending.target} will:` }),
17987
- pending.ancestors.length > 0 && /* @__PURE__ */ jsx16(Text14, { children: `- Reject ancestors: ${pending.ancestors.join(", ")}` }),
17988
- pending.descendants.length > 0 && /* @__PURE__ */ jsx16(Text14, { children: `- Deselect descendants: ${pending.descendants.join(", ")}` }),
17999
+ /* @__PURE__ */ jsx16(Text14, { bold: true, color: PALETTE2.warning, children: `Rejecting ${pending2.target} will:` }),
18000
+ pending2.ancestors.length > 0 && /* @__PURE__ */ jsx16(Text14, { children: `- Reject ancestors: ${pending2.ancestors.join(", ")}` }),
18001
+ pending2.descendants.length > 0 && /* @__PURE__ */ jsx16(Text14, { children: `- Deselect descendants: ${pending2.descendants.join(", ")}` }),
17989
18002
  /* @__PURE__ */ jsx16(Text14, { children: "[y] confirm \xB7 [n]/[Esc] cancel" })
17990
18003
  ] });
17991
18004
  }
@@ -20494,11 +20507,11 @@ async function checkGenerationCache(input) {
20494
20507
  }
20495
20508
 
20496
20509
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/load.ts
20497
- function loadScopeGate(sessionId) {
20510
+ function loadScopeGate(sessionId2) {
20498
20511
  try {
20499
20512
  const db = openPipelineDb();
20500
20513
  try {
20501
- const components = loadScopeComponents(db, sessionId);
20514
+ const components = loadScopeComponents(db, sessionId2);
20502
20515
  if (components.length === 0) {
20503
20516
  return { ok: false, message: "No components found for this session. Please run the import again." };
20504
20517
  }
@@ -20517,8 +20530,8 @@ function loadScopeGate(sessionId) {
20517
20530
  // packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
20518
20531
  var realDeps2 = { load: loadScopeGate, checkCache: checkGenerationCache };
20519
20532
  function useScopeGateFlow(input, deps = realDeps2) {
20520
- const sessionId = input?.sessionId;
20521
- const loaded = useMemo3(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
20533
+ const sessionId2 = input?.sessionId;
20534
+ const loaded = useMemo3(() => sessionId2 ? deps.load(sessionId2) : void 0, [sessionId2]);
20522
20535
  const cacheCheck = useRef5(void 0);
20523
20536
  const [confirmed, setConfirmed] = useState13();
20524
20537
  useEffect8(() => {
@@ -20595,7 +20608,7 @@ function GenerationScreen({
20595
20608
  import { useEffect as useEffect9, useRef as useRef6, useState as useState14 } from "react";
20596
20609
 
20597
20610
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
20598
- import { resolve as resolve24 } from "node:path";
20611
+ import { resolve as resolve23 } from "node:path";
20599
20612
 
20600
20613
  // packages/experience-design-system-cli/src/tui/import/steps/08-generation/map-tokens.ts
20601
20614
  async function prepareMapTokens(input, generatedSessionId) {
@@ -20695,7 +20708,7 @@ async function runGeneration(input, onProgress, deps = realDeps3) {
20695
20708
  update({ mapTokens: "running" });
20696
20709
  try {
20697
20710
  const mapTokensOptions = await buildMapTokensOptions(input);
20698
- await deps.runMapTokens({
20711
+ const mapResult = await deps.runMapTokens({
20699
20712
  sessionId: input.sessionId,
20700
20713
  agent: input.agent,
20701
20714
  ...input.agentModel ? { model: input.agentModel } : {},
@@ -20703,6 +20716,11 @@ async function runGeneration(input, onProgress, deps = realDeps3) {
20703
20716
  skillPathOverride: MAP_TOKENS_SKILL_PATH,
20704
20717
  ...mapTokensOptions
20705
20718
  });
20719
+ if (mapResult.diagnostics.length > 0) {
20720
+ process.stderr.write(`Unresolved token defaults:
20721
+ ${mapResult.diagnostics.map((d) => ` ${d}`).join("\n")}
20722
+ `);
20723
+ }
20706
20724
  } catch (error) {
20707
20725
  const message = error instanceof MapTokensRunFailure ? error.message : error instanceof Error ? error.message : String(error);
20708
20726
  return fail2("map tokens", message);
@@ -20730,7 +20748,7 @@ async function buildMapTokensOptions(input) {
20730
20748
  if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
20731
20749
  if (mapOverride?.kind === "path") {
20732
20750
  await resolvePromptOverride(mapOverride);
20733
- prompt.skillPathOverride = resolve24(mapOverride.value);
20751
+ prompt.skillPathOverride = resolve23(mapOverride.value);
20734
20752
  }
20735
20753
  if (input.existingEntitiesPath) {
20736
20754
  const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
@@ -20778,7 +20796,7 @@ function useGeneration(input) {
20778
20796
  }
20779
20797
 
20780
20798
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
20781
- import { join as join21 } from "node:path";
20799
+ import { join as join20 } from "node:path";
20782
20800
  function buildFlowStart(input) {
20783
20801
  const { extraction, handoff, saved, generatePromptPath } = input;
20784
20802
  const credentials = extraction.credentials ?? {
@@ -20791,7 +20809,7 @@ function buildFlowStart(input) {
20791
20809
  handoff,
20792
20810
  agent: extraction.agent,
20793
20811
  projectPath: extraction.projectPath,
20794
- outDir: extraction.projectPath ? join21(extraction.projectPath, ".contentful") : "",
20812
+ outDir: extraction.projectPath ? join20(extraction.projectPath, ".contentful") : "",
20795
20813
  rawTokensPath: extraction.rawTokensPath,
20796
20814
  credentials: {
20797
20815
  spaceId: credentials.spaceId,
@@ -24051,17 +24069,17 @@ var TimeoutError = class extends Error {
24051
24069
  };
24052
24070
  var DEFAULT_TIMEOUT_MS6 = 15e3;
24053
24071
  async function runLivePreview(opts) {
24054
- const { sessionId, tokensPath, spaceId, environmentId, cmaToken, host, generation } = opts;
24072
+ const { sessionId: sessionId2, tokensPath, spaceId, environmentId, cmaToken, host, generation } = opts;
24055
24073
  const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS6;
24056
24074
  if (!spaceId || !environmentId || !cmaToken) {
24057
24075
  return { generation, response: null };
24058
24076
  }
24059
24077
  let components = [];
24060
- if (sessionId) {
24078
+ if (sessionId2) {
24061
24079
  const db = openPipelineDb();
24062
24080
  try {
24063
- backfillUnclassifiedProps(db, sessionId);
24064
- components = loadCDFComponents(db, sessionId);
24081
+ backfillUnclassifiedProps(db, sessionId2);
24082
+ components = loadCDFComponents(db, sessionId2);
24065
24083
  } finally {
24066
24084
  db.close();
24067
24085
  }
@@ -24978,7 +24996,7 @@ function useReviewPreview({
24978
24996
  components,
24979
24997
  loading,
24980
24998
  livePreview,
24981
- sessionId,
24999
+ sessionId: sessionId2,
24982
25000
  tokensPath,
24983
25001
  spaceId,
24984
25002
  environmentId,
@@ -25005,7 +25023,7 @@ function useReviewPreview({
25005
25023
  );
25006
25024
  const livePreviewHook = useLivePreview({
25007
25025
  enabled: livePreview,
25008
- sessionId,
25026
+ sessionId: sessionId2,
25009
25027
  tokensPath,
25010
25028
  spaceId,
25011
25029
  environmentId,
@@ -25293,7 +25311,7 @@ function GenerateReviewStepView({
25293
25311
  () => loadReviewSessionState({
25294
25312
  extractSessionId,
25295
25313
  tokenSessionId,
25296
- loadExtra: (db, sessionId) => loadSlotCycles(db, sessionId),
25314
+ loadExtra: (db, sessionId2) => loadSlotCycles(db, sessionId2),
25297
25315
  sortEntries: (entries, cycles) => {
25298
25316
  const cycleParticipants = /* @__PURE__ */ new Set();
25299
25317
  for (const cycle of cycles ?? []) {
@@ -26534,11 +26552,11 @@ function DoneStep({
26534
26552
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/PathPrompt.tsx
26535
26553
  import { useState as useState24 } from "react";
26536
26554
  import { Box as Box37, Text as Text40 } from "ink";
26537
- import { readdirSync as readdirSync4 } from "node:fs";
26538
- import { dirname as dirname15, basename as basename6, join as join22 } from "node:path";
26555
+ import { readdirSync as readdirSync3 } from "node:fs";
26556
+ import { dirname as dirname15, basename as basename6, join as join21 } from "node:path";
26539
26557
 
26540
26558
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
26541
- import { resolve as resolve25 } from "node:path";
26559
+ import { resolve as resolve24 } from "node:path";
26542
26560
  import { homedir as homedir4 } from "node:os";
26543
26561
  function expandTilde(input) {
26544
26562
  if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
@@ -26552,7 +26570,7 @@ function normalizePath(input) {
26552
26570
  p = p.slice(1, -1);
26553
26571
  }
26554
26572
  p = expandTilde(p);
26555
- return resolve25(p);
26573
+ return resolve24(p);
26556
26574
  }
26557
26575
 
26558
26576
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
@@ -26575,19 +26593,19 @@ function autocomplete(partial) {
26575
26593
  const base = basename6(normalized);
26576
26594
  let entries;
26577
26595
  try {
26578
- entries = readdirSync4(dir);
26596
+ entries = readdirSync3(dir);
26579
26597
  } catch {
26580
26598
  return null;
26581
26599
  }
26582
26600
  const matches = entries.filter((e) => e.startsWith(base));
26583
26601
  if (matches.length === 0) return null;
26584
- if (matches.length === 1) return join22(dir, matches[0]);
26602
+ if (matches.length === 1) return join21(dir, matches[0]);
26585
26603
  let prefix = matches[0];
26586
26604
  for (const m of matches) {
26587
26605
  while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
26588
26606
  if (!prefix) break;
26589
26607
  }
26590
- return prefix.length > base.length ? join22(dir, prefix) : null;
26608
+ return prefix.length > base.length ? join21(dir, prefix) : null;
26591
26609
  }
26592
26610
  function PathPrompt({
26593
26611
  defaultPath,
@@ -27346,9 +27364,9 @@ import { useEffect as useEffect21, useRef as useRef13, useSyncExternalStore } fr
27346
27364
 
27347
27365
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
27348
27366
  import { appendFileSync, writeFileSync } from "node:fs";
27349
- import { mkdir as mkdir9 } from "node:fs/promises";
27367
+ import { mkdir as mkdir8 } from "node:fs/promises";
27350
27368
  import { tmpdir } from "node:os";
27351
- import { join as join24 } from "node:path";
27369
+ import { join as join23 } from "node:path";
27352
27370
 
27353
27371
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/wizard-state-transitions.ts
27354
27372
  function shouldBypassPreview(state) {
@@ -27692,8 +27710,8 @@ function pushFailure(e, deps) {
27692
27710
  }
27693
27711
 
27694
27712
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
27695
- import { writeFile as writeFile8 } from "node:fs/promises";
27696
- import { join as join23 } from "node:path";
27713
+ import { writeFile as writeFile7 } from "node:fs/promises";
27714
+ import { join as join22 } from "node:path";
27697
27715
 
27698
27716
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/run-print-files-helpers.ts
27699
27717
  function nextStateAfterPrint(opts) {
@@ -27716,15 +27734,15 @@ function buildSavedCDF(components, tokens, opts = {}) {
27716
27734
  var realSaveDeps = () => ({
27717
27735
  openDb: openPipelineDb,
27718
27736
  readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
27719
- writeFile: (path5, contents) => writeFile8(path5, contents),
27737
+ writeFile: (path5, contents) => writeFile7(path5, contents),
27720
27738
  appendRun,
27721
27739
  buildSourceFingerprint,
27722
- sleep: (ms) => new Promise((resolve26) => setTimeout(resolve26, ms)),
27740
+ sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
27723
27741
  warn: (message) => process.stderr.write(message)
27724
27742
  });
27725
27743
  async function runPrintFiles(input, deps, onPatch) {
27726
27744
  onPatch({ step: "printing" });
27727
- const componentsPath = join23(input.outDir, "components.json");
27745
+ const componentsPath = join22(input.outDir, "components.json");
27728
27746
  try {
27729
27747
  const db = deps.openDb();
27730
27748
  let components = [];
@@ -27805,7 +27823,7 @@ var EMPTY_PUSH_RESULT = {
27805
27823
  };
27806
27824
 
27807
27825
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
27808
- var WIZARD_LOG = join24(tmpdir(), "experiences-import-wizard.log");
27826
+ var WIZARD_LOG = join23(tmpdir(), "experiences-import-wizard.log");
27809
27827
  function appendWizardLog(entry) {
27810
27828
  appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
27811
27829
  }
@@ -27819,16 +27837,16 @@ function realFlowDeps() {
27819
27837
  preview: realPreviewDeps(),
27820
27838
  push: realPushDeps(log),
27821
27839
  save: realSaveDeps(),
27822
- loadAcceptedComponents: (sessionId) => {
27840
+ loadAcceptedComponents: (sessionId2) => {
27823
27841
  const db = openPipelineDb();
27824
27842
  try {
27825
- return loadCDFComponents(db, sessionId);
27843
+ return loadCDFComponents(db, sessionId2);
27826
27844
  } finally {
27827
27845
  db.close();
27828
27846
  }
27829
27847
  },
27830
27848
  mkdir: async (path5) => {
27831
- await mkdir9(path5, { recursive: true });
27849
+ await mkdir8(path5, { recursive: true });
27832
27850
  },
27833
27851
  detectSaveConflict,
27834
27852
  buildTimestampedSubdir,
@@ -28092,19 +28110,171 @@ function useFlow(start, deps = realFlowDeps) {
28092
28110
  // packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
28093
28111
  import { useEffect as useEffect22, useState as useState27 } from "react";
28094
28112
  import { Box as Box42, Text as Text44, useInput as useInput9 } from "ink";
28095
- init_debug_store();
28113
+
28114
+ // packages/experience-design-system-cli/src/tui/debug-store.ts
28115
+ import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
28116
+ import { existsSync as existsSync9, readdirSync as readdirSync4 } from "node:fs";
28117
+ import { join as join24 } from "node:path";
28118
+
28119
+ // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
28120
+ var DEFAULT_DEBUG_MODE_SETTING = {
28121
+ enabled: true
28122
+ };
28123
+ async function readDebugModeSetting() {
28124
+ const { debugMode } = await readSettings2();
28125
+ return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
28126
+ }
28127
+ async function writeDebugModeSetting(setting) {
28128
+ await updateSettings2({ debugMode: setting });
28129
+ }
28130
+
28131
+ // packages/experience-design-system-cli/src/tui/debug-store.ts
28132
+ var pendingRun;
28133
+ function generateRunId() {
28134
+ const now = /* @__PURE__ */ new Date();
28135
+ const pad = (n) => String(n).padStart(2, "0");
28136
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
28137
+ }
28138
+ function datePrefix(now = /* @__PURE__ */ new Date()) {
28139
+ const pad = (n) => String(n).padStart(2, "0");
28140
+ return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
28141
+ }
28142
+ function slugify(value) {
28143
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
28144
+ }
28145
+ function generateSessionId3() {
28146
+ const today = datePrefix();
28147
+ const root = debugSessionsDir2();
28148
+ const existing = existsSync9(root) ? readdirSync4(root) : [];
28149
+ const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
28150
+ const maxSeq = existing.reduce((max, entry) => {
28151
+ const match2 = seqPattern.exec(entry);
28152
+ return match2 ? Math.max(max, Number(match2[1])) : max;
28153
+ }, 0);
28154
+ return `${today}-session-${maxSeq + 1}`;
28155
+ }
28156
+ var SESSION_ID = generateSessionId3();
28157
+ function sessionDebugDir() {
28158
+ return join24(debugSessionsDir2(), SESSION_ID);
28159
+ }
28160
+ function currentDebugSessionDir() {
28161
+ return sessionDebugDir();
28162
+ }
28163
+ void isDebugModeEnabled().then((enabled) => {
28164
+ if (!enabled) return void 0;
28165
+ return mkdir9(sessionDebugDir(), { recursive: true });
28166
+ });
28167
+ async function isDebugModeEnabled() {
28168
+ try {
28169
+ return (await readDebugModeSetting()).enabled;
28170
+ } catch {
28171
+ return true;
28172
+ }
28173
+ }
28174
+ function redact(value) {
28175
+ const clone = { ...value };
28176
+ if ("cma_token" in clone) {
28177
+ const raw = clone.cma_token;
28178
+ clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
28179
+ }
28180
+ return clone;
28181
+ }
28182
+ function startDebugRun({
28183
+ flow,
28184
+ step,
28185
+ menuOption,
28186
+ inputs
28187
+ }) {
28188
+ const runId = generateRunId();
28189
+ const startedAt = Date.now();
28190
+ const redactedInputs = redact(inputs);
28191
+ isDebugModeEnabled().then((enabled) => {
28192
+ if (!enabled) return;
28193
+ pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
28194
+ });
28195
+ }
28196
+ async function finishDebugRun({
28197
+ outputs,
28198
+ status,
28199
+ exitMethod
28200
+ }) {
28201
+ const run = pendingRun;
28202
+ if (!run) return;
28203
+ pendingRun = void 0;
28204
+ const durationMs = Date.now() - run.startedAt;
28205
+ const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
28206
+ const flowSegments = run.flow.split("/");
28207
+ const dir = join24(sessionDebugDir(), ...flowSegments);
28208
+ await mkdir9(dir, { recursive: true });
28209
+ const filename = nextAttemptFilename(dir, run.menuOption);
28210
+ await writeFile8(join24(dir, filename), content, { mode: 384 });
28211
+ }
28212
+ function nextAttemptFilename(dir, menuOption) {
28213
+ const today = datePrefix();
28214
+ const optionSlug = slugify(menuOption);
28215
+ const existing = existsSync9(dir) ? readdirSync4(dir) : [];
28216
+ const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
28217
+ const maxAttempt = existing.reduce((max, entry) => {
28218
+ const match2 = attemptPattern.exec(entry);
28219
+ return match2 ? Math.max(max, Number(match2[1])) : max;
28220
+ }, 0);
28221
+ return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
28222
+ }
28223
+ function renderMarkdown(run, finish) {
28224
+ const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
28225
+ const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
28226
+ const flowSlug = run.flow.split("/").join("-");
28227
+ return `# Debug Log
28228
+
28229
+ - Run ID: ${run.runId}
28230
+ - Flow: ${flowSlug}
28231
+ - Step: ${stepLabel2}
28232
+ - Menu option: ${run.menuOption}
28233
+ - Date: ${(/* @__PURE__ */ new Date()).toISOString()}
28234
+ - CLI version: ${readPackageVersion()}
28235
+ - Platform: ${process.platform} / Node ${process.version}
28236
+ - Duration on screen: ${finish.durationMs}ms
28237
+ - Status: ${finish.status}
28238
+ - Exit method: ${finish.exitMethod}
28239
+
28240
+ ## Inputs
28241
+ \`\`\`json
28242
+ ${JSON.stringify(run.inputs, null, 2)}
28243
+ \`\`\`
28244
+
28245
+ ## Outputs
28246
+ \`\`\`json
28247
+ ${JSON.stringify(finish.outputs, null, 2)}
28248
+ \`\`\`
28249
+ `;
28250
+ }
28251
+ function handleCrash() {
28252
+ return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
28253
+ }
28254
+ process.once("uncaughtException", (err) => {
28255
+ void handleCrash().finally(() => {
28256
+ throw err;
28257
+ });
28258
+ });
28259
+ process.once("unhandledRejection", (reason) => {
28260
+ void handleCrash().finally(() => {
28261
+ throw reason;
28262
+ });
28263
+ });
28264
+ process.once("SIGINT", () => {
28265
+ void handleCrash().finally(() => {
28266
+ process.exit(130);
28267
+ });
28268
+ });
28096
28269
 
28097
28270
  // packages/experience-design-system-cli/src/tui/help/help-info.ts
28098
- init_config();
28099
- init_debug_store();
28100
- init_debug_mode_store();
28101
- init_version();
28102
28271
  async function readHelpInfo() {
28103
28272
  const debugMode = await readDebugModeSetting();
28104
28273
  return {
28105
28274
  storage: [
28106
28275
  { label: "Config folder", value: configRoot2() },
28107
- { label: "Settings file", value: configFilePath2() }
28276
+ { label: "Settings file", value: configFilePath2() },
28277
+ { label: "Debug logs", value: debugSessionsDir2() }
28108
28278
  ],
28109
28279
  troubleshooting: [
28110
28280
  { label: "CLI version", value: readPackageVersion() },
@@ -28113,7 +28283,7 @@ async function readHelpInfo() {
28113
28283
  { label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
28114
28284
  {
28115
28285
  label: "This session",
28116
- value: !debugMode.enabled ? "no logs written while Debug Mode is off" : currentDebugSessionDir() ?? "not started: set the default project directory in Settings, or start an import"
28286
+ value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
28117
28287
  }
28118
28288
  ]
28119
28289
  };
@@ -28230,7 +28400,6 @@ import { Box as Box44, Text as Text46, useInput as useInput11 } from "ink";
28230
28400
  import TextInput4 from "ink-text-input";
28231
28401
 
28232
28402
  // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
28233
- init_config();
28234
28403
  var readV1Store = readSettings2;
28235
28404
  var writeV1Store = writeSettings2;
28236
28405
 
@@ -28243,8 +28412,7 @@ async function readCredentials() {
28243
28412
  cmaToken: store.cmaToken || "",
28244
28413
  host: store.host || "",
28245
28414
  defaultComponentDir: store.defaultComponentDir || "",
28246
- defaultTokenFile: store.defaultTokenFile || "",
28247
- contentfulBaseDir: store.contentfulBaseDir || ""
28415
+ defaultTokenFile: store.defaultTokenFile || ""
28248
28416
  };
28249
28417
  }
28250
28418
  async function writeCredentials(config) {
@@ -28260,7 +28428,6 @@ async function writeCredentials(config) {
28260
28428
  }
28261
28429
 
28262
28430
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/ContentfulConfigScreen.tsx
28263
- init_debug_store();
28264
28431
  import { Fragment as Fragment17, jsx as jsx55, jsxs as jsxs45 } from "react/jsx-runtime";
28265
28432
  var FIELD_ORDER = [
28266
28433
  "spaceId",
@@ -28268,8 +28435,7 @@ var FIELD_ORDER = [
28268
28435
  "cmaToken",
28269
28436
  "host",
28270
28437
  "defaultComponentDir",
28271
- "defaultTokenFile",
28272
- "contentfulBaseDir"
28438
+ "defaultTokenFile"
28273
28439
  ];
28274
28440
  function debugFields(config) {
28275
28441
  return {
@@ -28278,8 +28444,7 @@ function debugFields(config) {
28278
28444
  cma_token: config?.cmaToken ?? "",
28279
28445
  host: config?.host ?? "",
28280
28446
  default_component_dir: config?.defaultComponentDir ?? "",
28281
- default_token_file: config?.defaultTokenFile ?? "",
28282
- contentful_base_dir: config?.contentfulBaseDir ?? ""
28447
+ default_token_file: config?.defaultTokenFile ?? ""
28283
28448
  };
28284
28449
  }
28285
28450
  var FIELD_LABELS = {
@@ -28288,8 +28453,7 @@ var FIELD_LABELS = {
28288
28453
  cmaToken: "CMA Token",
28289
28454
  host: "API Host (optional)",
28290
28455
  defaultComponentDir: "Default component directory (optional)",
28291
- defaultTokenFile: "Default token file (optional)",
28292
- contentfulBaseDir: "Default project directory, where .contentful goes (optional)"
28456
+ defaultTokenFile: "Default token file (optional)"
28293
28457
  };
28294
28458
  function ConfigurationScreen({ onDone }) {
28295
28459
  const [stage, setStage] = useState29("loading");
@@ -28326,7 +28490,6 @@ function ConfigurationScreen({ onDone }) {
28326
28490
  setNotice(null);
28327
28491
  writeCredentials(config).then(() => {
28328
28492
  setLastSaved(config);
28329
- if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir);
28330
28493
  setNotice({ kind: "success", text: "Configuration saved" });
28331
28494
  setStage("form");
28332
28495
  }).catch((err) => {
@@ -28456,7 +28619,6 @@ async function writeAnalyticsSetting(setting) {
28456
28619
  }
28457
28620
 
28458
28621
  // packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
28459
- init_debug_store();
28460
28622
  import { Fragment as Fragment18, jsx as jsx56, jsxs as jsxs46 } from "react/jsx-runtime";
28461
28623
  function OptInAnalyticsScreen({ onDone }) {
28462
28624
  const [loading, setLoading] = useState30(true);
@@ -28517,8 +28679,6 @@ function OptInAnalyticsScreen({ onDone }) {
28517
28679
  // packages/experience-design-system-cli/src/tui/upgrade/PageContainer.tsx
28518
28680
  import { useEffect as useEffect25, useState as useState31 } from "react";
28519
28681
  import { Box as Box46, Text as Text48, useInput as useInput13 } from "ink";
28520
- init_version();
28521
- init_debug_store();
28522
28682
  import { jsx as jsx57, jsxs as jsxs47 } from "react/jsx-runtime";
28523
28683
  var UPGRADE_COMMANDS = ["git pull", "pnpm install", "pnpm build"];
28524
28684
  function UpgradeScreen({ onDone }) {
@@ -28590,8 +28750,6 @@ function renderBody(upgradeCheck) {
28590
28750
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
28591
28751
  import { useEffect as useEffect26, useState as useState32 } from "react";
28592
28752
  import { Box as Box47, Text as Text49, useInput as useInput14 } from "ink";
28593
- init_debug_mode_store();
28594
- init_debug_store();
28595
28753
  import { jsx as jsx58, jsxs as jsxs48 } from "react/jsx-runtime";
28596
28754
  function DebugModeScreen({ onDone }) {
28597
28755
  const [loading, setLoading] = useState32(true);
@@ -28707,9 +28865,9 @@ function App({ importOptions, inkClear }) {
28707
28865
  }
28708
28866
  await startExtraction(launch, "generate", result);
28709
28867
  };
28710
- const chooseTokenStrategy = (pending, tokenStrategy) => {
28868
+ const chooseTokenStrategy = (pending2, tokenStrategy) => {
28711
28869
  setPendingLaunch(void 0);
28712
- void startExtraction(pending.launch, tokenStrategy, pending.credentials);
28870
+ void startExtraction(pending2.launch, tokenStrategy, pending2.credentials);
28713
28871
  };
28714
28872
  const startExtraction = async (launch, tokenStrategy, credentials) => {
28715
28873
  const settings = await readSettings2();