@contentful/experience-design-system-cli 2.37.1-dev-build-91b5f8aa.0 → 2.37.1-dev-build-fb8573b6.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 +4337 -500
- package/dist/index.js +5597 -1475
- package/dist/package.json +2 -1
- package/dist/src/tui/import/spawn-v1-import.d.ts +3 -3
- package/dist/src/tui/import/steps/04-credentials/logic.d.ts +0 -3
- package/dist/src/tui/import/steps/04-credentials/validate.d.ts +1 -1
- package/dist/src/tui/import/steps/05-token-reuse/logic.d.ts +1 -2
- package/dist/src/tui/import/steps/06-extraction/logic.d.ts +69 -0
- package/dist/src/tui/import/steps/06-extraction/processes.d.ts +45 -0
- package/dist/src/tui/import/steps/06-extraction/run.d.ts +24 -0
- package/dist/src/tui/import/steps/06-extraction/screen.d.ts +10 -0
- package/dist/src/tui/import/steps/06-extraction/selection.d.ts +18 -0
- package/dist/src/tui/import/steps/06-extraction/types.d.ts +44 -0
- package/dist/src/tui/import/steps/06-extraction/use-extraction.d.ts +14 -0
- package/dist/src/tui/import/steps/index.d.ts +1 -0
- package/legacy/dist/src/import/tui/WizardApp.d.ts +0 -8
- package/legacy/dist/src/import/tui/handoff.d.ts +26 -0
- package/legacy/dist/src/index.js +75 -628
- package/legacy/package.json +2 -1
- package/package.json +4 -3
- package/legacy/dist/src/import/tui/run-selection-agent.d.ts +0 -9
package/legacy/dist/src/index.js
CHANGED
|
@@ -4163,34 +4163,6 @@ function lookupCompositionCache(db, inputHash, cliVersion2) {
|
|
|
4163
4163
|
const row = db.prepare(`SELECT agent_output FROM composition_cache WHERE input_hash = ? AND cli_version = ?`).get(inputHash, cliVersion2);
|
|
4164
4164
|
return row ? row.agent_output : null;
|
|
4165
4165
|
}
|
|
4166
|
-
function storeSelectCache(db, componentHash, promptHash, cliVersion2, decision, reason) {
|
|
4167
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4168
|
-
db.prepare(
|
|
4169
|
-
`INSERT INTO select_cache (component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at)
|
|
4170
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
4171
|
-
ON CONFLICT(component_hash, prompt_hash, cli_version) DO UPDATE SET
|
|
4172
|
-
decision = excluded.decision,
|
|
4173
|
-
reason = excluded.reason,
|
|
4174
|
-
updated_at = excluded.updated_at`
|
|
4175
|
-
).run(componentHash, promptHash, cliVersion2, decision, reason, now, now);
|
|
4176
|
-
}
|
|
4177
|
-
function lookupSelectCache(db, componentHash, promptHash, cliVersion2) {
|
|
4178
|
-
const row = db.prepare(
|
|
4179
|
-
`SELECT component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at
|
|
4180
|
-
FROM select_cache
|
|
4181
|
-
WHERE component_hash = ? AND prompt_hash = ? AND cli_version = ?`
|
|
4182
|
-
).get(componentHash, promptHash, cliVersion2);
|
|
4183
|
-
if (!row) return null;
|
|
4184
|
-
return {
|
|
4185
|
-
componentHash: row.component_hash,
|
|
4186
|
-
promptHash: row.prompt_hash,
|
|
4187
|
-
cliVersion: row.cli_version,
|
|
4188
|
-
decision: row.decision,
|
|
4189
|
-
reason: row.reason,
|
|
4190
|
-
createdAt: row.created_at,
|
|
4191
|
-
updatedAt: row.updated_at
|
|
4192
|
-
};
|
|
4193
|
-
}
|
|
4194
4166
|
var SCHEMA, MAX_COMPONENT_SOURCE_CHARS, MAX_SIBLING_FILES, MAX_SIBLING_SNIPPET_CHARS, MAX_TYPE_DECLARING_SIBLING_CHARS, MAX_ENLARGED_SIBLINGS, MAX_SIBLING_DEPTH, MAX_SIBLING_CANDIDATES_EXPLORED, RELATIVE_IMPORT_PATTERN, SIBLING_FILE_EXTENSIONS, TS_ESM_EXTENSION_REWRITES, IDENTIFIER_PATTERN, _cliCacheVersionCache;
|
|
4195
4167
|
var init_db = __esm({
|
|
4196
4168
|
"packages/experience-design-system-cli-legacy/src/session/db.ts"() {
|
|
@@ -9919,6 +9891,37 @@ var init_GateStep = __esm({
|
|
|
9919
9891
|
}
|
|
9920
9892
|
});
|
|
9921
9893
|
|
|
9894
|
+
// packages/experience-design-system-cli-legacy/src/import/tui/handoff.ts
|
|
9895
|
+
import { HANDOFF_ENV, parseHandoff } from "@contentful/experience-design-system-types/handoff";
|
|
9896
|
+
function stateFromHandoff(handoff) {
|
|
9897
|
+
const { extraction } = handoff;
|
|
9898
|
+
return {
|
|
9899
|
+
credentialsSkipped: handoff.credentialsSkipped,
|
|
9900
|
+
...extraction ? {
|
|
9901
|
+
tokensPath: extraction.tokensPath,
|
|
9902
|
+
tokenSessionId: extraction.tokenSessionId,
|
|
9903
|
+
tokenCount: extraction.tokenCount,
|
|
9904
|
+
tokenGenerationStatus: "complete",
|
|
9905
|
+
outDir: extraction.outDir,
|
|
9906
|
+
extractSessionId: extraction.sessionId,
|
|
9907
|
+
compositionPhase: extraction.compositionPhase,
|
|
9908
|
+
selectionAgentStatus: "complete",
|
|
9909
|
+
existingEntitiesStatus: extraction.existingEntitiesStatus,
|
|
9910
|
+
existingEntitiesPath: extraction.existingEntitiesPath
|
|
9911
|
+
} : {}
|
|
9912
|
+
};
|
|
9913
|
+
}
|
|
9914
|
+
function readHandoff(env = process.env) {
|
|
9915
|
+
const parsed = parseHandoff(env[HANDOFF_ENV]);
|
|
9916
|
+
if (!parsed.ok) return parsed;
|
|
9917
|
+
return { ok: true, handoff: parsed.handoff, state: stateFromHandoff(parsed.handoff) };
|
|
9918
|
+
}
|
|
9919
|
+
var init_handoff = __esm({
|
|
9920
|
+
"packages/experience-design-system-cli-legacy/src/import/tui/handoff.ts"() {
|
|
9921
|
+
"use strict";
|
|
9922
|
+
}
|
|
9923
|
+
});
|
|
9924
|
+
|
|
9922
9925
|
// packages/experience-design-system-cli-legacy/src/tui/use-terminal-size.ts
|
|
9923
9926
|
import { useStdout } from "ink";
|
|
9924
9927
|
import { useEffect as useEffect4, useState as useState6 } from "react";
|
|
@@ -27241,80 +27244,6 @@ var init_runScopeGate = __esm({
|
|
|
27241
27244
|
}
|
|
27242
27245
|
});
|
|
27243
27246
|
|
|
27244
|
-
// packages/experience-design-system-cli-legacy/src/helpers/build-contentful-management-client.ts
|
|
27245
|
-
import { createClient as createClient2 } from "contentful-management";
|
|
27246
|
-
function buildContentfulManagementClient(opts) {
|
|
27247
|
-
return createClient2(
|
|
27248
|
-
{
|
|
27249
|
-
accessToken: opts.cmaToken,
|
|
27250
|
-
...opts.host ? { host: toConfiguredHost(opts.host) } : {}
|
|
27251
|
-
},
|
|
27252
|
-
{ type: "plain" }
|
|
27253
|
-
);
|
|
27254
|
-
}
|
|
27255
|
-
var init_build_contentful_management_client = __esm({
|
|
27256
|
-
"packages/experience-design-system-cli-legacy/src/helpers/build-contentful-management-client.ts"() {
|
|
27257
|
-
"use strict";
|
|
27258
|
-
init_host_utils();
|
|
27259
|
-
}
|
|
27260
|
-
});
|
|
27261
|
-
|
|
27262
|
-
// packages/experience-design-system-cli-legacy/src/helpers/fetch-existing-contentful-entities.ts
|
|
27263
|
-
import { fetchAll } from "contentful-management";
|
|
27264
|
-
async function fetchExistingContentfulEntitiesFromContentful(client2, params) {
|
|
27265
|
-
const componentScope = {
|
|
27266
|
-
spaceId: params.spaceId,
|
|
27267
|
-
environmentId: params.environmentId,
|
|
27268
|
-
query: { cursor: true, limit: 1e3 }
|
|
27269
|
-
};
|
|
27270
|
-
const tokenScope = {
|
|
27271
|
-
spaceId: params.spaceId,
|
|
27272
|
-
environmentId: params.environmentId,
|
|
27273
|
-
query: { cursor: true, limit: 1e3 }
|
|
27274
|
-
};
|
|
27275
|
-
const components = await fetchAll(client2.component.getMany, componentScope);
|
|
27276
|
-
const tokens = await fetchAll(client2.designToken.getMany, tokenScope);
|
|
27277
|
-
return { components, tokens };
|
|
27278
|
-
}
|
|
27279
|
-
var init_fetch_existing_contentful_entities = __esm({
|
|
27280
|
-
"packages/experience-design-system-cli-legacy/src/helpers/fetch-existing-contentful-entities.ts"() {
|
|
27281
|
-
"use strict";
|
|
27282
|
-
}
|
|
27283
|
-
});
|
|
27284
|
-
|
|
27285
|
-
// packages/experience-design-system-cli-legacy/src/helpers/fetch-and-persist-existing-contentful-entities.ts
|
|
27286
|
-
import { writeFile as writeFile4 } from "node:fs/promises";
|
|
27287
|
-
import { join as join19 } from "node:path";
|
|
27288
|
-
async function fetchAndPersistExistingContentfulEntities(params) {
|
|
27289
|
-
const t0 = Date.now();
|
|
27290
|
-
try {
|
|
27291
|
-
const client2 = buildContentfulManagementClient({
|
|
27292
|
-
cmaToken: params.cmaToken,
|
|
27293
|
-
...params.host ? { host: params.host } : {}
|
|
27294
|
-
});
|
|
27295
|
-
const entities = await fetchExistingContentfulEntitiesFromContentful(client2, {
|
|
27296
|
-
spaceId: params.spaceId,
|
|
27297
|
-
environmentId: params.environmentId
|
|
27298
|
-
});
|
|
27299
|
-
const path = join19(params.outDir, ".existing-entities.json");
|
|
27300
|
-
await writeFile4(path, JSON.stringify(entities, null, 2), "utf8");
|
|
27301
|
-
return { ok: true, path, durationMs: Date.now() - t0, entities };
|
|
27302
|
-
} catch (error) {
|
|
27303
|
-
return {
|
|
27304
|
-
ok: false,
|
|
27305
|
-
durationMs: Date.now() - t0,
|
|
27306
|
-
error: error instanceof Error ? error.message : String(error)
|
|
27307
|
-
};
|
|
27308
|
-
}
|
|
27309
|
-
}
|
|
27310
|
-
var init_fetch_and_persist_existing_contentful_entities = __esm({
|
|
27311
|
-
"packages/experience-design-system-cli-legacy/src/helpers/fetch-and-persist-existing-contentful-entities.ts"() {
|
|
27312
|
-
"use strict";
|
|
27313
|
-
init_build_contentful_management_client();
|
|
27314
|
-
init_fetch_existing_contentful_entities();
|
|
27315
|
-
}
|
|
27316
|
-
});
|
|
27317
|
-
|
|
27318
27247
|
// packages/experience-design-system-cli-legacy/src/import/tui/wizard-state-transitions.ts
|
|
27319
27248
|
function shouldGenerateAfterScopeGate(opts) {
|
|
27320
27249
|
return opts.acceptedCount > 0;
|
|
@@ -27350,121 +27279,11 @@ var init_wizard_state_transitions = __esm({
|
|
|
27350
27279
|
}
|
|
27351
27280
|
});
|
|
27352
27281
|
|
|
27353
|
-
// packages/experience-design-system-cli-legacy/src/import/tui/run-selection-agent.ts
|
|
27354
|
-
async function runSelectionAgent(options) {
|
|
27355
|
-
const db = openPipelineDb();
|
|
27356
|
-
let components;
|
|
27357
|
-
const cachedDecisions = /* @__PURE__ */ new Map();
|
|
27358
|
-
const cliVersion2 = await getCliCacheVersion();
|
|
27359
|
-
const promptHash = await hashPromptForSkill(
|
|
27360
|
-
"select",
|
|
27361
|
-
options.agent,
|
|
27362
|
-
options.model,
|
|
27363
|
-
options.promptPath,
|
|
27364
|
-
[],
|
|
27365
|
-
options.promptText
|
|
27366
|
-
);
|
|
27367
|
-
try {
|
|
27368
|
-
components = loadRawComponents(db, options.sessionId);
|
|
27369
|
-
if (!options.noCache) {
|
|
27370
|
-
for (const component of components) {
|
|
27371
|
-
const componentHash = hashComponentShape(component);
|
|
27372
|
-
const cached = lookupSelectCache(db, componentHash, promptHash, cliVersion2);
|
|
27373
|
-
if (cached) {
|
|
27374
|
-
cachedDecisions.set(component.name, {
|
|
27375
|
-
decision: cached.decision,
|
|
27376
|
-
reason: cached.reason
|
|
27377
|
-
});
|
|
27378
|
-
}
|
|
27379
|
-
}
|
|
27380
|
-
}
|
|
27381
|
-
} finally {
|
|
27382
|
-
db.close();
|
|
27383
|
-
}
|
|
27384
|
-
if (components.length === 0) return;
|
|
27385
|
-
const componentsToRun = components.filter((component) => !cachedDecisions.has(component.name));
|
|
27386
|
-
let calls = [];
|
|
27387
|
-
if (componentsToRun.length > 0) {
|
|
27388
|
-
const invoker2 = createLocalCliAgentInvoker({
|
|
27389
|
-
onDebugEvent: (name, payload) => getDebugLogger().event("agent", name, payload)
|
|
27390
|
-
});
|
|
27391
|
-
const prompt = await buildPrompt({
|
|
27392
|
-
skill: "select",
|
|
27393
|
-
mode: "autonomous",
|
|
27394
|
-
rawComponentsInline: JSON.stringify(componentsToRun, null, 2),
|
|
27395
|
-
outDir: process.cwd(),
|
|
27396
|
-
...options.promptText !== void 0 ? { skillContentOverride: options.promptText } : {},
|
|
27397
|
-
...options.promptText === void 0 && options.promptPath ? { skillPathOverride: options.promptPath } : {}
|
|
27398
|
-
});
|
|
27399
|
-
const { result } = await invokeAgentWithOutput(
|
|
27400
|
-
invoker2,
|
|
27401
|
-
{ agent: options.agent, model: options.model, prompt, timeoutMs: DEFAULT_TIMEOUT_MS4 },
|
|
27402
|
-
false
|
|
27403
|
-
);
|
|
27404
|
-
if (result.timedOut) throw new Error("selection agent timed out");
|
|
27405
|
-
if (result.exitCode !== 0) throw new Error(`selection agent exited with code ${result.exitCode}`);
|
|
27406
|
-
const parsed = parseSelectToolCallLines(result.stdout);
|
|
27407
|
-
for (const warning of parsed.warnings) process.stderr.write(`Warning: selection agent: ${warning}
|
|
27408
|
-
`);
|
|
27409
|
-
calls = parsed.calls;
|
|
27410
|
-
}
|
|
27411
|
-
const byName = new Map(calls.map((call) => [call.name, call]));
|
|
27412
|
-
const writeDb = openPipelineDb();
|
|
27413
|
-
try {
|
|
27414
|
-
writeDb.exec("BEGIN");
|
|
27415
|
-
const update = writeDb.prepare(
|
|
27416
|
-
`UPDATE raw_components SET status = ?, reject_reason = ? WHERE session_id = ? AND component_id = ?`
|
|
27417
|
-
);
|
|
27418
|
-
for (const component of components) {
|
|
27419
|
-
const cached = cachedDecisions.get(component.name);
|
|
27420
|
-
const call = byName.get(component.name);
|
|
27421
|
-
if (!cached && !call) continue;
|
|
27422
|
-
const rejected = cached ? cached.decision === "rejected" : call.tool === "reject_component";
|
|
27423
|
-
const reason = cached ? cached.reason : call.reason ?? null;
|
|
27424
|
-
update.run(
|
|
27425
|
-
rejected ? "rejected" : "accepted",
|
|
27426
|
-
rejected ? reason : null,
|
|
27427
|
-
options.sessionId,
|
|
27428
|
-
component.component_id
|
|
27429
|
-
);
|
|
27430
|
-
if (!cached) {
|
|
27431
|
-
storeSelectCache(
|
|
27432
|
-
writeDb,
|
|
27433
|
-
hashComponentShape(component),
|
|
27434
|
-
promptHash,
|
|
27435
|
-
cliVersion2,
|
|
27436
|
-
rejected ? "rejected" : "accepted",
|
|
27437
|
-
rejected ? reason : null
|
|
27438
|
-
);
|
|
27439
|
-
}
|
|
27440
|
-
}
|
|
27441
|
-
writeDb.exec("COMMIT");
|
|
27442
|
-
} catch (error) {
|
|
27443
|
-
writeDb.exec("ROLLBACK");
|
|
27444
|
-
throw error;
|
|
27445
|
-
} finally {
|
|
27446
|
-
writeDb.close();
|
|
27447
|
-
}
|
|
27448
|
-
}
|
|
27449
|
-
var DEFAULT_TIMEOUT_MS4;
|
|
27450
|
-
var init_run_selection_agent = __esm({
|
|
27451
|
-
"packages/experience-design-system-cli-legacy/src/import/tui/run-selection-agent.ts"() {
|
|
27452
|
-
"use strict";
|
|
27453
|
-
init_src();
|
|
27454
|
-
init_debug_logger();
|
|
27455
|
-
init_agent_output();
|
|
27456
|
-
init_db();
|
|
27457
|
-
init_cache_keys();
|
|
27458
|
-
DEFAULT_TIMEOUT_MS4 = Number(process.env.EDS_AGENT_TIMEOUT_MS ?? 5 * 60 * 1e3);
|
|
27459
|
-
}
|
|
27460
|
-
});
|
|
27461
|
-
|
|
27462
27282
|
// packages/experience-design-system-cli-legacy/src/import/tui/WizardApp.tsx
|
|
27463
27283
|
var WizardApp_exports = {};
|
|
27464
27284
|
__export(WizardApp_exports, {
|
|
27465
27285
|
WizardApp: () => WizardApp,
|
|
27466
27286
|
buildGenerateComponentsArgs: () => buildGenerateComponentsArgs,
|
|
27467
|
-
buildGenerateTokensArgs: () => buildGenerateTokensArgs,
|
|
27468
27287
|
buildMapTokensArgs: () => buildMapTokensArgs,
|
|
27469
27288
|
buildSavedCDF: () => buildSavedCDF,
|
|
27470
27289
|
formatAcceptanceSummary: () => formatAcceptanceSummary,
|
|
@@ -27473,11 +27292,11 @@ __export(WizardApp_exports, {
|
|
|
27473
27292
|
});
|
|
27474
27293
|
import { useEffect as useEffect14, useRef as useRef9, useState as useState19 } from "react";
|
|
27475
27294
|
import { Box as Box38, Text as Text40 } from "ink";
|
|
27476
|
-
import { join as
|
|
27295
|
+
import { join as join19, resolve as resolve18 } from "node:path";
|
|
27477
27296
|
import { appendFileSync as appendFileSync2, writeFileSync } from "node:fs";
|
|
27478
|
-
import { writeFile as
|
|
27297
|
+
import { writeFile as writeFile4 } from "node:fs/promises";
|
|
27479
27298
|
import { tmpdir } from "node:os";
|
|
27480
|
-
import { execFile as execFile2
|
|
27299
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
27481
27300
|
import { mkdir as mkdir4 } from "node:fs/promises";
|
|
27482
27301
|
import { buildCDF as buildCDF3, validateCDF as validateCDF3, validateSlotReferences as validateSlotReferences2 } from "@contentful/experience-design-system-types";
|
|
27483
27302
|
import { jsx as jsx47, jsxs as jsxs39 } from "react/jsx-runtime";
|
|
@@ -27496,14 +27315,6 @@ function buildGenerateComponentsArgs(opts) {
|
|
|
27496
27315
|
}
|
|
27497
27316
|
return args;
|
|
27498
27317
|
}
|
|
27499
|
-
function buildGenerateTokensArgs(opts) {
|
|
27500
|
-
const args = [findCliPath(), "__generate", "tokens", "--agent", opts.agent, "--raw-tokens", opts.rawTokensPath];
|
|
27501
|
-
if (opts.model) args.push("--model", opts.model);
|
|
27502
|
-
if (opts.bedrock) args.push("--bedrock");
|
|
27503
|
-
if (opts.noCache) args.push("--no-cache");
|
|
27504
|
-
for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
|
|
27505
|
-
return args;
|
|
27506
|
-
}
|
|
27507
27318
|
function buildMapTokensArgs(opts) {
|
|
27508
27319
|
const args = ["map", "tokens", "--session", opts.sessionId, "--agent", opts.agent];
|
|
27509
27320
|
if (opts.model) args.push("--model", opts.model);
|
|
@@ -27537,24 +27348,6 @@ function runCli(args) {
|
|
|
27537
27348
|
});
|
|
27538
27349
|
});
|
|
27539
27350
|
}
|
|
27540
|
-
function runSpawnedCli(args, onStderr, onStdout) {
|
|
27541
|
-
return new Promise((res) => {
|
|
27542
|
-
const child = spawn5("node", args);
|
|
27543
|
-
let stdout = "";
|
|
27544
|
-
let stderr = "";
|
|
27545
|
-
child.stdout.on("data", (d) => {
|
|
27546
|
-
const chunk = String(d);
|
|
27547
|
-
stdout += chunk;
|
|
27548
|
-
onStdout?.(chunk);
|
|
27549
|
-
});
|
|
27550
|
-
child.stderr.on("data", (d) => {
|
|
27551
|
-
const chunk = String(d);
|
|
27552
|
-
stderr += chunk;
|
|
27553
|
-
onStderr?.(chunk);
|
|
27554
|
-
});
|
|
27555
|
-
child.on("exit", (code) => res({ exitCode: code ?? 0, stdout, stderr }));
|
|
27556
|
-
});
|
|
27557
|
-
}
|
|
27558
27351
|
function buildGenerateProcessArgs(opts) {
|
|
27559
27352
|
return [findCliPath(), ...buildGenerateComponentsArgs(opts)];
|
|
27560
27353
|
}
|
|
@@ -27624,19 +27417,16 @@ function WizardApp({
|
|
|
27624
27417
|
const allowEmptyDeleteAllRef = useRef9(false);
|
|
27625
27418
|
const generationCachePreflightRef = useRef9(null);
|
|
27626
27419
|
const selectionToReviewStartedAtRef = useRef9(null);
|
|
27627
|
-
const tokenGenerationPromiseRef = useRef9(null);
|
|
27628
|
-
const extractPromiseRef = useRef9(null);
|
|
27629
|
-
const extractStartedRef = useRef9(false);
|
|
27630
27420
|
const credentialsReadyRef = useRef9(false);
|
|
27631
27421
|
const agentAuthVerifiedRef = useRef9(false);
|
|
27632
27422
|
const scopeGateCompletedRef = useRef9(false);
|
|
27633
27423
|
const scopeComponentsRef = useRef9(null);
|
|
27634
|
-
const existingEntitiesPromiseRef = useRef9(null);
|
|
27635
27424
|
const generatePromiseRef = useRef9(null);
|
|
27636
27425
|
const rawTokensEntryReady = !!initialRawTokensPath;
|
|
27637
27426
|
const effectiveNoCache = resolveNoCacheForGenerate({ cliNoCache: noCache });
|
|
27638
|
-
const
|
|
27639
|
-
const
|
|
27427
|
+
const [startedFrom] = useState19(() => readHandoff());
|
|
27428
|
+
const initialStepResolved = startedFrom.ok ? "credentials" : "error";
|
|
27429
|
+
const initialOutDir = initialProjectPath ? join19(resolve18(initialProjectPath), ".contentful") : "";
|
|
27640
27430
|
const [state, setState] = useState19({
|
|
27641
27431
|
step: initialStepResolved,
|
|
27642
27432
|
agent: initialAgent ?? "claude",
|
|
@@ -27646,7 +27436,6 @@ function WizardApp({
|
|
|
27646
27436
|
outDir: initialOutDir,
|
|
27647
27437
|
rawTokensPath: rawTokensEntryReady ? initialRawTokensPath : "",
|
|
27648
27438
|
tokensPath: "",
|
|
27649
|
-
skipComponents: false,
|
|
27650
27439
|
tokenSessionId: null,
|
|
27651
27440
|
tokenGenerationStatus: "idle",
|
|
27652
27441
|
mapTokensStatus: "idle",
|
|
@@ -27659,7 +27448,6 @@ function WizardApp({
|
|
|
27659
27448
|
generatedAcceptedCount: 0,
|
|
27660
27449
|
generateProgress: null,
|
|
27661
27450
|
selectionAgentStatus: "idle",
|
|
27662
|
-
extractProgress: null,
|
|
27663
27451
|
compositionPhase: null,
|
|
27664
27452
|
componentsPath: "",
|
|
27665
27453
|
spaceId: initialSpaceId,
|
|
@@ -27684,12 +27472,12 @@ function WizardApp({
|
|
|
27684
27472
|
credentialsValidating: false,
|
|
27685
27473
|
credentialsBackgroundValidating: false,
|
|
27686
27474
|
mapTokensEligible: null,
|
|
27687
|
-
credentialsSkipped: false,
|
|
27688
27475
|
existingEntitiesPath: null,
|
|
27689
27476
|
existingEntitiesStatus: "idle",
|
|
27690
27477
|
lastRunId: null,
|
|
27691
27478
|
finalizeErrorBanner: null,
|
|
27692
|
-
finalReviewPassed: false
|
|
27479
|
+
finalReviewPassed: false,
|
|
27480
|
+
...startedFrom.ok ? startedFrom.state : { credentialsSkipped: false, errorStep: "start import", errorMessage: startedFrom.error }
|
|
27693
27481
|
});
|
|
27694
27482
|
useEffect14(() => {
|
|
27695
27483
|
sessionRef.current = {
|
|
@@ -27809,58 +27597,6 @@ If you are using AWS Bedrock, run:
|
|
|
27809
27597
|
if (!deferStep) update({ step: nextStep });
|
|
27810
27598
|
return true;
|
|
27811
27599
|
};
|
|
27812
|
-
const runGenerateTokens = async (rawTokensPath, outDir, forceRegenerate = false) => {
|
|
27813
|
-
update({ tokenGenerationStatus: "running" });
|
|
27814
|
-
const tokenArgs = buildGenerateTokensArgs({
|
|
27815
|
-
rawTokensPath,
|
|
27816
|
-
agent: state.agent,
|
|
27817
|
-
...state.agentModel ? { model: state.agentModel } : {},
|
|
27818
|
-
...state.bedrock ? { bedrock: true } : {},
|
|
27819
|
-
noCache: effectiveNoCache || forceRegenerate,
|
|
27820
|
-
promptOverrides
|
|
27821
|
-
});
|
|
27822
|
-
const result = await runSpawnedCli(tokenArgs);
|
|
27823
|
-
if (result.exitCode !== 0) {
|
|
27824
|
-
update({
|
|
27825
|
-
step: "error",
|
|
27826
|
-
tokenGenerationStatus: "failed",
|
|
27827
|
-
errorStep: "generate tokens",
|
|
27828
|
-
errorMessage: result.stderr.trim() || "Unknown error"
|
|
27829
|
-
});
|
|
27830
|
-
return false;
|
|
27831
|
-
}
|
|
27832
|
-
const sessionMatch = /^session=(.+)$/m.exec(result.stdout);
|
|
27833
|
-
const tokenSessionId = sessionMatch ? sessionMatch[1].trim() : null;
|
|
27834
|
-
const tokensPath = join20(outDir, "tokens.json");
|
|
27835
|
-
const printArgs = ["print", "tokens", "--out", tokensPath];
|
|
27836
|
-
if (tokenSessionId) printArgs.push("--session", tokenSessionId);
|
|
27837
|
-
const r = await runCli(printArgs);
|
|
27838
|
-
if (r.exitCode !== 0) {
|
|
27839
|
-
update({
|
|
27840
|
-
step: "error",
|
|
27841
|
-
tokenGenerationStatus: "failed",
|
|
27842
|
-
errorStep: "print tokens",
|
|
27843
|
-
errorMessage: r.stderr.trim() || "Unknown error"
|
|
27844
|
-
});
|
|
27845
|
-
return false;
|
|
27846
|
-
}
|
|
27847
|
-
const tokenCount = parsePrintTokensCount(r.stdout);
|
|
27848
|
-
if (!state.projectPath) {
|
|
27849
|
-
update({
|
|
27850
|
-
tokensPath,
|
|
27851
|
-
tokenSessionId,
|
|
27852
|
-
tokenCount,
|
|
27853
|
-
tokenGenerationStatus: "complete",
|
|
27854
|
-
skipComponents: true,
|
|
27855
|
-
acceptedCount: 0,
|
|
27856
|
-
outDir: state.outDir || join20(process.cwd(), ".contentful")
|
|
27857
|
-
});
|
|
27858
|
-
update({ step: "credentials" });
|
|
27859
|
-
return true;
|
|
27860
|
-
}
|
|
27861
|
-
update({ tokensPath, tokenSessionId, tokenCount, tokenGenerationStatus: "complete" });
|
|
27862
|
-
return true;
|
|
27863
|
-
};
|
|
27864
27600
|
const runMapTokens2 = async (sessionId2, silent = false) => {
|
|
27865
27601
|
const timer = startWizardTimer("token-mapping", {
|
|
27866
27602
|
sessionId: sessionId2,
|
|
@@ -27944,236 +27680,6 @@ If you are using AWS Bedrock, run:
|
|
|
27944
27680
|
});
|
|
27945
27681
|
return true;
|
|
27946
27682
|
};
|
|
27947
|
-
const startExistingEntitiesFetch = (projectPath, outDir) => {
|
|
27948
|
-
if (state.credentialsSkipped || !state.spaceId || !state.environmentId || !state.cmaToken || !projectPath) {
|
|
27949
|
-
return null;
|
|
27950
|
-
}
|
|
27951
|
-
const startedAt = Date.now();
|
|
27952
|
-
getDebugLogger().event("wizard", "existing-entities.fetch.start", {
|
|
27953
|
-
spaceId: state.spaceId,
|
|
27954
|
-
environmentId: state.environmentId,
|
|
27955
|
-
host: state.host,
|
|
27956
|
-
outDir
|
|
27957
|
-
});
|
|
27958
|
-
update({ existingEntitiesStatus: "running" });
|
|
27959
|
-
const promise = (async () => {
|
|
27960
|
-
try {
|
|
27961
|
-
await mkdir4(outDir, { recursive: true });
|
|
27962
|
-
const result = await fetchAndPersistExistingContentfulEntities({
|
|
27963
|
-
spaceId: state.spaceId,
|
|
27964
|
-
environmentId: state.environmentId,
|
|
27965
|
-
cmaToken: state.cmaToken,
|
|
27966
|
-
...state.host ? { host: state.host } : {},
|
|
27967
|
-
outDir
|
|
27968
|
-
});
|
|
27969
|
-
if (result.ok) {
|
|
27970
|
-
getDebugLogger().event("wizard", "existing-entities.fetch.ok", {
|
|
27971
|
-
durationMs: result.durationMs,
|
|
27972
|
-
components: result.entities.components.length,
|
|
27973
|
-
tokens: result.entities.tokens.length
|
|
27974
|
-
});
|
|
27975
|
-
update({ existingEntitiesPath: result.path, existingEntitiesStatus: "complete" });
|
|
27976
|
-
return true;
|
|
27977
|
-
}
|
|
27978
|
-
getDebugLogger().event("wizard", "existing-entities.fetch.error", {
|
|
27979
|
-
durationMs: result.durationMs,
|
|
27980
|
-
error: result.error
|
|
27981
|
-
});
|
|
27982
|
-
update({ existingEntitiesStatus: "failed" });
|
|
27983
|
-
return false;
|
|
27984
|
-
} catch (error) {
|
|
27985
|
-
getDebugLogger().event("wizard", "existing-entities.fetch.error", {
|
|
27986
|
-
durationMs: Date.now() - startedAt,
|
|
27987
|
-
error: error instanceof Error ? error.message : String(error)
|
|
27988
|
-
});
|
|
27989
|
-
update({ existingEntitiesStatus: "failed" });
|
|
27990
|
-
return false;
|
|
27991
|
-
}
|
|
27992
|
-
})();
|
|
27993
|
-
existingEntitiesPromiseRef.current = promise;
|
|
27994
|
-
return promise;
|
|
27995
|
-
};
|
|
27996
|
-
const runExtract = async (projectPath, showProgress = true) => {
|
|
27997
|
-
const outDir = join20(resolve18(projectPath), ".contentful");
|
|
27998
|
-
const existingEntitiesExpected = !state.credentialsSkipped && Boolean(state.spaceId && state.environmentId && state.cmaToken && projectPath);
|
|
27999
|
-
update({
|
|
28000
|
-
...showProgress ? { step: "extracting" } : {},
|
|
28001
|
-
outDir,
|
|
28002
|
-
extractProgress: null,
|
|
28003
|
-
compositionPhase: "resolving",
|
|
28004
|
-
// Put every extraction-stage task on the first frame. The selection
|
|
28005
|
-
// agent cannot start until extraction emits its session, but it is
|
|
28006
|
-
// already part of this stage and should not appear later as a new row.
|
|
28007
|
-
selectionAgentStatus: state.agent ? "running" : "complete",
|
|
28008
|
-
existingEntitiesStatus: existingEntitiesExpected ? "running" : "idle"
|
|
28009
|
-
});
|
|
28010
|
-
const existingEntitiesPromise = startExistingEntitiesFetch(projectPath, outDir);
|
|
28011
|
-
const extractArgs = [findCliPath(), "__extract", "--project", projectPath];
|
|
28012
|
-
if (effectiveNoCache) extractArgs.push("--composition-refresh", "--no-cache");
|
|
28013
|
-
for (const p of promptOverrides ?? []) extractArgs.push("--prompt", p);
|
|
28014
|
-
if (state.agent) extractArgs.push("--agent", state.agent);
|
|
28015
|
-
if (state.bedrock) extractArgs.push("--bedrock");
|
|
28016
|
-
let selectionPromptText;
|
|
28017
|
-
let selectionPromptPath;
|
|
28018
|
-
try {
|
|
28019
|
-
const { overrides, errors } = parsePromptOverrides(promptOverrides ?? []);
|
|
28020
|
-
if (errors.length > 0) throw new Error(errors.join("; "));
|
|
28021
|
-
const selectOverride = overrides.get("select");
|
|
28022
|
-
if (selectOverride?.kind === "text") selectionPromptText = selectOverride.value;
|
|
28023
|
-
if (selectOverride?.kind === "path") {
|
|
28024
|
-
selectionPromptPath = resolve18(selectOverride.value);
|
|
28025
|
-
await resolvePromptOverride(selectOverride);
|
|
28026
|
-
}
|
|
28027
|
-
} catch (error) {
|
|
28028
|
-
update({
|
|
28029
|
-
step: "error",
|
|
28030
|
-
errorStep: "selection agent",
|
|
28031
|
-
errorMessage: error instanceof Error ? error.message : String(error)
|
|
28032
|
-
});
|
|
28033
|
-
return;
|
|
28034
|
-
}
|
|
28035
|
-
let selectionPromise = null;
|
|
28036
|
-
let selectionError;
|
|
28037
|
-
let selectionStarted = false;
|
|
28038
|
-
const startSelection = (sessionId2) => {
|
|
28039
|
-
if (selectionStarted || !state.agent) return;
|
|
28040
|
-
selectionStarted = true;
|
|
28041
|
-
selectionPromise = (async () => {
|
|
28042
|
-
if (existingEntitiesPromise) await existingEntitiesPromise;
|
|
28043
|
-
await runSelectionAgent({
|
|
28044
|
-
sessionId: sessionId2,
|
|
28045
|
-
agent: state.agent,
|
|
28046
|
-
...state.agentModel ? { model: state.agentModel } : {},
|
|
28047
|
-
...selectionPromptText !== void 0 ? { promptText: selectionPromptText } : {},
|
|
28048
|
-
...selectionPromptPath ? { promptPath: selectionPromptPath } : {},
|
|
28049
|
-
noCache: effectiveNoCache
|
|
28050
|
-
});
|
|
28051
|
-
})().catch((error) => {
|
|
28052
|
-
selectionError = error;
|
|
28053
|
-
}).finally(() => update({ selectionAgentStatus: "complete" }));
|
|
28054
|
-
};
|
|
28055
|
-
let stderrBuffer = "";
|
|
28056
|
-
let stdoutBuffer = "";
|
|
28057
|
-
const r = await runSpawnedCli(
|
|
28058
|
-
extractArgs,
|
|
28059
|
-
(chunk) => {
|
|
28060
|
-
stderrBuffer += chunk;
|
|
28061
|
-
const lines = stderrBuffer.split("\n");
|
|
28062
|
-
stderrBuffer = lines.pop() ?? "";
|
|
28063
|
-
for (const line of lines) {
|
|
28064
|
-
const scanMatch = /^progress=scan:(\d+)$/.exec(line.trim());
|
|
28065
|
-
if (scanMatch) {
|
|
28066
|
-
const scanned = Number(scanMatch[1]);
|
|
28067
|
-
setState((prev) => ({
|
|
28068
|
-
...prev,
|
|
28069
|
-
extractProgress: {
|
|
28070
|
-
scanned,
|
|
28071
|
-
filesProcessed: prev.extractProgress?.filesProcessed ?? 0,
|
|
28072
|
-
totalFiles: prev.extractProgress?.totalFiles ?? 0,
|
|
28073
|
-
componentsFound: prev.extractProgress?.componentsFound ?? 0
|
|
28074
|
-
}
|
|
28075
|
-
}));
|
|
28076
|
-
continue;
|
|
28077
|
-
}
|
|
28078
|
-
const scanDoneMatch = /^progress=scan-done:(\d+)$/.exec(line.trim());
|
|
28079
|
-
if (scanDoneMatch) {
|
|
28080
|
-
const scanned = Number(scanDoneMatch[1]);
|
|
28081
|
-
setState((prev) => ({
|
|
28082
|
-
...prev,
|
|
28083
|
-
extractProgress: {
|
|
28084
|
-
scanned,
|
|
28085
|
-
filesProcessed: prev.extractProgress?.filesProcessed ?? 0,
|
|
28086
|
-
totalFiles: scanned,
|
|
28087
|
-
componentsFound: prev.extractProgress?.componentsFound ?? 0
|
|
28088
|
-
}
|
|
28089
|
-
}));
|
|
28090
|
-
continue;
|
|
28091
|
-
}
|
|
28092
|
-
const extractMatch = /^progress=extract:(\d+)\/(\d+):(\d+)$/.exec(line.trim());
|
|
28093
|
-
if (extractMatch) {
|
|
28094
|
-
const filesProcessed = Number(extractMatch[1]);
|
|
28095
|
-
const totalFiles = Number(extractMatch[2]);
|
|
28096
|
-
const componentsFound = Number(extractMatch[3]);
|
|
28097
|
-
setState((prev) => ({
|
|
28098
|
-
...prev,
|
|
28099
|
-
extractProgress: {
|
|
28100
|
-
scanned: prev.extractProgress?.scanned ?? 0,
|
|
28101
|
-
filesProcessed,
|
|
28102
|
-
totalFiles,
|
|
28103
|
-
componentsFound
|
|
28104
|
-
}
|
|
28105
|
-
}));
|
|
28106
|
-
continue;
|
|
28107
|
-
}
|
|
28108
|
-
const compositionMatch = /^progress=composition:(.+)$/.exec(line.trim());
|
|
28109
|
-
if (compositionMatch) {
|
|
28110
|
-
setState((prev) => ({ ...prev, compositionPhase: compositionMatch[1].trim() }));
|
|
28111
|
-
}
|
|
28112
|
-
}
|
|
28113
|
-
},
|
|
28114
|
-
(chunk) => {
|
|
28115
|
-
stdoutBuffer += chunk;
|
|
28116
|
-
const lines = stdoutBuffer.split("\n");
|
|
28117
|
-
stdoutBuffer = lines.pop() ?? "";
|
|
28118
|
-
for (const line of lines) {
|
|
28119
|
-
const sessionMatch2 = /^session=(.+)$/.exec(line.trim());
|
|
28120
|
-
if (sessionMatch2) startSelection(sessionMatch2[1].trim());
|
|
28121
|
-
}
|
|
28122
|
-
}
|
|
28123
|
-
);
|
|
28124
|
-
const sessionMatch = /^session=(.+)$/m.exec(r.stdout);
|
|
28125
|
-
if (!selectionStarted && sessionMatch) startSelection(sessionMatch[1].trim());
|
|
28126
|
-
if (selectionPromise) await selectionPromise;
|
|
28127
|
-
if (!selectionStarted && existingEntitiesPromise) await existingEntitiesPromise;
|
|
28128
|
-
if (r.exitCode !== 0) {
|
|
28129
|
-
update({
|
|
28130
|
-
step: "error",
|
|
28131
|
-
errorStep: "analyze extract",
|
|
28132
|
-
errorMessage: r.stderr.trim() || "Unknown error"
|
|
28133
|
-
});
|
|
28134
|
-
return;
|
|
28135
|
-
}
|
|
28136
|
-
const extractSessionId = sessionMatch ? sessionMatch[1].trim() : null;
|
|
28137
|
-
const countMatch = /Extracted (\d+) components?/.exec(r.stderr);
|
|
28138
|
-
const extractedCount = countMatch ? Number(countMatch[1]) : 0;
|
|
28139
|
-
if (extractedCount === 0) {
|
|
28140
|
-
update({
|
|
28141
|
-
step: "error",
|
|
28142
|
-
errorStep: "analyze extract",
|
|
28143
|
-
errorMessage: `No components found in ${projectPath}.
|
|
28144
|
-
|
|
28145
|
-
Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .vue, etc.).`
|
|
28146
|
-
});
|
|
28147
|
-
return;
|
|
28148
|
-
}
|
|
28149
|
-
if (selectionError) {
|
|
28150
|
-
update({
|
|
28151
|
-
step: "error",
|
|
28152
|
-
errorStep: "selection agent",
|
|
28153
|
-
errorMessage: selectionError instanceof Error ? selectionError.message : String(selectionError)
|
|
28154
|
-
});
|
|
28155
|
-
return;
|
|
28156
|
-
}
|
|
28157
|
-
if (state.rawTokensPath && tokenGenerationPromiseRef.current) {
|
|
28158
|
-
const tokenGenerationSucceeded = await tokenGenerationPromiseRef.current;
|
|
28159
|
-
tokenGenerationPromiseRef.current = null;
|
|
28160
|
-
if (!tokenGenerationSucceeded) return;
|
|
28161
|
-
}
|
|
28162
|
-
update({
|
|
28163
|
-
extractSessionId,
|
|
28164
|
-
selectionAgentStatus: "complete",
|
|
28165
|
-
...credentialsReadyRef.current ? { step: "scope-gate" } : {}
|
|
28166
|
-
});
|
|
28167
|
-
};
|
|
28168
|
-
const startExtract = (projectPath, showProgress = true) => {
|
|
28169
|
-
if (extractStartedRef.current) return;
|
|
28170
|
-
extractStartedRef.current = true;
|
|
28171
|
-
const promise = runExtract(projectPath, showProgress);
|
|
28172
|
-
extractPromiseRef.current = promise;
|
|
28173
|
-
void promise.finally(() => {
|
|
28174
|
-
extractPromiseRef.current = null;
|
|
28175
|
-
});
|
|
28176
|
-
};
|
|
28177
27683
|
const buildGenerateOptions = (extractSessionId, tokensPath, generatePromptPath2, cachedComponents) => ({
|
|
28178
27684
|
sessionId: extractSessionId,
|
|
28179
27685
|
tokensPath,
|
|
@@ -28259,7 +27765,7 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28259
27765
|
}
|
|
28260
27766
|
};
|
|
28261
27767
|
useEffect14(() => {
|
|
28262
|
-
if (state.step !== "
|
|
27768
|
+
if (state.step !== "scope-gate" || !state.extractSessionId || state.existingEntitiesStatus === "running" || state.existingEntitiesStatus === "idle" || state.selectionAgentStatus !== "complete" || state.compositionPhase !== "done" && state.compositionPhase !== "cache-hit" || state.rawTokensPath && state.tokenGenerationStatus !== "complete" || effectiveNoCache) {
|
|
28263
27769
|
return;
|
|
28264
27770
|
}
|
|
28265
27771
|
const sessionId2 = state.extractSessionId;
|
|
@@ -28414,14 +27920,16 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28414
27920
|
};
|
|
28415
27921
|
const advanceAfterCredentialsValidated = async () => {
|
|
28416
27922
|
credentialsReadyRef.current = true;
|
|
28417
|
-
if (!sessionRef.current.extractSessionId
|
|
28418
|
-
|
|
28419
|
-
|
|
27923
|
+
if (!sessionRef.current.extractSessionId) {
|
|
27924
|
+
update({
|
|
27925
|
+
step: "error",
|
|
27926
|
+
errorStep: "start import",
|
|
27927
|
+
errorMessage: "Internal error: the CLI did not hand over an extract session."
|
|
27928
|
+
});
|
|
28420
27929
|
return;
|
|
28421
27930
|
}
|
|
28422
|
-
if (!scopeGateCompletedRef.current
|
|
28423
|
-
|
|
28424
|
-
else update({ step: "scope-gate" });
|
|
27931
|
+
if (!scopeGateCompletedRef.current) {
|
|
27932
|
+
update({ step: "scope-gate" });
|
|
28425
27933
|
return;
|
|
28426
27934
|
}
|
|
28427
27935
|
if (shouldSkipFinalReviewAfterCredentials({
|
|
@@ -28805,7 +28313,7 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
28805
28313
|
};
|
|
28806
28314
|
const runPrintFiles = async (extractSessionId, outDir, opts = {}) => {
|
|
28807
28315
|
update({ step: "printing" });
|
|
28808
|
-
const componentsPath =
|
|
28316
|
+
const componentsPath = join19(outDir, "components.json");
|
|
28809
28317
|
try {
|
|
28810
28318
|
const db = openPipelineDb();
|
|
28811
28319
|
let components = [];
|
|
@@ -28818,7 +28326,7 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
28818
28326
|
}
|
|
28819
28327
|
if (!opts.tokenSessionId && opts.tokensPath) tokens = await readTokensFromPath("tokens", opts.tokensPath);
|
|
28820
28328
|
const cdf = buildSavedCDF(components, tokens, { deleteAll: opts.allowEmpty });
|
|
28821
|
-
await
|
|
28329
|
+
await writeFile4(componentsPath, `${JSON.stringify(cdf, null, 2)}
|
|
28822
28330
|
`);
|
|
28823
28331
|
process.stderr.write(
|
|
28824
28332
|
`wrote ${componentsPath} (${components.length} component${components.length === 1 ? "" : "s"}, ${tokens.length} token${tokens.length === 1 ? "" : "s"})
|
|
@@ -28902,23 +28410,6 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
28902
28410
|
void runPreview(extractSessionId, tokensPath, state.spaceId, state.environmentId, state.cmaToken, state.host);
|
|
28903
28411
|
}
|
|
28904
28412
|
};
|
|
28905
|
-
const tokenStrategyApplied = useRef9(false);
|
|
28906
|
-
useEffect14(() => {
|
|
28907
|
-
if (!state.rawTokensPath || tokenStrategyApplied.current) return;
|
|
28908
|
-
tokenStrategyApplied.current = true;
|
|
28909
|
-
const strategy = process.env["EDS_IMPORT_TOKENS"];
|
|
28910
|
-
if (strategy === "reuse") {
|
|
28911
|
-
update({
|
|
28912
|
-
tokensPath: join20(state.outDir, "tokens.json"),
|
|
28913
|
-
tokenSessionId: null,
|
|
28914
|
-
tokenGenerationStatus: "complete"
|
|
28915
|
-
});
|
|
28916
|
-
return;
|
|
28917
|
-
}
|
|
28918
|
-
tokenGenerationPromiseRef.current = runAgentAuthCheck("credentials").then(
|
|
28919
|
-
(ok2) => ok2 ? runGenerateTokens(state.rawTokensPath, state.outDir, strategy === "regenerate") : false
|
|
28920
|
-
);
|
|
28921
|
-
}, [state.rawTokensPath]);
|
|
28922
28413
|
const credentialsHandedOff = useRef9(false);
|
|
28923
28414
|
useEffect14(() => {
|
|
28924
28415
|
if (state.step !== "credentials" || credentialsHandedOff.current) return;
|
|
@@ -28929,7 +28420,6 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
28929
28420
|
const noQuitSteps = [
|
|
28930
28421
|
"checking-claude-auth",
|
|
28931
28422
|
"validating-credentials",
|
|
28932
|
-
"extracting",
|
|
28933
28423
|
"generating",
|
|
28934
28424
|
"mapping-tokens",
|
|
28935
28425
|
"printing",
|
|
@@ -28939,8 +28429,7 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
28939
28429
|
const hints = noQuitSteps.includes(state.step) ? [] : [{ key: "q", label: "quit" }];
|
|
28940
28430
|
const hasTokens = !!state.tokensPath;
|
|
28941
28431
|
const hasTokenStage = hasTokens || !!state.rawTokensPath;
|
|
28942
|
-
const
|
|
28943
|
-
const totalSteps = 3 + (hasTokenStage ? 1 : 0) + (hasComponents ? 2 : 0) + (state.mapTokensEligible === true ? 1 : 0);
|
|
28432
|
+
const totalSteps = 3 + (hasTokenStage ? 1 : 0) + 2 + (state.mapTokensEligible === true ? 1 : 0);
|
|
28944
28433
|
const stepContent = (() => {
|
|
28945
28434
|
switch (state.step) {
|
|
28946
28435
|
case "checking-claude-auth":
|
|
@@ -28953,44 +28442,6 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
28953
28442
|
description: `Verifying ${state.agent} is installed and authenticated...`
|
|
28954
28443
|
}
|
|
28955
28444
|
);
|
|
28956
|
-
case "extracting": {
|
|
28957
|
-
const ep = state.extractProgress;
|
|
28958
|
-
const compositionComplete = state.compositionPhase === "done" || state.compositionPhase === "cache-hit";
|
|
28959
|
-
const tokenGenerationComplete = !state.rawTokensPath || state.tokenGenerationStatus === "complete";
|
|
28960
|
-
const extractionTasksComplete = ep !== null && ep.totalFiles > 0 && compositionComplete && state.selectionAgentStatus === "complete" && tokenGenerationComplete && state.existingEntitiesStatus !== "running";
|
|
28961
|
-
if (extractionTasksComplete) return null;
|
|
28962
|
-
let extractDetail;
|
|
28963
|
-
let extractComplete = false;
|
|
28964
|
-
if (ep && ep.totalFiles > 0) {
|
|
28965
|
-
extractDetail = `Scanned ${ep.scanned} file${ep.scanned === 1 ? "" : "s"}`;
|
|
28966
|
-
extractComplete = true;
|
|
28967
|
-
} else if (ep) {
|
|
28968
|
-
extractDetail = `Scanning ${ep.scanned} file${ep.scanned === 1 ? "" : "s"}`;
|
|
28969
|
-
} else {
|
|
28970
|
-
extractDetail = "Scanning files...";
|
|
28971
|
-
}
|
|
28972
|
-
const selectionDetail = state.selectionAgentStatus === "complete" ? "Selection agent complete" : `Filtering component selection via ${state.agent}...`;
|
|
28973
|
-
const compositionDetail = state.compositionPhase === "cache-hit" ? "Composition mapping (cached)" : compositionComplete ? "Composition mapping complete" : state.compositionPhase?.startsWith("agent:") ? `Mapping composition via ${state.compositionPhase.slice("agent:".length)}...` : `Mapping composition via ${state.agent}...`;
|
|
28974
|
-
return /* @__PURE__ */ jsx47(
|
|
28975
|
-
RunningStep,
|
|
28976
|
-
{
|
|
28977
|
-
stepNumber: hasTokenStage ? 2 : 1,
|
|
28978
|
-
totalSteps,
|
|
28979
|
-
title: "Extracting context",
|
|
28980
|
-
description: "Extracting context from your source files.",
|
|
28981
|
-
detail: extractDetail,
|
|
28982
|
-
detailComplete: extractComplete,
|
|
28983
|
-
secondaryDetail: compositionDetail,
|
|
28984
|
-
secondaryComplete: compositionComplete,
|
|
28985
|
-
tertiaryDetail: selectionDetail,
|
|
28986
|
-
tertiaryComplete: state.selectionAgentStatus === "complete",
|
|
28987
|
-
quaternaryDetail: state.existingEntitiesStatus === "running" ? "Fetching existing components and tokens..." : state.existingEntitiesStatus === "complete" ? "Existing components and tokens ready" : state.existingEntitiesStatus === "failed" ? "Existing entities unavailable; continuing without them" : void 0,
|
|
28988
|
-
quaternaryComplete: state.existingEntitiesStatus === "complete" || state.existingEntitiesStatus === "failed",
|
|
28989
|
-
quinaryDetail: state.rawTokensPath ? state.tokenGenerationStatus === "running" ? `Generating token definitions via ${state.agent}...` : state.tokenGenerationStatus === "complete" ? "Token definitions ready" : state.tokenGenerationStatus === "failed" ? "Token definition generation failed" : `Generating token definitions via ${state.agent}...` : void 0,
|
|
28990
|
-
quinaryComplete: state.tokenGenerationStatus === "complete"
|
|
28991
|
-
}
|
|
28992
|
-
);
|
|
28993
|
-
}
|
|
28994
28445
|
case "scope-gate": {
|
|
28995
28446
|
if (!state.extractSessionId) {
|
|
28996
28447
|
return /* @__PURE__ */ jsx47(Box38, { paddingX: 2, paddingY: 1, children: /* @__PURE__ */ jsx47(Text40, { color: PALETTE.error, children: "Error: extract session ID missing \u2014 please re-run." }) });
|
|
@@ -29276,9 +28727,7 @@ ${displayAgent} is mapping your selected components to Contentful's Component De
|
|
|
29276
28727
|
GateStep,
|
|
29277
28728
|
{
|
|
29278
28729
|
successMessage: "Files saved",
|
|
29279
|
-
summary: [
|
|
29280
|
-
(hasComponents || hasTokens) && state.componentsPath ? `components.json \u2192 ${state.componentsPath}` : null
|
|
29281
|
-
].filter(Boolean).join("\n"),
|
|
28730
|
+
summary: [state.componentsPath ? `components.json \u2192 ${state.componentsPath}` : null].filter(Boolean).join("\n"),
|
|
29282
28731
|
context: teaser ? `Your files are saved to disk. ${teaser}` : "Your files are saved to disk. Run `experiences import` again when you're ready to push to Contentful.",
|
|
29283
28732
|
continueLabel: "Exit",
|
|
29284
28733
|
showSkip: false,
|
|
@@ -29362,6 +28811,7 @@ var init_WizardApp = __esm({
|
|
|
29362
28811
|
init_CustomPromptBanner();
|
|
29363
28812
|
init_RunningStep();
|
|
29364
28813
|
init_GateStep();
|
|
28814
|
+
init_handoff();
|
|
29365
28815
|
init_WizardPreviewStep();
|
|
29366
28816
|
init_DoneStep();
|
|
29367
28817
|
init_ErrorStep();
|
|
@@ -29384,15 +28834,12 @@ var init_WizardApp = __esm({
|
|
|
29384
28834
|
init_runScopeGate();
|
|
29385
28835
|
init_src();
|
|
29386
28836
|
init_host_utils();
|
|
29387
|
-
init_fetch_and_persist_existing_contentful_entities();
|
|
29388
28837
|
init_wizard_state_transitions();
|
|
29389
28838
|
init_cli_path();
|
|
29390
|
-
init_prompt_overrides();
|
|
29391
|
-
init_run_selection_agent();
|
|
29392
28839
|
init_use_terminal_size();
|
|
29393
28840
|
init_render_with_goodbye();
|
|
29394
28841
|
SAVE_CONFIRMATION_DELAY_MS = 1e3;
|
|
29395
|
-
WIZARD_LOG =
|
|
28842
|
+
WIZARD_LOG = join19(tmpdir(), "experiences-import-wizard.log");
|
|
29396
28843
|
}
|
|
29397
28844
|
});
|
|
29398
28845
|
|
|
@@ -29523,7 +28970,7 @@ var init_agent_definitions = __esm({
|
|
|
29523
28970
|
});
|
|
29524
28971
|
|
|
29525
28972
|
// packages/experience-design-system-cli-legacy/src/setup/lib/shell.ts
|
|
29526
|
-
import { execFile as execFile3, spawn as
|
|
28973
|
+
import { execFile as execFile3, spawn as spawn5 } from "node:child_process";
|
|
29527
28974
|
import { access as access7 } from "node:fs/promises";
|
|
29528
28975
|
import { promisify as promisify2 } from "node:util";
|
|
29529
28976
|
async function binaryExists(name) {
|
|
@@ -29539,7 +28986,7 @@ async function pathExists3(path) {
|
|
|
29539
28986
|
}
|
|
29540
28987
|
function runSpawn(cmd, args, opts = {}) {
|
|
29541
28988
|
return new Promise((resolve22) => {
|
|
29542
|
-
const child =
|
|
28989
|
+
const child = spawn5(cmd, args, {
|
|
29543
28990
|
cwd: opts.cwd,
|
|
29544
28991
|
env: opts.env ?? process.env,
|
|
29545
28992
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -29572,7 +29019,7 @@ var init_shell = __esm({
|
|
|
29572
29019
|
});
|
|
29573
29020
|
|
|
29574
29021
|
// packages/experience-design-system-cli-legacy/src/setup/lib/checks.ts
|
|
29575
|
-
import { join as
|
|
29022
|
+
import { join as join20 } from "node:path";
|
|
29576
29023
|
function checkNodeVersion(nodeVersion = process.versions.node) {
|
|
29577
29024
|
const major = Number.parseInt(nodeVersion.split(".")[0], 10);
|
|
29578
29025
|
return {
|
|
@@ -29586,7 +29033,7 @@ async function detectNodeVersionManagers(homeDir, deps = {
|
|
|
29586
29033
|
binaryExists,
|
|
29587
29034
|
pathExists: pathExists3
|
|
29588
29035
|
}) {
|
|
29589
|
-
const nvmScript =
|
|
29036
|
+
const nvmScript = join20(homeDir, ".nvm", "nvm.sh");
|
|
29590
29037
|
return {
|
|
29591
29038
|
nvm: await deps.binaryExists("nvm") || await deps.pathExists(nvmScript),
|
|
29592
29039
|
fnm: await deps.binaryExists("fnm"),
|
|
@@ -29665,7 +29112,7 @@ var init_report = __esm({
|
|
|
29665
29112
|
|
|
29666
29113
|
// packages/experience-design-system-cli-legacy/src/doctor/checks.ts
|
|
29667
29114
|
import { homedir as homedir2 } from "node:os";
|
|
29668
|
-
import { join as
|
|
29115
|
+
import { join as join21 } from "node:path";
|
|
29669
29116
|
async function reportNode() {
|
|
29670
29117
|
section("Checking Node.js version");
|
|
29671
29118
|
const check = checkNodeVersion();
|
|
@@ -29716,12 +29163,12 @@ async function reportPnpm(pkgRoot) {
|
|
|
29716
29163
|
}
|
|
29717
29164
|
async function reportDependencies(pkgRoot) {
|
|
29718
29165
|
section("Checking dependencies (pnpm install)");
|
|
29719
|
-
if (!await pathExists3(
|
|
29166
|
+
if (!await pathExists3(join21(pkgRoot, "node_modules"))) {
|
|
29720
29167
|
info("node_modules not found \u2014 running pnpm install...");
|
|
29721
29168
|
} else {
|
|
29722
29169
|
info("Running pnpm install to ensure dependencies are up to date...");
|
|
29723
29170
|
}
|
|
29724
|
-
const check = await installDependencies(
|
|
29171
|
+
const check = await installDependencies(join21(pkgRoot, "..", ".."));
|
|
29725
29172
|
if (!check.passed) {
|
|
29726
29173
|
fail("pnpm install failed");
|
|
29727
29174
|
info("");
|
|
@@ -29738,7 +29185,7 @@ async function reportDependencies(pkgRoot) {
|
|
|
29738
29185
|
async function reportBuild(pkgRoot) {
|
|
29739
29186
|
section("Building CLI");
|
|
29740
29187
|
info("Running pnpm build...");
|
|
29741
|
-
const check = await buildCli(
|
|
29188
|
+
const check = await buildCli(join21(pkgRoot, "..", ".."));
|
|
29742
29189
|
if (!check.passed) {
|
|
29743
29190
|
fail("Build failed");
|
|
29744
29191
|
info("");
|
|
@@ -30957,9 +30404,9 @@ var init_SetupScreen = __esm({
|
|
|
30957
30404
|
|
|
30958
30405
|
// packages/experience-design-system-cli-legacy/src/setup/command.ts
|
|
30959
30406
|
import { readFileSync as readFileSync9 } from "node:fs";
|
|
30960
|
-
import { join as
|
|
30407
|
+
import { join as join22 } from "node:path";
|
|
30961
30408
|
function getCliVersion() {
|
|
30962
|
-
const pkg4 = JSON.parse(readFileSync9(
|
|
30409
|
+
const pkg4 = JSON.parse(readFileSync9(join22(findPkgRoot(), "package.json"), "utf8"));
|
|
30963
30410
|
return pkg4.version;
|
|
30964
30411
|
}
|
|
30965
30412
|
async function runSetup(opts) {
|
|
@@ -30971,7 +30418,7 @@ async function runSetup(opts) {
|
|
|
30971
30418
|
const { renderWithGoodbye: renderWithGoodbye2 } = await Promise.resolve().then(() => (init_render_with_goodbye(), render_with_goodbye_exports));
|
|
30972
30419
|
const { createElement: createElement6 } = await import("react");
|
|
30973
30420
|
const { SetupScreen: SetupScreen2 } = await Promise.resolve().then(() => (init_SetupScreen(), SetupScreen_exports));
|
|
30974
|
-
const repoRoot =
|
|
30421
|
+
const repoRoot = join22(findPkgRoot(), "..", "..");
|
|
30975
30422
|
const completion = { outcome: null };
|
|
30976
30423
|
let unmountInk = null;
|
|
30977
30424
|
const { waitUntilExit, unmount } = renderWithGoodbye2(
|
|
@@ -31173,14 +30620,14 @@ var init_apply_mapping = __esm({
|
|
|
31173
30620
|
|
|
31174
30621
|
// packages/experience-design-system-cli-legacy/src/analyze/composition/prompt-loader.ts
|
|
31175
30622
|
import { existsSync as existsSync10, readFileSync as readFileSync10 } from "node:fs";
|
|
31176
|
-
import { dirname as dirname18, join as
|
|
30623
|
+
import { dirname as dirname18, join as join23, resolve as resolve19 } from "node:path";
|
|
31177
30624
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
31178
30625
|
function resolvePromptPath(fileName) {
|
|
31179
30626
|
const thisDir = dirname18(fileURLToPath3(import.meta.url));
|
|
31180
30627
|
let dir = thisDir;
|
|
31181
30628
|
for (; ; ) {
|
|
31182
|
-
const candidate =
|
|
31183
|
-
if (existsSync10(candidate)) return
|
|
30629
|
+
const candidate = join23(dir, "prompts");
|
|
30630
|
+
if (existsSync10(candidate)) return join23(candidate, fileName);
|
|
31184
30631
|
const parent = resolve19(dir, "..");
|
|
31185
30632
|
if (parent === dir) {
|
|
31186
30633
|
throw new Error(
|
|
@@ -31448,7 +30895,7 @@ var init_manifest_doc_evidence = __esm({
|
|
|
31448
30895
|
|
|
31449
30896
|
// packages/experience-design-system-cli-legacy/src/analyze/extract-command.ts
|
|
31450
30897
|
import { mkdir as mkdir5, readdir as readdir3, readFile as readFile18, stat as stat5 } from "node:fs/promises";
|
|
31451
|
-
import { isAbsolute as isAbsolute2, join as
|
|
30898
|
+
import { isAbsolute as isAbsolute2, join as join24, relative as relative2, resolve as resolve20 } from "node:path";
|
|
31452
30899
|
function resolveExtractNoCache(opts) {
|
|
31453
30900
|
return opts.noCache === true || opts.cache === false;
|
|
31454
30901
|
}
|
|
@@ -31481,7 +30928,7 @@ async function collectSourceFiles(directory, onProgress) {
|
|
|
31481
30928
|
const entries = await readdir3(currentDirectory, { withFileTypes: true });
|
|
31482
30929
|
const subdirs = [];
|
|
31483
30930
|
for (const entry of entries) {
|
|
31484
|
-
const fullPath =
|
|
30931
|
+
const fullPath = join24(currentDirectory, entry.name);
|
|
31485
30932
|
if (entry.isDirectory()) {
|
|
31486
30933
|
if (!IGNORED_DIRECTORY_NAMES.has(entry.name)) {
|
|
31487
30934
|
subdirs.push(fullPath);
|
|
@@ -31565,7 +31012,7 @@ function registerInternalExtractCommand(program) {
|
|
|
31565
31012
|
}
|
|
31566
31013
|
}
|
|
31567
31014
|
const projectRoot = resolve20(opts.project);
|
|
31568
|
-
const outDir =
|
|
31015
|
+
const outDir = join24(projectRoot, ".contentful");
|
|
31569
31016
|
let sourceDirectory;
|
|
31570
31017
|
if (opts.dir !== void 0) {
|
|
31571
31018
|
sourceDirectory = resolveFromProjectRoot(projectRoot, opts.dir);
|
|
@@ -31928,9 +31375,9 @@ __export(program_exports, {
|
|
|
31928
31375
|
resolveBedrockFromAncestors: () => resolveBedrockFromAncestors,
|
|
31929
31376
|
runBuild: () => runBuild
|
|
31930
31377
|
});
|
|
31931
|
-
import { spawn as
|
|
31378
|
+
import { spawn as spawn6 } from "node:child_process";
|
|
31932
31379
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
31933
|
-
import { dirname as dirname20, join as
|
|
31380
|
+
import { dirname as dirname20, join as join25, resolve as resolve21 } from "node:path";
|
|
31934
31381
|
import { readFileSync as readFileSync11 } from "node:fs";
|
|
31935
31382
|
import { Command } from "commander";
|
|
31936
31383
|
async function runBuild(opts) {
|
|
@@ -31963,7 +31410,7 @@ function registerBuildCommand(program) {
|
|
|
31963
31410
|
const pkgRoot = resolve21(dirname20(fileURLToPath4(import.meta.url)), "..", "..");
|
|
31964
31411
|
process.stderr.write("\u2699 Building from source...\n");
|
|
31965
31412
|
const { exitCode } = await runBuild({
|
|
31966
|
-
spawnFn: () =>
|
|
31413
|
+
spawnFn: () => spawn6("pnpm", ["build"], { cwd: pkgRoot, stdio: "inherit" }),
|
|
31967
31414
|
stderrWrite: (s) => process.stderr.write(s)
|
|
31968
31415
|
});
|
|
31969
31416
|
process.exit(exitCode);
|
|
@@ -32030,7 +31477,7 @@ var init_program = __esm({
|
|
|
32030
31477
|
init_analytics();
|
|
32031
31478
|
init_credentials_store();
|
|
32032
31479
|
init_cli_path();
|
|
32033
|
-
pkg3 = JSON.parse(readFileSync11(
|
|
31480
|
+
pkg3 = JSON.parse(readFileSync11(join25(findPkgRoot(), "package.json"), "utf8"));
|
|
32034
31481
|
}
|
|
32035
31482
|
});
|
|
32036
31483
|
|