@contentful/experience-design-system-cli 2.41.1-dev-build-c9e39919.0 → 2.41.1-dev-build-3a724687.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 +163 -760
- package/dist/index.js +181 -802
- package/dist/package.json +1 -1
- package/dist/src/tui/debug-store.d.ts +0 -2
- package/dist/src/tui/import/steps/04-credentials/logic.d.ts +1 -23
- package/dist/src/tui/import/steps/04-credentials/screen.d.ts +1 -4
- package/dist/src/tui/import/steps/06-extraction/logic.d.ts +1 -14
- package/dist/src/tui/import/steps/08-generation/logic.d.ts +1 -8
- package/dist/src/tui/import/steps/09-review/use-review-session.d.ts +1 -3
- package/dist/src/tui/settings/configuration/agents/agent-debug.d.ts +1 -1
- package/package.json +3 -3
- package/dist/src/tui/import/steps/07-scope-gate/log.d.ts +0 -8
- package/dist/src/tui/import/steps/09-review/review-log.d.ts +0 -31
- package/dist/src/tui/import/steps/09-review/use-review-log.d.ts +0 -20
- package/dist/src/tui/import/steps/10-flow/flow/flow-log.d.ts +0 -46
- package/dist/src/tui/import/steps/10-flow/flow/use-flow-log.d.ts +0 -7
- /package/dist/src/tui/{shared → settings/shared}/debug-trail.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1986,9 +1986,12 @@ var init_schema = __esm({
|
|
|
1986
1986
|
$required: { type: "boolean" },
|
|
1987
1987
|
$default: {},
|
|
1988
1988
|
$values: { type: "array", items: { type: "string" } },
|
|
1989
|
-
"$token.kind": { type: "string" },
|
|
1989
|
+
"$token.kind": { type: "string", minLength: 1 },
|
|
1990
1990
|
"$token.allowed": { type: "array", items: { type: "string" } }
|
|
1991
1991
|
},
|
|
1992
|
+
// The API rejects a token property that does not say which kind of token it takes.
|
|
1993
|
+
if: { type: "object", properties: { $type: { const: "token" } }, required: ["$type"] },
|
|
1994
|
+
then: { type: "object", required: ["$token.kind"] },
|
|
1992
1995
|
additionalProperties: false
|
|
1993
1996
|
},
|
|
1994
1997
|
slot: {
|
|
@@ -14471,11 +14474,19 @@ var init_src = __esm({
|
|
|
14471
14474
|
}
|
|
14472
14475
|
});
|
|
14473
14476
|
|
|
14477
|
+
// packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/token-kinds/repair-token-kinds.js
|
|
14478
|
+
var init_repair_token_kinds = __esm({
|
|
14479
|
+
"packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/token-kinds/repair-token-kinds.js"() {
|
|
14480
|
+
"use strict";
|
|
14481
|
+
}
|
|
14482
|
+
});
|
|
14483
|
+
|
|
14474
14484
|
// packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/services/run-cdf-generation-service.js
|
|
14475
14485
|
var init_run_cdf_generation_service = __esm({
|
|
14476
14486
|
"packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/services/run-cdf-generation-service.js"() {
|
|
14477
14487
|
"use strict";
|
|
14478
14488
|
init_agents();
|
|
14489
|
+
init_repair_token_kinds();
|
|
14479
14490
|
}
|
|
14480
14491
|
});
|
|
14481
14492
|
|
|
@@ -15180,8 +15191,8 @@ function retryAfterMs(response) {
|
|
|
15180
15191
|
const value = response.headers?.get("retry-after")?.trim();
|
|
15181
15192
|
if (!value)
|
|
15182
15193
|
return void 0;
|
|
15183
|
-
const
|
|
15184
|
-
const delayMs = Number.isFinite(
|
|
15194
|
+
const seconds = Number(value);
|
|
15195
|
+
const delayMs = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(value) - Date.now();
|
|
15185
15196
|
if (!Number.isFinite(delayMs) || delayMs < 0 || delayMs > MAX_RETRY_AFTER_MS)
|
|
15186
15197
|
return void 0;
|
|
15187
15198
|
return Math.round(delayMs);
|
|
@@ -18053,10 +18064,10 @@ var init_read_candidate_files = __esm({
|
|
|
18053
18064
|
async function selectCompositionPromptFiles(components, sourceFiles) {
|
|
18054
18065
|
const allFiles = await readCandidateFiles(components, sourceFiles);
|
|
18055
18066
|
const selectedCandidates = selectCandidateFiles(allFiles).map((c2) => ({ path: c2.path, content: c2.content }));
|
|
18056
|
-
const
|
|
18057
|
-
const promptFiles =
|
|
18067
|
+
const capped = capCandidatesToPromptBudget(selectedCandidates);
|
|
18068
|
+
const promptFiles = capped.kept;
|
|
18058
18069
|
const runtimeFiles = allFiles.map((c2) => ({ path: c2.path, content: c2.content }));
|
|
18059
|
-
const droppedWarning =
|
|
18070
|
+
const droppedWarning = capped.dropped.length > 0 ? `composition \u2014 ${capped.dropped.length} candidate file(s) omitted from the agent prompt to fit the context budget; resolution runs on the ${promptFiles.length} highest-value files.` : void 0;
|
|
18060
18071
|
return { promptFiles, runtimeFiles, droppedWarning };
|
|
18061
18072
|
}
|
|
18062
18073
|
var init_select_composition_prompt_files = __esm({
|
|
@@ -19497,7 +19508,6 @@ __export(debug_store_exports, {
|
|
|
19497
19508
|
currentDebugSessionDir: () => currentDebugSessionDir,
|
|
19498
19509
|
currentSessionDir: () => currentSessionDir,
|
|
19499
19510
|
finishDebugRun: () => finishDebugRun,
|
|
19500
|
-
setDebugRunProgress: () => setDebugRunProgress,
|
|
19501
19511
|
startDebugRun: () => startDebugRun,
|
|
19502
19512
|
startDebugSessionIn: () => startDebugSessionIn,
|
|
19503
19513
|
startImportRun: () => startImportRun
|
|
@@ -19593,15 +19603,11 @@ function startDebugRun({
|
|
|
19593
19603
|
const runId = generateRunId();
|
|
19594
19604
|
const startedAt = Date.now();
|
|
19595
19605
|
const redactedInputs = redact(inputs);
|
|
19596
|
-
|
|
19597
|
-
|
|
19598
|
-
|
|
19599
|
-
if (!enabled && pendingRun === run) pendingRun = void 0;
|
|
19606
|
+
isDebugModeEnabled().then((enabled) => {
|
|
19607
|
+
if (!enabled) return;
|
|
19608
|
+
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
19600
19609
|
});
|
|
19601
19610
|
}
|
|
19602
|
-
function setDebugRunProgress(outputs) {
|
|
19603
|
-
if (pendingRun) pendingRun.progress = outputs;
|
|
19604
|
-
}
|
|
19605
19611
|
async function finishDebugRun({
|
|
19606
19612
|
outputs,
|
|
19607
19613
|
status,
|
|
@@ -19610,10 +19616,9 @@ async function finishDebugRun({
|
|
|
19610
19616
|
const run = pendingRun;
|
|
19611
19617
|
if (!run) return;
|
|
19612
19618
|
pendingRun = void 0;
|
|
19613
|
-
if (!await isDebugModeEnabled()) return;
|
|
19614
19619
|
const durationMs = Date.now() - run.startedAt;
|
|
19615
19620
|
const log = {
|
|
19616
|
-
flow:
|
|
19621
|
+
flow: run.flow,
|
|
19617
19622
|
menuOption: run.menuOption,
|
|
19618
19623
|
content: renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs })
|
|
19619
19624
|
};
|
|
@@ -19624,9 +19629,6 @@ async function finishDebugRun({
|
|
|
19624
19629
|
}
|
|
19625
19630
|
await writeLog(root, log);
|
|
19626
19631
|
}
|
|
19627
|
-
function logFolder(flow, step) {
|
|
19628
|
-
return flow.startsWith("import/") && /^\d+-/.test(step) ? `import/${step}` : flow;
|
|
19629
|
-
}
|
|
19630
19632
|
async function writeLog(root, log) {
|
|
19631
19633
|
const dir = join19(root, ...log.flow.split("/"));
|
|
19632
19634
|
await mkdir7(dir, { recursive: true });
|
|
@@ -19683,7 +19685,7 @@ ${JSON.stringify(finish.outputs, null, 2)}
|
|
|
19683
19685
|
`;
|
|
19684
19686
|
}
|
|
19685
19687
|
function handleCrash() {
|
|
19686
|
-
return finishDebugRun({ outputs:
|
|
19688
|
+
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
19687
19689
|
}
|
|
19688
19690
|
var pendingRun, sessionDir, WAITING_LIMIT, waiting;
|
|
19689
19691
|
var init_debug_store = __esm({
|
|
@@ -19727,17 +19729,11 @@ var init_debug_store = __esm({
|
|
|
19727
19729
|
throw reason;
|
|
19728
19730
|
});
|
|
19729
19731
|
});
|
|
19730
|
-
|
|
19731
|
-
|
|
19732
|
-
|
|
19733
|
-
["SIGHUP", 129]
|
|
19734
|
-
]) {
|
|
19735
|
-
process.once(signal, () => {
|
|
19736
|
-
void handleCrash().finally(() => {
|
|
19737
|
-
process.exit(exitCode);
|
|
19738
|
-
});
|
|
19732
|
+
process.once("SIGINT", () => {
|
|
19733
|
+
void handleCrash().finally(() => {
|
|
19734
|
+
process.exit(130);
|
|
19739
19735
|
});
|
|
19740
|
-
}
|
|
19736
|
+
});
|
|
19741
19737
|
}
|
|
19742
19738
|
});
|
|
19743
19739
|
|
|
@@ -20141,8 +20137,8 @@ function progressPercent(progress) {
|
|
|
20141
20137
|
}
|
|
20142
20138
|
function formatElapsed(totalSeconds) {
|
|
20143
20139
|
const minutes = Math.floor(totalSeconds / 60);
|
|
20144
|
-
const
|
|
20145
|
-
return minutes > 0 ? `${minutes}m ${
|
|
20140
|
+
const seconds = totalSeconds % 60;
|
|
20141
|
+
return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
|
|
20146
20142
|
}
|
|
20147
20143
|
var init_logic4 = __esm({
|
|
20148
20144
|
"packages/experience-design-system-cli/src/tui/import/shared/running-step/logic.ts"() {
|
|
@@ -20172,12 +20168,12 @@ var init_theme2 = __esm({
|
|
|
20172
20168
|
// packages/experience-design-system-cli/src/tui/import/shared/running-step/use-elapsed.ts
|
|
20173
20169
|
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
20174
20170
|
function useElapsed() {
|
|
20175
|
-
const [
|
|
20171
|
+
const [seconds, setSeconds] = useState3(0);
|
|
20176
20172
|
useEffect3(() => {
|
|
20177
20173
|
const timer = setInterval(() => setSeconds((current) => current + 1), 1e3);
|
|
20178
20174
|
return () => clearInterval(timer);
|
|
20179
20175
|
}, []);
|
|
20180
|
-
return formatElapsed(
|
|
20176
|
+
return formatElapsed(seconds);
|
|
20181
20177
|
}
|
|
20182
20178
|
var init_use_elapsed = __esm({
|
|
20183
20179
|
"packages/experience-design-system-cli/src/tui/import/shared/running-step/use-elapsed.ts"() {
|
|
@@ -21092,45 +21088,6 @@ var init_FieldForm = __esm({
|
|
|
21092
21088
|
}
|
|
21093
21089
|
});
|
|
21094
21090
|
|
|
21095
|
-
// packages/experience-design-system-cli/src/tui/shared/debug-trail.ts
|
|
21096
|
-
import { existsSync as existsSync10 } from "node:fs";
|
|
21097
|
-
function diffSnapshots(before, after) {
|
|
21098
|
-
const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
|
|
21099
|
-
const changed_fields = names.filter((name) => before[name] !== after[name]);
|
|
21100
|
-
return { changed: changed_fields.length > 0, changed_fields };
|
|
21101
|
-
}
|
|
21102
|
-
function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
|
|
21103
|
-
const actions = [];
|
|
21104
|
-
return {
|
|
21105
|
-
record(action) {
|
|
21106
|
-
actions.push(action);
|
|
21107
|
-
if (actions.length > limit) actions.shift();
|
|
21108
|
-
},
|
|
21109
|
-
entries: () => [...actions]
|
|
21110
|
-
};
|
|
21111
|
-
}
|
|
21112
|
-
function scrubError(error, secrets) {
|
|
21113
|
-
let message = error instanceof Error ? error.message : String(error);
|
|
21114
|
-
for (const secret of secrets) {
|
|
21115
|
-
if (secret.length < MIN_SECRET_LENGTH) continue;
|
|
21116
|
-
for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
|
|
21117
|
-
}
|
|
21118
|
-
return message;
|
|
21119
|
-
}
|
|
21120
|
-
function describeSettingsFile() {
|
|
21121
|
-
const path5 = configFilePath2();
|
|
21122
|
-
return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync10(path5) };
|
|
21123
|
-
}
|
|
21124
|
-
var DEFAULT_TRAIL_LIMIT, MIN_SECRET_LENGTH;
|
|
21125
|
-
var init_debug_trail = __esm({
|
|
21126
|
-
"packages/experience-design-system-cli/src/tui/shared/debug-trail.ts"() {
|
|
21127
|
-
"use strict";
|
|
21128
|
-
init_config();
|
|
21129
|
-
DEFAULT_TRAIL_LIMIT = 30;
|
|
21130
|
-
MIN_SECRET_LENGTH = 6;
|
|
21131
|
-
}
|
|
21132
|
-
});
|
|
21133
|
-
|
|
21134
21091
|
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
|
|
21135
21092
|
function credentialsPurpose(tokensOnly) {
|
|
21136
21093
|
const use = tokensOnly ? "We use it to push your design tokens" : "We use it to check what components already exist and to push your import";
|
|
@@ -21144,42 +21101,17 @@ function normalize(values) {
|
|
|
21144
21101
|
host: toConfiguredHost2(values.host) ?? DEFAULT_CONFIGURED_HOST
|
|
21145
21102
|
};
|
|
21146
21103
|
}
|
|
21147
|
-
function
|
|
21148
|
-
return
|
|
21104
|
+
function missingField(values) {
|
|
21105
|
+
return values.spaceId === "" || values.environmentId === "" || values.cmaToken === "";
|
|
21149
21106
|
}
|
|
21150
21107
|
function isUnchanged(current, initial) {
|
|
21151
21108
|
return FIELDS.every((field) => current[field] === initial[field]);
|
|
21152
21109
|
}
|
|
21153
|
-
function rejectedAttempt(reason, credentials) {
|
|
21154
|
-
return { host: credentials.host, reason: scrubError(reason, [credentials.cmaToken]) };
|
|
21155
|
-
}
|
|
21156
|
-
function credentialsLog(credentials) {
|
|
21157
|
-
return {
|
|
21158
|
-
space_id: credentials.spaceId,
|
|
21159
|
-
environment_id: credentials.environmentId,
|
|
21160
|
-
host: credentials.host,
|
|
21161
|
-
cma_token: credentials.cmaToken
|
|
21162
|
-
};
|
|
21163
|
-
}
|
|
21164
|
-
function credentialsOutputs({
|
|
21165
|
-
outcome,
|
|
21166
|
-
credentials,
|
|
21167
|
-
initial,
|
|
21168
|
-
attempts
|
|
21169
|
-
}) {
|
|
21170
|
-
return {
|
|
21171
|
-
outcome,
|
|
21172
|
-
...credentialsLog(credentials),
|
|
21173
|
-
changed_fields: diffSnapshots(initial, credentials).changed_fields,
|
|
21174
|
-
rejected_attempts: attempts
|
|
21175
|
-
};
|
|
21176
|
-
}
|
|
21177
21110
|
var FIELDS;
|
|
21178
21111
|
var init_logic8 = __esm({
|
|
21179
21112
|
"packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts"() {
|
|
21180
21113
|
"use strict";
|
|
21181
21114
|
init_src3();
|
|
21182
|
-
init_debug_trail();
|
|
21183
21115
|
FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
|
|
21184
21116
|
}
|
|
21185
21117
|
});
|
|
@@ -21232,11 +21164,10 @@ var init_validate4 = __esm({
|
|
|
21232
21164
|
});
|
|
21233
21165
|
|
|
21234
21166
|
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
|
|
21235
|
-
import {
|
|
21167
|
+
import { useRef as useRef5, useState as useState9 } from "react";
|
|
21236
21168
|
import { Box as Box14, Text as Text14, useInput as useInput11 } from "ink";
|
|
21237
21169
|
import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
21238
21170
|
function CredentialsScreen({
|
|
21239
|
-
mode,
|
|
21240
21171
|
onDone,
|
|
21241
21172
|
onBack,
|
|
21242
21173
|
initial = {},
|
|
@@ -21259,64 +21190,17 @@ function CredentialsScreen({
|
|
|
21259
21190
|
const [focus, setFocus] = useState9(0);
|
|
21260
21191
|
const [active, setActive] = useState9(0);
|
|
21261
21192
|
const [beforeEdit, setBeforeEdit] = useState9(initialValues);
|
|
21262
|
-
const visit = useRef5({ attempts: [], lastReason: "" }).current;
|
|
21263
|
-
useEffect8(() => {
|
|
21264
|
-
startDebugRun({
|
|
21265
|
-
flow: "import/credentials",
|
|
21266
|
-
step: "04-credentials",
|
|
21267
|
-
menuOption: "Credentials",
|
|
21268
|
-
inputs: { import_mode: mode, prefilled, ...credentialsLog(initialValues) }
|
|
21269
|
-
});
|
|
21270
|
-
}, []);
|
|
21271
|
-
const reject = (attempt, text) => {
|
|
21272
|
-
if (visit.attempts.length < MAX_LOGGED_ATTEMPTS2) visit.attempts.push(attempt);
|
|
21273
|
-
visit.lastReason = attempt.reason;
|
|
21274
|
-
setNotice({ kind: "error", text });
|
|
21275
|
-
};
|
|
21276
|
-
const leave = () => {
|
|
21277
|
-
void finishDebugRun({
|
|
21278
|
-
outputs: {
|
|
21279
|
-
...credentialsOutputs({
|
|
21280
|
-
outcome: "back",
|
|
21281
|
-
credentials: normalize(values),
|
|
21282
|
-
initial: initialValues,
|
|
21283
|
-
attempts: visit.attempts
|
|
21284
|
-
}),
|
|
21285
|
-
...notice ? { error: visit.lastReason } : {}
|
|
21286
|
-
},
|
|
21287
|
-
status: notice ? "error" : "success",
|
|
21288
|
-
exitMethod: "discarded"
|
|
21289
|
-
});
|
|
21290
|
-
onBack();
|
|
21291
|
-
};
|
|
21292
21193
|
const submit = async () => {
|
|
21293
21194
|
const credentials = normalize(values);
|
|
21294
|
-
|
|
21295
|
-
|
|
21296
|
-
reject(
|
|
21297
|
-
rejectedAttempt(`Missing required fields: ${missing.join(", ")}`, credentials),
|
|
21298
|
-
"Space ID, environment and CMA token are all required."
|
|
21299
|
-
);
|
|
21195
|
+
if (missingField(credentials)) {
|
|
21196
|
+
setNotice({ kind: "error", text: "Space ID, environment and CMA token are all required." });
|
|
21300
21197
|
return;
|
|
21301
21198
|
}
|
|
21302
21199
|
setValidating(true);
|
|
21303
21200
|
const result = await validate3(credentials);
|
|
21304
21201
|
setValidating(false);
|
|
21305
|
-
if (
|
|
21306
|
-
|
|
21307
|
-
return;
|
|
21308
|
-
}
|
|
21309
|
-
void finishDebugRun({
|
|
21310
|
-
outputs: credentialsOutputs({
|
|
21311
|
-
outcome: "validated",
|
|
21312
|
-
credentials,
|
|
21313
|
-
initial: initialValues,
|
|
21314
|
-
attempts: visit.attempts
|
|
21315
|
-
}),
|
|
21316
|
-
status: "success",
|
|
21317
|
-
exitMethod: "saved"
|
|
21318
|
-
});
|
|
21319
|
-
onDone({ skipped: false, credentials });
|
|
21202
|
+
if (result.ok) onDone({ skipped: false, credentials });
|
|
21203
|
+
else setNotice({ kind: "error", text: result.error });
|
|
21320
21204
|
};
|
|
21321
21205
|
const choose = (choice) => {
|
|
21322
21206
|
if (choice === "continue") void submit();
|
|
@@ -21325,7 +21209,7 @@ function CredentialsScreen({
|
|
|
21325
21209
|
setBeforeEdit(values);
|
|
21326
21210
|
setActive(0);
|
|
21327
21211
|
setEditing(true);
|
|
21328
|
-
} else
|
|
21212
|
+
} else onBack();
|
|
21329
21213
|
};
|
|
21330
21214
|
const stopEditing = () => {
|
|
21331
21215
|
setEditing(false);
|
|
@@ -21335,7 +21219,7 @@ function CredentialsScreen({
|
|
|
21335
21219
|
if (validating) return;
|
|
21336
21220
|
if (editing) {
|
|
21337
21221
|
if (key.escape) {
|
|
21338
|
-
if (!prefilled)
|
|
21222
|
+
if (!prefilled) onBack();
|
|
21339
21223
|
else {
|
|
21340
21224
|
setValues(beforeEdit);
|
|
21341
21225
|
setNotice(null);
|
|
@@ -21441,12 +21325,11 @@ function CredentialsScreen({
|
|
|
21441
21325
|
] })
|
|
21442
21326
|
] });
|
|
21443
21327
|
}
|
|
21444
|
-
var FIELDS2, MENU
|
|
21328
|
+
var FIELDS2, MENU;
|
|
21445
21329
|
var init_screen5 = __esm({
|
|
21446
21330
|
"packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx"() {
|
|
21447
21331
|
"use strict";
|
|
21448
21332
|
init_theme();
|
|
21449
|
-
init_debug_store();
|
|
21450
21333
|
init_FieldForm();
|
|
21451
21334
|
init_ClearableTextInput();
|
|
21452
21335
|
init_ControlHints();
|
|
@@ -21463,52 +21346,10 @@ var init_screen5 = __esm({
|
|
|
21463
21346
|
{ choice: "continue", label: "Continue", description: "Check the credentials and go on" },
|
|
21464
21347
|
{ choice: "edit", label: "Edit", description: "Change the credentials" }
|
|
21465
21348
|
];
|
|
21466
|
-
MAX_LOGGED_ATTEMPTS2 = 10;
|
|
21467
21349
|
}
|
|
21468
21350
|
});
|
|
21469
21351
|
|
|
21470
21352
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/logic.ts
|
|
21471
|
-
function extractionLogInputs(input) {
|
|
21472
|
-
const { credentials } = input;
|
|
21473
|
-
return {
|
|
21474
|
-
project_path: input.projectPath,
|
|
21475
|
-
out_dir: input.outDir ?? "",
|
|
21476
|
-
files_to_scan: input.filePaths.length,
|
|
21477
|
-
raw_tokens_path: input.rawTokensPath,
|
|
21478
|
-
agent: input.agent,
|
|
21479
|
-
agent_model: input.agentModel ?? "",
|
|
21480
|
-
prompt_overrides: input.promptOverrides,
|
|
21481
|
-
cache: !input.noCache,
|
|
21482
|
-
has_credentials: credentials !== null,
|
|
21483
|
-
space_id: credentials?.spaceId ?? "",
|
|
21484
|
-
environment_id: credentials?.environmentId ?? "",
|
|
21485
|
-
host: credentials?.host ?? "",
|
|
21486
|
-
cma_token: credentials?.cmaToken ?? ""
|
|
21487
|
-
};
|
|
21488
|
-
}
|
|
21489
|
-
function extractionLogOutputs(result, progress, cmaToken) {
|
|
21490
|
-
const last = progress ? { final_progress: progress } : {};
|
|
21491
|
-
if (!result.ok) {
|
|
21492
|
-
return {
|
|
21493
|
-
outputs: { result: "failed", failed_step: result.step, error: scrubError(result.message, [cmaToken]), ...last },
|
|
21494
|
-
status: "error"
|
|
21495
|
-
};
|
|
21496
|
-
}
|
|
21497
|
-
const { extraction } = result;
|
|
21498
|
-
return {
|
|
21499
|
-
outputs: {
|
|
21500
|
-
result: "done",
|
|
21501
|
-
session_id: extraction.sessionId,
|
|
21502
|
-
out_dir: extraction.outDir,
|
|
21503
|
-
tokens_path: extraction.tokensPath,
|
|
21504
|
-
token_count: extraction.tokenCount,
|
|
21505
|
-
existing_entities_status: extraction.existingEntitiesStatus,
|
|
21506
|
-
composition_phase: extraction.compositionPhase,
|
|
21507
|
-
...last
|
|
21508
|
-
},
|
|
21509
|
-
status: "success"
|
|
21510
|
-
};
|
|
21511
|
-
}
|
|
21512
21353
|
function initialProgress(input) {
|
|
21513
21354
|
return {
|
|
21514
21355
|
scan: null,
|
|
@@ -21592,7 +21433,6 @@ var init_logic9 = __esm({
|
|
|
21592
21433
|
"packages/experience-design-system-cli/src/tui/import/steps/06-extraction/logic.ts"() {
|
|
21593
21434
|
"use strict";
|
|
21594
21435
|
init_src3();
|
|
21595
|
-
init_debug_trail();
|
|
21596
21436
|
}
|
|
21597
21437
|
});
|
|
21598
21438
|
|
|
@@ -21680,7 +21520,7 @@ var init_load = __esm({
|
|
|
21680
21520
|
});
|
|
21681
21521
|
|
|
21682
21522
|
// packages/experience-design-system-cli/src/tui/import/steps/05-token-review/screen.tsx
|
|
21683
|
-
import {
|
|
21523
|
+
import { useMemo as useMemo2, useState as useState10 } from "react";
|
|
21684
21524
|
import { Box as Box15, Text as Text15, useInput as useInput12 } from "ink";
|
|
21685
21525
|
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
21686
21526
|
function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
|
|
@@ -21688,31 +21528,12 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
|
|
|
21688
21528
|
const rows = loaded.ok ? loaded.rows : [];
|
|
21689
21529
|
const columns = useTerminalWidth();
|
|
21690
21530
|
const [selected, setSelected] = useState10(0);
|
|
21691
|
-
useEffect9(() => {
|
|
21692
|
-
startDebugRun({
|
|
21693
|
-
flow: "import/token-review",
|
|
21694
|
-
step: "05-token-review",
|
|
21695
|
-
menuOption: "Token review",
|
|
21696
|
-
inputs: { import_mode: "tokens", tokens_path: tokensPath }
|
|
21697
|
-
});
|
|
21698
|
-
}, []);
|
|
21699
|
-
const finish = (outcome) => {
|
|
21700
|
-
void finishDebugRun({
|
|
21701
|
-
outputs: { outcome, ...loaded.ok ? { tokens: rows.length } : { load_error: loaded.message } },
|
|
21702
|
-
status: loaded.ok ? "success" : "error",
|
|
21703
|
-
exitMethod: outcome === "continued" ? "saved" : "discarded"
|
|
21704
|
-
});
|
|
21705
|
-
};
|
|
21706
21531
|
const move = (to) => setSelected(Math.max(0, Math.min(to, rows.length - 1)));
|
|
21707
21532
|
const { start, end } = computeColumnWindow(rows.length, selected, VISIBLE_ROWS);
|
|
21708
21533
|
useInput12((_input, key) => {
|
|
21709
|
-
if (key.return)
|
|
21710
|
-
|
|
21711
|
-
|
|
21712
|
-
} else if (key.escape) {
|
|
21713
|
-
finish("back");
|
|
21714
|
-
onQuit();
|
|
21715
|
-
} else if (key.upArrow) move(selected - 1);
|
|
21534
|
+
if (key.return) onContinue();
|
|
21535
|
+
else if (key.escape) onQuit();
|
|
21536
|
+
else if (key.upArrow) move(selected - 1);
|
|
21716
21537
|
else if (key.downArrow) move(selected + 1);
|
|
21717
21538
|
else if (key.pageUp) move(selected - VISIBLE_ROWS);
|
|
21718
21539
|
else if (key.pageDown) move(selected + VISIBLE_ROWS);
|
|
@@ -21776,7 +21597,6 @@ var init_screen7 = __esm({
|
|
|
21776
21597
|
"packages/experience-design-system-cli/src/tui/import/steps/05-token-review/screen.tsx"() {
|
|
21777
21598
|
"use strict";
|
|
21778
21599
|
init_theme();
|
|
21779
|
-
init_debug_store();
|
|
21780
21600
|
init_ControlHints();
|
|
21781
21601
|
init_StepHeader();
|
|
21782
21602
|
init_use_terminal_width();
|
|
@@ -21802,7 +21622,7 @@ var init_steps = __esm({
|
|
|
21802
21622
|
});
|
|
21803
21623
|
|
|
21804
21624
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
|
|
21805
|
-
import { existsSync as
|
|
21625
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
21806
21626
|
import { dirname as dirname16, join as join20, resolve as resolve22 } from "node:path";
|
|
21807
21627
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
21808
21628
|
function findSkillPath(fileName) {
|
|
@@ -21810,7 +21630,7 @@ function findSkillPath(fileName) {
|
|
|
21810
21630
|
let dir = thisDir;
|
|
21811
21631
|
for (; ; ) {
|
|
21812
21632
|
const candidate = join20(dir, "skills", fileName);
|
|
21813
|
-
if (
|
|
21633
|
+
if (existsSync10(candidate)) return candidate;
|
|
21814
21634
|
const parent = resolve22(dir, "..");
|
|
21815
21635
|
if (parent === dir) {
|
|
21816
21636
|
throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
|
|
@@ -22074,11 +21894,11 @@ var init_run = __esm({
|
|
|
22074
21894
|
});
|
|
22075
21895
|
|
|
22076
21896
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
|
|
22077
|
-
import { useEffect as
|
|
21897
|
+
import { useEffect as useEffect8, useRef as useRef6, useState as useState11 } from "react";
|
|
22078
21898
|
function useExtraction(input) {
|
|
22079
21899
|
const [state2, setState] = useState11();
|
|
22080
21900
|
const current = useRef6();
|
|
22081
|
-
|
|
21901
|
+
useEffect8(() => {
|
|
22082
21902
|
current.current = input;
|
|
22083
21903
|
if (!input) {
|
|
22084
21904
|
setState(void 0);
|
|
@@ -22091,23 +21911,10 @@ function useExtraction(input) {
|
|
|
22091
21911
|
hasRawTokens: input.rawTokensPath !== ""
|
|
22092
21912
|
})
|
|
22093
21913
|
});
|
|
22094
|
-
let lastProgress;
|
|
22095
|
-
startDebugRun({
|
|
22096
|
-
flow: "import/extraction",
|
|
22097
|
-
step: "06-extraction",
|
|
22098
|
-
menuOption: "Extraction",
|
|
22099
|
-
inputs: extractionLogInputs(input)
|
|
22100
|
-
});
|
|
22101
21914
|
void runExtraction(input, (progress) => {
|
|
22102
|
-
lastProgress = progress;
|
|
22103
21915
|
if (current.current === input) setState({ status: "running", progress });
|
|
22104
21916
|
}).then((result) => {
|
|
22105
|
-
if (current.current
|
|
22106
|
-
void finishDebugRun({
|
|
22107
|
-
...extractionLogOutputs(result, lastProgress, input.credentials?.cmaToken ?? ""),
|
|
22108
|
-
exitMethod: result.ok ? "saved" : "discarded"
|
|
22109
|
-
});
|
|
22110
|
-
setState({ status: "done", result });
|
|
21917
|
+
if (current.current === input) setState({ status: "done", result });
|
|
22111
21918
|
});
|
|
22112
21919
|
return () => {
|
|
22113
21920
|
if (current.current === input) current.current = void 0;
|
|
@@ -22118,7 +21925,6 @@ function useExtraction(input) {
|
|
|
22118
21925
|
var init_use_extraction = __esm({
|
|
22119
21926
|
"packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts"() {
|
|
22120
21927
|
"use strict";
|
|
22121
|
-
init_debug_store();
|
|
22122
21928
|
init_logic9();
|
|
22123
21929
|
init_run();
|
|
22124
21930
|
}
|
|
@@ -22163,11 +21969,11 @@ var init_run_tokens_only = __esm({
|
|
|
22163
21969
|
});
|
|
22164
21970
|
|
|
22165
21971
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-tokens-only.ts
|
|
22166
|
-
import { useEffect as
|
|
21972
|
+
import { useEffect as useEffect9, useRef as useRef7, useState as useState12 } from "react";
|
|
22167
21973
|
function useTokensOnly(input) {
|
|
22168
21974
|
const [state2, setState] = useState12();
|
|
22169
21975
|
const current = useRef7();
|
|
22170
|
-
|
|
21976
|
+
useEffect9(() => {
|
|
22171
21977
|
current.current = input;
|
|
22172
21978
|
if (!input) {
|
|
22173
21979
|
setState(void 0);
|
|
@@ -22190,39 +21996,6 @@ var init_use_tokens_only = __esm({
|
|
|
22190
21996
|
}
|
|
22191
21997
|
});
|
|
22192
21998
|
|
|
22193
|
-
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/log.ts
|
|
22194
|
-
function scopeGateLogInputs(components, tokenCount) {
|
|
22195
|
-
const ai = { accepted: 0, rejected: 0, failed: 0, none: 0 };
|
|
22196
|
-
for (const component of components) ai[component.aiDecision ?? "none"] += 1;
|
|
22197
|
-
return {
|
|
22198
|
-
components_found: components.length,
|
|
22199
|
-
ai_suggestions: ai,
|
|
22200
|
-
needs_review: components.filter((component) => component.needsReview === true).length,
|
|
22201
|
-
tokens: tokenCount
|
|
22202
|
-
};
|
|
22203
|
-
}
|
|
22204
|
-
function scopeGateLogOutputs(components, decisions) {
|
|
22205
|
-
const suggested = new Map(components.map((component) => [component.name, component.aiDecision]));
|
|
22206
|
-
return {
|
|
22207
|
-
outcome: "continued",
|
|
22208
|
-
accepted: new Set(decisions.accepted).size,
|
|
22209
|
-
rejected: new Set(decisions.rejected).size,
|
|
22210
|
-
accepted_although_ai_rejected: capped(decisions.accepted.filter((name) => suggested.get(name) === "rejected")),
|
|
22211
|
-
not_accepted_although_ai_accepted: capped(decisions.rejected.filter((name) => suggested.get(name) === "accepted"))
|
|
22212
|
-
};
|
|
22213
|
-
}
|
|
22214
|
-
var MAX_NAMES, capped;
|
|
22215
|
-
var init_log = __esm({
|
|
22216
|
-
"packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/log.ts"() {
|
|
22217
|
-
"use strict";
|
|
22218
|
-
MAX_NAMES = 20;
|
|
22219
|
-
capped = (names) => {
|
|
22220
|
-
const unique = [...new Set(names)];
|
|
22221
|
-
return { count: unique.length, names: unique.slice(0, MAX_NAMES) };
|
|
22222
|
-
};
|
|
22223
|
-
}
|
|
22224
|
-
});
|
|
22225
|
-
|
|
22226
21999
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/components/windowed-panel.tsx
|
|
22227
22000
|
import { Box as Box16, Text as Text16 } from "ink";
|
|
22228
22001
|
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
@@ -23477,7 +23250,7 @@ var init_useImmediateInput = __esm({
|
|
|
23477
23250
|
|
|
23478
23251
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/hooks/use-terminal-size.ts
|
|
23479
23252
|
import { useStdout as useStdout2 } from "ink";
|
|
23480
|
-
import { useEffect as
|
|
23253
|
+
import { useEffect as useEffect10, useState as useState13 } from "react";
|
|
23481
23254
|
function readTerminalSize(stdout) {
|
|
23482
23255
|
return {
|
|
23483
23256
|
columns: stdout?.columns ?? 80,
|
|
@@ -23487,7 +23260,7 @@ function readTerminalSize(stdout) {
|
|
|
23487
23260
|
function useTerminalSize() {
|
|
23488
23261
|
const { stdout } = useStdout2();
|
|
23489
23262
|
const [size, setSize] = useState13(() => readTerminalSize(stdout));
|
|
23490
|
-
|
|
23263
|
+
useEffect10(() => {
|
|
23491
23264
|
const updateSize = () => setSize(readTerminalSize(stdout));
|
|
23492
23265
|
stdout?.on("resize", updateSize);
|
|
23493
23266
|
updateSize();
|
|
@@ -24489,7 +24262,7 @@ var init_state = __esm({
|
|
|
24489
24262
|
});
|
|
24490
24263
|
|
|
24491
24264
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
|
|
24492
|
-
import { useEffect as
|
|
24265
|
+
import { useEffect as useEffect11, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
|
|
24493
24266
|
function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }) {
|
|
24494
24267
|
const { columns: totalWidth, rows: terminalRows } = useTerminalSize();
|
|
24495
24268
|
const columnPlan = useMemo3(
|
|
@@ -24536,7 +24309,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
|
|
|
24536
24309
|
return seed;
|
|
24537
24310
|
});
|
|
24538
24311
|
const seededGroupsRef = useRef9(closures.size > 0 || cycleParticipants.size > 0);
|
|
24539
|
-
|
|
24312
|
+
useEffect11(() => {
|
|
24540
24313
|
if (seededGroupsRef.current) return;
|
|
24541
24314
|
if (closures.size === 0 && cycleParticipants.size === 0) return;
|
|
24542
24315
|
seededGroupsRef.current = true;
|
|
@@ -24627,7 +24400,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
|
|
|
24627
24400
|
entryCount: 0
|
|
24628
24401
|
});
|
|
24629
24402
|
const panelLayout = useMemo3(() => computePanelLayout(visibleCount), [visibleCount]);
|
|
24630
|
-
|
|
24403
|
+
useEffect11(() => {
|
|
24631
24404
|
setNav((prev) => {
|
|
24632
24405
|
const maxIdx = Math.max(0, visibleRows.length - 1);
|
|
24633
24406
|
const nextCursor = Math.min(prev.cursor, maxIdx);
|
|
@@ -24972,59 +24745,27 @@ var init_use_scope_gate = __esm({
|
|
|
24972
24745
|
});
|
|
24973
24746
|
|
|
24974
24747
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/screen.tsx
|
|
24975
|
-
import {
|
|
24748
|
+
import { useMemo as useMemo4 } from "react";
|
|
24976
24749
|
import { Box as Box25, Text as Text26 } from "ink";
|
|
24977
24750
|
import { Fragment as Fragment5, jsx as jsx29, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
24978
24751
|
function ScopeGateScreen(props) {
|
|
24979
|
-
if (props.components.length === 0)
|
|
24752
|
+
if (props.components.length === 0) {
|
|
24753
|
+
return /* @__PURE__ */ jsx29(Box25, { paddingX: 2, paddingY: 1, children: /* @__PURE__ */ jsx29(Text26, { color: PALETTE.error, children: "Error: no components found for this session \u2014 please re-run analyze extract." }) });
|
|
24754
|
+
}
|
|
24980
24755
|
return /* @__PURE__ */ jsx29(ScopeGateView, { ...props });
|
|
24981
24756
|
}
|
|
24982
|
-
function NoComponents() {
|
|
24983
|
-
useEffect14(() => {
|
|
24984
|
-
startDebugRun({
|
|
24985
|
-
flow: "import/scope-gate",
|
|
24986
|
-
step: "07-scope-gate",
|
|
24987
|
-
menuOption: "Scope gate",
|
|
24988
|
-
inputs: scopeGateLogInputs([], 0)
|
|
24989
|
-
});
|
|
24990
|
-
void finishDebugRun({
|
|
24991
|
-
outputs: { outcome: "nothing to decide", error: "No components were found for this session." },
|
|
24992
|
-
status: "error",
|
|
24993
|
-
exitMethod: "discarded"
|
|
24994
|
-
});
|
|
24995
|
-
}, []);
|
|
24996
|
-
return /* @__PURE__ */ jsx29(Box25, { paddingX: 2, paddingY: 1, children: /* @__PURE__ */ jsx29(Text26, { color: PALETTE.error, children: "Error: no components found for this session \u2014 please re-run analyze extract." }) });
|
|
24997
|
-
}
|
|
24998
24757
|
function ScopeGateView({ components, tokensPath, onConfirm, onQuit }) {
|
|
24999
24758
|
const tokens = useMemo4(() => {
|
|
25000
24759
|
const loaded = tokensPath ? loadTokenRows(tokensPath) : void 0;
|
|
25001
24760
|
return loaded?.ok ? loaded.rows : [];
|
|
25002
24761
|
}, [tokensPath]);
|
|
25003
24762
|
const longest = useMemo4(() => longestEntries(tokens), [tokens]);
|
|
25004
|
-
useEffect14(() => {
|
|
25005
|
-
startDebugRun({
|
|
25006
|
-
flow: "import/scope-gate",
|
|
25007
|
-
step: "07-scope-gate",
|
|
25008
|
-
menuOption: "Scope gate",
|
|
25009
|
-
inputs: scopeGateLogInputs(components, tokens.length)
|
|
25010
|
-
});
|
|
25011
|
-
}, []);
|
|
25012
24763
|
const gate = useScopeGate({
|
|
25013
24764
|
components,
|
|
25014
24765
|
tokenCount: tokens.length,
|
|
25015
24766
|
tokensWidth: longest.path + longest.value + 10,
|
|
25016
|
-
onConfirm
|
|
25017
|
-
|
|
25018
|
-
outputs: scopeGateLogOutputs(components, decisions),
|
|
25019
|
-
status: "success",
|
|
25020
|
-
exitMethod: "saved"
|
|
25021
|
-
});
|
|
25022
|
-
onConfirm(decisions);
|
|
25023
|
-
},
|
|
25024
|
-
onQuit: () => {
|
|
25025
|
-
void finishDebugRun({ outputs: { outcome: "quit" }, status: "success", exitMethod: "discarded" });
|
|
25026
|
-
onQuit();
|
|
25027
|
-
}
|
|
24767
|
+
onConfirm,
|
|
24768
|
+
onQuit
|
|
25028
24769
|
});
|
|
25029
24770
|
const { search, graph, columnPlan, panelLayout, counters } = gate;
|
|
25030
24771
|
if (gate.showHelp) {
|
|
@@ -25124,9 +24865,7 @@ var HELP_SECTIONS;
|
|
|
25124
24865
|
var init_screen8 = __esm({
|
|
25125
24866
|
"packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/screen.tsx"() {
|
|
25126
24867
|
"use strict";
|
|
25127
|
-
init_debug_store();
|
|
25128
24868
|
init_StepHeader();
|
|
25129
|
-
init_log();
|
|
25130
24869
|
init_tokens_column();
|
|
25131
24870
|
init_load();
|
|
25132
24871
|
init_logic10();
|
|
@@ -25234,27 +24973,13 @@ var init_load2 = __esm({
|
|
|
25234
24973
|
});
|
|
25235
24974
|
|
|
25236
24975
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
|
|
25237
|
-
import { useEffect as
|
|
24976
|
+
import { useEffect as useEffect12, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
|
|
25238
24977
|
function useScopeGateFlow(input, deps = realDeps3) {
|
|
25239
24978
|
const sessionId = input?.sessionId;
|
|
25240
24979
|
const loaded = useMemo5(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
|
|
25241
24980
|
const cacheCheck = useRef10(void 0);
|
|
25242
24981
|
const [confirmed, setConfirmed] = useState17();
|
|
25243
|
-
|
|
25244
|
-
if (!sessionId || !loaded || loaded.ok) return;
|
|
25245
|
-
startDebugRun({
|
|
25246
|
-
flow: "import/scope-gate",
|
|
25247
|
-
step: "07-scope-gate",
|
|
25248
|
-
menuOption: "Scope gate",
|
|
25249
|
-
inputs: { session_id: sessionId }
|
|
25250
|
-
});
|
|
25251
|
-
void finishDebugRun({
|
|
25252
|
-
outputs: { outcome: "could not load the components", error: loaded.message },
|
|
25253
|
-
status: "error",
|
|
25254
|
-
exitMethod: "discarded"
|
|
25255
|
-
});
|
|
25256
|
-
}, [sessionId, loaded]);
|
|
25257
|
-
useEffect15(() => {
|
|
24982
|
+
useEffect12(() => {
|
|
25258
24983
|
if (!input || !loaded?.ok || cacheCheck.current) return;
|
|
25259
24984
|
cacheCheck.current = deps.checkCache(input.cache);
|
|
25260
24985
|
}, [input, loaded]);
|
|
@@ -25268,7 +24993,6 @@ var realDeps3;
|
|
|
25268
24993
|
var init_use_scope_gate_flow = __esm({
|
|
25269
24994
|
"packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts"() {
|
|
25270
24995
|
"use strict";
|
|
25271
|
-
init_debug_store();
|
|
25272
24996
|
init_cache_check();
|
|
25273
24997
|
init_load2();
|
|
25274
24998
|
realDeps3 = { load: loadScopeGate, checkCache: checkGenerationCache };
|
|
@@ -25276,41 +25000,6 @@ var init_use_scope_gate_flow = __esm({
|
|
|
25276
25000
|
});
|
|
25277
25001
|
|
|
25278
25002
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/logic.ts
|
|
25279
|
-
function generationLogInputs(input) {
|
|
25280
|
-
return {
|
|
25281
|
-
session_id: input.sessionId,
|
|
25282
|
-
accepted: input.decisions.accepted.length,
|
|
25283
|
-
rejected: input.decisions.rejected.length,
|
|
25284
|
-
tokens_path: input.tokensPath,
|
|
25285
|
-
token_session_id: input.tokenSessionId,
|
|
25286
|
-
existing_entities_path: input.existingEntitiesPath,
|
|
25287
|
-
agent: input.agent,
|
|
25288
|
-
agent_model: input.agentModel ?? "",
|
|
25289
|
-
prompt_overrides: input.promptOverrides,
|
|
25290
|
-
generate_prompt_path: input.generatePromptPath ?? "",
|
|
25291
|
-
cache: !input.noCache,
|
|
25292
|
-
has_tokens: input.hasTokens
|
|
25293
|
-
};
|
|
25294
|
-
}
|
|
25295
|
-
function generationLogOutputs(result, progress) {
|
|
25296
|
-
const last = progress ? { final_progress: progress } : {};
|
|
25297
|
-
if (!result.ok) {
|
|
25298
|
-
return { outputs: { result: "failed", failed_step: result.step, error: result.message, ...last }, status: "error" };
|
|
25299
|
-
}
|
|
25300
|
-
const { generation } = result;
|
|
25301
|
-
return {
|
|
25302
|
-
outputs: generation.route === "review" ? {
|
|
25303
|
-
result: "done",
|
|
25304
|
-
route: generation.route,
|
|
25305
|
-
session_id: generation.sessionId,
|
|
25306
|
-
accepted: generation.acceptedCount,
|
|
25307
|
-
generated: generation.generatedCount,
|
|
25308
|
-
map_tokens_eligible: generation.mapTokensEligible,
|
|
25309
|
-
...last
|
|
25310
|
-
} : { result: "done", route: generation.route, accepted: generation.acceptedCount, ...last },
|
|
25311
|
-
status: "success"
|
|
25312
|
-
};
|
|
25313
|
-
}
|
|
25314
25003
|
function initialProgress2() {
|
|
25315
25004
|
return { components: null, mapTokens: "idle", mapTokensEligible: null };
|
|
25316
25005
|
}
|
|
@@ -25561,34 +25250,21 @@ var init_run2 = __esm({
|
|
|
25561
25250
|
});
|
|
25562
25251
|
|
|
25563
25252
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts
|
|
25564
|
-
import { useEffect as
|
|
25253
|
+
import { useEffect as useEffect13, useRef as useRef11, useState as useState18 } from "react";
|
|
25565
25254
|
function useGeneration(input) {
|
|
25566
25255
|
const [state2, setState] = useState18();
|
|
25567
25256
|
const current = useRef11();
|
|
25568
|
-
|
|
25257
|
+
useEffect13(() => {
|
|
25569
25258
|
current.current = input;
|
|
25570
25259
|
if (!input) {
|
|
25571
25260
|
setState(void 0);
|
|
25572
25261
|
return;
|
|
25573
25262
|
}
|
|
25574
25263
|
setState({ status: "running", progress: initialProgress2() });
|
|
25575
|
-
let lastProgress;
|
|
25576
|
-
startDebugRun({
|
|
25577
|
-
flow: "import/generation",
|
|
25578
|
-
step: "08-generation",
|
|
25579
|
-
menuOption: "Generation",
|
|
25580
|
-
inputs: generationLogInputs(input)
|
|
25581
|
-
});
|
|
25582
25264
|
void runGeneration(input, (progress) => {
|
|
25583
|
-
lastProgress = progress;
|
|
25584
25265
|
if (current.current === input) setState({ status: "running", progress });
|
|
25585
25266
|
}).then((result) => {
|
|
25586
|
-
if (current.current
|
|
25587
|
-
void finishDebugRun({
|
|
25588
|
-
...generationLogOutputs(result, lastProgress),
|
|
25589
|
-
exitMethod: result.ok ? "saved" : "discarded"
|
|
25590
|
-
});
|
|
25591
|
-
setState({ status: "done", result });
|
|
25267
|
+
if (current.current === input) setState({ status: "done", result });
|
|
25592
25268
|
});
|
|
25593
25269
|
return () => {
|
|
25594
25270
|
if (current.current === input) current.current = void 0;
|
|
@@ -25599,7 +25275,6 @@ function useGeneration(input) {
|
|
|
25599
25275
|
var init_use_generation = __esm({
|
|
25600
25276
|
"packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts"() {
|
|
25601
25277
|
"use strict";
|
|
25602
|
-
init_debug_store();
|
|
25603
25278
|
init_logic11();
|
|
25604
25279
|
init_run2();
|
|
25605
25280
|
}
|
|
@@ -25729,9 +25404,12 @@ var init_schema2 = __esm({
|
|
|
25729
25404
|
$required: { type: "boolean" },
|
|
25730
25405
|
$default: {},
|
|
25731
25406
|
$values: { type: "array", items: { type: "string" } },
|
|
25732
|
-
"$token.kind": { type: "string" },
|
|
25407
|
+
"$token.kind": { type: "string", minLength: 1 },
|
|
25733
25408
|
"$token.allowed": { type: "array", items: { type: "string" } }
|
|
25734
25409
|
},
|
|
25410
|
+
// The API rejects a token property that does not say which kind of token it takes.
|
|
25411
|
+
if: { type: "object", properties: { $type: { const: "token" } }, required: ["$type"] },
|
|
25412
|
+
then: { type: "object", required: ["$token.kind"] },
|
|
25735
25413
|
additionalProperties: false
|
|
25736
25414
|
},
|
|
25737
25415
|
slot: {
|
|
@@ -26566,7 +26244,7 @@ var init_scroll_offset = __esm({
|
|
|
26566
26244
|
});
|
|
26567
26245
|
|
|
26568
26246
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/components/FieldEditor.tsx
|
|
26569
|
-
import React13, { useEffect as
|
|
26247
|
+
import React13, { useEffect as useEffect14, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
|
|
26570
26248
|
import figures6 from "figures";
|
|
26571
26249
|
import { Box as Box26, measureElement, Text as Text27 } from "ink";
|
|
26572
26250
|
import { Fragment as Fragment6, jsx as jsx32, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
@@ -28093,7 +27771,7 @@ function FieldEditor({
|
|
|
28093
27771
|
}
|
|
28094
27772
|
return Math.max(start + 1, end2);
|
|
28095
27773
|
};
|
|
28096
|
-
|
|
27774
|
+
useEffect14(() => {
|
|
28097
27775
|
if (focusLevel === "field" || selectedRowIdx < 0) return;
|
|
28098
27776
|
setListScrollStart((previous) => {
|
|
28099
27777
|
if (initialFocusTarget && !initialFocusScrollApplied.current) {
|
|
@@ -29488,7 +29166,7 @@ var init_FinalizeDialog = __esm({
|
|
|
29488
29166
|
});
|
|
29489
29167
|
|
|
29490
29168
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-finalize-preview.ts
|
|
29491
|
-
import { useEffect as
|
|
29169
|
+
import { useEffect as useEffect15, useRef as useRef12, useState as useState20 } from "react";
|
|
29492
29170
|
function useReviewFinalizePreview({
|
|
29493
29171
|
components,
|
|
29494
29172
|
...options
|
|
@@ -29505,7 +29183,7 @@ function useFinalizePreview(opts) {
|
|
|
29505
29183
|
const [scrollOffset, setScrollOffset] = useState20(0);
|
|
29506
29184
|
const generationRef = useRef12(0);
|
|
29507
29185
|
const acceptedKey = [...acceptedKeys].sort().join("\0");
|
|
29508
|
-
|
|
29186
|
+
useEffect15(() => {
|
|
29509
29187
|
if (!open) {
|
|
29510
29188
|
setStatus("idle");
|
|
29511
29189
|
setRemoved([]);
|
|
@@ -29557,7 +29235,7 @@ var init_use_finalize_preview = __esm({
|
|
|
29557
29235
|
});
|
|
29558
29236
|
|
|
29559
29237
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-session.ts
|
|
29560
|
-
import { useCallback as useCallback2, useEffect as
|
|
29238
|
+
import { useCallback as useCallback2, useEffect as useEffect16, useRef as useRef13, useState as useState21 } from "react";
|
|
29561
29239
|
function useReviewSession({
|
|
29562
29240
|
loadSession,
|
|
29563
29241
|
tokensPath,
|
|
@@ -29576,7 +29254,7 @@ function useReviewSession({
|
|
|
29576
29254
|
}));
|
|
29577
29255
|
return { result, catalog };
|
|
29578
29256
|
}, [loadSession, tokensPath]);
|
|
29579
|
-
|
|
29257
|
+
useEffect16(() => {
|
|
29580
29258
|
let disposed = false;
|
|
29581
29259
|
void (async () => {
|
|
29582
29260
|
try {
|
|
@@ -29629,7 +29307,7 @@ function useReviewSession({
|
|
|
29629
29307
|
function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
|
|
29630
29308
|
const [reviewMetadata, setReviewMetadata] = useState21(null);
|
|
29631
29309
|
const [componentRationale, setComponentRationale] = useState21(null);
|
|
29632
|
-
|
|
29310
|
+
useEffect16(() => {
|
|
29633
29311
|
const current = components[selectedIdx];
|
|
29634
29312
|
if (!current) {
|
|
29635
29313
|
setReviewMetadata(null);
|
|
@@ -29658,16 +29336,10 @@ function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
|
|
|
29658
29336
|
}, [components, extractSessionId, selectedIdx]);
|
|
29659
29337
|
return { reviewMetadata, componentRationale };
|
|
29660
29338
|
}
|
|
29661
|
-
function useReviewHistory({
|
|
29662
|
-
loading,
|
|
29663
|
-
components,
|
|
29664
|
-
createSnapshot,
|
|
29665
|
-
applySnapshot,
|
|
29666
|
-
onAction
|
|
29667
|
-
}) {
|
|
29339
|
+
function useReviewHistory({ loading, components, createSnapshot, applySnapshot }) {
|
|
29668
29340
|
const historyRef = useRef13(null);
|
|
29669
29341
|
const historySeededRef = useRef13(false);
|
|
29670
|
-
|
|
29342
|
+
useEffect16(() => {
|
|
29671
29343
|
if (loading || historySeededRef.current) return;
|
|
29672
29344
|
historySeededRef.current = true;
|
|
29673
29345
|
historyRef.current = createHistoryStack(createSnapshot(components));
|
|
@@ -29675,19 +29347,14 @@ function useReviewHistory({
|
|
|
29675
29347
|
const pushHistorySnapshot = (entries, label) => {
|
|
29676
29348
|
if (!historyRef.current) return;
|
|
29677
29349
|
historyRef.current.push(createSnapshot(entries), label);
|
|
29678
|
-
onAction?.(label);
|
|
29679
29350
|
};
|
|
29680
29351
|
const handleUndo = () => {
|
|
29681
29352
|
const snapshot = historyRef.current?.undo();
|
|
29682
|
-
if (
|
|
29683
|
-
applySnapshot(snapshot);
|
|
29684
|
-
onAction?.("undo");
|
|
29353
|
+
if (snapshot) applySnapshot(snapshot);
|
|
29685
29354
|
};
|
|
29686
29355
|
const handleRedo = () => {
|
|
29687
29356
|
const snapshot = historyRef.current?.redo();
|
|
29688
|
-
if (
|
|
29689
|
-
applySnapshot(snapshot);
|
|
29690
|
-
onAction?.("redo");
|
|
29357
|
+
if (snapshot) applySnapshot(snapshot);
|
|
29691
29358
|
};
|
|
29692
29359
|
const resetHistory = (snapshot) => {
|
|
29693
29360
|
historyRef.current?.reset(snapshot);
|
|
@@ -29754,7 +29421,7 @@ var init_token_suggestions = __esm({
|
|
|
29754
29421
|
});
|
|
29755
29422
|
|
|
29756
29423
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-editor.ts
|
|
29757
|
-
import { useEffect as
|
|
29424
|
+
import { useEffect as useEffect17, useRef as useRef14, useState as useState22 } from "react";
|
|
29758
29425
|
function parseReviewEntry(draftValue) {
|
|
29759
29426
|
const parsed = JSON.parse(draftValue);
|
|
29760
29427
|
const keys = Object.keys(parsed);
|
|
@@ -29788,7 +29455,7 @@ function useReviewEditor({
|
|
|
29788
29455
|
const [tokenReviewEditSelection, setTokenReviewEditSelection] = useState22(/* @__PURE__ */ new Set());
|
|
29789
29456
|
const tokenReviewSuggestedRef = useRef14(/* @__PURE__ */ new Map());
|
|
29790
29457
|
const pendingGRef = useRef14(false);
|
|
29791
|
-
|
|
29458
|
+
useEffect17(() => {
|
|
29792
29459
|
setTokenReviewRow(0);
|
|
29793
29460
|
setTokenReviewEditing(false);
|
|
29794
29461
|
setTokenReviewEditCursor(0);
|
|
@@ -30270,7 +29937,7 @@ var init_preview_annotations = __esm({
|
|
|
30270
29937
|
});
|
|
30271
29938
|
|
|
30272
29939
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-live-preview.ts
|
|
30273
|
-
import { useCallback as useCallback3, useEffect as
|
|
29940
|
+
import { useCallback as useCallback3, useEffect as useEffect18, useRef as useRef15, useState as useState24 } from "react";
|
|
30274
29941
|
function useLivePreview(opts) {
|
|
30275
29942
|
const debounceMs = opts.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
30276
29943
|
const [status, setStatus] = useState24("idle");
|
|
@@ -30280,14 +29947,14 @@ function useLivePreview(opts) {
|
|
|
30280
29947
|
const latestRef = useRef15(0);
|
|
30281
29948
|
const inflightRef = useRef15(0);
|
|
30282
29949
|
const optsRef = useRef15(opts);
|
|
30283
|
-
|
|
29950
|
+
useEffect18(() => {
|
|
30284
29951
|
optsRef.current = opts;
|
|
30285
29952
|
});
|
|
30286
29953
|
const disabledRef = useRef15(disabled);
|
|
30287
|
-
|
|
29954
|
+
useEffect18(() => {
|
|
30288
29955
|
disabledRef.current = disabled;
|
|
30289
29956
|
}, [disabled]);
|
|
30290
|
-
|
|
29957
|
+
useEffect18(() => {
|
|
30291
29958
|
return () => {
|
|
30292
29959
|
if (timerRef.current) {
|
|
30293
29960
|
clearTimeout(timerRef.current);
|
|
@@ -30368,7 +30035,7 @@ var init_use_live_preview = __esm({
|
|
|
30368
30035
|
});
|
|
30369
30036
|
|
|
30370
30037
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-preview.ts
|
|
30371
|
-
import { useCallback as useCallback4, useEffect as
|
|
30038
|
+
import { useCallback as useCallback4, useEffect as useEffect19, useState as useState25 } from "react";
|
|
30372
30039
|
function useReviewPreview({
|
|
30373
30040
|
components,
|
|
30374
30041
|
loading,
|
|
@@ -30410,13 +30077,13 @@ function useReviewPreview({
|
|
|
30410
30077
|
deleteAllComponents
|
|
30411
30078
|
});
|
|
30412
30079
|
const [spinnerTick, setSpinnerTick] = useState25(0);
|
|
30413
|
-
|
|
30080
|
+
useEffect19(() => {
|
|
30414
30081
|
if (livePreviewHook.status !== "running") return;
|
|
30415
30082
|
const id = setInterval(() => setSpinnerTick((tick) => tick + 1), 80);
|
|
30416
30083
|
return () => clearInterval(id);
|
|
30417
30084
|
}, [livePreviewHook.status]);
|
|
30418
30085
|
const livePreviewSpinner = SPINNER_FRAMES[spinnerTick % SPINNER_FRAMES.length];
|
|
30419
|
-
|
|
30086
|
+
useEffect19(() => {
|
|
30420
30087
|
if (loading) return;
|
|
30421
30088
|
if (!livePreview) return;
|
|
30422
30089
|
if (components.length === 0) return;
|
|
@@ -30434,127 +30101,6 @@ var init_use_review_preview = __esm({
|
|
|
30434
30101
|
}
|
|
30435
30102
|
});
|
|
30436
30103
|
|
|
30437
|
-
// packages/experience-design-system-cli/src/tui/import/steps/09-review/review-log.ts
|
|
30438
|
-
function reviewInputs(components) {
|
|
30439
|
-
return { components: components.length, by_status: countStatuses(components) };
|
|
30440
|
-
}
|
|
30441
|
-
function openReviewTrail(components, now) {
|
|
30442
|
-
return {
|
|
30443
|
-
startedAt: now,
|
|
30444
|
-
start: new Map(components.map((component) => [component.key, component.status])),
|
|
30445
|
-
actions: [],
|
|
30446
|
-
kinds: {}
|
|
30447
|
-
};
|
|
30448
|
-
}
|
|
30449
|
-
function recordReviewAction(trail, label) {
|
|
30450
|
-
const kind = label.split(":")[0] ?? label;
|
|
30451
|
-
trail.kinds[kind] = (trail.kinds[kind] ?? 0) + 1;
|
|
30452
|
-
if (trail.actions.length < MAX_ACTIONS) trail.actions.push(label);
|
|
30453
|
-
}
|
|
30454
|
-
function render(trail, components, now, outcome) {
|
|
30455
|
-
const acceptedByUser = [];
|
|
30456
|
-
const rejectedByUser = [];
|
|
30457
|
-
for (const { key, status } of components) {
|
|
30458
|
-
const was = trail.start.get(key);
|
|
30459
|
-
if (was === status) continue;
|
|
30460
|
-
if (status === "accepted") acceptedByUser.push(key);
|
|
30461
|
-
if (status === "rejected") rejectedByUser.push(key);
|
|
30462
|
-
}
|
|
30463
|
-
const total = Object.values(trail.kinds).reduce((sum, count) => sum + count, 0);
|
|
30464
|
-
return {
|
|
30465
|
-
outcome,
|
|
30466
|
-
seconds: Math.round((now - trail.startedAt) / 100) / 10,
|
|
30467
|
-
edits: { total, by_kind: trail.kinds, in_order: trail.actions },
|
|
30468
|
-
now: countStatuses(components),
|
|
30469
|
-
accepted_by_user: capped2(acceptedByUser),
|
|
30470
|
-
rejected_by_user: capped2(rejectedByUser)
|
|
30471
|
-
};
|
|
30472
|
-
}
|
|
30473
|
-
function reviewProgress(trail, components, now) {
|
|
30474
|
-
return render(trail, components, now, "interrupted");
|
|
30475
|
-
}
|
|
30476
|
-
function reviewFinish(trail, components, now, final) {
|
|
30477
|
-
const outcome = final ? `finalized: ${final.accepted} accepted, ${final.rejected} rejected, ${final.unresolved} unresolved` : "left the review without finishing";
|
|
30478
|
-
return {
|
|
30479
|
-
outputs: render(trail, components, now, outcome),
|
|
30480
|
-
status: "success",
|
|
30481
|
-
exitMethod: final ? "saved" : "discarded"
|
|
30482
|
-
};
|
|
30483
|
-
}
|
|
30484
|
-
var REVIEW_RUN, MAX_ACTIONS, MAX_NAMES2, countStatuses, capped2;
|
|
30485
|
-
var init_review_log = __esm({
|
|
30486
|
-
"packages/experience-design-system-cli/src/tui/import/steps/09-review/review-log.ts"() {
|
|
30487
|
-
"use strict";
|
|
30488
|
-
REVIEW_RUN = { flow: "import/review", step: "09-review", menuOption: "Review" };
|
|
30489
|
-
MAX_ACTIONS = 30;
|
|
30490
|
-
MAX_NAMES2 = 20;
|
|
30491
|
-
countStatuses = (components) => {
|
|
30492
|
-
const counts = {};
|
|
30493
|
-
for (const { status } of components) counts[status] = (counts[status] ?? 0) + 1;
|
|
30494
|
-
return counts;
|
|
30495
|
-
};
|
|
30496
|
-
capped2 = (keys) => ({
|
|
30497
|
-
count: keys.length,
|
|
30498
|
-
keys: keys.slice(0, MAX_NAMES2)
|
|
30499
|
-
});
|
|
30500
|
-
}
|
|
30501
|
-
});
|
|
30502
|
-
|
|
30503
|
-
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-log.ts
|
|
30504
|
-
import { useEffect as useEffect23, useRef as useRef16 } from "react";
|
|
30505
|
-
function useReviewLog({
|
|
30506
|
-
loading,
|
|
30507
|
-
loadError,
|
|
30508
|
-
components
|
|
30509
|
-
}) {
|
|
30510
|
-
const trail = useRef16(void 0);
|
|
30511
|
-
const started = useRef16(false);
|
|
30512
|
-
const latest = useRef16(components);
|
|
30513
|
-
latest.current = components;
|
|
30514
|
-
useEffect23(() => {
|
|
30515
|
-
if (loading || started.current) return;
|
|
30516
|
-
started.current = true;
|
|
30517
|
-
startDebugRun({ ...REVIEW_RUN, inputs: reviewInputs(components) });
|
|
30518
|
-
if (loadError) {
|
|
30519
|
-
void finishDebugRun({
|
|
30520
|
-
outputs: { outcome: "could not load the components", error: loadError },
|
|
30521
|
-
status: "error",
|
|
30522
|
-
exitMethod: "discarded"
|
|
30523
|
-
});
|
|
30524
|
-
return;
|
|
30525
|
-
}
|
|
30526
|
-
trail.current = openReviewTrail(components, Date.now());
|
|
30527
|
-
setDebugRunProgress(reviewProgress(trail.current, components, Date.now()));
|
|
30528
|
-
}, [loading, loadError, components]);
|
|
30529
|
-
useEffect23(
|
|
30530
|
-
() => () => {
|
|
30531
|
-
const open = trail.current;
|
|
30532
|
-
trail.current = void 0;
|
|
30533
|
-
if (open) void finishDebugRun(reviewFinish(open, latest.current, Date.now(), void 0));
|
|
30534
|
-
},
|
|
30535
|
-
[]
|
|
30536
|
-
);
|
|
30537
|
-
return {
|
|
30538
|
-
record: (label) => {
|
|
30539
|
-
if (!trail.current) return;
|
|
30540
|
-
recordReviewAction(trail.current, label);
|
|
30541
|
-
setDebugRunProgress(reviewProgress(trail.current, latest.current, Date.now()));
|
|
30542
|
-
},
|
|
30543
|
-
finish: (counts) => {
|
|
30544
|
-
const open = trail.current;
|
|
30545
|
-
trail.current = void 0;
|
|
30546
|
-
if (open) void finishDebugRun(reviewFinish(open, latest.current, Date.now(), counts));
|
|
30547
|
-
}
|
|
30548
|
-
};
|
|
30549
|
-
}
|
|
30550
|
-
var init_use_review_log = __esm({
|
|
30551
|
-
"packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-log.ts"() {
|
|
30552
|
-
"use strict";
|
|
30553
|
-
init_debug_store();
|
|
30554
|
-
init_review_log();
|
|
30555
|
-
}
|
|
30556
|
-
});
|
|
30557
|
-
|
|
30558
30104
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/components/LivePreviewSummary.tsx
|
|
30559
30105
|
import { Box as Box37, Text as Text39 } from "ink";
|
|
30560
30106
|
import { jsx as jsx47, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
@@ -30594,7 +30140,7 @@ var init_LivePreviewSummary = __esm({
|
|
|
30594
30140
|
});
|
|
30595
30141
|
|
|
30596
30142
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/generate-review-step.tsx
|
|
30597
|
-
import { useCallback as useCallback5, useEffect as
|
|
30143
|
+
import { useCallback as useCallback5, useEffect as useEffect20, useMemo as useMemo6, useRef as useRef16, useState as useState26 } from "react";
|
|
30598
30144
|
import figures8 from "figures";
|
|
30599
30145
|
import { Box as Box38, Text as Text40 } from "ink";
|
|
30600
30146
|
import { Fragment as Fragment14, jsx as jsx48, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
@@ -30791,7 +30337,6 @@ function GenerateReviewStepView({
|
|
|
30791
30337
|
tokensPath,
|
|
30792
30338
|
onExtraLoaded: setLoadedSlotCycles
|
|
30793
30339
|
});
|
|
30794
|
-
const reviewLog = useReviewLog({ loading, loadError, components });
|
|
30795
30340
|
const [nav, setNav] = useState26({
|
|
30796
30341
|
cursorRowIdx: 0,
|
|
30797
30342
|
sidebarScrollOffset: 0
|
|
@@ -30809,7 +30354,7 @@ function GenerateReviewStepView({
|
|
|
30809
30354
|
setFinalizeError
|
|
30810
30355
|
} = reviewSurface;
|
|
30811
30356
|
const [removedBannerCollapsed, setRemovedBannerCollapsed] = useState26(false);
|
|
30812
|
-
const removedBannerDefaultedRef =
|
|
30357
|
+
const removedBannerDefaultedRef = useRef16(false);
|
|
30813
30358
|
const [cyclePanelScroll, setCyclePanelScroll] = useState26(0);
|
|
30814
30359
|
const [cyclesCursor, setCyclesCursor] = useState26(0);
|
|
30815
30360
|
const cyclePanel = useOverlayPanel({
|
|
@@ -30829,7 +30374,7 @@ function GenerateReviewStepView({
|
|
|
30829
30374
|
const [breakCursor, setBreakCursor] = useState26(0);
|
|
30830
30375
|
const [breakConfirm, setBreakConfirm] = useState26(false);
|
|
30831
30376
|
const [expandedGroups, setExpandedGroups] = useState26(/* @__PURE__ */ new Set());
|
|
30832
|
-
const seededGroupsRef =
|
|
30377
|
+
const seededGroupsRef = useRef16(false);
|
|
30833
30378
|
const {
|
|
30834
30379
|
searchOpen,
|
|
30835
30380
|
setSearchOpen,
|
|
@@ -30853,7 +30398,7 @@ function GenerateReviewStepView({
|
|
|
30853
30398
|
const [pendingEditorFocus, setPendingEditorFocus] = useState26(null);
|
|
30854
30399
|
const [autoRejected, setAutoRejected] = useState26([]);
|
|
30855
30400
|
const [undoSnapshot, setUndoSnapshot] = useState26(null);
|
|
30856
|
-
const autoRejectFiredRef =
|
|
30401
|
+
const autoRejectFiredRef = useRef16(false);
|
|
30857
30402
|
const [showReloadDialog, setShowReloadDialog] = useState26(false);
|
|
30858
30403
|
const acceptedCountForPreview = components.filter((c2) => c2.status === "accepted").length;
|
|
30859
30404
|
const { previewAnnotations, removedComponents, livePreviewHook, livePreviewSpinner } = useReviewPreview({
|
|
@@ -30885,10 +30430,7 @@ function GenerateReviewStepView({
|
|
|
30885
30430
|
cmaToken,
|
|
30886
30431
|
host,
|
|
30887
30432
|
components,
|
|
30888
|
-
onFinalize
|
|
30889
|
-
reviewLog.finish({ accepted, rejected, unresolved });
|
|
30890
|
-
onFinalize(accepted, rejected, unresolved);
|
|
30891
|
-
}
|
|
30433
|
+
onFinalize
|
|
30892
30434
|
});
|
|
30893
30435
|
const recomputeCycles = (currentComponents) => {
|
|
30894
30436
|
try {
|
|
@@ -30919,7 +30461,7 @@ function GenerateReviewStepView({
|
|
|
30919
30461
|
[components]
|
|
30920
30462
|
);
|
|
30921
30463
|
const closures = useMemo6(() => computeAllClosures(componentGraph), [componentGraph]);
|
|
30922
|
-
|
|
30464
|
+
useEffect20(() => {
|
|
30923
30465
|
if (seededGroupsRef.current) return;
|
|
30924
30466
|
if (closures.size === 0 && slotCycles.length === 0) return;
|
|
30925
30467
|
seededGroupsRef.current = true;
|
|
@@ -30946,7 +30488,7 @@ function GenerateReviewStepView({
|
|
|
30946
30488
|
suggestedBreak: cycle.edges.length > 0 ? suggestCycleBreakEdge2(cycle, cycleView.pushBlocking) : null
|
|
30947
30489
|
}));
|
|
30948
30490
|
}, [slotCycles, cycleView]);
|
|
30949
|
-
|
|
30491
|
+
useEffect20(() => {
|
|
30950
30492
|
const decision = computeAutoRejectDecision({
|
|
30951
30493
|
loading,
|
|
30952
30494
|
autoRejectFired: autoRejectFiredRef.current,
|
|
@@ -30987,11 +30529,10 @@ function GenerateReviewStepView({
|
|
|
30987
30529
|
autoRejected,
|
|
30988
30530
|
undoSnapshot
|
|
30989
30531
|
}),
|
|
30990
|
-
applySnapshot: applyHistorySnapshot
|
|
30991
|
-
onAction: reviewLog.record
|
|
30532
|
+
applySnapshot: applyHistorySnapshot
|
|
30992
30533
|
});
|
|
30993
|
-
const autoRejectPushedRef =
|
|
30994
|
-
|
|
30534
|
+
const autoRejectPushedRef = useRef16(false);
|
|
30535
|
+
useEffect20(() => {
|
|
30995
30536
|
if (loading) return;
|
|
30996
30537
|
if (!historySeededRef.current) return;
|
|
30997
30538
|
if (!autoRejectFiredRef.current) return;
|
|
@@ -31075,7 +30616,7 @@ function GenerateReviewStepView({
|
|
|
31075
30616
|
const panelHeight = leftPanelHeight + 2;
|
|
31076
30617
|
const panelContentHeight = Math.max(1, panelHeight - 3);
|
|
31077
30618
|
const cycleViewportHeight = Math.max(1, panelHeight - 4);
|
|
31078
|
-
|
|
30619
|
+
useEffect20(() => {
|
|
31079
30620
|
if (selectableRowPositions.length === 0) return;
|
|
31080
30621
|
const cursorInRange = selectableRowPositions.includes(cursorRowIdx);
|
|
31081
30622
|
const maxScroll = Math.max(0, visibleRowsMemo.length - visibleCount);
|
|
@@ -31904,7 +31445,6 @@ var init_generate_review_step = __esm({
|
|
|
31904
31445
|
init_ReviewDialogs();
|
|
31905
31446
|
init_review_input();
|
|
31906
31447
|
init_use_review_preview();
|
|
31907
|
-
init_use_review_log();
|
|
31908
31448
|
init_LivePreviewSummary();
|
|
31909
31449
|
HELP_SECTIONS2 = [
|
|
31910
31450
|
{
|
|
@@ -32158,10 +31698,10 @@ var init_path_utils = __esm({
|
|
|
32158
31698
|
});
|
|
32159
31699
|
|
|
32160
31700
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
|
|
32161
|
-
import { useEffect as
|
|
31701
|
+
import { useEffect as useEffect21, useState as useState27 } from "react";
|
|
32162
31702
|
function useBlinkingCursor() {
|
|
32163
31703
|
const [visible, setVisible] = useState27(true);
|
|
32164
|
-
|
|
31704
|
+
useEffect21(() => {
|
|
32165
31705
|
const interval = setInterval(() => setVisible((current) => !current), 500);
|
|
32166
31706
|
return () => clearInterval(interval);
|
|
32167
31707
|
}, []);
|
|
@@ -32298,12 +31838,12 @@ var init_produced = __esm({
|
|
|
32298
31838
|
});
|
|
32299
31839
|
|
|
32300
31840
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-timed-spinner.tsx
|
|
32301
|
-
import { useEffect as
|
|
31841
|
+
import { useEffect as useEffect22, useState as useState29 } from "react";
|
|
32302
31842
|
import { Spinner as Spinner2 } from "@inkjs/ui";
|
|
32303
31843
|
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
32304
31844
|
function useTimedSpinner() {
|
|
32305
31845
|
const [elapsedSeconds, setElapsedSeconds] = useState29(0);
|
|
32306
|
-
|
|
31846
|
+
useEffect22(() => {
|
|
32307
31847
|
const timer = setInterval(() => setElapsedSeconds((current) => current + 1), 1e3);
|
|
32308
31848
|
return () => {
|
|
32309
31849
|
clearInterval(timer);
|
|
@@ -32572,7 +32112,7 @@ var init_preview_confirmation_input = __esm({
|
|
|
32572
32112
|
});
|
|
32573
32113
|
|
|
32574
32114
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/WizardPreviewStep.tsx
|
|
32575
|
-
import { useEffect as
|
|
32115
|
+
import { useEffect as useEffect23, useState as useState30, useMemo as useMemo7 } from "react";
|
|
32576
32116
|
import { Box as Box44, Text as Text46 } from "ink";
|
|
32577
32117
|
import { Fragment as Fragment16, jsx as jsx55, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
32578
32118
|
function buildPreviewSummaryLines(preview) {
|
|
@@ -32782,7 +32322,7 @@ function WizardPreviewStep({
|
|
|
32782
32322
|
const activeLines = diffExpanded ? diffLines : summaryLines;
|
|
32783
32323
|
const maxScroll = Math.max(0, activeLines.length - viewportHeight);
|
|
32784
32324
|
const boundedScrollOffset = Math.min(scrollOffset, maxScroll);
|
|
32785
|
-
|
|
32325
|
+
useEffect23(() => {
|
|
32786
32326
|
setScrollOffset((previous) => Math.min(previous, maxScroll));
|
|
32787
32327
|
}, [maxScroll]);
|
|
32788
32328
|
useImmediateInput((input, key) => {
|
|
@@ -32892,205 +32432,6 @@ var init_run_teaser = __esm({
|
|
|
32892
32432
|
}
|
|
32893
32433
|
});
|
|
32894
32434
|
|
|
32895
|
-
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/flow-log.ts
|
|
32896
|
-
function previewSummary(preview) {
|
|
32897
|
-
const counts = (group) => ({
|
|
32898
|
-
new: group.new.length,
|
|
32899
|
-
changed: group.changed.length,
|
|
32900
|
-
removed: group.removed.length
|
|
32901
|
-
});
|
|
32902
|
-
return {
|
|
32903
|
-
components: counts(preview.components),
|
|
32904
|
-
tokens: counts(preview.tokens),
|
|
32905
|
-
breaking_components: preview.components.changed.filter(
|
|
32906
|
-
(entry) => entry.changeClassification?.classification === "breaking"
|
|
32907
|
-
).length
|
|
32908
|
-
};
|
|
32909
|
-
}
|
|
32910
|
-
function pushSummary(result, state2) {
|
|
32911
|
-
const failures = result.failures ?? [];
|
|
32912
|
-
return {
|
|
32913
|
-
component_types: result.componentTypes,
|
|
32914
|
-
design_tokens: result.designTokens,
|
|
32915
|
-
...result.summary ? { summary: result.summary } : {},
|
|
32916
|
-
...failures.length > 0 ? {
|
|
32917
|
-
failure_count: failures.length,
|
|
32918
|
-
failures: failures.slice(0, MAX_LOGGED).map((failure) => ({
|
|
32919
|
-
entity_type: failure.entityType,
|
|
32920
|
-
entity_id: failure.entityId,
|
|
32921
|
-
message: scrub(failure.message, state2)
|
|
32922
|
-
}))
|
|
32923
|
-
} : {}
|
|
32924
|
-
};
|
|
32925
|
-
}
|
|
32926
|
-
function flowContext(state2) {
|
|
32927
|
-
return {
|
|
32928
|
-
agent: state2.agent,
|
|
32929
|
-
space_id: state2.spaceId,
|
|
32930
|
-
environment_id: state2.environmentId,
|
|
32931
|
-
host: state2.host,
|
|
32932
|
-
credentials_skipped: state2.credentialsSkipped,
|
|
32933
|
-
components_generated: state2.generatedCount,
|
|
32934
|
-
components_accepted: state2.generatedAcceptedCount,
|
|
32935
|
-
tokens: state2.tokenCount,
|
|
32936
|
-
cma_token: state2.cmaToken
|
|
32937
|
-
};
|
|
32938
|
-
}
|
|
32939
|
-
function arrive(trail, state2) {
|
|
32940
|
-
const next = { ...trail, at: state2.step };
|
|
32941
|
-
if (state2.step === "error") {
|
|
32942
|
-
next.failure = { step: state2.errorStep, message: scrub(state2.errorMessage, state2) };
|
|
32943
|
-
}
|
|
32944
|
-
if (state2.step === "preview-validation-error") {
|
|
32945
|
-
next.validation = {
|
|
32946
|
-
count: state2.previewValidationErrors.length,
|
|
32947
|
-
errors: state2.previewValidationErrors.slice(0, MAX_LOGGED).map((error) => ({
|
|
32948
|
-
component: error.componentName,
|
|
32949
|
-
path: error.path,
|
|
32950
|
-
message: scrub(error.message, state2)
|
|
32951
|
-
})),
|
|
32952
|
-
missing_names: state2.previewValidationMissingNames.slice(0, MAX_LOGGED * 2)
|
|
32953
|
-
};
|
|
32954
|
-
}
|
|
32955
|
-
return next;
|
|
32956
|
-
}
|
|
32957
|
-
function openTrail(state2, now) {
|
|
32958
|
-
return arrive({ startedAt: now, stageStartedAt: now, at: state2.step, stages: [] }, state2);
|
|
32959
|
-
}
|
|
32960
|
-
function advance(trail, from, to, now) {
|
|
32961
|
-
const next = { ...trail, stages: [...trail.stages], stageStartedAt: now };
|
|
32962
|
-
const failed = to.step === "error" || to.step === "preview-validation-error" || from.step === "pushing" && pushHasFailures(to.pushResult);
|
|
32963
|
-
if (WORK.includes(from.step)) {
|
|
32964
|
-
next.stages.push(`${LABELS[from.step]}: ${failed ? "failed" : "ok"} (${seconds(now - trail.stageStartedAt)}s)`);
|
|
32965
|
-
}
|
|
32966
|
-
if (from.step === "previewing" && to.serverPreview) next.preview = previewSummary(to.serverPreview);
|
|
32967
|
-
if (from.step === "pushing") {
|
|
32968
|
-
next.push = pushSummary(to.pushResult, to);
|
|
32969
|
-
next.pushFailed = pushHasFailures(to.pushResult);
|
|
32970
|
-
}
|
|
32971
|
-
if (from.step === "printing" && !failed) next.saved = { path: to.componentsPath, run_id: to.lastRunId };
|
|
32972
|
-
return arrive(next, to);
|
|
32973
|
-
}
|
|
32974
|
-
function render2(trail, now, outcome) {
|
|
32975
|
-
return {
|
|
32976
|
-
outcome,
|
|
32977
|
-
total_seconds: seconds(now - trail.startedAt),
|
|
32978
|
-
stages: trail.stages,
|
|
32979
|
-
...trail.preview ? { preview: trail.preview } : {},
|
|
32980
|
-
...trail.push ? { push: trail.push } : {},
|
|
32981
|
-
...trail.saved ? { saved: trail.saved } : {},
|
|
32982
|
-
...trail.failure ? { error: trail.failure } : {},
|
|
32983
|
-
...trail.validation ? { preview_validation: trail.validation } : {}
|
|
32984
|
-
};
|
|
32985
|
-
}
|
|
32986
|
-
function flowProgress(trail, now) {
|
|
32987
|
-
return render2(trail, now, `interrupted at ${LABELS[trail.at]}`);
|
|
32988
|
-
}
|
|
32989
|
-
function flowFinish(trail, final, now) {
|
|
32990
|
-
if (!final) {
|
|
32991
|
-
const midWork = WORK.includes(trail.at);
|
|
32992
|
-
const outcome2 = `left the import ${midWork ? "while" : "at"} ${LABELS[trail.at]}${midWork ? " was running" : ""}`;
|
|
32993
|
-
return { outputs: render2(trail, now, outcome2), status: midWork ? "error" : "success", exitMethod: "discarded" };
|
|
32994
|
-
}
|
|
32995
|
-
if (final.step === "final-review") {
|
|
32996
|
-
return {
|
|
32997
|
-
outputs: render2(trail, now, "went back to edit the definitions"),
|
|
32998
|
-
status: "success",
|
|
32999
|
-
exitMethod: "discarded"
|
|
33000
|
-
};
|
|
33001
|
-
}
|
|
33002
|
-
let outcome;
|
|
33003
|
-
let failed = true;
|
|
33004
|
-
if (trail.validation) {
|
|
33005
|
-
outcome = `blocked by ${String(trail.validation["count"])} preview validation error(s)`;
|
|
33006
|
-
} else if (trail.failure) {
|
|
33007
|
-
outcome = `failed at ${trail.failure.step}: ${trail.failure.message.slice(0, MAX_OUTCOME)}`;
|
|
33008
|
-
} else if (trail.pushFailed) {
|
|
33009
|
-
outcome = "pushed, but some entities failed";
|
|
33010
|
-
} else {
|
|
33011
|
-
failed = false;
|
|
33012
|
-
outcome = final.credentialsSkipped ? "saved without pushing (credentials skipped)" : "published";
|
|
33013
|
-
}
|
|
33014
|
-
return {
|
|
33015
|
-
outputs: render2(trail, now, outcome),
|
|
33016
|
-
status: failed ? "error" : "success",
|
|
33017
|
-
exitMethod: failed ? "discarded" : "saved"
|
|
33018
|
-
};
|
|
33019
|
-
}
|
|
33020
|
-
var FLOW_RUN, LABELS, WORK, FINISHED, MAX_LOGGED, MAX_OUTCOME, scrub, seconds, pushHasFailures, isFlowFinished;
|
|
33021
|
-
var init_flow_log = __esm({
|
|
33022
|
-
"packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/flow-log.ts"() {
|
|
33023
|
-
"use strict";
|
|
33024
|
-
init_debug_trail();
|
|
33025
|
-
FLOW_RUN = { flow: "import/publish", step: "10-publish", menuOption: "Publish" };
|
|
33026
|
-
LABELS = {
|
|
33027
|
-
"final-review": "Final review",
|
|
33028
|
-
"path-prompt": "Save path",
|
|
33029
|
-
printing: "Save files",
|
|
33030
|
-
previewing: "Preview",
|
|
33031
|
-
"preview-gate": "Preview confirmation",
|
|
33032
|
-
pushing: "Push",
|
|
33033
|
-
"print-gate": "Files saved",
|
|
33034
|
-
done: "Done",
|
|
33035
|
-
error: "Error",
|
|
33036
|
-
"preview-validation-error": "Preview validation"
|
|
33037
|
-
};
|
|
33038
|
-
WORK = ["printing", "previewing", "pushing"];
|
|
33039
|
-
FINISHED = ["done", "error", "preview-validation-error", "final-review"];
|
|
33040
|
-
MAX_LOGGED = 10;
|
|
33041
|
-
MAX_OUTCOME = 200;
|
|
33042
|
-
scrub = (text, state2) => scrubError(text, [state2.cmaToken]);
|
|
33043
|
-
seconds = (ms) => Math.round(ms / 100) / 10;
|
|
33044
|
-
pushHasFailures = (result) => result.componentTypes.failed + result.designTokens.failed > 0 || (result.failures?.length ?? 0) > 0 || (result.summary?.failed ?? 0) > 0;
|
|
33045
|
-
isFlowFinished = (step) => FINISHED.includes(step);
|
|
33046
|
-
}
|
|
33047
|
-
});
|
|
33048
|
-
|
|
33049
|
-
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts
|
|
33050
|
-
import { useEffect as useEffect28, useRef as useRef18 } from "react";
|
|
33051
|
-
function useFlowLog(state2) {
|
|
33052
|
-
const trail = useRef18(void 0);
|
|
33053
|
-
const previous = useRef18(void 0);
|
|
33054
|
-
useEffect28(() => {
|
|
33055
|
-
const before = previous.current;
|
|
33056
|
-
previous.current = state2;
|
|
33057
|
-
const moved = before !== void 0 && before.step !== state2.step;
|
|
33058
|
-
const now = Date.now();
|
|
33059
|
-
let open = trail.current;
|
|
33060
|
-
if (!open) {
|
|
33061
|
-
if (state2.step === "final-review" || before && !moved) return;
|
|
33062
|
-
open = openTrail(state2, now);
|
|
33063
|
-
startDebugRun({ ...FLOW_RUN, inputs: flowContext(state2) });
|
|
33064
|
-
} else if (before && moved) {
|
|
33065
|
-
open = advance(open, before, state2, now);
|
|
33066
|
-
} else {
|
|
33067
|
-
return;
|
|
33068
|
-
}
|
|
33069
|
-
if (isFlowFinished(state2.step)) {
|
|
33070
|
-
trail.current = void 0;
|
|
33071
|
-
void finishDebugRun(flowFinish(open, state2, now));
|
|
33072
|
-
return;
|
|
33073
|
-
}
|
|
33074
|
-
trail.current = open;
|
|
33075
|
-
setDebugRunProgress(flowProgress(open, now));
|
|
33076
|
-
}, [state2]);
|
|
33077
|
-
useEffect28(
|
|
33078
|
-
() => () => {
|
|
33079
|
-
const open = trail.current;
|
|
33080
|
-
trail.current = void 0;
|
|
33081
|
-
if (open) void finishDebugRun(flowFinish(open, void 0, Date.now()));
|
|
33082
|
-
},
|
|
33083
|
-
[]
|
|
33084
|
-
);
|
|
33085
|
-
}
|
|
33086
|
-
var init_use_flow_log = __esm({
|
|
33087
|
-
"packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts"() {
|
|
33088
|
-
"use strict";
|
|
33089
|
-
init_debug_store();
|
|
33090
|
-
init_flow_log();
|
|
33091
|
-
}
|
|
33092
|
-
});
|
|
33093
|
-
|
|
33094
32435
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/screen.tsx
|
|
33095
32436
|
import { Box as Box45 } from "ink";
|
|
33096
32437
|
import { jsx as jsx56, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
@@ -33105,7 +32446,6 @@ function FlowScreen({
|
|
|
33105
32446
|
generatePromptPath,
|
|
33106
32447
|
onExit
|
|
33107
32448
|
}) {
|
|
33108
|
-
useFlowLog(state2);
|
|
33109
32449
|
const produced = producedOf(state2);
|
|
33110
32450
|
const counts = { components: state2.generatedAcceptedCount, tokens: state2.tokenCount };
|
|
33111
32451
|
const things = countedThings(produced, counts);
|
|
@@ -33233,7 +32573,6 @@ var init_screen11 = __esm({
|
|
|
33233
32573
|
init_WizardPreviewStep();
|
|
33234
32574
|
init_produced();
|
|
33235
32575
|
init_run_teaser();
|
|
33236
|
-
init_use_flow_log();
|
|
33237
32576
|
}
|
|
33238
32577
|
});
|
|
33239
32578
|
|
|
@@ -33626,7 +32965,8 @@ function buildSavedCDF(components, tokens, opts = {}) {
|
|
|
33626
32965
|
if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
|
|
33627
32966
|
const validation = validateCDF2(cdf);
|
|
33628
32967
|
if (!validation.valid) {
|
|
33629
|
-
|
|
32968
|
+
const errors = validation.errors.filter((error) => error.message !== 'must match "then" schema');
|
|
32969
|
+
throw new Error(`generated CDF failed validation: ${errors.map(describeCdfError).join("; ")}`);
|
|
33630
32970
|
}
|
|
33631
32971
|
return cdf;
|
|
33632
32972
|
}
|
|
@@ -33705,7 +33045,7 @@ async function recordRun(input, deps) {
|
|
|
33705
33045
|
return null;
|
|
33706
33046
|
}
|
|
33707
33047
|
}
|
|
33708
|
-
var SAVE_CONFIRMATION_DELAY_MS, realSaveDeps;
|
|
33048
|
+
var SAVE_CONFIRMATION_DELAY_MS, describeCdfError, realSaveDeps;
|
|
33709
33049
|
var init_save = __esm({
|
|
33710
33050
|
"packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts"() {
|
|
33711
33051
|
"use strict";
|
|
@@ -33713,6 +33053,7 @@ var init_save = __esm({
|
|
|
33713
33053
|
init_src4();
|
|
33714
33054
|
init_run_print_files_helpers();
|
|
33715
33055
|
SAVE_CONFIRMATION_DELAY_MS = 1e3;
|
|
33056
|
+
describeCdfError = (error) => `${error.path.replace(/^\//, "").replace("/$properties/", ".").replaceAll("/", ".")}: ${error.message}`;
|
|
33716
33057
|
realSaveDeps = () => ({
|
|
33717
33058
|
openDb: openPipelineDb,
|
|
33718
33059
|
readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
|
|
@@ -34031,9 +33372,9 @@ var init_controller = __esm({
|
|
|
34031
33372
|
});
|
|
34032
33373
|
|
|
34033
33374
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
|
|
34034
|
-
import { useEffect as
|
|
33375
|
+
import { useEffect as useEffect24, useRef as useRef17, useSyncExternalStore } from "react";
|
|
34035
33376
|
function useFlow(start, options = {}) {
|
|
34036
|
-
const controller =
|
|
33377
|
+
const controller = useRef17();
|
|
34037
33378
|
if (start && !controller.current) {
|
|
34038
33379
|
try {
|
|
34039
33380
|
startWizardLog();
|
|
@@ -34050,7 +33391,7 @@ function useFlow(start, options = {}) {
|
|
|
34050
33391
|
(listener) => current?.subscribe(listener) ?? (() => void 0),
|
|
34051
33392
|
() => current?.getState()
|
|
34052
33393
|
);
|
|
34053
|
-
|
|
33394
|
+
useEffect24(() => {
|
|
34054
33395
|
if (!start) controller.current = void 0;
|
|
34055
33396
|
}, [start]);
|
|
34056
33397
|
return current && state2 ? { controller: current, state: state2 } : void 0;
|
|
@@ -34129,7 +33470,7 @@ var init_help_info = __esm({
|
|
|
34129
33470
|
});
|
|
34130
33471
|
|
|
34131
33472
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
34132
|
-
import { useEffect as
|
|
33473
|
+
import { useEffect as useEffect25, useState as useState31 } from "react";
|
|
34133
33474
|
import { Box as Box46, Text as Text47, useInput as useInput13 } from "ink";
|
|
34134
33475
|
import { Fragment as Fragment17, jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
34135
33476
|
function Section({ title, rows }) {
|
|
@@ -34143,7 +33484,7 @@ function Section({ title, rows }) {
|
|
|
34143
33484
|
}
|
|
34144
33485
|
function HelpScreen({ onDone }) {
|
|
34145
33486
|
const [info, setInfo] = useState31();
|
|
34146
|
-
|
|
33487
|
+
useEffect25(() => {
|
|
34147
33488
|
startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
|
|
34148
33489
|
void readHelpInfo().then(setInfo);
|
|
34149
33490
|
}, []);
|
|
@@ -34251,6 +33592,45 @@ var init_PageContainer3 = __esm({
|
|
|
34251
33592
|
}
|
|
34252
33593
|
});
|
|
34253
33594
|
|
|
33595
|
+
// packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts
|
|
33596
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
33597
|
+
function diffSnapshots(before, after) {
|
|
33598
|
+
const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
|
|
33599
|
+
const changed_fields = names.filter((name) => before[name] !== after[name]);
|
|
33600
|
+
return { changed: changed_fields.length > 0, changed_fields };
|
|
33601
|
+
}
|
|
33602
|
+
function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
|
|
33603
|
+
const actions = [];
|
|
33604
|
+
return {
|
|
33605
|
+
record(action) {
|
|
33606
|
+
actions.push(action);
|
|
33607
|
+
if (actions.length > limit) actions.shift();
|
|
33608
|
+
},
|
|
33609
|
+
entries: () => [...actions]
|
|
33610
|
+
};
|
|
33611
|
+
}
|
|
33612
|
+
function scrubError(error, secrets) {
|
|
33613
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
33614
|
+
for (const secret of secrets) {
|
|
33615
|
+
if (secret.length < MIN_SECRET_LENGTH) continue;
|
|
33616
|
+
for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
|
|
33617
|
+
}
|
|
33618
|
+
return message;
|
|
33619
|
+
}
|
|
33620
|
+
function describeSettingsFile() {
|
|
33621
|
+
const path5 = configFilePath2();
|
|
33622
|
+
return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync11(path5) };
|
|
33623
|
+
}
|
|
33624
|
+
var DEFAULT_TRAIL_LIMIT, MIN_SECRET_LENGTH;
|
|
33625
|
+
var init_debug_trail = __esm({
|
|
33626
|
+
"packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts"() {
|
|
33627
|
+
"use strict";
|
|
33628
|
+
init_config();
|
|
33629
|
+
DEFAULT_TRAIL_LIMIT = 30;
|
|
33630
|
+
MIN_SECRET_LENGTH = 6;
|
|
33631
|
+
}
|
|
33632
|
+
});
|
|
33633
|
+
|
|
34254
33634
|
// packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
|
|
34255
33635
|
import { execFile as execFile2 } from "node:child_process";
|
|
34256
33636
|
import { access as access5, constants } from "node:fs/promises";
|
|
@@ -34316,7 +33696,7 @@ async function testAgent(name, binary, model) {
|
|
|
34316
33696
|
timeoutMs: PROMPT_TIMEOUT_MS
|
|
34317
33697
|
})
|
|
34318
33698
|
);
|
|
34319
|
-
const
|
|
33699
|
+
const seconds = ((Date.now() - started) / 1e3).toFixed(1);
|
|
34320
33700
|
if (result.timedOut) {
|
|
34321
33701
|
return [...checks, { ...fail3("prompt", `no answer within ${PROMPT_TIMEOUT_MS / 1e3}s`), timedOut: true }];
|
|
34322
33702
|
}
|
|
@@ -34324,7 +33704,7 @@ async function testAgent(name, binary, model) {
|
|
|
34324
33704
|
const reason = result.stderr.trim().split("\n").pop()?.slice(0, 160) || `exited with code ${result.exitCode}`;
|
|
34325
33705
|
return [...checks, fail3("prompt", reason)];
|
|
34326
33706
|
}
|
|
34327
|
-
return [...checks, pass("prompt", `answered in ${
|
|
33707
|
+
return [...checks, pass("prompt", `answered in ${seconds}s`)];
|
|
34328
33708
|
}
|
|
34329
33709
|
function statusFromChecks(name, checks, savedBinary) {
|
|
34330
33710
|
if (checks.length === 0) return "checking";
|
|
@@ -34525,7 +33905,7 @@ var init_AgentStatusBadge = __esm({
|
|
|
34525
33905
|
});
|
|
34526
33906
|
|
|
34527
33907
|
// packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx
|
|
34528
|
-
import { useEffect as
|
|
33908
|
+
import { useEffect as useEffect26, useState as useState33 } from "react";
|
|
34529
33909
|
import { Box as Box48, Text as Text50 } from "ink";
|
|
34530
33910
|
import { jsx as jsx60, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
34531
33911
|
function StatusHeading() {
|
|
@@ -34546,7 +33926,7 @@ function AgentDetail({
|
|
|
34546
33926
|
const [testing, setTesting] = useState33(false);
|
|
34547
33927
|
const [notice, setNotice] = useState33(null);
|
|
34548
33928
|
const [checks, setChecks] = useState33(void 0);
|
|
34549
|
-
|
|
33929
|
+
useEffect26(() => {
|
|
34550
33930
|
let active = true;
|
|
34551
33931
|
setChecks(void 0);
|
|
34552
33932
|
const timer = setTimeout(() => {
|
|
@@ -34638,7 +34018,7 @@ var init_AgentDetail = __esm({
|
|
|
34638
34018
|
});
|
|
34639
34019
|
|
|
34640
34020
|
// packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
|
|
34641
|
-
import { useEffect as
|
|
34021
|
+
import { useEffect as useEffect27, useRef as useRef18, useState as useState34 } from "react";
|
|
34642
34022
|
import { Box as Box49, Text as Text51, useInput as useInput15 } from "ink";
|
|
34643
34023
|
import { Fragment as Fragment18, jsx as jsx61, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
34644
34024
|
function AgentsScreen({ onDone }) {
|
|
@@ -34649,7 +34029,7 @@ function AgentsScreen({ onDone }) {
|
|
|
34649
34029
|
const [saving, setSaving] = useState34(false);
|
|
34650
34030
|
const [loadError, setLoadError] = useState34(null);
|
|
34651
34031
|
const [checks, setChecks] = useState34({});
|
|
34652
|
-
const visit =
|
|
34032
|
+
const visit = useRef18({
|
|
34653
34033
|
trail: createTrail(),
|
|
34654
34034
|
before: void 0,
|
|
34655
34035
|
environment: void 0,
|
|
@@ -34662,7 +34042,7 @@ function AgentsScreen({ onDone }) {
|
|
|
34662
34042
|
);
|
|
34663
34043
|
}
|
|
34664
34044
|
};
|
|
34665
|
-
|
|
34045
|
+
useEffect27(() => {
|
|
34666
34046
|
readAgentConfig().then((loaded) => {
|
|
34667
34047
|
setConfig(loaded);
|
|
34668
34048
|
inspectAll(loaded);
|
|
@@ -34888,7 +34268,7 @@ var init_project_store = __esm({
|
|
|
34888
34268
|
});
|
|
34889
34269
|
|
|
34890
34270
|
// packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
|
|
34891
|
-
import { useEffect as
|
|
34271
|
+
import { useEffect as useEffect28, useRef as useRef19, useState as useState35 } from "react";
|
|
34892
34272
|
import { Box as Box50, Text as Text52, useInput as useInput16 } from "ink";
|
|
34893
34273
|
import { Fragment as Fragment19, jsx as jsx62, jsxs as jsxs50 } from "react/jsx-runtime";
|
|
34894
34274
|
function debugFields(config) {
|
|
@@ -34907,14 +34287,14 @@ function ProjectScreen({ onDone }) {
|
|
|
34907
34287
|
const [saving, setSaving] = useState35(false);
|
|
34908
34288
|
const [notice, setNotice] = useState35(null);
|
|
34909
34289
|
const [loadError, setLoadError] = useState35(null);
|
|
34910
|
-
const visit =
|
|
34290
|
+
const visit = useRef19({
|
|
34911
34291
|
trail: createTrail(),
|
|
34912
34292
|
before: void 0,
|
|
34913
34293
|
persisted: void 0,
|
|
34914
34294
|
error: ""
|
|
34915
34295
|
}).current;
|
|
34916
|
-
const
|
|
34917
|
-
|
|
34296
|
+
const scrub = (err) => scrubError(err, [config?.cmaToken ?? ""]);
|
|
34297
|
+
useEffect28(() => {
|
|
34918
34298
|
readCredentials().then((cfg) => {
|
|
34919
34299
|
setConfig(cfg);
|
|
34920
34300
|
visit.before = snapshotOf(cfg);
|
|
@@ -34981,7 +34361,7 @@ function ProjectScreen({ onDone }) {
|
|
|
34981
34361
|
if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
|
|
34982
34362
|
setNotice({ kind: "success", text: "Project settings saved" });
|
|
34983
34363
|
}).catch((err) => {
|
|
34984
|
-
visit.error =
|
|
34364
|
+
visit.error = scrub(err);
|
|
34985
34365
|
visit.trail.record("save failed");
|
|
34986
34366
|
setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
|
|
34987
34367
|
}).finally(() => setSaving(false));
|
|
@@ -35101,13 +34481,13 @@ var init_ConfigurationScreen = __esm({
|
|
|
35101
34481
|
});
|
|
35102
34482
|
|
|
35103
34483
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
35104
|
-
import { useEffect as
|
|
34484
|
+
import { useEffect as useEffect29, useState as useState37 } from "react";
|
|
35105
34485
|
import { Box as Box52, Text as Text54, useInput as useInput18 } from "ink";
|
|
35106
34486
|
import { Fragment as Fragment20, jsx as jsx64, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
35107
34487
|
function OptInAnalyticsScreen({ onDone }) {
|
|
35108
34488
|
const [loading, setLoading] = useState37(true);
|
|
35109
34489
|
const [enabled, setEnabled] = useState37(true);
|
|
35110
|
-
|
|
34490
|
+
useEffect29(() => {
|
|
35111
34491
|
readAnalyticsSetting().then((setting) => {
|
|
35112
34492
|
setEnabled(setting.enabled);
|
|
35113
34493
|
setLoading(false);
|
|
@@ -35170,7 +34550,7 @@ var init_screen12 = __esm({
|
|
|
35170
34550
|
});
|
|
35171
34551
|
|
|
35172
34552
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
35173
|
-
import { useEffect as
|
|
34553
|
+
import { useEffect as useEffect30, useRef as useRef20, useState as useState38 } from "react";
|
|
35174
34554
|
import { Box as Box53, Text as Text55, useInput as useInput19 } from "ink";
|
|
35175
34555
|
import { Fragment as Fragment21, jsx as jsx65, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
35176
34556
|
function DebugModeScreen({ onDone }) {
|
|
@@ -35180,8 +34560,8 @@ function DebugModeScreen({ onDone }) {
|
|
|
35180
34560
|
RETENTION_CHOICES[RETENTION_CHOICES.length - 1]
|
|
35181
34561
|
);
|
|
35182
34562
|
const [notice, setNotice] = useState38(null);
|
|
35183
|
-
const visit =
|
|
35184
|
-
|
|
34563
|
+
const visit = useRef20({ trail: createTrail(), before: void 0, error: "" }).current;
|
|
34564
|
+
useEffect30(() => {
|
|
35185
34565
|
readDebugModeSetting().then((loaded) => {
|
|
35186
34566
|
setSetting(loaded);
|
|
35187
34567
|
setPending(loaded.retentionDays);
|
|
@@ -35322,7 +34702,7 @@ var app_exports = {};
|
|
|
35322
34702
|
__export(app_exports, {
|
|
35323
34703
|
runApp: () => runApp
|
|
35324
34704
|
});
|
|
35325
|
-
import { useEffect as
|
|
34705
|
+
import { useEffect as useEffect31, useState as useState39 } from "react";
|
|
35326
34706
|
import { Fragment as Fragment22, jsx as jsx66 } from "react/jsx-runtime";
|
|
35327
34707
|
function App({ importOptions, inkClear }) {
|
|
35328
34708
|
const [screen, setScreen] = useState39("start");
|
|
@@ -35356,7 +34736,7 @@ function App({ importOptions, inkClear }) {
|
|
|
35356
34736
|
const [flowStart, setFlowStart] = useState39();
|
|
35357
34737
|
const flow = useFlow(flowStart, { beforeStepChange: inkClear });
|
|
35358
34738
|
const [importDefaults, setImportDefaults] = useState39();
|
|
35359
|
-
|
|
34739
|
+
useEffect31(() => {
|
|
35360
34740
|
if (screen !== "import") {
|
|
35361
34741
|
setImportDefaults(void 0);
|
|
35362
34742
|
return;
|
|
@@ -35429,7 +34809,7 @@ function App({ importOptions, inkClear }) {
|
|
|
35429
34809
|
}
|
|
35430
34810
|
});
|
|
35431
34811
|
};
|
|
35432
|
-
|
|
34812
|
+
useEffect31(() => {
|
|
35433
34813
|
if (!tokensOnlyRun || tokensOnly?.status !== "done" || !tokensOnly.result.ok) return;
|
|
35434
34814
|
const { credentialsSkipped, input, tokens } = tokensOnlyRun;
|
|
35435
34815
|
const { tokensPath, tokenSessionId, tokenCount } = tokensOnly.result;
|
|
@@ -35451,12 +34831,12 @@ function App({ importOptions, inkClear }) {
|
|
|
35451
34831
|
}
|
|
35452
34832
|
});
|
|
35453
34833
|
}, [tokensOnly, tokensOnlyRun]);
|
|
35454
|
-
|
|
34834
|
+
useEffect31(() => {
|
|
35455
34835
|
if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
|
|
35456
34836
|
setExtractionRun(void 0);
|
|
35457
34837
|
setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
|
|
35458
34838
|
}, [extraction, extractionRun]);
|
|
35459
|
-
|
|
34839
|
+
useEffect31(() => {
|
|
35460
34840
|
if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
|
|
35461
34841
|
const { extraction: produced, input, generatePromptPath } = scopeRun;
|
|
35462
34842
|
setGenerationInput({
|
|
@@ -35474,7 +34854,7 @@ function App({ importOptions, inkClear }) {
|
|
|
35474
34854
|
...generatePromptPath ? { generatePromptPath } : {}
|
|
35475
34855
|
});
|
|
35476
34856
|
}, [scopeFlow, scopeRun, generationInput]);
|
|
35477
|
-
|
|
34857
|
+
useEffect31(() => {
|
|
35478
34858
|
if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
|
|
35479
34859
|
const { credentialsSkipped, extraction: produced, input, generatePromptPath } = scopeRun;
|
|
35480
34860
|
inkClear();
|
|
@@ -35643,7 +35023,6 @@ function App({ importOptions, inkClear }) {
|
|
|
35643
35023
|
return /* @__PURE__ */ jsx66(
|
|
35644
35024
|
CredentialsScreen,
|
|
35645
35025
|
{
|
|
35646
|
-
mode: target,
|
|
35647
35026
|
initial: importDefaults.credentials,
|
|
35648
35027
|
tokensOnly: target === "tokens",
|
|
35649
35028
|
onBack: () => goBackFrom("credentials"),
|
|
@@ -35781,9 +35160,9 @@ var pkg = JSON.parse(
|
|
|
35781
35160
|
function createProgram() {
|
|
35782
35161
|
const program = new Command().name("experiences").description("Contentful Experiences design system import CLI").version(pkg.version, "--version", "Print version number");
|
|
35783
35162
|
registerImportCommand(program, async (options) => {
|
|
35784
|
-
const { render
|
|
35163
|
+
const { render } = await import("ink");
|
|
35785
35164
|
const { runApp: runApp2 } = await Promise.resolve().then(() => (init_app(), app_exports));
|
|
35786
|
-
await runApp2(
|
|
35165
|
+
await runApp2(render, options);
|
|
35787
35166
|
});
|
|
35788
35167
|
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
35789
35168
|
const chain = [];
|