@contentful/experience-design-system-cli 2.37.1-dev-build-5bd13138.0 → 2.37.1-dev-build-2fb4dadf.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 +302 -414
- package/dist/index.js +238 -310
- package/dist/package.json +1 -1
- package/dist/src/tui/debug-store.d.ts +0 -6
- package/dist/src/tui/import/steps/06-extraction/run.d.ts +0 -3
- package/dist/src/tui/import/steps/10-flow/flow/controller.d.ts +0 -3
- package/legacy/package.json +1 -1
- package/package.json +3 -3
- package/dist/src/tui/import/debug-hooks.d.ts +0 -17
package/dist/index.js
CHANGED
|
@@ -2121,7 +2121,7 @@ async function runAgent(options) {
|
|
|
2121
2121
|
promptLen: prompt.length,
|
|
2122
2122
|
promptHead: prompt.slice(0, 500)
|
|
2123
2123
|
});
|
|
2124
|
-
return new Promise((
|
|
2124
|
+
return new Promise((resolve25) => {
|
|
2125
2125
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
|
|
2126
2126
|
const child = spawn3(binary, args, {
|
|
2127
2127
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -2170,7 +2170,7 @@ async function runAgent(options) {
|
|
|
2170
2170
|
stderrLen: stderr.length,
|
|
2171
2171
|
stderrTail: stderr.slice(-1e3)
|
|
2172
2172
|
});
|
|
2173
|
-
|
|
2173
|
+
resolve25(result);
|
|
2174
2174
|
});
|
|
2175
2175
|
});
|
|
2176
2176
|
}
|
|
@@ -2192,7 +2192,7 @@ async function checkAgentAuth(agent) {
|
|
|
2192
2192
|
return "not-found";
|
|
2193
2193
|
if (agent !== "claude")
|
|
2194
2194
|
return "ok";
|
|
2195
|
-
return new Promise((
|
|
2195
|
+
return new Promise((resolve25) => {
|
|
2196
2196
|
const child = spawn4(binary, ["auth", "status", "--json"], { stdio: ["ignore", "pipe", "pipe"] });
|
|
2197
2197
|
let stdout = "";
|
|
2198
2198
|
let done = false;
|
|
@@ -2201,7 +2201,7 @@ async function checkAgentAuth(agent) {
|
|
|
2201
2201
|
return;
|
|
2202
2202
|
done = true;
|
|
2203
2203
|
child.kill("SIGTERM");
|
|
2204
|
-
|
|
2204
|
+
resolve25("unauthenticated");
|
|
2205
2205
|
}, 5e3);
|
|
2206
2206
|
child.stdout?.on("data", (chunk) => {
|
|
2207
2207
|
stdout += chunk.toString();
|
|
@@ -2212,14 +2212,14 @@ async function checkAgentAuth(agent) {
|
|
|
2212
2212
|
done = true;
|
|
2213
2213
|
clearTimeout(timer);
|
|
2214
2214
|
if (code !== 0) {
|
|
2215
|
-
|
|
2215
|
+
resolve25("unauthenticated");
|
|
2216
2216
|
return;
|
|
2217
2217
|
}
|
|
2218
2218
|
try {
|
|
2219
2219
|
const status = JSON.parse(stdout);
|
|
2220
|
-
|
|
2220
|
+
resolve25(status.loggedIn ? "ok" : "unauthenticated");
|
|
2221
2221
|
} catch {
|
|
2222
|
-
|
|
2222
|
+
resolve25("unauthenticated");
|
|
2223
2223
|
}
|
|
2224
2224
|
});
|
|
2225
2225
|
});
|
|
@@ -2229,9 +2229,9 @@ async function binaryIsOnPath(binary) {
|
|
|
2229
2229
|
const fs = await import("node:fs/promises");
|
|
2230
2230
|
return fs.access(binary).then(() => true, () => false);
|
|
2231
2231
|
}
|
|
2232
|
-
return new Promise((
|
|
2232
|
+
return new Promise((resolve25) => {
|
|
2233
2233
|
const child = spawn4(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
|
|
2234
|
-
child.on("close", (code) =>
|
|
2234
|
+
child.on("close", (code) => resolve25(code === 0));
|
|
2235
2235
|
});
|
|
2236
2236
|
}
|
|
2237
2237
|
var init_check_agent_auth = __esm({
|
|
@@ -4153,12 +4153,12 @@ function renameEmptySlots(db, sessionId, componentId, componentName, slotCount)
|
|
|
4153
4153
|
return { renames: [], warnings: [] };
|
|
4154
4154
|
const renames = [];
|
|
4155
4155
|
const warnings = [];
|
|
4156
|
-
const
|
|
4156
|
+
const rename4 = db.prepare(`UPDATE raw_slots SET name = ? WHERE session_id = ? AND component_id = ? AND name = ? AND position = ?`);
|
|
4157
4157
|
db.exec("BEGIN");
|
|
4158
4158
|
try {
|
|
4159
4159
|
for (const slot of emptySlots) {
|
|
4160
4160
|
const newName = slotCount === 1 ? "children" : `slot_${slot.position}`;
|
|
4161
|
-
|
|
4161
|
+
rename4.run(newName, sessionId, componentId, slot.name, slot.position);
|
|
4162
4162
|
renames.push({ oldName: slot.name, newName });
|
|
4163
4163
|
warnings.push(`${componentName}: slot at position ${slot.position} had empty name \u2014 renamed to "${newName}" for classification`);
|
|
4164
4164
|
}
|
|
@@ -5197,7 +5197,7 @@ function getTsxExtractionContext(filePaths, componentFilePattern) {
|
|
|
5197
5197
|
project: createTsxProject(getTsxProjectFiles(filePaths))
|
|
5198
5198
|
};
|
|
5199
5199
|
}
|
|
5200
|
-
function extractTsxComponents(filePaths, componentFilePattern,
|
|
5200
|
+
function extractTsxComponents(filePaths, componentFilePattern, extract) {
|
|
5201
5201
|
const extractionContext = getTsxExtractionContext(filePaths, componentFilePattern);
|
|
5202
5202
|
if (!extractionContext) {
|
|
5203
5203
|
return { components: [], warnings: [], exclusions: [] };
|
|
@@ -5211,7 +5211,7 @@ function extractTsxComponents(filePaths, componentFilePattern, extract2) {
|
|
|
5211
5211
|
const sourceFile = project.getSourceFile(filePath);
|
|
5212
5212
|
if (!sourceFile)
|
|
5213
5213
|
continue;
|
|
5214
|
-
components.push(...
|
|
5214
|
+
components.push(...extract(sourceFile, exclusions));
|
|
5215
5215
|
} catch (e) {
|
|
5216
5216
|
warnings.push(`Failed to extract from ${filePath}: ${e instanceof Error ? e.message : String(e)}`);
|
|
5217
5217
|
}
|
|
@@ -14901,7 +14901,7 @@ function errorMessage(error) {
|
|
|
14901
14901
|
return error instanceof Error && error.message ? error.message : String(error);
|
|
14902
14902
|
}
|
|
14903
14903
|
function defaultSleep(delayMs) {
|
|
14904
|
-
return new Promise((
|
|
14904
|
+
return new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
14905
14905
|
}
|
|
14906
14906
|
var MAX_RETRY_AFTER_MS;
|
|
14907
14907
|
var init_http_utils = __esm({
|
|
@@ -15177,7 +15177,7 @@ var init_api_client = __esm({
|
|
|
15177
15177
|
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
15178
15178
|
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
15179
15179
|
const jitter = Math.random() * baseDelay * 0.15;
|
|
15180
|
-
await new Promise((
|
|
15180
|
+
await new Promise((resolve25) => setTimeout(resolve25, baseDelay + jitter));
|
|
15181
15181
|
}
|
|
15182
15182
|
}
|
|
15183
15183
|
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
@@ -18734,7 +18734,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
18734
18734
|
const message = error instanceof Error ? error.message : String(error);
|
|
18735
18735
|
if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
|
|
18736
18736
|
throw error;
|
|
18737
|
-
await new Promise((
|
|
18737
|
+
await new Promise((resolve25) => setTimeout(resolve25, Math.min(250 * attempt, 2e3)));
|
|
18738
18738
|
}
|
|
18739
18739
|
}
|
|
18740
18740
|
}
|
|
@@ -19251,12 +19251,12 @@ async function runOneGenerateComponent(options, component, index, total) {
|
|
|
19251
19251
|
if (renames.length > 0) {
|
|
19252
19252
|
const renameMap = new Map(renames.map((r) => [r.oldName, r.newName]));
|
|
19253
19253
|
effectiveSlots = component.slots.map((s) => renameMap.has(s.name) ? { ...s, name: renameMap.get(s.name) } : s);
|
|
19254
|
-
for (const
|
|
19254
|
+
for (const rename4 of renames) {
|
|
19255
19255
|
onProgress?.({
|
|
19256
19256
|
kind: "component:slot-renamed",
|
|
19257
19257
|
componentName: component.name,
|
|
19258
|
-
oldName:
|
|
19259
|
-
newName:
|
|
19258
|
+
oldName: rename4.oldName,
|
|
19259
|
+
newName: rename4.newName
|
|
19260
19260
|
});
|
|
19261
19261
|
}
|
|
19262
19262
|
}
|
|
@@ -19402,7 +19402,7 @@ var init_run_with_pool = __esm({
|
|
|
19402
19402
|
});
|
|
19403
19403
|
|
|
19404
19404
|
// packages/experience-design-system-backend-pipeline/dist/src/orchestrators/run-generate-components-session/helpers/restore-cached-components.js
|
|
19405
|
-
function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, allowedComponentNames2) {
|
|
19405
|
+
async function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, allowedComponentNames2) {
|
|
19406
19406
|
const restorations = [];
|
|
19407
19407
|
const rekeyed = [];
|
|
19408
19408
|
const componentStatus = db.prepare("SELECT status FROM raw_components WHERE session_id = ? AND component_id = ?");
|
|
@@ -19417,6 +19417,7 @@ function restoreCachedComponents(db, sessionId, cachedComponents, promptHash, al
|
|
|
19417
19417
|
componentId: component.component_id
|
|
19418
19418
|
});
|
|
19419
19419
|
rekeyed.push({ component, cached: resolution.entry });
|
|
19420
|
+
await new Promise((r) => setImmediate(r));
|
|
19420
19421
|
}
|
|
19421
19422
|
copyComponentsFromCache(db, restorations, { allowedComponentNames: allowedComponentNames2 });
|
|
19422
19423
|
storeCaches(db, rekeyed.map(({ component, cached }) => ({
|
|
@@ -19457,12 +19458,15 @@ async function checkGenerateComponentsCache(request) {
|
|
|
19457
19458
|
...components.map((component) => component.name),
|
|
19458
19459
|
...(existingEntities?.components ?? []).map((component) => component.name)
|
|
19459
19460
|
]);
|
|
19460
|
-
const cachedComponents =
|
|
19461
|
+
const cachedComponents = [];
|
|
19462
|
+
for (const component of components) {
|
|
19461
19463
|
const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
|
|
19462
|
-
|
|
19463
|
-
|
|
19464
|
+
if (resolution)
|
|
19465
|
+
cachedComponents.push({ component, resolution });
|
|
19466
|
+
await new Promise((r) => setImmediate(r));
|
|
19467
|
+
}
|
|
19464
19468
|
if (request.restoreCache) {
|
|
19465
|
-
restoreCachedComponents(db, request.sessionId, cachedComponents, promptHash, allowedComponentNames2);
|
|
19469
|
+
await restoreCachedComponents(db, request.sessionId, cachedComponents, promptHash, allowedComponentNames2);
|
|
19466
19470
|
}
|
|
19467
19471
|
return {
|
|
19468
19472
|
sessionId: request.sessionId,
|
|
@@ -20527,228 +20531,17 @@ var init_config = __esm({
|
|
|
20527
20531
|
}
|
|
20528
20532
|
});
|
|
20529
20533
|
|
|
20530
|
-
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
20531
|
-
async function readDebugModeSetting() {
|
|
20532
|
-
const { debugMode } = await readSettings2();
|
|
20533
|
-
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
20534
|
-
}
|
|
20535
|
-
async function writeDebugModeSetting(setting) {
|
|
20536
|
-
await updateSettings2({ debugMode: setting });
|
|
20537
|
-
}
|
|
20538
|
-
var DEFAULT_DEBUG_MODE_SETTING;
|
|
20539
|
-
var init_debug_mode_store = __esm({
|
|
20540
|
-
"packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
|
|
20541
|
-
"use strict";
|
|
20542
|
-
init_config();
|
|
20543
|
-
DEFAULT_DEBUG_MODE_SETTING = {
|
|
20544
|
-
enabled: true
|
|
20545
|
-
};
|
|
20546
|
-
}
|
|
20547
|
-
});
|
|
20548
|
-
|
|
20549
|
-
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
20550
|
-
var debug_store_exports = {};
|
|
20551
|
-
__export(debug_store_exports, {
|
|
20552
|
-
currentDebugSessionDir: () => currentDebugSessionDir,
|
|
20553
|
-
finishDebugRun: () => finishDebugRun,
|
|
20554
|
-
setDebugOutDir: () => setDebugOutDir,
|
|
20555
|
-
startDebugRun: () => startDebugRun
|
|
20556
|
-
});
|
|
20557
|
-
import { cp, mkdir as mkdir7, rename as rename3, rm, writeFile as writeFile7 } from "node:fs/promises";
|
|
20558
|
-
import { existsSync as existsSync10, readdirSync as readdirSync3 } from "node:fs";
|
|
20559
|
-
import { join as join20, resolve as resolve20 } from "node:path";
|
|
20560
|
-
function generateRunId() {
|
|
20561
|
-
const now = /* @__PURE__ */ new Date();
|
|
20562
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
20563
|
-
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
20564
|
-
}
|
|
20565
|
-
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
20566
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
20567
|
-
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
20568
|
-
}
|
|
20569
|
-
function slugify(value) {
|
|
20570
|
-
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
20571
|
-
}
|
|
20572
|
-
function generateSessionId3() {
|
|
20573
|
-
const today = datePrefix();
|
|
20574
|
-
const root = debugSessionsDir2();
|
|
20575
|
-
const existing = existsSync10(root) ? readdirSync3(root) : [];
|
|
20576
|
-
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
20577
|
-
const maxSeq = existing.reduce((max, entry) => {
|
|
20578
|
-
const match2 = seqPattern.exec(entry);
|
|
20579
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
20580
|
-
}, 0);
|
|
20581
|
-
return `${today}-session-${maxSeq + 1}`;
|
|
20582
|
-
}
|
|
20583
|
-
function sessionDebugDir() {
|
|
20584
|
-
return join20(projectSessionsRoot ?? debugSessionsDir2(), SESSION_ID);
|
|
20585
|
-
}
|
|
20586
|
-
function currentDebugSessionDir() {
|
|
20587
|
-
return sessionDebugDir();
|
|
20588
|
-
}
|
|
20589
|
-
async function setDebugOutDir(outDir) {
|
|
20590
|
-
if (!await isDebugModeEnabled()) return;
|
|
20591
|
-
const nextRoot = join20(resolve20(outDir), "debug", "sessions");
|
|
20592
|
-
const from = sessionDebugDir();
|
|
20593
|
-
const to = join20(nextRoot, SESSION_ID);
|
|
20594
|
-
if (from === to) return;
|
|
20595
|
-
try {
|
|
20596
|
-
await mkdir7(nextRoot, { recursive: true });
|
|
20597
|
-
if (existsSync10(from)) {
|
|
20598
|
-
try {
|
|
20599
|
-
await rename3(from, to);
|
|
20600
|
-
} catch {
|
|
20601
|
-
await cp(from, to, { recursive: true });
|
|
20602
|
-
await rm(from, { recursive: true, force: true });
|
|
20603
|
-
}
|
|
20604
|
-
} else {
|
|
20605
|
-
await mkdir7(to, { recursive: true });
|
|
20606
|
-
}
|
|
20607
|
-
projectSessionsRoot = nextRoot;
|
|
20608
|
-
} catch {
|
|
20609
|
-
}
|
|
20610
|
-
}
|
|
20611
|
-
async function isDebugModeEnabled() {
|
|
20612
|
-
try {
|
|
20613
|
-
return (await readDebugModeSetting()).enabled;
|
|
20614
|
-
} catch {
|
|
20615
|
-
return true;
|
|
20616
|
-
}
|
|
20617
|
-
}
|
|
20618
|
-
function redact(value) {
|
|
20619
|
-
const clone = { ...value };
|
|
20620
|
-
if ("cma_token" in clone) {
|
|
20621
|
-
const raw = clone.cma_token;
|
|
20622
|
-
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
20623
|
-
}
|
|
20624
|
-
return clone;
|
|
20625
|
-
}
|
|
20626
|
-
function startDebugRun({
|
|
20627
|
-
flow,
|
|
20628
|
-
step,
|
|
20629
|
-
menuOption,
|
|
20630
|
-
inputs
|
|
20631
|
-
}) {
|
|
20632
|
-
const runId = generateRunId();
|
|
20633
|
-
const startedAt = Date.now();
|
|
20634
|
-
const redactedInputs = redact(inputs);
|
|
20635
|
-
isDebugModeEnabled().then((enabled) => {
|
|
20636
|
-
if (!enabled) return;
|
|
20637
|
-
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
20638
|
-
});
|
|
20639
|
-
}
|
|
20640
|
-
async function finishDebugRun({
|
|
20641
|
-
outputs,
|
|
20642
|
-
status,
|
|
20643
|
-
exitMethod
|
|
20644
|
-
}) {
|
|
20645
|
-
const run = pendingRun;
|
|
20646
|
-
if (!run) return;
|
|
20647
|
-
pendingRun = void 0;
|
|
20648
|
-
const durationMs = Date.now() - run.startedAt;
|
|
20649
|
-
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
20650
|
-
const flowSegments = run.flow.split("/");
|
|
20651
|
-
const dir = join20(sessionDebugDir(), ...flowSegments);
|
|
20652
|
-
await mkdir7(dir, { recursive: true });
|
|
20653
|
-
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
20654
|
-
await writeFile7(join20(dir, filename), content, { mode: 384 });
|
|
20655
|
-
}
|
|
20656
|
-
function nextAttemptFilename(dir, menuOption) {
|
|
20657
|
-
const today = datePrefix();
|
|
20658
|
-
const optionSlug = slugify(menuOption);
|
|
20659
|
-
const existing = existsSync10(dir) ? readdirSync3(dir) : [];
|
|
20660
|
-
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
20661
|
-
const maxAttempt = existing.reduce((max, entry) => {
|
|
20662
|
-
const match2 = attemptPattern.exec(entry);
|
|
20663
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
20664
|
-
}, 0);
|
|
20665
|
-
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
20666
|
-
}
|
|
20667
|
-
function renderMarkdown(run, finish) {
|
|
20668
|
-
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
20669
|
-
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
20670
|
-
const flowSlug = run.flow.split("/").join("-");
|
|
20671
|
-
return `# Debug Log
|
|
20672
|
-
|
|
20673
|
-
- Run ID: ${run.runId}
|
|
20674
|
-
- Flow: ${flowSlug}
|
|
20675
|
-
- Step: ${stepLabel2}
|
|
20676
|
-
- Menu option: ${run.menuOption}
|
|
20677
|
-
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
20678
|
-
- CLI version: ${readPackageVersion()}
|
|
20679
|
-
- Platform: ${process.platform} / Node ${process.version}
|
|
20680
|
-
- Duration on screen: ${finish.durationMs}ms
|
|
20681
|
-
- Status: ${finish.status}
|
|
20682
|
-
- Exit method: ${finish.exitMethod}
|
|
20683
|
-
|
|
20684
|
-
## Inputs
|
|
20685
|
-
\`\`\`json
|
|
20686
|
-
${JSON.stringify(run.inputs, null, 2)}
|
|
20687
|
-
\`\`\`
|
|
20688
|
-
|
|
20689
|
-
## Outputs
|
|
20690
|
-
\`\`\`json
|
|
20691
|
-
${JSON.stringify(finish.outputs, null, 2)}
|
|
20692
|
-
\`\`\`
|
|
20693
|
-
`;
|
|
20694
|
-
}
|
|
20695
|
-
function handleCrash() {
|
|
20696
|
-
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
20697
|
-
}
|
|
20698
|
-
var pendingRun, SESSION_ID, projectSessionsRoot;
|
|
20699
|
-
var init_debug_store = __esm({
|
|
20700
|
-
"packages/experience-design-system-cli/src/tui/debug-store.ts"() {
|
|
20701
|
-
"use strict";
|
|
20702
|
-
init_config();
|
|
20703
|
-
init_version();
|
|
20704
|
-
init_debug_mode_store();
|
|
20705
|
-
SESSION_ID = generateSessionId3();
|
|
20706
|
-
void isDebugModeEnabled().then((enabled) => {
|
|
20707
|
-
if (!enabled) return void 0;
|
|
20708
|
-
return mkdir7(sessionDebugDir(), { recursive: true });
|
|
20709
|
-
});
|
|
20710
|
-
process.once("uncaughtException", (err) => {
|
|
20711
|
-
void handleCrash().finally(() => {
|
|
20712
|
-
throw err;
|
|
20713
|
-
});
|
|
20714
|
-
});
|
|
20715
|
-
process.once("unhandledRejection", (reason) => {
|
|
20716
|
-
void handleCrash().finally(() => {
|
|
20717
|
-
throw reason;
|
|
20718
|
-
});
|
|
20719
|
-
});
|
|
20720
|
-
process.once("SIGINT", () => {
|
|
20721
|
-
void handleCrash().finally(() => {
|
|
20722
|
-
process.exit(130);
|
|
20723
|
-
});
|
|
20724
|
-
});
|
|
20725
|
-
}
|
|
20726
|
-
});
|
|
20727
|
-
|
|
20728
|
-
// packages/experience-design-system-cli/src/tui/import/debug-hooks.ts
|
|
20729
|
-
var realDebugHooks;
|
|
20730
|
-
var init_debug_hooks = __esm({
|
|
20731
|
-
"packages/experience-design-system-cli/src/tui/import/debug-hooks.ts"() {
|
|
20732
|
-
"use strict";
|
|
20733
|
-
realDebugHooks = {
|
|
20734
|
-
setOutDir: async (outDir) => (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).setDebugOutDir(outDir),
|
|
20735
|
-
start: (run) => void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then((m) => m.startDebugRun(run)),
|
|
20736
|
-
finish: async (run) => (await Promise.resolve().then(() => (init_debug_store(), debug_store_exports))).finishDebugRun(run)
|
|
20737
|
-
};
|
|
20738
|
-
}
|
|
20739
|
-
});
|
|
20740
|
-
|
|
20741
20534
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
|
|
20742
|
-
import { existsSync as
|
|
20743
|
-
import { dirname as dirname14, join as
|
|
20535
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
20536
|
+
import { dirname as dirname14, join as join20, resolve as resolve20 } from "node:path";
|
|
20744
20537
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
20745
20538
|
function findSkillPath(fileName) {
|
|
20746
20539
|
const thisDir = dirname14(fileURLToPath4(import.meta.url));
|
|
20747
20540
|
let dir = thisDir;
|
|
20748
20541
|
for (; ; ) {
|
|
20749
|
-
const candidate =
|
|
20750
|
-
if (
|
|
20751
|
-
const parent =
|
|
20542
|
+
const candidate = join20(dir, "skills", fileName);
|
|
20543
|
+
if (existsSync10(candidate)) return candidate;
|
|
20544
|
+
const parent = resolve20(dir, "..");
|
|
20752
20545
|
if (parent === dir) {
|
|
20753
20546
|
throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
|
|
20754
20547
|
}
|
|
@@ -20762,9 +20555,9 @@ var init_find_skill_path = __esm({
|
|
|
20762
20555
|
});
|
|
20763
20556
|
|
|
20764
20557
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/selection.ts
|
|
20765
|
-
import { resolve as
|
|
20558
|
+
import { resolve as resolve21 } from "node:path";
|
|
20766
20559
|
async function hashSelectPrompt(options) {
|
|
20767
|
-
const promptHash = options.promptText ? hashContent(options.promptText) : options.promptPath ? await hashFile(
|
|
20560
|
+
const promptHash = options.promptText ? hashContent(options.promptText) : options.promptPath ? await hashFile(resolve21(options.promptPath)) : await hashFile(SELECT_SKILL_PATH);
|
|
20768
20561
|
return hashContent(`${promptHash}|${options.agent}|${options.model ?? ""}`);
|
|
20769
20562
|
}
|
|
20770
20563
|
async function runSelection(options) {
|
|
@@ -20858,29 +20651,10 @@ var init_selection2 = __esm({
|
|
|
20858
20651
|
});
|
|
20859
20652
|
|
|
20860
20653
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
|
|
20861
|
-
import { mkdir as
|
|
20862
|
-
import { join as
|
|
20654
|
+
import { mkdir as mkdir7 } from "node:fs/promises";
|
|
20655
|
+
import { join as join21, resolve as resolve22 } from "node:path";
|
|
20863
20656
|
async function runExtraction(input, onProgress, deps = realDeps) {
|
|
20864
|
-
const outDir =
|
|
20865
|
-
await deps.debug?.setOutDir(outDir);
|
|
20866
|
-
deps.debug?.start({
|
|
20867
|
-
flow: "import",
|
|
20868
|
-
step: "06-extraction",
|
|
20869
|
-
menuOption: "Import",
|
|
20870
|
-
inputs: {
|
|
20871
|
-
projectPath: input.projectPath,
|
|
20872
|
-
agent: input.agent,
|
|
20873
|
-
files: input.filePaths.length,
|
|
20874
|
-
noCache: input.noCache
|
|
20875
|
-
}
|
|
20876
|
-
});
|
|
20877
|
-
const result = await extract(input, outDir, onProgress, deps);
|
|
20878
|
-
await deps.debug?.finish(
|
|
20879
|
-
result.ok ? { outputs: { sessionId: result.extraction.sessionId, outDir }, status: "success", exitMethod: "saved" } : { outputs: { step: result.step, message: result.message }, status: "error", exitMethod: "discarded" }
|
|
20880
|
-
);
|
|
20881
|
-
return result;
|
|
20882
|
-
}
|
|
20883
|
-
async function extract(input, outDir, onProgress, deps) {
|
|
20657
|
+
const outDir = join21(resolve22(input.projectPath), ".contentful");
|
|
20884
20658
|
let progress = initialProgress({
|
|
20885
20659
|
hasCredentials: input.credentials !== null,
|
|
20886
20660
|
hasRawTokens: input.rawTokensPath !== "",
|
|
@@ -20975,7 +20749,7 @@ async function extract(input, outDir, onProgress, deps) {
|
|
|
20975
20749
|
const extraction = {
|
|
20976
20750
|
sessionId: extracted.sessionId,
|
|
20977
20751
|
outDir,
|
|
20978
|
-
tokensPath: tokens?.ok ? tokens.tokensPath : hasTokenSource ?
|
|
20752
|
+
tokensPath: tokens?.ok ? tokens.tokensPath : hasTokenSource ? join21(outDir, "tokens.json") : "",
|
|
20979
20753
|
tokenSessionId: tokens?.ok ? tokens.tokenSessionId : null,
|
|
20980
20754
|
tokenCount: tokens?.ok ? tokens.tokenCount : 0,
|
|
20981
20755
|
existingEntitiesPath,
|
|
@@ -20986,7 +20760,7 @@ async function extract(input, outDir, onProgress, deps) {
|
|
|
20986
20760
|
}
|
|
20987
20761
|
async function fetchEntities(credentials, outDir) {
|
|
20988
20762
|
try {
|
|
20989
|
-
await
|
|
20763
|
+
await mkdir7(outDir, { recursive: true });
|
|
20990
20764
|
const result = await fetchAndPersistExistingContentfulEntities({
|
|
20991
20765
|
spaceId: credentials.spaceId,
|
|
20992
20766
|
environmentId: credentials.environmentId,
|
|
@@ -21006,7 +20780,7 @@ async function resolveSelectionPrompt(overrides) {
|
|
|
21006
20780
|
if (select?.kind === "text") return { promptText: select.value };
|
|
21007
20781
|
if (select?.kind === "path") {
|
|
21008
20782
|
await resolvePromptOverride(select);
|
|
21009
|
-
return { promptPath:
|
|
20783
|
+
return { promptPath: resolve22(select.value) };
|
|
21010
20784
|
}
|
|
21011
20785
|
return {};
|
|
21012
20786
|
}
|
|
@@ -21015,7 +20789,6 @@ var init_run = __esm({
|
|
|
21015
20789
|
"packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts"() {
|
|
21016
20790
|
"use strict";
|
|
21017
20791
|
init_src4();
|
|
21018
|
-
init_debug_hooks();
|
|
21019
20792
|
init_find_skill_path();
|
|
21020
20793
|
init_logic9();
|
|
21021
20794
|
init_selection2();
|
|
@@ -21025,8 +20798,7 @@ var init_run = __esm({
|
|
|
21025
20798
|
fetchEntities,
|
|
21026
20799
|
runExtractAndComposeSession,
|
|
21027
20800
|
runGenerateTokensSession,
|
|
21028
|
-
runSelection
|
|
21029
|
-
debug: realDebugHooks
|
|
20801
|
+
runSelection
|
|
21030
20802
|
};
|
|
21031
20803
|
fail = (step, message) => ({ ok: false, step, message });
|
|
21032
20804
|
errorMessage2 = (error) => error instanceof Error ? error.message : String(error);
|
|
@@ -24273,7 +24045,7 @@ var init_save_decisions = __esm({
|
|
|
24273
24045
|
});
|
|
24274
24046
|
|
|
24275
24047
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
|
|
24276
|
-
import { resolve as
|
|
24048
|
+
import { resolve as resolve23 } from "node:path";
|
|
24277
24049
|
async function runGeneration(input, onProgress, deps = realDeps3) {
|
|
24278
24050
|
let progress = { components: null, mapTokens: "idle", mapTokensEligible: null };
|
|
24279
24051
|
const update = (change) => {
|
|
@@ -24359,7 +24131,7 @@ async function buildMapTokensOptions(input) {
|
|
|
24359
24131
|
if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
|
|
24360
24132
|
if (mapOverride?.kind === "path") {
|
|
24361
24133
|
await resolvePromptOverride(mapOverride);
|
|
24362
|
-
prompt.skillPathOverride =
|
|
24134
|
+
prompt.skillPathOverride = resolve23(mapOverride.value);
|
|
24363
24135
|
}
|
|
24364
24136
|
if (input.existingEntitiesPath) {
|
|
24365
24137
|
const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
|
|
@@ -24437,7 +24209,7 @@ var init_use_generation = __esm({
|
|
|
24437
24209
|
});
|
|
24438
24210
|
|
|
24439
24211
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
|
|
24440
|
-
import { join as
|
|
24212
|
+
import { join as join22 } from "node:path";
|
|
24441
24213
|
function buildFlowStart(input) {
|
|
24442
24214
|
const { extraction, handoff, saved, generatePromptPath } = input;
|
|
24443
24215
|
const credentials = extraction.credentials ?? {
|
|
@@ -24450,7 +24222,7 @@ function buildFlowStart(input) {
|
|
|
24450
24222
|
handoff,
|
|
24451
24223
|
agent: extraction.agent,
|
|
24452
24224
|
projectPath: extraction.projectPath,
|
|
24453
|
-
outDir: extraction.projectPath ?
|
|
24225
|
+
outDir: extraction.projectPath ? join22(extraction.projectPath, ".contentful") : "",
|
|
24454
24226
|
rawTokensPath: extraction.rawTokensPath,
|
|
24455
24227
|
credentials: {
|
|
24456
24228
|
spaceId: credentials.spaceId,
|
|
@@ -30646,7 +30418,7 @@ var init_DoneStep = __esm({
|
|
|
30646
30418
|
});
|
|
30647
30419
|
|
|
30648
30420
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
|
|
30649
|
-
import { resolve as
|
|
30421
|
+
import { resolve as resolve24 } from "node:path";
|
|
30650
30422
|
import { homedir as homedir4 } from "node:os";
|
|
30651
30423
|
function expandTilde(input) {
|
|
30652
30424
|
if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
|
|
@@ -30660,7 +30432,7 @@ function normalizePath(input) {
|
|
|
30660
30432
|
p = p.slice(1, -1);
|
|
30661
30433
|
}
|
|
30662
30434
|
p = expandTilde(p);
|
|
30663
|
-
return
|
|
30435
|
+
return resolve24(p);
|
|
30664
30436
|
}
|
|
30665
30437
|
var init_path_utils = __esm({
|
|
30666
30438
|
"packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts"() {
|
|
@@ -30687,8 +30459,8 @@ var init_use_blinking_cursor = __esm({
|
|
|
30687
30459
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/PathPrompt.tsx
|
|
30688
30460
|
import { useState as useState24 } from "react";
|
|
30689
30461
|
import { Box as Box37, Text as Text40 } from "ink";
|
|
30690
|
-
import { readdirSync as
|
|
30691
|
-
import { dirname as dirname15, basename as basename6, join as
|
|
30462
|
+
import { readdirSync as readdirSync3 } from "node:fs";
|
|
30463
|
+
import { dirname as dirname15, basename as basename6, join as join23 } from "node:path";
|
|
30692
30464
|
import { jsx as jsx47, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
30693
30465
|
function autocomplete(partial) {
|
|
30694
30466
|
if (!partial) return null;
|
|
@@ -30697,19 +30469,19 @@ function autocomplete(partial) {
|
|
|
30697
30469
|
const base = basename6(normalized);
|
|
30698
30470
|
let entries;
|
|
30699
30471
|
try {
|
|
30700
|
-
entries =
|
|
30472
|
+
entries = readdirSync3(dir);
|
|
30701
30473
|
} catch {
|
|
30702
30474
|
return null;
|
|
30703
30475
|
}
|
|
30704
30476
|
const matches = entries.filter((e) => e.startsWith(base));
|
|
30705
30477
|
if (matches.length === 0) return null;
|
|
30706
|
-
if (matches.length === 1) return
|
|
30478
|
+
if (matches.length === 1) return join23(dir, matches[0]);
|
|
30707
30479
|
let prefix = matches[0];
|
|
30708
30480
|
for (const m of matches) {
|
|
30709
30481
|
while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
|
|
30710
30482
|
if (!prefix) break;
|
|
30711
30483
|
}
|
|
30712
|
-
return prefix.length > base.length ?
|
|
30484
|
+
return prefix.length > base.length ? join23(dir, prefix) : null;
|
|
30713
30485
|
}
|
|
30714
30486
|
function PathPrompt({
|
|
30715
30487
|
defaultPath,
|
|
@@ -31912,8 +31684,8 @@ var init_run_print_files_helpers = __esm({
|
|
|
31912
31684
|
});
|
|
31913
31685
|
|
|
31914
31686
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
|
|
31915
|
-
import { writeFile as
|
|
31916
|
-
import { join as
|
|
31687
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
31688
|
+
import { join as join24 } from "node:path";
|
|
31917
31689
|
function buildSavedCDF(components, tokens, opts = {}) {
|
|
31918
31690
|
const cdf = buildCDF2(components, toCdfTokens(tokens), opts);
|
|
31919
31691
|
if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
|
|
@@ -31925,7 +31697,7 @@ function buildSavedCDF(components, tokens, opts = {}) {
|
|
|
31925
31697
|
}
|
|
31926
31698
|
async function runPrintFiles(input, deps, onPatch) {
|
|
31927
31699
|
onPatch({ step: "printing" });
|
|
31928
|
-
const componentsPath =
|
|
31700
|
+
const componentsPath = join24(input.outDir, "components.json");
|
|
31929
31701
|
try {
|
|
31930
31702
|
const db = deps.openDb();
|
|
31931
31703
|
let components = [];
|
|
@@ -32009,10 +31781,10 @@ var init_save = __esm({
|
|
|
32009
31781
|
realSaveDeps = () => ({
|
|
32010
31782
|
openDb: openPipelineDb,
|
|
32011
31783
|
readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
|
|
32012
|
-
writeFile: (path5, contents) =>
|
|
31784
|
+
writeFile: (path5, contents) => writeFile7(path5, contents),
|
|
32013
31785
|
appendRun,
|
|
32014
31786
|
buildSourceFingerprint,
|
|
32015
|
-
sleep: (ms) => new Promise((
|
|
31787
|
+
sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
|
|
32016
31788
|
warn: (message) => process.stderr.write(message)
|
|
32017
31789
|
});
|
|
32018
31790
|
}
|
|
@@ -32032,9 +31804,9 @@ var init_types9 = __esm({
|
|
|
32032
31804
|
|
|
32033
31805
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
|
|
32034
31806
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
32035
|
-
import { mkdir as
|
|
31807
|
+
import { mkdir as mkdir8 } from "node:fs/promises";
|
|
32036
31808
|
import { tmpdir } from "node:os";
|
|
32037
|
-
import { join as
|
|
31809
|
+
import { join as join25 } from "node:path";
|
|
32038
31810
|
function appendWizardLog(entry) {
|
|
32039
31811
|
appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
|
|
32040
31812
|
}
|
|
@@ -32057,14 +31829,13 @@ function realFlowDeps() {
|
|
|
32057
31829
|
}
|
|
32058
31830
|
},
|
|
32059
31831
|
mkdir: async (path5) => {
|
|
32060
|
-
await
|
|
31832
|
+
await mkdir8(path5, { recursive: true });
|
|
32061
31833
|
},
|
|
32062
31834
|
detectSaveConflict,
|
|
32063
31835
|
buildTimestampedSubdir,
|
|
32064
31836
|
rejectComponentsByName,
|
|
32065
31837
|
log,
|
|
32066
|
-
stderr: (text) => process.stderr.write(text)
|
|
32067
|
-
debug: realDebugHooks
|
|
31838
|
+
stderr: (text) => process.stderr.write(text)
|
|
32068
31839
|
};
|
|
32069
31840
|
}
|
|
32070
31841
|
function initialFlowState(start) {
|
|
@@ -32208,13 +31979,6 @@ function createFlowController(start, deps) {
|
|
|
32208
31979
|
};
|
|
32209
31980
|
const proceedToWrite = async (path5) => {
|
|
32210
31981
|
update({ outDir: path5 });
|
|
32211
|
-
await deps.debug?.setOutDir(path5);
|
|
32212
|
-
deps.debug?.start({
|
|
32213
|
-
flow: "import",
|
|
32214
|
-
step: "10-flow",
|
|
32215
|
-
menuOption: "Save",
|
|
32216
|
-
inputs: { outDir: path5, extractSessionId: state.extractSessionId, andPush: !!pendingSave.andPush }
|
|
32217
|
-
});
|
|
32218
31982
|
const { skipGate, andPush } = pendingSave;
|
|
32219
31983
|
const written = await runPrintFiles(
|
|
32220
31984
|
{
|
|
@@ -32229,9 +31993,6 @@ function createFlowController(start, deps) {
|
|
|
32229
31993
|
update
|
|
32230
31994
|
);
|
|
32231
31995
|
update(written.patch);
|
|
32232
|
-
await deps.debug?.finish(
|
|
32233
|
-
written.ok ? { outputs: { componentsPath: join26(path5, "components.json") }, status: "success", exitMethod: "saved" } : { outputs: { error: written.patch.errorMessage ?? "unknown" }, status: "error", exitMethod: "discarded" }
|
|
32234
|
-
);
|
|
32235
31996
|
if (!written.ok) return;
|
|
32236
31997
|
const runId = await recordRun({ state, savePath: path5 }, deps.save);
|
|
32237
31998
|
if (runId) update({ lastRunId: runId });
|
|
@@ -32315,12 +32076,11 @@ var init_controller = __esm({
|
|
|
32315
32076
|
init_slot_graph();
|
|
32316
32077
|
init_cycle_detection();
|
|
32317
32078
|
init_wizard_state_transitions();
|
|
32318
|
-
init_debug_hooks();
|
|
32319
32079
|
init_preview2();
|
|
32320
32080
|
init_push();
|
|
32321
32081
|
init_save();
|
|
32322
32082
|
init_types9();
|
|
32323
|
-
WIZARD_LOG =
|
|
32083
|
+
WIZARD_LOG = join25(tmpdir(), "experiences-import-wizard.log");
|
|
32324
32084
|
}
|
|
32325
32085
|
});
|
|
32326
32086
|
|
|
@@ -32352,6 +32112,175 @@ var init_use_flow = __esm({
|
|
|
32352
32112
|
}
|
|
32353
32113
|
});
|
|
32354
32114
|
|
|
32115
|
+
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
32116
|
+
async function readDebugModeSetting() {
|
|
32117
|
+
const { debugMode } = await readSettings2();
|
|
32118
|
+
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
32119
|
+
}
|
|
32120
|
+
async function writeDebugModeSetting(setting) {
|
|
32121
|
+
await updateSettings2({ debugMode: setting });
|
|
32122
|
+
}
|
|
32123
|
+
var DEFAULT_DEBUG_MODE_SETTING;
|
|
32124
|
+
var init_debug_mode_store = __esm({
|
|
32125
|
+
"packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
|
|
32126
|
+
"use strict";
|
|
32127
|
+
init_config();
|
|
32128
|
+
DEFAULT_DEBUG_MODE_SETTING = {
|
|
32129
|
+
enabled: true
|
|
32130
|
+
};
|
|
32131
|
+
}
|
|
32132
|
+
});
|
|
32133
|
+
|
|
32134
|
+
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
32135
|
+
import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
|
|
32136
|
+
import { existsSync as existsSync11, readdirSync as readdirSync4 } from "node:fs";
|
|
32137
|
+
import { join as join26 } from "node:path";
|
|
32138
|
+
function generateRunId() {
|
|
32139
|
+
const now = /* @__PURE__ */ new Date();
|
|
32140
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
32141
|
+
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
32142
|
+
}
|
|
32143
|
+
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
32144
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
32145
|
+
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
32146
|
+
}
|
|
32147
|
+
function slugify(value) {
|
|
32148
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
32149
|
+
}
|
|
32150
|
+
function generateSessionId3() {
|
|
32151
|
+
const today = datePrefix();
|
|
32152
|
+
const root = debugSessionsDir2();
|
|
32153
|
+
const existing = existsSync11(root) ? readdirSync4(root) : [];
|
|
32154
|
+
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
32155
|
+
const maxSeq = existing.reduce((max, entry) => {
|
|
32156
|
+
const match2 = seqPattern.exec(entry);
|
|
32157
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
32158
|
+
}, 0);
|
|
32159
|
+
return `${today}-session-${maxSeq + 1}`;
|
|
32160
|
+
}
|
|
32161
|
+
function sessionDebugDir() {
|
|
32162
|
+
return join26(debugSessionsDir2(), SESSION_ID);
|
|
32163
|
+
}
|
|
32164
|
+
function currentDebugSessionDir() {
|
|
32165
|
+
return sessionDebugDir();
|
|
32166
|
+
}
|
|
32167
|
+
async function isDebugModeEnabled() {
|
|
32168
|
+
try {
|
|
32169
|
+
return (await readDebugModeSetting()).enabled;
|
|
32170
|
+
} catch {
|
|
32171
|
+
return true;
|
|
32172
|
+
}
|
|
32173
|
+
}
|
|
32174
|
+
function redact(value) {
|
|
32175
|
+
const clone = { ...value };
|
|
32176
|
+
if ("cma_token" in clone) {
|
|
32177
|
+
const raw = clone.cma_token;
|
|
32178
|
+
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
32179
|
+
}
|
|
32180
|
+
return clone;
|
|
32181
|
+
}
|
|
32182
|
+
function startDebugRun({
|
|
32183
|
+
flow,
|
|
32184
|
+
step,
|
|
32185
|
+
menuOption,
|
|
32186
|
+
inputs
|
|
32187
|
+
}) {
|
|
32188
|
+
const runId = generateRunId();
|
|
32189
|
+
const startedAt = Date.now();
|
|
32190
|
+
const redactedInputs = redact(inputs);
|
|
32191
|
+
isDebugModeEnabled().then((enabled) => {
|
|
32192
|
+
if (!enabled) return;
|
|
32193
|
+
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
32194
|
+
});
|
|
32195
|
+
}
|
|
32196
|
+
async function finishDebugRun({
|
|
32197
|
+
outputs,
|
|
32198
|
+
status,
|
|
32199
|
+
exitMethod
|
|
32200
|
+
}) {
|
|
32201
|
+
const run = pendingRun;
|
|
32202
|
+
if (!run) return;
|
|
32203
|
+
pendingRun = void 0;
|
|
32204
|
+
const durationMs = Date.now() - run.startedAt;
|
|
32205
|
+
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
32206
|
+
const flowSegments = run.flow.split("/");
|
|
32207
|
+
const dir = join26(sessionDebugDir(), ...flowSegments);
|
|
32208
|
+
await mkdir9(dir, { recursive: true });
|
|
32209
|
+
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
32210
|
+
await writeFile8(join26(dir, filename), content, { mode: 384 });
|
|
32211
|
+
}
|
|
32212
|
+
function nextAttemptFilename(dir, menuOption) {
|
|
32213
|
+
const today = datePrefix();
|
|
32214
|
+
const optionSlug = slugify(menuOption);
|
|
32215
|
+
const existing = existsSync11(dir) ? readdirSync4(dir) : [];
|
|
32216
|
+
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
32217
|
+
const maxAttempt = existing.reduce((max, entry) => {
|
|
32218
|
+
const match2 = attemptPattern.exec(entry);
|
|
32219
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
32220
|
+
}, 0);
|
|
32221
|
+
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
32222
|
+
}
|
|
32223
|
+
function renderMarkdown(run, finish) {
|
|
32224
|
+
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
32225
|
+
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
32226
|
+
const flowSlug = run.flow.split("/").join("-");
|
|
32227
|
+
return `# Debug Log
|
|
32228
|
+
|
|
32229
|
+
- Run ID: ${run.runId}
|
|
32230
|
+
- Flow: ${flowSlug}
|
|
32231
|
+
- Step: ${stepLabel2}
|
|
32232
|
+
- Menu option: ${run.menuOption}
|
|
32233
|
+
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
32234
|
+
- CLI version: ${readPackageVersion()}
|
|
32235
|
+
- Platform: ${process.platform} / Node ${process.version}
|
|
32236
|
+
- Duration on screen: ${finish.durationMs}ms
|
|
32237
|
+
- Status: ${finish.status}
|
|
32238
|
+
- Exit method: ${finish.exitMethod}
|
|
32239
|
+
|
|
32240
|
+
## Inputs
|
|
32241
|
+
\`\`\`json
|
|
32242
|
+
${JSON.stringify(run.inputs, null, 2)}
|
|
32243
|
+
\`\`\`
|
|
32244
|
+
|
|
32245
|
+
## Outputs
|
|
32246
|
+
\`\`\`json
|
|
32247
|
+
${JSON.stringify(finish.outputs, null, 2)}
|
|
32248
|
+
\`\`\`
|
|
32249
|
+
`;
|
|
32250
|
+
}
|
|
32251
|
+
function handleCrash() {
|
|
32252
|
+
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
32253
|
+
}
|
|
32254
|
+
var pendingRun, SESSION_ID;
|
|
32255
|
+
var init_debug_store = __esm({
|
|
32256
|
+
"packages/experience-design-system-cli/src/tui/debug-store.ts"() {
|
|
32257
|
+
"use strict";
|
|
32258
|
+
init_config();
|
|
32259
|
+
init_version();
|
|
32260
|
+
init_debug_mode_store();
|
|
32261
|
+
SESSION_ID = generateSessionId3();
|
|
32262
|
+
void isDebugModeEnabled().then((enabled) => {
|
|
32263
|
+
if (!enabled) return void 0;
|
|
32264
|
+
return mkdir9(sessionDebugDir(), { recursive: true });
|
|
32265
|
+
});
|
|
32266
|
+
process.once("uncaughtException", (err) => {
|
|
32267
|
+
void handleCrash().finally(() => {
|
|
32268
|
+
throw err;
|
|
32269
|
+
});
|
|
32270
|
+
});
|
|
32271
|
+
process.once("unhandledRejection", (reason) => {
|
|
32272
|
+
void handleCrash().finally(() => {
|
|
32273
|
+
throw reason;
|
|
32274
|
+
});
|
|
32275
|
+
});
|
|
32276
|
+
process.once("SIGINT", () => {
|
|
32277
|
+
void handleCrash().finally(() => {
|
|
32278
|
+
process.exit(130);
|
|
32279
|
+
});
|
|
32280
|
+
});
|
|
32281
|
+
}
|
|
32282
|
+
});
|
|
32283
|
+
|
|
32355
32284
|
// packages/experience-design-system-cli/src/tui/help/help-info.ts
|
|
32356
32285
|
async function readHelpInfo() {
|
|
32357
32286
|
const debugMode = await readDebugModeSetting();
|
|
@@ -32359,8 +32288,7 @@ async function readHelpInfo() {
|
|
|
32359
32288
|
storage: [
|
|
32360
32289
|
{ label: "Config folder", value: configRoot2() },
|
|
32361
32290
|
{ label: "Settings file", value: configFilePath2() },
|
|
32362
|
-
{ label: "Debug logs", value:
|
|
32363
|
-
{ label: "No project", value: `${debugSessionsDir2()} (sessions that never pick a project)` }
|
|
32291
|
+
{ label: "Debug logs", value: debugSessionsDir2() }
|
|
32364
32292
|
],
|
|
32365
32293
|
troubleshooting: [
|
|
32366
32294
|
{ label: "CLI version", value: readPackageVersion() },
|
|
@@ -33398,14 +33326,14 @@ function runDevWatch(args) {
|
|
|
33398
33326
|
process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
|
|
33399
33327
|
return Promise.resolve(1);
|
|
33400
33328
|
}
|
|
33401
|
-
return new Promise((
|
|
33329
|
+
return new Promise((resolve25) => {
|
|
33402
33330
|
const child = spawn2(process.execPath, [script, ...args], { stdio: "inherit" });
|
|
33403
33331
|
process.on("SIGINT", () => void 0);
|
|
33404
|
-
child.on("exit", (code) =>
|
|
33332
|
+
child.on("exit", (code) => resolve25(code ?? 0));
|
|
33405
33333
|
child.on("error", (err) => {
|
|
33406
33334
|
process.stderr.write(`${err.message}
|
|
33407
33335
|
`);
|
|
33408
|
-
|
|
33336
|
+
resolve25(1);
|
|
33409
33337
|
});
|
|
33410
33338
|
});
|
|
33411
33339
|
}
|
|
@@ -33449,7 +33377,7 @@ function createProgram() {
|
|
|
33449
33377
|
init_config();
|
|
33450
33378
|
init_package_root();
|
|
33451
33379
|
import { existsSync as existsSync12 } from "node:fs";
|
|
33452
|
-
import { mkdir as mkdir10, readFile as readFile19, rename as
|
|
33380
|
+
import { mkdir as mkdir10, readFile as readFile19, rename as rename3, rmdir, unlink } from "node:fs/promises";
|
|
33453
33381
|
import { dirname as dirname16, join as join29 } from "node:path";
|
|
33454
33382
|
var PACKAGE_NAME4 = "@contentful/experience-design-system-cli";
|
|
33455
33383
|
async function readJson(path5) {
|
|
@@ -33477,7 +33405,7 @@ async function migrateOldConfig() {
|
|
|
33477
33405
|
if (existsSync12(oldRuns)) {
|
|
33478
33406
|
if (!existsSync12(runsFilePath2())) {
|
|
33479
33407
|
await mkdir10(dirname16(runsFilePath2()), { recursive: true });
|
|
33480
|
-
await
|
|
33408
|
+
await rename3(oldRuns, runsFilePath2());
|
|
33481
33409
|
} else {
|
|
33482
33410
|
await unlink(oldRuns);
|
|
33483
33411
|
}
|