@contentful/experience-design-system-cli 2.37.1-dev-build-36f90a5a.0 → 2.37.1-dev-build-ced30421.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 +403 -388
- package/dist/index.js +339 -276
- package/dist/package.json +1 -1
- package/dist/src/tui/debug-store.d.ts +1 -6
- package/dist/src/tui/import/steps/07-scope-gate/keymap.d.ts +2 -0
- package/dist/src/tui/import/steps/07-scope-gate/sidebar/components/GroupedSidebar.d.ts +2 -0
- package/dist/src/tui/import/steps/07-scope-gate/state.d.ts +3 -2
- package/dist/src/tui/import/steps/07-scope-gate/types.d.ts +7 -0
- package/dist/src/tui/import/steps/07-scope-gate/use-scope-gate.d.ts +1 -1
- package/dist/src/tui/import/steps/08-generation/types.d.ts +2 -4
- package/dist/src/tui/settings/contentful-configuration/config-store.d.ts +0 -1
- package/legacy/package.json +1 -1
- package/package.json +3 -3
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({
|
|
@@ -4386,8 +4386,30 @@ function applyScopeDecisions(db, sessionId, decisions) {
|
|
|
4386
4386
|
const placeholders = accepted.map(() => "?").join(",");
|
|
4387
4387
|
db.prepare(`UPDATE raw_components SET status = 'generated' WHERE session_id = ? AND name IN (${placeholders})`).run(sessionId, ...accepted);
|
|
4388
4388
|
}
|
|
4389
|
+
removeSlotAllowedComponents(db, sessionId, decisions.excludedSlotEdges ?? [], rejected);
|
|
4389
4390
|
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId);
|
|
4390
4391
|
}
|
|
4392
|
+
function removeSlotAllowedComponents(db, sessionId, edges, rejectedNames) {
|
|
4393
|
+
if (edges.length === 0 && rejectedNames.length === 0)
|
|
4394
|
+
return;
|
|
4395
|
+
const componentId = db.prepare("SELECT component_id FROM raw_components WHERE session_id = ? AND name = ?");
|
|
4396
|
+
const removeEdge = db.prepare("DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ? AND allowed_component = ?");
|
|
4397
|
+
const removeEverywhere = db.prepare("DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND allowed_component = ?");
|
|
4398
|
+
db.exec("BEGIN");
|
|
4399
|
+
try {
|
|
4400
|
+
for (const edge of edges) {
|
|
4401
|
+
const row = componentId.get(sessionId, edge.parent);
|
|
4402
|
+
if (row)
|
|
4403
|
+
removeEdge.run(sessionId, row.component_id, edge.child);
|
|
4404
|
+
}
|
|
4405
|
+
for (const name of rejectedNames)
|
|
4406
|
+
removeEverywhere.run(sessionId, name);
|
|
4407
|
+
db.exec("COMMIT");
|
|
4408
|
+
} catch (e) {
|
|
4409
|
+
db.exec("ROLLBACK");
|
|
4410
|
+
throw e;
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4391
4413
|
function findLatestSessionForCommand(db, command) {
|
|
4392
4414
|
return getLatestCompletedSessionForCommand(db, command);
|
|
4393
4415
|
}
|
|
@@ -13144,11 +13166,11 @@ var init_load_and_validate_for_review = __esm({
|
|
|
13144
13166
|
// packages/experience-design-system-backend-pipeline/dist/src/persistence/src/review-session/repositories/review-session-paths.js
|
|
13145
13167
|
import { resolve as resolve15 } from "node:path";
|
|
13146
13168
|
async function getRefineSessionPaths(sessionId, artifactsRoot) {
|
|
13147
|
-
const
|
|
13169
|
+
const sessionDir = resolve15(artifactsRoot, sessionId);
|
|
13148
13170
|
return {
|
|
13149
|
-
sessionDir
|
|
13150
|
-
eventsPath: resolve15(
|
|
13151
|
-
statePath: resolve15(
|
|
13171
|
+
sessionDir,
|
|
13172
|
+
eventsPath: resolve15(sessionDir, "events.jsonl"),
|
|
13173
|
+
statePath: resolve15(sessionDir, "current-review-state.json")
|
|
13152
13174
|
};
|
|
13153
13175
|
}
|
|
13154
13176
|
var init_review_session_paths = __esm({
|
|
@@ -14901,7 +14923,7 @@ function errorMessage(error) {
|
|
|
14901
14923
|
return error instanceof Error && error.message ? error.message : String(error);
|
|
14902
14924
|
}
|
|
14903
14925
|
function defaultSleep(delayMs) {
|
|
14904
|
-
return new Promise((
|
|
14926
|
+
return new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
14905
14927
|
}
|
|
14906
14928
|
var MAX_RETRY_AFTER_MS;
|
|
14907
14929
|
var init_http_utils = __esm({
|
|
@@ -15177,7 +15199,7 @@ var init_api_client = __esm({
|
|
|
15177
15199
|
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
15178
15200
|
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
15179
15201
|
const jitter = Math.random() * baseDelay * 0.15;
|
|
15180
|
-
await new Promise((
|
|
15202
|
+
await new Promise((resolve25) => setTimeout(resolve25, baseDelay + jitter));
|
|
15181
15203
|
}
|
|
15182
15204
|
}
|
|
15183
15205
|
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
@@ -18734,7 +18756,7 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
18734
18756
|
const message = error instanceof Error ? error.message : String(error);
|
|
18735
18757
|
if (!/database is locked|database is busy/i.test(message) || attempt >= attempts)
|
|
18736
18758
|
throw error;
|
|
18737
|
-
await new Promise((
|
|
18759
|
+
await new Promise((resolve25) => setTimeout(resolve25, Math.min(250 * attempt, 2e3)));
|
|
18738
18760
|
}
|
|
18739
18761
|
}
|
|
18740
18762
|
}
|
|
@@ -20520,12 +20542,13 @@ async function writeSettings2(settings) {
|
|
|
20520
20542
|
async function updateSettings2(patch) {
|
|
20521
20543
|
await writeSettings2({ ...await readSettings2(), ...patch });
|
|
20522
20544
|
}
|
|
20523
|
-
var configFilePath2, runsFilePath2, oldConfigDir2;
|
|
20545
|
+
var configFilePath2, runsFilePath2, debugSessionsDir2, oldConfigDir2;
|
|
20524
20546
|
var init_config = __esm({
|
|
20525
20547
|
"packages/experience-design-system-types/dist/src/config/index.js"() {
|
|
20526
20548
|
"use strict";
|
|
20527
20549
|
configFilePath2 = () => join19(configRoot2(), "config.json");
|
|
20528
20550
|
runsFilePath2 = () => join19(configRoot2(), "state", "runs.json");
|
|
20551
|
+
debugSessionsDir2 = () => join19(configRoot2(), "debug", "sessions");
|
|
20529
20552
|
oldConfigDir2 = () => join19(homedir3(), ".config", "experiences");
|
|
20530
20553
|
}
|
|
20531
20554
|
});
|
|
@@ -20804,199 +20827,6 @@ var init_run = __esm({
|
|
|
20804
20827
|
}
|
|
20805
20828
|
});
|
|
20806
20829
|
|
|
20807
|
-
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
20808
|
-
async function readDebugModeSetting() {
|
|
20809
|
-
const { debugMode } = await readSettings2();
|
|
20810
|
-
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
20811
|
-
}
|
|
20812
|
-
async function writeDebugModeSetting(setting) {
|
|
20813
|
-
await updateSettings2({ debugMode: setting });
|
|
20814
|
-
}
|
|
20815
|
-
var DEFAULT_DEBUG_MODE_SETTING;
|
|
20816
|
-
var init_debug_mode_store = __esm({
|
|
20817
|
-
"packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
|
|
20818
|
-
"use strict";
|
|
20819
|
-
init_config();
|
|
20820
|
-
DEFAULT_DEBUG_MODE_SETTING = {
|
|
20821
|
-
enabled: true
|
|
20822
|
-
};
|
|
20823
|
-
}
|
|
20824
|
-
});
|
|
20825
|
-
|
|
20826
|
-
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
20827
|
-
var debug_store_exports = {};
|
|
20828
|
-
__export(debug_store_exports, {
|
|
20829
|
-
currentDebugSessionDir: () => currentDebugSessionDir,
|
|
20830
|
-
finishDebugRun: () => finishDebugRun,
|
|
20831
|
-
startDebugRun: () => startDebugRun,
|
|
20832
|
-
startDebugSessionIn: () => startDebugSessionIn
|
|
20833
|
-
});
|
|
20834
|
-
import { mkdir as mkdir8, writeFile as writeFile7 } from "node:fs/promises";
|
|
20835
|
-
import { existsSync as existsSync11, readdirSync as readdirSync3 } from "node:fs";
|
|
20836
|
-
import { join as join22, resolve as resolve23 } from "node:path";
|
|
20837
|
-
function generateRunId() {
|
|
20838
|
-
const now = /* @__PURE__ */ new Date();
|
|
20839
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
20840
|
-
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
20841
|
-
}
|
|
20842
|
-
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
20843
|
-
const pad = (n) => String(n).padStart(2, "0");
|
|
20844
|
-
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
20845
|
-
}
|
|
20846
|
-
function slugify(value) {
|
|
20847
|
-
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
20848
|
-
}
|
|
20849
|
-
async function readBaseDir() {
|
|
20850
|
-
try {
|
|
20851
|
-
const dir = (await readSettings2())["contentfulBaseDir"];
|
|
20852
|
-
return typeof dir === "string" && dir !== "" ? resolve23(dir) : void 0;
|
|
20853
|
-
} catch {
|
|
20854
|
-
return void 0;
|
|
20855
|
-
}
|
|
20856
|
-
}
|
|
20857
|
-
function nextSessionId(contentfulDir) {
|
|
20858
|
-
const today = datePrefix();
|
|
20859
|
-
const existing = existsSync11(contentfulDir) ? readdirSync3(contentfulDir) : [];
|
|
20860
|
-
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
20861
|
-
const maxSeq = existing.reduce((max, entry) => {
|
|
20862
|
-
const match2 = seqPattern.exec(entry);
|
|
20863
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
20864
|
-
}, 0);
|
|
20865
|
-
return `${today}-session-${maxSeq + 1}`;
|
|
20866
|
-
}
|
|
20867
|
-
function startSession(base) {
|
|
20868
|
-
const contentfulDir = join22(base, ".contentful");
|
|
20869
|
-
sessionDir ??= join22(contentfulDir, nextSessionId(contentfulDir));
|
|
20870
|
-
return sessionDir;
|
|
20871
|
-
}
|
|
20872
|
-
function currentDebugSessionDir() {
|
|
20873
|
-
return sessionDir && join22(sessionDir, "debug");
|
|
20874
|
-
}
|
|
20875
|
-
async function startDebugSessionIn(base) {
|
|
20876
|
-
try {
|
|
20877
|
-
if (!await isDebugModeEnabled()) return;
|
|
20878
|
-
await mkdir8(join22(startSession(resolve23(base)), "debug"), { recursive: true });
|
|
20879
|
-
} catch {
|
|
20880
|
-
}
|
|
20881
|
-
}
|
|
20882
|
-
async function isDebugModeEnabled() {
|
|
20883
|
-
try {
|
|
20884
|
-
return (await readDebugModeSetting()).enabled;
|
|
20885
|
-
} catch {
|
|
20886
|
-
return true;
|
|
20887
|
-
}
|
|
20888
|
-
}
|
|
20889
|
-
function redact(value) {
|
|
20890
|
-
const clone = { ...value };
|
|
20891
|
-
if ("cma_token" in clone) {
|
|
20892
|
-
const raw = clone.cma_token;
|
|
20893
|
-
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
20894
|
-
}
|
|
20895
|
-
return clone;
|
|
20896
|
-
}
|
|
20897
|
-
function startDebugRun({
|
|
20898
|
-
flow,
|
|
20899
|
-
step,
|
|
20900
|
-
menuOption,
|
|
20901
|
-
inputs
|
|
20902
|
-
}) {
|
|
20903
|
-
const runId = generateRunId();
|
|
20904
|
-
const startedAt = Date.now();
|
|
20905
|
-
const redactedInputs = redact(inputs);
|
|
20906
|
-
isDebugModeEnabled().then((enabled) => {
|
|
20907
|
-
if (!enabled) return;
|
|
20908
|
-
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
20909
|
-
});
|
|
20910
|
-
}
|
|
20911
|
-
async function finishDebugRun({
|
|
20912
|
-
outputs,
|
|
20913
|
-
status,
|
|
20914
|
-
exitMethod
|
|
20915
|
-
}) {
|
|
20916
|
-
const run = pendingRun;
|
|
20917
|
-
if (!run) return;
|
|
20918
|
-
pendingRun = void 0;
|
|
20919
|
-
const durationMs = Date.now() - run.startedAt;
|
|
20920
|
-
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
20921
|
-
const root = currentDebugSessionDir();
|
|
20922
|
-
if (!root) return;
|
|
20923
|
-
const flowSegments = run.flow.split("/");
|
|
20924
|
-
const dir = join22(root, ...flowSegments);
|
|
20925
|
-
await mkdir8(dir, { recursive: true });
|
|
20926
|
-
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
20927
|
-
await writeFile7(join22(dir, filename), content, { mode: 384 });
|
|
20928
|
-
}
|
|
20929
|
-
function nextAttemptFilename(dir, menuOption) {
|
|
20930
|
-
const today = datePrefix();
|
|
20931
|
-
const optionSlug = slugify(menuOption);
|
|
20932
|
-
const existing = existsSync11(dir) ? readdirSync3(dir) : [];
|
|
20933
|
-
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
20934
|
-
const maxAttempt = existing.reduce((max, entry) => {
|
|
20935
|
-
const match2 = attemptPattern.exec(entry);
|
|
20936
|
-
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
20937
|
-
}, 0);
|
|
20938
|
-
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
20939
|
-
}
|
|
20940
|
-
function renderMarkdown(run, finish) {
|
|
20941
|
-
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
20942
|
-
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
20943
|
-
const flowSlug = run.flow.split("/").join("-");
|
|
20944
|
-
return `# Debug Log
|
|
20945
|
-
|
|
20946
|
-
- Run ID: ${run.runId}
|
|
20947
|
-
- Flow: ${flowSlug}
|
|
20948
|
-
- Step: ${stepLabel2}
|
|
20949
|
-
- Menu option: ${run.menuOption}
|
|
20950
|
-
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
20951
|
-
- CLI version: ${readPackageVersion()}
|
|
20952
|
-
- Platform: ${process.platform} / Node ${process.version}
|
|
20953
|
-
- Duration on screen: ${finish.durationMs}ms
|
|
20954
|
-
- Status: ${finish.status}
|
|
20955
|
-
- Exit method: ${finish.exitMethod}
|
|
20956
|
-
|
|
20957
|
-
## Inputs
|
|
20958
|
-
\`\`\`json
|
|
20959
|
-
${JSON.stringify(run.inputs, null, 2)}
|
|
20960
|
-
\`\`\`
|
|
20961
|
-
|
|
20962
|
-
## Outputs
|
|
20963
|
-
\`\`\`json
|
|
20964
|
-
${JSON.stringify(finish.outputs, null, 2)}
|
|
20965
|
-
\`\`\`
|
|
20966
|
-
`;
|
|
20967
|
-
}
|
|
20968
|
-
function handleCrash() {
|
|
20969
|
-
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
20970
|
-
}
|
|
20971
|
-
var pendingRun, sessionDir;
|
|
20972
|
-
var init_debug_store = __esm({
|
|
20973
|
-
"packages/experience-design-system-cli/src/tui/debug-store.ts"() {
|
|
20974
|
-
"use strict";
|
|
20975
|
-
init_config();
|
|
20976
|
-
init_version();
|
|
20977
|
-
init_debug_mode_store();
|
|
20978
|
-
void Promise.all([isDebugModeEnabled(), readBaseDir()]).then(([enabled, base]) => {
|
|
20979
|
-
if (!enabled || !base) return void 0;
|
|
20980
|
-
return mkdir8(join22(startSession(base), "debug"), { recursive: true });
|
|
20981
|
-
});
|
|
20982
|
-
process.once("uncaughtException", (err) => {
|
|
20983
|
-
void handleCrash().finally(() => {
|
|
20984
|
-
throw err;
|
|
20985
|
-
});
|
|
20986
|
-
});
|
|
20987
|
-
process.once("unhandledRejection", (reason) => {
|
|
20988
|
-
void handleCrash().finally(() => {
|
|
20989
|
-
throw reason;
|
|
20990
|
-
});
|
|
20991
|
-
});
|
|
20992
|
-
process.once("SIGINT", () => {
|
|
20993
|
-
void handleCrash().finally(() => {
|
|
20994
|
-
process.exit(130);
|
|
20995
|
-
});
|
|
20996
|
-
});
|
|
20997
|
-
}
|
|
20998
|
-
});
|
|
20999
|
-
|
|
21000
20830
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
|
|
21001
20831
|
import { useEffect as useEffect5, useRef as useRef2, useState as useState8 } from "react";
|
|
21002
20832
|
function useExtraction(input) {
|
|
@@ -21016,7 +20846,6 @@ function useExtraction(input) {
|
|
|
21016
20846
|
reuseTokens: input.tokenStrategy === "reuse"
|
|
21017
20847
|
})
|
|
21018
20848
|
});
|
|
21019
|
-
void Promise.resolve().then(() => (init_debug_store(), debug_store_exports)).then((store) => store.startDebugSessionIn(input.projectPath));
|
|
21020
20849
|
void runExtraction(input, (progress) => {
|
|
21021
20850
|
if (current.current === input) setState({ status: "running", progress });
|
|
21022
20851
|
}).then((result) => {
|
|
@@ -21974,7 +21803,7 @@ function buildVisibleRows(props) {
|
|
|
21974
21803
|
if (visited.has(target)) continue;
|
|
21975
21804
|
visited.add(target);
|
|
21976
21805
|
const isCycleMember = cycleParticipants.has(target);
|
|
21977
|
-
out.push({ name: target, depth: cur.depth + 1, isCycleMember });
|
|
21806
|
+
out.push({ name: target, depth: cur.depth + 1, isCycleMember, parent: cur.name });
|
|
21978
21807
|
queue.push({ name: target, depth: cur.depth + 1 });
|
|
21979
21808
|
}
|
|
21980
21809
|
}
|
|
@@ -22021,7 +21850,8 @@ function buildVisibleRows(props) {
|
|
|
22021
21850
|
sharedSuffix,
|
|
22022
21851
|
cycleChild: child.isCycleMember || void 0,
|
|
22023
21852
|
itemIdx: childRec?.idx ?? -1,
|
|
22024
|
-
rootName: key
|
|
21853
|
+
rootName: key,
|
|
21854
|
+
parentName: child.parent
|
|
22025
21855
|
});
|
|
22026
21856
|
});
|
|
22027
21857
|
}
|
|
@@ -22104,13 +21934,19 @@ function buildVisibleRows(props) {
|
|
|
22104
21934
|
injectedChildren.push({
|
|
22105
21935
|
name: target,
|
|
22106
21936
|
depth: parentDepth + 1,
|
|
22107
|
-
isCycleChild: true
|
|
21937
|
+
isCycleChild: true,
|
|
21938
|
+
parent: parentName
|
|
22108
21939
|
});
|
|
22109
21940
|
}
|
|
22110
21941
|
};
|
|
22111
21942
|
emitCycleChildrenOf(root, 0);
|
|
22112
21943
|
for (const c2 of closureChildren) {
|
|
22113
|
-
injectedChildren.push({
|
|
21944
|
+
injectedChildren.push({
|
|
21945
|
+
name: c2.name,
|
|
21946
|
+
depth: c2.depth,
|
|
21947
|
+
isCycleChild: false,
|
|
21948
|
+
parent: c2.path[c2.path.length - 2] ?? root
|
|
21949
|
+
});
|
|
22114
21950
|
emitCycleChildrenOf(c2.name, c2.depth);
|
|
22115
21951
|
}
|
|
22116
21952
|
const isLastAtDepth = (idx) => {
|
|
@@ -22144,7 +21980,8 @@ function buildVisibleRows(props) {
|
|
|
22144
21980
|
sharedSuffix,
|
|
22145
21981
|
cycleChild: child.isCycleChild || void 0,
|
|
22146
21982
|
itemIdx: childRec?.idx ?? -1,
|
|
22147
|
-
rootName: root
|
|
21983
|
+
rootName: root,
|
|
21984
|
+
parentName: child.parent
|
|
22148
21985
|
});
|
|
22149
21986
|
});
|
|
22150
21987
|
}
|
|
@@ -22297,7 +22134,7 @@ function GroupedSidebar(props) {
|
|
|
22297
22134
|
const rs = itemName ? renderStatusByKey?.get(itemName) : void 0;
|
|
22298
22135
|
const badge = itemName ? previewBadge(previewAnnotationByKey?.get(itemName)) : null;
|
|
22299
22136
|
const showInheritance = rs !== void 0 && row.kind !== "cycle" && row.kind !== "empty" && row.kind !== "group-root";
|
|
22300
|
-
const supportsSelectionGlyph = selectionStateByKey !== void 0 && itemName !== void 0 && (row.kind === "standalone" || row.kind === "group-root" || row.kind === "group-child" || row.kind === "flat" || row.kind === "cycle");
|
|
22137
|
+
const supportsSelectionGlyph = selectionStateByKey !== void 0 && itemName !== void 0 && (row.kind === "standalone" || row.kind === "group-root" || row.kind === "group-child" || row.kind === "flat" || row.kind === "empty" || row.kind === "cycle");
|
|
22301
22138
|
const selState = supportsSelectionGlyph ? selectionStateByKey.get(itemName) ?? "undecided" : void 0;
|
|
22302
22139
|
const isCycleRow = row.kind === "cycle";
|
|
22303
22140
|
const selStyle = selectionGlyphStyleFor(selState, isCycleRow);
|
|
@@ -22327,7 +22164,7 @@ function GroupedSidebar(props) {
|
|
|
22327
22164
|
color: isSelected ? PALETTE2.info : labelStyle.dim ? PALETTE2.muted : labelStyle.color,
|
|
22328
22165
|
bold: isSelected || labelStyle.bold,
|
|
22329
22166
|
inverse: false,
|
|
22330
|
-
underline: isSelected &&
|
|
22167
|
+
underline: isSelected && focused,
|
|
22331
22168
|
wrap: wrapLabels ? "wrap" : "truncate",
|
|
22332
22169
|
children: [
|
|
22333
22170
|
" ",
|
|
@@ -23078,6 +22915,7 @@ function resolveKey(mode, key, ctx) {
|
|
|
23078
22915
|
function resolveMain(key, ctx) {
|
|
23079
22916
|
const { input } = key;
|
|
23080
22917
|
const inMain = ctx.focusedColumn === "main";
|
|
22918
|
+
if (key.ctrl && input === "z") return { type: "undo" };
|
|
23081
22919
|
if (input === "q" || key.escape) {
|
|
23082
22920
|
if (key.escape && ctx.jumpFilterActive) return { type: "clear-jump-filter" };
|
|
23083
22921
|
if (key.escape && ctx.searchActive) return { type: "clear-search" };
|
|
@@ -23376,14 +23214,30 @@ function rejectNeedsConfirmation(graph, name, state) {
|
|
|
23376
23214
|
const ancestors = toReject.filter((n) => n !== name);
|
|
23377
23215
|
return ancestors.length + toDeselect.length >= 2;
|
|
23378
23216
|
}
|
|
23379
|
-
function
|
|
23217
|
+
function removeSlotChild(components, edge) {
|
|
23218
|
+
return components.map(
|
|
23219
|
+
(component) => component.name === edge.parent ? {
|
|
23220
|
+
...component,
|
|
23221
|
+
slots: component.slots?.map((slot) => ({
|
|
23222
|
+
...slot,
|
|
23223
|
+
allowedComponents: slot.allowedComponents.filter((name) => name !== edge.child)
|
|
23224
|
+
}))
|
|
23225
|
+
} : component
|
|
23226
|
+
);
|
|
23227
|
+
}
|
|
23228
|
+
function withoutSlotChildren(components, removedEdges) {
|
|
23229
|
+
return removedEdges.reduce(removeSlotChild, components);
|
|
23230
|
+
}
|
|
23231
|
+
function partitionDecisions(components, state, removedEdges) {
|
|
23380
23232
|
const accepted = [];
|
|
23381
23233
|
const rejected = [];
|
|
23382
23234
|
for (const c2 of components) {
|
|
23383
23235
|
if (state.get(c2.name) === "accepted") accepted.push(c2.name);
|
|
23384
23236
|
else rejected.push(c2.name);
|
|
23385
23237
|
}
|
|
23386
|
-
|
|
23238
|
+
const rejectedNames = new Set(rejected);
|
|
23239
|
+
const excludedSlotEdges = removedEdges.filter((e) => !rejectedNames.has(e.parent) && !rejectedNames.has(e.child));
|
|
23240
|
+
return { accepted, rejected, excludedSlotEdges };
|
|
23387
23241
|
}
|
|
23388
23242
|
var init_state = __esm({
|
|
23389
23243
|
"packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/state.ts"() {
|
|
@@ -23395,10 +23249,15 @@ var init_state = __esm({
|
|
|
23395
23249
|
|
|
23396
23250
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
|
|
23397
23251
|
import { useEffect as useEffect7, useMemo as useMemo2, useRef as useRef4, useState as useState12 } from "react";
|
|
23398
|
-
function useScopeGate({ components, onConfirm, onQuit }) {
|
|
23252
|
+
function useScopeGate({ components: loadedComponents, onConfirm, onQuit }) {
|
|
23399
23253
|
const { columns: totalWidth, rows: terminalRows } = useTerminalSize();
|
|
23400
23254
|
const columnPlan = useMemo2(() => computeColumnWidths(totalWidth), [totalWidth]);
|
|
23401
23255
|
const [decisions, setDecisions] = useState12(/* @__PURE__ */ new Map());
|
|
23256
|
+
const [removedEdges, setRemovedEdges] = useState12([]);
|
|
23257
|
+
const components = useMemo2(
|
|
23258
|
+
() => withoutSlotChildren(loadedComponents, removedEdges),
|
|
23259
|
+
[loadedComponents, removedEdges]
|
|
23260
|
+
);
|
|
23402
23261
|
const [nav, setNav] = useState12({ cursor: 0, scrollOffset: 0 });
|
|
23403
23262
|
const [focusedColumn, setFocusedColumn] = useState12("main");
|
|
23404
23263
|
const [addedComponentsCursor, setAddedComponentsCursor] = useState12(0);
|
|
@@ -23570,6 +23429,14 @@ function useScopeGate({ components, onConfirm, onQuit }) {
|
|
|
23570
23429
|
return void 0;
|
|
23571
23430
|
}
|
|
23572
23431
|
};
|
|
23432
|
+
const focusedNestedEdge = () => {
|
|
23433
|
+
const row = visibleRows[safeCursor];
|
|
23434
|
+
if (row?.kind !== "group-child" || !row.parentName || row.itemIdx < 0) return void 0;
|
|
23435
|
+
const child = groupedItems[row.itemIdx]?.key;
|
|
23436
|
+
return child ? { parent: row.parentName, child } : void 0;
|
|
23437
|
+
};
|
|
23438
|
+
const removeFromParentSlot = (edge) => setRemovedEdges((edges) => [...edges, edge]);
|
|
23439
|
+
const undoSlotRemoval = () => setRemovedEdges((edges) => edges.slice(0, -1));
|
|
23573
23440
|
const jumpCursorTo = (name) => {
|
|
23574
23441
|
let idx = -1;
|
|
23575
23442
|
for (let i = 0; i < visibleRows.length; i++) {
|
|
@@ -23669,7 +23536,7 @@ function useScopeGate({ components, onConfirm, onQuit }) {
|
|
|
23669
23536
|
onQuit();
|
|
23670
23537
|
return;
|
|
23671
23538
|
case "confirm":
|
|
23672
|
-
onConfirm(partitionDecisions(components, decisions));
|
|
23539
|
+
onConfirm(partitionDecisions(components, decisions, removedEdges));
|
|
23673
23540
|
return;
|
|
23674
23541
|
case "close-help":
|
|
23675
23542
|
setShowHelp(false);
|
|
@@ -23722,6 +23589,11 @@ function useScopeGate({ components, onConfirm, onQuit }) {
|
|
|
23722
23589
|
return;
|
|
23723
23590
|
}
|
|
23724
23591
|
case "reject": {
|
|
23592
|
+
const edge = focusedColumn === "main" ? focusedNestedEdge() : void 0;
|
|
23593
|
+
if (edge) {
|
|
23594
|
+
removeFromParentSlot(edge);
|
|
23595
|
+
return;
|
|
23596
|
+
}
|
|
23725
23597
|
const key = focusedColumn === "added-components" ? addedComponents[safeAddedComponentsCursor]?.name : focusedRowKey();
|
|
23726
23598
|
if (key) requestReject(key);
|
|
23727
23599
|
return;
|
|
@@ -23729,6 +23601,9 @@ function useScopeGate({ components, onConfirm, onQuit }) {
|
|
|
23729
23601
|
case "toggle-all":
|
|
23730
23602
|
decide({ type: "toggle-all" });
|
|
23731
23603
|
return;
|
|
23604
|
+
case "undo":
|
|
23605
|
+
undoSlotRemoval();
|
|
23606
|
+
return;
|
|
23732
23607
|
case "accept-unflagged":
|
|
23733
23608
|
decide({ type: "accept-unflagged" });
|
|
23734
23609
|
return;
|
|
@@ -24238,7 +24113,7 @@ var init_save_decisions = __esm({
|
|
|
24238
24113
|
});
|
|
24239
24114
|
|
|
24240
24115
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
|
|
24241
|
-
import { resolve as
|
|
24116
|
+
import { resolve as resolve23 } from "node:path";
|
|
24242
24117
|
async function runGeneration(input, onProgress, deps = realDeps3) {
|
|
24243
24118
|
let progress = { components: null, mapTokens: "idle", mapTokensEligible: null };
|
|
24244
24119
|
const update = (change) => {
|
|
@@ -24324,7 +24199,7 @@ async function buildMapTokensOptions(input) {
|
|
|
24324
24199
|
if (mapOverride?.kind === "text") prompt.skillContentOverride = mapOverride.value;
|
|
24325
24200
|
if (mapOverride?.kind === "path") {
|
|
24326
24201
|
await resolvePromptOverride(mapOverride);
|
|
24327
|
-
prompt.skillPathOverride =
|
|
24202
|
+
prompt.skillPathOverride = resolve23(mapOverride.value);
|
|
24328
24203
|
}
|
|
24329
24204
|
if (input.existingEntitiesPath) {
|
|
24330
24205
|
const entities = await readExistingContentfulEntitiesFromSession({ path: input.existingEntitiesPath });
|
|
@@ -24402,7 +24277,7 @@ var init_use_generation = __esm({
|
|
|
24402
24277
|
});
|
|
24403
24278
|
|
|
24404
24279
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/build-flow-start.ts
|
|
24405
|
-
import { join as
|
|
24280
|
+
import { join as join22 } from "node:path";
|
|
24406
24281
|
function buildFlowStart(input) {
|
|
24407
24282
|
const { extraction, handoff, saved, generatePromptPath } = input;
|
|
24408
24283
|
const credentials = extraction.credentials ?? {
|
|
@@ -24415,7 +24290,7 @@ function buildFlowStart(input) {
|
|
|
24415
24290
|
handoff,
|
|
24416
24291
|
agent: extraction.agent,
|
|
24417
24292
|
projectPath: extraction.projectPath,
|
|
24418
|
-
outDir: extraction.projectPath ?
|
|
24293
|
+
outDir: extraction.projectPath ? join22(extraction.projectPath, ".contentful") : "",
|
|
24419
24294
|
rawTokensPath: extraction.rawTokensPath,
|
|
24420
24295
|
credentials: {
|
|
24421
24296
|
spaceId: credentials.spaceId,
|
|
@@ -26643,8 +26518,8 @@ function FieldEditor({
|
|
|
26643
26518
|
return /* @__PURE__ */ jsxs22(Box21, { flexDirection: "column", width, borderStyle: "single", borderColor: PALETTE3.warning, children: [
|
|
26644
26519
|
/* @__PURE__ */ jsx27(Text23, { bold: true, color: PALETTE3.warning, children: "FIELD EDITOR \u2014 no fields" }),
|
|
26645
26520
|
/* @__PURE__ */ jsx27(Text23, { color: PALETTE3.warning, children: "\u26A0 No properties classified for this component. The LLM didn't find anything to classify." }),
|
|
26646
|
-
/* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "
|
|
26647
|
-
/* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "
|
|
26521
|
+
/* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: "There is nothing to edit here." }),
|
|
26522
|
+
/* @__PURE__ */ jsx27(Text23, { color: PALETTE3.muted, children: active ? "[Esc] go back to the list" : "In the list: [r] reject this component \xB7 [a] accept it" })
|
|
26648
26523
|
] });
|
|
26649
26524
|
}
|
|
26650
26525
|
const hasEmptyProperties = props.length === 0 && slots.length === 0;
|
|
@@ -26859,7 +26734,7 @@ function FieldEditor({
|
|
|
26859
26734
|
children: [
|
|
26860
26735
|
hasEmptyProperties && /* @__PURE__ */ jsx27(Text23, { color: PALETTE3.warning, children: "\u26A0 No properties classified for this component. The LLM didn't find anything to classify. Reject this component or add fields manually." }),
|
|
26861
26736
|
header,
|
|
26862
|
-
/* @__PURE__ */ jsx27(Box21, { flexDirection: "column", width: innerWidth, flexShrink: 0, children: focusLevel === "field" && !inComponentDesc && currentProp ? /* @__PURE__ */ jsx27(
|
|
26737
|
+
/* @__PURE__ */ jsx27(Box21, { flexDirection: "column", width: innerWidth, flexShrink: 0, children: focusLevel === "field" && !inComponentDesc && !inSlots && currentProp ? /* @__PURE__ */ jsx27(
|
|
26863
26738
|
PropRow,
|
|
26864
26739
|
{
|
|
26865
26740
|
prop: currentProp,
|
|
@@ -27863,6 +27738,7 @@ function finalizeReviewSession(extractSessionId, components) {
|
|
|
27863
27738
|
db.exec("ROLLBACK");
|
|
27864
27739
|
throw error;
|
|
27865
27740
|
}
|
|
27741
|
+
removeSlotAllowedComponents(db, extractSessionId, [], toReject);
|
|
27866
27742
|
} finally {
|
|
27867
27743
|
db.close();
|
|
27868
27744
|
}
|
|
@@ -29641,33 +29517,50 @@ function GenerateReviewStepView({
|
|
|
29641
29517
|
const cycle = cycleRows[cyclesCursor];
|
|
29642
29518
|
return cycle ? enumerateCycleBreaks(cycle, components) : [];
|
|
29643
29519
|
}, [cycleRows, cyclesCursor, components]);
|
|
29644
|
-
const
|
|
29645
|
-
const target = components.find((component) => component.key === edge.fromComponent);
|
|
29646
|
-
const slot = target?.entry.$slots?.[edge.slotName];
|
|
29647
|
-
if (!target || !slot || !Array.isArray(slot.$allowedComponents)) return;
|
|
29648
|
-
const nextEntry = {
|
|
29649
|
-
...target.entry,
|
|
29650
|
-
$slots: {
|
|
29651
|
-
...target.entry.$slots,
|
|
29652
|
-
[edge.slotName]: {
|
|
29653
|
-
...slot,
|
|
29654
|
-
$allowedComponents: slot.$allowedComponents.filter((value) => value !== edge.toComponent)
|
|
29655
|
-
}
|
|
29656
|
-
}
|
|
29657
|
-
};
|
|
29520
|
+
const saveSlotChange = (parentKey, nextEntry, historyLabel) => {
|
|
29658
29521
|
const next = components.map(
|
|
29659
|
-
(component) => component.key ===
|
|
29522
|
+
(component) => component.key === parentKey ? { ...component, entry: nextEntry } : component
|
|
29660
29523
|
);
|
|
29661
29524
|
setComponents(next);
|
|
29662
29525
|
const db = openPipelineDb();
|
|
29663
29526
|
try {
|
|
29664
|
-
storeCDFComponents(db, extractSessionId, [{ key:
|
|
29527
|
+
storeCDFComponents(db, extractSessionId, [{ key: parentKey, entry: nextEntry }]);
|
|
29665
29528
|
} finally {
|
|
29666
29529
|
db.close();
|
|
29667
29530
|
}
|
|
29668
29531
|
recomputeCycles(next);
|
|
29669
29532
|
livePreviewHook.trigger();
|
|
29670
|
-
pushHistorySnapshot(next,
|
|
29533
|
+
pushHistorySnapshot(next, historyLabel);
|
|
29534
|
+
};
|
|
29535
|
+
const handleBreakEdge = (edge) => {
|
|
29536
|
+
const target = components.find((component) => component.key === edge.fromComponent);
|
|
29537
|
+
const slot = target?.entry.$slots?.[edge.slotName];
|
|
29538
|
+
if (!target || !slot || !Array.isArray(slot.$allowedComponents)) return;
|
|
29539
|
+
saveSlotChange(
|
|
29540
|
+
target.key,
|
|
29541
|
+
{
|
|
29542
|
+
...target.entry,
|
|
29543
|
+
$slots: {
|
|
29544
|
+
...target.entry.$slots,
|
|
29545
|
+
[edge.slotName]: {
|
|
29546
|
+
...slot,
|
|
29547
|
+
$allowedComponents: slot.$allowedComponents.filter((value) => value !== edge.toComponent)
|
|
29548
|
+
}
|
|
29549
|
+
}
|
|
29550
|
+
},
|
|
29551
|
+
"break-cycle-edge"
|
|
29552
|
+
);
|
|
29553
|
+
};
|
|
29554
|
+
const handleRemoveSlotChild = (parentKey, childKey) => {
|
|
29555
|
+
const parent = components.find((component) => component.key === parentKey);
|
|
29556
|
+
if (!parent?.entry.$slots) return;
|
|
29557
|
+
const slots = Object.fromEntries(
|
|
29558
|
+
Object.entries(parent.entry.$slots).map(([slotName, slot]) => [
|
|
29559
|
+
slotName,
|
|
29560
|
+
Array.isArray(slot.$allowedComponents) ? { ...slot, $allowedComponents: slot.$allowedComponents.filter((value) => value !== childKey) } : slot
|
|
29561
|
+
])
|
|
29562
|
+
);
|
|
29563
|
+
saveSlotChange(parentKey, { ...parent.entry, $slots: slots }, "remove-slot-child");
|
|
29671
29564
|
};
|
|
29672
29565
|
const handleRejectComponent = (key) => {
|
|
29673
29566
|
const rejectCascade2 = computeRejectCascade(key, componentGraph);
|
|
@@ -29997,6 +29890,11 @@ function GenerateReviewStepView({
|
|
|
29997
29890
|
if (input === "r") {
|
|
29998
29891
|
const current = components[selectedIdx];
|
|
29999
29892
|
if (!current) return;
|
|
29893
|
+
const row = visibleRowsMemo[cursorRowIdx];
|
|
29894
|
+
if (row?.kind === "group-child" && row.parentName) {
|
|
29895
|
+
handleRemoveSlotChild(row.parentName, current.key);
|
|
29896
|
+
return;
|
|
29897
|
+
}
|
|
30000
29898
|
handleRejectComponent(current.key);
|
|
30001
29899
|
return;
|
|
30002
29900
|
}
|
|
@@ -30611,7 +30509,7 @@ var init_DoneStep = __esm({
|
|
|
30611
30509
|
});
|
|
30612
30510
|
|
|
30613
30511
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts
|
|
30614
|
-
import { resolve as
|
|
30512
|
+
import { resolve as resolve24 } from "node:path";
|
|
30615
30513
|
import { homedir as homedir4 } from "node:os";
|
|
30616
30514
|
function expandTilde(input) {
|
|
30617
30515
|
if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
|
|
@@ -30625,7 +30523,7 @@ function normalizePath(input) {
|
|
|
30625
30523
|
p = p.slice(1, -1);
|
|
30626
30524
|
}
|
|
30627
30525
|
p = expandTilde(p);
|
|
30628
|
-
return
|
|
30526
|
+
return resolve24(p);
|
|
30629
30527
|
}
|
|
30630
30528
|
var init_path_utils = __esm({
|
|
30631
30529
|
"packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/path-utils.ts"() {
|
|
@@ -30652,8 +30550,8 @@ var init_use_blinking_cursor = __esm({
|
|
|
30652
30550
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/PathPrompt.tsx
|
|
30653
30551
|
import { useState as useState24 } from "react";
|
|
30654
30552
|
import { Box as Box37, Text as Text40 } from "ink";
|
|
30655
|
-
import { readdirSync as
|
|
30656
|
-
import { dirname as dirname15, basename as basename6, join as
|
|
30553
|
+
import { readdirSync as readdirSync3 } from "node:fs";
|
|
30554
|
+
import { dirname as dirname15, basename as basename6, join as join23 } from "node:path";
|
|
30657
30555
|
import { jsx as jsx47, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
30658
30556
|
function autocomplete(partial) {
|
|
30659
30557
|
if (!partial) return null;
|
|
@@ -30662,19 +30560,19 @@ function autocomplete(partial) {
|
|
|
30662
30560
|
const base = basename6(normalized);
|
|
30663
30561
|
let entries;
|
|
30664
30562
|
try {
|
|
30665
|
-
entries =
|
|
30563
|
+
entries = readdirSync3(dir);
|
|
30666
30564
|
} catch {
|
|
30667
30565
|
return null;
|
|
30668
30566
|
}
|
|
30669
30567
|
const matches = entries.filter((e) => e.startsWith(base));
|
|
30670
30568
|
if (matches.length === 0) return null;
|
|
30671
|
-
if (matches.length === 1) return
|
|
30569
|
+
if (matches.length === 1) return join23(dir, matches[0]);
|
|
30672
30570
|
let prefix = matches[0];
|
|
30673
30571
|
for (const m of matches) {
|
|
30674
30572
|
while (!m.startsWith(prefix)) prefix = prefix.slice(0, -1);
|
|
30675
30573
|
if (!prefix) break;
|
|
30676
30574
|
}
|
|
30677
|
-
return prefix.length > base.length ?
|
|
30575
|
+
return prefix.length > base.length ? join23(dir, prefix) : null;
|
|
30678
30576
|
}
|
|
30679
30577
|
function PathPrompt({
|
|
30680
30578
|
defaultPath,
|
|
@@ -31877,8 +31775,8 @@ var init_run_print_files_helpers = __esm({
|
|
|
31877
31775
|
});
|
|
31878
31776
|
|
|
31879
31777
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
|
|
31880
|
-
import { writeFile as
|
|
31881
|
-
import { join as
|
|
31778
|
+
import { writeFile as writeFile7 } from "node:fs/promises";
|
|
31779
|
+
import { join as join24 } from "node:path";
|
|
31882
31780
|
function buildSavedCDF(components, tokens, opts = {}) {
|
|
31883
31781
|
const cdf = buildCDF2(components, toCdfTokens(tokens), opts);
|
|
31884
31782
|
if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
|
|
@@ -31890,7 +31788,7 @@ function buildSavedCDF(components, tokens, opts = {}) {
|
|
|
31890
31788
|
}
|
|
31891
31789
|
async function runPrintFiles(input, deps, onPatch) {
|
|
31892
31790
|
onPatch({ step: "printing" });
|
|
31893
|
-
const componentsPath =
|
|
31791
|
+
const componentsPath = join24(input.outDir, "components.json");
|
|
31894
31792
|
try {
|
|
31895
31793
|
const db = deps.openDb();
|
|
31896
31794
|
let components = [];
|
|
@@ -31974,10 +31872,10 @@ var init_save = __esm({
|
|
|
31974
31872
|
realSaveDeps = () => ({
|
|
31975
31873
|
openDb: openPipelineDb,
|
|
31976
31874
|
readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
|
|
31977
|
-
writeFile: (path5, contents) =>
|
|
31875
|
+
writeFile: (path5, contents) => writeFile7(path5, contents),
|
|
31978
31876
|
appendRun,
|
|
31979
31877
|
buildSourceFingerprint,
|
|
31980
|
-
sleep: (ms) => new Promise((
|
|
31878
|
+
sleep: (ms) => new Promise((resolve25) => setTimeout(resolve25, ms)),
|
|
31981
31879
|
warn: (message) => process.stderr.write(message)
|
|
31982
31880
|
});
|
|
31983
31881
|
}
|
|
@@ -31997,9 +31895,9 @@ var init_types9 = __esm({
|
|
|
31997
31895
|
|
|
31998
31896
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
|
|
31999
31897
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
32000
|
-
import { mkdir as
|
|
31898
|
+
import { mkdir as mkdir8 } from "node:fs/promises";
|
|
32001
31899
|
import { tmpdir } from "node:os";
|
|
32002
|
-
import { join as
|
|
31900
|
+
import { join as join25 } from "node:path";
|
|
32003
31901
|
function appendWizardLog(entry) {
|
|
32004
31902
|
appendFileSync(WIZARD_LOG, JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), ...entry }) + "\n");
|
|
32005
31903
|
}
|
|
@@ -32022,7 +31920,7 @@ function realFlowDeps() {
|
|
|
32022
31920
|
}
|
|
32023
31921
|
},
|
|
32024
31922
|
mkdir: async (path5) => {
|
|
32025
|
-
await
|
|
31923
|
+
await mkdir8(path5, { recursive: true });
|
|
32026
31924
|
},
|
|
32027
31925
|
detectSaveConflict,
|
|
32028
31926
|
buildTimestampedSubdir,
|
|
@@ -32273,7 +32171,7 @@ var init_controller = __esm({
|
|
|
32273
32171
|
init_push();
|
|
32274
32172
|
init_save();
|
|
32275
32173
|
init_types9();
|
|
32276
|
-
WIZARD_LOG =
|
|
32174
|
+
WIZARD_LOG = join25(tmpdir(), "experiences-import-wizard.log");
|
|
32277
32175
|
}
|
|
32278
32176
|
});
|
|
32279
32177
|
|
|
@@ -32305,13 +32203,183 @@ var init_use_flow = __esm({
|
|
|
32305
32203
|
}
|
|
32306
32204
|
});
|
|
32307
32205
|
|
|
32206
|
+
// packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
|
|
32207
|
+
async function readDebugModeSetting() {
|
|
32208
|
+
const { debugMode } = await readSettings2();
|
|
32209
|
+
return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
|
|
32210
|
+
}
|
|
32211
|
+
async function writeDebugModeSetting(setting) {
|
|
32212
|
+
await updateSettings2({ debugMode: setting });
|
|
32213
|
+
}
|
|
32214
|
+
var DEFAULT_DEBUG_MODE_SETTING;
|
|
32215
|
+
var init_debug_mode_store = __esm({
|
|
32216
|
+
"packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts"() {
|
|
32217
|
+
"use strict";
|
|
32218
|
+
init_config();
|
|
32219
|
+
DEFAULT_DEBUG_MODE_SETTING = {
|
|
32220
|
+
enabled: true
|
|
32221
|
+
};
|
|
32222
|
+
}
|
|
32223
|
+
});
|
|
32224
|
+
|
|
32225
|
+
// packages/experience-design-system-cli/src/tui/debug-store.ts
|
|
32226
|
+
import { mkdir as mkdir9, writeFile as writeFile8 } from "node:fs/promises";
|
|
32227
|
+
import { existsSync as existsSync11, readdirSync as readdirSync4 } from "node:fs";
|
|
32228
|
+
import { join as join26 } from "node:path";
|
|
32229
|
+
function generateRunId() {
|
|
32230
|
+
const now = /* @__PURE__ */ new Date();
|
|
32231
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
32232
|
+
return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
|
|
32233
|
+
}
|
|
32234
|
+
function datePrefix(now = /* @__PURE__ */ new Date()) {
|
|
32235
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
32236
|
+
return `${pad(now.getMonth() + 1)}-${pad(now.getDate())}-${now.getFullYear()}`;
|
|
32237
|
+
}
|
|
32238
|
+
function slugify(value) {
|
|
32239
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
32240
|
+
}
|
|
32241
|
+
function generateSessionId3() {
|
|
32242
|
+
const today = datePrefix();
|
|
32243
|
+
const root = debugSessionsDir2();
|
|
32244
|
+
const existing = existsSync11(root) ? readdirSync4(root) : [];
|
|
32245
|
+
const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
|
|
32246
|
+
const maxSeq = existing.reduce((max, entry) => {
|
|
32247
|
+
const match2 = seqPattern.exec(entry);
|
|
32248
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
32249
|
+
}, 0);
|
|
32250
|
+
return `${today}-session-${maxSeq + 1}`;
|
|
32251
|
+
}
|
|
32252
|
+
function sessionDebugDir() {
|
|
32253
|
+
return join26(debugSessionsDir2(), SESSION_ID);
|
|
32254
|
+
}
|
|
32255
|
+
function currentDebugSessionDir() {
|
|
32256
|
+
return sessionDebugDir();
|
|
32257
|
+
}
|
|
32258
|
+
async function isDebugModeEnabled() {
|
|
32259
|
+
try {
|
|
32260
|
+
return (await readDebugModeSetting()).enabled;
|
|
32261
|
+
} catch {
|
|
32262
|
+
return true;
|
|
32263
|
+
}
|
|
32264
|
+
}
|
|
32265
|
+
function redact(value) {
|
|
32266
|
+
const clone = { ...value };
|
|
32267
|
+
if ("cma_token" in clone) {
|
|
32268
|
+
const raw = clone.cma_token;
|
|
32269
|
+
clone.cma_token = typeof raw === "string" && raw.length > 0 ? `[present, ${raw.length} chars]` : "[not set]";
|
|
32270
|
+
}
|
|
32271
|
+
return clone;
|
|
32272
|
+
}
|
|
32273
|
+
function startDebugRun({
|
|
32274
|
+
flow,
|
|
32275
|
+
step,
|
|
32276
|
+
menuOption,
|
|
32277
|
+
inputs
|
|
32278
|
+
}) {
|
|
32279
|
+
const runId = generateRunId();
|
|
32280
|
+
const startedAt = Date.now();
|
|
32281
|
+
const redactedInputs = redact(inputs);
|
|
32282
|
+
isDebugModeEnabled().then((enabled) => {
|
|
32283
|
+
if (!enabled) return;
|
|
32284
|
+
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
32285
|
+
});
|
|
32286
|
+
}
|
|
32287
|
+
async function finishDebugRun({
|
|
32288
|
+
outputs,
|
|
32289
|
+
status,
|
|
32290
|
+
exitMethod
|
|
32291
|
+
}) {
|
|
32292
|
+
const run = pendingRun;
|
|
32293
|
+
if (!run) return;
|
|
32294
|
+
pendingRun = void 0;
|
|
32295
|
+
const durationMs = Date.now() - run.startedAt;
|
|
32296
|
+
const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
|
|
32297
|
+
const flowSegments = run.flow.split("/");
|
|
32298
|
+
const dir = join26(sessionDebugDir(), ...flowSegments);
|
|
32299
|
+
await mkdir9(dir, { recursive: true });
|
|
32300
|
+
const filename = nextAttemptFilename(dir, run.menuOption);
|
|
32301
|
+
await writeFile8(join26(dir, filename), content, { mode: 384 });
|
|
32302
|
+
}
|
|
32303
|
+
function nextAttemptFilename(dir, menuOption) {
|
|
32304
|
+
const today = datePrefix();
|
|
32305
|
+
const optionSlug = slugify(menuOption);
|
|
32306
|
+
const existing = existsSync11(dir) ? readdirSync4(dir) : [];
|
|
32307
|
+
const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
|
|
32308
|
+
const maxAttempt = existing.reduce((max, entry) => {
|
|
32309
|
+
const match2 = attemptPattern.exec(entry);
|
|
32310
|
+
return match2 ? Math.max(max, Number(match2[1])) : max;
|
|
32311
|
+
}, 0);
|
|
32312
|
+
return `${today}-${optionSlug}-attempt-${maxAttempt + 1}.md`;
|
|
32313
|
+
}
|
|
32314
|
+
function renderMarkdown(run, finish) {
|
|
32315
|
+
const stepMatch = /^(\d+)-(.+)$/.exec(run.step);
|
|
32316
|
+
const stepLabel2 = stepMatch ? `${stepMatch[1]} - ${stepMatch[2]}` : run.step;
|
|
32317
|
+
const flowSlug = run.flow.split("/").join("-");
|
|
32318
|
+
return `# Debug Log
|
|
32319
|
+
|
|
32320
|
+
- Run ID: ${run.runId}
|
|
32321
|
+
- Flow: ${flowSlug}
|
|
32322
|
+
- Step: ${stepLabel2}
|
|
32323
|
+
- Menu option: ${run.menuOption}
|
|
32324
|
+
- Date: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
32325
|
+
- CLI version: ${readPackageVersion()}
|
|
32326
|
+
- Platform: ${process.platform} / Node ${process.version}
|
|
32327
|
+
- Duration on screen: ${finish.durationMs}ms
|
|
32328
|
+
- Status: ${finish.status}
|
|
32329
|
+
- Exit method: ${finish.exitMethod}
|
|
32330
|
+
|
|
32331
|
+
## Inputs
|
|
32332
|
+
\`\`\`json
|
|
32333
|
+
${JSON.stringify(run.inputs, null, 2)}
|
|
32334
|
+
\`\`\`
|
|
32335
|
+
|
|
32336
|
+
## Outputs
|
|
32337
|
+
\`\`\`json
|
|
32338
|
+
${JSON.stringify(finish.outputs, null, 2)}
|
|
32339
|
+
\`\`\`
|
|
32340
|
+
`;
|
|
32341
|
+
}
|
|
32342
|
+
function handleCrash() {
|
|
32343
|
+
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
32344
|
+
}
|
|
32345
|
+
var pendingRun, SESSION_ID;
|
|
32346
|
+
var init_debug_store = __esm({
|
|
32347
|
+
"packages/experience-design-system-cli/src/tui/debug-store.ts"() {
|
|
32348
|
+
"use strict";
|
|
32349
|
+
init_config();
|
|
32350
|
+
init_version();
|
|
32351
|
+
init_debug_mode_store();
|
|
32352
|
+
SESSION_ID = generateSessionId3();
|
|
32353
|
+
void isDebugModeEnabled().then((enabled) => {
|
|
32354
|
+
if (!enabled) return void 0;
|
|
32355
|
+
return mkdir9(sessionDebugDir(), { recursive: true });
|
|
32356
|
+
});
|
|
32357
|
+
process.once("uncaughtException", (err) => {
|
|
32358
|
+
void handleCrash().finally(() => {
|
|
32359
|
+
throw err;
|
|
32360
|
+
});
|
|
32361
|
+
});
|
|
32362
|
+
process.once("unhandledRejection", (reason) => {
|
|
32363
|
+
void handleCrash().finally(() => {
|
|
32364
|
+
throw reason;
|
|
32365
|
+
});
|
|
32366
|
+
});
|
|
32367
|
+
process.once("SIGINT", () => {
|
|
32368
|
+
void handleCrash().finally(() => {
|
|
32369
|
+
process.exit(130);
|
|
32370
|
+
});
|
|
32371
|
+
});
|
|
32372
|
+
}
|
|
32373
|
+
});
|
|
32374
|
+
|
|
32308
32375
|
// packages/experience-design-system-cli/src/tui/help/help-info.ts
|
|
32309
32376
|
async function readHelpInfo() {
|
|
32310
32377
|
const debugMode = await readDebugModeSetting();
|
|
32311
32378
|
return {
|
|
32312
32379
|
storage: [
|
|
32313
32380
|
{ label: "Config folder", value: configRoot2() },
|
|
32314
|
-
{ label: "Settings file", value: configFilePath2() }
|
|
32381
|
+
{ label: "Settings file", value: configFilePath2() },
|
|
32382
|
+
{ label: "Debug logs", value: debugSessionsDir2() }
|
|
32315
32383
|
],
|
|
32316
32384
|
troubleshooting: [
|
|
32317
32385
|
{ label: "CLI version", value: readPackageVersion() },
|
|
@@ -32320,7 +32388,7 @@ async function readHelpInfo() {
|
|
|
32320
32388
|
{ label: "Debug Mode", value: debugMode.enabled ? "on" : "off" },
|
|
32321
32389
|
{
|
|
32322
32390
|
label: "This session",
|
|
32323
|
-
value:
|
|
32391
|
+
value: debugMode.enabled ? currentDebugSessionDir() : "no logs written while Debug Mode is off"
|
|
32324
32392
|
}
|
|
32325
32393
|
]
|
|
32326
32394
|
};
|
|
@@ -32477,8 +32545,7 @@ async function readCredentials() {
|
|
|
32477
32545
|
cmaToken: store.cmaToken || "",
|
|
32478
32546
|
host: store.host || "",
|
|
32479
32547
|
defaultComponentDir: store.defaultComponentDir || "",
|
|
32480
|
-
defaultTokenFile: store.defaultTokenFile || ""
|
|
32481
|
-
contentfulBaseDir: store.contentfulBaseDir || ""
|
|
32548
|
+
defaultTokenFile: store.defaultTokenFile || ""
|
|
32482
32549
|
};
|
|
32483
32550
|
}
|
|
32484
32551
|
async function writeCredentials(config) {
|
|
@@ -32511,8 +32578,7 @@ function debugFields(config) {
|
|
|
32511
32578
|
cma_token: config?.cmaToken ?? "",
|
|
32512
32579
|
host: config?.host ?? "",
|
|
32513
32580
|
default_component_dir: config?.defaultComponentDir ?? "",
|
|
32514
|
-
default_token_file: config?.defaultTokenFile ?? ""
|
|
32515
|
-
contentful_base_dir: config?.contentfulBaseDir ?? ""
|
|
32581
|
+
default_token_file: config?.defaultTokenFile ?? ""
|
|
32516
32582
|
};
|
|
32517
32583
|
}
|
|
32518
32584
|
function ConfigurationScreen({ onDone }) {
|
|
@@ -32550,7 +32616,6 @@ function ConfigurationScreen({ onDone }) {
|
|
|
32550
32616
|
setNotice(null);
|
|
32551
32617
|
writeCredentials(config).then(() => {
|
|
32552
32618
|
setLastSaved(config);
|
|
32553
|
-
if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir);
|
|
32554
32619
|
setNotice({ kind: "success", text: "Configuration saved" });
|
|
32555
32620
|
setStage("form");
|
|
32556
32621
|
}).catch((err) => {
|
|
@@ -32673,8 +32738,7 @@ var init_ContentfulConfigScreen = __esm({
|
|
|
32673
32738
|
"cmaToken",
|
|
32674
32739
|
"host",
|
|
32675
32740
|
"defaultComponentDir",
|
|
32676
|
-
"defaultTokenFile"
|
|
32677
|
-
"contentfulBaseDir"
|
|
32741
|
+
"defaultTokenFile"
|
|
32678
32742
|
];
|
|
32679
32743
|
FIELD_LABELS = {
|
|
32680
32744
|
spaceId: "Space ID",
|
|
@@ -32682,8 +32746,7 @@ var init_ContentfulConfigScreen = __esm({
|
|
|
32682
32746
|
cmaToken: "CMA Token",
|
|
32683
32747
|
host: "API Host (optional)",
|
|
32684
32748
|
defaultComponentDir: "Default component directory (optional)",
|
|
32685
|
-
defaultTokenFile: "Default token file (optional)"
|
|
32686
|
-
contentfulBaseDir: "Default project directory, where .contentful goes (optional)"
|
|
32749
|
+
defaultTokenFile: "Default token file (optional)"
|
|
32687
32750
|
};
|
|
32688
32751
|
}
|
|
32689
32752
|
});
|
|
@@ -33354,14 +33417,14 @@ function runDevWatch(args) {
|
|
|
33354
33417
|
process.stderr.write("--watch only works from a checkout of the repo (scripts/dev.mjs is not in the package).\n");
|
|
33355
33418
|
return Promise.resolve(1);
|
|
33356
33419
|
}
|
|
33357
|
-
return new Promise((
|
|
33420
|
+
return new Promise((resolve25) => {
|
|
33358
33421
|
const child = spawn2(process.execPath, [script, ...args], { stdio: "inherit" });
|
|
33359
33422
|
process.on("SIGINT", () => void 0);
|
|
33360
|
-
child.on("exit", (code) =>
|
|
33423
|
+
child.on("exit", (code) => resolve25(code ?? 0));
|
|
33361
33424
|
child.on("error", (err) => {
|
|
33362
33425
|
process.stderr.write(`${err.message}
|
|
33363
33426
|
`);
|
|
33364
|
-
|
|
33427
|
+
resolve25(1);
|
|
33365
33428
|
});
|
|
33366
33429
|
});
|
|
33367
33430
|
}
|