@contentful/experience-design-system-cli 2.41.1-dev-build-bf9d918c.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 +154 -619
- package/dist/index.js +172 -650
- 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/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/10-flow/flow/flow-log.d.ts +0 -48
- 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/app.js
CHANGED
|
@@ -197,7 +197,6 @@ __export(debug_store_exports, {
|
|
|
197
197
|
currentDebugSessionDir: () => currentDebugSessionDir,
|
|
198
198
|
currentSessionDir: () => currentSessionDir,
|
|
199
199
|
finishDebugRun: () => finishDebugRun,
|
|
200
|
-
setDebugRunProgress: () => setDebugRunProgress,
|
|
201
200
|
startDebugRun: () => startDebugRun,
|
|
202
201
|
startDebugSessionIn: () => startDebugSessionIn,
|
|
203
202
|
startImportRun: () => startImportRun
|
|
@@ -293,15 +292,11 @@ function startDebugRun({
|
|
|
293
292
|
const runId = generateRunId();
|
|
294
293
|
const startedAt = Date.now();
|
|
295
294
|
const redactedInputs = redact(inputs);
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (!enabled && pendingRun === run) pendingRun = void 0;
|
|
295
|
+
isDebugModeEnabled().then((enabled) => {
|
|
296
|
+
if (!enabled) return;
|
|
297
|
+
pendingRun = { flow, step, runId, menuOption, inputs: redactedInputs, startedAt };
|
|
300
298
|
});
|
|
301
299
|
}
|
|
302
|
-
function setDebugRunProgress(outputs) {
|
|
303
|
-
if (pendingRun) pendingRun.progress = outputs;
|
|
304
|
-
}
|
|
305
300
|
async function finishDebugRun({
|
|
306
301
|
outputs,
|
|
307
302
|
status,
|
|
@@ -310,10 +305,9 @@ async function finishDebugRun({
|
|
|
310
305
|
const run = pendingRun;
|
|
311
306
|
if (!run) return;
|
|
312
307
|
pendingRun = void 0;
|
|
313
|
-
if (!await isDebugModeEnabled()) return;
|
|
314
308
|
const durationMs = Date.now() - run.startedAt;
|
|
315
309
|
const log = {
|
|
316
|
-
flow:
|
|
310
|
+
flow: run.flow,
|
|
317
311
|
menuOption: run.menuOption,
|
|
318
312
|
content: renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs })
|
|
319
313
|
};
|
|
@@ -324,9 +318,6 @@ async function finishDebugRun({
|
|
|
324
318
|
}
|
|
325
319
|
await writeLog(root, log);
|
|
326
320
|
}
|
|
327
|
-
function logFolder(flow, step) {
|
|
328
|
-
return flow.startsWith("import/") && /^\d+-/.test(step) ? `import/${step}` : flow;
|
|
329
|
-
}
|
|
330
321
|
async function writeLog(root, log) {
|
|
331
322
|
const dir = join5(root, ...log.flow.split("/"));
|
|
332
323
|
await mkdir2(dir, { recursive: true });
|
|
@@ -383,7 +374,7 @@ ${JSON.stringify(finish.outputs, null, 2)}
|
|
|
383
374
|
`;
|
|
384
375
|
}
|
|
385
376
|
function handleCrash() {
|
|
386
|
-
return finishDebugRun({ outputs:
|
|
377
|
+
return finishDebugRun({ outputs: {}, status: "error", exitMethod: "crashed" });
|
|
387
378
|
}
|
|
388
379
|
var pendingRun, sessionDir, WAITING_LIMIT, waiting;
|
|
389
380
|
var init_debug_store = __esm({
|
|
@@ -427,17 +418,11 @@ var init_debug_store = __esm({
|
|
|
427
418
|
throw reason;
|
|
428
419
|
});
|
|
429
420
|
});
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
["SIGHUP", 129]
|
|
434
|
-
]) {
|
|
435
|
-
process.once(signal, () => {
|
|
436
|
-
void handleCrash().finally(() => {
|
|
437
|
-
process.exit(exitCode);
|
|
438
|
-
});
|
|
421
|
+
process.once("SIGINT", () => {
|
|
422
|
+
void handleCrash().finally(() => {
|
|
423
|
+
process.exit(130);
|
|
439
424
|
});
|
|
440
|
-
}
|
|
425
|
+
});
|
|
441
426
|
}
|
|
442
427
|
});
|
|
443
428
|
|
|
@@ -1691,9 +1676,12 @@ var init_schema = __esm({
|
|
|
1691
1676
|
$required: { type: "boolean" },
|
|
1692
1677
|
$default: {},
|
|
1693
1678
|
$values: { type: "array", items: { type: "string" } },
|
|
1694
|
-
"$token.kind": { type: "string" },
|
|
1679
|
+
"$token.kind": { type: "string", minLength: 1 },
|
|
1695
1680
|
"$token.allowed": { type: "array", items: { type: "string" } }
|
|
1696
1681
|
},
|
|
1682
|
+
// The API rejects a token property that does not say which kind of token it takes.
|
|
1683
|
+
if: { type: "object", properties: { $type: { const: "token" } }, required: ["$type"] },
|
|
1684
|
+
then: { type: "object", required: ["$token.kind"] },
|
|
1697
1685
|
additionalProperties: false
|
|
1698
1686
|
},
|
|
1699
1687
|
slot: {
|
|
@@ -2499,7 +2487,7 @@ var init_cache_keys = __esm({
|
|
|
2499
2487
|
});
|
|
2500
2488
|
|
|
2501
2489
|
// packages/experience-design-system-cli/app.tsx
|
|
2502
|
-
import { useEffect as
|
|
2490
|
+
import { useEffect as useEffect31, useState as useState39 } from "react";
|
|
2503
2491
|
|
|
2504
2492
|
// packages/experience-design-system-cli/src/tui/home/home.tsx
|
|
2505
2493
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
@@ -3057,8 +3045,8 @@ function progressPercent(progress) {
|
|
|
3057
3045
|
}
|
|
3058
3046
|
function formatElapsed(totalSeconds) {
|
|
3059
3047
|
const minutes = Math.floor(totalSeconds / 60);
|
|
3060
|
-
const
|
|
3061
|
-
return minutes > 0 ? `${minutes}m ${
|
|
3048
|
+
const seconds = totalSeconds % 60;
|
|
3049
|
+
return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
|
|
3062
3050
|
}
|
|
3063
3051
|
|
|
3064
3052
|
// packages/experience-design-system-cli/src/tui/import/shared/running-step/theme.ts
|
|
@@ -3076,12 +3064,12 @@ var PROGRESS_THEME = extendTheme(defaultTheme, {
|
|
|
3076
3064
|
// packages/experience-design-system-cli/src/tui/import/shared/running-step/use-elapsed.ts
|
|
3077
3065
|
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
3078
3066
|
function useElapsed() {
|
|
3079
|
-
const [
|
|
3067
|
+
const [seconds, setSeconds] = useState3(0);
|
|
3080
3068
|
useEffect3(() => {
|
|
3081
3069
|
const timer = setInterval(() => setSeconds((current) => current + 1), 1e3);
|
|
3082
3070
|
return () => clearInterval(timer);
|
|
3083
3071
|
}, []);
|
|
3084
|
-
return formatElapsed(
|
|
3072
|
+
return formatElapsed(seconds);
|
|
3085
3073
|
}
|
|
3086
3074
|
|
|
3087
3075
|
// packages/experience-design-system-cli/src/tui/import/shared/running-step/running-step.tsx
|
|
@@ -15268,8 +15256,8 @@ function retryAfterMs(response) {
|
|
|
15268
15256
|
const value = response.headers?.get("retry-after")?.trim();
|
|
15269
15257
|
if (!value)
|
|
15270
15258
|
return void 0;
|
|
15271
|
-
const
|
|
15272
|
-
const delayMs = Number.isFinite(
|
|
15259
|
+
const seconds = Number(value);
|
|
15260
|
+
const delayMs = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(value) - Date.now();
|
|
15273
15261
|
if (!Number.isFinite(delayMs) || delayMs < 0 || delayMs > MAX_RETRY_AFTER_MS)
|
|
15274
15262
|
return void 0;
|
|
15275
15263
|
return Math.round(delayMs);
|
|
@@ -17417,10 +17405,10 @@ async function readCandidateFiles(components, extraFiles = []) {
|
|
|
17417
17405
|
async function selectCompositionPromptFiles(components, sourceFiles) {
|
|
17418
17406
|
const allFiles = await readCandidateFiles(components, sourceFiles);
|
|
17419
17407
|
const selectedCandidates = selectCandidateFiles(allFiles).map((c2) => ({ path: c2.path, content: c2.content }));
|
|
17420
|
-
const
|
|
17421
|
-
const promptFiles =
|
|
17408
|
+
const capped = capCandidatesToPromptBudget(selectedCandidates);
|
|
17409
|
+
const promptFiles = capped.kept;
|
|
17422
17410
|
const runtimeFiles = allFiles.map((c2) => ({ path: c2.path, content: c2.content }));
|
|
17423
|
-
const droppedWarning =
|
|
17411
|
+
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;
|
|
17424
17412
|
return { promptFiles, runtimeFiles, droppedWarning };
|
|
17425
17413
|
}
|
|
17426
17414
|
|
|
@@ -18172,9 +18160,8 @@ function PathValidationScreen({
|
|
|
18172
18160
|
}
|
|
18173
18161
|
|
|
18174
18162
|
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
|
|
18175
|
-
import {
|
|
18163
|
+
import { useRef as useRef5, useState as useState9 } from "react";
|
|
18176
18164
|
import { Box as Box14, Text as Text14, useInput as useInput11 } from "ink";
|
|
18177
|
-
init_debug_store();
|
|
18178
18165
|
|
|
18179
18166
|
// packages/experience-design-system-cli/src/tui/shared/components/FieldForm.tsx
|
|
18180
18167
|
import { useState as useState8 } from "react";
|
|
@@ -18351,39 +18338,6 @@ function FieldForm({
|
|
|
18351
18338
|
] });
|
|
18352
18339
|
}
|
|
18353
18340
|
|
|
18354
|
-
// packages/experience-design-system-cli/src/tui/shared/debug-trail.ts
|
|
18355
|
-
init_config();
|
|
18356
|
-
import { existsSync as existsSync9 } from "node:fs";
|
|
18357
|
-
function diffSnapshots(before, after) {
|
|
18358
|
-
const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
|
|
18359
|
-
const changed_fields = names.filter((name) => before[name] !== after[name]);
|
|
18360
|
-
return { changed: changed_fields.length > 0, changed_fields };
|
|
18361
|
-
}
|
|
18362
|
-
var DEFAULT_TRAIL_LIMIT = 30;
|
|
18363
|
-
function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
|
|
18364
|
-
const actions = [];
|
|
18365
|
-
return {
|
|
18366
|
-
record(action) {
|
|
18367
|
-
actions.push(action);
|
|
18368
|
-
if (actions.length > limit) actions.shift();
|
|
18369
|
-
},
|
|
18370
|
-
entries: () => [...actions]
|
|
18371
|
-
};
|
|
18372
|
-
}
|
|
18373
|
-
var MIN_SECRET_LENGTH = 6;
|
|
18374
|
-
function scrubError(error, secrets) {
|
|
18375
|
-
let message = error instanceof Error ? error.message : String(error);
|
|
18376
|
-
for (const secret of secrets) {
|
|
18377
|
-
if (secret.length < MIN_SECRET_LENGTH) continue;
|
|
18378
|
-
for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
|
|
18379
|
-
}
|
|
18380
|
-
return message;
|
|
18381
|
-
}
|
|
18382
|
-
function describeSettingsFile() {
|
|
18383
|
-
const path5 = configFilePath();
|
|
18384
|
-
return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync9(path5) };
|
|
18385
|
-
}
|
|
18386
|
-
|
|
18387
18341
|
// packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
|
|
18388
18342
|
var FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
|
|
18389
18343
|
function credentialsPurpose(tokensOnly) {
|
|
@@ -18398,36 +18352,12 @@ function normalize(values) {
|
|
|
18398
18352
|
host: toConfiguredHost2(values.host) ?? DEFAULT_CONFIGURED_HOST
|
|
18399
18353
|
};
|
|
18400
18354
|
}
|
|
18401
|
-
function
|
|
18402
|
-
return
|
|
18355
|
+
function missingField(values) {
|
|
18356
|
+
return values.spaceId === "" || values.environmentId === "" || values.cmaToken === "";
|
|
18403
18357
|
}
|
|
18404
18358
|
function isUnchanged(current, initial) {
|
|
18405
18359
|
return FIELDS.every((field) => current[field] === initial[field]);
|
|
18406
18360
|
}
|
|
18407
|
-
function rejectedAttempt(reason, credentials) {
|
|
18408
|
-
return { host: credentials.host, reason: scrubError(reason, [credentials.cmaToken]) };
|
|
18409
|
-
}
|
|
18410
|
-
function credentialsLog(credentials) {
|
|
18411
|
-
return {
|
|
18412
|
-
space_id: credentials.spaceId,
|
|
18413
|
-
environment_id: credentials.environmentId,
|
|
18414
|
-
host: credentials.host,
|
|
18415
|
-
cma_token: credentials.cmaToken
|
|
18416
|
-
};
|
|
18417
|
-
}
|
|
18418
|
-
function credentialsOutputs({
|
|
18419
|
-
outcome,
|
|
18420
|
-
credentials,
|
|
18421
|
-
initial,
|
|
18422
|
-
attempts
|
|
18423
|
-
}) {
|
|
18424
|
-
return {
|
|
18425
|
-
outcome,
|
|
18426
|
-
...credentialsLog(credentials),
|
|
18427
|
-
changed_fields: diffSnapshots(initial, credentials).changed_fields,
|
|
18428
|
-
rejected_attempts: attempts
|
|
18429
|
-
};
|
|
18430
|
-
}
|
|
18431
18361
|
|
|
18432
18362
|
// packages/experience-design-system-cli/src/tui/user-agent.ts
|
|
18433
18363
|
init_version();
|
|
@@ -18475,9 +18405,7 @@ var MENU = [
|
|
|
18475
18405
|
{ choice: "continue", label: "Continue", description: "Check the credentials and go on" },
|
|
18476
18406
|
{ choice: "edit", label: "Edit", description: "Change the credentials" }
|
|
18477
18407
|
];
|
|
18478
|
-
var MAX_LOGGED_ATTEMPTS2 = 10;
|
|
18479
18408
|
function CredentialsScreen({
|
|
18480
|
-
mode,
|
|
18481
18409
|
onDone,
|
|
18482
18410
|
onBack,
|
|
18483
18411
|
initial = {},
|
|
@@ -18500,64 +18428,17 @@ function CredentialsScreen({
|
|
|
18500
18428
|
const [focus, setFocus] = useState9(0);
|
|
18501
18429
|
const [active, setActive] = useState9(0);
|
|
18502
18430
|
const [beforeEdit, setBeforeEdit] = useState9(initialValues);
|
|
18503
|
-
const visit = useRef5({ attempts: [], lastReason: "" }).current;
|
|
18504
|
-
useEffect8(() => {
|
|
18505
|
-
startDebugRun({
|
|
18506
|
-
flow: "import/credentials",
|
|
18507
|
-
step: "04-credentials",
|
|
18508
|
-
menuOption: "Credentials",
|
|
18509
|
-
inputs: { import_mode: mode, prefilled, ...credentialsLog(initialValues) }
|
|
18510
|
-
});
|
|
18511
|
-
}, []);
|
|
18512
|
-
const reject = (attempt, text) => {
|
|
18513
|
-
if (visit.attempts.length < MAX_LOGGED_ATTEMPTS2) visit.attempts.push(attempt);
|
|
18514
|
-
visit.lastReason = attempt.reason;
|
|
18515
|
-
setNotice({ kind: "error", text });
|
|
18516
|
-
};
|
|
18517
|
-
const leave = () => {
|
|
18518
|
-
void finishDebugRun({
|
|
18519
|
-
outputs: {
|
|
18520
|
-
...credentialsOutputs({
|
|
18521
|
-
outcome: "back",
|
|
18522
|
-
credentials: normalize(values),
|
|
18523
|
-
initial: initialValues,
|
|
18524
|
-
attempts: visit.attempts
|
|
18525
|
-
}),
|
|
18526
|
-
...notice ? { error: visit.lastReason } : {}
|
|
18527
|
-
},
|
|
18528
|
-
status: notice ? "error" : "success",
|
|
18529
|
-
exitMethod: "discarded"
|
|
18530
|
-
});
|
|
18531
|
-
onBack();
|
|
18532
|
-
};
|
|
18533
18431
|
const submit = async () => {
|
|
18534
18432
|
const credentials = normalize(values);
|
|
18535
|
-
|
|
18536
|
-
|
|
18537
|
-
reject(
|
|
18538
|
-
rejectedAttempt(`Missing required fields: ${missing.join(", ")}`, credentials),
|
|
18539
|
-
"Space ID, environment and CMA token are all required."
|
|
18540
|
-
);
|
|
18433
|
+
if (missingField(credentials)) {
|
|
18434
|
+
setNotice({ kind: "error", text: "Space ID, environment and CMA token are all required." });
|
|
18541
18435
|
return;
|
|
18542
18436
|
}
|
|
18543
18437
|
setValidating(true);
|
|
18544
18438
|
const result = await validate3(credentials);
|
|
18545
18439
|
setValidating(false);
|
|
18546
|
-
if (
|
|
18547
|
-
|
|
18548
|
-
return;
|
|
18549
|
-
}
|
|
18550
|
-
void finishDebugRun({
|
|
18551
|
-
outputs: credentialsOutputs({
|
|
18552
|
-
outcome: "validated",
|
|
18553
|
-
credentials,
|
|
18554
|
-
initial: initialValues,
|
|
18555
|
-
attempts: visit.attempts
|
|
18556
|
-
}),
|
|
18557
|
-
status: "success",
|
|
18558
|
-
exitMethod: "saved"
|
|
18559
|
-
});
|
|
18560
|
-
onDone({ skipped: false, credentials });
|
|
18440
|
+
if (result.ok) onDone({ skipped: false, credentials });
|
|
18441
|
+
else setNotice({ kind: "error", text: result.error });
|
|
18561
18442
|
};
|
|
18562
18443
|
const choose = (choice) => {
|
|
18563
18444
|
if (choice === "continue") void submit();
|
|
@@ -18566,7 +18447,7 @@ function CredentialsScreen({
|
|
|
18566
18447
|
setBeforeEdit(values);
|
|
18567
18448
|
setActive(0);
|
|
18568
18449
|
setEditing(true);
|
|
18569
|
-
} else
|
|
18450
|
+
} else onBack();
|
|
18570
18451
|
};
|
|
18571
18452
|
const stopEditing = () => {
|
|
18572
18453
|
setEditing(false);
|
|
@@ -18576,7 +18457,7 @@ function CredentialsScreen({
|
|
|
18576
18457
|
if (validating) return;
|
|
18577
18458
|
if (editing) {
|
|
18578
18459
|
if (key.escape) {
|
|
18579
|
-
if (!prefilled)
|
|
18460
|
+
if (!prefilled) onBack();
|
|
18580
18461
|
else {
|
|
18581
18462
|
setValues(beforeEdit);
|
|
18582
18463
|
setNotice(null);
|
|
@@ -18684,47 +18565,6 @@ function CredentialsScreen({
|
|
|
18684
18565
|
}
|
|
18685
18566
|
|
|
18686
18567
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/logic.ts
|
|
18687
|
-
function extractionLogInputs(input) {
|
|
18688
|
-
const { credentials } = input;
|
|
18689
|
-
return {
|
|
18690
|
-
project_path: input.projectPath,
|
|
18691
|
-
out_dir: input.outDir ?? "",
|
|
18692
|
-
files_to_scan: input.filePaths.length,
|
|
18693
|
-
raw_tokens_path: input.rawTokensPath,
|
|
18694
|
-
agent: input.agent,
|
|
18695
|
-
agent_model: input.agentModel ?? "",
|
|
18696
|
-
prompt_overrides: input.promptOverrides,
|
|
18697
|
-
cache: !input.noCache,
|
|
18698
|
-
has_credentials: credentials !== null,
|
|
18699
|
-
space_id: credentials?.spaceId ?? "",
|
|
18700
|
-
environment_id: credentials?.environmentId ?? "",
|
|
18701
|
-
host: credentials?.host ?? "",
|
|
18702
|
-
cma_token: credentials?.cmaToken ?? ""
|
|
18703
|
-
};
|
|
18704
|
-
}
|
|
18705
|
-
function extractionLogOutputs(result, progress, cmaToken) {
|
|
18706
|
-
const last = progress ? { final_progress: progress } : {};
|
|
18707
|
-
if (!result.ok) {
|
|
18708
|
-
return {
|
|
18709
|
-
outputs: { result: "failed", failed_step: result.step, error: scrubError(result.message, [cmaToken]), ...last },
|
|
18710
|
-
status: "error"
|
|
18711
|
-
};
|
|
18712
|
-
}
|
|
18713
|
-
const { extraction } = result;
|
|
18714
|
-
return {
|
|
18715
|
-
outputs: {
|
|
18716
|
-
result: "done",
|
|
18717
|
-
session_id: extraction.sessionId,
|
|
18718
|
-
out_dir: extraction.outDir,
|
|
18719
|
-
tokens_path: extraction.tokensPath,
|
|
18720
|
-
token_count: extraction.tokenCount,
|
|
18721
|
-
existing_entities_status: extraction.existingEntitiesStatus,
|
|
18722
|
-
composition_phase: extraction.compositionPhase,
|
|
18723
|
-
...last
|
|
18724
|
-
},
|
|
18725
|
-
status: "success"
|
|
18726
|
-
};
|
|
18727
|
-
}
|
|
18728
18568
|
function initialProgress(input) {
|
|
18729
18569
|
return {
|
|
18730
18570
|
scan: null,
|
|
@@ -18819,9 +18659,8 @@ function ExtractionScreen({ progress, agent }) {
|
|
|
18819
18659
|
}
|
|
18820
18660
|
|
|
18821
18661
|
// packages/experience-design-system-cli/src/tui/import/steps/05-token-review/screen.tsx
|
|
18822
|
-
import {
|
|
18662
|
+
import { useMemo as useMemo2, useState as useState10 } from "react";
|
|
18823
18663
|
import { Box as Box15, Text as Text15, useInput as useInput12 } from "ink";
|
|
18824
|
-
init_debug_store();
|
|
18825
18664
|
|
|
18826
18665
|
// packages/experience-design-system-cli/src/tui/import/steps/05-token-review/load.ts
|
|
18827
18666
|
import { readFileSync as readFileSync9 } from "node:fs";
|
|
@@ -18885,31 +18724,12 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
|
|
|
18885
18724
|
const rows = loaded.ok ? loaded.rows : [];
|
|
18886
18725
|
const columns = useTerminalWidth();
|
|
18887
18726
|
const [selected, setSelected] = useState10(0);
|
|
18888
|
-
useEffect9(() => {
|
|
18889
|
-
startDebugRun({
|
|
18890
|
-
flow: "import/token-review",
|
|
18891
|
-
step: "05-token-review",
|
|
18892
|
-
menuOption: "Token review",
|
|
18893
|
-
inputs: { import_mode: "tokens", tokens_path: tokensPath }
|
|
18894
|
-
});
|
|
18895
|
-
}, []);
|
|
18896
|
-
const finish = (outcome) => {
|
|
18897
|
-
void finishDebugRun({
|
|
18898
|
-
outputs: { outcome, ...loaded.ok ? { tokens: rows.length } : { load_error: loaded.message } },
|
|
18899
|
-
status: loaded.ok ? "success" : "error",
|
|
18900
|
-
exitMethod: outcome === "continued" ? "saved" : "discarded"
|
|
18901
|
-
});
|
|
18902
|
-
};
|
|
18903
18727
|
const move = (to) => setSelected(Math.max(0, Math.min(to, rows.length - 1)));
|
|
18904
18728
|
const { start, end } = computeColumnWindow(rows.length, selected, VISIBLE_ROWS);
|
|
18905
18729
|
useInput12((_input, key) => {
|
|
18906
|
-
if (key.return)
|
|
18907
|
-
|
|
18908
|
-
|
|
18909
|
-
} else if (key.escape) {
|
|
18910
|
-
finish("back");
|
|
18911
|
-
onQuit();
|
|
18912
|
-
} else if (key.upArrow) move(selected - 1);
|
|
18730
|
+
if (key.return) onContinue();
|
|
18731
|
+
else if (key.escape) onQuit();
|
|
18732
|
+
else if (key.upArrow) move(selected - 1);
|
|
18913
18733
|
else if (key.downArrow) move(selected + 1);
|
|
18914
18734
|
else if (key.pageUp) move(selected - VISIBLE_ROWS);
|
|
18915
18735
|
else if (key.pageDown) move(selected + VISIBLE_ROWS);
|
|
@@ -18973,15 +18793,14 @@ function TokenReviewScreen({ tokensPath, onContinue, onQuit }) {
|
|
|
18973
18793
|
init_config();
|
|
18974
18794
|
|
|
18975
18795
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-extraction.ts
|
|
18976
|
-
|
|
18977
|
-
import { useEffect as useEffect10, useRef as useRef6, useState as useState11 } from "react";
|
|
18796
|
+
import { useEffect as useEffect8, useRef as useRef6, useState as useState11 } from "react";
|
|
18978
18797
|
|
|
18979
18798
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run.ts
|
|
18980
18799
|
import { mkdir as mkdir8 } from "node:fs/promises";
|
|
18981
18800
|
import { join as join20, resolve as resolve24 } from "node:path";
|
|
18982
18801
|
|
|
18983
18802
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/find-skill-path.ts
|
|
18984
|
-
import { existsSync as
|
|
18803
|
+
import { existsSync as existsSync9 } from "node:fs";
|
|
18985
18804
|
import { dirname as dirname16, join as join19, resolve as resolve22 } from "node:path";
|
|
18986
18805
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
18987
18806
|
function findSkillPath(fileName) {
|
|
@@ -18989,7 +18808,7 @@ function findSkillPath(fileName) {
|
|
|
18989
18808
|
let dir = thisDir;
|
|
18990
18809
|
for (; ; ) {
|
|
18991
18810
|
const candidate = join19(dir, "skills", fileName);
|
|
18992
|
-
if (
|
|
18811
|
+
if (existsSync9(candidate)) return candidate;
|
|
18993
18812
|
const parent = resolve22(dir, "..");
|
|
18994
18813
|
if (parent === dir) {
|
|
18995
18814
|
throw new Error(`skill file not found (looked for skills/${fileName} from ${thisDir})`);
|
|
@@ -19231,7 +19050,7 @@ async function resolveSelectionPrompt(overrides) {
|
|
|
19231
19050
|
function useExtraction(input) {
|
|
19232
19051
|
const [state2, setState] = useState11();
|
|
19233
19052
|
const current = useRef6();
|
|
19234
|
-
|
|
19053
|
+
useEffect8(() => {
|
|
19235
19054
|
current.current = input;
|
|
19236
19055
|
if (!input) {
|
|
19237
19056
|
setState(void 0);
|
|
@@ -19244,23 +19063,10 @@ function useExtraction(input) {
|
|
|
19244
19063
|
hasRawTokens: input.rawTokensPath !== ""
|
|
19245
19064
|
})
|
|
19246
19065
|
});
|
|
19247
|
-
let lastProgress;
|
|
19248
|
-
startDebugRun({
|
|
19249
|
-
flow: "import/extraction",
|
|
19250
|
-
step: "06-extraction",
|
|
19251
|
-
menuOption: "Extraction",
|
|
19252
|
-
inputs: extractionLogInputs(input)
|
|
19253
|
-
});
|
|
19254
19066
|
void runExtraction(input, (progress) => {
|
|
19255
|
-
lastProgress = progress;
|
|
19256
19067
|
if (current.current === input) setState({ status: "running", progress });
|
|
19257
19068
|
}).then((result) => {
|
|
19258
|
-
if (current.current
|
|
19259
|
-
void finishDebugRun({
|
|
19260
|
-
...extractionLogOutputs(result, lastProgress, input.credentials?.cmaToken ?? ""),
|
|
19261
|
-
exitMethod: result.ok ? "saved" : "discarded"
|
|
19262
|
-
});
|
|
19263
|
-
setState({ status: "done", result });
|
|
19069
|
+
if (current.current === input) setState({ status: "done", result });
|
|
19264
19070
|
});
|
|
19265
19071
|
return () => {
|
|
19266
19072
|
if (current.current === input) current.current = void 0;
|
|
@@ -19270,7 +19076,7 @@ function useExtraction(input) {
|
|
|
19270
19076
|
}
|
|
19271
19077
|
|
|
19272
19078
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/use-tokens-only.ts
|
|
19273
|
-
import { useEffect as
|
|
19079
|
+
import { useEffect as useEffect9, useRef as useRef7, useState as useState12 } from "react";
|
|
19274
19080
|
|
|
19275
19081
|
// packages/experience-design-system-cli/src/tui/import/steps/06-extraction/run-tokens-only.ts
|
|
19276
19082
|
var TOKENS_SKILL_PATH2 = findSkillPath("generate-tokens.md");
|
|
@@ -19305,7 +19111,7 @@ async function runTokensOnly(input, deps = realDeps2) {
|
|
|
19305
19111
|
function useTokensOnly(input) {
|
|
19306
19112
|
const [state2, setState] = useState12();
|
|
19307
19113
|
const current = useRef7();
|
|
19308
|
-
|
|
19114
|
+
useEffect9(() => {
|
|
19309
19115
|
current.current = input;
|
|
19310
19116
|
if (!input) {
|
|
19311
19117
|
setState(void 0);
|
|
@@ -19323,37 +19129,9 @@ function useTokensOnly(input) {
|
|
|
19323
19129
|
}
|
|
19324
19130
|
|
|
19325
19131
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/screen.tsx
|
|
19326
|
-
|
|
19327
|
-
import { useEffect as useEffect14, useMemo as useMemo4 } from "react";
|
|
19132
|
+
import { useMemo as useMemo4 } from "react";
|
|
19328
19133
|
import { Box as Box25, Text as Text26 } from "ink";
|
|
19329
19134
|
|
|
19330
|
-
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/log.ts
|
|
19331
|
-
var MAX_NAMES = 20;
|
|
19332
|
-
var capped = (names) => {
|
|
19333
|
-
const unique = [...new Set(names)];
|
|
19334
|
-
return { count: unique.length, names: unique.slice(0, MAX_NAMES) };
|
|
19335
|
-
};
|
|
19336
|
-
function scopeGateLogInputs(components, tokenCount) {
|
|
19337
|
-
const ai = { accepted: 0, rejected: 0, failed: 0, none: 0 };
|
|
19338
|
-
for (const component of components) ai[component.aiDecision ?? "none"] += 1;
|
|
19339
|
-
return {
|
|
19340
|
-
components_found: components.length,
|
|
19341
|
-
ai_suggestions: ai,
|
|
19342
|
-
needs_review: components.filter((component) => component.needsReview === true).length,
|
|
19343
|
-
tokens: tokenCount
|
|
19344
|
-
};
|
|
19345
|
-
}
|
|
19346
|
-
function scopeGateLogOutputs(components, decisions) {
|
|
19347
|
-
const suggested = new Map(components.map((component) => [component.name, component.aiDecision]));
|
|
19348
|
-
return {
|
|
19349
|
-
outcome: "continued",
|
|
19350
|
-
accepted: new Set(decisions.accepted).size,
|
|
19351
|
-
rejected: new Set(decisions.rejected).size,
|
|
19352
|
-
accepted_although_ai_rejected: capped(decisions.accepted.filter((name) => suggested.get(name) === "rejected")),
|
|
19353
|
-
not_accepted_although_ai_accepted: capped(decisions.rejected.filter((name) => suggested.get(name) === "accepted"))
|
|
19354
|
-
};
|
|
19355
|
-
}
|
|
19356
|
-
|
|
19357
19135
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/panels/tokens-column.tsx
|
|
19358
19136
|
import { Box as Box17, Text as Text17 } from "ink";
|
|
19359
19137
|
import figures2 from "figures";
|
|
@@ -20537,7 +20315,7 @@ function useImmediateInput(handler, enabled = true) {
|
|
|
20537
20315
|
|
|
20538
20316
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/sidebar/hooks/use-terminal-size.ts
|
|
20539
20317
|
import { useStdout as useStdout2 } from "ink";
|
|
20540
|
-
import { useEffect as
|
|
20318
|
+
import { useEffect as useEffect10, useState as useState13 } from "react";
|
|
20541
20319
|
function readTerminalSize(stdout) {
|
|
20542
20320
|
return {
|
|
20543
20321
|
columns: stdout?.columns ?? 80,
|
|
@@ -20547,7 +20325,7 @@ function readTerminalSize(stdout) {
|
|
|
20547
20325
|
function useTerminalSize() {
|
|
20548
20326
|
const { stdout } = useStdout2();
|
|
20549
20327
|
const [size, setSize] = useState13(() => readTerminalSize(stdout));
|
|
20550
|
-
|
|
20328
|
+
useEffect10(() => {
|
|
20551
20329
|
const updateSize = () => setSize(readTerminalSize(stdout));
|
|
20552
20330
|
stdout?.on("resize", updateSize);
|
|
20553
20331
|
updateSize();
|
|
@@ -20730,7 +20508,7 @@ function createSidebarViewsHelpSection(includeBreaking) {
|
|
|
20730
20508
|
}
|
|
20731
20509
|
|
|
20732
20510
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate.ts
|
|
20733
|
-
import { useEffect as
|
|
20511
|
+
import { useEffect as useEffect11, useMemo as useMemo3, useRef as useRef9, useState as useState16 } from "react";
|
|
20734
20512
|
|
|
20735
20513
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/columns.ts
|
|
20736
20514
|
var TWO_COLUMN_MIN_WIDTH = 100;
|
|
@@ -21467,7 +21245,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
|
|
|
21467
21245
|
return seed;
|
|
21468
21246
|
});
|
|
21469
21247
|
const seededGroupsRef = useRef9(closures.size > 0 || cycleParticipants.size > 0);
|
|
21470
|
-
|
|
21248
|
+
useEffect11(() => {
|
|
21471
21249
|
if (seededGroupsRef.current) return;
|
|
21472
21250
|
if (closures.size === 0 && cycleParticipants.size === 0) return;
|
|
21473
21251
|
seededGroupsRef.current = true;
|
|
@@ -21558,7 +21336,7 @@ function useScopeGate({ components, tokenCount, tokensWidth, onConfirm, onQuit }
|
|
|
21558
21336
|
entryCount: 0
|
|
21559
21337
|
});
|
|
21560
21338
|
const panelLayout = useMemo3(() => computePanelLayout(visibleCount), [visibleCount]);
|
|
21561
|
-
|
|
21339
|
+
useEffect11(() => {
|
|
21562
21340
|
setNav((prev) => {
|
|
21563
21341
|
const maxIdx = Math.max(0, visibleRows.length - 1);
|
|
21564
21342
|
const nextCursor = Math.min(prev.cursor, maxIdx);
|
|
@@ -21919,55 +21697,23 @@ var HELP_SECTIONS = [
|
|
|
21919
21697
|
}
|
|
21920
21698
|
];
|
|
21921
21699
|
function ScopeGateScreen(props) {
|
|
21922
|
-
if (props.components.length === 0)
|
|
21700
|
+
if (props.components.length === 0) {
|
|
21701
|
+
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." }) });
|
|
21702
|
+
}
|
|
21923
21703
|
return /* @__PURE__ */ jsx29(ScopeGateView, { ...props });
|
|
21924
21704
|
}
|
|
21925
|
-
function NoComponents() {
|
|
21926
|
-
useEffect14(() => {
|
|
21927
|
-
startDebugRun({
|
|
21928
|
-
flow: "import/scope-gate",
|
|
21929
|
-
step: "07-scope-gate",
|
|
21930
|
-
menuOption: "Scope gate",
|
|
21931
|
-
inputs: scopeGateLogInputs([], 0)
|
|
21932
|
-
});
|
|
21933
|
-
void finishDebugRun({
|
|
21934
|
-
outputs: { outcome: "nothing to decide", error: "No components were found for this session." },
|
|
21935
|
-
status: "error",
|
|
21936
|
-
exitMethod: "discarded"
|
|
21937
|
-
});
|
|
21938
|
-
}, []);
|
|
21939
|
-
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." }) });
|
|
21940
|
-
}
|
|
21941
21705
|
function ScopeGateView({ components, tokensPath, onConfirm, onQuit }) {
|
|
21942
21706
|
const tokens = useMemo4(() => {
|
|
21943
21707
|
const loaded = tokensPath ? loadTokenRows(tokensPath) : void 0;
|
|
21944
21708
|
return loaded?.ok ? loaded.rows : [];
|
|
21945
21709
|
}, [tokensPath]);
|
|
21946
21710
|
const longest = useMemo4(() => longestEntries(tokens), [tokens]);
|
|
21947
|
-
useEffect14(() => {
|
|
21948
|
-
startDebugRun({
|
|
21949
|
-
flow: "import/scope-gate",
|
|
21950
|
-
step: "07-scope-gate",
|
|
21951
|
-
menuOption: "Scope gate",
|
|
21952
|
-
inputs: scopeGateLogInputs(components, tokens.length)
|
|
21953
|
-
});
|
|
21954
|
-
}, []);
|
|
21955
21711
|
const gate = useScopeGate({
|
|
21956
21712
|
components,
|
|
21957
21713
|
tokenCount: tokens.length,
|
|
21958
21714
|
tokensWidth: longest.path + longest.value + 10,
|
|
21959
|
-
onConfirm
|
|
21960
|
-
|
|
21961
|
-
outputs: scopeGateLogOutputs(components, decisions),
|
|
21962
|
-
status: "success",
|
|
21963
|
-
exitMethod: "saved"
|
|
21964
|
-
});
|
|
21965
|
-
onConfirm(decisions);
|
|
21966
|
-
},
|
|
21967
|
-
onQuit: () => {
|
|
21968
|
-
void finishDebugRun({ outputs: { outcome: "quit" }, status: "success", exitMethod: "discarded" });
|
|
21969
|
-
onQuit();
|
|
21970
|
-
}
|
|
21715
|
+
onConfirm,
|
|
21716
|
+
onQuit
|
|
21971
21717
|
});
|
|
21972
21718
|
const { search, graph, columnPlan, panelLayout, counters } = gate;
|
|
21973
21719
|
if (gate.showHelp) {
|
|
@@ -22065,8 +21811,7 @@ function ScopeGateView({ components, tokensPath, onConfirm, onQuit }) {
|
|
|
22065
21811
|
}
|
|
22066
21812
|
|
|
22067
21813
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/use-scope-gate-flow.ts
|
|
22068
|
-
|
|
22069
|
-
import { useEffect as useEffect15, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
|
|
21814
|
+
import { useEffect as useEffect12, useMemo as useMemo5, useRef as useRef10, useState as useState17 } from "react";
|
|
22070
21815
|
|
|
22071
21816
|
// packages/experience-design-system-cli/src/tui/import/steps/07-scope-gate/cache-check.ts
|
|
22072
21817
|
async function checkGenerationCache(input) {
|
|
@@ -22115,21 +21860,7 @@ function useScopeGateFlow(input, deps = realDeps3) {
|
|
|
22115
21860
|
const loaded = useMemo5(() => sessionId ? deps.load(sessionId) : void 0, [sessionId]);
|
|
22116
21861
|
const cacheCheck = useRef10(void 0);
|
|
22117
21862
|
const [confirmed, setConfirmed] = useState17();
|
|
22118
|
-
|
|
22119
|
-
if (!sessionId || !loaded || loaded.ok) return;
|
|
22120
|
-
startDebugRun({
|
|
22121
|
-
flow: "import/scope-gate",
|
|
22122
|
-
step: "07-scope-gate",
|
|
22123
|
-
menuOption: "Scope gate",
|
|
22124
|
-
inputs: { session_id: sessionId }
|
|
22125
|
-
});
|
|
22126
|
-
void finishDebugRun({
|
|
22127
|
-
outputs: { outcome: "could not load the components", error: loaded.message },
|
|
22128
|
-
status: "error",
|
|
22129
|
-
exitMethod: "discarded"
|
|
22130
|
-
});
|
|
22131
|
-
}, [sessionId, loaded]);
|
|
22132
|
-
useEffect15(() => {
|
|
21863
|
+
useEffect12(() => {
|
|
22133
21864
|
if (!input || !loaded?.ok || cacheCheck.current) return;
|
|
22134
21865
|
cacheCheck.current = deps.checkCache(input.cache);
|
|
22135
21866
|
}, [input, loaded]);
|
|
@@ -22141,41 +21872,6 @@ function useScopeGateFlow(input, deps = realDeps3) {
|
|
|
22141
21872
|
}
|
|
22142
21873
|
|
|
22143
21874
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/logic.ts
|
|
22144
|
-
function generationLogInputs(input) {
|
|
22145
|
-
return {
|
|
22146
|
-
session_id: input.sessionId,
|
|
22147
|
-
accepted: input.decisions.accepted.length,
|
|
22148
|
-
rejected: input.decisions.rejected.length,
|
|
22149
|
-
tokens_path: input.tokensPath,
|
|
22150
|
-
token_session_id: input.tokenSessionId,
|
|
22151
|
-
existing_entities_path: input.existingEntitiesPath,
|
|
22152
|
-
agent: input.agent,
|
|
22153
|
-
agent_model: input.agentModel ?? "",
|
|
22154
|
-
prompt_overrides: input.promptOverrides,
|
|
22155
|
-
generate_prompt_path: input.generatePromptPath ?? "",
|
|
22156
|
-
cache: !input.noCache,
|
|
22157
|
-
has_tokens: input.hasTokens
|
|
22158
|
-
};
|
|
22159
|
-
}
|
|
22160
|
-
function generationLogOutputs(result, progress) {
|
|
22161
|
-
const last = progress ? { final_progress: progress } : {};
|
|
22162
|
-
if (!result.ok) {
|
|
22163
|
-
return { outputs: { result: "failed", failed_step: result.step, error: result.message, ...last }, status: "error" };
|
|
22164
|
-
}
|
|
22165
|
-
const { generation } = result;
|
|
22166
|
-
return {
|
|
22167
|
-
outputs: generation.route === "review" ? {
|
|
22168
|
-
result: "done",
|
|
22169
|
-
route: generation.route,
|
|
22170
|
-
session_id: generation.sessionId,
|
|
22171
|
-
accepted: generation.acceptedCount,
|
|
22172
|
-
generated: generation.generatedCount,
|
|
22173
|
-
map_tokens_eligible: generation.mapTokensEligible,
|
|
22174
|
-
...last
|
|
22175
|
-
} : { result: "done", route: generation.route, accepted: generation.acceptedCount, ...last },
|
|
22176
|
-
status: "success"
|
|
22177
|
-
};
|
|
22178
|
-
}
|
|
22179
21875
|
function initialProgress2() {
|
|
22180
21876
|
return { components: null, mapTokens: "idle", mapTokensEligible: null };
|
|
22181
21877
|
}
|
|
@@ -22231,8 +21927,7 @@ function GenerationScreen({
|
|
|
22231
21927
|
}
|
|
22232
21928
|
|
|
22233
21929
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/use-generation.ts
|
|
22234
|
-
|
|
22235
|
-
import { useEffect as useEffect16, useRef as useRef11, useState as useState18 } from "react";
|
|
21930
|
+
import { useEffect as useEffect13, useRef as useRef11, useState as useState18 } from "react";
|
|
22236
21931
|
|
|
22237
21932
|
// packages/experience-design-system-cli/src/tui/import/steps/08-generation/run.ts
|
|
22238
21933
|
import { resolve as resolve25 } from "node:path";
|
|
@@ -22398,30 +22093,17 @@ function applyProgressEvent2(event, previous, total) {
|
|
|
22398
22093
|
function useGeneration(input) {
|
|
22399
22094
|
const [state2, setState] = useState18();
|
|
22400
22095
|
const current = useRef11();
|
|
22401
|
-
|
|
22096
|
+
useEffect13(() => {
|
|
22402
22097
|
current.current = input;
|
|
22403
22098
|
if (!input) {
|
|
22404
22099
|
setState(void 0);
|
|
22405
22100
|
return;
|
|
22406
22101
|
}
|
|
22407
22102
|
setState({ status: "running", progress: initialProgress2() });
|
|
22408
|
-
let lastProgress;
|
|
22409
|
-
startDebugRun({
|
|
22410
|
-
flow: "import/generation",
|
|
22411
|
-
step: "08-generation",
|
|
22412
|
-
menuOption: "Generation",
|
|
22413
|
-
inputs: generationLogInputs(input)
|
|
22414
|
-
});
|
|
22415
22103
|
void runGeneration(input, (progress) => {
|
|
22416
|
-
lastProgress = progress;
|
|
22417
22104
|
if (current.current === input) setState({ status: "running", progress });
|
|
22418
22105
|
}).then((result) => {
|
|
22419
|
-
if (current.current
|
|
22420
|
-
void finishDebugRun({
|
|
22421
|
-
...generationLogOutputs(result, lastProgress),
|
|
22422
|
-
exitMethod: result.ok ? "saved" : "discarded"
|
|
22423
|
-
});
|
|
22424
|
-
setState({ status: "done", result });
|
|
22106
|
+
if (current.current === input) setState({ status: "done", result });
|
|
22425
22107
|
});
|
|
22426
22108
|
return () => {
|
|
22427
22109
|
if (current.current === input) current.current = void 0;
|
|
@@ -22536,9 +22218,12 @@ var cdfJsonSchema2 = {
|
|
|
22536
22218
|
$required: { type: "boolean" },
|
|
22537
22219
|
$default: {},
|
|
22538
22220
|
$values: { type: "array", items: { type: "string" } },
|
|
22539
|
-
"$token.kind": { type: "string" },
|
|
22221
|
+
"$token.kind": { type: "string", minLength: 1 },
|
|
22540
22222
|
"$token.allowed": { type: "array", items: { type: "string" } }
|
|
22541
22223
|
},
|
|
22224
|
+
// The API rejects a token property that does not say which kind of token it takes.
|
|
22225
|
+
if: { type: "object", properties: { $type: { const: "token" } }, required: ["$type"] },
|
|
22226
|
+
then: { type: "object", required: ["$token.kind"] },
|
|
22542
22227
|
additionalProperties: false
|
|
22543
22228
|
},
|
|
22544
22229
|
slot: {
|
|
@@ -22892,7 +22577,7 @@ function PreviewValidationErrorScreen({
|
|
|
22892
22577
|
}
|
|
22893
22578
|
|
|
22894
22579
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/generate-review-step.tsx
|
|
22895
|
-
import { useCallback as useCallback5, useEffect as
|
|
22580
|
+
import { useCallback as useCallback5, useEffect as useEffect20, useMemo as useMemo6, useRef as useRef16, useState as useState26 } from "react";
|
|
22896
22581
|
import figures8 from "figures";
|
|
22897
22582
|
|
|
22898
22583
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/review-json-panel.ts
|
|
@@ -23153,7 +22838,7 @@ function enumerateCycleBreaks(cycle, components) {
|
|
|
23153
22838
|
import { Box as Box32, Text as Text34 } from "ink";
|
|
23154
22839
|
|
|
23155
22840
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/components/FieldEditor.tsx
|
|
23156
|
-
import React13, { useEffect as
|
|
22841
|
+
import React13, { useEffect as useEffect14, useLayoutEffect as useLayoutEffect2, useState as useState19 } from "react";
|
|
23157
22842
|
import figures6 from "figures";
|
|
23158
22843
|
import { Box as Box26, measureElement, Text as Text27 } from "ink";
|
|
23159
22844
|
|
|
@@ -24711,7 +24396,7 @@ function FieldEditor({
|
|
|
24711
24396
|
}
|
|
24712
24397
|
return Math.max(start + 1, end2);
|
|
24713
24398
|
};
|
|
24714
|
-
|
|
24399
|
+
useEffect14(() => {
|
|
24715
24400
|
if (focusLevel === "field" || selectedRowIdx < 0) return;
|
|
24716
24401
|
setListScrollStart((previous) => {
|
|
24717
24402
|
if (initialFocusTarget && !initialFocusScrollApplied.current) {
|
|
@@ -25783,7 +25468,7 @@ function finalizeReviewSession(extractSessionId, components) {
|
|
|
25783
25468
|
}
|
|
25784
25469
|
|
|
25785
25470
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-session.ts
|
|
25786
|
-
import { useCallback as useCallback2, useEffect as
|
|
25471
|
+
import { useCallback as useCallback2, useEffect as useEffect16, useRef as useRef13, useState as useState21 } from "react";
|
|
25787
25472
|
|
|
25788
25473
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/history.ts
|
|
25789
25474
|
var DEFAULT_MAX_DEPTH = 50;
|
|
@@ -25839,7 +25524,7 @@ function createHistoryStack(seed, maxDepth = DEFAULT_MAX_DEPTH) {
|
|
|
25839
25524
|
}
|
|
25840
25525
|
|
|
25841
25526
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-finalize-preview.ts
|
|
25842
|
-
import { useEffect as
|
|
25527
|
+
import { useEffect as useEffect15, useRef as useRef12, useState as useState20 } from "react";
|
|
25843
25528
|
|
|
25844
25529
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/run-live-preview.ts
|
|
25845
25530
|
var TimeoutError = class extends Error {
|
|
@@ -25999,7 +25684,7 @@ function useFinalizePreview(opts) {
|
|
|
25999
25684
|
const [scrollOffset, setScrollOffset] = useState20(0);
|
|
26000
25685
|
const generationRef = useRef12(0);
|
|
26001
25686
|
const acceptedKey = [...acceptedKeys].sort().join("\0");
|
|
26002
|
-
|
|
25687
|
+
useEffect15(() => {
|
|
26003
25688
|
if (!open) {
|
|
26004
25689
|
setStatus("idle");
|
|
26005
25690
|
setRemoved([]);
|
|
@@ -26062,7 +25747,7 @@ function useReviewSession({
|
|
|
26062
25747
|
}));
|
|
26063
25748
|
return { result, catalog };
|
|
26064
25749
|
}, [loadSession, tokensPath]);
|
|
26065
|
-
|
|
25750
|
+
useEffect16(() => {
|
|
26066
25751
|
let disposed = false;
|
|
26067
25752
|
void (async () => {
|
|
26068
25753
|
try {
|
|
@@ -26115,7 +25800,7 @@ function useReviewSession({
|
|
|
26115
25800
|
function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
|
|
26116
25801
|
const [reviewMetadata, setReviewMetadata] = useState21(null);
|
|
26117
25802
|
const [componentRationale, setComponentRationale] = useState21(null);
|
|
26118
|
-
|
|
25803
|
+
useEffect16(() => {
|
|
26119
25804
|
const current = components[selectedIdx];
|
|
26120
25805
|
if (!current) {
|
|
26121
25806
|
setReviewMetadata(null);
|
|
@@ -26147,7 +25832,7 @@ function useReviewMetadata({ components, selectedIdx, extractSessionId }) {
|
|
|
26147
25832
|
function useReviewHistory({ loading, components, createSnapshot, applySnapshot }) {
|
|
26148
25833
|
const historyRef = useRef13(null);
|
|
26149
25834
|
const historySeededRef = useRef13(false);
|
|
26150
|
-
|
|
25835
|
+
useEffect16(() => {
|
|
26151
25836
|
if (loading || historySeededRef.current) return;
|
|
26152
25837
|
historySeededRef.current = true;
|
|
26153
25838
|
historyRef.current = createHistoryStack(createSnapshot(components));
|
|
@@ -26198,7 +25883,7 @@ function useReviewFinalize({
|
|
|
26198
25883
|
}
|
|
26199
25884
|
|
|
26200
25885
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-editor.ts
|
|
26201
|
-
import { useEffect as
|
|
25886
|
+
import { useEffect as useEffect17, useRef as useRef14, useState as useState22 } from "react";
|
|
26202
25887
|
|
|
26203
25888
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/token-suggestions.ts
|
|
26204
25889
|
function collectTokenSuggestions(entry, availableTokens = []) {
|
|
@@ -26251,7 +25936,7 @@ function useReviewEditor({
|
|
|
26251
25936
|
const [tokenReviewEditSelection, setTokenReviewEditSelection] = useState22(/* @__PURE__ */ new Set());
|
|
26252
25937
|
const tokenReviewSuggestedRef = useRef14(/* @__PURE__ */ new Map());
|
|
26253
25938
|
const pendingGRef = useRef14(false);
|
|
26254
|
-
|
|
25939
|
+
useEffect17(() => {
|
|
26255
25940
|
setTokenReviewRow(0);
|
|
26256
25941
|
setTokenReviewEditing(false);
|
|
26257
25942
|
setTokenReviewEditCursor(0);
|
|
@@ -26663,7 +26348,7 @@ function handleJsonPanelInput(input, key, state2) {
|
|
|
26663
26348
|
}
|
|
26664
26349
|
|
|
26665
26350
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-review-preview.ts
|
|
26666
|
-
import { useCallback as useCallback4, useEffect as
|
|
26351
|
+
import { useCallback as useCallback4, useEffect as useEffect19, useState as useState25 } from "react";
|
|
26667
26352
|
|
|
26668
26353
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/preview-annotations.ts
|
|
26669
26354
|
function applyPreviewAnnotations(preview, localNames) {
|
|
@@ -26698,7 +26383,7 @@ function applyPreviewAnnotations(preview, localNames) {
|
|
|
26698
26383
|
}
|
|
26699
26384
|
|
|
26700
26385
|
// packages/experience-design-system-cli/src/tui/import/steps/09-review/use-live-preview.ts
|
|
26701
|
-
import { useCallback as useCallback3, useEffect as
|
|
26386
|
+
import { useCallback as useCallback3, useEffect as useEffect18, useRef as useRef15, useState as useState24 } from "react";
|
|
26702
26387
|
var DEFAULT_DEBOUNCE_MS = 500;
|
|
26703
26388
|
function useLivePreview(opts) {
|
|
26704
26389
|
const debounceMs = opts.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
@@ -26709,14 +26394,14 @@ function useLivePreview(opts) {
|
|
|
26709
26394
|
const latestRef = useRef15(0);
|
|
26710
26395
|
const inflightRef = useRef15(0);
|
|
26711
26396
|
const optsRef = useRef15(opts);
|
|
26712
|
-
|
|
26397
|
+
useEffect18(() => {
|
|
26713
26398
|
optsRef.current = opts;
|
|
26714
26399
|
});
|
|
26715
26400
|
const disabledRef = useRef15(disabled);
|
|
26716
|
-
|
|
26401
|
+
useEffect18(() => {
|
|
26717
26402
|
disabledRef.current = disabled;
|
|
26718
26403
|
}, [disabled]);
|
|
26719
|
-
|
|
26404
|
+
useEffect18(() => {
|
|
26720
26405
|
return () => {
|
|
26721
26406
|
if (timerRef.current) {
|
|
26722
26407
|
clearTimeout(timerRef.current);
|
|
@@ -26830,13 +26515,13 @@ function useReviewPreview({
|
|
|
26830
26515
|
deleteAllComponents
|
|
26831
26516
|
});
|
|
26832
26517
|
const [spinnerTick, setSpinnerTick] = useState25(0);
|
|
26833
|
-
|
|
26518
|
+
useEffect19(() => {
|
|
26834
26519
|
if (livePreviewHook.status !== "running") return;
|
|
26835
26520
|
const id = setInterval(() => setSpinnerTick((tick) => tick + 1), 80);
|
|
26836
26521
|
return () => clearInterval(id);
|
|
26837
26522
|
}, [livePreviewHook.status]);
|
|
26838
26523
|
const livePreviewSpinner = SPINNER_FRAMES[spinnerTick % SPINNER_FRAMES.length];
|
|
26839
|
-
|
|
26524
|
+
useEffect19(() => {
|
|
26840
26525
|
if (loading) return;
|
|
26841
26526
|
if (!livePreview) return;
|
|
26842
26527
|
if (components.length === 0) return;
|
|
@@ -27256,7 +26941,7 @@ function GenerateReviewStepView({
|
|
|
27256
26941
|
[components]
|
|
27257
26942
|
);
|
|
27258
26943
|
const closures = useMemo6(() => computeAllClosures(componentGraph), [componentGraph]);
|
|
27259
|
-
|
|
26944
|
+
useEffect20(() => {
|
|
27260
26945
|
if (seededGroupsRef.current) return;
|
|
27261
26946
|
if (closures.size === 0 && slotCycles.length === 0) return;
|
|
27262
26947
|
seededGroupsRef.current = true;
|
|
@@ -27283,7 +26968,7 @@ function GenerateReviewStepView({
|
|
|
27283
26968
|
suggestedBreak: cycle.edges.length > 0 ? suggestCycleBreakEdge2(cycle, cycleView.pushBlocking) : null
|
|
27284
26969
|
}));
|
|
27285
26970
|
}, [slotCycles, cycleView]);
|
|
27286
|
-
|
|
26971
|
+
useEffect20(() => {
|
|
27287
26972
|
const decision = computeAutoRejectDecision({
|
|
27288
26973
|
loading,
|
|
27289
26974
|
autoRejectFired: autoRejectFiredRef.current,
|
|
@@ -27327,7 +27012,7 @@ function GenerateReviewStepView({
|
|
|
27327
27012
|
applySnapshot: applyHistorySnapshot
|
|
27328
27013
|
});
|
|
27329
27014
|
const autoRejectPushedRef = useRef16(false);
|
|
27330
|
-
|
|
27015
|
+
useEffect20(() => {
|
|
27331
27016
|
if (loading) return;
|
|
27332
27017
|
if (!historySeededRef.current) return;
|
|
27333
27018
|
if (!autoRejectFiredRef.current) return;
|
|
@@ -27411,7 +27096,7 @@ function GenerateReviewStepView({
|
|
|
27411
27096
|
const panelHeight = leftPanelHeight + 2;
|
|
27412
27097
|
const panelContentHeight = Math.max(1, panelHeight - 3);
|
|
27413
27098
|
const cycleViewportHeight = Math.max(1, panelHeight - 4);
|
|
27414
|
-
|
|
27099
|
+
useEffect20(() => {
|
|
27415
27100
|
if (selectableRowPositions.length === 0) return;
|
|
27416
27101
|
const cursorInRange = selectableRowPositions.includes(cursorRowIdx);
|
|
27417
27102
|
const maxScroll = Math.max(0, visibleRowsMemo.length - visibleCount);
|
|
@@ -28356,10 +28041,10 @@ function normalizePath(input) {
|
|
|
28356
28041
|
}
|
|
28357
28042
|
|
|
28358
28043
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-blinking-cursor.ts
|
|
28359
|
-
import { useEffect as
|
|
28044
|
+
import { useEffect as useEffect21, useState as useState27 } from "react";
|
|
28360
28045
|
function useBlinkingCursor() {
|
|
28361
28046
|
const [visible, setVisible] = useState27(true);
|
|
28362
|
-
|
|
28047
|
+
useEffect21(() => {
|
|
28363
28048
|
const interval = setInterval(() => setVisible((current) => !current), 500);
|
|
28364
28049
|
return () => clearInterval(interval);
|
|
28365
28050
|
}, []);
|
|
@@ -28475,12 +28160,12 @@ function countedThings({ components, tokens }, counts = {}) {
|
|
|
28475
28160
|
}
|
|
28476
28161
|
|
|
28477
28162
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/use-timed-spinner.tsx
|
|
28478
|
-
import { useEffect as
|
|
28163
|
+
import { useEffect as useEffect22, useState as useState29 } from "react";
|
|
28479
28164
|
import { Spinner as Spinner2 } from "@inkjs/ui";
|
|
28480
28165
|
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
28481
28166
|
function useTimedSpinner() {
|
|
28482
28167
|
const [elapsedSeconds, setElapsedSeconds] = useState29(0);
|
|
28483
|
-
|
|
28168
|
+
useEffect22(() => {
|
|
28484
28169
|
const timer = setInterval(() => setElapsedSeconds((current) => current + 1), 1e3);
|
|
28485
28170
|
return () => {
|
|
28486
28171
|
clearInterval(timer);
|
|
@@ -28538,7 +28223,7 @@ function PushingStep({ progress, produced, counts }) {
|
|
|
28538
28223
|
}
|
|
28539
28224
|
|
|
28540
28225
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/screens/WizardPreviewStep.tsx
|
|
28541
|
-
import { useEffect as
|
|
28226
|
+
import { useEffect as useEffect23, useState as useState30, useMemo as useMemo7 } from "react";
|
|
28542
28227
|
import { Box as Box44, Text as Text46 } from "ink";
|
|
28543
28228
|
|
|
28544
28229
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/support/preview-diff.ts
|
|
@@ -28933,7 +28618,7 @@ function WizardPreviewStep({
|
|
|
28933
28618
|
const activeLines = diffExpanded ? diffLines : summaryLines;
|
|
28934
28619
|
const maxScroll = Math.max(0, activeLines.length - viewportHeight);
|
|
28935
28620
|
const boundedScrollOffset = Math.min(scrollOffset, maxScroll);
|
|
28936
|
-
|
|
28621
|
+
useEffect23(() => {
|
|
28937
28622
|
setScrollOffset((previous) => Math.min(previous, maxScroll));
|
|
28938
28623
|
}, [maxScroll]);
|
|
28939
28624
|
useImmediateInput((input, key) => {
|
|
@@ -29023,189 +28708,6 @@ function buildRunTeaserLine(runId) {
|
|
|
29023
28708
|
return `Run saved as ${runId}.`;
|
|
29024
28709
|
}
|
|
29025
28710
|
|
|
29026
|
-
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts
|
|
29027
|
-
init_debug_store();
|
|
29028
|
-
import { useEffect as useEffect27, useRef as useRef17 } from "react";
|
|
29029
|
-
|
|
29030
|
-
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/flow-log.ts
|
|
29031
|
-
var FLOW_RUN = { flow: "import/publish", step: "10-publish", menuOption: "Publish" };
|
|
29032
|
-
var LABELS = {
|
|
29033
|
-
"final-review": "Final review",
|
|
29034
|
-
"path-prompt": "Save path",
|
|
29035
|
-
printing: "Save files",
|
|
29036
|
-
previewing: "Preview",
|
|
29037
|
-
"preview-gate": "Preview confirmation",
|
|
29038
|
-
pushing: "Push",
|
|
29039
|
-
"print-gate": "Files saved",
|
|
29040
|
-
done: "Done",
|
|
29041
|
-
error: "Error",
|
|
29042
|
-
"preview-validation-error": "Preview validation"
|
|
29043
|
-
};
|
|
29044
|
-
var WORK = ["printing", "previewing", "pushing"];
|
|
29045
|
-
var FINISHED = ["done", "error", "preview-validation-error"];
|
|
29046
|
-
var MAX_LOGGED = 10;
|
|
29047
|
-
var MAX_OUTCOME = 200;
|
|
29048
|
-
var scrub = (text, state2) => scrubError(text, [state2.cmaToken]);
|
|
29049
|
-
var seconds = (ms) => Math.round(ms / 100) / 10;
|
|
29050
|
-
var pushHasFailures = (result) => result.componentTypes.failed + result.designTokens.failed > 0 || (result.failures?.length ?? 0) > 0 || (result.summary?.failed ?? 0) > 0;
|
|
29051
|
-
function previewSummary(preview) {
|
|
29052
|
-
const counts = (group) => ({
|
|
29053
|
-
new: group.new.length,
|
|
29054
|
-
changed: group.changed.length,
|
|
29055
|
-
removed: group.removed.length
|
|
29056
|
-
});
|
|
29057
|
-
return {
|
|
29058
|
-
components: counts(preview.components),
|
|
29059
|
-
tokens: counts(preview.tokens),
|
|
29060
|
-
breaking_components: preview.components.changed.filter(
|
|
29061
|
-
(entry) => entry.changeClassification?.classification === "breaking"
|
|
29062
|
-
).length
|
|
29063
|
-
};
|
|
29064
|
-
}
|
|
29065
|
-
function pushSummary(result, state2) {
|
|
29066
|
-
const failures = result.failures ?? [];
|
|
29067
|
-
return {
|
|
29068
|
-
component_types: result.componentTypes,
|
|
29069
|
-
design_tokens: result.designTokens,
|
|
29070
|
-
...result.summary ? { summary: result.summary } : {},
|
|
29071
|
-
...failures.length > 0 ? {
|
|
29072
|
-
failure_count: failures.length,
|
|
29073
|
-
failures: failures.slice(0, MAX_LOGGED).map((failure) => ({
|
|
29074
|
-
entity_type: failure.entityType,
|
|
29075
|
-
entity_id: failure.entityId,
|
|
29076
|
-
message: scrub(failure.message, state2)
|
|
29077
|
-
}))
|
|
29078
|
-
} : {}
|
|
29079
|
-
};
|
|
29080
|
-
}
|
|
29081
|
-
function flowContext(state2) {
|
|
29082
|
-
return {
|
|
29083
|
-
agent: state2.agent,
|
|
29084
|
-
space_id: state2.spaceId,
|
|
29085
|
-
environment_id: state2.environmentId,
|
|
29086
|
-
host: state2.host,
|
|
29087
|
-
credentials_skipped: state2.credentialsSkipped,
|
|
29088
|
-
components_generated: state2.generatedCount,
|
|
29089
|
-
components_accepted: state2.generatedAcceptedCount,
|
|
29090
|
-
tokens: state2.tokenCount,
|
|
29091
|
-
cma_token: state2.cmaToken
|
|
29092
|
-
};
|
|
29093
|
-
}
|
|
29094
|
-
function arrive(trail, state2) {
|
|
29095
|
-
const next = { ...trail, at: state2.step };
|
|
29096
|
-
if (state2.step === "error") {
|
|
29097
|
-
next.failure = { step: state2.errorStep, message: scrub(state2.errorMessage, state2) };
|
|
29098
|
-
}
|
|
29099
|
-
if (state2.step === "preview-validation-error") {
|
|
29100
|
-
next.validation = {
|
|
29101
|
-
count: state2.previewValidationErrors.length,
|
|
29102
|
-
errors: state2.previewValidationErrors.slice(0, MAX_LOGGED).map((error) => ({
|
|
29103
|
-
component: error.componentName,
|
|
29104
|
-
path: error.path,
|
|
29105
|
-
message: scrub(error.message, state2)
|
|
29106
|
-
})),
|
|
29107
|
-
missing_names: state2.previewValidationMissingNames.slice(0, MAX_LOGGED * 2)
|
|
29108
|
-
};
|
|
29109
|
-
}
|
|
29110
|
-
return next;
|
|
29111
|
-
}
|
|
29112
|
-
function openTrail(state2, now) {
|
|
29113
|
-
return arrive({ startedAt: now, stageStartedAt: now, at: state2.step, stages: [], edits: 0 }, state2);
|
|
29114
|
-
}
|
|
29115
|
-
function advance(trail, from, to, now) {
|
|
29116
|
-
const next = { ...trail, stages: [...trail.stages], stageStartedAt: now };
|
|
29117
|
-
const failed = to.step === "error" || to.step === "preview-validation-error" || from.step === "pushing" && pushHasFailures(to.pushResult);
|
|
29118
|
-
if (WORK.includes(from.step)) {
|
|
29119
|
-
next.stages.push(`${LABELS[from.step]}: ${failed ? "failed" : "ok"} (${seconds(now - trail.stageStartedAt)}s)`);
|
|
29120
|
-
}
|
|
29121
|
-
if (from.step === "previewing" && to.serverPreview) next.preview = previewSummary(to.serverPreview);
|
|
29122
|
-
if (from.step === "pushing") {
|
|
29123
|
-
next.push = pushSummary(to.pushResult, to);
|
|
29124
|
-
next.pushFailed = pushHasFailures(to.pushResult);
|
|
29125
|
-
}
|
|
29126
|
-
if (from.step === "printing" && !failed) next.saved = { path: to.componentsPath, run_id: to.lastRunId };
|
|
29127
|
-
if (from.step === "preview-gate" && to.step === "final-review") next.edits += 1;
|
|
29128
|
-
return arrive(next, to);
|
|
29129
|
-
}
|
|
29130
|
-
var isFlowFinished = (step) => FINISHED.includes(step);
|
|
29131
|
-
function render(trail, now, outcome) {
|
|
29132
|
-
return {
|
|
29133
|
-
outcome,
|
|
29134
|
-
total_seconds: seconds(now - trail.startedAt),
|
|
29135
|
-
stages: trail.stages,
|
|
29136
|
-
...trail.preview ? { preview: trail.preview } : {},
|
|
29137
|
-
...trail.edits > 0 ? { edited_definitions_after_preview: trail.edits } : {},
|
|
29138
|
-
...trail.push ? { push: trail.push } : {},
|
|
29139
|
-
...trail.saved ? { saved: trail.saved } : {},
|
|
29140
|
-
...trail.failure ? { error: trail.failure } : {},
|
|
29141
|
-
...trail.validation ? { preview_validation: trail.validation } : {}
|
|
29142
|
-
};
|
|
29143
|
-
}
|
|
29144
|
-
function flowProgress(trail, now) {
|
|
29145
|
-
return render(trail, now, `interrupted at ${LABELS[trail.at]}`);
|
|
29146
|
-
}
|
|
29147
|
-
function flowFinish(trail, final, now) {
|
|
29148
|
-
if (!final) {
|
|
29149
|
-
const midWork = WORK.includes(trail.at);
|
|
29150
|
-
const outcome2 = `left the import ${midWork ? "while" : "at"} ${LABELS[trail.at]}${midWork ? " was running" : ""}`;
|
|
29151
|
-
return { outputs: render(trail, now, outcome2), status: midWork ? "error" : "success", exitMethod: "discarded" };
|
|
29152
|
-
}
|
|
29153
|
-
let outcome;
|
|
29154
|
-
let failed = true;
|
|
29155
|
-
if (trail.validation) {
|
|
29156
|
-
outcome = `blocked by ${String(trail.validation["count"])} preview validation error(s)`;
|
|
29157
|
-
} else if (trail.failure) {
|
|
29158
|
-
outcome = `failed at ${trail.failure.step}: ${trail.failure.message.slice(0, MAX_OUTCOME)}`;
|
|
29159
|
-
} else if (trail.pushFailed) {
|
|
29160
|
-
outcome = "pushed, but some entities failed";
|
|
29161
|
-
} else {
|
|
29162
|
-
failed = false;
|
|
29163
|
-
outcome = final.credentialsSkipped ? "saved without pushing (credentials skipped)" : "published";
|
|
29164
|
-
}
|
|
29165
|
-
return {
|
|
29166
|
-
outputs: render(trail, now, outcome),
|
|
29167
|
-
status: failed ? "error" : "success",
|
|
29168
|
-
exitMethod: failed ? "discarded" : "saved"
|
|
29169
|
-
};
|
|
29170
|
-
}
|
|
29171
|
-
|
|
29172
|
-
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow-log.ts
|
|
29173
|
-
function useFlowLog(state2) {
|
|
29174
|
-
const trail = useRef17(void 0);
|
|
29175
|
-
const previous = useRef17(void 0);
|
|
29176
|
-
useEffect27(() => {
|
|
29177
|
-
const before = previous.current;
|
|
29178
|
-
previous.current = state2;
|
|
29179
|
-
const moved = before !== void 0 && before.step !== state2.step;
|
|
29180
|
-
const now = Date.now();
|
|
29181
|
-
let open = trail.current;
|
|
29182
|
-
if (!open) {
|
|
29183
|
-
if (state2.step === "final-review" || before && !moved) return;
|
|
29184
|
-
open = openTrail(state2, now);
|
|
29185
|
-
startDebugRun({ ...FLOW_RUN, inputs: flowContext(state2) });
|
|
29186
|
-
} else if (before && moved) {
|
|
29187
|
-
open = advance(open, before, state2, now);
|
|
29188
|
-
} else {
|
|
29189
|
-
return;
|
|
29190
|
-
}
|
|
29191
|
-
if (isFlowFinished(state2.step)) {
|
|
29192
|
-
trail.current = void 0;
|
|
29193
|
-
void finishDebugRun(flowFinish(open, state2, now));
|
|
29194
|
-
return;
|
|
29195
|
-
}
|
|
29196
|
-
trail.current = open;
|
|
29197
|
-
setDebugRunProgress(flowProgress(open, now));
|
|
29198
|
-
}, [state2]);
|
|
29199
|
-
useEffect27(
|
|
29200
|
-
() => () => {
|
|
29201
|
-
const open = trail.current;
|
|
29202
|
-
trail.current = void 0;
|
|
29203
|
-
if (open) void finishDebugRun(flowFinish(open, void 0, Date.now()));
|
|
29204
|
-
},
|
|
29205
|
-
[]
|
|
29206
|
-
);
|
|
29207
|
-
}
|
|
29208
|
-
|
|
29209
28711
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/screen.tsx
|
|
29210
28712
|
import { jsx as jsx56, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
29211
28713
|
function canEditFromPreview(cdf) {
|
|
@@ -29219,7 +28721,6 @@ function FlowScreen({
|
|
|
29219
28721
|
generatePromptPath,
|
|
29220
28722
|
onExit
|
|
29221
28723
|
}) {
|
|
29222
|
-
useFlowLog(state2);
|
|
29223
28724
|
const produced = producedOf(state2);
|
|
29224
28725
|
const counts = { components: state2.generatedAcceptedCount, tokens: state2.tokenCount };
|
|
29225
28726
|
const things = countedThings(produced, counts);
|
|
@@ -29335,7 +28836,7 @@ function FlowScreen({
|
|
|
29335
28836
|
}
|
|
29336
28837
|
|
|
29337
28838
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
|
|
29338
|
-
import { useEffect as
|
|
28839
|
+
import { useEffect as useEffect24, useRef as useRef17, useSyncExternalStore } from "react";
|
|
29339
28840
|
|
|
29340
28841
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/controller.ts
|
|
29341
28842
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
@@ -29700,12 +29201,14 @@ function nextStateAfterPrint(opts) {
|
|
|
29700
29201
|
|
|
29701
29202
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
|
|
29702
29203
|
var SAVE_CONFIRMATION_DELAY_MS = 1e3;
|
|
29204
|
+
var describeCdfError = (error) => `${error.path.replace(/^\//, "").replace("/$properties/", ".").replaceAll("/", ".")}: ${error.message}`;
|
|
29703
29205
|
function buildSavedCDF(components, tokens, opts = {}) {
|
|
29704
29206
|
const cdf = buildCDF2(components, toCdfTokens(tokens), opts);
|
|
29705
29207
|
if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
|
|
29706
29208
|
const validation = validateCDF2(cdf);
|
|
29707
29209
|
if (!validation.valid) {
|
|
29708
|
-
|
|
29210
|
+
const errors = validation.errors.filter((error) => error.message !== 'must match "then" schema');
|
|
29211
|
+
throw new Error(`generated CDF failed validation: ${errors.map(describeCdfError).join("; ")}`);
|
|
29709
29212
|
}
|
|
29710
29213
|
return cdf;
|
|
29711
29214
|
}
|
|
@@ -30077,7 +29580,7 @@ function createFlowController(start, deps) {
|
|
|
30077
29580
|
|
|
30078
29581
|
// packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/use-flow.ts
|
|
30079
29582
|
function useFlow(start, options = {}) {
|
|
30080
|
-
const controller =
|
|
29583
|
+
const controller = useRef17();
|
|
30081
29584
|
if (start && !controller.current) {
|
|
30082
29585
|
try {
|
|
30083
29586
|
startWizardLog();
|
|
@@ -30094,14 +29597,14 @@ function useFlow(start, options = {}) {
|
|
|
30094
29597
|
(listener) => current?.subscribe(listener) ?? (() => void 0),
|
|
30095
29598
|
() => current?.getState()
|
|
30096
29599
|
);
|
|
30097
|
-
|
|
29600
|
+
useEffect24(() => {
|
|
30098
29601
|
if (!start) controller.current = void 0;
|
|
30099
29602
|
}, [start]);
|
|
30100
29603
|
return current && state2 ? { controller: current, state: state2 } : void 0;
|
|
30101
29604
|
}
|
|
30102
29605
|
|
|
30103
29606
|
// packages/experience-design-system-cli/src/tui/help/PageContainer.tsx
|
|
30104
|
-
import { useEffect as
|
|
29607
|
+
import { useEffect as useEffect25, useState as useState31 } from "react";
|
|
30105
29608
|
import { Box as Box46, Text as Text47, useInput as useInput13 } from "ink";
|
|
30106
29609
|
init_debug_store();
|
|
30107
29610
|
|
|
@@ -30175,7 +29678,7 @@ function Section({ title, rows }) {
|
|
|
30175
29678
|
}
|
|
30176
29679
|
function HelpScreen({ onDone }) {
|
|
30177
29680
|
const [info, setInfo] = useState31();
|
|
30178
|
-
|
|
29681
|
+
useEffect25(() => {
|
|
30179
29682
|
startDebugRun({ flow: "help", step: "01-help", menuOption: "Help", inputs: {} });
|
|
30180
29683
|
void readHelpInfo().then(setInfo);
|
|
30181
29684
|
}, []);
|
|
@@ -30272,10 +29775,43 @@ import { useState as useState36 } from "react";
|
|
|
30272
29775
|
import { Box as Box51, Text as Text53, useInput as useInput17 } from "ink";
|
|
30273
29776
|
|
|
30274
29777
|
// packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentsScreen.tsx
|
|
30275
|
-
import { useEffect as
|
|
29778
|
+
import { useEffect as useEffect27, useRef as useRef18, useState as useState34 } from "react";
|
|
30276
29779
|
import { Box as Box49, Text as Text51, useInput as useInput15 } from "ink";
|
|
30277
29780
|
init_debug_store();
|
|
30278
29781
|
|
|
29782
|
+
// packages/experience-design-system-cli/src/tui/settings/shared/debug-trail.ts
|
|
29783
|
+
init_config();
|
|
29784
|
+
import { existsSync as existsSync10 } from "node:fs";
|
|
29785
|
+
function diffSnapshots(before, after) {
|
|
29786
|
+
const names = [.../* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])];
|
|
29787
|
+
const changed_fields = names.filter((name) => before[name] !== after[name]);
|
|
29788
|
+
return { changed: changed_fields.length > 0, changed_fields };
|
|
29789
|
+
}
|
|
29790
|
+
var DEFAULT_TRAIL_LIMIT = 30;
|
|
29791
|
+
function createTrail(limit = DEFAULT_TRAIL_LIMIT) {
|
|
29792
|
+
const actions = [];
|
|
29793
|
+
return {
|
|
29794
|
+
record(action) {
|
|
29795
|
+
actions.push(action);
|
|
29796
|
+
if (actions.length > limit) actions.shift();
|
|
29797
|
+
},
|
|
29798
|
+
entries: () => [...actions]
|
|
29799
|
+
};
|
|
29800
|
+
}
|
|
29801
|
+
var MIN_SECRET_LENGTH = 6;
|
|
29802
|
+
function scrubError(error, secrets) {
|
|
29803
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
29804
|
+
for (const secret of secrets) {
|
|
29805
|
+
if (secret.length < MIN_SECRET_LENGTH) continue;
|
|
29806
|
+
for (const form of /* @__PURE__ */ new Set([secret, encodeURIComponent(secret)])) message = message.split(form).join("[redacted]");
|
|
29807
|
+
}
|
|
29808
|
+
return message;
|
|
29809
|
+
}
|
|
29810
|
+
function describeSettingsFile() {
|
|
29811
|
+
const path5 = configFilePath();
|
|
29812
|
+
return { path: path5, eds_home_set: Boolean(process.env["EDS_HOME"]), exists: existsSync10(path5) };
|
|
29813
|
+
}
|
|
29814
|
+
|
|
30279
29815
|
// packages/experience-design-system-cli/src/tui/settings/configuration/agents/agent-status.ts
|
|
30280
29816
|
import { execFile as execFile2 } from "node:child_process";
|
|
30281
29817
|
import { access as access5, constants } from "node:fs/promises";
|
|
@@ -30360,7 +29896,7 @@ async function testAgent(name, binary, model) {
|
|
|
30360
29896
|
timeoutMs: PROMPT_TIMEOUT_MS
|
|
30361
29897
|
})
|
|
30362
29898
|
);
|
|
30363
|
-
const
|
|
29899
|
+
const seconds = ((Date.now() - started) / 1e3).toFixed(1);
|
|
30364
29900
|
if (result.timedOut) {
|
|
30365
29901
|
return [...checks, { ...fail3("prompt", `no answer within ${PROMPT_TIMEOUT_MS / 1e3}s`), timedOut: true }];
|
|
30366
29902
|
}
|
|
@@ -30368,7 +29904,7 @@ async function testAgent(name, binary, model) {
|
|
|
30368
29904
|
const reason = result.stderr.trim().split("\n").pop()?.slice(0, 160) || `exited with code ${result.exitCode}`;
|
|
30369
29905
|
return [...checks, fail3("prompt", reason)];
|
|
30370
29906
|
}
|
|
30371
|
-
return [...checks, pass("prompt", `answered in ${
|
|
29907
|
+
return [...checks, pass("prompt", `answered in ${seconds}s`)];
|
|
30372
29908
|
}
|
|
30373
29909
|
function statusFromChecks(name, checks, savedBinary) {
|
|
30374
29910
|
if (checks.length === 0) return "checking";
|
|
@@ -30568,7 +30104,7 @@ async function writeAgentConfig(config) {
|
|
|
30568
30104
|
}
|
|
30569
30105
|
|
|
30570
30106
|
// packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentDetail.tsx
|
|
30571
|
-
import { useEffect as
|
|
30107
|
+
import { useEffect as useEffect26, useState as useState33 } from "react";
|
|
30572
30108
|
import { Box as Box48, Text as Text50 } from "ink";
|
|
30573
30109
|
|
|
30574
30110
|
// packages/experience-design-system-cli/src/tui/settings/configuration/agents/AgentStatusBadge.tsx
|
|
@@ -30631,7 +30167,7 @@ function AgentDetail({
|
|
|
30631
30167
|
const [testing, setTesting] = useState33(false);
|
|
30632
30168
|
const [notice, setNotice] = useState33(null);
|
|
30633
30169
|
const [checks, setChecks] = useState33(void 0);
|
|
30634
|
-
|
|
30170
|
+
useEffect26(() => {
|
|
30635
30171
|
let active = true;
|
|
30636
30172
|
setChecks(void 0);
|
|
30637
30173
|
const timer = setTimeout(() => {
|
|
@@ -30716,7 +30252,7 @@ function AgentsScreen({ onDone }) {
|
|
|
30716
30252
|
const [saving, setSaving] = useState34(false);
|
|
30717
30253
|
const [loadError, setLoadError] = useState34(null);
|
|
30718
30254
|
const [checks, setChecks] = useState34({});
|
|
30719
|
-
const visit =
|
|
30255
|
+
const visit = useRef18({
|
|
30720
30256
|
trail: createTrail(),
|
|
30721
30257
|
before: void 0,
|
|
30722
30258
|
environment: void 0,
|
|
@@ -30729,7 +30265,7 @@ function AgentsScreen({ onDone }) {
|
|
|
30729
30265
|
);
|
|
30730
30266
|
}
|
|
30731
30267
|
};
|
|
30732
|
-
|
|
30268
|
+
useEffect27(() => {
|
|
30733
30269
|
readAgentConfig().then((loaded) => {
|
|
30734
30270
|
setConfig(loaded);
|
|
30735
30271
|
inspectAll(loaded);
|
|
@@ -30906,7 +30442,7 @@ function AgentsScreen({ onDone }) {
|
|
|
30906
30442
|
}
|
|
30907
30443
|
|
|
30908
30444
|
// packages/experience-design-system-cli/src/tui/settings/configuration/project/ProjectScreen.tsx
|
|
30909
|
-
import { useEffect as
|
|
30445
|
+
import { useEffect as useEffect28, useRef as useRef19, useState as useState35 } from "react";
|
|
30910
30446
|
import { Box as Box50, Text as Text52, useInput as useInput16 } from "ink";
|
|
30911
30447
|
init_debug_store();
|
|
30912
30448
|
|
|
@@ -30964,14 +30500,14 @@ function ProjectScreen({ onDone }) {
|
|
|
30964
30500
|
const [saving, setSaving] = useState35(false);
|
|
30965
30501
|
const [notice, setNotice] = useState35(null);
|
|
30966
30502
|
const [loadError, setLoadError] = useState35(null);
|
|
30967
|
-
const visit =
|
|
30503
|
+
const visit = useRef19({
|
|
30968
30504
|
trail: createTrail(),
|
|
30969
30505
|
before: void 0,
|
|
30970
30506
|
persisted: void 0,
|
|
30971
30507
|
error: ""
|
|
30972
30508
|
}).current;
|
|
30973
|
-
const
|
|
30974
|
-
|
|
30509
|
+
const scrub = (err) => scrubError(err, [config?.cmaToken ?? ""]);
|
|
30510
|
+
useEffect28(() => {
|
|
30975
30511
|
readCredentials().then((cfg) => {
|
|
30976
30512
|
setConfig(cfg);
|
|
30977
30513
|
visit.before = snapshotOf(cfg);
|
|
@@ -31038,7 +30574,7 @@ function ProjectScreen({ onDone }) {
|
|
|
31038
30574
|
if (config.contentfulBaseDir) void startDebugSessionIn(config.contentfulBaseDir, { replace: true });
|
|
31039
30575
|
setNotice({ kind: "success", text: "Project settings saved" });
|
|
31040
30576
|
}).catch((err) => {
|
|
31041
|
-
visit.error =
|
|
30577
|
+
visit.error = scrub(err);
|
|
31042
30578
|
visit.trail.record("save failed");
|
|
31043
30579
|
setNotice({ kind: "error", text: err instanceof Error ? err.message : "Failed to save" });
|
|
31044
30580
|
}).finally(() => setSaving(false));
|
|
@@ -31123,7 +30659,7 @@ function ConfigurationScreen({ onDone }) {
|
|
|
31123
30659
|
}
|
|
31124
30660
|
|
|
31125
30661
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/screen.tsx
|
|
31126
|
-
import { useEffect as
|
|
30662
|
+
import { useEffect as useEffect29, useState as useState37 } from "react";
|
|
31127
30663
|
import { Box as Box52, Text as Text54, useInput as useInput18 } from "ink";
|
|
31128
30664
|
|
|
31129
30665
|
// packages/experience-design-system-cli/src/tui/settings/opt-in-analytics/analytics-store.ts
|
|
@@ -31147,7 +30683,7 @@ import { Fragment as Fragment20, jsx as jsx64, jsxs as jsxs52 } from "react/jsx-
|
|
|
31147
30683
|
function OptInAnalyticsScreen({ onDone }) {
|
|
31148
30684
|
const [loading, setLoading] = useState37(true);
|
|
31149
30685
|
const [enabled, setEnabled] = useState37(true);
|
|
31150
|
-
|
|
30686
|
+
useEffect29(() => {
|
|
31151
30687
|
readAnalyticsSetting().then((setting) => {
|
|
31152
30688
|
setEnabled(setting.enabled);
|
|
31153
30689
|
setLoading(false);
|
|
@@ -31201,7 +30737,7 @@ function OptInAnalyticsScreen({ onDone }) {
|
|
|
31201
30737
|
}
|
|
31202
30738
|
|
|
31203
30739
|
// packages/experience-design-system-cli/src/tui/settings/debug-mode/screen.tsx
|
|
31204
|
-
import { useEffect as
|
|
30740
|
+
import { useEffect as useEffect30, useRef as useRef20, useState as useState38 } from "react";
|
|
31205
30741
|
import { Box as Box53, Text as Text55, useInput as useInput19 } from "ink";
|
|
31206
30742
|
init_debug_mode_store();
|
|
31207
30743
|
init_debug_store();
|
|
@@ -31218,8 +30754,8 @@ function DebugModeScreen({ onDone }) {
|
|
|
31218
30754
|
RETENTION_CHOICES[RETENTION_CHOICES.length - 1]
|
|
31219
30755
|
);
|
|
31220
30756
|
const [notice, setNotice] = useState38(null);
|
|
31221
|
-
const visit =
|
|
31222
|
-
|
|
30757
|
+
const visit = useRef20({ trail: createTrail(), before: void 0, error: "" }).current;
|
|
30758
|
+
useEffect30(() => {
|
|
31223
30759
|
readDebugModeSetting().then((loaded) => {
|
|
31224
30760
|
setSetting(loaded);
|
|
31225
30761
|
setPending(loaded.retentionDays);
|
|
@@ -31374,7 +30910,7 @@ function App({ importOptions, inkClear }) {
|
|
|
31374
30910
|
const [flowStart, setFlowStart] = useState39();
|
|
31375
30911
|
const flow = useFlow(flowStart, { beforeStepChange: inkClear });
|
|
31376
30912
|
const [importDefaults, setImportDefaults] = useState39();
|
|
31377
|
-
|
|
30913
|
+
useEffect31(() => {
|
|
31378
30914
|
if (screen !== "import") {
|
|
31379
30915
|
setImportDefaults(void 0);
|
|
31380
30916
|
return;
|
|
@@ -31447,7 +30983,7 @@ function App({ importOptions, inkClear }) {
|
|
|
31447
30983
|
}
|
|
31448
30984
|
});
|
|
31449
30985
|
};
|
|
31450
|
-
|
|
30986
|
+
useEffect31(() => {
|
|
31451
30987
|
if (!tokensOnlyRun || tokensOnly?.status !== "done" || !tokensOnly.result.ok) return;
|
|
31452
30988
|
const { credentialsSkipped, input, tokens } = tokensOnlyRun;
|
|
31453
30989
|
const { tokensPath, tokenSessionId, tokenCount } = tokensOnly.result;
|
|
@@ -31469,12 +31005,12 @@ function App({ importOptions, inkClear }) {
|
|
|
31469
31005
|
}
|
|
31470
31006
|
});
|
|
31471
31007
|
}, [tokensOnly, tokensOnlyRun]);
|
|
31472
|
-
|
|
31008
|
+
useEffect31(() => {
|
|
31473
31009
|
if (!extractionRun || extraction?.status !== "done" || !extraction.result.ok) return;
|
|
31474
31010
|
setExtractionRun(void 0);
|
|
31475
31011
|
setScopeRun({ ...extractionRun, extraction: extraction.result.extraction });
|
|
31476
31012
|
}, [extraction, extractionRun]);
|
|
31477
|
-
|
|
31013
|
+
useEffect31(() => {
|
|
31478
31014
|
if (!scopeRun || scopeFlow?.status !== "confirmed" || generationInput) return;
|
|
31479
31015
|
const { extraction: produced, input, generatePromptPath } = scopeRun;
|
|
31480
31016
|
setGenerationInput({
|
|
@@ -31492,7 +31028,7 @@ function App({ importOptions, inkClear }) {
|
|
|
31492
31028
|
...generatePromptPath ? { generatePromptPath } : {}
|
|
31493
31029
|
});
|
|
31494
31030
|
}, [scopeFlow, scopeRun, generationInput]);
|
|
31495
|
-
|
|
31031
|
+
useEffect31(() => {
|
|
31496
31032
|
if (!scopeRun || generation?.status !== "done" || !generation.result.ok) return;
|
|
31497
31033
|
const { credentialsSkipped, extraction: produced, input, generatePromptPath } = scopeRun;
|
|
31498
31034
|
inkClear();
|
|
@@ -31661,7 +31197,6 @@ function App({ importOptions, inkClear }) {
|
|
|
31661
31197
|
return /* @__PURE__ */ jsx66(
|
|
31662
31198
|
CredentialsScreen,
|
|
31663
31199
|
{
|
|
31664
|
-
mode: target,
|
|
31665
31200
|
initial: importDefaults.credentials,
|
|
31666
31201
|
tokensOnly: target === "tokens",
|
|
31667
31202
|
onBack: () => goBackFrom("credentials"),
|