@contentful/experience-design-system-cli 2.35.1-dev-build-b8da2525.0 → 2.35.1-dev-build-e1cfef52.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/package.json +5 -1
- package/dist/src/tui/home/home.d.ts +1 -0
- package/dist/src/tui/home/home.theme.d.ts +11 -0
- package/legacy/dist/src/analyze/extract-command.d.ts +0 -4
- package/legacy/dist/src/import/tui/WizardApp.d.ts +1 -7
- package/legacy/dist/src/import/tui/run-selection-agent.d.ts +0 -1
- package/legacy/dist/src/import/tui/wizard-state-transitions.d.ts +0 -3
- package/legacy/dist/src/index.js +215 -1366
- package/legacy/dist/src/map-tokens/tui/MapTokensView.d.ts +0 -1
- package/legacy/dist/src/session/db.d.ts +2 -72
- package/legacy/package.json +5 -1
- package/legacy/skills/debate-select.md +23 -0
- package/package.json +7 -3
- package/legacy/dist/src/session/cache-keys.d.ts +0 -22
- package/legacy/dist/src/session/core/components/hash-component-shape.d.ts +0 -5
- package/legacy/dist/src/session/core/tokens/hash-token-content.d.ts +0 -1
package/legacy/dist/src/index.js
CHANGED
|
@@ -164,18 +164,11 @@ var init_render_with_goodbye = __esm({
|
|
|
164
164
|
function isAgentName(value) {
|
|
165
165
|
return AGENT_NAMES.includes(value);
|
|
166
166
|
}
|
|
167
|
-
var AGENT_NAMES,
|
|
167
|
+
var AGENT_NAMES, AGENT_BINARIES;
|
|
168
168
|
var init_agent_names = __esm({
|
|
169
169
|
"packages/experience-design-system-generation/dist/src/agent-names.js"() {
|
|
170
170
|
"use strict";
|
|
171
|
-
AGENT_NAMES = [
|
|
172
|
-
"claude",
|
|
173
|
-
"codex",
|
|
174
|
-
"opencode",
|
|
175
|
-
"cursor",
|
|
176
|
-
"copilot"
|
|
177
|
-
];
|
|
178
|
-
DEFAULT_AGENT_NAME = "claude";
|
|
171
|
+
AGENT_NAMES = ["claude", "codex", "opencode", "cursor", "copilot"];
|
|
179
172
|
AGENT_BINARIES = {
|
|
180
173
|
claude: "claude",
|
|
181
174
|
codex: "codex",
|
|
@@ -187,23 +180,6 @@ var init_agent_names = __esm({
|
|
|
187
180
|
});
|
|
188
181
|
|
|
189
182
|
// packages/experience-design-system-generation/dist/src/controller/helpers/validate-generation-request.js
|
|
190
|
-
function validateGenerationRequest(request2) {
|
|
191
|
-
if (request2 === null || typeof request2 !== "object") {
|
|
192
|
-
throw new TypeError("createGenerationEndpoint requires a request object");
|
|
193
|
-
}
|
|
194
|
-
if (!isAgentName(request2.agent)) {
|
|
195
|
-
throw new TypeError(`createGenerationEndpoint requires agent to be a valid agent name, got: ${String(request2.agent)}`);
|
|
196
|
-
}
|
|
197
|
-
if (typeof request2.timeoutMs !== "number" || request2.timeoutMs <= 0) {
|
|
198
|
-
throw new TypeError("createGenerationEndpoint requires timeoutMs to be a positive number");
|
|
199
|
-
}
|
|
200
|
-
if (request2.promptOptions === null || typeof request2.promptOptions !== "object") {
|
|
201
|
-
throw new TypeError("createGenerationEndpoint requires promptOptions to be an object");
|
|
202
|
-
}
|
|
203
|
-
if (request2.onOutput !== void 0 && typeof request2.onOutput !== "function") {
|
|
204
|
-
throw new TypeError("createGenerationEndpoint requires onOutput to be a function when provided");
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
183
|
var init_validate_generation_request = __esm({
|
|
208
184
|
"packages/experience-design-system-generation/dist/src/controller/helpers/validate-generation-request.js"() {
|
|
209
185
|
"use strict";
|
|
@@ -262,6 +238,7 @@ var init_resolve_skill_file = __esm({
|
|
|
262
238
|
components: "generate-components.md",
|
|
263
239
|
tokens: "generate-tokens.md",
|
|
264
240
|
select: "select-components.md",
|
|
241
|
+
"debate-select": "debate-select.md",
|
|
265
242
|
"map-tokens": "map-tokens.md"
|
|
266
243
|
};
|
|
267
244
|
}
|
|
@@ -523,6 +500,31 @@ Rules:
|
|
|
523
500
|
- Emit set_group calls before the set_token calls that fall under them.
|
|
524
501
|
- You may emit prose lines (not starting with {) anywhere \u2014 they are ignored by the parser and serve as your reasoning log.`;
|
|
525
502
|
}
|
|
503
|
+
function buildDebateSelectAutonomousPreamble(inputBlock, debateRole, disagreementInline) {
|
|
504
|
+
const role = debateRole ?? "for";
|
|
505
|
+
return [
|
|
506
|
+
"You are the " + role.toUpperCase() + " participant in an adversarial review of one component-selection disagreement. This is an automatic escalation stage; do not ask the developer for confirmation.",
|
|
507
|
+
"",
|
|
508
|
+
"Your role is to argue the " + role.toUpperCase() + " position on the exact disagreement below. Address the claim literally, cite the supplied component evidence, and do not substitute a nearby component or field. The opposing participant is evaluating the same evidence independently.",
|
|
509
|
+
"",
|
|
510
|
+
"Component and source data:" + inputBlock,
|
|
511
|
+
"",
|
|
512
|
+
"Disagreement under review (JSON):",
|
|
513
|
+
"~~~json",
|
|
514
|
+
disagreementInline ?? "{}",
|
|
515
|
+
"~~~",
|
|
516
|
+
"",
|
|
517
|
+
"## Output protocol",
|
|
518
|
+
"",
|
|
519
|
+
"Emit exactly one JSON object on one line and do not write files:",
|
|
520
|
+
"",
|
|
521
|
+
"~~~json",
|
|
522
|
+
'{"role":"' + role + '","disagreement_id":"<id>","argument":"<position and reasoning>","evidence":[{"source":"<path>","line":"<line-or-range>","quote":"<verbatim evidence>"}]}',
|
|
523
|
+
"~~~",
|
|
524
|
+
"",
|
|
525
|
+
"The role and disagreement_id must match the values in this prompt. Use an empty evidence array only when the supplied context contains no citable source evidence."
|
|
526
|
+
].join("\n");
|
|
527
|
+
}
|
|
526
528
|
var init_build_skill_preambles = __esm({
|
|
527
529
|
"packages/experience-design-system-generation/dist/src/services/prompts/helpers/build-skill-preambles.js"() {
|
|
528
530
|
"use strict";
|
|
@@ -531,7 +533,7 @@ var init_build_skill_preambles = __esm({
|
|
|
531
533
|
|
|
532
534
|
// packages/experience-design-system-generation/dist/src/services/prompts/helpers/build-preamble.js
|
|
533
535
|
function buildPreamble(options) {
|
|
534
|
-
const { skill, rawComponentsInline, propBucketsInline, rawTokensInline, rawTokensFilename, tokensInline, tokenMapInline, generatedCdf, tokenTree, componentSourceRefs, existingComponentsInline, existingTokensInline, componentAllowlistInline } = options;
|
|
536
|
+
const { skill, rawComponentsInline, propBucketsInline, rawTokensInline, rawTokensFilename, tokensInline, tokenMapInline, generatedCdf, tokenTree, componentSourceRefs, existingComponentsInline, existingTokensInline, componentAllowlistInline, debateRole, disagreementInline } = options;
|
|
535
537
|
const sections = [];
|
|
536
538
|
if (existingComponentsInline) {
|
|
537
539
|
sections.push(`Existing components in the target Contentful space (JSON) \u2014 use for alignment, not as a hard filter:
|
|
@@ -603,6 +605,8 @@ ${sections.join("\n\n")}` : "";
|
|
|
603
605
|
return buildComponentsAutonomousPreamble(inputBlock);
|
|
604
606
|
if (skill === "select")
|
|
605
607
|
return buildSelectAutonomousPreamble(inputBlock);
|
|
608
|
+
if (skill === "debate-select")
|
|
609
|
+
return buildDebateSelectAutonomousPreamble(inputBlock, debateRole, disagreementInline);
|
|
606
610
|
if (skill === "map-tokens")
|
|
607
611
|
return buildMapTokensAutonomousPreamble(inputBlock);
|
|
608
612
|
return buildTokensAutonomousPreamble(inputBlock);
|
|
@@ -636,17 +640,6 @@ var init_build_prompt = __esm({
|
|
|
636
640
|
});
|
|
637
641
|
|
|
638
642
|
// packages/experience-design-system-generation/dist/src/orchestrator/execute-generation-orchestrator.js
|
|
639
|
-
async function executeGenerationOrchestrator(request2) {
|
|
640
|
-
const prompt = await buildPrompt(request2.promptOptions);
|
|
641
|
-
return request2.invoker.invoke({
|
|
642
|
-
agent: request2.agent,
|
|
643
|
-
model: request2.model,
|
|
644
|
-
bedrock: request2.bedrock,
|
|
645
|
-
prompt,
|
|
646
|
-
timeoutMs: request2.timeoutMs,
|
|
647
|
-
onOutput: request2.onOutput
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
643
|
var init_execute_generation_orchestrator = __esm({
|
|
651
644
|
"packages/experience-design-system-generation/dist/src/orchestrator/execute-generation-orchestrator.js"() {
|
|
652
645
|
"use strict";
|
|
@@ -690,12 +683,7 @@ function resolveAgentModel(agent, explicit, bedrock = false) {
|
|
|
690
683
|
}
|
|
691
684
|
function codexBedrockConfigArgs() {
|
|
692
685
|
const region = process.env.AWS_REGION?.trim() || process.env.AWS_DEFAULT_REGION?.trim() || DEFAULT_CODEX_BEDROCK_REGION;
|
|
693
|
-
return [
|
|
694
|
-
"-c",
|
|
695
|
-
"model_provider=amazon-bedrock",
|
|
696
|
-
"-c",
|
|
697
|
-
`model_providers.amazon-bedrock.region=${region}`
|
|
698
|
-
];
|
|
686
|
+
return ["-c", "model_provider=amazon-bedrock", "-c", `model_providers.amazon-bedrock.region=${region}`];
|
|
699
687
|
}
|
|
700
688
|
function buildAgentArgs(agent, prompt, model, promptViaStdin = false, bedrock = false) {
|
|
701
689
|
const resolvedModel = resolveAgentModel(agent, model, bedrock);
|
|
@@ -706,13 +694,7 @@ function buildAgentArgs(agent, prompt, model, promptViaStdin = false, bedrock =
|
|
|
706
694
|
return ["--print", ...modelArg, ...promptArg];
|
|
707
695
|
case "codex": {
|
|
708
696
|
const bedrockArgs = bedrock ? codexBedrockConfigArgs() : [];
|
|
709
|
-
return [
|
|
710
|
-
"exec",
|
|
711
|
-
...bedrockArgs,
|
|
712
|
-
...modelArg,
|
|
713
|
-
"--dangerously-bypass-approvals-and-sandbox",
|
|
714
|
-
...promptArg
|
|
715
|
-
];
|
|
697
|
+
return ["exec", ...bedrockArgs, ...modelArg, "--dangerously-bypass-approvals-and-sandbox", ...promptArg];
|
|
716
698
|
}
|
|
717
699
|
case "opencode":
|
|
718
700
|
return ["run", ...modelArg, ...promptArg];
|
|
@@ -732,11 +714,7 @@ var init_build_agent_args = __esm({
|
|
|
732
714
|
BEDROCK_ENV_BY_AGENT = {
|
|
733
715
|
claude: { CLAUDE_CODE_USE_BEDROCK: "1" }
|
|
734
716
|
};
|
|
735
|
-
BEDROCK_CAPABLE_AGENTS = /* @__PURE__ */ new Set([
|
|
736
|
-
"claude",
|
|
737
|
-
"codex",
|
|
738
|
-
"opencode"
|
|
739
|
-
]);
|
|
717
|
+
BEDROCK_CAPABLE_AGENTS = /* @__PURE__ */ new Set(["claude", "codex", "opencode"]);
|
|
740
718
|
DEFAULT_CODEX_BEDROCK_REGION = "us-east-1";
|
|
741
719
|
DEFAULT_OPENCODE_MODEL = "claude-haiku-4-5";
|
|
742
720
|
DEFAULT_CODEX_BEDROCK_MODEL = "openai.gpt-5.6-luna";
|
|
@@ -762,22 +740,6 @@ var init_describe_agent_failure = __esm({
|
|
|
762
740
|
});
|
|
763
741
|
|
|
764
742
|
// packages/experience-design-system-generation/dist/src/services/agent/helpers/extract-sentinel-output.js
|
|
765
|
-
function extractSentinelOutput(stdout) {
|
|
766
|
-
const START = "<<<EDS_OUTPUT_START>>>";
|
|
767
|
-
const END = "<<<EDS_OUTPUT_END>>>";
|
|
768
|
-
const startIdx = stdout.indexOf(START);
|
|
769
|
-
const endIdx = stdout.indexOf(END);
|
|
770
|
-
if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx)
|
|
771
|
-
return null;
|
|
772
|
-
const secondStart = stdout.indexOf(START, startIdx + START.length);
|
|
773
|
-
if (secondStart !== -1 && secondStart < endIdx)
|
|
774
|
-
return "multiple";
|
|
775
|
-
const afterStart = stdout.indexOf(END, startIdx);
|
|
776
|
-
const secondEnd = stdout.indexOf(END, afterStart + END.length);
|
|
777
|
-
if (secondEnd !== -1)
|
|
778
|
-
return "multiple";
|
|
779
|
-
return stdout.slice(startIdx + START.length, endIdx).trim();
|
|
780
|
-
}
|
|
781
743
|
var init_extract_sentinel_output = __esm({
|
|
782
744
|
"packages/experience-design-system-generation/dist/src/services/agent/helpers/extract-sentinel-output.js"() {
|
|
783
745
|
"use strict";
|
|
@@ -802,7 +764,7 @@ async function runAgent(options) {
|
|
|
802
764
|
promptLen: prompt.length,
|
|
803
765
|
promptHead: prompt.slice(0, 500)
|
|
804
766
|
});
|
|
805
|
-
return new Promise((
|
|
767
|
+
return new Promise((resolve20) => {
|
|
806
768
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
|
|
807
769
|
const child = spawn(binary, args, {
|
|
808
770
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -851,7 +813,7 @@ async function runAgent(options) {
|
|
|
851
813
|
stderrLen: stderr.length,
|
|
852
814
|
stderrTail: stderr.slice(-1e3)
|
|
853
815
|
});
|
|
854
|
-
|
|
816
|
+
resolve20(result);
|
|
855
817
|
});
|
|
856
818
|
});
|
|
857
819
|
}
|
|
@@ -868,7 +830,7 @@ var init_run_agent = __esm({
|
|
|
868
830
|
// packages/experience-design-system-generation/dist/src/services/agent/helpers/check-claude-auth.js
|
|
869
831
|
import { spawn as spawn2 } from "node:child_process";
|
|
870
832
|
function checkClaudeAuth(binary) {
|
|
871
|
-
return new Promise((
|
|
833
|
+
return new Promise((resolve20) => {
|
|
872
834
|
const child = spawn2(binary, ["auth", "status", "--json"], {
|
|
873
835
|
stdio: ["ignore", "pipe", "pipe"]
|
|
874
836
|
});
|
|
@@ -878,7 +840,7 @@ function checkClaudeAuth(binary) {
|
|
|
878
840
|
if (!done) {
|
|
879
841
|
done = true;
|
|
880
842
|
child.kill("SIGTERM");
|
|
881
|
-
|
|
843
|
+
resolve20("unauthenticated");
|
|
882
844
|
}
|
|
883
845
|
}, 5e3);
|
|
884
846
|
child.stdout?.on("data", (chunk) => {
|
|
@@ -890,14 +852,14 @@ function checkClaudeAuth(binary) {
|
|
|
890
852
|
done = true;
|
|
891
853
|
clearTimeout(timer);
|
|
892
854
|
if (code !== 0) {
|
|
893
|
-
|
|
855
|
+
resolve20("unauthenticated");
|
|
894
856
|
return;
|
|
895
857
|
}
|
|
896
858
|
try {
|
|
897
859
|
const status = JSON.parse(stdout);
|
|
898
|
-
|
|
860
|
+
resolve20(status.loggedIn ? "ok" : "unauthenticated");
|
|
899
861
|
} catch {
|
|
900
|
-
|
|
862
|
+
resolve20("unauthenticated");
|
|
901
863
|
}
|
|
902
864
|
});
|
|
903
865
|
});
|
|
@@ -912,13 +874,13 @@ var init_check_claude_auth = __esm({
|
|
|
912
874
|
import { spawn as spawn3 } from "node:child_process";
|
|
913
875
|
async function checkAgentAuth(agent) {
|
|
914
876
|
const binary = resolveAgentBinary(agent);
|
|
915
|
-
const binaryExists2 = await new Promise((
|
|
877
|
+
const binaryExists2 = await new Promise((resolve20) => {
|
|
916
878
|
if (binary.startsWith("/")) {
|
|
917
|
-
import("node:fs/promises").then((fs2) => fs2.access(binary).then(() =>
|
|
879
|
+
import("node:fs/promises").then((fs2) => fs2.access(binary).then(() => resolve20(true), () => resolve20(false)));
|
|
918
880
|
return;
|
|
919
881
|
}
|
|
920
882
|
const child = spawn3(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
|
|
921
|
-
child.on("close", (code) =>
|
|
883
|
+
child.on("close", (code) => resolve20(code === 0));
|
|
922
884
|
});
|
|
923
885
|
if (!binaryExists2)
|
|
924
886
|
return "not-found";
|
|
@@ -955,20 +917,6 @@ var init_local_cli_agent_invoker = __esm({
|
|
|
955
917
|
});
|
|
956
918
|
|
|
957
919
|
// packages/experience-design-system-generation/dist/src/controller/create-generation-endpoint.js
|
|
958
|
-
function createGenerationEndpoint(options = {}) {
|
|
959
|
-
const invoker2 = createLocalCliAgentInvoker({
|
|
960
|
-
onDebugEvent: options.onDebugEvent
|
|
961
|
-
});
|
|
962
|
-
return {
|
|
963
|
-
async run(request2) {
|
|
964
|
-
validateGenerationRequest(request2);
|
|
965
|
-
return executeGenerationOrchestrator({ ...request2, invoker: invoker2 });
|
|
966
|
-
},
|
|
967
|
-
checkAuth(agent) {
|
|
968
|
-
return invoker2.checkAuth(agent);
|
|
969
|
-
}
|
|
970
|
-
};
|
|
971
|
-
}
|
|
972
920
|
var init_create_generation_endpoint = __esm({
|
|
973
921
|
"packages/experience-design-system-generation/dist/src/controller/create-generation-endpoint.js"() {
|
|
974
922
|
"use strict";
|
|
@@ -1128,20 +1076,8 @@ var init_parse_prop_tool_calls = __esm({
|
|
|
1128
1076
|
"packages/experience-design-system-generation/dist/src/services/parsing/parse-prop-tool-calls.js"() {
|
|
1129
1077
|
"use strict";
|
|
1130
1078
|
init_read_tool_call_objects();
|
|
1131
|
-
VALID_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1132
|
-
|
|
1133
|
-
"exclude_prop",
|
|
1134
|
-
"classify_component",
|
|
1135
|
-
"classify_slot"
|
|
1136
|
-
]);
|
|
1137
|
-
VALID_CDF_TYPES = /* @__PURE__ */ new Set([
|
|
1138
|
-
"string",
|
|
1139
|
-
"richtext",
|
|
1140
|
-
"media",
|
|
1141
|
-
"enum",
|
|
1142
|
-
"token",
|
|
1143
|
-
"boolean"
|
|
1144
|
-
]);
|
|
1079
|
+
VALID_TOOL_NAMES = /* @__PURE__ */ new Set(["classify_prop", "exclude_prop", "classify_component", "classify_slot"]);
|
|
1080
|
+
VALID_CDF_TYPES = /* @__PURE__ */ new Set(["string", "richtext", "media", "enum", "token", "boolean"]);
|
|
1145
1081
|
VALID_CATEGORIES = /* @__PURE__ */ new Set(["content", "design", "state"]);
|
|
1146
1082
|
}
|
|
1147
1083
|
});
|
|
@@ -1249,10 +1185,7 @@ var init_parse_select_tool_calls = __esm({
|
|
|
1249
1185
|
"use strict";
|
|
1250
1186
|
init_parse_selection_slot_evidence();
|
|
1251
1187
|
init_read_tool_call_objects();
|
|
1252
|
-
VALID_SELECT_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1253
|
-
"select_component",
|
|
1254
|
-
"reject_component"
|
|
1255
|
-
]);
|
|
1188
|
+
VALID_SELECT_TOOL_NAMES = /* @__PURE__ */ new Set(["select_component", "reject_component"]);
|
|
1256
1189
|
}
|
|
1257
1190
|
});
|
|
1258
1191
|
|
|
@@ -1368,32 +1301,6 @@ var init_progress = __esm({
|
|
|
1368
1301
|
});
|
|
1369
1302
|
|
|
1370
1303
|
// packages/experience-design-system-generation/dist/src/index.js
|
|
1371
|
-
var src_exports = {};
|
|
1372
|
-
__export(src_exports, {
|
|
1373
|
-
AGENT_BINARIES: () => AGENT_BINARIES,
|
|
1374
|
-
AGENT_NAMES: () => AGENT_NAMES,
|
|
1375
|
-
DEFAULT_AGENT_NAME: () => DEFAULT_AGENT_NAME,
|
|
1376
|
-
agentSupportsBedrock: () => agentSupportsBedrock,
|
|
1377
|
-
buildArgs: () => buildAgentArgs,
|
|
1378
|
-
buildPrompt: () => buildPrompt,
|
|
1379
|
-
checkAgentAuth: () => checkAgentAuth,
|
|
1380
|
-
createGenerationEndpoint: () => createGenerationEndpoint,
|
|
1381
|
-
createLocalCliAgentInvoker: () => createLocalCliAgentInvoker,
|
|
1382
|
-
describeAgentFailure: () => describeAgentFailure,
|
|
1383
|
-
executeGenerationOrchestrator: () => executeGenerationOrchestrator,
|
|
1384
|
-
extractSentinelOutput: () => extractSentinelOutput,
|
|
1385
|
-
formatCustomPromptBanner: () => formatCustomPromptBanner,
|
|
1386
|
-
formatGenerateProgressLine: () => formatGenerateProgressLine,
|
|
1387
|
-
isAgentName: () => isAgentName,
|
|
1388
|
-
parseMapTokenPropToolCallLines: () => parseMapTokenPropToolCallLines,
|
|
1389
|
-
parseSelectToolCallLines: () => parseSelectToolCallLines,
|
|
1390
|
-
parseTokenToolCallLines: () => parseTokenToolCallLines,
|
|
1391
|
-
parseToolCallLines: () => parsePropToolCallLines,
|
|
1392
|
-
resolveAgentModel: () => resolveAgentModel,
|
|
1393
|
-
resolveBinary: () => resolveAgentBinary,
|
|
1394
|
-
resolveSkillPath: () => resolveSkillPath,
|
|
1395
|
-
runAgent: () => runAgent
|
|
1396
|
-
});
|
|
1397
1304
|
var init_src = __esm({
|
|
1398
1305
|
"packages/experience-design-system-generation/dist/src/index.js"() {
|
|
1399
1306
|
"use strict";
|
|
@@ -10426,41 +10333,6 @@ var init_read3 = __esm({
|
|
|
10426
10333
|
}
|
|
10427
10334
|
});
|
|
10428
10335
|
|
|
10429
|
-
// packages/experience-design-system-cli-legacy/src/session/core/components/hash-component-shape.ts
|
|
10430
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
10431
|
-
function hashComponentShape(component) {
|
|
10432
|
-
const payload = {
|
|
10433
|
-
framework: component.framework,
|
|
10434
|
-
name: component.name,
|
|
10435
|
-
source: component.source,
|
|
10436
|
-
props: component.props.map((p) => ({
|
|
10437
|
-
name: p.name,
|
|
10438
|
-
type: p.type
|
|
10439
|
-
})),
|
|
10440
|
-
slots: component.slots.map((s) => ({
|
|
10441
|
-
name: s.name,
|
|
10442
|
-
isDefault: s.isDefault
|
|
10443
|
-
}))
|
|
10444
|
-
};
|
|
10445
|
-
return createHash2("sha256").update(JSON.stringify(payload)).digest("hex");
|
|
10446
|
-
}
|
|
10447
|
-
var init_hash_component_shape = __esm({
|
|
10448
|
-
"packages/experience-design-system-cli-legacy/src/session/core/components/hash-component-shape.ts"() {
|
|
10449
|
-
"use strict";
|
|
10450
|
-
}
|
|
10451
|
-
});
|
|
10452
|
-
|
|
10453
|
-
// packages/experience-design-system-cli-legacy/src/session/core/tokens/hash-token-content.ts
|
|
10454
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
10455
|
-
function hashTokenContent(rawTokenContent) {
|
|
10456
|
-
return createHash3("sha256").update(rawTokenContent.trim()).digest("hex");
|
|
10457
|
-
}
|
|
10458
|
-
var init_hash_token_content = __esm({
|
|
10459
|
-
"packages/experience-design-system-cli-legacy/src/session/core/tokens/hash-token-content.ts"() {
|
|
10460
|
-
"use strict";
|
|
10461
|
-
}
|
|
10462
|
-
});
|
|
10463
|
-
|
|
10464
10336
|
// packages/experience-design-system-cli-legacy/src/session/repositories/tokens/write.ts
|
|
10465
10337
|
function deleteRawTokensForSession(db, sessionId2) {
|
|
10466
10338
|
db.prepare("DELETE FROM raw_token_groups WHERE session_id = ?").run(sessionId2);
|
|
@@ -10624,47 +10496,17 @@ var init_replace_raw_prop_token_paths = __esm({
|
|
|
10624
10496
|
}
|
|
10625
10497
|
});
|
|
10626
10498
|
|
|
10627
|
-
// packages/experience-design-system-cli-legacy/src/session/cache-keys.ts
|
|
10628
|
-
var cache_keys_exports = {};
|
|
10629
|
-
__export(cache_keys_exports, {
|
|
10630
|
-
hashContent: () => hashContent,
|
|
10631
|
-
hashFile: () => hashFile,
|
|
10632
|
-
hashPromptForSkill: () => hashPromptForSkill
|
|
10633
|
-
});
|
|
10634
|
-
import { createHash as createHash4 } from "node:crypto";
|
|
10635
|
-
import { readFile as readFile7 } from "node:fs/promises";
|
|
10636
|
-
import { resolve as resolve8 } from "node:path";
|
|
10637
|
-
function hashContent(content) {
|
|
10638
|
-
return createHash4("sha256").update(content).digest("hex");
|
|
10639
|
-
}
|
|
10640
|
-
async function hashFile(filePath) {
|
|
10641
|
-
const content = await readFile7(filePath, "utf8");
|
|
10642
|
-
return hashContent(content);
|
|
10643
|
-
}
|
|
10644
|
-
async function hashPromptForSkill(skill, agent, model, skillPathOverride, extraInputs = [], skillContentOverride) {
|
|
10645
|
-
const promptHash = skillContentOverride ? hashContent(skillContentOverride) : skillPathOverride ? await hashFile(resolve8(skillPathOverride)) : await hashFile(resolveSkillPath(skill));
|
|
10646
|
-
const extraSegment = extraInputs.length > 0 ? `|${extraInputs.join("|")}` : "";
|
|
10647
|
-
return hashContent(`${promptHash}|${agent}|${model ?? ""}${extraSegment}`);
|
|
10648
|
-
}
|
|
10649
|
-
var init_cache_keys = __esm({
|
|
10650
|
-
"packages/experience-design-system-cli-legacy/src/session/cache-keys.ts"() {
|
|
10651
|
-
"use strict";
|
|
10652
|
-
init_src();
|
|
10653
|
-
}
|
|
10654
|
-
});
|
|
10655
|
-
|
|
10656
10499
|
// packages/experience-design-system-cli-legacy/src/session/db.ts
|
|
10657
10500
|
import { DatabaseSync } from "node:sqlite";
|
|
10658
10501
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync5 } from "node:fs";
|
|
10659
|
-
import { readFile as
|
|
10660
|
-
import { createHash as createHash5 } from "node:crypto";
|
|
10502
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
10661
10503
|
import { homedir as homedir3 } from "node:os";
|
|
10662
|
-
import { dirname as dirname14, resolve as
|
|
10504
|
+
import { dirname as dirname14, resolve as resolve8 } from "node:path";
|
|
10663
10505
|
function getPipelineDbPath() {
|
|
10664
10506
|
if (process.env.EDS_PIPELINE_DB_PATH) {
|
|
10665
|
-
return
|
|
10507
|
+
return resolve8(process.env.EDS_PIPELINE_DB_PATH);
|
|
10666
10508
|
}
|
|
10667
|
-
return
|
|
10509
|
+
return resolve8(homedir3(), ".contentful", "experience-design-system-cli", "pipeline.db");
|
|
10668
10510
|
}
|
|
10669
10511
|
function openPipelineDb(dbPath) {
|
|
10670
10512
|
const path = dbPath ?? getPipelineDbPath();
|
|
@@ -10799,134 +10641,8 @@ function applyDbMigrations(db) {
|
|
|
10799
10641
|
if (!rawSlotColsForRationale.some((c2) => c2.name === "rationale")) {
|
|
10800
10642
|
db.exec("ALTER TABLE raw_slots ADD COLUMN rationale TEXT");
|
|
10801
10643
|
}
|
|
10802
|
-
|
|
10803
|
-
|
|
10804
|
-
db.exec(`
|
|
10805
|
-
CREATE TABLE extract_cache (
|
|
10806
|
-
file_path TEXT NOT NULL,
|
|
10807
|
-
file_hash TEXT NOT NULL,
|
|
10808
|
-
cli_version TEXT NOT NULL,
|
|
10809
|
-
created_at TEXT NOT NULL,
|
|
10810
|
-
updated_at TEXT NOT NULL,
|
|
10811
|
-
components_json TEXT NOT NULL,
|
|
10812
|
-
PRIMARY KEY (file_hash, cli_version)
|
|
10813
|
-
);
|
|
10814
|
-
CREATE INDEX idx_extract_cache_file ON extract_cache(file_path);
|
|
10815
|
-
`);
|
|
10816
|
-
}
|
|
10817
|
-
const hasSelectCache = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='select_cache'`).all();
|
|
10818
|
-
if (hasSelectCache.length === 0) {
|
|
10819
|
-
db.exec(`
|
|
10820
|
-
CREATE TABLE select_cache (
|
|
10821
|
-
component_hash TEXT NOT NULL,
|
|
10822
|
-
prompt_hash TEXT NOT NULL,
|
|
10823
|
-
cli_version TEXT NOT NULL,
|
|
10824
|
-
decision TEXT NOT NULL CHECK (decision IN ('accepted','rejected')),
|
|
10825
|
-
reason TEXT,
|
|
10826
|
-
created_at TEXT NOT NULL,
|
|
10827
|
-
updated_at TEXT NOT NULL,
|
|
10828
|
-
PRIMARY KEY (component_hash, prompt_hash, cli_version)
|
|
10829
|
-
);
|
|
10830
|
-
`);
|
|
10831
|
-
}
|
|
10832
|
-
const tables = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='generation_cache'`).all();
|
|
10833
|
-
if (tables.length === 0) {
|
|
10834
|
-
db.exec(`
|
|
10835
|
-
CREATE TABLE generation_cache (
|
|
10836
|
-
input_hash TEXT NOT NULL,
|
|
10837
|
-
entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
|
|
10838
|
-
entity_id TEXT NOT NULL,
|
|
10839
|
-
source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
10840
|
-
human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
|
|
10841
|
-
created_at TEXT NOT NULL,
|
|
10842
|
-
updated_at TEXT NOT NULL,
|
|
10843
|
-
PRIMARY KEY (input_hash, entity_type, entity_id)
|
|
10844
|
-
);
|
|
10845
|
-
CREATE INDEX idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
|
|
10846
|
-
CREATE INDEX idx_generation_cache_session ON generation_cache(source_session_id);
|
|
10847
|
-
`);
|
|
10848
|
-
}
|
|
10849
|
-
const genCacheCols = db.prepare(`PRAGMA table_info(generation_cache)`).all();
|
|
10850
|
-
const hasPromptHash = genCacheCols.some((c2) => c2.name === "prompt_hash");
|
|
10851
|
-
const oldPkCols = genCacheCols.filter((c2) => c2.pk > 0).map((c2) => c2.name);
|
|
10852
|
-
const promptHashInPk = oldPkCols.includes("prompt_hash");
|
|
10853
|
-
if (!hasPromptHash) {
|
|
10854
|
-
db.exec(`ALTER TABLE generation_cache ADD COLUMN prompt_hash TEXT NOT NULL DEFAULT ''`);
|
|
10855
|
-
}
|
|
10856
|
-
if (!promptHashInPk) {
|
|
10857
|
-
db.exec("BEGIN");
|
|
10858
|
-
try {
|
|
10859
|
-
db.exec(`
|
|
10860
|
-
CREATE TABLE generation_cache__new (
|
|
10861
|
-
input_hash TEXT NOT NULL,
|
|
10862
|
-
entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
|
|
10863
|
-
entity_id TEXT NOT NULL,
|
|
10864
|
-
source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
10865
|
-
human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
|
|
10866
|
-
created_at TEXT NOT NULL,
|
|
10867
|
-
updated_at TEXT NOT NULL,
|
|
10868
|
-
prompt_hash TEXT NOT NULL DEFAULT '',
|
|
10869
|
-
PRIMARY KEY (input_hash, prompt_hash, entity_type, entity_id)
|
|
10870
|
-
);
|
|
10871
|
-
INSERT INTO generation_cache__new
|
|
10872
|
-
(input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash)
|
|
10873
|
-
SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
|
|
10874
|
-
FROM generation_cache;
|
|
10875
|
-
DROP TABLE generation_cache;
|
|
10876
|
-
ALTER TABLE generation_cache__new RENAME TO generation_cache;
|
|
10877
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
|
|
10878
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_session ON generation_cache(source_session_id);
|
|
10879
|
-
`);
|
|
10880
|
-
db.exec("COMMIT");
|
|
10881
|
-
} catch (e) {
|
|
10882
|
-
db.exec("ROLLBACK");
|
|
10883
|
-
throw e;
|
|
10884
|
-
}
|
|
10885
|
-
}
|
|
10886
|
-
const genCacheTableSql = db.prepare(`SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'generation_cache'`).get();
|
|
10887
|
-
const hasTokenMappingEntityType = genCacheTableSql?.sql.includes("'token_mapping'") ?? true;
|
|
10888
|
-
if (!hasTokenMappingEntityType) {
|
|
10889
|
-
db.exec("BEGIN");
|
|
10890
|
-
try {
|
|
10891
|
-
db.exec(`
|
|
10892
|
-
CREATE TABLE generation_cache__new2 (
|
|
10893
|
-
input_hash TEXT NOT NULL,
|
|
10894
|
-
entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
|
|
10895
|
-
entity_id TEXT NOT NULL,
|
|
10896
|
-
source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
10897
|
-
human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
|
|
10898
|
-
created_at TEXT NOT NULL,
|
|
10899
|
-
updated_at TEXT NOT NULL,
|
|
10900
|
-
prompt_hash TEXT NOT NULL DEFAULT '',
|
|
10901
|
-
PRIMARY KEY (input_hash, prompt_hash, entity_type, entity_id)
|
|
10902
|
-
);
|
|
10903
|
-
INSERT INTO generation_cache__new2
|
|
10904
|
-
(input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash)
|
|
10905
|
-
SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
|
|
10906
|
-
FROM generation_cache;
|
|
10907
|
-
DROP TABLE generation_cache;
|
|
10908
|
-
ALTER TABLE generation_cache__new2 RENAME TO generation_cache;
|
|
10909
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
|
|
10910
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_session ON generation_cache(source_session_id);
|
|
10911
|
-
`);
|
|
10912
|
-
db.exec("COMMIT");
|
|
10913
|
-
} catch (e) {
|
|
10914
|
-
db.exec("ROLLBACK");
|
|
10915
|
-
throw e;
|
|
10916
|
-
}
|
|
10917
|
-
}
|
|
10918
|
-
const hasCompositionCache = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='composition_cache'`).all();
|
|
10919
|
-
if (hasCompositionCache.length === 0) {
|
|
10920
|
-
db.exec(`
|
|
10921
|
-
CREATE TABLE composition_cache (
|
|
10922
|
-
input_hash TEXT NOT NULL,
|
|
10923
|
-
cli_version TEXT NOT NULL,
|
|
10924
|
-
agent_output TEXT NOT NULL,
|
|
10925
|
-
created_at TEXT NOT NULL,
|
|
10926
|
-
updated_at TEXT NOT NULL,
|
|
10927
|
-
PRIMARY KEY (input_hash, cli_version)
|
|
10928
|
-
);
|
|
10929
|
-
`);
|
|
10644
|
+
for (const table of REMOVED_CACHE_TABLES) {
|
|
10645
|
+
db.exec(`DROP TABLE IF EXISTS ${table}`);
|
|
10930
10646
|
}
|
|
10931
10647
|
}
|
|
10932
10648
|
function loadComponentReviewMetadata(db, sessionId2, componentName) {
|
|
@@ -11462,16 +11178,16 @@ function extractRelativeImportPaths(sourceText) {
|
|
|
11462
11178
|
return [...specifiers];
|
|
11463
11179
|
}
|
|
11464
11180
|
async function resolveRelativeImport(specifier, fromDir) {
|
|
11465
|
-
const basePath =
|
|
11181
|
+
const basePath = resolve8(fromDir, specifier);
|
|
11466
11182
|
const candidates = [
|
|
11467
11183
|
basePath,
|
|
11468
11184
|
...rewrittenSourcePaths(basePath),
|
|
11469
11185
|
...SIBLING_FILE_EXTENSIONS.map((ext) => `${basePath}${ext}`),
|
|
11470
|
-
...SIBLING_FILE_EXTENSIONS.map((ext) =>
|
|
11186
|
+
...SIBLING_FILE_EXTENSIONS.map((ext) => resolve8(basePath, `index${ext}`))
|
|
11471
11187
|
];
|
|
11472
11188
|
for (const candidate of candidates) {
|
|
11473
11189
|
try {
|
|
11474
|
-
await
|
|
11190
|
+
await readFile7(candidate, "utf8");
|
|
11475
11191
|
return candidate;
|
|
11476
11192
|
} catch {
|
|
11477
11193
|
}
|
|
@@ -11487,7 +11203,7 @@ async function resolveImportSpecifiers(sourceText, fromDir) {
|
|
|
11487
11203
|
return resolvedPaths;
|
|
11488
11204
|
}
|
|
11489
11205
|
async function loadSiblingFiles(sourceText, sourcePath, propNames, candidateTypeNames = []) {
|
|
11490
|
-
const visited = /* @__PURE__ */ new Set([
|
|
11206
|
+
const visited = /* @__PURE__ */ new Set([resolve8(sourcePath)]);
|
|
11491
11207
|
const discovered = [];
|
|
11492
11208
|
let frontier = [{ text: sourceText, dir: dirname14(sourcePath) }];
|
|
11493
11209
|
for (let hop = 0; hop < MAX_SIBLING_DEPTH && discovered.length < MAX_SIBLING_CANDIDATES_EXPLORED; hop++) {
|
|
@@ -11501,7 +11217,7 @@ async function loadSiblingFiles(sourceText, sourcePath, propNames, candidateType
|
|
|
11501
11217
|
if (discovered.length >= MAX_SIBLING_CANDIDATES_EXPLORED) break;
|
|
11502
11218
|
let content;
|
|
11503
11219
|
try {
|
|
11504
|
-
content = await
|
|
11220
|
+
content = await readFile7(resolvedPath, "utf8");
|
|
11505
11221
|
} catch {
|
|
11506
11222
|
continue;
|
|
11507
11223
|
}
|
|
@@ -11538,7 +11254,7 @@ async function loadComponentSourceRef(name, sourcePath, propNames = [], propType
|
|
|
11538
11254
|
let truncatedSiblingCount = 0;
|
|
11539
11255
|
const usesNotShown = /* @__PURE__ */ new Set();
|
|
11540
11256
|
try {
|
|
11541
|
-
const rawText = await
|
|
11257
|
+
const rawText = await readFile7(sourcePath, "utf8");
|
|
11542
11258
|
let siblingUsesNotShown;
|
|
11543
11259
|
let declaredTypeNames;
|
|
11544
11260
|
({
|
|
@@ -11974,108 +11690,6 @@ function backfillUnclassifiedProps(db, sessionId2) {
|
|
|
11974
11690
|
).run(sessionId2, sessionId2);
|
|
11975
11691
|
return Number(withCategory.changes) + Number(withoutCategory.changes);
|
|
11976
11692
|
}
|
|
11977
|
-
function computeMapTokensInputHash(db, sessionId2, componentSourceRefs = []) {
|
|
11978
|
-
const props = db.prepare(
|
|
11979
|
-
`SELECT rc.name AS component_name, rp.name AS prop_name, rp.cdf_token_kind, rp.default_value
|
|
11980
|
-
FROM raw_props rp
|
|
11981
|
-
JOIN raw_components rc ON rc.session_id = rp.session_id AND rc.component_id = rp.component_id
|
|
11982
|
-
WHERE rp.session_id = ? AND rp.cdf_type = 'token' AND rp.cdf_category = 'design'
|
|
11983
|
-
ORDER BY rc.name, rp.name`
|
|
11984
|
-
).all(sessionId2);
|
|
11985
|
-
const tokens = db.prepare(`SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path`).all(sessionId2);
|
|
11986
|
-
const defaultMappings = db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId2);
|
|
11987
|
-
const payload = {
|
|
11988
|
-
props: props.map((p) => ({
|
|
11989
|
-
component: p.component_name,
|
|
11990
|
-
prop: p.prop_name,
|
|
11991
|
-
tokenKind: p.cdf_token_kind,
|
|
11992
|
-
rawDefault: p.default_value
|
|
11993
|
-
})),
|
|
11994
|
-
tokens,
|
|
11995
|
-
defaultMappings,
|
|
11996
|
-
// The agent's evidence, not just its inputs: a comment or allowlist edit
|
|
11997
|
-
// in a source file (or a sibling it reads) changes the correct answer
|
|
11998
|
-
// without touching props or tokens, so it must invalidate the cache too.
|
|
11999
|
-
sourceRefs: [...componentSourceRefs].sort((a, b) => a.component.localeCompare(b.component)).map((ref) => ({
|
|
12000
|
-
component: ref.component,
|
|
12001
|
-
content: ref.content,
|
|
12002
|
-
siblingFiles: (ref.siblingFiles ?? []).map((s) => ({ path: s.path, content: s.content })).sort((a, b) => a.path.localeCompare(b.path)),
|
|
12003
|
-
usesNotShown: [...ref.usesNotShown ?? []].sort()
|
|
12004
|
-
}))
|
|
12005
|
-
};
|
|
12006
|
-
return createHash5("sha256").update(JSON.stringify(payload)).digest("hex");
|
|
12007
|
-
}
|
|
12008
|
-
function lookupCache(db, inputHash, entityType, entityId, promptHash = "") {
|
|
12009
|
-
const row = db.prepare(
|
|
12010
|
-
`SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
|
|
12011
|
-
FROM generation_cache
|
|
12012
|
-
WHERE input_hash = ? AND entity_type = ? AND entity_id = ? AND prompt_hash = ?`
|
|
12013
|
-
).get(inputHash, entityType, entityId, promptHash);
|
|
12014
|
-
if (!row) return null;
|
|
12015
|
-
return {
|
|
12016
|
-
inputHash: row.input_hash,
|
|
12017
|
-
entityType: row.entity_type,
|
|
12018
|
-
entityId: row.entity_id,
|
|
12019
|
-
sourceSessionId: row.source_session_id,
|
|
12020
|
-
humanEdited: row.human_edited === 1,
|
|
12021
|
-
promptHash: row.prompt_hash,
|
|
12022
|
-
createdAt: row.created_at,
|
|
12023
|
-
updatedAt: row.updated_at
|
|
12024
|
-
};
|
|
12025
|
-
}
|
|
12026
|
-
function lookupCacheByEntity(db, entityType, entityId) {
|
|
12027
|
-
const row = db.prepare(
|
|
12028
|
-
`SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
|
|
12029
|
-
FROM generation_cache
|
|
12030
|
-
WHERE entity_type = ? AND entity_id = ?
|
|
12031
|
-
ORDER BY updated_at DESC LIMIT 1`
|
|
12032
|
-
).get(entityType, entityId);
|
|
12033
|
-
if (!row) return null;
|
|
12034
|
-
return {
|
|
12035
|
-
inputHash: row.input_hash,
|
|
12036
|
-
entityType: row.entity_type,
|
|
12037
|
-
entityId: row.entity_id,
|
|
12038
|
-
sourceSessionId: row.source_session_id,
|
|
12039
|
-
humanEdited: row.human_edited === 1,
|
|
12040
|
-
promptHash: row.prompt_hash,
|
|
12041
|
-
createdAt: row.created_at,
|
|
12042
|
-
updatedAt: row.updated_at
|
|
12043
|
-
};
|
|
12044
|
-
}
|
|
12045
|
-
function storeCache(db, inputHash, entityType, entityId, sourceSessionId, humanEdited, promptHash = "") {
|
|
12046
|
-
storeCaches(db, [{ inputHash, entityType, entityId, sourceSessionId, humanEdited, promptHash }]);
|
|
12047
|
-
}
|
|
12048
|
-
function storeCaches(db, entries) {
|
|
12049
|
-
if (entries.length === 0) return;
|
|
12050
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12051
|
-
const insert = db.prepare(
|
|
12052
|
-
`INSERT INTO generation_cache (input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash)
|
|
12053
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
12054
|
-
ON CONFLICT(input_hash, prompt_hash, entity_type, entity_id) DO UPDATE SET
|
|
12055
|
-
source_session_id = excluded.source_session_id,
|
|
12056
|
-
human_edited = CASE WHEN generation_cache.human_edited = 1 THEN 1 ELSE excluded.human_edited END,
|
|
12057
|
-
updated_at = excluded.updated_at`
|
|
12058
|
-
);
|
|
12059
|
-
db.exec("BEGIN");
|
|
12060
|
-
try {
|
|
12061
|
-
for (const entry of entries) {
|
|
12062
|
-
insert.run(
|
|
12063
|
-
entry.inputHash,
|
|
12064
|
-
entry.entityType,
|
|
12065
|
-
entry.entityId,
|
|
12066
|
-
entry.sourceSessionId,
|
|
12067
|
-
entry.humanEdited ? 1 : 0,
|
|
12068
|
-
now,
|
|
12069
|
-
now,
|
|
12070
|
-
entry.promptHash ?? ""
|
|
12071
|
-
);
|
|
12072
|
-
}
|
|
12073
|
-
db.exec("COMMIT");
|
|
12074
|
-
} catch (e) {
|
|
12075
|
-
db.exec("ROLLBACK");
|
|
12076
|
-
throw e;
|
|
12077
|
-
}
|
|
12078
|
-
}
|
|
12079
11693
|
function storeScannedFiles(db, sessionId2, filePaths) {
|
|
12080
11694
|
db.exec("BEGIN");
|
|
12081
11695
|
try {
|
|
@@ -12158,105 +11772,7 @@ function filterUnknownSlotAllowedComponents(db, sessionId2, allowedComponentName
|
|
|
12158
11772
|
}
|
|
12159
11773
|
return unknown;
|
|
12160
11774
|
}
|
|
12161
|
-
function
|
|
12162
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12163
|
-
if (manageTransaction) db.exec("BEGIN");
|
|
12164
|
-
try {
|
|
12165
|
-
const srcComp = db.prepare(
|
|
12166
|
-
`SELECT description, status, component_description_rationale, props_rationale, slots_rationale
|
|
12167
|
-
FROM raw_components WHERE session_id = ? AND component_id = ?`
|
|
12168
|
-
).get(sourceSessionId, componentId);
|
|
12169
|
-
if (srcComp) {
|
|
12170
|
-
db.prepare(
|
|
12171
|
-
`UPDATE raw_components
|
|
12172
|
-
SET description = ?, status = ?, component_description_rationale = ?, props_rationale = ?, slots_rationale = ?, extracted_at = ?
|
|
12173
|
-
WHERE session_id = ? AND component_id = ?`
|
|
12174
|
-
).run(
|
|
12175
|
-
srcComp.description,
|
|
12176
|
-
srcComp.status,
|
|
12177
|
-
srcComp.component_description_rationale,
|
|
12178
|
-
srcComp.props_rationale,
|
|
12179
|
-
srcComp.slots_rationale,
|
|
12180
|
-
now,
|
|
12181
|
-
targetSessionId,
|
|
12182
|
-
componentId
|
|
12183
|
-
);
|
|
12184
|
-
}
|
|
12185
|
-
const srcProps = db.prepare(
|
|
12186
|
-
`SELECT name, cdf_type, cdf_category, cdf_token_kind, required, description, default_value, rationale
|
|
12187
|
-
FROM raw_props WHERE session_id = ? AND component_id = ?`
|
|
12188
|
-
).all(sourceSessionId, componentId);
|
|
12189
|
-
for (const p of srcProps) {
|
|
12190
|
-
db.prepare(
|
|
12191
|
-
`UPDATE raw_props SET cdf_type = ?, cdf_category = ?, cdf_token_kind = ?, required = ?, description = ?, default_value = ?, rationale = ?
|
|
12192
|
-
WHERE session_id = ? AND component_id = ? AND name = ?`
|
|
12193
|
-
).run(
|
|
12194
|
-
p.cdf_type,
|
|
12195
|
-
p.cdf_category,
|
|
12196
|
-
p.cdf_token_kind,
|
|
12197
|
-
p.required,
|
|
12198
|
-
p.description,
|
|
12199
|
-
p.default_value,
|
|
12200
|
-
p.rationale,
|
|
12201
|
-
targetSessionId,
|
|
12202
|
-
componentId,
|
|
12203
|
-
p.name
|
|
12204
|
-
);
|
|
12205
|
-
}
|
|
12206
|
-
db.prepare(`DELETE FROM raw_prop_allowed_values WHERE session_id = ? AND component_id = ?`).run(
|
|
12207
|
-
targetSessionId,
|
|
12208
|
-
componentId
|
|
12209
|
-
);
|
|
12210
|
-
const srcAV = db.prepare(
|
|
12211
|
-
`SELECT prop_name, position, value FROM raw_prop_allowed_values WHERE session_id = ? AND component_id = ?`
|
|
12212
|
-
).all(sourceSessionId, componentId);
|
|
12213
|
-
const insertAV = db.prepare(
|
|
12214
|
-
`INSERT INTO raw_prop_allowed_values (session_id, component_id, prop_name, position, value) VALUES (?, ?, ?, ?, ?)`
|
|
12215
|
-
);
|
|
12216
|
-
for (const av of srcAV) {
|
|
12217
|
-
insertAV.run(targetSessionId, componentId, av.prop_name, av.position, av.value);
|
|
12218
|
-
}
|
|
12219
|
-
const srcSlots = db.prepare(`SELECT name, required, description, rationale FROM raw_slots WHERE session_id = ? AND component_id = ?`).all(sourceSessionId, componentId);
|
|
12220
|
-
for (const s of srcSlots) {
|
|
12221
|
-
db.prepare(
|
|
12222
|
-
`UPDATE raw_slots SET required = ?, description = ?, rationale = ? WHERE session_id = ? AND component_id = ? AND name = ?`
|
|
12223
|
-
).run(s.required, s.description, s.rationale, targetSessionId, componentId, s.name);
|
|
12224
|
-
}
|
|
12225
|
-
db.prepare(`DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ?`).run(
|
|
12226
|
-
targetSessionId,
|
|
12227
|
-
componentId
|
|
12228
|
-
);
|
|
12229
|
-
const srcSAC = db.prepare(
|
|
12230
|
-
`SELECT slot_name, position, allowed_component FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ?`
|
|
12231
|
-
).all(sourceSessionId, componentId);
|
|
12232
|
-
const insertSAC = db.prepare(
|
|
12233
|
-
`INSERT INTO raw_slot_allowed_components (session_id, component_id, slot_name, allowed_component, position) VALUES (?, ?, ?, ?, ?)`
|
|
12234
|
-
);
|
|
12235
|
-
const allowedSAC = options.allowedComponentNames ? srcSAC.filter((sac) => options.allowedComponentNames.has(sac.allowed_component)) : srcSAC;
|
|
12236
|
-
for (const sac of allowedSAC) {
|
|
12237
|
-
insertSAC.run(targetSessionId, componentId, sac.slot_name, sac.allowed_component, sac.position);
|
|
12238
|
-
}
|
|
12239
|
-
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, targetSessionId);
|
|
12240
|
-
if (manageTransaction) db.exec("COMMIT");
|
|
12241
|
-
} catch (e) {
|
|
12242
|
-
if (manageTransaction) db.exec("ROLLBACK");
|
|
12243
|
-
throw e;
|
|
12244
|
-
}
|
|
12245
|
-
}
|
|
12246
|
-
function copyComponentsFromCache(db, entries, options = {}) {
|
|
12247
|
-
if (entries.length === 0) return;
|
|
12248
|
-
db.exec("BEGIN");
|
|
12249
|
-
try {
|
|
12250
|
-
for (const entry of entries) {
|
|
12251
|
-
copyComponentFromCache(db, entry.sourceSessionId, entry.targetSessionId, entry.componentId, false, options);
|
|
12252
|
-
}
|
|
12253
|
-
db.exec("COMMIT");
|
|
12254
|
-
} catch (e) {
|
|
12255
|
-
db.exec("ROLLBACK");
|
|
12256
|
-
throw e;
|
|
12257
|
-
}
|
|
12258
|
-
}
|
|
12259
|
-
function copyTokensFromCache(db, sourceSessionId, targetSessionId) {
|
|
11775
|
+
function copyTokensBetweenSessions(db, sourceSessionId, targetSessionId) {
|
|
12260
11776
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12261
11777
|
db.exec("BEGIN");
|
|
12262
11778
|
try {
|
|
@@ -12277,139 +11793,7 @@ function copyTokensFromCache(db, sourceSessionId, targetSessionId) {
|
|
|
12277
11793
|
throw e;
|
|
12278
11794
|
}
|
|
12279
11795
|
}
|
|
12280
|
-
|
|
12281
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12282
|
-
let copiedCount = 0;
|
|
12283
|
-
db.exec("BEGIN");
|
|
12284
|
-
try {
|
|
12285
|
-
const sourceRows = db.prepare(
|
|
12286
|
-
`SELECT rc.name AS component_name, rptp.prop_name, rptp.source, rptp.position, rptp.path
|
|
12287
|
-
FROM raw_prop_token_paths rptp
|
|
12288
|
-
JOIN raw_components rc ON rc.session_id = rptp.session_id AND rc.component_id = rptp.component_id
|
|
12289
|
-
WHERE rptp.session_id = ?
|
|
12290
|
-
ORDER BY rc.name, rptp.prop_name, rptp.position`
|
|
12291
|
-
).all(sourceSessionId);
|
|
12292
|
-
const targetComponents = db.prepare(`SELECT component_id, name FROM raw_components WHERE session_id = ?`).all(targetSessionId);
|
|
12293
|
-
const targetIdByName = new Map(targetComponents.map((c2) => [c2.name, c2.component_id]));
|
|
12294
|
-
const targetProps = new Set(
|
|
12295
|
-
db.prepare(`SELECT component_id, name FROM raw_props WHERE session_id = ?`).all(targetSessionId).map((p) => `${p.component_id}::${p.name}`)
|
|
12296
|
-
);
|
|
12297
|
-
const insertPath = db.prepare(
|
|
12298
|
-
`INSERT INTO raw_prop_token_paths (session_id, component_id, prop_name, source, position, path)
|
|
12299
|
-
VALUES (?, ?, ?, ?, ?, ?)`
|
|
12300
|
-
);
|
|
12301
|
-
const clearedProps = /* @__PURE__ */ new Set();
|
|
12302
|
-
const copiedProps = /* @__PURE__ */ new Set();
|
|
12303
|
-
for (const row of sourceRows) {
|
|
12304
|
-
const targetComponentId = targetIdByName.get(row.component_name);
|
|
12305
|
-
if (!targetComponentId) continue;
|
|
12306
|
-
if (!targetProps.has(`${targetComponentId}::${row.prop_name}`)) continue;
|
|
12307
|
-
const propKey = `${targetComponentId}::${row.prop_name}`;
|
|
12308
|
-
if (!clearedProps.has(propKey)) {
|
|
12309
|
-
clearedProps.add(propKey);
|
|
12310
|
-
db.prepare(`DELETE FROM raw_prop_token_paths WHERE session_id = ? AND component_id = ? AND prop_name = ?`).run(
|
|
12311
|
-
targetSessionId,
|
|
12312
|
-
targetComponentId,
|
|
12313
|
-
row.prop_name
|
|
12314
|
-
);
|
|
12315
|
-
}
|
|
12316
|
-
insertPath.run(targetSessionId, targetComponentId, row.prop_name, row.source, row.position, row.path);
|
|
12317
|
-
copiedProps.add(propKey);
|
|
12318
|
-
}
|
|
12319
|
-
copiedCount = copiedProps.size;
|
|
12320
|
-
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, targetSessionId);
|
|
12321
|
-
db.exec("COMMIT");
|
|
12322
|
-
} catch (e) {
|
|
12323
|
-
db.exec("ROLLBACK");
|
|
12324
|
-
throw e;
|
|
12325
|
-
}
|
|
12326
|
-
return copiedCount;
|
|
12327
|
-
}
|
|
12328
|
-
async function getCliCacheVersion() {
|
|
12329
|
-
if (_cliCacheVersionCache) return _cliCacheVersionCache;
|
|
12330
|
-
try {
|
|
12331
|
-
const { hashContent: hashContent2 } = await Promise.resolve().then(() => (init_cache_keys(), cache_keys_exports));
|
|
12332
|
-
const { resolveSkillPath: resolveSkillPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
12333
|
-
const skills = ["components", "tokens", "select"];
|
|
12334
|
-
const parts = [];
|
|
12335
|
-
for (const s of skills) {
|
|
12336
|
-
try {
|
|
12337
|
-
const p = resolveSkillPath2(s);
|
|
12338
|
-
parts.push(readFileSync5(p, "utf8"));
|
|
12339
|
-
} catch {
|
|
12340
|
-
parts.push(`<missing:${s}>`);
|
|
12341
|
-
}
|
|
12342
|
-
}
|
|
12343
|
-
_cliCacheVersionCache = hashContent2(parts.join("\n---\n"));
|
|
12344
|
-
return _cliCacheVersionCache;
|
|
12345
|
-
} catch {
|
|
12346
|
-
_cliCacheVersionCache = "fallback";
|
|
12347
|
-
return _cliCacheVersionCache;
|
|
12348
|
-
}
|
|
12349
|
-
}
|
|
12350
|
-
function storeExtractCache(db, filePath, fileHash, cliVersion2, components) {
|
|
12351
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12352
|
-
const componentsJson = JSON.stringify(components);
|
|
12353
|
-
db.prepare(
|
|
12354
|
-
`INSERT INTO extract_cache (file_path, file_hash, cli_version, created_at, updated_at, components_json)
|
|
12355
|
-
VALUES (?, ?, ?, ?, ?, ?)
|
|
12356
|
-
ON CONFLICT(file_hash, cli_version) DO UPDATE SET
|
|
12357
|
-
file_path = excluded.file_path,
|
|
12358
|
-
updated_at = excluded.updated_at,
|
|
12359
|
-
components_json = excluded.components_json`
|
|
12360
|
-
).run(filePath, fileHash, cliVersion2, now, now, componentsJson);
|
|
12361
|
-
}
|
|
12362
|
-
function lookupExtractCache(db, fileHash, cliVersion2) {
|
|
12363
|
-
const row = db.prepare(
|
|
12364
|
-
`SELECT file_path, file_hash, cli_version, created_at, updated_at, components_json
|
|
12365
|
-
FROM extract_cache
|
|
12366
|
-
WHERE file_hash = ? AND cli_version = ?`
|
|
12367
|
-
).get(fileHash, cliVersion2);
|
|
12368
|
-
if (!row) return null;
|
|
12369
|
-
let components = [];
|
|
12370
|
-
try {
|
|
12371
|
-
components = JSON.parse(row.components_json);
|
|
12372
|
-
} catch {
|
|
12373
|
-
return null;
|
|
12374
|
-
}
|
|
12375
|
-
return {
|
|
12376
|
-
filePath: row.file_path,
|
|
12377
|
-
fileHash: row.file_hash,
|
|
12378
|
-
cliVersion: row.cli_version,
|
|
12379
|
-
createdAt: row.created_at,
|
|
12380
|
-
updatedAt: row.updated_at,
|
|
12381
|
-
components
|
|
12382
|
-
};
|
|
12383
|
-
}
|
|
12384
|
-
function storeSelectCache(db, componentHash, promptHash, cliVersion2, decision, reason) {
|
|
12385
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12386
|
-
db.prepare(
|
|
12387
|
-
`INSERT INTO select_cache (component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at)
|
|
12388
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
12389
|
-
ON CONFLICT(component_hash, prompt_hash, cli_version) DO UPDATE SET
|
|
12390
|
-
decision = excluded.decision,
|
|
12391
|
-
reason = excluded.reason,
|
|
12392
|
-
updated_at = excluded.updated_at`
|
|
12393
|
-
).run(componentHash, promptHash, cliVersion2, decision, reason, now, now);
|
|
12394
|
-
}
|
|
12395
|
-
function lookupSelectCache(db, componentHash, promptHash, cliVersion2) {
|
|
12396
|
-
const row = db.prepare(
|
|
12397
|
-
`SELECT component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at
|
|
12398
|
-
FROM select_cache
|
|
12399
|
-
WHERE component_hash = ? AND prompt_hash = ? AND cli_version = ?`
|
|
12400
|
-
).get(componentHash, promptHash, cliVersion2);
|
|
12401
|
-
if (!row) return null;
|
|
12402
|
-
return {
|
|
12403
|
-
componentHash: row.component_hash,
|
|
12404
|
-
promptHash: row.prompt_hash,
|
|
12405
|
-
cliVersion: row.cli_version,
|
|
12406
|
-
decision: row.decision,
|
|
12407
|
-
reason: row.reason,
|
|
12408
|
-
createdAt: row.created_at,
|
|
12409
|
-
updatedAt: row.updated_at
|
|
12410
|
-
};
|
|
12411
|
-
}
|
|
12412
|
-
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;
|
|
11796
|
+
var SCHEMA, REMOVED_CACHE_TABLES, 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;
|
|
12413
11797
|
var init_db = __esm({
|
|
12414
11798
|
"packages/experience-design-system-cli-legacy/src/session/db.ts"() {
|
|
12415
11799
|
"use strict";
|
|
@@ -12423,8 +11807,6 @@ var init_db = __esm({
|
|
|
12423
11807
|
init_write2();
|
|
12424
11808
|
init_session_resolver();
|
|
12425
11809
|
init_read3();
|
|
12426
|
-
init_hash_component_shape();
|
|
12427
|
-
init_hash_token_content();
|
|
12428
11810
|
init_read3();
|
|
12429
11811
|
init_store_dtcg_tokens();
|
|
12430
11812
|
init_apply_tool_calls();
|
|
@@ -12548,17 +11930,6 @@ CREATE TABLE IF NOT EXISTS raw_tokens (
|
|
|
12548
11930
|
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
12549
11931
|
);
|
|
12550
11932
|
|
|
12551
|
-
CREATE TABLE IF NOT EXISTS generation_cache (
|
|
12552
|
-
input_hash TEXT NOT NULL,
|
|
12553
|
-
entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
|
|
12554
|
-
entity_id TEXT NOT NULL,
|
|
12555
|
-
source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
12556
|
-
human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
|
|
12557
|
-
created_at TEXT NOT NULL,
|
|
12558
|
-
updated_at TEXT NOT NULL,
|
|
12559
|
-
PRIMARY KEY (input_hash, entity_type, entity_id)
|
|
12560
|
-
);
|
|
12561
|
-
|
|
12562
11933
|
CREATE TABLE IF NOT EXISTS scanned_files (
|
|
12563
11934
|
session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
12564
11935
|
path TEXT NOT NULL,
|
|
@@ -12604,10 +11975,9 @@ CREATE INDEX IF NOT EXISTS idx_raw_props_session ON raw_props(session_id,
|
|
|
12604
11975
|
CREATE INDEX IF NOT EXISTS idx_raw_slots_session ON raw_slots(session_id, component_id);
|
|
12605
11976
|
CREATE INDEX IF NOT EXISTS idx_raw_tokens_session ON raw_tokens(session_id);
|
|
12606
11977
|
CREATE INDEX IF NOT EXISTS idx_raw_token_groups_session ON raw_token_groups(session_id);
|
|
12607
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
|
|
12608
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_session ON generation_cache(source_session_id);
|
|
12609
11978
|
CREATE INDEX IF NOT EXISTS idx_scanned_files_session ON scanned_files(session_id);
|
|
12610
11979
|
`;
|
|
11980
|
+
REMOVED_CACHE_TABLES = ["generation_cache", "extract_cache", "composition_cache", "select_cache"];
|
|
12611
11981
|
MAX_COMPONENT_SOURCE_CHARS = 8e3;
|
|
12612
11982
|
MAX_SIBLING_FILES = 5;
|
|
12613
11983
|
MAX_SIBLING_SNIPPET_CHARS = 1200;
|
|
@@ -12624,16 +11994,15 @@ CREATE INDEX IF NOT EXISTS idx_scanned_files_session ON scanned_files(session
|
|
|
12624
11994
|
[".cjs", [".cts", ".cjs"]]
|
|
12625
11995
|
];
|
|
12626
11996
|
IDENTIFIER_PATTERN = /[A-Za-z_$][A-Za-z0-9_$]*/g;
|
|
12627
|
-
_cliCacheVersionCache = null;
|
|
12628
11997
|
}
|
|
12629
11998
|
});
|
|
12630
11999
|
|
|
12631
12000
|
// packages/experience-design-system-cli-legacy/src/helpers/read-existing-contentful-entities-from-session.ts
|
|
12632
|
-
import { readFile as
|
|
12001
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
12633
12002
|
async function readExistingContentfulEntitiesFromSession(path) {
|
|
12634
12003
|
if (!path) return void 0;
|
|
12635
12004
|
try {
|
|
12636
|
-
const raw = await
|
|
12005
|
+
const raw = await readFile8(path, "utf8");
|
|
12637
12006
|
const parsed = JSON.parse(raw);
|
|
12638
12007
|
if (!Array.isArray(parsed.components) || !Array.isArray(parsed.tokens)) return void 0;
|
|
12639
12008
|
return parsed;
|
|
@@ -12757,21 +12126,21 @@ var init_resolve_session_id = __esm({
|
|
|
12757
12126
|
});
|
|
12758
12127
|
|
|
12759
12128
|
// packages/experience-design-system-cli-legacy/src/analyze/select/persistence.ts
|
|
12760
|
-
import { access, appendFile, mkdir as mkdir2, readFile as
|
|
12129
|
+
import { access, appendFile, mkdir as mkdir2, readFile as readFile9, writeFile as writeFile2 } from "node:fs/promises";
|
|
12761
12130
|
import { homedir as homedir4 } from "node:os";
|
|
12762
|
-
import { resolve as
|
|
12131
|
+
import { resolve as resolve9 } from "node:path";
|
|
12763
12132
|
function getRefineArtifactsRoot() {
|
|
12764
12133
|
if (process.env.EDS_REVIEW_ARTIFACTS_DIR) {
|
|
12765
|
-
return
|
|
12134
|
+
return resolve9(process.env.EDS_REVIEW_ARTIFACTS_DIR);
|
|
12766
12135
|
}
|
|
12767
|
-
return
|
|
12136
|
+
return resolve9(homedir4(), ".contentful", "experience-design-system-cli", "reviews");
|
|
12768
12137
|
}
|
|
12769
12138
|
async function getRefineSessionPaths(sessionId2, artifactsRoot) {
|
|
12770
|
-
const sessionDir =
|
|
12139
|
+
const sessionDir = resolve9(artifactsRoot, sessionId2);
|
|
12771
12140
|
return {
|
|
12772
12141
|
sessionDir,
|
|
12773
|
-
eventsPath:
|
|
12774
|
-
statePath:
|
|
12142
|
+
eventsPath: resolve9(sessionDir, "events.jsonl"),
|
|
12143
|
+
statePath: resolve9(sessionDir, "current-review-state.json")
|
|
12775
12144
|
};
|
|
12776
12145
|
}
|
|
12777
12146
|
async function saveReviewState(statePath, session) {
|
|
@@ -12782,7 +12151,7 @@ async function ensureRefineSession(sessionId2, artifactsRoot, initialSnapshot) {
|
|
|
12782
12151
|
await mkdir2(paths.sessionDir, { recursive: true });
|
|
12783
12152
|
try {
|
|
12784
12153
|
await access(paths.statePath);
|
|
12785
|
-
const savedState = await
|
|
12154
|
+
const savedState = await readFile9(paths.statePath, "utf8");
|
|
12786
12155
|
return JSON.parse(savedState);
|
|
12787
12156
|
} catch {
|
|
12788
12157
|
await writeFile2(paths.statePath, JSON.stringify(initialSnapshot, null, 2), "utf8");
|
|
@@ -13267,8 +12636,8 @@ var init_path_exists = __esm({
|
|
|
13267
12636
|
});
|
|
13268
12637
|
|
|
13269
12638
|
// packages/experience-design-system-cli-legacy/src/lib/prompt-overrides.ts
|
|
13270
|
-
import { readFile as
|
|
13271
|
-
import { resolve as
|
|
12639
|
+
import { readFile as readFile10 } from "node:fs/promises";
|
|
12640
|
+
import { resolve as resolve10 } from "node:path";
|
|
13272
12641
|
function looksLikePath(value) {
|
|
13273
12642
|
if (value.includes("/") || value.includes("\\")) return true;
|
|
13274
12643
|
if (value.startsWith("~")) return true;
|
|
@@ -13300,9 +12669,9 @@ function parsePromptOverrides(inputs) {
|
|
|
13300
12669
|
}
|
|
13301
12670
|
async function resolvePromptOverride(override) {
|
|
13302
12671
|
if (override.kind === "text") return override.value;
|
|
13303
|
-
const abs =
|
|
12672
|
+
const abs = resolve10(override.value);
|
|
13304
12673
|
try {
|
|
13305
|
-
return await
|
|
12674
|
+
return await readFile10(abs, "utf8");
|
|
13306
12675
|
} catch {
|
|
13307
12676
|
throw new Error(`--prompt: could not read prompt file: ${abs}`);
|
|
13308
12677
|
}
|
|
@@ -13317,21 +12686,21 @@ var init_prompt_overrides = __esm({
|
|
|
13317
12686
|
|
|
13318
12687
|
// packages/experience-design-system-cli-legacy/src/generate/command.ts
|
|
13319
12688
|
import { createElement } from "react";
|
|
13320
|
-
import { readFile as
|
|
13321
|
-
import { join as join14, resolve as
|
|
12689
|
+
import { readFile as readFile11, readdir, stat } from "node:fs/promises";
|
|
12690
|
+
import { join as join14, resolve as resolve11 } from "node:path";
|
|
13322
12691
|
async function assertFileExists(flag, p) {
|
|
13323
12692
|
if (!await pathExists(p)) die(`Error: file not found: ${p} (from ${flag})`);
|
|
13324
12693
|
}
|
|
13325
12694
|
async function readFileInline(path) {
|
|
13326
12695
|
if (!path) return void 0;
|
|
13327
|
-
const resolved =
|
|
12696
|
+
const resolved = resolve11(path);
|
|
13328
12697
|
let s;
|
|
13329
12698
|
try {
|
|
13330
12699
|
s = await stat(resolved);
|
|
13331
12700
|
} catch {
|
|
13332
12701
|
return void 0;
|
|
13333
12702
|
}
|
|
13334
|
-
if (!s.isDirectory()) return
|
|
12703
|
+
if (!s.isDirectory()) return readFile11(resolved, "utf8");
|
|
13335
12704
|
const files = [];
|
|
13336
12705
|
async function walk(dir) {
|
|
13337
12706
|
let entries;
|
|
@@ -13357,7 +12726,7 @@ async function readFileInline(path) {
|
|
|
13357
12726
|
}
|
|
13358
12727
|
await walk(resolved);
|
|
13359
12728
|
if (files.length === 0) return void 0;
|
|
13360
|
-
const parts = await Promise.all(files.map((f) =>
|
|
12729
|
+
const parts = await Promise.all(files.map((f) => readFile11(f, "utf8").catch(() => "")));
|
|
13361
12730
|
return parts.filter(Boolean).join("\n\n");
|
|
13362
12731
|
}
|
|
13363
12732
|
function printFallbackInstructions(options) {
|
|
@@ -13379,23 +12748,6 @@ function printFallbackInstructions(options) {
|
|
|
13379
12748
|
lines.push(` Re-run the generate command with the agent available, or use --dry-run to inspect the prompt.`);
|
|
13380
12749
|
process.stderr.write(lines.join("\n") + "\n");
|
|
13381
12750
|
}
|
|
13382
|
-
function createCachedComponentResult(componentName, warnings = []) {
|
|
13383
|
-
return {
|
|
13384
|
-
componentName,
|
|
13385
|
-
classified: 0,
|
|
13386
|
-
excluded: 0,
|
|
13387
|
-
slots: 0,
|
|
13388
|
-
warnings,
|
|
13389
|
-
failed: false,
|
|
13390
|
-
cached: true,
|
|
13391
|
-
renamedSlotsCount: 0
|
|
13392
|
-
};
|
|
13393
|
-
}
|
|
13394
|
-
function writeCachedComponentStatus(position, componentName, pinned) {
|
|
13395
|
-
const status = pinned ? c.cyan("pinned (human-edited)") : c.green("cached");
|
|
13396
|
-
process.stderr.write(` ${position} ${c.bold(componentName)} ${status}
|
|
13397
|
-
`);
|
|
13398
|
-
}
|
|
13399
12751
|
async function showGenerateView(result) {
|
|
13400
12752
|
if (process.stdout.isTTY) {
|
|
13401
12753
|
const { waitUntilExit } = renderWithGoodbye(
|
|
@@ -13416,29 +12768,6 @@ session=${result.sessionId}
|
|
|
13416
12768
|
);
|
|
13417
12769
|
await exitWithAnalytics(0);
|
|
13418
12770
|
}
|
|
13419
|
-
function normalizeComponentForCache(component) {
|
|
13420
|
-
const slots = component.slots.map((slot, index, allSlots) => ({
|
|
13421
|
-
...slot,
|
|
13422
|
-
name: slot.name.trim() || (allSlots.length === 1 ? "children" : `slot_${index}`)
|
|
13423
|
-
}));
|
|
13424
|
-
return { ...component, slots };
|
|
13425
|
-
}
|
|
13426
|
-
function lookupComponentCache(db, component, promptHash) {
|
|
13427
|
-
const normalized = normalizeComponentForCache(component);
|
|
13428
|
-
const inputHash = hashComponentShape(normalized);
|
|
13429
|
-
const cached = lookupCache(db, inputHash, "component", component.component_id, promptHash);
|
|
13430
|
-
if (cached) return cached;
|
|
13431
|
-
const legacyInputHash = hashComponentShape(component);
|
|
13432
|
-
return legacyInputHash === inputHash ? null : lookupCache(db, legacyInputHash, "component", component.component_id, promptHash);
|
|
13433
|
-
}
|
|
13434
|
-
function resolveComponentCache(db, component, promptHash, allowedComponentNames2) {
|
|
13435
|
-
const cached = lookupComponentCache(db, component, promptHash);
|
|
13436
|
-
if (cached && findUnknownSlotAllowedComponents(db, cached.sourceSessionId, allowedComponentNames2, component.component_id).length === 0) {
|
|
13437
|
-
return { entry: cached, humanEdited: cached.humanEdited };
|
|
13438
|
-
}
|
|
13439
|
-
const pinned = lookupCacheByEntity(db, "component", component.component_id);
|
|
13440
|
-
return pinned?.humanEdited && findUnknownSlotAllowedComponents(db, pinned.sourceSessionId, allowedComponentNames2, component.component_id).length === 0 ? { entry: pinned, humanEdited: true } : null;
|
|
13441
|
-
}
|
|
13442
12771
|
async function runOneComponent(options, component, index, total) {
|
|
13443
12772
|
const {
|
|
13444
12773
|
agent,
|
|
@@ -13448,13 +12777,10 @@ async function runOneComponent(options, component, index, total) {
|
|
|
13448
12777
|
tokensInline,
|
|
13449
12778
|
tokenMapInline,
|
|
13450
12779
|
verbose,
|
|
13451
|
-
noCache,
|
|
13452
12780
|
skillPathOverride,
|
|
13453
12781
|
skillContentOverride,
|
|
13454
|
-
promptHash,
|
|
13455
12782
|
existingContentfulEntities,
|
|
13456
12783
|
existingTokensInline,
|
|
13457
|
-
precomputedCachedNames,
|
|
13458
12784
|
allowedComponentNames: allowedComponentNames2
|
|
13459
12785
|
} = options;
|
|
13460
12786
|
const pos = c.dim(`[${index + 1}/${total}]`);
|
|
@@ -13479,40 +12805,6 @@ async function runOneComponent(options, component, index, total) {
|
|
|
13479
12805
|
allowedComponents: slot.allowedComponents.filter((name) => allowedComponentNames2.has(name))
|
|
13480
12806
|
};
|
|
13481
12807
|
});
|
|
13482
|
-
const cacheComponent = normalizeComponentForCache(component);
|
|
13483
|
-
if (!noCache && precomputedCachedNames.has(component.name)) {
|
|
13484
|
-
writeCachedComponentStatus(pos, component.name, false);
|
|
13485
|
-
return createCachedComponentResult(component.name);
|
|
13486
|
-
}
|
|
13487
|
-
if (!noCache) {
|
|
13488
|
-
const inputHash = hashComponentShape(cacheComponent);
|
|
13489
|
-
const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
|
|
13490
|
-
if (resolution && !resolution.humanEdited) {
|
|
13491
|
-
copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId2, component.component_id, true, {
|
|
13492
|
-
allowedComponentNames: allowedComponentNames2
|
|
13493
|
-
});
|
|
13494
|
-
storeCache(
|
|
13495
|
-
db,
|
|
13496
|
-
inputHash,
|
|
13497
|
-
"component",
|
|
13498
|
-
component.component_id,
|
|
13499
|
-
resolution.entry.sourceSessionId,
|
|
13500
|
-
resolution.entry.humanEdited,
|
|
13501
|
-
promptHash
|
|
13502
|
-
);
|
|
13503
|
-
writeCachedComponentStatus(pos, component.name, false);
|
|
13504
|
-
return createCachedComponentResult(component.name);
|
|
13505
|
-
}
|
|
13506
|
-
if (resolution?.humanEdited) {
|
|
13507
|
-
copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId2, component.component_id, true, {
|
|
13508
|
-
allowedComponentNames: allowedComponentNames2
|
|
13509
|
-
});
|
|
13510
|
-
writeCachedComponentStatus(pos, component.name, true);
|
|
13511
|
-
return createCachedComponentResult(`${component.name}`, [
|
|
13512
|
-
`${component.name}: source changed but human edits preserved`
|
|
13513
|
-
]);
|
|
13514
|
-
}
|
|
13515
|
-
}
|
|
13516
12808
|
const rawComponentsInline = JSON.stringify(
|
|
13517
12809
|
[
|
|
13518
12810
|
{
|
|
@@ -13585,10 +12877,6 @@ ${outputBuf}`);
|
|
|
13585
12877
|
const applied = applyToolCalls(db, sessionId2, component.component_id, component.name, calls, warnings, {
|
|
13586
12878
|
allowedComponentNames: allowedComponentNames2
|
|
13587
12879
|
});
|
|
13588
|
-
if (!noCache) {
|
|
13589
|
-
const inputHash = hashComponentShape(cacheComponent);
|
|
13590
|
-
storeCache(db, inputHash, "component", component.component_id, sessionId2, false, promptHash);
|
|
13591
|
-
}
|
|
13592
12880
|
return {
|
|
13593
12881
|
componentName: component.name,
|
|
13594
12882
|
classified: applied.classified,
|
|
@@ -13640,7 +12928,7 @@ async function loadAcceptedNames(sessionId2) {
|
|
|
13640
12928
|
try {
|
|
13641
12929
|
const artifactsRoot = getRefineArtifactsRoot();
|
|
13642
12930
|
const paths = await getRefineSessionPaths(sessionId2, artifactsRoot);
|
|
13643
|
-
const raw = await
|
|
12931
|
+
const raw = await readFile11(paths.statePath, "utf8");
|
|
13644
12932
|
const snapshot = JSON.parse(raw);
|
|
13645
12933
|
const accepted = snapshot.components.filter((c2) => c2.status === "accepted").map((c2) => c2.name);
|
|
13646
12934
|
if (accepted.length === 0) return null;
|
|
@@ -13649,15 +12937,6 @@ async function loadAcceptedNames(sessionId2) {
|
|
|
13649
12937
|
return null;
|
|
13650
12938
|
}
|
|
13651
12939
|
}
|
|
13652
|
-
function parsePrecomputedCachedNames(value) {
|
|
13653
|
-
if (!value) return /* @__PURE__ */ new Set();
|
|
13654
|
-
try {
|
|
13655
|
-
const parsed = JSON.parse(value);
|
|
13656
|
-
return new Set(Array.isArray(parsed) ? parsed.filter((name) => typeof name === "string") : []);
|
|
13657
|
-
} catch {
|
|
13658
|
-
return /* @__PURE__ */ new Set();
|
|
13659
|
-
}
|
|
13660
|
-
}
|
|
13661
12940
|
async function runGenerateSkill(skill, opts, verbose = false) {
|
|
13662
12941
|
const savedCreds = await readExperiencesCredentials();
|
|
13663
12942
|
const agentName = opts.agent ?? savedCreds.agent;
|
|
@@ -13686,8 +12965,8 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13686
12965
|
}
|
|
13687
12966
|
const generatePromptPath = generatePrompt === void 0 ? configuredGeneratePromptPath : void 0;
|
|
13688
12967
|
if (generatePromptPath) {
|
|
13689
|
-
if (!await pathExists(
|
|
13690
|
-
die(`Error: custom prompt path not found: ${
|
|
12968
|
+
if (!await pathExists(resolve11(generatePromptPath))) {
|
|
12969
|
+
die(`Error: custom prompt path not found: ${resolve11(generatePromptPath)}`);
|
|
13691
12970
|
}
|
|
13692
12971
|
if (!generatePromptPath.toLowerCase().endsWith(".md")) {
|
|
13693
12972
|
process.stderr.write(
|
|
@@ -13695,7 +12974,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13695
12974
|
`
|
|
13696
12975
|
);
|
|
13697
12976
|
}
|
|
13698
|
-
process.stderr.write(formatCustomPromptBanner("components",
|
|
12977
|
+
process.stderr.write(formatCustomPromptBanner("components", resolve11(generatePromptPath)));
|
|
13699
12978
|
}
|
|
13700
12979
|
if (skill === "tokens" && !opts.rawTokens) {
|
|
13701
12980
|
die("Error: --raw-tokens is required when using generate tokens");
|
|
@@ -13711,7 +12990,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13711
12990
|
let existingContentfulEntities;
|
|
13712
12991
|
let existingTokensInline;
|
|
13713
12992
|
if (opts.existingEntitiesPath) {
|
|
13714
|
-
existingContentfulEntities = await readExistingContentfulEntitiesFromSession(
|
|
12993
|
+
existingContentfulEntities = await readExistingContentfulEntitiesFromSession(resolve11(opts.existingEntitiesPath));
|
|
13715
12994
|
if (existingContentfulEntities) {
|
|
13716
12995
|
existingTokensInline = JSON.stringify(summarizeForMapTokens(existingContentfulEntities));
|
|
13717
12996
|
} else {
|
|
@@ -13810,7 +13089,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13810
13089
|
rawComponentsInline: sampleInline ?? rawTokensInline,
|
|
13811
13090
|
propBucketsInline: sampleComponent ? logPropBuckets("generate", [bucketComponentProps(sampleComponent)]) : void 0,
|
|
13812
13091
|
rawTokensInline: skill === "tokens" ? rawTokensInline : void 0,
|
|
13813
|
-
rawTokensFilename: opts.rawTokens ?
|
|
13092
|
+
rawTokensFilename: opts.rawTokens ? resolve11(opts.rawTokens).split("/").pop() : void 0,
|
|
13814
13093
|
tokensInline,
|
|
13815
13094
|
tokenMapInline,
|
|
13816
13095
|
outDir: process.cwd(),
|
|
@@ -13836,64 +13115,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13836
13115
|
if (skill === "components" && allComponents && sessionId2) {
|
|
13837
13116
|
const db = openPipelineDb();
|
|
13838
13117
|
let componentResults;
|
|
13839
|
-
const precomputedCachedNames = parsePrecomputedCachedNames(opts.cachedComponents);
|
|
13840
13118
|
try {
|
|
13841
|
-
const existingContentfulEntitiesHashInputs = [];
|
|
13842
|
-
if (existingTokensInline) existingContentfulEntitiesHashInputs.push(hashContent(existingTokensInline));
|
|
13843
|
-
const promptHash = await hashPromptForSkill(
|
|
13844
|
-
"components",
|
|
13845
|
-
agent,
|
|
13846
|
-
model,
|
|
13847
|
-
generatePromptPath,
|
|
13848
|
-
existingContentfulEntitiesHashInputs,
|
|
13849
|
-
generatePrompt
|
|
13850
|
-
);
|
|
13851
|
-
if (opts.cacheStatus) {
|
|
13852
|
-
const cacheEnabled = opts.cache !== false && process.env.EDS_NO_CACHE !== "1";
|
|
13853
|
-
const cachedComponents = cacheEnabled ? allComponents.flatMap((component) => {
|
|
13854
|
-
const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
|
|
13855
|
-
return resolution ? [{ component, resolution }] : [];
|
|
13856
|
-
}) : [];
|
|
13857
|
-
if (cacheEnabled && opts.restoreCache) {
|
|
13858
|
-
const restorations = [];
|
|
13859
|
-
const rekeyed = [];
|
|
13860
|
-
const componentStatus = db.prepare(
|
|
13861
|
-
"SELECT status FROM raw_components WHERE session_id = ? AND component_id = ?"
|
|
13862
|
-
);
|
|
13863
|
-
for (const { component, resolution } of cachedComponents) {
|
|
13864
|
-
const current = componentStatus.get(sessionId2, component.component_id);
|
|
13865
|
-
if (current?.status === "generated") continue;
|
|
13866
|
-
renameEmptySlots(db, sessionId2, component.component_id, component.name, component.slots.length);
|
|
13867
|
-
restorations.push({
|
|
13868
|
-
sourceSessionId: resolution.entry.sourceSessionId,
|
|
13869
|
-
targetSessionId: sessionId2,
|
|
13870
|
-
componentId: component.component_id
|
|
13871
|
-
});
|
|
13872
|
-
rekeyed.push({ component, cached: resolution.entry });
|
|
13873
|
-
}
|
|
13874
|
-
copyComponentsFromCache(db, restorations, { allowedComponentNames: allowedComponentNames2 });
|
|
13875
|
-
storeCaches(
|
|
13876
|
-
db,
|
|
13877
|
-
rekeyed.map(({ component, cached }) => ({
|
|
13878
|
-
inputHash: hashComponentShape(normalizeComponentForCache(component)),
|
|
13879
|
-
entityType: "component",
|
|
13880
|
-
entityId: component.component_id,
|
|
13881
|
-
sourceSessionId: cached.sourceSessionId,
|
|
13882
|
-
humanEdited: cached.humanEdited,
|
|
13883
|
-
promptHash
|
|
13884
|
-
}))
|
|
13885
|
-
);
|
|
13886
|
-
}
|
|
13887
|
-
const fullyCached = cacheEnabled && cachedComponents.length === allComponents.length;
|
|
13888
|
-
process.stdout.write(`cache-status=${fullyCached ? "hit" : "miss"}
|
|
13889
|
-
`);
|
|
13890
|
-
process.stdout.write(
|
|
13891
|
-
`cache-components=${JSON.stringify(cachedComponents.map(({ component }) => component.name))}
|
|
13892
|
-
`
|
|
13893
|
-
);
|
|
13894
|
-
await exitWithAnalytics(0);
|
|
13895
|
-
return;
|
|
13896
|
-
}
|
|
13897
13119
|
componentResults = await runAllComponents(
|
|
13898
13120
|
{
|
|
13899
13121
|
agent,
|
|
@@ -13903,13 +13125,10 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13903
13125
|
tokensInline,
|
|
13904
13126
|
tokenMapInline,
|
|
13905
13127
|
verbose,
|
|
13906
|
-
noCache: opts.cache === false || process.env.EDS_NO_CACHE === "1",
|
|
13907
13128
|
skillPathOverride: generatePromptPath,
|
|
13908
13129
|
skillContentOverride: generatePrompt,
|
|
13909
|
-
promptHash,
|
|
13910
13130
|
existingContentfulEntities,
|
|
13911
13131
|
existingTokensInline,
|
|
13912
|
-
precomputedCachedNames,
|
|
13913
13132
|
allowedComponentNames: allowedComponentNames2
|
|
13914
13133
|
},
|
|
13915
13134
|
allComponents
|
|
@@ -13918,8 +13137,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13918
13137
|
db.close();
|
|
13919
13138
|
}
|
|
13920
13139
|
const failed = componentResults.filter((r) => r.failed);
|
|
13921
|
-
const
|
|
13922
|
-
const generated = componentResults.filter((r) => !r.failed && !r.cached);
|
|
13140
|
+
const generated = componentResults.filter((r) => !r.failed);
|
|
13923
13141
|
const allWarnings = componentResults.flatMap((r) => r.warnings.map((w) => ` ${r.componentName}: ${w}`));
|
|
13924
13142
|
if (allWarnings.length > 0) {
|
|
13925
13143
|
process.stderr.write(c.yellow("Warnings:") + "\n" + allWarnings.join("\n") + "\n");
|
|
@@ -13935,21 +13153,17 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13935
13153
|
const totalExcluded = generated.reduce((s, r) => s + r.excluded, 0);
|
|
13936
13154
|
const totalRenamedSlots = componentResults.reduce((s, r) => s + r.renamedSlotsCount, 0);
|
|
13937
13155
|
const allOk = failed.length === 0;
|
|
13938
|
-
const cachedNote = cachedResults.length > 0 ? c.dim(` (${cachedResults.length} cached)`) : "";
|
|
13939
13156
|
process.stderr.write(
|
|
13940
|
-
(allOk ? c.green("\u2713") : c.yellow("\u26A0")) + ` ${generated.length
|
|
13157
|
+
(allOk ? c.green("\u2713") : c.yellow("\u26A0")) + ` ${generated.length}/${componentResults.length} components` + c.dim(` ${totalClassified} classified, ${totalExcluded} unattached`) + "\n"
|
|
13941
13158
|
);
|
|
13942
13159
|
process.stdout.write(`renamed-slots: ${totalRenamedSlots}
|
|
13943
13160
|
`);
|
|
13944
|
-
if (generated.length === 0
|
|
13161
|
+
if (generated.length === 0) {
|
|
13945
13162
|
die(
|
|
13946
13163
|
`Error: all ${componentResults.length} component(s) failed to generate \u2014 see the per-component errors above.`
|
|
13947
13164
|
);
|
|
13948
13165
|
}
|
|
13949
13166
|
} else if (skill === "tokens") {
|
|
13950
|
-
const noCache = opts.cache === false || process.env.EDS_NO_CACHE === "1";
|
|
13951
|
-
const tokenInputContent = rawTokensInline ?? "";
|
|
13952
|
-
const tokenInputHash = hashTokenContent(tokenInputContent);
|
|
13953
13167
|
const db = openPipelineDb();
|
|
13954
13168
|
try {
|
|
13955
13169
|
let resolvedSessionId = opts.session;
|
|
@@ -13976,26 +13190,11 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13976
13190
|
}
|
|
13977
13191
|
sessionId2 = resolvedSessionId;
|
|
13978
13192
|
await bindAnalyticsSessionId(resolvedSessionId);
|
|
13979
|
-
const tokenPromptHash = await hashPromptForSkill("tokens", agent, model);
|
|
13980
|
-
if (!noCache) {
|
|
13981
|
-
const tokenCached = lookupCache(db, tokenInputHash, "token_set", "__tokens__", tokenPromptHash);
|
|
13982
|
-
if (tokenCached) {
|
|
13983
|
-
copyTokensFromCache(db, tokenCached.sourceSessionId, resolvedSessionId);
|
|
13984
|
-
sessionId2 = resolvedSessionId;
|
|
13985
|
-
process.stderr.write(
|
|
13986
|
-
`Done: tokens reused from cache ${c.dim(`(source: ${tokenCached.sourceSessionId.slice(0, 12)})`)}
|
|
13987
|
-
`
|
|
13988
|
-
);
|
|
13989
|
-
db.close();
|
|
13990
|
-
await showGenerateView({ skill, agent, sessionId: sessionId2 ?? "" });
|
|
13991
|
-
return;
|
|
13992
|
-
}
|
|
13993
|
-
}
|
|
13994
13193
|
const prompt = await buildPrompt({
|
|
13995
13194
|
skill,
|
|
13996
13195
|
mode: "autonomous",
|
|
13997
13196
|
rawTokensInline,
|
|
13998
|
-
rawTokensFilename: opts.rawTokens ?
|
|
13197
|
+
rawTokensFilename: opts.rawTokens ? resolve11(opts.rawTokens).split("/").pop() : void 0,
|
|
13999
13198
|
tokensInline,
|
|
14000
13199
|
tokenMapInline,
|
|
14001
13200
|
outDir: process.cwd()
|
|
@@ -14032,9 +13231,6 @@ ${tokenWarnings.map((w) => ` ${w}`).join("\n")}
|
|
|
14032
13231
|
`);
|
|
14033
13232
|
}
|
|
14034
13233
|
applyTokenToolCalls(db, resolvedSessionId, tokenCalls, []);
|
|
14035
|
-
if (!noCache) {
|
|
14036
|
-
storeCache(db, tokenInputHash, "token_set", "__tokens__", resolvedSessionId, false, tokenPromptHash);
|
|
14037
|
-
}
|
|
14038
13234
|
sessionId2 = resolvedSessionId;
|
|
14039
13235
|
const groupCount = tokenCalls.filter((tc) => tc.tool === "set_group").length;
|
|
14040
13236
|
process.stderr.write(`Done: ${tokenCount} tokens, ${groupCount} groups stored
|
|
@@ -14046,10 +13242,7 @@ ${tokenWarnings.map((w) => ` ${w}`).join("\n")}
|
|
|
14046
13242
|
await showGenerateView({ skill, agent, sessionId: sessionId2 ?? "" });
|
|
14047
13243
|
}
|
|
14048
13244
|
function addAgentFlags(cmd) {
|
|
14049
|
-
return addAgentModelOptions(cmd).option("--verbose", "Show full agent output including reasoning text").option("--dry-run", "Print the prompt without invoking the agent")
|
|
14050
|
-
"--no-cache",
|
|
14051
|
-
"Bypass ALL fine-grained caches (extract, select, generate) and force AI re-run. Cache keys now factor in prompt content \u2014 changing the prompt file via --generate-prompt-path or --select-prompt-path will already bust the corresponding stage. Use --no-cache to force a full re-run."
|
|
14052
|
-
);
|
|
13245
|
+
return addAgentModelOptions(cmd).option("--verbose", "Show full agent output including reasoning text").option("--dry-run", "Print the prompt without invoking the agent");
|
|
14053
13246
|
}
|
|
14054
13247
|
function registerInternalGenerateCommand(program) {
|
|
14055
13248
|
const generate = program.command("__generate", { hidden: true }).description("Internal import pipeline generation command");
|
|
@@ -14065,12 +13258,6 @@ function registerInternalGenerateCommand(program) {
|
|
|
14065
13258
|
"--existing-entities-path <path>",
|
|
14066
13259
|
"Path to the .existing-entities.json file written after CMA credentials are supplied. When present, per-component prompts include a summary of the target space so classifications can align to existing prop names/tokens. Missing/malformed files are treated as no-op."
|
|
14067
13260
|
);
|
|
14068
|
-
componentsCmd.option("--cache-status", "Check whether all selected component definitions are cached");
|
|
14069
|
-
componentsCmd.option("--restore-cache", "Restore cached component definitions into the current session");
|
|
14070
|
-
componentsCmd.option(
|
|
14071
|
-
"--cached-components <json>",
|
|
14072
|
-
"Component names already restored by a prior cache-status lookup; skip per-component cache lookup"
|
|
14073
|
-
);
|
|
14074
13261
|
addAgentFlags(componentsCmd).action(async (opts) => {
|
|
14075
13262
|
await runGenerateSkill("components", opts, opts.verbose ?? false);
|
|
14076
13263
|
});
|
|
@@ -14098,7 +13285,6 @@ var init_command = __esm({
|
|
|
14098
13285
|
init_agent_output();
|
|
14099
13286
|
init_GenerateView();
|
|
14100
13287
|
init_db();
|
|
14101
|
-
init_cache_keys();
|
|
14102
13288
|
init_read_existing_contentful_entities_from_session();
|
|
14103
13289
|
init_summarize_existing_contentful_entities();
|
|
14104
13290
|
init_resolve_session_id();
|
|
@@ -14814,7 +14000,7 @@ var init_user_agent = __esm({
|
|
|
14814
14000
|
// packages/experience-design-system-cli-legacy/src/apply/api-client.ts
|
|
14815
14001
|
import { parseCDFComponents } from "@contentful/experience-design-system-types";
|
|
14816
14002
|
function defaultSleep(delayMs) {
|
|
14817
|
-
return new Promise((
|
|
14003
|
+
return new Promise((resolve20) => setTimeout(resolve20, delayMs));
|
|
14818
14004
|
}
|
|
14819
14005
|
function isTransientStatus(status) {
|
|
14820
14006
|
return status >= 500 && status <= 599;
|
|
@@ -15204,7 +14390,7 @@ ${trimmed}`;
|
|
|
15204
14390
|
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
15205
14391
|
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
15206
14392
|
const jitter = Math.random() * baseDelay * 0.15;
|
|
15207
|
-
await new Promise((
|
|
14393
|
+
await new Promise((resolve20) => setTimeout(resolve20, baseDelay + jitter));
|
|
15208
14394
|
}
|
|
15209
14395
|
}
|
|
15210
14396
|
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
@@ -16014,7 +15200,7 @@ var init_terminal_capabilities = __esm({
|
|
|
16014
15200
|
|
|
16015
15201
|
// packages/experience-design-system-cli-legacy/src/apply/command.ts
|
|
16016
15202
|
import { createElement as createElement2 } from "react";
|
|
16017
|
-
import { readFile as
|
|
15203
|
+
import { readFile as readFile12, readdir as readdir2, stat as stat2 } from "node:fs/promises";
|
|
16018
15204
|
import { join as join16 } from "node:path";
|
|
16019
15205
|
import {
|
|
16020
15206
|
validateCDF,
|
|
@@ -16035,7 +15221,7 @@ function dieWithApiError(error) {
|
|
|
16035
15221
|
async function readJsonFile(flag, p) {
|
|
16036
15222
|
let text;
|
|
16037
15223
|
try {
|
|
16038
|
-
text = await
|
|
15224
|
+
text = await readFile12(p, "utf8");
|
|
16039
15225
|
} catch {
|
|
16040
15226
|
return await die2(`Error: file not found: ${p} (from ${flag})`);
|
|
16041
15227
|
}
|
|
@@ -16089,7 +15275,7 @@ async function readTokensFromPath(flag, p) {
|
|
|
16089
15275
|
for (const file of files.sort()) {
|
|
16090
15276
|
let text;
|
|
16091
15277
|
try {
|
|
16092
|
-
text = await
|
|
15278
|
+
text = await readFile12(file, "utf8");
|
|
16093
15279
|
} catch {
|
|
16094
15280
|
continue;
|
|
16095
15281
|
}
|
|
@@ -16458,11 +15644,11 @@ var init_command2 = __esm({
|
|
|
16458
15644
|
});
|
|
16459
15645
|
|
|
16460
15646
|
// packages/experience-design-system-cli-legacy/src/print/validate/validators/read-json-file.ts
|
|
16461
|
-
import { readFile as
|
|
15647
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
16462
15648
|
async function readJsonFile2(filePath) {
|
|
16463
15649
|
let content;
|
|
16464
15650
|
try {
|
|
16465
|
-
content = await
|
|
15651
|
+
content = await readFile13(filePath, "utf-8");
|
|
16466
15652
|
} catch (err) {
|
|
16467
15653
|
return {
|
|
16468
15654
|
ok: false,
|
|
@@ -16873,7 +16059,7 @@ var init_ValidateView = __esm({
|
|
|
16873
16059
|
// packages/experience-design-system-cli-legacy/src/print/command.ts
|
|
16874
16060
|
import { createElement as createElement3 } from "react";
|
|
16875
16061
|
import { access as access3, mkdir as mkdir3, stat as stat3, writeFile as writeFile3 } from "node:fs/promises";
|
|
16876
|
-
import { basename as basename5, resolve as
|
|
16062
|
+
import { basename as basename5, resolve as resolve12 } from "node:path";
|
|
16877
16063
|
import { CDF_SCHEMA_URL } from "@contentful/experience-design-system-types";
|
|
16878
16064
|
async function die3(message) {
|
|
16879
16065
|
process.stderr.write(`${message}
|
|
@@ -16940,7 +16126,7 @@ function registerPrintCommand(program) {
|
|
|
16940
16126
|
"--allow-empty",
|
|
16941
16127
|
"Write an empty-but-present CDF file when no components are accepted (a subsequent push then removes ALL components from the target space). Without this, an empty accepted set is an error."
|
|
16942
16128
|
).action(async (opts) => {
|
|
16943
|
-
const outPath =
|
|
16129
|
+
const outPath = resolve12(opts.out);
|
|
16944
16130
|
await assertOutIsNotDirectory(outPath);
|
|
16945
16131
|
const sessionId2 = await resolveSession(opts.session, "generate components");
|
|
16946
16132
|
await bindAnalyticsSessionId(sessionId2);
|
|
@@ -16988,7 +16174,7 @@ function registerPrintCommand(program) {
|
|
|
16988
16174
|
`
|
|
16989
16175
|
);
|
|
16990
16176
|
}
|
|
16991
|
-
await mkdir3(
|
|
16177
|
+
await mkdir3(resolve12(outPath, ".."), { recursive: true });
|
|
16992
16178
|
await writeFile3(outPath, `${JSON.stringify(cdfObj, null, 2)}
|
|
16993
16179
|
`);
|
|
16994
16180
|
process.stdout.write(
|
|
@@ -16997,7 +16183,7 @@ function registerPrintCommand(program) {
|
|
|
16997
16183
|
);
|
|
16998
16184
|
});
|
|
16999
16185
|
print.command("tokens").description("Write generated tokens to a DTCG JSON file").option("--session <id>", "Session ID to print from (default: most recent generate tokens session)").option("--out <path>", "Output file path", "tokens.json").action(async (opts) => {
|
|
17000
|
-
const outPath =
|
|
16186
|
+
const outPath = resolve12(opts.out);
|
|
17001
16187
|
await assertOutIsNotDirectory(outPath);
|
|
17002
16188
|
const sessionId2 = await resolveSession(opts.session, "generate tokens");
|
|
17003
16189
|
await bindAnalyticsSessionId(sessionId2);
|
|
@@ -17012,7 +16198,7 @@ function registerPrintCommand(program) {
|
|
|
17012
16198
|
await die3(`Error: no generated tokens in session '${sessionId2}'. Run generate tokens first.`);
|
|
17013
16199
|
}
|
|
17014
16200
|
const tree = rebuildDTCGTree(result.groups, result.tokens);
|
|
17015
|
-
await mkdir3(
|
|
16201
|
+
await mkdir3(resolve12(outPath, ".."), { recursive: true });
|
|
17016
16202
|
await writeFile3(outPath, `${JSON.stringify(tree, null, 2)}
|
|
17017
16203
|
`);
|
|
17018
16204
|
process.stdout.write(
|
|
@@ -17161,7 +16347,7 @@ function MapTokensView({ result, onExit }) {
|
|
|
17161
16347
|
const timer = setTimeout(onExit, 100);
|
|
17162
16348
|
return () => clearTimeout(timer);
|
|
17163
16349
|
}, [onExit]);
|
|
17164
|
-
const summary =
|
|
16350
|
+
const summary = `${result.applied} mapping${result.applied === 1 ? "" : "s"} applied`;
|
|
17165
16351
|
return /* @__PURE__ */ jsx8(
|
|
17166
16352
|
CommandCompletionView,
|
|
17167
16353
|
{
|
|
@@ -17295,8 +16481,8 @@ var init_resolve_defaults = __esm({
|
|
|
17295
16481
|
|
|
17296
16482
|
// packages/experience-design-system-cli-legacy/src/map-tokens/command.ts
|
|
17297
16483
|
import { createElement as createElement4 } from "react";
|
|
17298
|
-
import { readFile as
|
|
17299
|
-
import { resolve as
|
|
16484
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
16485
|
+
import { resolve as resolve13 } from "node:path";
|
|
17300
16486
|
async function renderResult(result) {
|
|
17301
16487
|
if (process.stdout.isTTY) {
|
|
17302
16488
|
const { waitUntilExit } = renderWithGoodbye(
|
|
@@ -17304,12 +16490,13 @@ async function renderResult(result) {
|
|
|
17304
16490
|
);
|
|
17305
16491
|
await waitUntilExit();
|
|
17306
16492
|
} else {
|
|
17307
|
-
|
|
17308
|
-
|
|
16493
|
+
process.stdout.write(
|
|
16494
|
+
`map tokens complete
|
|
17309
16495
|
agent: ${result.agent}
|
|
17310
16496
|
session=${result.sessionId}
|
|
17311
|
-
${
|
|
17312
|
-
`
|
|
16497
|
+
${result.applied} mapping(s) applied
|
|
16498
|
+
`
|
|
16499
|
+
);
|
|
17313
16500
|
await exitWithAnalytics(0);
|
|
17314
16501
|
}
|
|
17315
16502
|
}
|
|
@@ -17331,7 +16518,7 @@ async function runMapTokens(opts) {
|
|
|
17331
16518
|
let mapPromptPath;
|
|
17332
16519
|
if (mapPromptOverride?.kind === "text") mapPromptText = mapPromptOverride.value;
|
|
17333
16520
|
if (mapPromptOverride?.kind === "path") {
|
|
17334
|
-
mapPromptPath =
|
|
16521
|
+
mapPromptPath = resolve13(mapPromptOverride.value);
|
|
17335
16522
|
try {
|
|
17336
16523
|
await resolvePromptOverride(mapPromptOverride);
|
|
17337
16524
|
} catch (error) {
|
|
@@ -17351,7 +16538,7 @@ async function runMapTokens(opts) {
|
|
|
17351
16538
|
const knownTokenPaths = new Set(tokenLeaves.map((t) => t.path));
|
|
17352
16539
|
const tokenMapDiagnostics = [];
|
|
17353
16540
|
if (opts.tokenMap) {
|
|
17354
|
-
const fileMappings = JSON.parse(await
|
|
16541
|
+
const fileMappings = JSON.parse(await readFile14(opts.tokenMap, "utf8"));
|
|
17355
16542
|
const validMappings = {};
|
|
17356
16543
|
for (const [rawName, path] of Object.entries(fileMappings)) {
|
|
17357
16544
|
if (knownTokenPaths.has(path)) {
|
|
@@ -17429,7 +16616,7 @@ ${defaultDiagnostics.map((diagnostic) => ` ${diagnostic}`).join("\n")}
|
|
|
17429
16616
|
let existingTokensInline;
|
|
17430
16617
|
if (opts.existingEntitiesPath) {
|
|
17431
16618
|
const existingContentfulEntities = await readExistingContentfulEntitiesFromSession(
|
|
17432
|
-
|
|
16619
|
+
resolve13(opts.existingEntitiesPath)
|
|
17433
16620
|
);
|
|
17434
16621
|
if (existingContentfulEntities) {
|
|
17435
16622
|
existingTokensInline = JSON.stringify(summarizeForMapTokens(existingContentfulEntities));
|
|
@@ -17464,30 +16651,10 @@ ${defaultDiagnostics.map((diagnostic) => ` ${diagnostic}`).join("\n")}
|
|
|
17464
16651
|
skipAgent: "true"
|
|
17465
16652
|
});
|
|
17466
16653
|
updateStep(db, stepId2, "complete", { applied: "0", skipAgent: "true" });
|
|
17467
|
-
await renderResult({ agent: resultAgent, sessionId: sessionId2, applied: 0
|
|
16654
|
+
await renderResult({ agent: resultAgent, sessionId: sessionId2, applied: 0 });
|
|
17468
16655
|
return;
|
|
17469
16656
|
}
|
|
17470
16657
|
const agent = configuredAgent;
|
|
17471
|
-
const noCache = opts.cache === false || process.env.EDS_NO_CACHE === "1";
|
|
17472
|
-
const promptHash = await hashPromptForSkill(
|
|
17473
|
-
"map-tokens",
|
|
17474
|
-
agent,
|
|
17475
|
-
model,
|
|
17476
|
-
void 0,
|
|
17477
|
-
existingTokensInline ? [hashContent(existingTokensInline)] : [],
|
|
17478
|
-
mapPromptText
|
|
17479
|
-
);
|
|
17480
|
-
const inputHash = computeMapTokensInputHash(db, sessionId2, componentSourceRefs);
|
|
17481
|
-
if (!noCache) {
|
|
17482
|
-
const cached = lookupCache(db, inputHash, "token_mapping", "__map_tokens__", promptHash);
|
|
17483
|
-
if (cached) {
|
|
17484
|
-
const appliedFromCache = copyMapTokensFromCache(db, cached.sourceSessionId, sessionId2);
|
|
17485
|
-
const stepId2 = createStep(db, sessionId2, "map tokens", { agent, model: model ?? "" });
|
|
17486
|
-
updateStep(db, stepId2, "complete", { cached: "true", applied: String(appliedFromCache) });
|
|
17487
|
-
await renderResult({ agent, sessionId: sessionId2, applied: appliedFromCache, cached: true });
|
|
17488
|
-
return;
|
|
17489
|
-
}
|
|
17490
|
-
}
|
|
17491
16658
|
const binary = resolveAgentBinary(agent);
|
|
17492
16659
|
if (!await assertBinaryInPath(binary)) {
|
|
17493
16660
|
die(
|
|
@@ -17507,23 +16674,20 @@ Install it, choose another agent with --agent, or use --print-prompt to run the
|
|
|
17507
16674
|
}
|
|
17508
16675
|
const { calls, warnings: parseWarnings } = parseMapTokenPropToolCallLines(result.stdout);
|
|
17509
16676
|
const { applied, warnings } = applyMapTokenPropCalls(db, sessionId2, calls, parseWarnings);
|
|
17510
|
-
if (!noCache) {
|
|
17511
|
-
storeCache(db, inputHash, "token_mapping", "__map_tokens__", sessionId2, false, promptHash);
|
|
17512
|
-
}
|
|
17513
16677
|
updateStep(db, stepId, "complete", { applied: String(applied), warnings: String(warnings.length) });
|
|
17514
16678
|
if (warnings.length > 0) {
|
|
17515
16679
|
process.stderr.write(`Warnings:
|
|
17516
16680
|
${warnings.map((w) => ` ${w}`).join("\n")}
|
|
17517
16681
|
`);
|
|
17518
16682
|
}
|
|
17519
|
-
await renderResult({ agent, sessionId: sessionId2, applied
|
|
16683
|
+
await renderResult({ agent, sessionId: sessionId2, applied });
|
|
17520
16684
|
} finally {
|
|
17521
16685
|
db.close();
|
|
17522
16686
|
}
|
|
17523
16687
|
}
|
|
17524
16688
|
function registerMapTokensCommand(program) {
|
|
17525
16689
|
const map = program.command("map", { hidden: true }).description("Suggest token restrictions for generated design-token props");
|
|
17526
|
-
const tokensCmd = map.command("tokens").description("Invoke a coding agent to suggest $token.allowed for design-category token props").option("--session <id>", "Session ID from generate components (defaults to most recent)").option("--print-prompt", "Print the prompt without invoking the agent").option("--skip-agent", "Resolve token defaults without agentic $token.allowed inference").option(
|
|
16690
|
+
const tokensCmd = map.command("tokens").description("Invoke a coding agent to suggest $token.allowed for design-category token props").option("--session <id>", "Session ID from generate components (defaults to most recent)").option("--print-prompt", "Print the prompt without invoking the agent").option("--skip-agent", "Resolve token defaults without agentic $token.allowed inference").option(
|
|
17527
16691
|
"--prompt <stage=value>",
|
|
17528
16692
|
"Override a stage prompt (repeatable). Used here for the map-tokens stage.",
|
|
17529
16693
|
(v, acc) => [...acc, v],
|
|
@@ -17543,7 +16707,6 @@ var init_command4 = __esm({
|
|
|
17543
16707
|
init_render_with_goodbye();
|
|
17544
16708
|
init_src();
|
|
17545
16709
|
init_db();
|
|
17546
|
-
init_cache_keys();
|
|
17547
16710
|
init_read_existing_contentful_entities_from_session();
|
|
17548
16711
|
init_summarize_existing_contentful_entities();
|
|
17549
16712
|
init_command3();
|
|
@@ -17560,7 +16723,7 @@ var init_command4 = __esm({
|
|
|
17560
16723
|
});
|
|
17561
16724
|
|
|
17562
16725
|
// packages/experience-design-system-cli-legacy/src/import/path-utils.ts
|
|
17563
|
-
import { resolve as
|
|
16726
|
+
import { resolve as resolve14 } from "node:path";
|
|
17564
16727
|
import { homedir as homedir5 } from "node:os";
|
|
17565
16728
|
function expandTilde(input) {
|
|
17566
16729
|
if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
|
|
@@ -17574,7 +16737,7 @@ function normalizePath(input) {
|
|
|
17574
16737
|
p = p.slice(1, -1);
|
|
17575
16738
|
}
|
|
17576
16739
|
p = expandTilde(p);
|
|
17577
|
-
return
|
|
16740
|
+
return resolve14(p);
|
|
17578
16741
|
}
|
|
17579
16742
|
var init_path_utils = __esm({
|
|
17580
16743
|
"packages/experience-design-system-cli-legacy/src/import/path-utils.ts"() {
|
|
@@ -17799,7 +16962,7 @@ var init_save_path_resolver = __esm({
|
|
|
17799
16962
|
});
|
|
17800
16963
|
|
|
17801
16964
|
// packages/experience-design-system-cli-legacy/src/runs/store.ts
|
|
17802
|
-
import { readFile as
|
|
16965
|
+
import { readFile as readFile15, writeFile as writeFile4, mkdir as mkdir4, rename } from "node:fs/promises";
|
|
17803
16966
|
import { join as join20 } from "node:path";
|
|
17804
16967
|
import { homedir as homedir6 } from "node:os";
|
|
17805
16968
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
@@ -17839,7 +17002,7 @@ function migrateRecord(rec) {
|
|
|
17839
17002
|
}
|
|
17840
17003
|
async function readFileMaybe() {
|
|
17841
17004
|
try {
|
|
17842
|
-
const raw = await
|
|
17005
|
+
const raw = await readFile15(RUNS_PATH, "utf8");
|
|
17843
17006
|
const parsed = JSON.parse(raw);
|
|
17844
17007
|
if (!READABLE_VERSIONS.has(parsed.version)) {
|
|
17845
17008
|
throw new Error(
|
|
@@ -17903,15 +17066,15 @@ var init_store = __esm({
|
|
|
17903
17066
|
});
|
|
17904
17067
|
|
|
17905
17068
|
// packages/experience-design-system-cli-legacy/src/runs/fingerprint.ts
|
|
17906
|
-
import { createHash as
|
|
17907
|
-
import { readFile as
|
|
17908
|
-
import { resolve as
|
|
17069
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
17070
|
+
import { readFile as readFile16, stat as stat4 } from "node:fs/promises";
|
|
17071
|
+
import { resolve as resolve15 } from "node:path";
|
|
17909
17072
|
function rowField(row, key) {
|
|
17910
17073
|
const v = row[key];
|
|
17911
17074
|
return typeof v === "string" ? v : null;
|
|
17912
17075
|
}
|
|
17913
17076
|
function sha256Hex(buf) {
|
|
17914
|
-
return
|
|
17077
|
+
return createHash2("sha256").update(buf).digest("hex");
|
|
17915
17078
|
}
|
|
17916
17079
|
async function buildSourceFingerprint(opts) {
|
|
17917
17080
|
const rows = opts.db.prepare("SELECT name, source_path FROM raw_components WHERE session_id = ?").all(opts.extractSessionId);
|
|
@@ -17921,7 +17084,7 @@ async function buildSourceFingerprint(opts) {
|
|
|
17921
17084
|
const sourcePath = rowField(row, "source_path");
|
|
17922
17085
|
const name = rowField(row, "name");
|
|
17923
17086
|
if (!sourcePath) continue;
|
|
17924
|
-
const abs =
|
|
17087
|
+
const abs = resolve15(sourcePath);
|
|
17925
17088
|
if (seen.has(abs)) continue;
|
|
17926
17089
|
seen.add(abs);
|
|
17927
17090
|
try {
|
|
@@ -17936,10 +17099,10 @@ async function buildSourceFingerprint(opts) {
|
|
|
17936
17099
|
let rawTokensMtime = null;
|
|
17937
17100
|
let rawTokensContentHash = null;
|
|
17938
17101
|
if (opts.rawTokensPath) {
|
|
17939
|
-
const abs =
|
|
17102
|
+
const abs = resolve15(opts.rawTokensPath);
|
|
17940
17103
|
rawTokensPath = abs;
|
|
17941
17104
|
try {
|
|
17942
|
-
const [st, buf] = await Promise.all([stat4(abs),
|
|
17105
|
+
const [st, buf] = await Promise.all([stat4(abs), readFile16(abs)]);
|
|
17943
17106
|
rawTokensMtime = st.mtime.toISOString();
|
|
17944
17107
|
rawTokensContentHash = sha256Hex(buf);
|
|
17945
17108
|
} catch {
|
|
@@ -19694,11 +18857,11 @@ var init_slot_graph = __esm({
|
|
|
19694
18857
|
});
|
|
19695
18858
|
|
|
19696
18859
|
// packages/experience-design-system-cli-legacy/src/analyze/select/parser.ts
|
|
19697
|
-
import { createHash as
|
|
18860
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
19698
18861
|
import { access as access5 } from "node:fs/promises";
|
|
19699
|
-
import { isAbsolute, relative, resolve as
|
|
18862
|
+
import { isAbsolute, relative, resolve as resolve16 } from "node:path";
|
|
19700
18863
|
function createComponentId(name, resolvedSourcePath) {
|
|
19701
|
-
const sourceHash =
|
|
18864
|
+
const sourceHash = createHash3("sha256").update(`${name}:${resolvedSourcePath}`).digest("hex").slice(0, 12);
|
|
19702
18865
|
return `${name}-${sourceHash}`;
|
|
19703
18866
|
}
|
|
19704
18867
|
async function resolveComponentSourcePath(source, reviewRoot) {
|
|
@@ -19710,7 +18873,7 @@ async function resolveComponentSourcePath(source, reviewRoot) {
|
|
|
19710
18873
|
throw new Error(`Unable to access component source at ${source}`);
|
|
19711
18874
|
}
|
|
19712
18875
|
}
|
|
19713
|
-
const candidate =
|
|
18876
|
+
const candidate = resolve16(reviewRoot, source);
|
|
19714
18877
|
const relativeToRoot = relative(reviewRoot, candidate);
|
|
19715
18878
|
if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || isAbsolute(relativeToRoot)) {
|
|
19716
18879
|
throw new Error(
|
|
@@ -19725,7 +18888,7 @@ async function resolveComponentSourcePath(source, reviewRoot) {
|
|
|
19725
18888
|
}
|
|
19726
18889
|
}
|
|
19727
18890
|
async function loadReviewInput(components, options = {}) {
|
|
19728
|
-
const reviewRoot =
|
|
18891
|
+
const reviewRoot = resolve16(options.reviewRoot ?? process.cwd());
|
|
19729
18892
|
const records = await Promise.all(
|
|
19730
18893
|
components.map(async (component) => {
|
|
19731
18894
|
let resolvedSourcePath;
|
|
@@ -19756,7 +18919,7 @@ var init_parser = __esm({
|
|
|
19756
18919
|
});
|
|
19757
18920
|
|
|
19758
18921
|
// packages/experience-design-system-cli-legacy/src/analyze/select/command.ts
|
|
19759
|
-
import { access as access6, readFile as
|
|
18922
|
+
import { access as access6, readFile as readFile17 } from "node:fs/promises";
|
|
19760
18923
|
async function loadAndValidateForReview(sessionId2, projectRoot) {
|
|
19761
18924
|
const db = openPipelineDb();
|
|
19762
18925
|
let rawComponents;
|
|
@@ -19774,7 +18937,7 @@ async function patchReviewStateWithValidationErrors(sessionId2, errors, opts = {
|
|
|
19774
18937
|
let snapshot;
|
|
19775
18938
|
try {
|
|
19776
18939
|
await access6(paths.statePath);
|
|
19777
|
-
snapshot = JSON.parse(await
|
|
18940
|
+
snapshot = JSON.parse(await readFile17(paths.statePath, "utf8"));
|
|
19778
18941
|
} catch {
|
|
19779
18942
|
snapshot = await loadAndValidateForReview(sessionId2, void 0);
|
|
19780
18943
|
snapshot = await ensureRefineSession(sessionId2, artifactsRoot, snapshot);
|
|
@@ -19825,7 +18988,7 @@ async function rejectComponentsByName(sessionId2, names, opts = {}) {
|
|
|
19825
18988
|
const nameSet = new Set(names);
|
|
19826
18989
|
let snapshot;
|
|
19827
18990
|
try {
|
|
19828
|
-
snapshot = JSON.parse(await
|
|
18991
|
+
snapshot = JSON.parse(await readFile17(paths.statePath, "utf8"));
|
|
19829
18992
|
} catch {
|
|
19830
18993
|
return;
|
|
19831
18994
|
}
|
|
@@ -19924,9 +19087,9 @@ function spawnGenerateChild(opts) {
|
|
|
19924
19087
|
stderr += chunk;
|
|
19925
19088
|
opts.onStderr?.(chunk);
|
|
19926
19089
|
});
|
|
19927
|
-
const donePromise = new Promise((
|
|
19090
|
+
const donePromise = new Promise((resolve20) => {
|
|
19928
19091
|
child.on("close", (code, signal) => {
|
|
19929
|
-
|
|
19092
|
+
resolve20({
|
|
19930
19093
|
exitCode: code ?? 0,
|
|
19931
19094
|
signal: signal ?? null,
|
|
19932
19095
|
stdout,
|
|
@@ -19934,7 +19097,7 @@ function spawnGenerateChild(opts) {
|
|
|
19934
19097
|
});
|
|
19935
19098
|
});
|
|
19936
19099
|
child.on("error", (err) => {
|
|
19937
|
-
|
|
19100
|
+
resolve20({
|
|
19938
19101
|
exitCode: 1,
|
|
19939
19102
|
signal: null,
|
|
19940
19103
|
stdout,
|
|
@@ -28072,9 +27235,6 @@ function shouldGenerateAfterCredentialsValidated(opts) {
|
|
|
28072
27235
|
function shouldSkipFinalReviewAfterCredentials(state) {
|
|
28073
27236
|
return state.finalReviewPassed && state.generateSessionId != null;
|
|
28074
27237
|
}
|
|
28075
|
-
function resolveNoCacheForGenerate(opts) {
|
|
28076
|
-
return opts.cliNoCache;
|
|
28077
|
-
}
|
|
28078
27238
|
function shouldBypassPreview(state) {
|
|
28079
27239
|
return state.credentialsSkipped === true;
|
|
28080
27240
|
}
|
|
@@ -28101,66 +27261,39 @@ var init_wizard_state_transitions = __esm({
|
|
|
28101
27261
|
async function runSelectionAgent(options) {
|
|
28102
27262
|
const db = openPipelineDb();
|
|
28103
27263
|
let components;
|
|
28104
|
-
const cachedDecisions = /* @__PURE__ */ new Map();
|
|
28105
|
-
const cliVersion2 = await getCliCacheVersion();
|
|
28106
|
-
const promptHash = await hashPromptForSkill(
|
|
28107
|
-
"select",
|
|
28108
|
-
options.agent,
|
|
28109
|
-
options.model,
|
|
28110
|
-
options.promptPath,
|
|
28111
|
-
[],
|
|
28112
|
-
options.promptText
|
|
28113
|
-
);
|
|
28114
27264
|
try {
|
|
28115
27265
|
components = loadRawComponents(db, options.sessionId);
|
|
28116
|
-
if (!options.noCache) {
|
|
28117
|
-
for (const component of components) {
|
|
28118
|
-
const componentHash = hashComponentShape(component);
|
|
28119
|
-
const cached = lookupSelectCache(db, componentHash, promptHash, cliVersion2);
|
|
28120
|
-
if (cached) {
|
|
28121
|
-
cachedDecisions.set(component.name, {
|
|
28122
|
-
decision: cached.decision,
|
|
28123
|
-
reason: cached.reason
|
|
28124
|
-
});
|
|
28125
|
-
}
|
|
28126
|
-
}
|
|
28127
|
-
}
|
|
28128
27266
|
} finally {
|
|
28129
27267
|
db.close();
|
|
28130
27268
|
}
|
|
28131
27269
|
if (components.length === 0) return;
|
|
28132
|
-
const
|
|
28133
|
-
|
|
28134
|
-
|
|
28135
|
-
|
|
28136
|
-
|
|
28137
|
-
|
|
28138
|
-
|
|
28139
|
-
|
|
28140
|
-
|
|
28141
|
-
|
|
28142
|
-
|
|
28143
|
-
|
|
28144
|
-
|
|
28145
|
-
|
|
28146
|
-
|
|
28147
|
-
|
|
28148
|
-
|
|
28149
|
-
|
|
28150
|
-
}
|
|
28151
|
-
|
|
28152
|
-
|
|
28153
|
-
|
|
28154
|
-
|
|
28155
|
-
|
|
28156
|
-
|
|
28157
|
-
if (result.exitCode !== 0) throw new Error(`selection agent exited with code ${result.exitCode}`);
|
|
28158
|
-
const parsed = parseSelectToolCallLines(result.stdout);
|
|
28159
|
-
for (const warning of parsed.warnings) process.stderr.write(`Warning: selection agent: ${warning}
|
|
27270
|
+
const invoker2 = createLocalCliAgentInvoker({
|
|
27271
|
+
onDebugEvent: (name, payload) => getDebugLogger().event("agent", name, payload)
|
|
27272
|
+
});
|
|
27273
|
+
const prompt = await buildPrompt({
|
|
27274
|
+
skill: "select",
|
|
27275
|
+
mode: "autonomous",
|
|
27276
|
+
rawComponentsInline: JSON.stringify(
|
|
27277
|
+
components.map((component) => ({ ...component, props: component.props.map(stripPropProvenance) })),
|
|
27278
|
+
null,
|
|
27279
|
+
2
|
|
27280
|
+
),
|
|
27281
|
+
propBucketsInline: logPropBuckets("select", bucketComponentsProps(components)),
|
|
27282
|
+
outDir: process.cwd(),
|
|
27283
|
+
...options.promptText !== void 0 ? { skillContentOverride: options.promptText } : {},
|
|
27284
|
+
...options.promptText === void 0 && options.promptPath ? { skillPathOverride: options.promptPath } : {}
|
|
27285
|
+
});
|
|
27286
|
+
const { result } = await invokeAgentWithOutput(
|
|
27287
|
+
invoker2,
|
|
27288
|
+
{ agent: options.agent, model: options.model, prompt, timeoutMs: DEFAULT_TIMEOUT_MS4 },
|
|
27289
|
+
false
|
|
27290
|
+
);
|
|
27291
|
+
if (result.timedOut) throw new Error("selection agent timed out");
|
|
27292
|
+
if (result.exitCode !== 0) throw new Error(`selection agent exited with code ${result.exitCode}`);
|
|
27293
|
+
const parsed = parseSelectToolCallLines(result.stdout);
|
|
27294
|
+
for (const warning of parsed.warnings) process.stderr.write(`Warning: selection agent: ${warning}
|
|
28160
27295
|
`);
|
|
28161
|
-
|
|
28162
|
-
}
|
|
28163
|
-
const byName = new Map(calls.map((call) => [call.name, call]));
|
|
27296
|
+
const byName = new Map(parsed.calls.map((call) => [call.name, call]));
|
|
28164
27297
|
const writeDb = openPipelineDb();
|
|
28165
27298
|
try {
|
|
28166
27299
|
writeDb.exec("BEGIN");
|
|
@@ -28168,27 +27301,15 @@ async function runSelectionAgent(options) {
|
|
|
28168
27301
|
`UPDATE raw_components SET status = ?, reject_reason = ? WHERE session_id = ? AND component_id = ?`
|
|
28169
27302
|
);
|
|
28170
27303
|
for (const component of components) {
|
|
28171
|
-
const cached = cachedDecisions.get(component.name);
|
|
28172
27304
|
const call = byName.get(component.name);
|
|
28173
|
-
if (!
|
|
28174
|
-
const rejected =
|
|
28175
|
-
const reason = cached ? cached.reason : call.reason ?? null;
|
|
27305
|
+
if (!call) continue;
|
|
27306
|
+
const rejected = call.tool === "reject_component";
|
|
28176
27307
|
update.run(
|
|
28177
27308
|
rejected ? "rejected" : "accepted",
|
|
28178
|
-
rejected ? reason : null,
|
|
27309
|
+
rejected ? call.reason ?? null : null,
|
|
28179
27310
|
options.sessionId,
|
|
28180
27311
|
component.component_id
|
|
28181
27312
|
);
|
|
28182
|
-
if (!cached) {
|
|
28183
|
-
storeSelectCache(
|
|
28184
|
-
writeDb,
|
|
28185
|
-
hashComponentShape(component),
|
|
28186
|
-
promptHash,
|
|
28187
|
-
cliVersion2,
|
|
28188
|
-
rejected ? "rejected" : "accepted",
|
|
28189
|
-
rejected ? reason : null
|
|
28190
|
-
);
|
|
28191
|
-
}
|
|
28192
27313
|
}
|
|
28193
27314
|
writeDb.exec("COMMIT");
|
|
28194
27315
|
} catch (error) {
|
|
@@ -28209,7 +27330,6 @@ var init_run_selection_agent = __esm({
|
|
|
28209
27330
|
init_debug_logger();
|
|
28210
27331
|
init_agent_output();
|
|
28211
27332
|
init_db();
|
|
28212
|
-
init_cache_keys();
|
|
28213
27333
|
DEFAULT_TIMEOUT_MS4 = Number(process.env.EDS_AGENT_TIMEOUT_MS ?? 5 * 60 * 1e3);
|
|
28214
27334
|
}
|
|
28215
27335
|
});
|
|
@@ -28228,7 +27348,7 @@ __export(WizardApp_exports, {
|
|
|
28228
27348
|
});
|
|
28229
27349
|
import { useEffect as useEffect15, useRef as useRef10, useState as useState23 } from "react";
|
|
28230
27350
|
import { Box as Box42, Text as Text46 } from "ink";
|
|
28231
|
-
import { join as join23, resolve as
|
|
27351
|
+
import { join as join23, resolve as resolve17 } from "node:path";
|
|
28232
27352
|
import { appendFileSync as appendFileSync2, writeFileSync } from "node:fs";
|
|
28233
27353
|
import { access as access7, stat as stat5, writeFile as writeFile6 } from "node:fs/promises";
|
|
28234
27354
|
import { tmpdir } from "node:os";
|
|
@@ -28241,28 +27361,21 @@ function buildGenerateComponentsArgs(opts) {
|
|
|
28241
27361
|
if (opts.tokensPath) args.push("--tokens", opts.tokensPath);
|
|
28242
27362
|
if (opts.model) args.push("--model", opts.model);
|
|
28243
27363
|
if (opts.bedrock) args.push("--bedrock");
|
|
28244
|
-
if (opts.noCache) args.push("--no-cache");
|
|
28245
27364
|
if (opts.generatePromptPath) args.push("--generate-prompt-path", opts.generatePromptPath);
|
|
28246
27365
|
for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
|
|
28247
27366
|
if (opts.existingEntitiesPath) args.push("--existing-entities-path", opts.existingEntitiesPath);
|
|
28248
|
-
if (opts.restoreCache) args.push("--restore-cache");
|
|
28249
|
-
if (opts.cachedComponents && opts.cachedComponents.length > 0) {
|
|
28250
|
-
args.push("--cached-components", JSON.stringify(opts.cachedComponents));
|
|
28251
|
-
}
|
|
28252
27367
|
return args;
|
|
28253
27368
|
}
|
|
28254
27369
|
function buildGenerateTokensArgs(opts) {
|
|
28255
27370
|
const args = [findCliPath(), "__generate", "tokens", "--agent", opts.agent, "--raw-tokens", opts.rawTokensPath];
|
|
28256
27371
|
if (opts.model) args.push("--model", opts.model);
|
|
28257
27372
|
if (opts.bedrock) args.push("--bedrock");
|
|
28258
|
-
if (opts.noCache) args.push("--no-cache");
|
|
28259
27373
|
for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
|
|
28260
27374
|
return args;
|
|
28261
27375
|
}
|
|
28262
27376
|
function buildMapTokensArgs(opts) {
|
|
28263
27377
|
const args = ["map", "tokens", "--session", opts.sessionId, "--agent", opts.agent];
|
|
28264
27378
|
if (opts.model) args.push("--model", opts.model);
|
|
28265
|
-
if (opts.noCache) args.push("--no-cache");
|
|
28266
27379
|
if (opts.skipAgent) args.push("--skip-agent");
|
|
28267
27380
|
for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
|
|
28268
27381
|
if (opts.existingEntitiesPath) args.push("--existing-entities-path", opts.existingEntitiesPath);
|
|
@@ -28354,7 +27467,6 @@ function WizardApp({
|
|
|
28354
27467
|
initialProjectPath,
|
|
28355
27468
|
host,
|
|
28356
27469
|
promptOverrides,
|
|
28357
|
-
noCache = false,
|
|
28358
27470
|
livePreview = true,
|
|
28359
27471
|
generatePromptPath,
|
|
28360
27472
|
skipMapTokens = false,
|
|
@@ -28379,7 +27491,6 @@ function WizardApp({
|
|
|
28379
27491
|
});
|
|
28380
27492
|
const allowEmptyDeleteAllRef = useRef10(false);
|
|
28381
27493
|
const generateChildRef = useRef10(null);
|
|
28382
|
-
const generationCachePreflightRef = useRef10(null);
|
|
28383
27494
|
const selectionToReviewStartedAtRef = useRef10(null);
|
|
28384
27495
|
const credentialsValidationIdRef = useRef10(0);
|
|
28385
27496
|
const pendingCredentialValidationRef = useRef10(null);
|
|
@@ -28394,9 +27505,8 @@ function WizardApp({
|
|
|
28394
27505
|
const existingEntitiesPromiseRef = useRef10(null);
|
|
28395
27506
|
const generatePromiseRef = useRef10(null);
|
|
28396
27507
|
const rawTokensEntryReady = !!initialRawTokensPath;
|
|
28397
|
-
const effectiveNoCache = resolveNoCacheForGenerate({ cliNoCache: noCache });
|
|
28398
27508
|
const initialStepResolved = rawTokensEntryReady ? initialProjectPath ? "path-validation" : "credentials" : initialProjectPath ? "token-input" : "welcome";
|
|
28399
|
-
const initialOutDir = initialProjectPath ? join23(
|
|
27509
|
+
const initialOutDir = initialProjectPath ? join23(resolve17(initialProjectPath), ".contentful") : "";
|
|
28400
27510
|
const [state, setState] = useState23({
|
|
28401
27511
|
step: initialStepResolved,
|
|
28402
27512
|
agent: initialAgent ?? "claude",
|
|
@@ -28572,14 +27682,13 @@ If you are using AWS Bedrock, run:
|
|
|
28572
27682
|
if (!deferStep) update({ step: nextStep });
|
|
28573
27683
|
return true;
|
|
28574
27684
|
};
|
|
28575
|
-
const runGenerateTokens = async (rawTokensPath, outDir
|
|
27685
|
+
const runGenerateTokens = async (rawTokensPath, outDir) => {
|
|
28576
27686
|
update({ tokenGenerationStatus: "running" });
|
|
28577
27687
|
const tokenArgs = buildGenerateTokensArgs({
|
|
28578
27688
|
rawTokensPath,
|
|
28579
27689
|
agent: state.agent,
|
|
28580
27690
|
...state.agentModel ? { model: state.agentModel } : {},
|
|
28581
27691
|
...state.bedrock ? { bedrock: true } : {},
|
|
28582
|
-
noCache: effectiveNoCache || forceRegenerate,
|
|
28583
27692
|
promptOverrides
|
|
28584
27693
|
});
|
|
28585
27694
|
const result = await runSpawnedCli(tokenArgs);
|
|
@@ -28628,7 +27737,6 @@ If you are using AWS Bedrock, run:
|
|
|
28628
27737
|
const timer = startWizardTimer("token-mapping", {
|
|
28629
27738
|
sessionId: sessionId2,
|
|
28630
27739
|
silent,
|
|
28631
|
-
noCache: effectiveNoCache,
|
|
28632
27740
|
skipAgent: skipMapTokens
|
|
28633
27741
|
});
|
|
28634
27742
|
let mappablePropCount = 0;
|
|
@@ -28637,7 +27745,7 @@ If you are using AWS Bedrock, run:
|
|
|
28637
27745
|
const db = openPipelineDb();
|
|
28638
27746
|
try {
|
|
28639
27747
|
if (state.tokenSessionId && state.tokenSessionId !== sessionId2) {
|
|
28640
|
-
|
|
27748
|
+
copyTokensBetweenSessions(db, state.tokenSessionId, sessionId2);
|
|
28641
27749
|
} else if (!state.tokenSessionId && state.tokensPath) {
|
|
28642
27750
|
const tokens = await readTokensFromPath("tokens", state.tokensPath);
|
|
28643
27751
|
storeDtcgTokens(db, sessionId2, [], tokens);
|
|
@@ -28677,7 +27785,6 @@ If you are using AWS Bedrock, run:
|
|
|
28677
27785
|
sessionId: sessionId2,
|
|
28678
27786
|
agent: state.agent,
|
|
28679
27787
|
...state.agentModel ? { model: state.agentModel } : {},
|
|
28680
|
-
noCache: effectiveNoCache,
|
|
28681
27788
|
skipAgent: skipMapTokens,
|
|
28682
27789
|
promptOverrides,
|
|
28683
27790
|
...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {}
|
|
@@ -28757,7 +27864,7 @@ If you are using AWS Bedrock, run:
|
|
|
28757
27864
|
return promise;
|
|
28758
27865
|
};
|
|
28759
27866
|
const runExtract = async (projectPath, showProgress = true) => {
|
|
28760
|
-
const outDir = join23(
|
|
27867
|
+
const outDir = join23(resolve17(projectPath), ".contentful");
|
|
28761
27868
|
const existingEntitiesExpected = !state.credentialsSkipped && Boolean(state.spaceId && state.environmentId && state.cmaToken && projectPath);
|
|
28762
27869
|
update({
|
|
28763
27870
|
...showProgress ? { step: "extracting" } : {},
|
|
@@ -28772,7 +27879,6 @@ If you are using AWS Bedrock, run:
|
|
|
28772
27879
|
});
|
|
28773
27880
|
const existingEntitiesPromise = startExistingEntitiesFetch(projectPath, outDir);
|
|
28774
27881
|
const extractArgs = [findCliPath(), "__extract", "--project", projectPath];
|
|
28775
|
-
if (effectiveNoCache) extractArgs.push("--no-cache");
|
|
28776
27882
|
let selectionPromptText;
|
|
28777
27883
|
let selectionPromptPath;
|
|
28778
27884
|
try {
|
|
@@ -28781,7 +27887,7 @@ If you are using AWS Bedrock, run:
|
|
|
28781
27887
|
const selectOverride = overrides.get("select");
|
|
28782
27888
|
if (selectOverride?.kind === "text") selectionPromptText = selectOverride.value;
|
|
28783
27889
|
if (selectOverride?.kind === "path") {
|
|
28784
|
-
selectionPromptPath =
|
|
27890
|
+
selectionPromptPath = resolve17(selectOverride.value);
|
|
28785
27891
|
await resolvePromptOverride(selectOverride);
|
|
28786
27892
|
}
|
|
28787
27893
|
} catch (error) {
|
|
@@ -28805,8 +27911,7 @@ If you are using AWS Bedrock, run:
|
|
|
28805
27911
|
agent: state.agent,
|
|
28806
27912
|
...state.agentModel ? { model: state.agentModel } : {},
|
|
28807
27913
|
...selectionPromptText !== void 0 ? { promptText: selectionPromptText } : {},
|
|
28808
|
-
...selectionPromptPath ? { promptPath: selectionPromptPath } : {}
|
|
28809
|
-
noCache: effectiveNoCache
|
|
27914
|
+
...selectionPromptPath ? { promptPath: selectionPromptPath } : {}
|
|
28810
27915
|
});
|
|
28811
27916
|
})().catch((error) => {
|
|
28812
27917
|
selectionError = error;
|
|
@@ -28951,136 +28056,17 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28951
28056
|
generateProgress: null
|
|
28952
28057
|
}));
|
|
28953
28058
|
};
|
|
28954
|
-
const buildGenerateOptions = (extractSessionId, tokensPath, generatePromptPath2
|
|
28059
|
+
const buildGenerateOptions = (extractSessionId, tokensPath, generatePromptPath2) => ({
|
|
28955
28060
|
sessionId: extractSessionId,
|
|
28956
28061
|
tokensPath,
|
|
28957
28062
|
agent: state.agent,
|
|
28958
28063
|
...state.agentModel ? { model: state.agentModel } : {},
|
|
28959
28064
|
...state.bedrock ? { bedrock: true } : {},
|
|
28960
|
-
noCache: effectiveNoCache,
|
|
28961
28065
|
...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {},
|
|
28962
28066
|
...generatePromptPath2 ? { generatePromptPath: generatePromptPath2 } : {},
|
|
28963
|
-
promptOverrides
|
|
28964
|
-
...cachedComponents && cachedComponents.length > 0 ? { cachedComponents } : {}
|
|
28067
|
+
promptOverrides
|
|
28965
28068
|
});
|
|
28966
|
-
const buildGenerateArgs = (extractSessionId, tokensPath, generatePromptPath2
|
|
28967
|
-
const buildGenerateCliArgs = (extractSessionId, tokensPath, generatePromptPath2, cachedComponents) => buildGenerateComponentsArgs(
|
|
28968
|
-
buildGenerateOptions(extractSessionId, tokensPath, generatePromptPath2, cachedComponents)
|
|
28969
|
-
);
|
|
28970
|
-
const checkGenerateCache = async (extractSessionId, tokensPath) => {
|
|
28971
|
-
const timer = startWizardTimer("generation-cache-status", {
|
|
28972
|
-
sessionId: extractSessionId,
|
|
28973
|
-
noCache: effectiveNoCache
|
|
28974
|
-
});
|
|
28975
|
-
if (effectiveNoCache) {
|
|
28976
|
-
finishWizardTimer("generation-cache-status", timer, { status: "skipped" });
|
|
28977
|
-
return false;
|
|
28978
|
-
}
|
|
28979
|
-
const result = await runCli([...buildGenerateCliArgs(extractSessionId, tokensPath), "--cache-status"]);
|
|
28980
|
-
const hit = result.exitCode === 0 && /^cache-status=hit$/m.test(result.stdout);
|
|
28981
|
-
finishWizardTimer("generation-cache-status", timer, {
|
|
28982
|
-
status: hit ? "hit" : "miss",
|
|
28983
|
-
exitCode: result.exitCode,
|
|
28984
|
-
...result.exitCode !== 0 ? { stderrTail: result.stderr.trim().slice(-500) } : {}
|
|
28985
|
-
});
|
|
28986
|
-
return hit;
|
|
28987
|
-
};
|
|
28988
|
-
const checkGenerateCacheComponents = async (extractSessionId, tokensPath, restoreCache = false) => {
|
|
28989
|
-
const timer = startWizardTimer("generation-cache-components", {
|
|
28990
|
-
sessionId: extractSessionId,
|
|
28991
|
-
restoreCache,
|
|
28992
|
-
noCache: effectiveNoCache
|
|
28993
|
-
});
|
|
28994
|
-
if (effectiveNoCache) {
|
|
28995
|
-
finishWizardTimer("generation-cache-components", timer, { status: "skipped" });
|
|
28996
|
-
return /* @__PURE__ */ new Set();
|
|
28997
|
-
}
|
|
28998
|
-
const args = [...buildGenerateCliArgs(extractSessionId, tokensPath), "--cache-status"];
|
|
28999
|
-
if (restoreCache) args.push("--restore-cache");
|
|
29000
|
-
const result = await runCli(args);
|
|
29001
|
-
if (result.exitCode !== 0) {
|
|
29002
|
-
finishWizardTimer("generation-cache-components", timer, {
|
|
29003
|
-
status: "error",
|
|
29004
|
-
exitCode: result.exitCode,
|
|
29005
|
-
stderrTail: result.stderr.trim().slice(-500)
|
|
29006
|
-
});
|
|
29007
|
-
return /* @__PURE__ */ new Set();
|
|
29008
|
-
}
|
|
29009
|
-
const line = /^cache-components=(.+)$/m.exec(result.stdout)?.[1];
|
|
29010
|
-
if (!line) {
|
|
29011
|
-
finishWizardTimer("generation-cache-components", timer, {
|
|
29012
|
-
status: "missing-output",
|
|
29013
|
-
exitCode: result.exitCode,
|
|
29014
|
-
cachedCount: 0
|
|
29015
|
-
});
|
|
29016
|
-
return /* @__PURE__ */ new Set();
|
|
29017
|
-
}
|
|
29018
|
-
try {
|
|
29019
|
-
const names = JSON.parse(line);
|
|
29020
|
-
const cachedNames = new Set(
|
|
29021
|
-
Array.isArray(names) ? names.filter((name) => typeof name === "string") : []
|
|
29022
|
-
);
|
|
29023
|
-
finishWizardTimer("generation-cache-components", timer, {
|
|
29024
|
-
status: "complete",
|
|
29025
|
-
exitCode: result.exitCode,
|
|
29026
|
-
cachedCount: cachedNames.size
|
|
29027
|
-
});
|
|
29028
|
-
return cachedNames;
|
|
29029
|
-
} catch {
|
|
29030
|
-
finishWizardTimer("generation-cache-components", timer, {
|
|
29031
|
-
status: "invalid-output",
|
|
29032
|
-
exitCode: result.exitCode,
|
|
29033
|
-
cachedCount: 0
|
|
29034
|
-
});
|
|
29035
|
-
return /* @__PURE__ */ new Set();
|
|
29036
|
-
}
|
|
29037
|
-
};
|
|
29038
|
-
useEffect15(() => {
|
|
29039
|
-
if (state.step !== "extracting" && state.step !== "scope-gate" || !state.extractSessionId || state.existingEntitiesStatus === "running" || state.existingEntitiesStatus === "idle" || state.selectionAgentStatus !== "complete" || state.compositionPhase !== "done" || state.rawTokensPath && state.tokenGenerationStatus !== "complete" || effectiveNoCache) {
|
|
29040
|
-
return;
|
|
29041
|
-
}
|
|
29042
|
-
const sessionId2 = state.extractSessionId;
|
|
29043
|
-
if (generationCachePreflightRef.current?.sessionId === sessionId2) return;
|
|
29044
|
-
const timer = startWizardTimer("generation-cache-preflight", { sessionId: sessionId2 });
|
|
29045
|
-
const db = openPipelineDb();
|
|
29046
|
-
let generatedNames = null;
|
|
29047
|
-
try {
|
|
29048
|
-
const rows = db.prepare("SELECT name, status FROM raw_components WHERE session_id = ?").all(sessionId2);
|
|
29049
|
-
if (rows.length > 0 && rows.every((row) => row.status === "generated")) {
|
|
29050
|
-
generatedNames = new Set(rows.map((row) => row.name));
|
|
29051
|
-
}
|
|
29052
|
-
} finally {
|
|
29053
|
-
db.close();
|
|
29054
|
-
}
|
|
29055
|
-
if (generatedNames) {
|
|
29056
|
-
generationCachePreflightRef.current = { sessionId: sessionId2, promise: Promise.resolve(generatedNames) };
|
|
29057
|
-
finishWizardTimer("generation-cache-preflight", timer, {
|
|
29058
|
-
status: "complete",
|
|
29059
|
-
source: "session-db",
|
|
29060
|
-
cachedCount: generatedNames.size
|
|
29061
|
-
});
|
|
29062
|
-
return;
|
|
29063
|
-
}
|
|
29064
|
-
const promise = checkGenerateCacheComponents(sessionId2, state.tokensPath, true);
|
|
29065
|
-
generationCachePreflightRef.current = { sessionId: sessionId2, promise };
|
|
29066
|
-
void promise.then((cachedNames) => {
|
|
29067
|
-
finishWizardTimer("generation-cache-preflight", timer, {
|
|
29068
|
-
status: "complete",
|
|
29069
|
-
source: "cache-status",
|
|
29070
|
-
cachedCount: cachedNames.size
|
|
29071
|
-
});
|
|
29072
|
-
});
|
|
29073
|
-
}, [
|
|
29074
|
-
state.step,
|
|
29075
|
-
state.extractSessionId,
|
|
29076
|
-
state.tokensPath,
|
|
29077
|
-
state.rawTokensPath,
|
|
29078
|
-
state.tokenGenerationStatus,
|
|
29079
|
-
state.selectionAgentStatus,
|
|
29080
|
-
state.compositionPhase,
|
|
29081
|
-
state.existingEntitiesStatus,
|
|
29082
|
-
state.existingEntitiesPath
|
|
29083
|
-
]);
|
|
28069
|
+
const buildGenerateArgs = (extractSessionId, tokensPath, generatePromptPath2) => buildGenerateProcessArgs(buildGenerateOptions(extractSessionId, tokensPath, generatePromptPath2));
|
|
29084
28070
|
const startGeneratePrefetch = (extractSessionId, tokensPath) => {
|
|
29085
28071
|
const args = buildGenerateArgs(extractSessionId, tokensPath);
|
|
29086
28072
|
let progressCursor = null;
|
|
@@ -29135,14 +28121,13 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
29135
28121
|
});
|
|
29136
28122
|
return donePromise;
|
|
29137
28123
|
};
|
|
29138
|
-
const runGenerate = async (extractSessionId, tokensPath, acceptedCount, suppressScreen = false
|
|
28124
|
+
const runGenerate = async (extractSessionId, tokensPath, acceptedCount, suppressScreen = false) => {
|
|
29139
28125
|
const timer = startWizardTimer("component-generation", {
|
|
29140
28126
|
sessionId: extractSessionId,
|
|
29141
28127
|
acceptedCount,
|
|
29142
|
-
suppressScreen
|
|
29143
|
-
noCache: effectiveNoCache
|
|
28128
|
+
suppressScreen
|
|
29144
28129
|
});
|
|
29145
|
-
const args = buildGenerateArgs(extractSessionId, tokensPath, generatePromptPath
|
|
28130
|
+
const args = buildGenerateArgs(extractSessionId, tokensPath, generatePromptPath);
|
|
29146
28131
|
let progressCursor = state.generateProgress;
|
|
29147
28132
|
const { donePromise } = spawnGenerateChild({
|
|
29148
28133
|
command: "node",
|
|
@@ -29212,25 +28197,6 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
29212
28197
|
finishSelectionToReviewTimer("error");
|
|
29213
28198
|
}
|
|
29214
28199
|
};
|
|
29215
|
-
const finishCachedGeneration = async (sessionId2, acceptedCount) => {
|
|
29216
|
-
if (await runMapTokens2(sessionId2, true)) {
|
|
29217
|
-
finishSelectionToReviewTimer("cached");
|
|
29218
|
-
update(
|
|
29219
|
-
{
|
|
29220
|
-
acceptedCount,
|
|
29221
|
-
autoRejectedCount: 0,
|
|
29222
|
-
generateSessionId: sessionId2,
|
|
29223
|
-
generatedCount: acceptedCount,
|
|
29224
|
-
generateProgress: null,
|
|
29225
|
-
mapTokensStatus: "complete",
|
|
29226
|
-
step: "final-review"
|
|
29227
|
-
},
|
|
29228
|
-
{ clearScreen: false }
|
|
29229
|
-
);
|
|
29230
|
-
} else {
|
|
29231
|
-
finishSelectionToReviewTimer("error");
|
|
29232
|
-
}
|
|
29233
|
-
};
|
|
29234
28200
|
const advanceToPushFlow = (generatedAcceptedCount) => {
|
|
29235
28201
|
update({ generatedAcceptedCount });
|
|
29236
28202
|
void runSaveAndPush();
|
|
@@ -29415,14 +28381,8 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
29415
28381
|
}
|
|
29416
28382
|
}
|
|
29417
28383
|
if (await runAgentAuthCheck("generating", true)) {
|
|
29418
|
-
|
|
29419
|
-
|
|
29420
|
-
update({ step: "generating" });
|
|
29421
|
-
void finishCachedGeneration(sid, state.acceptedCount);
|
|
29422
|
-
} else {
|
|
29423
|
-
update({ step: "generating" });
|
|
29424
|
-
void runGenerate(sid, state.tokensPath, state.acceptedCount);
|
|
29425
|
-
}
|
|
28384
|
+
update({ step: "generating" });
|
|
28385
|
+
void runGenerate(sid, state.tokensPath, state.acceptedCount);
|
|
29426
28386
|
}
|
|
29427
28387
|
return;
|
|
29428
28388
|
}
|
|
@@ -29786,7 +28746,7 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
29786
28746
|
});
|
|
29787
28747
|
return { ok: false };
|
|
29788
28748
|
}
|
|
29789
|
-
await new Promise((
|
|
28749
|
+
await new Promise((resolve20) => setTimeout(resolve20, SAVE_CONFIRMATION_DELAY_MS));
|
|
29790
28750
|
update(nextStateAfterPrint({ skipGate: opts.skipGate, componentsPath }));
|
|
29791
28751
|
return { ok: true };
|
|
29792
28752
|
};
|
|
@@ -29863,12 +28823,6 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
29863
28823
|
tokenReuseChecked.current = true;
|
|
29864
28824
|
const tokenNextStep = state.projectPath ? "path-validation" : "credentials";
|
|
29865
28825
|
const existingTokensPath = join23(state.outDir, "tokens.json");
|
|
29866
|
-
if (effectiveNoCache) {
|
|
29867
|
-
tokenGenerationPromiseRef.current = runAgentAuthCheck(tokenNextStep).then(
|
|
29868
|
-
(ok2) => ok2 ? runGenerateTokens(state.rawTokensPath, state.outDir) : false
|
|
29869
|
-
);
|
|
29870
|
-
return;
|
|
29871
|
-
}
|
|
29872
28826
|
(async () => {
|
|
29873
28827
|
try {
|
|
29874
28828
|
await access7(existingTokensPath);
|
|
@@ -29952,7 +28906,7 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
29952
28906
|
const tokenNextStep = state.projectPath ? "path-validation" : "credentials";
|
|
29953
28907
|
update({ step: tokenNextStep });
|
|
29954
28908
|
if (await runAgentAuthCheck(tokenNextStep)) {
|
|
29955
|
-
tokenGenerationPromiseRef.current = runGenerateTokens(state.rawTokensPath, state.outDir
|
|
28909
|
+
tokenGenerationPromiseRef.current = runGenerateTokens(state.rawTokensPath, state.outDir);
|
|
29956
28910
|
}
|
|
29957
28911
|
},
|
|
29958
28912
|
onQuit: () => process.exit(0)
|
|
@@ -30051,29 +29005,6 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
30051
29005
|
acceptedCount: decisions.accepted.length,
|
|
30052
29006
|
rejectedCount: decisions.rejected.length
|
|
30053
29007
|
}) : null;
|
|
30054
|
-
const preflight = generationCachePreflightRef.current;
|
|
30055
|
-
const cachePromise = preflight?.sessionId === sessionId2 ? preflight.promise : checkGenerateCacheComponents(sessionId2, state.tokensPath, true);
|
|
30056
|
-
if (!preflight || preflight.sessionId !== sessionId2) {
|
|
30057
|
-
generationCachePreflightRef.current = { sessionId: sessionId2, promise: cachePromise };
|
|
30058
|
-
}
|
|
30059
|
-
const cacheWaitStartedAt = startWizardTimer("selection-cache-restoration-wait", {
|
|
30060
|
-
sessionId: sessionId2,
|
|
30061
|
-
preflight: Boolean(preflight?.sessionId === sessionId2)
|
|
30062
|
-
});
|
|
30063
|
-
try {
|
|
30064
|
-
const cachedNames = await cachePromise;
|
|
30065
|
-
finishWizardTimer("selection-cache-restoration-wait", cacheWaitStartedAt, {
|
|
30066
|
-
status: "complete",
|
|
30067
|
-
cachedCount: cachedNames.size
|
|
30068
|
-
});
|
|
30069
|
-
} catch (error) {
|
|
30070
|
-
finishWizardTimer("selection-cache-restoration-wait", cacheWaitStartedAt, {
|
|
30071
|
-
status: "error",
|
|
30072
|
-
error: error instanceof Error ? error.message : String(error)
|
|
30073
|
-
});
|
|
30074
|
-
finishSelectionToReviewTimer("error");
|
|
30075
|
-
throw error;
|
|
30076
|
-
}
|
|
30077
29008
|
await runScopeGate({
|
|
30078
29009
|
sessionId: sessionId2,
|
|
30079
29010
|
decisions,
|
|
@@ -30082,35 +29013,12 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
30082
29013
|
if (shouldGenerateAfterScopeGate({ acceptedCount })) {
|
|
30083
29014
|
const authPromise = runAgentAuthCheck("generating", true);
|
|
30084
29015
|
if (await authPromise) {
|
|
30085
|
-
|
|
30086
|
-
|
|
30087
|
-
|
|
30088
|
-
|
|
30089
|
-
let cachedNames = await cachePromise;
|
|
30090
|
-
const acceptedNames = decisions?.accepted ?? [];
|
|
30091
|
-
let cacheHit = !effectiveNoCache && acceptedNames.length > 0 && acceptedNames.every((name) => cachedNames.has(name));
|
|
30092
|
-
if (!cacheHit && !effectiveNoCache && acceptedNames.length > 0) {
|
|
30093
|
-
cachedNames = await checkGenerateCacheComponents(sid, state.tokensPath, true);
|
|
30094
|
-
cacheHit = acceptedNames.every((name) => cachedNames.has(name));
|
|
30095
|
-
}
|
|
30096
|
-
finishWizardTimer("generation-cache-set-comparison", comparisonStartedAt, {
|
|
30097
|
-
status: "complete",
|
|
30098
|
-
cacheHit,
|
|
30099
|
-
cachedCount: cachedNames.size,
|
|
30100
|
-
acceptedCount: acceptedNames.length
|
|
29016
|
+
update({
|
|
29017
|
+
step: "generating",
|
|
29018
|
+
generateProgress: null,
|
|
29019
|
+
acceptedCount
|
|
30101
29020
|
});
|
|
30102
|
-
|
|
30103
|
-
void finishCachedGeneration(sid, acceptedCount);
|
|
30104
|
-
} else {
|
|
30105
|
-
const acceptedNameSet = new Set(acceptedNames);
|
|
30106
|
-
const restoredCachedNames = [...cachedNames].filter((name) => acceptedNameSet.has(name));
|
|
30107
|
-
update({
|
|
30108
|
-
step: "generating",
|
|
30109
|
-
generateProgress: null,
|
|
30110
|
-
acceptedCount
|
|
30111
|
-
});
|
|
30112
|
-
void runGenerate(sid, state.tokensPath, acceptedCount, false, restoredCachedNames);
|
|
30113
|
-
}
|
|
29021
|
+
void runGenerate(sid, state.tokensPath, acceptedCount);
|
|
30114
29022
|
} else {
|
|
30115
29023
|
finishSelectionToReviewTimer("error");
|
|
30116
29024
|
}
|
|
@@ -30476,7 +29384,7 @@ function registerImportCommand(program) {
|
|
|
30476
29384
|
"Override a composition, selection, token, generation, or token-mapping prompt (repeatable). value is a file path or literal text, e.g. --prompt select=./p.md",
|
|
30477
29385
|
(v, acc) => [...acc, v],
|
|
30478
29386
|
[]
|
|
30479
|
-
).
|
|
29387
|
+
).action(async (opts) => {
|
|
30480
29388
|
const interactiveTerminalSupported = getInteractiveTerminalSupport().supported;
|
|
30481
29389
|
if (opts.tokens !== void 0) {
|
|
30482
29390
|
const { access: access9 } = await import("node:fs/promises");
|
|
@@ -30513,7 +29421,6 @@ function registerImportCommand(program) {
|
|
|
30513
29421
|
...resolvedModel ? { initialModel: resolvedModel } : {},
|
|
30514
29422
|
initialProjectPath: opts.project !== "." ? normalizePath(opts.project) : void 0,
|
|
30515
29423
|
...buildCompositionForwardingOptions(opts),
|
|
30516
|
-
noCache: opts.cache === false,
|
|
30517
29424
|
skipMapTokens: false,
|
|
30518
29425
|
livePreview: true,
|
|
30519
29426
|
generatePromptPath: creds.generatePromptPath,
|
|
@@ -30601,7 +29508,7 @@ async function pathExists3(path) {
|
|
|
30601
29508
|
return access8(path).then(() => true).catch(() => false);
|
|
30602
29509
|
}
|
|
30603
29510
|
function runSpawn(cmd, args, opts = {}) {
|
|
30604
|
-
return new Promise((
|
|
29511
|
+
return new Promise((resolve20) => {
|
|
30605
29512
|
const child = spawn6(cmd, args, {
|
|
30606
29513
|
cwd: opts.cwd,
|
|
30607
29514
|
env: opts.env ?? process.env,
|
|
@@ -30613,7 +29520,7 @@ function runSpawn(cmd, args, opts = {}) {
|
|
|
30613
29520
|
const settle = (result) => {
|
|
30614
29521
|
if (settled) return;
|
|
30615
29522
|
settled = true;
|
|
30616
|
-
|
|
29523
|
+
resolve20(result);
|
|
30617
29524
|
};
|
|
30618
29525
|
child.on("error", (err) => settle({ exitCode: 1, stdout: "", stderr: err.message }));
|
|
30619
29526
|
child.stdout.on("data", (d) => {
|
|
@@ -31814,13 +30721,13 @@ function PrerequisitesScreen({
|
|
|
31814
30721
|
const driver = {
|
|
31815
30722
|
...base,
|
|
31816
30723
|
emit: (event) => setEvents((current) => [...current, event]),
|
|
31817
|
-
confirm: (question, defaultYes = true) => new Promise((
|
|
30724
|
+
confirm: (question, defaultYes = true) => new Promise((resolve20) => {
|
|
31818
30725
|
setConfirm({
|
|
31819
30726
|
question,
|
|
31820
30727
|
defaultYes,
|
|
31821
30728
|
resolve: (answer) => {
|
|
31822
30729
|
setConfirm(null);
|
|
31823
|
-
|
|
30730
|
+
resolve20(answer);
|
|
31824
30731
|
}
|
|
31825
30732
|
});
|
|
31826
30733
|
})
|
|
@@ -31895,8 +30802,8 @@ function SetupScreen({
|
|
|
31895
30802
|
useEffect21(() => {
|
|
31896
30803
|
if (startedRef.current) return;
|
|
31897
30804
|
startedRef.current = true;
|
|
31898
|
-
const runScreen = (build) => new Promise((
|
|
31899
|
-
setScreen(build(
|
|
30805
|
+
const runScreen = (build) => new Promise((resolve20) => {
|
|
30806
|
+
setScreen(build(resolve20));
|
|
31900
30807
|
});
|
|
31901
30808
|
void (async () => {
|
|
31902
30809
|
const results = [];
|
|
@@ -32504,11 +31411,8 @@ var init_source_call_site_evidence = __esm({
|
|
|
32504
31411
|
});
|
|
32505
31412
|
|
|
32506
31413
|
// packages/experience-design-system-cli-legacy/src/analyze/extract-command.ts
|
|
32507
|
-
import { mkdir as mkdir6, readdir as readdir3, readFile as
|
|
32508
|
-
import { isAbsolute as isAbsolute2, join as join27, relative as relative2, resolve as
|
|
32509
|
-
function resolveExtractNoCache(opts) {
|
|
32510
|
-
return opts.noCache === true || opts.cache === false;
|
|
32511
|
-
}
|
|
31414
|
+
import { mkdir as mkdir6, readdir as readdir3, readFile as readFile18, stat as stat6 } from "node:fs/promises";
|
|
31415
|
+
import { isAbsolute as isAbsolute2, join as join27, relative as relative2, resolve as resolve18 } from "node:path";
|
|
32512
31416
|
function isDenylistedNoiseFile(name) {
|
|
32513
31417
|
return DENYLISTED_EXACT_FILE_NAMES.has(name) || DENYLISTED_FILE_NAME_PATTERNS.some((pattern) => pattern.test(name));
|
|
32514
31418
|
}
|
|
@@ -32522,12 +31426,12 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
32522
31426
|
} catch (error) {
|
|
32523
31427
|
const message = error instanceof Error ? error.message : String(error);
|
|
32524
31428
|
if (!/database is locked|database is busy/i.test(message) || attempt >= attempts) throw error;
|
|
32525
|
-
await new Promise((
|
|
31429
|
+
await new Promise((resolve20) => setTimeout(resolve20, Math.min(250 * attempt, 2e3)));
|
|
32526
31430
|
}
|
|
32527
31431
|
}
|
|
32528
31432
|
}
|
|
32529
31433
|
function resolveFromProjectRoot(projectRoot, inputPath) {
|
|
32530
|
-
return isAbsolute2(inputPath) ? inputPath :
|
|
31434
|
+
return isAbsolute2(inputPath) ? inputPath : resolve18(projectRoot, inputPath);
|
|
32531
31435
|
}
|
|
32532
31436
|
async function pathExists4(path) {
|
|
32533
31437
|
return Boolean(await stat6(path).catch(() => null));
|
|
@@ -32574,7 +31478,7 @@ async function readCandidateFiles(components, extraFiles = []) {
|
|
|
32574
31478
|
await Promise.all(
|
|
32575
31479
|
[...paths].map(async (p) => {
|
|
32576
31480
|
try {
|
|
32577
|
-
const content = await
|
|
31481
|
+
const content = await readFile18(p, "utf8");
|
|
32578
31482
|
out.push({ path: p, content });
|
|
32579
31483
|
} catch {
|
|
32580
31484
|
}
|
|
@@ -32587,8 +31491,7 @@ function registerInternalExtractCommand(program) {
|
|
|
32587
31491
|
"--resolve-unreachable <mode>",
|
|
32588
31492
|
"Retry pass for unresolved Svelte Props types: 'auto' (default), 'always', or 'never'",
|
|
32589
31493
|
"auto"
|
|
32590
|
-
).
|
|
32591
|
-
const noCache = resolveExtractNoCache(opts);
|
|
31494
|
+
).action(async (opts) => {
|
|
32592
31495
|
const resolveUnreachable = (() => {
|
|
32593
31496
|
const v = opts.resolveUnreachable ?? "auto";
|
|
32594
31497
|
if (v !== "auto" && v !== "always" && v !== "never") {
|
|
@@ -32598,7 +31501,7 @@ function registerInternalExtractCommand(program) {
|
|
|
32598
31501
|
}
|
|
32599
31502
|
return v;
|
|
32600
31503
|
})();
|
|
32601
|
-
const projectRoot =
|
|
31504
|
+
const projectRoot = resolve18(opts.project);
|
|
32602
31505
|
const outDir = join27(projectRoot, ".contentful");
|
|
32603
31506
|
let sourceDirectory;
|
|
32604
31507
|
if (opts.dir !== void 0) {
|
|
@@ -32622,50 +31525,16 @@ function registerInternalExtractCommand(program) {
|
|
|
32622
31525
|
process.stderr.write(`progress=scan-done:${sourceFiles.length}
|
|
32623
31526
|
`);
|
|
32624
31527
|
}
|
|
32625
|
-
const
|
|
32626
|
-
|
|
32627
|
-
|
|
32628
|
-
try {
|
|
32629
|
-
const cacheVersion = await getCliCacheVersion();
|
|
32630
|
-
const cachedByPath = /* @__PURE__ */ new Map();
|
|
32631
|
-
if (!noCache && sourceFiles.length > 0) {
|
|
32632
|
-
const hashes = await Promise.all(
|
|
32633
|
-
sourceFiles.map(async (filePath) => [filePath, await hashFile(filePath)])
|
|
32634
|
-
);
|
|
32635
|
-
for (const [filePath, fileHash] of hashes) {
|
|
32636
|
-
cachedByPath.set(filePath, lookupExtractCache(extractionCacheDb, fileHash, cacheVersion));
|
|
32637
|
-
}
|
|
32638
|
-
}
|
|
32639
|
-
const allFilesCached = !noCache && sourceFiles.length > 0 && sourceFiles.every((filePath) => cachedByPath.get(filePath) !== null);
|
|
32640
|
-
if (allFilesCached) {
|
|
32641
|
-
const cachedComponents = sourceFiles.flatMap((filePath) => cachedByPath.get(filePath).components);
|
|
32642
|
-
extractionCacheHits = sourceFiles.length;
|
|
32643
|
-
extraction = { components: cachedComponents, warnings: [], exclusions: [] };
|
|
31528
|
+
const extraction = await extractComponents(
|
|
31529
|
+
sourceFiles,
|
|
31530
|
+
({ filesProcessed, componentsFound }) => {
|
|
32644
31531
|
if (!process.stdout.isTTY) {
|
|
32645
|
-
process.stderr.write(
|
|
32646
|
-
`progress=extract:${sourceFiles.length}/${sourceFiles.length}:${cachedComponents.length}
|
|
32647
|
-
`
|
|
32648
|
-
);
|
|
32649
|
-
}
|
|
32650
|
-
getDebugLogger().event("analyze", "extract.cache-hit", {
|
|
32651
|
-
files: sourceFiles.length,
|
|
32652
|
-
components: cachedComponents.length
|
|
32653
|
-
});
|
|
32654
|
-
} else {
|
|
32655
|
-
extraction = await extractComponents(
|
|
32656
|
-
sourceFiles,
|
|
32657
|
-
({ filesProcessed, componentsFound }) => {
|
|
32658
|
-
if (!process.stdout.isTTY) {
|
|
32659
|
-
process.stderr.write(`progress=extract:${filesProcessed}/${sourceFiles.length}:${componentsFound}
|
|
31532
|
+
process.stderr.write(`progress=extract:${filesProcessed}/${sourceFiles.length}:${componentsFound}
|
|
32660
31533
|
`);
|
|
32661
|
-
|
|
32662
|
-
|
|
32663
|
-
|
|
32664
|
-
|
|
32665
|
-
}
|
|
32666
|
-
} finally {
|
|
32667
|
-
extractionCacheDb.close();
|
|
32668
|
-
}
|
|
31534
|
+
}
|
|
31535
|
+
},
|
|
31536
|
+
{ resolveUnreachable, projectRoot }
|
|
31537
|
+
);
|
|
32669
31538
|
await mkdir6(outDir, { recursive: true });
|
|
32670
31539
|
const db = openPipelineDb();
|
|
32671
31540
|
const { sessionId: sessionId2 } = getOrCreateSession(db, void 0, void 0, {
|
|
@@ -32680,25 +31549,6 @@ function registerInternalExtractCommand(program) {
|
|
|
32680
31549
|
const stepId = createStep(db, sessionId2, "analyze extract", {
|
|
32681
31550
|
project: projectRoot
|
|
32682
31551
|
});
|
|
32683
|
-
if (extractionCacheHits === 0 && !noCache) {
|
|
32684
|
-
const cacheVersion = await getCliCacheVersion();
|
|
32685
|
-
const componentsBySourcePath = /* @__PURE__ */ new Map();
|
|
32686
|
-
for (const component of extraction.components) {
|
|
32687
|
-
if (!component.sourcePath) continue;
|
|
32688
|
-
const components = componentsBySourcePath.get(component.sourcePath) ?? [];
|
|
32689
|
-
components.push(component);
|
|
32690
|
-
componentsBySourcePath.set(component.sourcePath, components);
|
|
32691
|
-
}
|
|
32692
|
-
for (const filePath of sourceFiles) {
|
|
32693
|
-
storeExtractCache(
|
|
32694
|
-
db,
|
|
32695
|
-
filePath,
|
|
32696
|
-
await hashFile(filePath),
|
|
32697
|
-
cacheVersion,
|
|
32698
|
-
componentsBySourcePath.get(filePath) ?? []
|
|
32699
|
-
);
|
|
32700
|
-
}
|
|
32701
|
-
}
|
|
32702
31552
|
const classifiedComponents = extraction.components.map(preClassifyComponent);
|
|
32703
31553
|
for (const exclusion of extraction.exclusions ?? []) {
|
|
32704
31554
|
getDebugLogger().event("filter", "extract.excluded", { ...exclusion });
|
|
@@ -32803,7 +31653,6 @@ var init_extract_command = __esm({
|
|
|
32803
31653
|
"use strict";
|
|
32804
31654
|
init_src2();
|
|
32805
31655
|
init_db();
|
|
32806
|
-
init_cache_keys();
|
|
32807
31656
|
init_cycle_detection();
|
|
32808
31657
|
init_resolve_mapping();
|
|
32809
31658
|
init_manifest_doc_evidence();
|
|
@@ -32902,7 +31751,7 @@ __export(program_exports, {
|
|
|
32902
31751
|
});
|
|
32903
31752
|
import { spawn as spawn7 } from "node:child_process";
|
|
32904
31753
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
32905
|
-
import { dirname as dirname18, join as join28, resolve as
|
|
31754
|
+
import { dirname as dirname18, join as join28, resolve as resolve19 } from "node:path";
|
|
32906
31755
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
32907
31756
|
import { Command } from "commander";
|
|
32908
31757
|
async function runBuild(opts) {
|
|
@@ -32932,7 +31781,7 @@ function resolveBedrockFromAncestors(actionCommand) {
|
|
|
32932
31781
|
}
|
|
32933
31782
|
function registerBuildCommand(program) {
|
|
32934
31783
|
program.command("build").description("Rebuild from source and re-link exo/experiences binaries to this build").helpOption(false).action(async () => {
|
|
32935
|
-
const pkgRoot =
|
|
31784
|
+
const pkgRoot = resolve19(dirname18(fileURLToPath3(import.meta.url)), "..", "..");
|
|
32936
31785
|
process.stderr.write("\u2699 Building from source...\n");
|
|
32937
31786
|
const { exitCode } = await runBuild({
|
|
32938
31787
|
spawnFn: () => spawn7("pnpm", ["build"], { cwd: pkgRoot, stdio: "inherit" }),
|