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