@contentful/experience-design-system-cli 2.35.1-dev-build-c8bff53c.0 → 2.35.1-dev-build-459d7e23.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 +213 -1329
- 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,12 +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
171
|
AGENT_NAMES = ["claude", "codex", "opencode", "cursor", "copilot"];
|
|
172
|
-
DEFAULT_AGENT_NAME = "claude";
|
|
173
172
|
AGENT_BINARIES = {
|
|
174
173
|
claude: "claude",
|
|
175
174
|
codex: "codex",
|
|
@@ -181,23 +180,6 @@ var init_agent_names = __esm({
|
|
|
181
180
|
});
|
|
182
181
|
|
|
183
182
|
// packages/experience-design-system-generation/dist/src/controller/helpers/validate-generation-request.js
|
|
184
|
-
function validateGenerationRequest(request2) {
|
|
185
|
-
if (request2 === null || typeof request2 !== "object") {
|
|
186
|
-
throw new TypeError("createGenerationEndpoint requires a request object");
|
|
187
|
-
}
|
|
188
|
-
if (!isAgentName(request2.agent)) {
|
|
189
|
-
throw new TypeError(`createGenerationEndpoint requires agent to be a valid agent name, got: ${String(request2.agent)}`);
|
|
190
|
-
}
|
|
191
|
-
if (typeof request2.timeoutMs !== "number" || request2.timeoutMs <= 0) {
|
|
192
|
-
throw new TypeError("createGenerationEndpoint requires timeoutMs to be a positive number");
|
|
193
|
-
}
|
|
194
|
-
if (request2.promptOptions === null || typeof request2.promptOptions !== "object") {
|
|
195
|
-
throw new TypeError("createGenerationEndpoint requires promptOptions to be an object");
|
|
196
|
-
}
|
|
197
|
-
if (request2.onOutput !== void 0 && typeof request2.onOutput !== "function") {
|
|
198
|
-
throw new TypeError("createGenerationEndpoint requires onOutput to be a function when provided");
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
183
|
var init_validate_generation_request = __esm({
|
|
202
184
|
"packages/experience-design-system-generation/dist/src/controller/helpers/validate-generation-request.js"() {
|
|
203
185
|
"use strict";
|
|
@@ -256,6 +238,7 @@ var init_resolve_skill_file = __esm({
|
|
|
256
238
|
components: "generate-components.md",
|
|
257
239
|
tokens: "generate-tokens.md",
|
|
258
240
|
select: "select-components.md",
|
|
241
|
+
"debate-select": "debate-select.md",
|
|
259
242
|
"map-tokens": "map-tokens.md"
|
|
260
243
|
};
|
|
261
244
|
}
|
|
@@ -517,6 +500,31 @@ Rules:
|
|
|
517
500
|
- Emit set_group calls before the set_token calls that fall under them.
|
|
518
501
|
- You may emit prose lines (not starting with {) anywhere \u2014 they are ignored by the parser and serve as your reasoning log.`;
|
|
519
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
|
+
}
|
|
520
528
|
var init_build_skill_preambles = __esm({
|
|
521
529
|
"packages/experience-design-system-generation/dist/src/services/prompts/helpers/build-skill-preambles.js"() {
|
|
522
530
|
"use strict";
|
|
@@ -525,7 +533,7 @@ var init_build_skill_preambles = __esm({
|
|
|
525
533
|
|
|
526
534
|
// packages/experience-design-system-generation/dist/src/services/prompts/helpers/build-preamble.js
|
|
527
535
|
function buildPreamble(options) {
|
|
528
|
-
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;
|
|
529
537
|
const sections = [];
|
|
530
538
|
if (existingComponentsInline) {
|
|
531
539
|
sections.push(`Existing components in the target Contentful space (JSON) \u2014 use for alignment, not as a hard filter:
|
|
@@ -597,6 +605,8 @@ ${sections.join("\n\n")}` : "";
|
|
|
597
605
|
return buildComponentsAutonomousPreamble(inputBlock);
|
|
598
606
|
if (skill === "select")
|
|
599
607
|
return buildSelectAutonomousPreamble(inputBlock);
|
|
608
|
+
if (skill === "debate-select")
|
|
609
|
+
return buildDebateSelectAutonomousPreamble(inputBlock, debateRole, disagreementInline);
|
|
600
610
|
if (skill === "map-tokens")
|
|
601
611
|
return buildMapTokensAutonomousPreamble(inputBlock);
|
|
602
612
|
return buildTokensAutonomousPreamble(inputBlock);
|
|
@@ -630,17 +640,6 @@ var init_build_prompt = __esm({
|
|
|
630
640
|
});
|
|
631
641
|
|
|
632
642
|
// packages/experience-design-system-generation/dist/src/orchestrator/execute-generation-orchestrator.js
|
|
633
|
-
async function executeGenerationOrchestrator(request2) {
|
|
634
|
-
const prompt = await buildPrompt(request2.promptOptions);
|
|
635
|
-
return request2.invoker.invoke({
|
|
636
|
-
agent: request2.agent,
|
|
637
|
-
model: request2.model,
|
|
638
|
-
bedrock: request2.bedrock,
|
|
639
|
-
prompt,
|
|
640
|
-
timeoutMs: request2.timeoutMs,
|
|
641
|
-
onOutput: request2.onOutput
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
643
|
var init_execute_generation_orchestrator = __esm({
|
|
645
644
|
"packages/experience-design-system-generation/dist/src/orchestrator/execute-generation-orchestrator.js"() {
|
|
646
645
|
"use strict";
|
|
@@ -741,22 +740,6 @@ var init_describe_agent_failure = __esm({
|
|
|
741
740
|
});
|
|
742
741
|
|
|
743
742
|
// packages/experience-design-system-generation/dist/src/services/agent/helpers/extract-sentinel-output.js
|
|
744
|
-
function extractSentinelOutput(stdout) {
|
|
745
|
-
const START = "<<<EDS_OUTPUT_START>>>";
|
|
746
|
-
const END = "<<<EDS_OUTPUT_END>>>";
|
|
747
|
-
const startIdx = stdout.indexOf(START);
|
|
748
|
-
const endIdx = stdout.indexOf(END);
|
|
749
|
-
if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx)
|
|
750
|
-
return null;
|
|
751
|
-
const secondStart = stdout.indexOf(START, startIdx + START.length);
|
|
752
|
-
if (secondStart !== -1 && secondStart < endIdx)
|
|
753
|
-
return "multiple";
|
|
754
|
-
const afterStart = stdout.indexOf(END, startIdx);
|
|
755
|
-
const secondEnd = stdout.indexOf(END, afterStart + END.length);
|
|
756
|
-
if (secondEnd !== -1)
|
|
757
|
-
return "multiple";
|
|
758
|
-
return stdout.slice(startIdx + START.length, endIdx).trim();
|
|
759
|
-
}
|
|
760
743
|
var init_extract_sentinel_output = __esm({
|
|
761
744
|
"packages/experience-design-system-generation/dist/src/services/agent/helpers/extract-sentinel-output.js"() {
|
|
762
745
|
"use strict";
|
|
@@ -781,7 +764,7 @@ async function runAgent(options) {
|
|
|
781
764
|
promptLen: prompt.length,
|
|
782
765
|
promptHead: prompt.slice(0, 500)
|
|
783
766
|
});
|
|
784
|
-
return new Promise((
|
|
767
|
+
return new Promise((resolve20) => {
|
|
785
768
|
const bedrockEnv = bedrock ? BEDROCK_ENV_BY_AGENT[agent] : void 0;
|
|
786
769
|
const child = spawn(binary, args, {
|
|
787
770
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -830,7 +813,7 @@ async function runAgent(options) {
|
|
|
830
813
|
stderrLen: stderr.length,
|
|
831
814
|
stderrTail: stderr.slice(-1e3)
|
|
832
815
|
});
|
|
833
|
-
|
|
816
|
+
resolve20(result);
|
|
834
817
|
});
|
|
835
818
|
});
|
|
836
819
|
}
|
|
@@ -847,7 +830,7 @@ var init_run_agent = __esm({
|
|
|
847
830
|
// packages/experience-design-system-generation/dist/src/services/agent/helpers/check-claude-auth.js
|
|
848
831
|
import { spawn as spawn2 } from "node:child_process";
|
|
849
832
|
function checkClaudeAuth(binary) {
|
|
850
|
-
return new Promise((
|
|
833
|
+
return new Promise((resolve20) => {
|
|
851
834
|
const child = spawn2(binary, ["auth", "status", "--json"], {
|
|
852
835
|
stdio: ["ignore", "pipe", "pipe"]
|
|
853
836
|
});
|
|
@@ -857,7 +840,7 @@ function checkClaudeAuth(binary) {
|
|
|
857
840
|
if (!done) {
|
|
858
841
|
done = true;
|
|
859
842
|
child.kill("SIGTERM");
|
|
860
|
-
|
|
843
|
+
resolve20("unauthenticated");
|
|
861
844
|
}
|
|
862
845
|
}, 5e3);
|
|
863
846
|
child.stdout?.on("data", (chunk) => {
|
|
@@ -869,14 +852,14 @@ function checkClaudeAuth(binary) {
|
|
|
869
852
|
done = true;
|
|
870
853
|
clearTimeout(timer);
|
|
871
854
|
if (code !== 0) {
|
|
872
|
-
|
|
855
|
+
resolve20("unauthenticated");
|
|
873
856
|
return;
|
|
874
857
|
}
|
|
875
858
|
try {
|
|
876
859
|
const status = JSON.parse(stdout);
|
|
877
|
-
|
|
860
|
+
resolve20(status.loggedIn ? "ok" : "unauthenticated");
|
|
878
861
|
} catch {
|
|
879
|
-
|
|
862
|
+
resolve20("unauthenticated");
|
|
880
863
|
}
|
|
881
864
|
});
|
|
882
865
|
});
|
|
@@ -891,13 +874,13 @@ var init_check_claude_auth = __esm({
|
|
|
891
874
|
import { spawn as spawn3 } from "node:child_process";
|
|
892
875
|
async function checkAgentAuth(agent) {
|
|
893
876
|
const binary = resolveAgentBinary(agent);
|
|
894
|
-
const binaryExists2 = await new Promise((
|
|
877
|
+
const binaryExists2 = await new Promise((resolve20) => {
|
|
895
878
|
if (binary.startsWith("/")) {
|
|
896
|
-
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)));
|
|
897
880
|
return;
|
|
898
881
|
}
|
|
899
882
|
const child = spawn3(process.platform === "win32" ? "where" : "which", [binary], { stdio: "ignore" });
|
|
900
|
-
child.on("close", (code) =>
|
|
883
|
+
child.on("close", (code) => resolve20(code === 0));
|
|
901
884
|
});
|
|
902
885
|
if (!binaryExists2)
|
|
903
886
|
return "not-found";
|
|
@@ -934,20 +917,6 @@ var init_local_cli_agent_invoker = __esm({
|
|
|
934
917
|
});
|
|
935
918
|
|
|
936
919
|
// packages/experience-design-system-generation/dist/src/controller/create-generation-endpoint.js
|
|
937
|
-
function createGenerationEndpoint(options = {}) {
|
|
938
|
-
const invoker2 = createLocalCliAgentInvoker({
|
|
939
|
-
onDebugEvent: options.onDebugEvent
|
|
940
|
-
});
|
|
941
|
-
return {
|
|
942
|
-
async run(request2) {
|
|
943
|
-
validateGenerationRequest(request2);
|
|
944
|
-
return executeGenerationOrchestrator({ ...request2, invoker: invoker2 });
|
|
945
|
-
},
|
|
946
|
-
checkAuth(agent) {
|
|
947
|
-
return invoker2.checkAuth(agent);
|
|
948
|
-
}
|
|
949
|
-
};
|
|
950
|
-
}
|
|
951
920
|
var init_create_generation_endpoint = __esm({
|
|
952
921
|
"packages/experience-design-system-generation/dist/src/controller/create-generation-endpoint.js"() {
|
|
953
922
|
"use strict";
|
|
@@ -1332,32 +1301,6 @@ var init_progress = __esm({
|
|
|
1332
1301
|
});
|
|
1333
1302
|
|
|
1334
1303
|
// packages/experience-design-system-generation/dist/src/index.js
|
|
1335
|
-
var src_exports = {};
|
|
1336
|
-
__export(src_exports, {
|
|
1337
|
-
AGENT_BINARIES: () => AGENT_BINARIES,
|
|
1338
|
-
AGENT_NAMES: () => AGENT_NAMES,
|
|
1339
|
-
DEFAULT_AGENT_NAME: () => DEFAULT_AGENT_NAME,
|
|
1340
|
-
agentSupportsBedrock: () => agentSupportsBedrock,
|
|
1341
|
-
buildArgs: () => buildAgentArgs,
|
|
1342
|
-
buildPrompt: () => buildPrompt,
|
|
1343
|
-
checkAgentAuth: () => checkAgentAuth,
|
|
1344
|
-
createGenerationEndpoint: () => createGenerationEndpoint,
|
|
1345
|
-
createLocalCliAgentInvoker: () => createLocalCliAgentInvoker,
|
|
1346
|
-
describeAgentFailure: () => describeAgentFailure,
|
|
1347
|
-
executeGenerationOrchestrator: () => executeGenerationOrchestrator,
|
|
1348
|
-
extractSentinelOutput: () => extractSentinelOutput,
|
|
1349
|
-
formatCustomPromptBanner: () => formatCustomPromptBanner,
|
|
1350
|
-
formatGenerateProgressLine: () => formatGenerateProgressLine,
|
|
1351
|
-
isAgentName: () => isAgentName,
|
|
1352
|
-
parseMapTokenPropToolCallLines: () => parseMapTokenPropToolCallLines,
|
|
1353
|
-
parseSelectToolCallLines: () => parseSelectToolCallLines,
|
|
1354
|
-
parseTokenToolCallLines: () => parseTokenToolCallLines,
|
|
1355
|
-
parseToolCallLines: () => parsePropToolCallLines,
|
|
1356
|
-
resolveAgentModel: () => resolveAgentModel,
|
|
1357
|
-
resolveBinary: () => resolveAgentBinary,
|
|
1358
|
-
resolveSkillPath: () => resolveSkillPath,
|
|
1359
|
-
runAgent: () => runAgent
|
|
1360
|
-
});
|
|
1361
1304
|
var init_src = __esm({
|
|
1362
1305
|
"packages/experience-design-system-generation/dist/src/index.js"() {
|
|
1363
1306
|
"use strict";
|
|
@@ -10357,41 +10300,6 @@ var init_read3 = __esm({
|
|
|
10357
10300
|
}
|
|
10358
10301
|
});
|
|
10359
10302
|
|
|
10360
|
-
// packages/experience-design-system-cli-legacy/src/session/core/components/hash-component-shape.ts
|
|
10361
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
10362
|
-
function hashComponentShape(component) {
|
|
10363
|
-
const payload = {
|
|
10364
|
-
framework: component.framework,
|
|
10365
|
-
name: component.name,
|
|
10366
|
-
source: component.source,
|
|
10367
|
-
props: component.props.map((p) => ({
|
|
10368
|
-
name: p.name,
|
|
10369
|
-
type: p.type
|
|
10370
|
-
})),
|
|
10371
|
-
slots: component.slots.map((s) => ({
|
|
10372
|
-
name: s.name,
|
|
10373
|
-
isDefault: s.isDefault
|
|
10374
|
-
}))
|
|
10375
|
-
};
|
|
10376
|
-
return createHash2("sha256").update(JSON.stringify(payload)).digest("hex");
|
|
10377
|
-
}
|
|
10378
|
-
var init_hash_component_shape = __esm({
|
|
10379
|
-
"packages/experience-design-system-cli-legacy/src/session/core/components/hash-component-shape.ts"() {
|
|
10380
|
-
"use strict";
|
|
10381
|
-
}
|
|
10382
|
-
});
|
|
10383
|
-
|
|
10384
|
-
// packages/experience-design-system-cli-legacy/src/session/core/tokens/hash-token-content.ts
|
|
10385
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
10386
|
-
function hashTokenContent(rawTokenContent) {
|
|
10387
|
-
return createHash3("sha256").update(rawTokenContent.trim()).digest("hex");
|
|
10388
|
-
}
|
|
10389
|
-
var init_hash_token_content = __esm({
|
|
10390
|
-
"packages/experience-design-system-cli-legacy/src/session/core/tokens/hash-token-content.ts"() {
|
|
10391
|
-
"use strict";
|
|
10392
|
-
}
|
|
10393
|
-
});
|
|
10394
|
-
|
|
10395
10303
|
// packages/experience-design-system-cli-legacy/src/session/repositories/tokens/write.ts
|
|
10396
10304
|
function deleteRawTokensForSession(db, sessionId2) {
|
|
10397
10305
|
db.prepare("DELETE FROM raw_token_groups WHERE session_id = ?").run(sessionId2);
|
|
@@ -10555,47 +10463,17 @@ var init_replace_raw_prop_token_paths = __esm({
|
|
|
10555
10463
|
}
|
|
10556
10464
|
});
|
|
10557
10465
|
|
|
10558
|
-
// packages/experience-design-system-cli-legacy/src/session/cache-keys.ts
|
|
10559
|
-
var cache_keys_exports = {};
|
|
10560
|
-
__export(cache_keys_exports, {
|
|
10561
|
-
hashContent: () => hashContent,
|
|
10562
|
-
hashFile: () => hashFile,
|
|
10563
|
-
hashPromptForSkill: () => hashPromptForSkill
|
|
10564
|
-
});
|
|
10565
|
-
import { createHash as createHash4 } from "node:crypto";
|
|
10566
|
-
import { readFile as readFile7 } from "node:fs/promises";
|
|
10567
|
-
import { resolve as resolve8 } from "node:path";
|
|
10568
|
-
function hashContent(content) {
|
|
10569
|
-
return createHash4("sha256").update(content).digest("hex");
|
|
10570
|
-
}
|
|
10571
|
-
async function hashFile(filePath) {
|
|
10572
|
-
const content = await readFile7(filePath, "utf8");
|
|
10573
|
-
return hashContent(content);
|
|
10574
|
-
}
|
|
10575
|
-
async function hashPromptForSkill(skill, agent, model, skillPathOverride, extraInputs = [], skillContentOverride) {
|
|
10576
|
-
const promptHash = skillContentOverride ? hashContent(skillContentOverride) : skillPathOverride ? await hashFile(resolve8(skillPathOverride)) : await hashFile(resolveSkillPath(skill));
|
|
10577
|
-
const extraSegment = extraInputs.length > 0 ? `|${extraInputs.join("|")}` : "";
|
|
10578
|
-
return hashContent(`${promptHash}|${agent}|${model ?? ""}${extraSegment}`);
|
|
10579
|
-
}
|
|
10580
|
-
var init_cache_keys = __esm({
|
|
10581
|
-
"packages/experience-design-system-cli-legacy/src/session/cache-keys.ts"() {
|
|
10582
|
-
"use strict";
|
|
10583
|
-
init_src();
|
|
10584
|
-
}
|
|
10585
|
-
});
|
|
10586
|
-
|
|
10587
10466
|
// packages/experience-design-system-cli-legacy/src/session/db.ts
|
|
10588
10467
|
import { DatabaseSync } from "node:sqlite";
|
|
10589
10468
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync5 } from "node:fs";
|
|
10590
|
-
import { readFile as
|
|
10591
|
-
import { createHash as createHash5 } from "node:crypto";
|
|
10469
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
10592
10470
|
import { homedir as homedir3 } from "node:os";
|
|
10593
|
-
import { dirname as dirname14, resolve as
|
|
10471
|
+
import { dirname as dirname14, resolve as resolve8 } from "node:path";
|
|
10594
10472
|
function getPipelineDbPath() {
|
|
10595
10473
|
if (process.env.EDS_PIPELINE_DB_PATH) {
|
|
10596
|
-
return
|
|
10474
|
+
return resolve8(process.env.EDS_PIPELINE_DB_PATH);
|
|
10597
10475
|
}
|
|
10598
|
-
return
|
|
10476
|
+
return resolve8(homedir3(), ".contentful", "experience-design-system-cli", "pipeline.db");
|
|
10599
10477
|
}
|
|
10600
10478
|
function openPipelineDb(dbPath) {
|
|
10601
10479
|
const path = dbPath ?? getPipelineDbPath();
|
|
@@ -10729,134 +10607,8 @@ function applyDbMigrations(db) {
|
|
|
10729
10607
|
if (!rawSlotColsForRationale.some((c2) => c2.name === "rationale")) {
|
|
10730
10608
|
db.exec("ALTER TABLE raw_slots ADD COLUMN rationale TEXT");
|
|
10731
10609
|
}
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
db.exec(`
|
|
10735
|
-
CREATE TABLE extract_cache (
|
|
10736
|
-
file_path TEXT NOT NULL,
|
|
10737
|
-
file_hash TEXT NOT NULL,
|
|
10738
|
-
cli_version TEXT NOT NULL,
|
|
10739
|
-
created_at TEXT NOT NULL,
|
|
10740
|
-
updated_at TEXT NOT NULL,
|
|
10741
|
-
components_json TEXT NOT NULL,
|
|
10742
|
-
PRIMARY KEY (file_hash, cli_version)
|
|
10743
|
-
);
|
|
10744
|
-
CREATE INDEX idx_extract_cache_file ON extract_cache(file_path);
|
|
10745
|
-
`);
|
|
10746
|
-
}
|
|
10747
|
-
const hasSelectCache = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='select_cache'`).all();
|
|
10748
|
-
if (hasSelectCache.length === 0) {
|
|
10749
|
-
db.exec(`
|
|
10750
|
-
CREATE TABLE select_cache (
|
|
10751
|
-
component_hash TEXT NOT NULL,
|
|
10752
|
-
prompt_hash TEXT NOT NULL,
|
|
10753
|
-
cli_version TEXT NOT NULL,
|
|
10754
|
-
decision TEXT NOT NULL CHECK (decision IN ('accepted','rejected')),
|
|
10755
|
-
reason TEXT,
|
|
10756
|
-
created_at TEXT NOT NULL,
|
|
10757
|
-
updated_at TEXT NOT NULL,
|
|
10758
|
-
PRIMARY KEY (component_hash, prompt_hash, cli_version)
|
|
10759
|
-
);
|
|
10760
|
-
`);
|
|
10761
|
-
}
|
|
10762
|
-
const tables = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='generation_cache'`).all();
|
|
10763
|
-
if (tables.length === 0) {
|
|
10764
|
-
db.exec(`
|
|
10765
|
-
CREATE TABLE generation_cache (
|
|
10766
|
-
input_hash TEXT NOT NULL,
|
|
10767
|
-
entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
|
|
10768
|
-
entity_id TEXT NOT NULL,
|
|
10769
|
-
source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
10770
|
-
human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
|
|
10771
|
-
created_at TEXT NOT NULL,
|
|
10772
|
-
updated_at TEXT NOT NULL,
|
|
10773
|
-
PRIMARY KEY (input_hash, entity_type, entity_id)
|
|
10774
|
-
);
|
|
10775
|
-
CREATE INDEX idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
|
|
10776
|
-
CREATE INDEX idx_generation_cache_session ON generation_cache(source_session_id);
|
|
10777
|
-
`);
|
|
10778
|
-
}
|
|
10779
|
-
const genCacheCols = db.prepare(`PRAGMA table_info(generation_cache)`).all();
|
|
10780
|
-
const hasPromptHash = genCacheCols.some((c2) => c2.name === "prompt_hash");
|
|
10781
|
-
const oldPkCols = genCacheCols.filter((c2) => c2.pk > 0).map((c2) => c2.name);
|
|
10782
|
-
const promptHashInPk = oldPkCols.includes("prompt_hash");
|
|
10783
|
-
if (!hasPromptHash) {
|
|
10784
|
-
db.exec(`ALTER TABLE generation_cache ADD COLUMN prompt_hash TEXT NOT NULL DEFAULT ''`);
|
|
10785
|
-
}
|
|
10786
|
-
if (!promptHashInPk) {
|
|
10787
|
-
db.exec("BEGIN");
|
|
10788
|
-
try {
|
|
10789
|
-
db.exec(`
|
|
10790
|
-
CREATE TABLE generation_cache__new (
|
|
10791
|
-
input_hash TEXT NOT NULL,
|
|
10792
|
-
entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
|
|
10793
|
-
entity_id TEXT NOT NULL,
|
|
10794
|
-
source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
10795
|
-
human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
|
|
10796
|
-
created_at TEXT NOT NULL,
|
|
10797
|
-
updated_at TEXT NOT NULL,
|
|
10798
|
-
prompt_hash TEXT NOT NULL DEFAULT '',
|
|
10799
|
-
PRIMARY KEY (input_hash, prompt_hash, entity_type, entity_id)
|
|
10800
|
-
);
|
|
10801
|
-
INSERT INTO generation_cache__new
|
|
10802
|
-
(input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash)
|
|
10803
|
-
SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
|
|
10804
|
-
FROM generation_cache;
|
|
10805
|
-
DROP TABLE generation_cache;
|
|
10806
|
-
ALTER TABLE generation_cache__new RENAME TO generation_cache;
|
|
10807
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
|
|
10808
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_session ON generation_cache(source_session_id);
|
|
10809
|
-
`);
|
|
10810
|
-
db.exec("COMMIT");
|
|
10811
|
-
} catch (e) {
|
|
10812
|
-
db.exec("ROLLBACK");
|
|
10813
|
-
throw e;
|
|
10814
|
-
}
|
|
10815
|
-
}
|
|
10816
|
-
const genCacheTableSql = db.prepare(`SELECT sql FROM sqlite_master WHERE type = 'table' AND name = 'generation_cache'`).get();
|
|
10817
|
-
const hasTokenMappingEntityType = genCacheTableSql?.sql.includes("'token_mapping'") ?? true;
|
|
10818
|
-
if (!hasTokenMappingEntityType) {
|
|
10819
|
-
db.exec("BEGIN");
|
|
10820
|
-
try {
|
|
10821
|
-
db.exec(`
|
|
10822
|
-
CREATE TABLE generation_cache__new2 (
|
|
10823
|
-
input_hash TEXT NOT NULL,
|
|
10824
|
-
entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
|
|
10825
|
-
entity_id TEXT NOT NULL,
|
|
10826
|
-
source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
10827
|
-
human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
|
|
10828
|
-
created_at TEXT NOT NULL,
|
|
10829
|
-
updated_at TEXT NOT NULL,
|
|
10830
|
-
prompt_hash TEXT NOT NULL DEFAULT '',
|
|
10831
|
-
PRIMARY KEY (input_hash, prompt_hash, entity_type, entity_id)
|
|
10832
|
-
);
|
|
10833
|
-
INSERT INTO generation_cache__new2
|
|
10834
|
-
(input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash)
|
|
10835
|
-
SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
|
|
10836
|
-
FROM generation_cache;
|
|
10837
|
-
DROP TABLE generation_cache;
|
|
10838
|
-
ALTER TABLE generation_cache__new2 RENAME TO generation_cache;
|
|
10839
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
|
|
10840
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_session ON generation_cache(source_session_id);
|
|
10841
|
-
`);
|
|
10842
|
-
db.exec("COMMIT");
|
|
10843
|
-
} catch (e) {
|
|
10844
|
-
db.exec("ROLLBACK");
|
|
10845
|
-
throw e;
|
|
10846
|
-
}
|
|
10847
|
-
}
|
|
10848
|
-
const hasCompositionCache = db.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='composition_cache'`).all();
|
|
10849
|
-
if (hasCompositionCache.length === 0) {
|
|
10850
|
-
db.exec(`
|
|
10851
|
-
CREATE TABLE composition_cache (
|
|
10852
|
-
input_hash TEXT NOT NULL,
|
|
10853
|
-
cli_version TEXT NOT NULL,
|
|
10854
|
-
agent_output TEXT NOT NULL,
|
|
10855
|
-
created_at TEXT NOT NULL,
|
|
10856
|
-
updated_at TEXT NOT NULL,
|
|
10857
|
-
PRIMARY KEY (input_hash, cli_version)
|
|
10858
|
-
);
|
|
10859
|
-
`);
|
|
10610
|
+
for (const table of REMOVED_CACHE_TABLES) {
|
|
10611
|
+
db.exec(`DROP TABLE IF EXISTS ${table}`);
|
|
10860
10612
|
}
|
|
10861
10613
|
}
|
|
10862
10614
|
function loadComponentReviewMetadata(db, sessionId2, componentName) {
|
|
@@ -11396,16 +11148,16 @@ function extractRelativeImportPaths(sourceText) {
|
|
|
11396
11148
|
return [...specifiers];
|
|
11397
11149
|
}
|
|
11398
11150
|
async function resolveRelativeImport(specifier, fromDir) {
|
|
11399
|
-
const basePath =
|
|
11151
|
+
const basePath = resolve8(fromDir, specifier);
|
|
11400
11152
|
const candidates = [
|
|
11401
11153
|
basePath,
|
|
11402
11154
|
...rewrittenSourcePaths(basePath),
|
|
11403
11155
|
...SIBLING_FILE_EXTENSIONS.map((ext) => `${basePath}${ext}`),
|
|
11404
|
-
...SIBLING_FILE_EXTENSIONS.map((ext) =>
|
|
11156
|
+
...SIBLING_FILE_EXTENSIONS.map((ext) => resolve8(basePath, `index${ext}`))
|
|
11405
11157
|
];
|
|
11406
11158
|
for (const candidate of candidates) {
|
|
11407
11159
|
try {
|
|
11408
|
-
await
|
|
11160
|
+
await readFile7(candidate, "utf8");
|
|
11409
11161
|
return candidate;
|
|
11410
11162
|
} catch {
|
|
11411
11163
|
}
|
|
@@ -11421,7 +11173,7 @@ async function resolveImportSpecifiers(sourceText, fromDir) {
|
|
|
11421
11173
|
return resolvedPaths;
|
|
11422
11174
|
}
|
|
11423
11175
|
async function loadSiblingFiles(sourceText, sourcePath, propNames, candidateTypeNames = []) {
|
|
11424
|
-
const visited = /* @__PURE__ */ new Set([
|
|
11176
|
+
const visited = /* @__PURE__ */ new Set([resolve8(sourcePath)]);
|
|
11425
11177
|
const discovered = [];
|
|
11426
11178
|
let frontier = [{ text: sourceText, dir: dirname14(sourcePath) }];
|
|
11427
11179
|
for (let hop = 0; hop < MAX_SIBLING_DEPTH && discovered.length < MAX_SIBLING_CANDIDATES_EXPLORED; hop++) {
|
|
@@ -11435,7 +11187,7 @@ async function loadSiblingFiles(sourceText, sourcePath, propNames, candidateType
|
|
|
11435
11187
|
if (discovered.length >= MAX_SIBLING_CANDIDATES_EXPLORED) break;
|
|
11436
11188
|
let content;
|
|
11437
11189
|
try {
|
|
11438
|
-
content = await
|
|
11190
|
+
content = await readFile7(resolvedPath, "utf8");
|
|
11439
11191
|
} catch {
|
|
11440
11192
|
continue;
|
|
11441
11193
|
}
|
|
@@ -11472,7 +11224,7 @@ async function loadComponentSourceRef(name, sourcePath, propNames = [], propType
|
|
|
11472
11224
|
let truncatedSiblingCount = 0;
|
|
11473
11225
|
const usesNotShown = /* @__PURE__ */ new Set();
|
|
11474
11226
|
try {
|
|
11475
|
-
const rawText = await
|
|
11227
|
+
const rawText = await readFile7(sourcePath, "utf8");
|
|
11476
11228
|
let siblingUsesNotShown;
|
|
11477
11229
|
let declaredTypeNames;
|
|
11478
11230
|
({
|
|
@@ -11908,108 +11660,6 @@ function backfillUnclassifiedProps(db, sessionId2) {
|
|
|
11908
11660
|
).run(sessionId2, sessionId2);
|
|
11909
11661
|
return Number(withCategory.changes) + Number(withoutCategory.changes);
|
|
11910
11662
|
}
|
|
11911
|
-
function computeMapTokensInputHash(db, sessionId2, componentSourceRefs = []) {
|
|
11912
|
-
const props = db.prepare(
|
|
11913
|
-
`SELECT rc.name AS component_name, rp.name AS prop_name, rp.cdf_token_kind, rp.default_value
|
|
11914
|
-
FROM raw_props rp
|
|
11915
|
-
JOIN raw_components rc ON rc.session_id = rp.session_id AND rc.component_id = rp.component_id
|
|
11916
|
-
WHERE rp.session_id = ? AND rp.cdf_type = 'token' AND rp.cdf_category = 'design'
|
|
11917
|
-
ORDER BY rc.name, rp.name`
|
|
11918
|
-
).all(sessionId2);
|
|
11919
|
-
const tokens = db.prepare(`SELECT path, type FROM raw_tokens WHERE session_id = ? ORDER BY path`).all(sessionId2);
|
|
11920
|
-
const defaultMappings = db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId2);
|
|
11921
|
-
const payload = {
|
|
11922
|
-
props: props.map((p) => ({
|
|
11923
|
-
component: p.component_name,
|
|
11924
|
-
prop: p.prop_name,
|
|
11925
|
-
tokenKind: p.cdf_token_kind,
|
|
11926
|
-
rawDefault: p.default_value
|
|
11927
|
-
})),
|
|
11928
|
-
tokens,
|
|
11929
|
-
defaultMappings,
|
|
11930
|
-
// The agent's evidence, not just its inputs: a comment or allowlist edit
|
|
11931
|
-
// in a source file (or a sibling it reads) changes the correct answer
|
|
11932
|
-
// without touching props or tokens, so it must invalidate the cache too.
|
|
11933
|
-
sourceRefs: [...componentSourceRefs].sort((a, b) => a.component.localeCompare(b.component)).map((ref) => ({
|
|
11934
|
-
component: ref.component,
|
|
11935
|
-
content: ref.content,
|
|
11936
|
-
siblingFiles: (ref.siblingFiles ?? []).map((s) => ({ path: s.path, content: s.content })).sort((a, b) => a.path.localeCompare(b.path)),
|
|
11937
|
-
usesNotShown: [...ref.usesNotShown ?? []].sort()
|
|
11938
|
-
}))
|
|
11939
|
-
};
|
|
11940
|
-
return createHash5("sha256").update(JSON.stringify(payload)).digest("hex");
|
|
11941
|
-
}
|
|
11942
|
-
function lookupCache(db, inputHash, entityType, entityId, promptHash = "") {
|
|
11943
|
-
const row = db.prepare(
|
|
11944
|
-
`SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
|
|
11945
|
-
FROM generation_cache
|
|
11946
|
-
WHERE input_hash = ? AND entity_type = ? AND entity_id = ? AND prompt_hash = ?`
|
|
11947
|
-
).get(inputHash, entityType, entityId, promptHash);
|
|
11948
|
-
if (!row) return null;
|
|
11949
|
-
return {
|
|
11950
|
-
inputHash: row.input_hash,
|
|
11951
|
-
entityType: row.entity_type,
|
|
11952
|
-
entityId: row.entity_id,
|
|
11953
|
-
sourceSessionId: row.source_session_id,
|
|
11954
|
-
humanEdited: row.human_edited === 1,
|
|
11955
|
-
promptHash: row.prompt_hash,
|
|
11956
|
-
createdAt: row.created_at,
|
|
11957
|
-
updatedAt: row.updated_at
|
|
11958
|
-
};
|
|
11959
|
-
}
|
|
11960
|
-
function lookupCacheByEntity(db, entityType, entityId) {
|
|
11961
|
-
const row = db.prepare(
|
|
11962
|
-
`SELECT input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash
|
|
11963
|
-
FROM generation_cache
|
|
11964
|
-
WHERE entity_type = ? AND entity_id = ?
|
|
11965
|
-
ORDER BY updated_at DESC LIMIT 1`
|
|
11966
|
-
).get(entityType, entityId);
|
|
11967
|
-
if (!row) return null;
|
|
11968
|
-
return {
|
|
11969
|
-
inputHash: row.input_hash,
|
|
11970
|
-
entityType: row.entity_type,
|
|
11971
|
-
entityId: row.entity_id,
|
|
11972
|
-
sourceSessionId: row.source_session_id,
|
|
11973
|
-
humanEdited: row.human_edited === 1,
|
|
11974
|
-
promptHash: row.prompt_hash,
|
|
11975
|
-
createdAt: row.created_at,
|
|
11976
|
-
updatedAt: row.updated_at
|
|
11977
|
-
};
|
|
11978
|
-
}
|
|
11979
|
-
function storeCache(db, inputHash, entityType, entityId, sourceSessionId, humanEdited, promptHash = "") {
|
|
11980
|
-
storeCaches(db, [{ inputHash, entityType, entityId, sourceSessionId, humanEdited, promptHash }]);
|
|
11981
|
-
}
|
|
11982
|
-
function storeCaches(db, entries) {
|
|
11983
|
-
if (entries.length === 0) return;
|
|
11984
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
11985
|
-
const insert = db.prepare(
|
|
11986
|
-
`INSERT INTO generation_cache (input_hash, entity_type, entity_id, source_session_id, human_edited, created_at, updated_at, prompt_hash)
|
|
11987
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
11988
|
-
ON CONFLICT(input_hash, prompt_hash, entity_type, entity_id) DO UPDATE SET
|
|
11989
|
-
source_session_id = excluded.source_session_id,
|
|
11990
|
-
human_edited = CASE WHEN generation_cache.human_edited = 1 THEN 1 ELSE excluded.human_edited END,
|
|
11991
|
-
updated_at = excluded.updated_at`
|
|
11992
|
-
);
|
|
11993
|
-
db.exec("BEGIN");
|
|
11994
|
-
try {
|
|
11995
|
-
for (const entry of entries) {
|
|
11996
|
-
insert.run(
|
|
11997
|
-
entry.inputHash,
|
|
11998
|
-
entry.entityType,
|
|
11999
|
-
entry.entityId,
|
|
12000
|
-
entry.sourceSessionId,
|
|
12001
|
-
entry.humanEdited ? 1 : 0,
|
|
12002
|
-
now,
|
|
12003
|
-
now,
|
|
12004
|
-
entry.promptHash ?? ""
|
|
12005
|
-
);
|
|
12006
|
-
}
|
|
12007
|
-
db.exec("COMMIT");
|
|
12008
|
-
} catch (e) {
|
|
12009
|
-
db.exec("ROLLBACK");
|
|
12010
|
-
throw e;
|
|
12011
|
-
}
|
|
12012
|
-
}
|
|
12013
11663
|
function storeScannedFiles(db, sessionId2, filePaths) {
|
|
12014
11664
|
db.exec("BEGIN");
|
|
12015
11665
|
try {
|
|
@@ -12092,105 +11742,7 @@ function filterUnknownSlotAllowedComponents(db, sessionId2, allowedComponentName
|
|
|
12092
11742
|
}
|
|
12093
11743
|
return unknown;
|
|
12094
11744
|
}
|
|
12095
|
-
function
|
|
12096
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12097
|
-
if (manageTransaction) db.exec("BEGIN");
|
|
12098
|
-
try {
|
|
12099
|
-
const srcComp = db.prepare(
|
|
12100
|
-
`SELECT description, status, component_description_rationale, props_rationale, slots_rationale
|
|
12101
|
-
FROM raw_components WHERE session_id = ? AND component_id = ?`
|
|
12102
|
-
).get(sourceSessionId, componentId);
|
|
12103
|
-
if (srcComp) {
|
|
12104
|
-
db.prepare(
|
|
12105
|
-
`UPDATE raw_components
|
|
12106
|
-
SET description = ?, status = ?, component_description_rationale = ?, props_rationale = ?, slots_rationale = ?, extracted_at = ?
|
|
12107
|
-
WHERE session_id = ? AND component_id = ?`
|
|
12108
|
-
).run(
|
|
12109
|
-
srcComp.description,
|
|
12110
|
-
srcComp.status,
|
|
12111
|
-
srcComp.component_description_rationale,
|
|
12112
|
-
srcComp.props_rationale,
|
|
12113
|
-
srcComp.slots_rationale,
|
|
12114
|
-
now,
|
|
12115
|
-
targetSessionId,
|
|
12116
|
-
componentId
|
|
12117
|
-
);
|
|
12118
|
-
}
|
|
12119
|
-
const srcProps = db.prepare(
|
|
12120
|
-
`SELECT name, cdf_type, cdf_category, cdf_token_kind, required, description, default_value, rationale
|
|
12121
|
-
FROM raw_props WHERE session_id = ? AND component_id = ?`
|
|
12122
|
-
).all(sourceSessionId, componentId);
|
|
12123
|
-
for (const p of srcProps) {
|
|
12124
|
-
db.prepare(
|
|
12125
|
-
`UPDATE raw_props SET cdf_type = ?, cdf_category = ?, cdf_token_kind = ?, required = ?, description = ?, default_value = ?, rationale = ?
|
|
12126
|
-
WHERE session_id = ? AND component_id = ? AND name = ?`
|
|
12127
|
-
).run(
|
|
12128
|
-
p.cdf_type,
|
|
12129
|
-
p.cdf_category,
|
|
12130
|
-
p.cdf_token_kind,
|
|
12131
|
-
p.required,
|
|
12132
|
-
p.description,
|
|
12133
|
-
p.default_value,
|
|
12134
|
-
p.rationale,
|
|
12135
|
-
targetSessionId,
|
|
12136
|
-
componentId,
|
|
12137
|
-
p.name
|
|
12138
|
-
);
|
|
12139
|
-
}
|
|
12140
|
-
db.prepare(`DELETE FROM raw_prop_allowed_values WHERE session_id = ? AND component_id = ?`).run(
|
|
12141
|
-
targetSessionId,
|
|
12142
|
-
componentId
|
|
12143
|
-
);
|
|
12144
|
-
const srcAV = db.prepare(
|
|
12145
|
-
`SELECT prop_name, position, value FROM raw_prop_allowed_values WHERE session_id = ? AND component_id = ?`
|
|
12146
|
-
).all(sourceSessionId, componentId);
|
|
12147
|
-
const insertAV = db.prepare(
|
|
12148
|
-
`INSERT INTO raw_prop_allowed_values (session_id, component_id, prop_name, position, value) VALUES (?, ?, ?, ?, ?)`
|
|
12149
|
-
);
|
|
12150
|
-
for (const av of srcAV) {
|
|
12151
|
-
insertAV.run(targetSessionId, componentId, av.prop_name, av.position, av.value);
|
|
12152
|
-
}
|
|
12153
|
-
const srcSlots = db.prepare(`SELECT name, required, description, rationale FROM raw_slots WHERE session_id = ? AND component_id = ?`).all(sourceSessionId, componentId);
|
|
12154
|
-
for (const s of srcSlots) {
|
|
12155
|
-
db.prepare(
|
|
12156
|
-
`UPDATE raw_slots SET required = ?, description = ?, rationale = ? WHERE session_id = ? AND component_id = ? AND name = ?`
|
|
12157
|
-
).run(s.required, s.description, s.rationale, targetSessionId, componentId, s.name);
|
|
12158
|
-
}
|
|
12159
|
-
db.prepare(`DELETE FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ?`).run(
|
|
12160
|
-
targetSessionId,
|
|
12161
|
-
componentId
|
|
12162
|
-
);
|
|
12163
|
-
const srcSAC = db.prepare(
|
|
12164
|
-
`SELECT slot_name, position, allowed_component FROM raw_slot_allowed_components WHERE session_id = ? AND component_id = ?`
|
|
12165
|
-
).all(sourceSessionId, componentId);
|
|
12166
|
-
const insertSAC = db.prepare(
|
|
12167
|
-
`INSERT INTO raw_slot_allowed_components (session_id, component_id, slot_name, allowed_component, position) VALUES (?, ?, ?, ?, ?)`
|
|
12168
|
-
);
|
|
12169
|
-
const allowedSAC = options.allowedComponentNames ? srcSAC.filter((sac) => options.allowedComponentNames.has(sac.allowed_component)) : srcSAC;
|
|
12170
|
-
for (const sac of allowedSAC) {
|
|
12171
|
-
insertSAC.run(targetSessionId, componentId, sac.slot_name, sac.allowed_component, sac.position);
|
|
12172
|
-
}
|
|
12173
|
-
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, targetSessionId);
|
|
12174
|
-
if (manageTransaction) db.exec("COMMIT");
|
|
12175
|
-
} catch (e) {
|
|
12176
|
-
if (manageTransaction) db.exec("ROLLBACK");
|
|
12177
|
-
throw e;
|
|
12178
|
-
}
|
|
12179
|
-
}
|
|
12180
|
-
function copyComponentsFromCache(db, entries, options = {}) {
|
|
12181
|
-
if (entries.length === 0) return;
|
|
12182
|
-
db.exec("BEGIN");
|
|
12183
|
-
try {
|
|
12184
|
-
for (const entry of entries) {
|
|
12185
|
-
copyComponentFromCache(db, entry.sourceSessionId, entry.targetSessionId, entry.componentId, false, options);
|
|
12186
|
-
}
|
|
12187
|
-
db.exec("COMMIT");
|
|
12188
|
-
} catch (e) {
|
|
12189
|
-
db.exec("ROLLBACK");
|
|
12190
|
-
throw e;
|
|
12191
|
-
}
|
|
12192
|
-
}
|
|
12193
|
-
function copyTokensFromCache(db, sourceSessionId, targetSessionId) {
|
|
11745
|
+
function copyTokensBetweenSessions(db, sourceSessionId, targetSessionId) {
|
|
12194
11746
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12195
11747
|
db.exec("BEGIN");
|
|
12196
11748
|
try {
|
|
@@ -12211,139 +11763,7 @@ function copyTokensFromCache(db, sourceSessionId, targetSessionId) {
|
|
|
12211
11763
|
throw e;
|
|
12212
11764
|
}
|
|
12213
11765
|
}
|
|
12214
|
-
|
|
12215
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12216
|
-
let copiedCount = 0;
|
|
12217
|
-
db.exec("BEGIN");
|
|
12218
|
-
try {
|
|
12219
|
-
const sourceRows = db.prepare(
|
|
12220
|
-
`SELECT rc.name AS component_name, rptp.prop_name, rptp.source, rptp.position, rptp.path
|
|
12221
|
-
FROM raw_prop_token_paths rptp
|
|
12222
|
-
JOIN raw_components rc ON rc.session_id = rptp.session_id AND rc.component_id = rptp.component_id
|
|
12223
|
-
WHERE rptp.session_id = ?
|
|
12224
|
-
ORDER BY rc.name, rptp.prop_name, rptp.position`
|
|
12225
|
-
).all(sourceSessionId);
|
|
12226
|
-
const targetComponents = db.prepare(`SELECT component_id, name FROM raw_components WHERE session_id = ?`).all(targetSessionId);
|
|
12227
|
-
const targetIdByName = new Map(targetComponents.map((c2) => [c2.name, c2.component_id]));
|
|
12228
|
-
const targetProps = new Set(
|
|
12229
|
-
db.prepare(`SELECT component_id, name FROM raw_props WHERE session_id = ?`).all(targetSessionId).map((p) => `${p.component_id}::${p.name}`)
|
|
12230
|
-
);
|
|
12231
|
-
const insertPath = db.prepare(
|
|
12232
|
-
`INSERT INTO raw_prop_token_paths (session_id, component_id, prop_name, source, position, path)
|
|
12233
|
-
VALUES (?, ?, ?, ?, ?, ?)`
|
|
12234
|
-
);
|
|
12235
|
-
const clearedProps = /* @__PURE__ */ new Set();
|
|
12236
|
-
const copiedProps = /* @__PURE__ */ new Set();
|
|
12237
|
-
for (const row of sourceRows) {
|
|
12238
|
-
const targetComponentId = targetIdByName.get(row.component_name);
|
|
12239
|
-
if (!targetComponentId) continue;
|
|
12240
|
-
if (!targetProps.has(`${targetComponentId}::${row.prop_name}`)) continue;
|
|
12241
|
-
const propKey = `${targetComponentId}::${row.prop_name}`;
|
|
12242
|
-
if (!clearedProps.has(propKey)) {
|
|
12243
|
-
clearedProps.add(propKey);
|
|
12244
|
-
db.prepare(`DELETE FROM raw_prop_token_paths WHERE session_id = ? AND component_id = ? AND prop_name = ?`).run(
|
|
12245
|
-
targetSessionId,
|
|
12246
|
-
targetComponentId,
|
|
12247
|
-
row.prop_name
|
|
12248
|
-
);
|
|
12249
|
-
}
|
|
12250
|
-
insertPath.run(targetSessionId, targetComponentId, row.prop_name, row.source, row.position, row.path);
|
|
12251
|
-
copiedProps.add(propKey);
|
|
12252
|
-
}
|
|
12253
|
-
copiedCount = copiedProps.size;
|
|
12254
|
-
db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, targetSessionId);
|
|
12255
|
-
db.exec("COMMIT");
|
|
12256
|
-
} catch (e) {
|
|
12257
|
-
db.exec("ROLLBACK");
|
|
12258
|
-
throw e;
|
|
12259
|
-
}
|
|
12260
|
-
return copiedCount;
|
|
12261
|
-
}
|
|
12262
|
-
async function getCliCacheVersion() {
|
|
12263
|
-
if (_cliCacheVersionCache) return _cliCacheVersionCache;
|
|
12264
|
-
try {
|
|
12265
|
-
const { hashContent: hashContent2 } = await Promise.resolve().then(() => (init_cache_keys(), cache_keys_exports));
|
|
12266
|
-
const { resolveSkillPath: resolveSkillPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
12267
|
-
const skills = ["components", "tokens", "select"];
|
|
12268
|
-
const parts = [];
|
|
12269
|
-
for (const s of skills) {
|
|
12270
|
-
try {
|
|
12271
|
-
const p = resolveSkillPath2(s);
|
|
12272
|
-
parts.push(readFileSync5(p, "utf8"));
|
|
12273
|
-
} catch {
|
|
12274
|
-
parts.push(`<missing:${s}>`);
|
|
12275
|
-
}
|
|
12276
|
-
}
|
|
12277
|
-
_cliCacheVersionCache = hashContent2(parts.join("\n---\n"));
|
|
12278
|
-
return _cliCacheVersionCache;
|
|
12279
|
-
} catch {
|
|
12280
|
-
_cliCacheVersionCache = "fallback";
|
|
12281
|
-
return _cliCacheVersionCache;
|
|
12282
|
-
}
|
|
12283
|
-
}
|
|
12284
|
-
function storeExtractCache(db, filePath, fileHash, cliVersion2, components) {
|
|
12285
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12286
|
-
const componentsJson = JSON.stringify(components);
|
|
12287
|
-
db.prepare(
|
|
12288
|
-
`INSERT INTO extract_cache (file_path, file_hash, cli_version, created_at, updated_at, components_json)
|
|
12289
|
-
VALUES (?, ?, ?, ?, ?, ?)
|
|
12290
|
-
ON CONFLICT(file_hash, cli_version) DO UPDATE SET
|
|
12291
|
-
file_path = excluded.file_path,
|
|
12292
|
-
updated_at = excluded.updated_at,
|
|
12293
|
-
components_json = excluded.components_json`
|
|
12294
|
-
).run(filePath, fileHash, cliVersion2, now, now, componentsJson);
|
|
12295
|
-
}
|
|
12296
|
-
function lookupExtractCache(db, fileHash, cliVersion2) {
|
|
12297
|
-
const row = db.prepare(
|
|
12298
|
-
`SELECT file_path, file_hash, cli_version, created_at, updated_at, components_json
|
|
12299
|
-
FROM extract_cache
|
|
12300
|
-
WHERE file_hash = ? AND cli_version = ?`
|
|
12301
|
-
).get(fileHash, cliVersion2);
|
|
12302
|
-
if (!row) return null;
|
|
12303
|
-
let components = [];
|
|
12304
|
-
try {
|
|
12305
|
-
components = JSON.parse(row.components_json);
|
|
12306
|
-
} catch {
|
|
12307
|
-
return null;
|
|
12308
|
-
}
|
|
12309
|
-
return {
|
|
12310
|
-
filePath: row.file_path,
|
|
12311
|
-
fileHash: row.file_hash,
|
|
12312
|
-
cliVersion: row.cli_version,
|
|
12313
|
-
createdAt: row.created_at,
|
|
12314
|
-
updatedAt: row.updated_at,
|
|
12315
|
-
components
|
|
12316
|
-
};
|
|
12317
|
-
}
|
|
12318
|
-
function storeSelectCache(db, componentHash, promptHash, cliVersion2, decision, reason) {
|
|
12319
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
12320
|
-
db.prepare(
|
|
12321
|
-
`INSERT INTO select_cache (component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at)
|
|
12322
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
12323
|
-
ON CONFLICT(component_hash, prompt_hash, cli_version) DO UPDATE SET
|
|
12324
|
-
decision = excluded.decision,
|
|
12325
|
-
reason = excluded.reason,
|
|
12326
|
-
updated_at = excluded.updated_at`
|
|
12327
|
-
).run(componentHash, promptHash, cliVersion2, decision, reason, now, now);
|
|
12328
|
-
}
|
|
12329
|
-
function lookupSelectCache(db, componentHash, promptHash, cliVersion2) {
|
|
12330
|
-
const row = db.prepare(
|
|
12331
|
-
`SELECT component_hash, prompt_hash, cli_version, decision, reason, created_at, updated_at
|
|
12332
|
-
FROM select_cache
|
|
12333
|
-
WHERE component_hash = ? AND prompt_hash = ? AND cli_version = ?`
|
|
12334
|
-
).get(componentHash, promptHash, cliVersion2);
|
|
12335
|
-
if (!row) return null;
|
|
12336
|
-
return {
|
|
12337
|
-
componentHash: row.component_hash,
|
|
12338
|
-
promptHash: row.prompt_hash,
|
|
12339
|
-
cliVersion: row.cli_version,
|
|
12340
|
-
decision: row.decision,
|
|
12341
|
-
reason: row.reason,
|
|
12342
|
-
createdAt: row.created_at,
|
|
12343
|
-
updatedAt: row.updated_at
|
|
12344
|
-
};
|
|
12345
|
-
}
|
|
12346
|
-
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;
|
|
11766
|
+
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;
|
|
12347
11767
|
var init_db = __esm({
|
|
12348
11768
|
"packages/experience-design-system-cli-legacy/src/session/db.ts"() {
|
|
12349
11769
|
"use strict";
|
|
@@ -12357,8 +11777,6 @@ var init_db = __esm({
|
|
|
12357
11777
|
init_write2();
|
|
12358
11778
|
init_session_resolver();
|
|
12359
11779
|
init_read3();
|
|
12360
|
-
init_hash_component_shape();
|
|
12361
|
-
init_hash_token_content();
|
|
12362
11780
|
init_read3();
|
|
12363
11781
|
init_store_dtcg_tokens();
|
|
12364
11782
|
init_apply_tool_calls();
|
|
@@ -12482,17 +11900,6 @@ CREATE TABLE IF NOT EXISTS raw_tokens (
|
|
|
12482
11900
|
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
12483
11901
|
);
|
|
12484
11902
|
|
|
12485
|
-
CREATE TABLE IF NOT EXISTS generation_cache (
|
|
12486
|
-
input_hash TEXT NOT NULL,
|
|
12487
|
-
entity_type TEXT NOT NULL CHECK (entity_type IN ('component', 'token_set', 'token_mapping')),
|
|
12488
|
-
entity_id TEXT NOT NULL,
|
|
12489
|
-
source_session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
12490
|
-
human_edited INTEGER NOT NULL DEFAULT 0 CHECK (human_edited IN (0, 1)),
|
|
12491
|
-
created_at TEXT NOT NULL,
|
|
12492
|
-
updated_at TEXT NOT NULL,
|
|
12493
|
-
PRIMARY KEY (input_hash, entity_type, entity_id)
|
|
12494
|
-
);
|
|
12495
|
-
|
|
12496
11903
|
CREATE TABLE IF NOT EXISTS scanned_files (
|
|
12497
11904
|
session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
12498
11905
|
path TEXT NOT NULL,
|
|
@@ -12538,10 +11945,9 @@ CREATE INDEX IF NOT EXISTS idx_raw_props_session ON raw_props(session_id,
|
|
|
12538
11945
|
CREATE INDEX IF NOT EXISTS idx_raw_slots_session ON raw_slots(session_id, component_id);
|
|
12539
11946
|
CREATE INDEX IF NOT EXISTS idx_raw_tokens_session ON raw_tokens(session_id);
|
|
12540
11947
|
CREATE INDEX IF NOT EXISTS idx_raw_token_groups_session ON raw_token_groups(session_id);
|
|
12541
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_entity ON generation_cache(entity_type, entity_id);
|
|
12542
|
-
CREATE INDEX IF NOT EXISTS idx_generation_cache_session ON generation_cache(source_session_id);
|
|
12543
11948
|
CREATE INDEX IF NOT EXISTS idx_scanned_files_session ON scanned_files(session_id);
|
|
12544
11949
|
`;
|
|
11950
|
+
REMOVED_CACHE_TABLES = ["generation_cache", "extract_cache", "composition_cache", "select_cache"];
|
|
12545
11951
|
MAX_COMPONENT_SOURCE_CHARS = 8e3;
|
|
12546
11952
|
MAX_SIBLING_FILES = 5;
|
|
12547
11953
|
MAX_SIBLING_SNIPPET_CHARS = 1200;
|
|
@@ -12558,16 +11964,15 @@ CREATE INDEX IF NOT EXISTS idx_scanned_files_session ON scanned_files(session
|
|
|
12558
11964
|
[".cjs", [".cts", ".cjs"]]
|
|
12559
11965
|
];
|
|
12560
11966
|
IDENTIFIER_PATTERN = /[A-Za-z_$][A-Za-z0-9_$]*/g;
|
|
12561
|
-
_cliCacheVersionCache = null;
|
|
12562
11967
|
}
|
|
12563
11968
|
});
|
|
12564
11969
|
|
|
12565
11970
|
// packages/experience-design-system-cli-legacy/src/helpers/read-existing-contentful-entities-from-session.ts
|
|
12566
|
-
import { readFile as
|
|
11971
|
+
import { readFile as readFile8 } from "node:fs/promises";
|
|
12567
11972
|
async function readExistingContentfulEntitiesFromSession(path) {
|
|
12568
11973
|
if (!path) return void 0;
|
|
12569
11974
|
try {
|
|
12570
|
-
const raw = await
|
|
11975
|
+
const raw = await readFile8(path, "utf8");
|
|
12571
11976
|
const parsed = JSON.parse(raw);
|
|
12572
11977
|
if (!Array.isArray(parsed.components) || !Array.isArray(parsed.tokens)) return void 0;
|
|
12573
11978
|
return parsed;
|
|
@@ -12691,21 +12096,21 @@ var init_resolve_session_id = __esm({
|
|
|
12691
12096
|
});
|
|
12692
12097
|
|
|
12693
12098
|
// packages/experience-design-system-cli-legacy/src/analyze/select/persistence.ts
|
|
12694
|
-
import { access, appendFile, mkdir as mkdir2, readFile as
|
|
12099
|
+
import { access, appendFile, mkdir as mkdir2, readFile as readFile9, writeFile as writeFile2 } from "node:fs/promises";
|
|
12695
12100
|
import { homedir as homedir4 } from "node:os";
|
|
12696
|
-
import { resolve as
|
|
12101
|
+
import { resolve as resolve9 } from "node:path";
|
|
12697
12102
|
function getRefineArtifactsRoot() {
|
|
12698
12103
|
if (process.env.EDS_REVIEW_ARTIFACTS_DIR) {
|
|
12699
|
-
return
|
|
12104
|
+
return resolve9(process.env.EDS_REVIEW_ARTIFACTS_DIR);
|
|
12700
12105
|
}
|
|
12701
|
-
return
|
|
12106
|
+
return resolve9(homedir4(), ".contentful", "experience-design-system-cli", "reviews");
|
|
12702
12107
|
}
|
|
12703
12108
|
async function getRefineSessionPaths(sessionId2, artifactsRoot) {
|
|
12704
|
-
const sessionDir =
|
|
12109
|
+
const sessionDir = resolve9(artifactsRoot, sessionId2);
|
|
12705
12110
|
return {
|
|
12706
12111
|
sessionDir,
|
|
12707
|
-
eventsPath:
|
|
12708
|
-
statePath:
|
|
12112
|
+
eventsPath: resolve9(sessionDir, "events.jsonl"),
|
|
12113
|
+
statePath: resolve9(sessionDir, "current-review-state.json")
|
|
12709
12114
|
};
|
|
12710
12115
|
}
|
|
12711
12116
|
async function saveReviewState(statePath, session) {
|
|
@@ -12716,7 +12121,7 @@ async function ensureRefineSession(sessionId2, artifactsRoot, initialSnapshot) {
|
|
|
12716
12121
|
await mkdir2(paths.sessionDir, { recursive: true });
|
|
12717
12122
|
try {
|
|
12718
12123
|
await access(paths.statePath);
|
|
12719
|
-
const savedState = await
|
|
12124
|
+
const savedState = await readFile9(paths.statePath, "utf8");
|
|
12720
12125
|
return JSON.parse(savedState);
|
|
12721
12126
|
} catch {
|
|
12722
12127
|
await writeFile2(paths.statePath, JSON.stringify(initialSnapshot, null, 2), "utf8");
|
|
@@ -13201,8 +12606,8 @@ var init_path_exists = __esm({
|
|
|
13201
12606
|
});
|
|
13202
12607
|
|
|
13203
12608
|
// packages/experience-design-system-cli-legacy/src/lib/prompt-overrides.ts
|
|
13204
|
-
import { readFile as
|
|
13205
|
-
import { resolve as
|
|
12609
|
+
import { readFile as readFile10 } from "node:fs/promises";
|
|
12610
|
+
import { resolve as resolve10 } from "node:path";
|
|
13206
12611
|
function looksLikePath(value) {
|
|
13207
12612
|
if (value.includes("/") || value.includes("\\")) return true;
|
|
13208
12613
|
if (value.startsWith("~")) return true;
|
|
@@ -13234,9 +12639,9 @@ function parsePromptOverrides(inputs) {
|
|
|
13234
12639
|
}
|
|
13235
12640
|
async function resolvePromptOverride(override) {
|
|
13236
12641
|
if (override.kind === "text") return override.value;
|
|
13237
|
-
const abs =
|
|
12642
|
+
const abs = resolve10(override.value);
|
|
13238
12643
|
try {
|
|
13239
|
-
return await
|
|
12644
|
+
return await readFile10(abs, "utf8");
|
|
13240
12645
|
} catch {
|
|
13241
12646
|
throw new Error(`--prompt: could not read prompt file: ${abs}`);
|
|
13242
12647
|
}
|
|
@@ -13251,21 +12656,21 @@ var init_prompt_overrides = __esm({
|
|
|
13251
12656
|
|
|
13252
12657
|
// packages/experience-design-system-cli-legacy/src/generate/command.ts
|
|
13253
12658
|
import { createElement } from "react";
|
|
13254
|
-
import { readFile as
|
|
13255
|
-
import { join as join14, resolve as
|
|
12659
|
+
import { readFile as readFile11, readdir, stat } from "node:fs/promises";
|
|
12660
|
+
import { join as join14, resolve as resolve11 } from "node:path";
|
|
13256
12661
|
async function assertFileExists(flag, p) {
|
|
13257
12662
|
if (!await pathExists(p)) die(`Error: file not found: ${p} (from ${flag})`);
|
|
13258
12663
|
}
|
|
13259
12664
|
async function readFileInline(path) {
|
|
13260
12665
|
if (!path) return void 0;
|
|
13261
|
-
const resolved =
|
|
12666
|
+
const resolved = resolve11(path);
|
|
13262
12667
|
let s;
|
|
13263
12668
|
try {
|
|
13264
12669
|
s = await stat(resolved);
|
|
13265
12670
|
} catch {
|
|
13266
12671
|
return void 0;
|
|
13267
12672
|
}
|
|
13268
|
-
if (!s.isDirectory()) return
|
|
12673
|
+
if (!s.isDirectory()) return readFile11(resolved, "utf8");
|
|
13269
12674
|
const files = [];
|
|
13270
12675
|
async function walk(dir) {
|
|
13271
12676
|
let entries;
|
|
@@ -13291,7 +12696,7 @@ async function readFileInline(path) {
|
|
|
13291
12696
|
}
|
|
13292
12697
|
await walk(resolved);
|
|
13293
12698
|
if (files.length === 0) return void 0;
|
|
13294
|
-
const parts = await Promise.all(files.map((f) =>
|
|
12699
|
+
const parts = await Promise.all(files.map((f) => readFile11(f, "utf8").catch(() => "")));
|
|
13295
12700
|
return parts.filter(Boolean).join("\n\n");
|
|
13296
12701
|
}
|
|
13297
12702
|
function printFallbackInstructions(options) {
|
|
@@ -13313,23 +12718,6 @@ function printFallbackInstructions(options) {
|
|
|
13313
12718
|
lines.push(` Re-run the generate command with the agent available, or use --dry-run to inspect the prompt.`);
|
|
13314
12719
|
process.stderr.write(lines.join("\n") + "\n");
|
|
13315
12720
|
}
|
|
13316
|
-
function createCachedComponentResult(componentName, warnings = []) {
|
|
13317
|
-
return {
|
|
13318
|
-
componentName,
|
|
13319
|
-
classified: 0,
|
|
13320
|
-
excluded: 0,
|
|
13321
|
-
slots: 0,
|
|
13322
|
-
warnings,
|
|
13323
|
-
failed: false,
|
|
13324
|
-
cached: true,
|
|
13325
|
-
renamedSlotsCount: 0
|
|
13326
|
-
};
|
|
13327
|
-
}
|
|
13328
|
-
function writeCachedComponentStatus(position, componentName, pinned) {
|
|
13329
|
-
const status = pinned ? c.cyan("pinned (human-edited)") : c.green("cached");
|
|
13330
|
-
process.stderr.write(` ${position} ${c.bold(componentName)} ${status}
|
|
13331
|
-
`);
|
|
13332
|
-
}
|
|
13333
12721
|
async function showGenerateView(result) {
|
|
13334
12722
|
if (process.stdout.isTTY) {
|
|
13335
12723
|
const { waitUntilExit } = renderWithGoodbye(
|
|
@@ -13350,29 +12738,6 @@ session=${result.sessionId}
|
|
|
13350
12738
|
);
|
|
13351
12739
|
await exitWithAnalytics(0);
|
|
13352
12740
|
}
|
|
13353
|
-
function normalizeComponentForCache(component) {
|
|
13354
|
-
const slots = component.slots.map((slot, index, allSlots) => ({
|
|
13355
|
-
...slot,
|
|
13356
|
-
name: slot.name.trim() || (allSlots.length === 1 ? "children" : `slot_${index}`)
|
|
13357
|
-
}));
|
|
13358
|
-
return { ...component, slots };
|
|
13359
|
-
}
|
|
13360
|
-
function lookupComponentCache(db, component, promptHash) {
|
|
13361
|
-
const normalized = normalizeComponentForCache(component);
|
|
13362
|
-
const inputHash = hashComponentShape(normalized);
|
|
13363
|
-
const cached = lookupCache(db, inputHash, "component", component.component_id, promptHash);
|
|
13364
|
-
if (cached) return cached;
|
|
13365
|
-
const legacyInputHash = hashComponentShape(component);
|
|
13366
|
-
return legacyInputHash === inputHash ? null : lookupCache(db, legacyInputHash, "component", component.component_id, promptHash);
|
|
13367
|
-
}
|
|
13368
|
-
function resolveComponentCache(db, component, promptHash, allowedComponentNames2) {
|
|
13369
|
-
const cached = lookupComponentCache(db, component, promptHash);
|
|
13370
|
-
if (cached && findUnknownSlotAllowedComponents(db, cached.sourceSessionId, allowedComponentNames2, component.component_id).length === 0) {
|
|
13371
|
-
return { entry: cached, humanEdited: cached.humanEdited };
|
|
13372
|
-
}
|
|
13373
|
-
const pinned = lookupCacheByEntity(db, "component", component.component_id);
|
|
13374
|
-
return pinned?.humanEdited && findUnknownSlotAllowedComponents(db, pinned.sourceSessionId, allowedComponentNames2, component.component_id).length === 0 ? { entry: pinned, humanEdited: true } : null;
|
|
13375
|
-
}
|
|
13376
12741
|
async function runOneComponent(options, component, index, total) {
|
|
13377
12742
|
const {
|
|
13378
12743
|
agent,
|
|
@@ -13382,13 +12747,10 @@ async function runOneComponent(options, component, index, total) {
|
|
|
13382
12747
|
tokensInline,
|
|
13383
12748
|
tokenMapInline,
|
|
13384
12749
|
verbose,
|
|
13385
|
-
noCache,
|
|
13386
12750
|
skillPathOverride,
|
|
13387
12751
|
skillContentOverride,
|
|
13388
|
-
promptHash,
|
|
13389
12752
|
existingContentfulEntities,
|
|
13390
12753
|
existingTokensInline,
|
|
13391
|
-
precomputedCachedNames,
|
|
13392
12754
|
allowedComponentNames: allowedComponentNames2
|
|
13393
12755
|
} = options;
|
|
13394
12756
|
const pos = c.dim(`[${index + 1}/${total}]`);
|
|
@@ -13413,40 +12775,6 @@ async function runOneComponent(options, component, index, total) {
|
|
|
13413
12775
|
allowedComponents: slot.allowedComponents.filter((name) => allowedComponentNames2.has(name))
|
|
13414
12776
|
};
|
|
13415
12777
|
});
|
|
13416
|
-
const cacheComponent = normalizeComponentForCache(component);
|
|
13417
|
-
if (!noCache && precomputedCachedNames.has(component.name)) {
|
|
13418
|
-
writeCachedComponentStatus(pos, component.name, false);
|
|
13419
|
-
return createCachedComponentResult(component.name);
|
|
13420
|
-
}
|
|
13421
|
-
if (!noCache) {
|
|
13422
|
-
const inputHash = hashComponentShape(cacheComponent);
|
|
13423
|
-
const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
|
|
13424
|
-
if (resolution && !resolution.humanEdited) {
|
|
13425
|
-
copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId2, component.component_id, true, {
|
|
13426
|
-
allowedComponentNames: allowedComponentNames2
|
|
13427
|
-
});
|
|
13428
|
-
storeCache(
|
|
13429
|
-
db,
|
|
13430
|
-
inputHash,
|
|
13431
|
-
"component",
|
|
13432
|
-
component.component_id,
|
|
13433
|
-
resolution.entry.sourceSessionId,
|
|
13434
|
-
resolution.entry.humanEdited,
|
|
13435
|
-
promptHash
|
|
13436
|
-
);
|
|
13437
|
-
writeCachedComponentStatus(pos, component.name, false);
|
|
13438
|
-
return createCachedComponentResult(component.name);
|
|
13439
|
-
}
|
|
13440
|
-
if (resolution?.humanEdited) {
|
|
13441
|
-
copyComponentFromCache(db, resolution.entry.sourceSessionId, sessionId2, component.component_id, true, {
|
|
13442
|
-
allowedComponentNames: allowedComponentNames2
|
|
13443
|
-
});
|
|
13444
|
-
writeCachedComponentStatus(pos, component.name, true);
|
|
13445
|
-
return createCachedComponentResult(`${component.name}`, [
|
|
13446
|
-
`${component.name}: source changed but human edits preserved`
|
|
13447
|
-
]);
|
|
13448
|
-
}
|
|
13449
|
-
}
|
|
13450
12778
|
const componentBuckets = bucketComponentProps(component);
|
|
13451
12779
|
getDebugLogger().event("analyze", "prop-buckets.generate", { ...componentBuckets });
|
|
13452
12780
|
const rawComponentsInline = JSON.stringify(
|
|
@@ -13521,10 +12849,6 @@ ${outputBuf}`);
|
|
|
13521
12849
|
const applied = applyToolCalls(db, sessionId2, component.component_id, component.name, calls, warnings, {
|
|
13522
12850
|
allowedComponentNames: allowedComponentNames2
|
|
13523
12851
|
});
|
|
13524
|
-
if (!noCache) {
|
|
13525
|
-
const inputHash = hashComponentShape(cacheComponent);
|
|
13526
|
-
storeCache(db, inputHash, "component", component.component_id, sessionId2, false, promptHash);
|
|
13527
|
-
}
|
|
13528
12852
|
return {
|
|
13529
12853
|
componentName: component.name,
|
|
13530
12854
|
classified: applied.classified,
|
|
@@ -13576,7 +12900,7 @@ async function loadAcceptedNames(sessionId2) {
|
|
|
13576
12900
|
try {
|
|
13577
12901
|
const artifactsRoot = getRefineArtifactsRoot();
|
|
13578
12902
|
const paths = await getRefineSessionPaths(sessionId2, artifactsRoot);
|
|
13579
|
-
const raw = await
|
|
12903
|
+
const raw = await readFile11(paths.statePath, "utf8");
|
|
13580
12904
|
const snapshot = JSON.parse(raw);
|
|
13581
12905
|
const accepted = snapshot.components.filter((c2) => c2.status === "accepted").map((c2) => c2.name);
|
|
13582
12906
|
if (accepted.length === 0) return null;
|
|
@@ -13585,15 +12909,6 @@ async function loadAcceptedNames(sessionId2) {
|
|
|
13585
12909
|
return null;
|
|
13586
12910
|
}
|
|
13587
12911
|
}
|
|
13588
|
-
function parsePrecomputedCachedNames(value) {
|
|
13589
|
-
if (!value) return /* @__PURE__ */ new Set();
|
|
13590
|
-
try {
|
|
13591
|
-
const parsed = JSON.parse(value);
|
|
13592
|
-
return new Set(Array.isArray(parsed) ? parsed.filter((name) => typeof name === "string") : []);
|
|
13593
|
-
} catch {
|
|
13594
|
-
return /* @__PURE__ */ new Set();
|
|
13595
|
-
}
|
|
13596
|
-
}
|
|
13597
12912
|
async function runGenerateSkill(skill, opts, verbose = false) {
|
|
13598
12913
|
const savedCreds = await readExperiencesCredentials();
|
|
13599
12914
|
const agentName = opts.agent ?? savedCreds.agent;
|
|
@@ -13622,8 +12937,8 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13622
12937
|
}
|
|
13623
12938
|
const generatePromptPath = generatePrompt === void 0 ? configuredGeneratePromptPath : void 0;
|
|
13624
12939
|
if (generatePromptPath) {
|
|
13625
|
-
if (!await pathExists(
|
|
13626
|
-
die(`Error: custom prompt path not found: ${
|
|
12940
|
+
if (!await pathExists(resolve11(generatePromptPath))) {
|
|
12941
|
+
die(`Error: custom prompt path not found: ${resolve11(generatePromptPath)}`);
|
|
13627
12942
|
}
|
|
13628
12943
|
if (!generatePromptPath.toLowerCase().endsWith(".md")) {
|
|
13629
12944
|
process.stderr.write(
|
|
@@ -13631,7 +12946,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13631
12946
|
`
|
|
13632
12947
|
);
|
|
13633
12948
|
}
|
|
13634
|
-
process.stderr.write(formatCustomPromptBanner("components",
|
|
12949
|
+
process.stderr.write(formatCustomPromptBanner("components", resolve11(generatePromptPath)));
|
|
13635
12950
|
}
|
|
13636
12951
|
if (skill === "tokens" && !opts.rawTokens) {
|
|
13637
12952
|
die("Error: --raw-tokens is required when using generate tokens");
|
|
@@ -13647,7 +12962,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13647
12962
|
let existingContentfulEntities;
|
|
13648
12963
|
let existingTokensInline;
|
|
13649
12964
|
if (opts.existingEntitiesPath) {
|
|
13650
|
-
existingContentfulEntities = await readExistingContentfulEntitiesFromSession(
|
|
12965
|
+
existingContentfulEntities = await readExistingContentfulEntitiesFromSession(resolve11(opts.existingEntitiesPath));
|
|
13651
12966
|
if (existingContentfulEntities) {
|
|
13652
12967
|
existingTokensInline = JSON.stringify(summarizeForMapTokens(existingContentfulEntities));
|
|
13653
12968
|
} else {
|
|
@@ -13748,7 +13063,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13748
13063
|
rawComponentsInline: sampleInline ?? rawTokensInline,
|
|
13749
13064
|
propBucketsInline: sampleBuckets ? JSON.stringify(sampleBuckets) : void 0,
|
|
13750
13065
|
rawTokensInline: skill === "tokens" ? rawTokensInline : void 0,
|
|
13751
|
-
rawTokensFilename: opts.rawTokens ?
|
|
13066
|
+
rawTokensFilename: opts.rawTokens ? resolve11(opts.rawTokens).split("/").pop() : void 0,
|
|
13752
13067
|
tokensInline,
|
|
13753
13068
|
tokenMapInline,
|
|
13754
13069
|
outDir: process.cwd(),
|
|
@@ -13774,64 +13089,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13774
13089
|
if (skill === "components" && allComponents && sessionId2) {
|
|
13775
13090
|
const db = openPipelineDb();
|
|
13776
13091
|
let componentResults;
|
|
13777
|
-
const precomputedCachedNames = parsePrecomputedCachedNames(opts.cachedComponents);
|
|
13778
13092
|
try {
|
|
13779
|
-
const existingContentfulEntitiesHashInputs = [];
|
|
13780
|
-
if (existingTokensInline) existingContentfulEntitiesHashInputs.push(hashContent(existingTokensInline));
|
|
13781
|
-
const promptHash = await hashPromptForSkill(
|
|
13782
|
-
"components",
|
|
13783
|
-
agent,
|
|
13784
|
-
model,
|
|
13785
|
-
generatePromptPath,
|
|
13786
|
-
existingContentfulEntitiesHashInputs,
|
|
13787
|
-
generatePrompt
|
|
13788
|
-
);
|
|
13789
|
-
if (opts.cacheStatus) {
|
|
13790
|
-
const cacheEnabled = opts.cache !== false && process.env.EDS_NO_CACHE !== "1";
|
|
13791
|
-
const cachedComponents = cacheEnabled ? allComponents.flatMap((component) => {
|
|
13792
|
-
const resolution = resolveComponentCache(db, component, promptHash, allowedComponentNames2);
|
|
13793
|
-
return resolution ? [{ component, resolution }] : [];
|
|
13794
|
-
}) : [];
|
|
13795
|
-
if (cacheEnabled && opts.restoreCache) {
|
|
13796
|
-
const restorations = [];
|
|
13797
|
-
const rekeyed = [];
|
|
13798
|
-
const componentStatus = db.prepare(
|
|
13799
|
-
"SELECT status FROM raw_components WHERE session_id = ? AND component_id = ?"
|
|
13800
|
-
);
|
|
13801
|
-
for (const { component, resolution } of cachedComponents) {
|
|
13802
|
-
const current = componentStatus.get(sessionId2, component.component_id);
|
|
13803
|
-
if (current?.status === "generated") continue;
|
|
13804
|
-
renameEmptySlots(db, sessionId2, component.component_id, component.name, component.slots.length);
|
|
13805
|
-
restorations.push({
|
|
13806
|
-
sourceSessionId: resolution.entry.sourceSessionId,
|
|
13807
|
-
targetSessionId: sessionId2,
|
|
13808
|
-
componentId: component.component_id
|
|
13809
|
-
});
|
|
13810
|
-
rekeyed.push({ component, cached: resolution.entry });
|
|
13811
|
-
}
|
|
13812
|
-
copyComponentsFromCache(db, restorations, { allowedComponentNames: allowedComponentNames2 });
|
|
13813
|
-
storeCaches(
|
|
13814
|
-
db,
|
|
13815
|
-
rekeyed.map(({ component, cached }) => ({
|
|
13816
|
-
inputHash: hashComponentShape(normalizeComponentForCache(component)),
|
|
13817
|
-
entityType: "component",
|
|
13818
|
-
entityId: component.component_id,
|
|
13819
|
-
sourceSessionId: cached.sourceSessionId,
|
|
13820
|
-
humanEdited: cached.humanEdited,
|
|
13821
|
-
promptHash
|
|
13822
|
-
}))
|
|
13823
|
-
);
|
|
13824
|
-
}
|
|
13825
|
-
const fullyCached = cacheEnabled && cachedComponents.length === allComponents.length;
|
|
13826
|
-
process.stdout.write(`cache-status=${fullyCached ? "hit" : "miss"}
|
|
13827
|
-
`);
|
|
13828
|
-
process.stdout.write(
|
|
13829
|
-
`cache-components=${JSON.stringify(cachedComponents.map(({ component }) => component.name))}
|
|
13830
|
-
`
|
|
13831
|
-
);
|
|
13832
|
-
await exitWithAnalytics(0);
|
|
13833
|
-
return;
|
|
13834
|
-
}
|
|
13835
13093
|
componentResults = await runAllComponents(
|
|
13836
13094
|
{
|
|
13837
13095
|
agent,
|
|
@@ -13841,13 +13099,10 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13841
13099
|
tokensInline,
|
|
13842
13100
|
tokenMapInline,
|
|
13843
13101
|
verbose,
|
|
13844
|
-
noCache: opts.cache === false || process.env.EDS_NO_CACHE === "1",
|
|
13845
13102
|
skillPathOverride: generatePromptPath,
|
|
13846
13103
|
skillContentOverride: generatePrompt,
|
|
13847
|
-
promptHash,
|
|
13848
13104
|
existingContentfulEntities,
|
|
13849
13105
|
existingTokensInline,
|
|
13850
|
-
precomputedCachedNames,
|
|
13851
13106
|
allowedComponentNames: allowedComponentNames2
|
|
13852
13107
|
},
|
|
13853
13108
|
allComponents
|
|
@@ -13856,8 +13111,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13856
13111
|
db.close();
|
|
13857
13112
|
}
|
|
13858
13113
|
const failed = componentResults.filter((r) => r.failed);
|
|
13859
|
-
const
|
|
13860
|
-
const generated = componentResults.filter((r) => !r.failed && !r.cached);
|
|
13114
|
+
const generated = componentResults.filter((r) => !r.failed);
|
|
13861
13115
|
const allWarnings = componentResults.flatMap((r) => r.warnings.map((w) => ` ${r.componentName}: ${w}`));
|
|
13862
13116
|
if (allWarnings.length > 0) {
|
|
13863
13117
|
process.stderr.write(c.yellow("Warnings:") + "\n" + allWarnings.join("\n") + "\n");
|
|
@@ -13873,21 +13127,17 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13873
13127
|
const totalExcluded = generated.reduce((s, r) => s + r.excluded, 0);
|
|
13874
13128
|
const totalRenamedSlots = componentResults.reduce((s, r) => s + r.renamedSlotsCount, 0);
|
|
13875
13129
|
const allOk = failed.length === 0;
|
|
13876
|
-
const cachedNote = cachedResults.length > 0 ? c.dim(` (${cachedResults.length} cached)`) : "";
|
|
13877
13130
|
process.stderr.write(
|
|
13878
|
-
(allOk ? c.green("\u2713") : c.yellow("\u26A0")) + ` ${generated.length
|
|
13131
|
+
(allOk ? c.green("\u2713") : c.yellow("\u26A0")) + ` ${generated.length}/${componentResults.length} components` + c.dim(` ${totalClassified} classified, ${totalExcluded} unattached`) + "\n"
|
|
13879
13132
|
);
|
|
13880
13133
|
process.stdout.write(`renamed-slots: ${totalRenamedSlots}
|
|
13881
13134
|
`);
|
|
13882
|
-
if (generated.length === 0
|
|
13135
|
+
if (generated.length === 0) {
|
|
13883
13136
|
die(
|
|
13884
13137
|
`Error: all ${componentResults.length} component(s) failed to generate \u2014 see the per-component errors above.`
|
|
13885
13138
|
);
|
|
13886
13139
|
}
|
|
13887
13140
|
} else if (skill === "tokens") {
|
|
13888
|
-
const noCache = opts.cache === false || process.env.EDS_NO_CACHE === "1";
|
|
13889
|
-
const tokenInputContent = rawTokensInline ?? "";
|
|
13890
|
-
const tokenInputHash = hashTokenContent(tokenInputContent);
|
|
13891
13141
|
const db = openPipelineDb();
|
|
13892
13142
|
try {
|
|
13893
13143
|
let resolvedSessionId = opts.session;
|
|
@@ -13914,26 +13164,11 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
13914
13164
|
}
|
|
13915
13165
|
sessionId2 = resolvedSessionId;
|
|
13916
13166
|
await bindAnalyticsSessionId(resolvedSessionId);
|
|
13917
|
-
const tokenPromptHash = await hashPromptForSkill("tokens", agent, model);
|
|
13918
|
-
if (!noCache) {
|
|
13919
|
-
const tokenCached = lookupCache(db, tokenInputHash, "token_set", "__tokens__", tokenPromptHash);
|
|
13920
|
-
if (tokenCached) {
|
|
13921
|
-
copyTokensFromCache(db, tokenCached.sourceSessionId, resolvedSessionId);
|
|
13922
|
-
sessionId2 = resolvedSessionId;
|
|
13923
|
-
process.stderr.write(
|
|
13924
|
-
`Done: tokens reused from cache ${c.dim(`(source: ${tokenCached.sourceSessionId.slice(0, 12)})`)}
|
|
13925
|
-
`
|
|
13926
|
-
);
|
|
13927
|
-
db.close();
|
|
13928
|
-
await showGenerateView({ skill, agent, sessionId: sessionId2 ?? "" });
|
|
13929
|
-
return;
|
|
13930
|
-
}
|
|
13931
|
-
}
|
|
13932
13167
|
const prompt = await buildPrompt({
|
|
13933
13168
|
skill,
|
|
13934
13169
|
mode: "autonomous",
|
|
13935
13170
|
rawTokensInline,
|
|
13936
|
-
rawTokensFilename: opts.rawTokens ?
|
|
13171
|
+
rawTokensFilename: opts.rawTokens ? resolve11(opts.rawTokens).split("/").pop() : void 0,
|
|
13937
13172
|
tokensInline,
|
|
13938
13173
|
tokenMapInline,
|
|
13939
13174
|
outDir: process.cwd()
|
|
@@ -13970,9 +13205,6 @@ ${tokenWarnings.map((w) => ` ${w}`).join("\n")}
|
|
|
13970
13205
|
`);
|
|
13971
13206
|
}
|
|
13972
13207
|
applyTokenToolCalls(db, resolvedSessionId, tokenCalls, []);
|
|
13973
|
-
if (!noCache) {
|
|
13974
|
-
storeCache(db, tokenInputHash, "token_set", "__tokens__", resolvedSessionId, false, tokenPromptHash);
|
|
13975
|
-
}
|
|
13976
13208
|
sessionId2 = resolvedSessionId;
|
|
13977
13209
|
const groupCount = tokenCalls.filter((tc) => tc.tool === "set_group").length;
|
|
13978
13210
|
process.stderr.write(`Done: ${tokenCount} tokens, ${groupCount} groups stored
|
|
@@ -13984,10 +13216,7 @@ ${tokenWarnings.map((w) => ` ${w}`).join("\n")}
|
|
|
13984
13216
|
await showGenerateView({ skill, agent, sessionId: sessionId2 ?? "" });
|
|
13985
13217
|
}
|
|
13986
13218
|
function addAgentFlags(cmd) {
|
|
13987
|
-
return addAgentModelOptions(cmd).option("--verbose", "Show full agent output including reasoning text").option("--dry-run", "Print the prompt without invoking the agent")
|
|
13988
|
-
"--no-cache",
|
|
13989
|
-
"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."
|
|
13990
|
-
);
|
|
13219
|
+
return addAgentModelOptions(cmd).option("--verbose", "Show full agent output including reasoning text").option("--dry-run", "Print the prompt without invoking the agent");
|
|
13991
13220
|
}
|
|
13992
13221
|
function registerInternalGenerateCommand(program) {
|
|
13993
13222
|
const generate = program.command("__generate", { hidden: true }).description("Internal import pipeline generation command");
|
|
@@ -14003,12 +13232,6 @@ function registerInternalGenerateCommand(program) {
|
|
|
14003
13232
|
"--existing-entities-path <path>",
|
|
14004
13233
|
"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."
|
|
14005
13234
|
);
|
|
14006
|
-
componentsCmd.option("--cache-status", "Check whether all selected component definitions are cached");
|
|
14007
|
-
componentsCmd.option("--restore-cache", "Restore cached component definitions into the current session");
|
|
14008
|
-
componentsCmd.option(
|
|
14009
|
-
"--cached-components <json>",
|
|
14010
|
-
"Component names already restored by a prior cache-status lookup; skip per-component cache lookup"
|
|
14011
|
-
);
|
|
14012
13235
|
addAgentFlags(componentsCmd).action(async (opts) => {
|
|
14013
13236
|
await runGenerateSkill("components", opts, opts.verbose ?? false);
|
|
14014
13237
|
});
|
|
@@ -14034,7 +13257,6 @@ var init_command = __esm({
|
|
|
14034
13257
|
init_agent_output();
|
|
14035
13258
|
init_GenerateView();
|
|
14036
13259
|
init_db();
|
|
14037
|
-
init_cache_keys();
|
|
14038
13260
|
init_read_existing_contentful_entities_from_session();
|
|
14039
13261
|
init_summarize_existing_contentful_entities();
|
|
14040
13262
|
init_resolve_session_id();
|
|
@@ -14750,7 +13972,7 @@ var init_user_agent = __esm({
|
|
|
14750
13972
|
// packages/experience-design-system-cli-legacy/src/apply/api-client.ts
|
|
14751
13973
|
import { parseCDFComponents } from "@contentful/experience-design-system-types";
|
|
14752
13974
|
function defaultSleep(delayMs) {
|
|
14753
|
-
return new Promise((
|
|
13975
|
+
return new Promise((resolve20) => setTimeout(resolve20, delayMs));
|
|
14754
13976
|
}
|
|
14755
13977
|
function isTransientStatus(status) {
|
|
14756
13978
|
return status >= 500 && status <= 599;
|
|
@@ -15140,7 +14362,7 @@ ${trimmed}`;
|
|
|
15140
14362
|
const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
|
|
15141
14363
|
const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
|
|
15142
14364
|
const jitter = Math.random() * baseDelay * 0.15;
|
|
15143
|
-
await new Promise((
|
|
14365
|
+
await new Promise((resolve20) => setTimeout(resolve20, baseDelay + jitter));
|
|
15144
14366
|
}
|
|
15145
14367
|
}
|
|
15146
14368
|
throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
|
|
@@ -15950,7 +15172,7 @@ var init_terminal_capabilities = __esm({
|
|
|
15950
15172
|
|
|
15951
15173
|
// packages/experience-design-system-cli-legacy/src/apply/command.ts
|
|
15952
15174
|
import { createElement as createElement2 } from "react";
|
|
15953
|
-
import { readFile as
|
|
15175
|
+
import { readFile as readFile12, readdir as readdir2, stat as stat2 } from "node:fs/promises";
|
|
15954
15176
|
import { join as join16 } from "node:path";
|
|
15955
15177
|
import {
|
|
15956
15178
|
validateCDF,
|
|
@@ -15971,7 +15193,7 @@ function dieWithApiError(error) {
|
|
|
15971
15193
|
async function readJsonFile(flag, p) {
|
|
15972
15194
|
let text;
|
|
15973
15195
|
try {
|
|
15974
|
-
text = await
|
|
15196
|
+
text = await readFile12(p, "utf8");
|
|
15975
15197
|
} catch {
|
|
15976
15198
|
return await die2(`Error: file not found: ${p} (from ${flag})`);
|
|
15977
15199
|
}
|
|
@@ -16025,7 +15247,7 @@ async function readTokensFromPath(flag, p) {
|
|
|
16025
15247
|
for (const file of files.sort()) {
|
|
16026
15248
|
let text;
|
|
16027
15249
|
try {
|
|
16028
|
-
text = await
|
|
15250
|
+
text = await readFile12(file, "utf8");
|
|
16029
15251
|
} catch {
|
|
16030
15252
|
continue;
|
|
16031
15253
|
}
|
|
@@ -16394,11 +15616,11 @@ var init_command2 = __esm({
|
|
|
16394
15616
|
});
|
|
16395
15617
|
|
|
16396
15618
|
// packages/experience-design-system-cli-legacy/src/print/validate/validators/read-json-file.ts
|
|
16397
|
-
import { readFile as
|
|
15619
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
16398
15620
|
async function readJsonFile2(filePath) {
|
|
16399
15621
|
let content;
|
|
16400
15622
|
try {
|
|
16401
|
-
content = await
|
|
15623
|
+
content = await readFile13(filePath, "utf-8");
|
|
16402
15624
|
} catch (err) {
|
|
16403
15625
|
return {
|
|
16404
15626
|
ok: false,
|
|
@@ -16809,7 +16031,7 @@ var init_ValidateView = __esm({
|
|
|
16809
16031
|
// packages/experience-design-system-cli-legacy/src/print/command.ts
|
|
16810
16032
|
import { createElement as createElement3 } from "react";
|
|
16811
16033
|
import { access as access3, mkdir as mkdir3, stat as stat3, writeFile as writeFile3 } from "node:fs/promises";
|
|
16812
|
-
import { basename as basename5, resolve as
|
|
16034
|
+
import { basename as basename5, resolve as resolve12 } from "node:path";
|
|
16813
16035
|
import { CDF_SCHEMA_URL } from "@contentful/experience-design-system-types";
|
|
16814
16036
|
async function die3(message) {
|
|
16815
16037
|
process.stderr.write(`${message}
|
|
@@ -16876,7 +16098,7 @@ function registerPrintCommand(program) {
|
|
|
16876
16098
|
"--allow-empty",
|
|
16877
16099
|
"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."
|
|
16878
16100
|
).action(async (opts) => {
|
|
16879
|
-
const outPath =
|
|
16101
|
+
const outPath = resolve12(opts.out);
|
|
16880
16102
|
await assertOutIsNotDirectory(outPath);
|
|
16881
16103
|
const sessionId2 = await resolveSession(opts.session, "generate components");
|
|
16882
16104
|
await bindAnalyticsSessionId(sessionId2);
|
|
@@ -16924,7 +16146,7 @@ function registerPrintCommand(program) {
|
|
|
16924
16146
|
`
|
|
16925
16147
|
);
|
|
16926
16148
|
}
|
|
16927
|
-
await mkdir3(
|
|
16149
|
+
await mkdir3(resolve12(outPath, ".."), { recursive: true });
|
|
16928
16150
|
await writeFile3(outPath, `${JSON.stringify(cdfObj, null, 2)}
|
|
16929
16151
|
`);
|
|
16930
16152
|
process.stdout.write(
|
|
@@ -16933,7 +16155,7 @@ function registerPrintCommand(program) {
|
|
|
16933
16155
|
);
|
|
16934
16156
|
});
|
|
16935
16157
|
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) => {
|
|
16936
|
-
const outPath =
|
|
16158
|
+
const outPath = resolve12(opts.out);
|
|
16937
16159
|
await assertOutIsNotDirectory(outPath);
|
|
16938
16160
|
const sessionId2 = await resolveSession(opts.session, "generate tokens");
|
|
16939
16161
|
await bindAnalyticsSessionId(sessionId2);
|
|
@@ -16948,7 +16170,7 @@ function registerPrintCommand(program) {
|
|
|
16948
16170
|
await die3(`Error: no generated tokens in session '${sessionId2}'. Run generate tokens first.`);
|
|
16949
16171
|
}
|
|
16950
16172
|
const tree = rebuildDTCGTree(result.groups, result.tokens);
|
|
16951
|
-
await mkdir3(
|
|
16173
|
+
await mkdir3(resolve12(outPath, ".."), { recursive: true });
|
|
16952
16174
|
await writeFile3(outPath, `${JSON.stringify(tree, null, 2)}
|
|
16953
16175
|
`);
|
|
16954
16176
|
process.stdout.write(
|
|
@@ -17097,7 +16319,7 @@ function MapTokensView({ result, onExit }) {
|
|
|
17097
16319
|
const timer = setTimeout(onExit, 100);
|
|
17098
16320
|
return () => clearTimeout(timer);
|
|
17099
16321
|
}, [onExit]);
|
|
17100
|
-
const summary =
|
|
16322
|
+
const summary = `${result.applied} mapping${result.applied === 1 ? "" : "s"} applied`;
|
|
17101
16323
|
return /* @__PURE__ */ jsx8(
|
|
17102
16324
|
CommandCompletionView,
|
|
17103
16325
|
{
|
|
@@ -17231,8 +16453,8 @@ var init_resolve_defaults = __esm({
|
|
|
17231
16453
|
|
|
17232
16454
|
// packages/experience-design-system-cli-legacy/src/map-tokens/command.ts
|
|
17233
16455
|
import { createElement as createElement4 } from "react";
|
|
17234
|
-
import { readFile as
|
|
17235
|
-
import { resolve as
|
|
16456
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
16457
|
+
import { resolve as resolve13 } from "node:path";
|
|
17236
16458
|
async function renderResult(result) {
|
|
17237
16459
|
if (process.stdout.isTTY) {
|
|
17238
16460
|
const { waitUntilExit } = renderWithGoodbye(
|
|
@@ -17240,12 +16462,13 @@ async function renderResult(result) {
|
|
|
17240
16462
|
);
|
|
17241
16463
|
await waitUntilExit();
|
|
17242
16464
|
} else {
|
|
17243
|
-
|
|
17244
|
-
|
|
16465
|
+
process.stdout.write(
|
|
16466
|
+
`map tokens complete
|
|
17245
16467
|
agent: ${result.agent}
|
|
17246
16468
|
session=${result.sessionId}
|
|
17247
|
-
${
|
|
17248
|
-
`
|
|
16469
|
+
${result.applied} mapping(s) applied
|
|
16470
|
+
`
|
|
16471
|
+
);
|
|
17249
16472
|
await exitWithAnalytics(0);
|
|
17250
16473
|
}
|
|
17251
16474
|
}
|
|
@@ -17267,7 +16490,7 @@ async function runMapTokens(opts) {
|
|
|
17267
16490
|
let mapPromptPath;
|
|
17268
16491
|
if (mapPromptOverride?.kind === "text") mapPromptText = mapPromptOverride.value;
|
|
17269
16492
|
if (mapPromptOverride?.kind === "path") {
|
|
17270
|
-
mapPromptPath =
|
|
16493
|
+
mapPromptPath = resolve13(mapPromptOverride.value);
|
|
17271
16494
|
try {
|
|
17272
16495
|
await resolvePromptOverride(mapPromptOverride);
|
|
17273
16496
|
} catch (error) {
|
|
@@ -17287,7 +16510,7 @@ async function runMapTokens(opts) {
|
|
|
17287
16510
|
const knownTokenPaths = new Set(tokenLeaves.map((t) => t.path));
|
|
17288
16511
|
const tokenMapDiagnostics = [];
|
|
17289
16512
|
if (opts.tokenMap) {
|
|
17290
|
-
const fileMappings = JSON.parse(await
|
|
16513
|
+
const fileMappings = JSON.parse(await readFile14(opts.tokenMap, "utf8"));
|
|
17291
16514
|
const validMappings = {};
|
|
17292
16515
|
for (const [rawName, path] of Object.entries(fileMappings)) {
|
|
17293
16516
|
if (knownTokenPaths.has(path)) {
|
|
@@ -17365,7 +16588,7 @@ ${defaultDiagnostics.map((diagnostic) => ` ${diagnostic}`).join("\n")}
|
|
|
17365
16588
|
let existingTokensInline;
|
|
17366
16589
|
if (opts.existingEntitiesPath) {
|
|
17367
16590
|
const existingContentfulEntities = await readExistingContentfulEntitiesFromSession(
|
|
17368
|
-
|
|
16591
|
+
resolve13(opts.existingEntitiesPath)
|
|
17369
16592
|
);
|
|
17370
16593
|
if (existingContentfulEntities) {
|
|
17371
16594
|
existingTokensInline = JSON.stringify(summarizeForMapTokens(existingContentfulEntities));
|
|
@@ -17400,30 +16623,10 @@ ${defaultDiagnostics.map((diagnostic) => ` ${diagnostic}`).join("\n")}
|
|
|
17400
16623
|
skipAgent: "true"
|
|
17401
16624
|
});
|
|
17402
16625
|
updateStep(db, stepId2, "complete", { applied: "0", skipAgent: "true" });
|
|
17403
|
-
await renderResult({ agent: resultAgent, sessionId: sessionId2, applied: 0
|
|
16626
|
+
await renderResult({ agent: resultAgent, sessionId: sessionId2, applied: 0 });
|
|
17404
16627
|
return;
|
|
17405
16628
|
}
|
|
17406
16629
|
const agent = configuredAgent;
|
|
17407
|
-
const noCache = opts.cache === false || process.env.EDS_NO_CACHE === "1";
|
|
17408
|
-
const promptHash = await hashPromptForSkill(
|
|
17409
|
-
"map-tokens",
|
|
17410
|
-
agent,
|
|
17411
|
-
model,
|
|
17412
|
-
void 0,
|
|
17413
|
-
existingTokensInline ? [hashContent(existingTokensInline)] : [],
|
|
17414
|
-
mapPromptText
|
|
17415
|
-
);
|
|
17416
|
-
const inputHash = computeMapTokensInputHash(db, sessionId2, componentSourceRefs);
|
|
17417
|
-
if (!noCache) {
|
|
17418
|
-
const cached = lookupCache(db, inputHash, "token_mapping", "__map_tokens__", promptHash);
|
|
17419
|
-
if (cached) {
|
|
17420
|
-
const appliedFromCache = copyMapTokensFromCache(db, cached.sourceSessionId, sessionId2);
|
|
17421
|
-
const stepId2 = createStep(db, sessionId2, "map tokens", { agent, model: model ?? "" });
|
|
17422
|
-
updateStep(db, stepId2, "complete", { cached: "true", applied: String(appliedFromCache) });
|
|
17423
|
-
await renderResult({ agent, sessionId: sessionId2, applied: appliedFromCache, cached: true });
|
|
17424
|
-
return;
|
|
17425
|
-
}
|
|
17426
|
-
}
|
|
17427
16630
|
const binary = resolveAgentBinary(agent);
|
|
17428
16631
|
if (!await assertBinaryInPath(binary)) {
|
|
17429
16632
|
die(
|
|
@@ -17443,23 +16646,20 @@ Install it, choose another agent with --agent, or use --print-prompt to run the
|
|
|
17443
16646
|
}
|
|
17444
16647
|
const { calls, warnings: parseWarnings } = parseMapTokenPropToolCallLines(result.stdout);
|
|
17445
16648
|
const { applied, warnings } = applyMapTokenPropCalls(db, sessionId2, calls, parseWarnings);
|
|
17446
|
-
if (!noCache) {
|
|
17447
|
-
storeCache(db, inputHash, "token_mapping", "__map_tokens__", sessionId2, false, promptHash);
|
|
17448
|
-
}
|
|
17449
16649
|
updateStep(db, stepId, "complete", { applied: String(applied), warnings: String(warnings.length) });
|
|
17450
16650
|
if (warnings.length > 0) {
|
|
17451
16651
|
process.stderr.write(`Warnings:
|
|
17452
16652
|
${warnings.map((w) => ` ${w}`).join("\n")}
|
|
17453
16653
|
`);
|
|
17454
16654
|
}
|
|
17455
|
-
await renderResult({ agent, sessionId: sessionId2, applied
|
|
16655
|
+
await renderResult({ agent, sessionId: sessionId2, applied });
|
|
17456
16656
|
} finally {
|
|
17457
16657
|
db.close();
|
|
17458
16658
|
}
|
|
17459
16659
|
}
|
|
17460
16660
|
function registerMapTokensCommand(program) {
|
|
17461
16661
|
const map = program.command("map", { hidden: true }).description("Suggest token restrictions for generated design-token props");
|
|
17462
|
-
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(
|
|
16662
|
+
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(
|
|
17463
16663
|
"--prompt <stage=value>",
|
|
17464
16664
|
"Override a stage prompt (repeatable). Used here for the map-tokens stage.",
|
|
17465
16665
|
(v, acc) => [...acc, v],
|
|
@@ -17479,7 +16679,6 @@ var init_command4 = __esm({
|
|
|
17479
16679
|
init_render_with_goodbye();
|
|
17480
16680
|
init_src();
|
|
17481
16681
|
init_db();
|
|
17482
|
-
init_cache_keys();
|
|
17483
16682
|
init_read_existing_contentful_entities_from_session();
|
|
17484
16683
|
init_summarize_existing_contentful_entities();
|
|
17485
16684
|
init_command3();
|
|
@@ -17496,7 +16695,7 @@ var init_command4 = __esm({
|
|
|
17496
16695
|
});
|
|
17497
16696
|
|
|
17498
16697
|
// packages/experience-design-system-cli-legacy/src/import/path-utils.ts
|
|
17499
|
-
import { resolve as
|
|
16698
|
+
import { resolve as resolve14 } from "node:path";
|
|
17500
16699
|
import { homedir as homedir5 } from "node:os";
|
|
17501
16700
|
function expandTilde(input) {
|
|
17502
16701
|
if (input === "~" || input.startsWith("~/") || input.startsWith("~\\")) {
|
|
@@ -17510,7 +16709,7 @@ function normalizePath(input) {
|
|
|
17510
16709
|
p = p.slice(1, -1);
|
|
17511
16710
|
}
|
|
17512
16711
|
p = expandTilde(p);
|
|
17513
|
-
return
|
|
16712
|
+
return resolve14(p);
|
|
17514
16713
|
}
|
|
17515
16714
|
var init_path_utils = __esm({
|
|
17516
16715
|
"packages/experience-design-system-cli-legacy/src/import/path-utils.ts"() {
|
|
@@ -17735,7 +16934,7 @@ var init_save_path_resolver = __esm({
|
|
|
17735
16934
|
});
|
|
17736
16935
|
|
|
17737
16936
|
// packages/experience-design-system-cli-legacy/src/runs/store.ts
|
|
17738
|
-
import { readFile as
|
|
16937
|
+
import { readFile as readFile15, writeFile as writeFile4, mkdir as mkdir4, rename } from "node:fs/promises";
|
|
17739
16938
|
import { join as join20 } from "node:path";
|
|
17740
16939
|
import { homedir as homedir6 } from "node:os";
|
|
17741
16940
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
@@ -17775,7 +16974,7 @@ function migrateRecord(rec) {
|
|
|
17775
16974
|
}
|
|
17776
16975
|
async function readFileMaybe() {
|
|
17777
16976
|
try {
|
|
17778
|
-
const raw = await
|
|
16977
|
+
const raw = await readFile15(RUNS_PATH, "utf8");
|
|
17779
16978
|
const parsed = JSON.parse(raw);
|
|
17780
16979
|
if (!READABLE_VERSIONS.has(parsed.version)) {
|
|
17781
16980
|
throw new Error(
|
|
@@ -17839,15 +17038,15 @@ var init_store = __esm({
|
|
|
17839
17038
|
});
|
|
17840
17039
|
|
|
17841
17040
|
// packages/experience-design-system-cli-legacy/src/runs/fingerprint.ts
|
|
17842
|
-
import { createHash as
|
|
17843
|
-
import { readFile as
|
|
17844
|
-
import { resolve as
|
|
17041
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
17042
|
+
import { readFile as readFile16, stat as stat4 } from "node:fs/promises";
|
|
17043
|
+
import { resolve as resolve15 } from "node:path";
|
|
17845
17044
|
function rowField(row, key) {
|
|
17846
17045
|
const v = row[key];
|
|
17847
17046
|
return typeof v === "string" ? v : null;
|
|
17848
17047
|
}
|
|
17849
17048
|
function sha256Hex(buf) {
|
|
17850
|
-
return
|
|
17049
|
+
return createHash2("sha256").update(buf).digest("hex");
|
|
17851
17050
|
}
|
|
17852
17051
|
async function buildSourceFingerprint(opts) {
|
|
17853
17052
|
const rows = opts.db.prepare("SELECT name, source_path FROM raw_components WHERE session_id = ?").all(opts.extractSessionId);
|
|
@@ -17857,7 +17056,7 @@ async function buildSourceFingerprint(opts) {
|
|
|
17857
17056
|
const sourcePath = rowField(row, "source_path");
|
|
17858
17057
|
const name = rowField(row, "name");
|
|
17859
17058
|
if (!sourcePath) continue;
|
|
17860
|
-
const abs =
|
|
17059
|
+
const abs = resolve15(sourcePath);
|
|
17861
17060
|
if (seen.has(abs)) continue;
|
|
17862
17061
|
seen.add(abs);
|
|
17863
17062
|
try {
|
|
@@ -17872,10 +17071,10 @@ async function buildSourceFingerprint(opts) {
|
|
|
17872
17071
|
let rawTokensMtime = null;
|
|
17873
17072
|
let rawTokensContentHash = null;
|
|
17874
17073
|
if (opts.rawTokensPath) {
|
|
17875
|
-
const abs =
|
|
17074
|
+
const abs = resolve15(opts.rawTokensPath);
|
|
17876
17075
|
rawTokensPath = abs;
|
|
17877
17076
|
try {
|
|
17878
|
-
const [st, buf] = await Promise.all([stat4(abs),
|
|
17077
|
+
const [st, buf] = await Promise.all([stat4(abs), readFile16(abs)]);
|
|
17879
17078
|
rawTokensMtime = st.mtime.toISOString();
|
|
17880
17079
|
rawTokensContentHash = sha256Hex(buf);
|
|
17881
17080
|
} catch {
|
|
@@ -19630,11 +18829,11 @@ var init_slot_graph = __esm({
|
|
|
19630
18829
|
});
|
|
19631
18830
|
|
|
19632
18831
|
// packages/experience-design-system-cli-legacy/src/analyze/select/parser.ts
|
|
19633
|
-
import { createHash as
|
|
18832
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
19634
18833
|
import { access as access5 } from "node:fs/promises";
|
|
19635
|
-
import { isAbsolute, relative, resolve as
|
|
18834
|
+
import { isAbsolute, relative, resolve as resolve16 } from "node:path";
|
|
19636
18835
|
function createComponentId(name, resolvedSourcePath) {
|
|
19637
|
-
const sourceHash =
|
|
18836
|
+
const sourceHash = createHash3("sha256").update(`${name}:${resolvedSourcePath}`).digest("hex").slice(0, 12);
|
|
19638
18837
|
return `${name}-${sourceHash}`;
|
|
19639
18838
|
}
|
|
19640
18839
|
async function resolveComponentSourcePath(source, reviewRoot) {
|
|
@@ -19646,7 +18845,7 @@ async function resolveComponentSourcePath(source, reviewRoot) {
|
|
|
19646
18845
|
throw new Error(`Unable to access component source at ${source}`);
|
|
19647
18846
|
}
|
|
19648
18847
|
}
|
|
19649
|
-
const candidate =
|
|
18848
|
+
const candidate = resolve16(reviewRoot, source);
|
|
19650
18849
|
const relativeToRoot = relative(reviewRoot, candidate);
|
|
19651
18850
|
if (relativeToRoot.startsWith("..") || relativeToRoot === ".." || isAbsolute(relativeToRoot)) {
|
|
19652
18851
|
throw new Error(
|
|
@@ -19661,7 +18860,7 @@ async function resolveComponentSourcePath(source, reviewRoot) {
|
|
|
19661
18860
|
}
|
|
19662
18861
|
}
|
|
19663
18862
|
async function loadReviewInput(components, options = {}) {
|
|
19664
|
-
const reviewRoot =
|
|
18863
|
+
const reviewRoot = resolve16(options.reviewRoot ?? process.cwd());
|
|
19665
18864
|
const records = await Promise.all(
|
|
19666
18865
|
components.map(async (component) => {
|
|
19667
18866
|
let resolvedSourcePath;
|
|
@@ -19692,7 +18891,7 @@ var init_parser = __esm({
|
|
|
19692
18891
|
});
|
|
19693
18892
|
|
|
19694
18893
|
// packages/experience-design-system-cli-legacy/src/analyze/select/command.ts
|
|
19695
|
-
import { access as access6, readFile as
|
|
18894
|
+
import { access as access6, readFile as readFile17 } from "node:fs/promises";
|
|
19696
18895
|
async function loadAndValidateForReview(sessionId2, projectRoot) {
|
|
19697
18896
|
const db = openPipelineDb();
|
|
19698
18897
|
let rawComponents;
|
|
@@ -19710,7 +18909,7 @@ async function patchReviewStateWithValidationErrors(sessionId2, errors, opts = {
|
|
|
19710
18909
|
let snapshot;
|
|
19711
18910
|
try {
|
|
19712
18911
|
await access6(paths.statePath);
|
|
19713
|
-
snapshot = JSON.parse(await
|
|
18912
|
+
snapshot = JSON.parse(await readFile17(paths.statePath, "utf8"));
|
|
19714
18913
|
} catch {
|
|
19715
18914
|
snapshot = await loadAndValidateForReview(sessionId2, void 0);
|
|
19716
18915
|
snapshot = await ensureRefineSession(sessionId2, artifactsRoot, snapshot);
|
|
@@ -19761,7 +18960,7 @@ async function rejectComponentsByName(sessionId2, names, opts = {}) {
|
|
|
19761
18960
|
const nameSet = new Set(names);
|
|
19762
18961
|
let snapshot;
|
|
19763
18962
|
try {
|
|
19764
|
-
snapshot = JSON.parse(await
|
|
18963
|
+
snapshot = JSON.parse(await readFile17(paths.statePath, "utf8"));
|
|
19765
18964
|
} catch {
|
|
19766
18965
|
return;
|
|
19767
18966
|
}
|
|
@@ -19860,9 +19059,9 @@ function spawnGenerateChild(opts) {
|
|
|
19860
19059
|
stderr += chunk;
|
|
19861
19060
|
opts.onStderr?.(chunk);
|
|
19862
19061
|
});
|
|
19863
|
-
const donePromise = new Promise((
|
|
19062
|
+
const donePromise = new Promise((resolve20) => {
|
|
19864
19063
|
child.on("close", (code, signal) => {
|
|
19865
|
-
|
|
19064
|
+
resolve20({
|
|
19866
19065
|
exitCode: code ?? 0,
|
|
19867
19066
|
signal: signal ?? null,
|
|
19868
19067
|
stdout,
|
|
@@ -19870,7 +19069,7 @@ function spawnGenerateChild(opts) {
|
|
|
19870
19069
|
});
|
|
19871
19070
|
});
|
|
19872
19071
|
child.on("error", (err) => {
|
|
19873
|
-
|
|
19072
|
+
resolve20({
|
|
19874
19073
|
exitCode: 1,
|
|
19875
19074
|
signal: null,
|
|
19876
19075
|
stdout,
|
|
@@ -28008,9 +27207,6 @@ function shouldGenerateAfterCredentialsValidated(opts) {
|
|
|
28008
27207
|
function shouldSkipFinalReviewAfterCredentials(state) {
|
|
28009
27208
|
return state.finalReviewPassed && state.generateSessionId != null;
|
|
28010
27209
|
}
|
|
28011
|
-
function resolveNoCacheForGenerate(opts) {
|
|
28012
|
-
return opts.cliNoCache;
|
|
28013
|
-
}
|
|
28014
27210
|
function shouldBypassPreview(state) {
|
|
28015
27211
|
return state.credentialsSkipped === true;
|
|
28016
27212
|
}
|
|
@@ -28037,70 +27233,43 @@ var init_wizard_state_transitions = __esm({
|
|
|
28037
27233
|
async function runSelectionAgent(options) {
|
|
28038
27234
|
const db = openPipelineDb();
|
|
28039
27235
|
let components;
|
|
28040
|
-
const cachedDecisions = /* @__PURE__ */ new Map();
|
|
28041
|
-
const cliVersion2 = await getCliCacheVersion();
|
|
28042
|
-
const promptHash = await hashPromptForSkill(
|
|
28043
|
-
"select",
|
|
28044
|
-
options.agent,
|
|
28045
|
-
options.model,
|
|
28046
|
-
options.promptPath,
|
|
28047
|
-
[SELECT_PAYLOAD_FORMAT],
|
|
28048
|
-
options.promptText
|
|
28049
|
-
);
|
|
28050
27236
|
try {
|
|
28051
27237
|
components = loadRawComponents(db, options.sessionId);
|
|
28052
|
-
if (!options.noCache) {
|
|
28053
|
-
for (const component of components) {
|
|
28054
|
-
const componentHash = hashComponentShape(component);
|
|
28055
|
-
const cached = lookupSelectCache(db, componentHash, promptHash, cliVersion2);
|
|
28056
|
-
if (cached) {
|
|
28057
|
-
cachedDecisions.set(component.name, {
|
|
28058
|
-
decision: cached.decision,
|
|
28059
|
-
reason: cached.reason
|
|
28060
|
-
});
|
|
28061
|
-
}
|
|
28062
|
-
}
|
|
28063
|
-
}
|
|
28064
27238
|
} finally {
|
|
28065
27239
|
db.close();
|
|
28066
27240
|
}
|
|
28067
27241
|
if (components.length === 0) return;
|
|
28068
|
-
const
|
|
28069
|
-
|
|
28070
|
-
|
|
28071
|
-
|
|
28072
|
-
|
|
28073
|
-
});
|
|
28074
|
-
const selectBuckets = bucketComponentsProps(componentsToRun);
|
|
28075
|
-
for (const assignment of selectBuckets) {
|
|
28076
|
-
getDebugLogger().event("analyze", "prop-buckets.select", { ...assignment });
|
|
28077
|
-
}
|
|
28078
|
-
const prompt = await buildPrompt({
|
|
28079
|
-
skill: "select",
|
|
28080
|
-
mode: "autonomous",
|
|
28081
|
-
rawComponentsInline: JSON.stringify(
|
|
28082
|
-
componentsToRun.map((component) => ({ ...component, props: component.props.map(stripPropProvenance) })),
|
|
28083
|
-
null,
|
|
28084
|
-
2
|
|
28085
|
-
),
|
|
28086
|
-
propBucketsInline: JSON.stringify(selectBuckets),
|
|
28087
|
-
outDir: process.cwd(),
|
|
28088
|
-
...options.promptText !== void 0 ? { skillContentOverride: options.promptText } : {},
|
|
28089
|
-
...options.promptText === void 0 && options.promptPath ? { skillPathOverride: options.promptPath } : {}
|
|
28090
|
-
});
|
|
28091
|
-
const { result } = await invokeAgentWithOutput(
|
|
28092
|
-
invoker2,
|
|
28093
|
-
{ agent: options.agent, model: options.model, prompt, timeoutMs: DEFAULT_TIMEOUT_MS4 },
|
|
28094
|
-
false
|
|
28095
|
-
);
|
|
28096
|
-
if (result.timedOut) throw new Error("selection agent timed out");
|
|
28097
|
-
if (result.exitCode !== 0) throw new Error(`selection agent exited with code ${result.exitCode}`);
|
|
28098
|
-
const parsed = parseSelectToolCallLines(result.stdout);
|
|
28099
|
-
for (const warning of parsed.warnings) process.stderr.write(`Warning: selection agent: ${warning}
|
|
28100
|
-
`);
|
|
28101
|
-
calls = parsed.calls;
|
|
27242
|
+
const invoker2 = createLocalCliAgentInvoker({
|
|
27243
|
+
onDebugEvent: (name, payload) => getDebugLogger().event("agent", name, payload)
|
|
27244
|
+
});
|
|
27245
|
+
const selectBuckets = bucketComponentsProps(components);
|
|
27246
|
+
for (const assignment of selectBuckets) {
|
|
27247
|
+
getDebugLogger().event("analyze", "prop-buckets.select", { ...assignment });
|
|
28102
27248
|
}
|
|
28103
|
-
const
|
|
27249
|
+
const prompt = await buildPrompt({
|
|
27250
|
+
skill: "select",
|
|
27251
|
+
mode: "autonomous",
|
|
27252
|
+
rawComponentsInline: JSON.stringify(
|
|
27253
|
+
components.map((component) => ({ ...component, props: component.props.map(stripPropProvenance) })),
|
|
27254
|
+
null,
|
|
27255
|
+
2
|
|
27256
|
+
),
|
|
27257
|
+
propBucketsInline: JSON.stringify(selectBuckets),
|
|
27258
|
+
outDir: process.cwd(),
|
|
27259
|
+
...options.promptText !== void 0 ? { skillContentOverride: options.promptText } : {},
|
|
27260
|
+
...options.promptText === void 0 && options.promptPath ? { skillPathOverride: options.promptPath } : {}
|
|
27261
|
+
});
|
|
27262
|
+
const { result } = await invokeAgentWithOutput(
|
|
27263
|
+
invoker2,
|
|
27264
|
+
{ agent: options.agent, model: options.model, prompt, timeoutMs: DEFAULT_TIMEOUT_MS4 },
|
|
27265
|
+
false
|
|
27266
|
+
);
|
|
27267
|
+
if (result.timedOut) throw new Error("selection agent timed out");
|
|
27268
|
+
if (result.exitCode !== 0) throw new Error(`selection agent exited with code ${result.exitCode}`);
|
|
27269
|
+
const parsed = parseSelectToolCallLines(result.stdout);
|
|
27270
|
+
for (const warning of parsed.warnings) process.stderr.write(`Warning: selection agent: ${warning}
|
|
27271
|
+
`);
|
|
27272
|
+
const byName = new Map(parsed.calls.map((call) => [call.name, call]));
|
|
28104
27273
|
const writeDb = openPipelineDb();
|
|
28105
27274
|
try {
|
|
28106
27275
|
writeDb.exec("BEGIN");
|
|
@@ -28108,27 +27277,15 @@ async function runSelectionAgent(options) {
|
|
|
28108
27277
|
`UPDATE raw_components SET status = ?, reject_reason = ? WHERE session_id = ? AND component_id = ?`
|
|
28109
27278
|
);
|
|
28110
27279
|
for (const component of components) {
|
|
28111
|
-
const cached = cachedDecisions.get(component.name);
|
|
28112
27280
|
const call = byName.get(component.name);
|
|
28113
|
-
if (!
|
|
28114
|
-
const rejected =
|
|
28115
|
-
const reason = cached ? cached.reason : call.reason ?? null;
|
|
27281
|
+
if (!call) continue;
|
|
27282
|
+
const rejected = call.tool === "reject_component";
|
|
28116
27283
|
update.run(
|
|
28117
27284
|
rejected ? "rejected" : "accepted",
|
|
28118
|
-
rejected ? reason : null,
|
|
27285
|
+
rejected ? call.reason ?? null : null,
|
|
28119
27286
|
options.sessionId,
|
|
28120
27287
|
component.component_id
|
|
28121
27288
|
);
|
|
28122
|
-
if (!cached) {
|
|
28123
|
-
storeSelectCache(
|
|
28124
|
-
writeDb,
|
|
28125
|
-
hashComponentShape(component),
|
|
28126
|
-
promptHash,
|
|
28127
|
-
cliVersion2,
|
|
28128
|
-
rejected ? "rejected" : "accepted",
|
|
28129
|
-
rejected ? reason : null
|
|
28130
|
-
);
|
|
28131
|
-
}
|
|
28132
27289
|
}
|
|
28133
27290
|
writeDb.exec("COMMIT");
|
|
28134
27291
|
} catch (error) {
|
|
@@ -28138,7 +27295,7 @@ async function runSelectionAgent(options) {
|
|
|
28138
27295
|
writeDb.close();
|
|
28139
27296
|
}
|
|
28140
27297
|
}
|
|
28141
|
-
var
|
|
27298
|
+
var DEFAULT_TIMEOUT_MS4;
|
|
28142
27299
|
var init_run_selection_agent = __esm({
|
|
28143
27300
|
"packages/experience-design-system-cli-legacy/src/import/tui/run-selection-agent.ts"() {
|
|
28144
27301
|
"use strict";
|
|
@@ -28147,8 +27304,6 @@ var init_run_selection_agent = __esm({
|
|
|
28147
27304
|
init_debug_logger();
|
|
28148
27305
|
init_agent_output();
|
|
28149
27306
|
init_db();
|
|
28150
|
-
init_cache_keys();
|
|
28151
|
-
SELECT_PAYLOAD_FORMAT = "prop-buckets-v1";
|
|
28152
27307
|
DEFAULT_TIMEOUT_MS4 = Number(process.env.EDS_AGENT_TIMEOUT_MS ?? 5 * 60 * 1e3);
|
|
28153
27308
|
}
|
|
28154
27309
|
});
|
|
@@ -28167,7 +27322,7 @@ __export(WizardApp_exports, {
|
|
|
28167
27322
|
});
|
|
28168
27323
|
import { useEffect as useEffect15, useRef as useRef10, useState as useState23 } from "react";
|
|
28169
27324
|
import { Box as Box42, Text as Text46 } from "ink";
|
|
28170
|
-
import { join as join23, resolve as
|
|
27325
|
+
import { join as join23, resolve as resolve17 } from "node:path";
|
|
28171
27326
|
import { appendFileSync as appendFileSync2, writeFileSync } from "node:fs";
|
|
28172
27327
|
import { access as access7, stat as stat5, writeFile as writeFile6 } from "node:fs/promises";
|
|
28173
27328
|
import { tmpdir } from "node:os";
|
|
@@ -28180,28 +27335,21 @@ function buildGenerateComponentsArgs(opts) {
|
|
|
28180
27335
|
if (opts.tokensPath) args.push("--tokens", opts.tokensPath);
|
|
28181
27336
|
if (opts.model) args.push("--model", opts.model);
|
|
28182
27337
|
if (opts.bedrock) args.push("--bedrock");
|
|
28183
|
-
if (opts.noCache) args.push("--no-cache");
|
|
28184
27338
|
if (opts.generatePromptPath) args.push("--generate-prompt-path", opts.generatePromptPath);
|
|
28185
27339
|
for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
|
|
28186
27340
|
if (opts.existingEntitiesPath) args.push("--existing-entities-path", opts.existingEntitiesPath);
|
|
28187
|
-
if (opts.restoreCache) args.push("--restore-cache");
|
|
28188
|
-
if (opts.cachedComponents && opts.cachedComponents.length > 0) {
|
|
28189
|
-
args.push("--cached-components", JSON.stringify(opts.cachedComponents));
|
|
28190
|
-
}
|
|
28191
27341
|
return args;
|
|
28192
27342
|
}
|
|
28193
27343
|
function buildGenerateTokensArgs(opts) {
|
|
28194
27344
|
const args = [findCliPath(), "__generate", "tokens", "--agent", opts.agent, "--raw-tokens", opts.rawTokensPath];
|
|
28195
27345
|
if (opts.model) args.push("--model", opts.model);
|
|
28196
27346
|
if (opts.bedrock) args.push("--bedrock");
|
|
28197
|
-
if (opts.noCache) args.push("--no-cache");
|
|
28198
27347
|
for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
|
|
28199
27348
|
return args;
|
|
28200
27349
|
}
|
|
28201
27350
|
function buildMapTokensArgs(opts) {
|
|
28202
27351
|
const args = ["map", "tokens", "--session", opts.sessionId, "--agent", opts.agent];
|
|
28203
27352
|
if (opts.model) args.push("--model", opts.model);
|
|
28204
|
-
if (opts.noCache) args.push("--no-cache");
|
|
28205
27353
|
if (opts.skipAgent) args.push("--skip-agent");
|
|
28206
27354
|
for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
|
|
28207
27355
|
if (opts.existingEntitiesPath) args.push("--existing-entities-path", opts.existingEntitiesPath);
|
|
@@ -28293,7 +27441,6 @@ function WizardApp({
|
|
|
28293
27441
|
initialProjectPath,
|
|
28294
27442
|
host,
|
|
28295
27443
|
promptOverrides,
|
|
28296
|
-
noCache = false,
|
|
28297
27444
|
livePreview = true,
|
|
28298
27445
|
generatePromptPath,
|
|
28299
27446
|
skipMapTokens = false,
|
|
@@ -28318,7 +27465,6 @@ function WizardApp({
|
|
|
28318
27465
|
});
|
|
28319
27466
|
const allowEmptyDeleteAllRef = useRef10(false);
|
|
28320
27467
|
const generateChildRef = useRef10(null);
|
|
28321
|
-
const generationCachePreflightRef = useRef10(null);
|
|
28322
27468
|
const selectionToReviewStartedAtRef = useRef10(null);
|
|
28323
27469
|
const credentialsValidationIdRef = useRef10(0);
|
|
28324
27470
|
const pendingCredentialValidationRef = useRef10(null);
|
|
@@ -28333,9 +27479,8 @@ function WizardApp({
|
|
|
28333
27479
|
const existingEntitiesPromiseRef = useRef10(null);
|
|
28334
27480
|
const generatePromiseRef = useRef10(null);
|
|
28335
27481
|
const rawTokensEntryReady = !!initialRawTokensPath;
|
|
28336
|
-
const effectiveNoCache = resolveNoCacheForGenerate({ cliNoCache: noCache });
|
|
28337
27482
|
const initialStepResolved = rawTokensEntryReady ? initialProjectPath ? "path-validation" : "credentials" : initialProjectPath ? "token-input" : "welcome";
|
|
28338
|
-
const initialOutDir = initialProjectPath ? join23(
|
|
27483
|
+
const initialOutDir = initialProjectPath ? join23(resolve17(initialProjectPath), ".contentful") : "";
|
|
28339
27484
|
const [state, setState] = useState23({
|
|
28340
27485
|
step: initialStepResolved,
|
|
28341
27486
|
agent: initialAgent ?? "claude",
|
|
@@ -28511,14 +27656,13 @@ If you are using AWS Bedrock, run:
|
|
|
28511
27656
|
if (!deferStep) update({ step: nextStep });
|
|
28512
27657
|
return true;
|
|
28513
27658
|
};
|
|
28514
|
-
const runGenerateTokens = async (rawTokensPath, outDir
|
|
27659
|
+
const runGenerateTokens = async (rawTokensPath, outDir) => {
|
|
28515
27660
|
update({ tokenGenerationStatus: "running" });
|
|
28516
27661
|
const tokenArgs = buildGenerateTokensArgs({
|
|
28517
27662
|
rawTokensPath,
|
|
28518
27663
|
agent: state.agent,
|
|
28519
27664
|
...state.agentModel ? { model: state.agentModel } : {},
|
|
28520
27665
|
...state.bedrock ? { bedrock: true } : {},
|
|
28521
|
-
noCache: effectiveNoCache || forceRegenerate,
|
|
28522
27666
|
promptOverrides
|
|
28523
27667
|
});
|
|
28524
27668
|
const result = await runSpawnedCli(tokenArgs);
|
|
@@ -28567,7 +27711,6 @@ If you are using AWS Bedrock, run:
|
|
|
28567
27711
|
const timer = startWizardTimer("token-mapping", {
|
|
28568
27712
|
sessionId: sessionId2,
|
|
28569
27713
|
silent,
|
|
28570
|
-
noCache: effectiveNoCache,
|
|
28571
27714
|
skipAgent: skipMapTokens
|
|
28572
27715
|
});
|
|
28573
27716
|
let mappablePropCount = 0;
|
|
@@ -28576,7 +27719,7 @@ If you are using AWS Bedrock, run:
|
|
|
28576
27719
|
const db = openPipelineDb();
|
|
28577
27720
|
try {
|
|
28578
27721
|
if (state.tokenSessionId && state.tokenSessionId !== sessionId2) {
|
|
28579
|
-
|
|
27722
|
+
copyTokensBetweenSessions(db, state.tokenSessionId, sessionId2);
|
|
28580
27723
|
} else if (!state.tokenSessionId && state.tokensPath) {
|
|
28581
27724
|
const tokens = await readTokensFromPath("tokens", state.tokensPath);
|
|
28582
27725
|
storeDtcgTokens(db, sessionId2, [], tokens);
|
|
@@ -28616,7 +27759,6 @@ If you are using AWS Bedrock, run:
|
|
|
28616
27759
|
sessionId: sessionId2,
|
|
28617
27760
|
agent: state.agent,
|
|
28618
27761
|
...state.agentModel ? { model: state.agentModel } : {},
|
|
28619
|
-
noCache: effectiveNoCache,
|
|
28620
27762
|
skipAgent: skipMapTokens,
|
|
28621
27763
|
promptOverrides,
|
|
28622
27764
|
...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {}
|
|
@@ -28696,7 +27838,7 @@ If you are using AWS Bedrock, run:
|
|
|
28696
27838
|
return promise;
|
|
28697
27839
|
};
|
|
28698
27840
|
const runExtract = async (projectPath, showProgress = true) => {
|
|
28699
|
-
const outDir = join23(
|
|
27841
|
+
const outDir = join23(resolve17(projectPath), ".contentful");
|
|
28700
27842
|
const existingEntitiesExpected = !state.credentialsSkipped && Boolean(state.spaceId && state.environmentId && state.cmaToken && projectPath);
|
|
28701
27843
|
update({
|
|
28702
27844
|
...showProgress ? { step: "extracting" } : {},
|
|
@@ -28711,7 +27853,6 @@ If you are using AWS Bedrock, run:
|
|
|
28711
27853
|
});
|
|
28712
27854
|
const existingEntitiesPromise = startExistingEntitiesFetch(projectPath, outDir);
|
|
28713
27855
|
const extractArgs = [findCliPath(), "__extract", "--project", projectPath];
|
|
28714
|
-
if (effectiveNoCache) extractArgs.push("--no-cache");
|
|
28715
27856
|
let selectionPromptText;
|
|
28716
27857
|
let selectionPromptPath;
|
|
28717
27858
|
try {
|
|
@@ -28720,7 +27861,7 @@ If you are using AWS Bedrock, run:
|
|
|
28720
27861
|
const selectOverride = overrides.get("select");
|
|
28721
27862
|
if (selectOverride?.kind === "text") selectionPromptText = selectOverride.value;
|
|
28722
27863
|
if (selectOverride?.kind === "path") {
|
|
28723
|
-
selectionPromptPath =
|
|
27864
|
+
selectionPromptPath = resolve17(selectOverride.value);
|
|
28724
27865
|
await resolvePromptOverride(selectOverride);
|
|
28725
27866
|
}
|
|
28726
27867
|
} catch (error) {
|
|
@@ -28744,8 +27885,7 @@ If you are using AWS Bedrock, run:
|
|
|
28744
27885
|
agent: state.agent,
|
|
28745
27886
|
...state.agentModel ? { model: state.agentModel } : {},
|
|
28746
27887
|
...selectionPromptText !== void 0 ? { promptText: selectionPromptText } : {},
|
|
28747
|
-
...selectionPromptPath ? { promptPath: selectionPromptPath } : {}
|
|
28748
|
-
noCache: effectiveNoCache
|
|
27888
|
+
...selectionPromptPath ? { promptPath: selectionPromptPath } : {}
|
|
28749
27889
|
});
|
|
28750
27890
|
})().catch((error) => {
|
|
28751
27891
|
selectionError = error;
|
|
@@ -28890,136 +28030,17 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
28890
28030
|
generateProgress: null
|
|
28891
28031
|
}));
|
|
28892
28032
|
};
|
|
28893
|
-
const buildGenerateOptions = (extractSessionId, tokensPath, generatePromptPath2
|
|
28033
|
+
const buildGenerateOptions = (extractSessionId, tokensPath, generatePromptPath2) => ({
|
|
28894
28034
|
sessionId: extractSessionId,
|
|
28895
28035
|
tokensPath,
|
|
28896
28036
|
agent: state.agent,
|
|
28897
28037
|
...state.agentModel ? { model: state.agentModel } : {},
|
|
28898
28038
|
...state.bedrock ? { bedrock: true } : {},
|
|
28899
|
-
noCache: effectiveNoCache,
|
|
28900
28039
|
...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {},
|
|
28901
28040
|
...generatePromptPath2 ? { generatePromptPath: generatePromptPath2 } : {},
|
|
28902
|
-
promptOverrides
|
|
28903
|
-
...cachedComponents && cachedComponents.length > 0 ? { cachedComponents } : {}
|
|
28041
|
+
promptOverrides
|
|
28904
28042
|
});
|
|
28905
|
-
const buildGenerateArgs = (extractSessionId, tokensPath, generatePromptPath2
|
|
28906
|
-
const buildGenerateCliArgs = (extractSessionId, tokensPath, generatePromptPath2, cachedComponents) => buildGenerateComponentsArgs(
|
|
28907
|
-
buildGenerateOptions(extractSessionId, tokensPath, generatePromptPath2, cachedComponents)
|
|
28908
|
-
);
|
|
28909
|
-
const checkGenerateCache = async (extractSessionId, tokensPath) => {
|
|
28910
|
-
const timer = startWizardTimer("generation-cache-status", {
|
|
28911
|
-
sessionId: extractSessionId,
|
|
28912
|
-
noCache: effectiveNoCache
|
|
28913
|
-
});
|
|
28914
|
-
if (effectiveNoCache) {
|
|
28915
|
-
finishWizardTimer("generation-cache-status", timer, { status: "skipped" });
|
|
28916
|
-
return false;
|
|
28917
|
-
}
|
|
28918
|
-
const result = await runCli([...buildGenerateCliArgs(extractSessionId, tokensPath), "--cache-status"]);
|
|
28919
|
-
const hit = result.exitCode === 0 && /^cache-status=hit$/m.test(result.stdout);
|
|
28920
|
-
finishWizardTimer("generation-cache-status", timer, {
|
|
28921
|
-
status: hit ? "hit" : "miss",
|
|
28922
|
-
exitCode: result.exitCode,
|
|
28923
|
-
...result.exitCode !== 0 ? { stderrTail: result.stderr.trim().slice(-500) } : {}
|
|
28924
|
-
});
|
|
28925
|
-
return hit;
|
|
28926
|
-
};
|
|
28927
|
-
const checkGenerateCacheComponents = async (extractSessionId, tokensPath, restoreCache = false) => {
|
|
28928
|
-
const timer = startWizardTimer("generation-cache-components", {
|
|
28929
|
-
sessionId: extractSessionId,
|
|
28930
|
-
restoreCache,
|
|
28931
|
-
noCache: effectiveNoCache
|
|
28932
|
-
});
|
|
28933
|
-
if (effectiveNoCache) {
|
|
28934
|
-
finishWizardTimer("generation-cache-components", timer, { status: "skipped" });
|
|
28935
|
-
return /* @__PURE__ */ new Set();
|
|
28936
|
-
}
|
|
28937
|
-
const args = [...buildGenerateCliArgs(extractSessionId, tokensPath), "--cache-status"];
|
|
28938
|
-
if (restoreCache) args.push("--restore-cache");
|
|
28939
|
-
const result = await runCli(args);
|
|
28940
|
-
if (result.exitCode !== 0) {
|
|
28941
|
-
finishWizardTimer("generation-cache-components", timer, {
|
|
28942
|
-
status: "error",
|
|
28943
|
-
exitCode: result.exitCode,
|
|
28944
|
-
stderrTail: result.stderr.trim().slice(-500)
|
|
28945
|
-
});
|
|
28946
|
-
return /* @__PURE__ */ new Set();
|
|
28947
|
-
}
|
|
28948
|
-
const line = /^cache-components=(.+)$/m.exec(result.stdout)?.[1];
|
|
28949
|
-
if (!line) {
|
|
28950
|
-
finishWizardTimer("generation-cache-components", timer, {
|
|
28951
|
-
status: "missing-output",
|
|
28952
|
-
exitCode: result.exitCode,
|
|
28953
|
-
cachedCount: 0
|
|
28954
|
-
});
|
|
28955
|
-
return /* @__PURE__ */ new Set();
|
|
28956
|
-
}
|
|
28957
|
-
try {
|
|
28958
|
-
const names = JSON.parse(line);
|
|
28959
|
-
const cachedNames = new Set(
|
|
28960
|
-
Array.isArray(names) ? names.filter((name) => typeof name === "string") : []
|
|
28961
|
-
);
|
|
28962
|
-
finishWizardTimer("generation-cache-components", timer, {
|
|
28963
|
-
status: "complete",
|
|
28964
|
-
exitCode: result.exitCode,
|
|
28965
|
-
cachedCount: cachedNames.size
|
|
28966
|
-
});
|
|
28967
|
-
return cachedNames;
|
|
28968
|
-
} catch {
|
|
28969
|
-
finishWizardTimer("generation-cache-components", timer, {
|
|
28970
|
-
status: "invalid-output",
|
|
28971
|
-
exitCode: result.exitCode,
|
|
28972
|
-
cachedCount: 0
|
|
28973
|
-
});
|
|
28974
|
-
return /* @__PURE__ */ new Set();
|
|
28975
|
-
}
|
|
28976
|
-
};
|
|
28977
|
-
useEffect15(() => {
|
|
28978
|
-
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) {
|
|
28979
|
-
return;
|
|
28980
|
-
}
|
|
28981
|
-
const sessionId2 = state.extractSessionId;
|
|
28982
|
-
if (generationCachePreflightRef.current?.sessionId === sessionId2) return;
|
|
28983
|
-
const timer = startWizardTimer("generation-cache-preflight", { sessionId: sessionId2 });
|
|
28984
|
-
const db = openPipelineDb();
|
|
28985
|
-
let generatedNames = null;
|
|
28986
|
-
try {
|
|
28987
|
-
const rows = db.prepare("SELECT name, status FROM raw_components WHERE session_id = ?").all(sessionId2);
|
|
28988
|
-
if (rows.length > 0 && rows.every((row) => row.status === "generated")) {
|
|
28989
|
-
generatedNames = new Set(rows.map((row) => row.name));
|
|
28990
|
-
}
|
|
28991
|
-
} finally {
|
|
28992
|
-
db.close();
|
|
28993
|
-
}
|
|
28994
|
-
if (generatedNames) {
|
|
28995
|
-
generationCachePreflightRef.current = { sessionId: sessionId2, promise: Promise.resolve(generatedNames) };
|
|
28996
|
-
finishWizardTimer("generation-cache-preflight", timer, {
|
|
28997
|
-
status: "complete",
|
|
28998
|
-
source: "session-db",
|
|
28999
|
-
cachedCount: generatedNames.size
|
|
29000
|
-
});
|
|
29001
|
-
return;
|
|
29002
|
-
}
|
|
29003
|
-
const promise = checkGenerateCacheComponents(sessionId2, state.tokensPath, true);
|
|
29004
|
-
generationCachePreflightRef.current = { sessionId: sessionId2, promise };
|
|
29005
|
-
void promise.then((cachedNames) => {
|
|
29006
|
-
finishWizardTimer("generation-cache-preflight", timer, {
|
|
29007
|
-
status: "complete",
|
|
29008
|
-
source: "cache-status",
|
|
29009
|
-
cachedCount: cachedNames.size
|
|
29010
|
-
});
|
|
29011
|
-
});
|
|
29012
|
-
}, [
|
|
29013
|
-
state.step,
|
|
29014
|
-
state.extractSessionId,
|
|
29015
|
-
state.tokensPath,
|
|
29016
|
-
state.rawTokensPath,
|
|
29017
|
-
state.tokenGenerationStatus,
|
|
29018
|
-
state.selectionAgentStatus,
|
|
29019
|
-
state.compositionPhase,
|
|
29020
|
-
state.existingEntitiesStatus,
|
|
29021
|
-
state.existingEntitiesPath
|
|
29022
|
-
]);
|
|
28043
|
+
const buildGenerateArgs = (extractSessionId, tokensPath, generatePromptPath2) => buildGenerateProcessArgs(buildGenerateOptions(extractSessionId, tokensPath, generatePromptPath2));
|
|
29023
28044
|
const startGeneratePrefetch = (extractSessionId, tokensPath) => {
|
|
29024
28045
|
const args = buildGenerateArgs(extractSessionId, tokensPath);
|
|
29025
28046
|
let progressCursor = null;
|
|
@@ -29074,14 +28095,13 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
29074
28095
|
});
|
|
29075
28096
|
return donePromise;
|
|
29076
28097
|
};
|
|
29077
|
-
const runGenerate = async (extractSessionId, tokensPath, acceptedCount, suppressScreen = false
|
|
28098
|
+
const runGenerate = async (extractSessionId, tokensPath, acceptedCount, suppressScreen = false) => {
|
|
29078
28099
|
const timer = startWizardTimer("component-generation", {
|
|
29079
28100
|
sessionId: extractSessionId,
|
|
29080
28101
|
acceptedCount,
|
|
29081
|
-
suppressScreen
|
|
29082
|
-
noCache: effectiveNoCache
|
|
28102
|
+
suppressScreen
|
|
29083
28103
|
});
|
|
29084
|
-
const args = buildGenerateArgs(extractSessionId, tokensPath, generatePromptPath
|
|
28104
|
+
const args = buildGenerateArgs(extractSessionId, tokensPath, generatePromptPath);
|
|
29085
28105
|
let progressCursor = state.generateProgress;
|
|
29086
28106
|
const { donePromise } = spawnGenerateChild({
|
|
29087
28107
|
command: "node",
|
|
@@ -29151,25 +28171,6 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
29151
28171
|
finishSelectionToReviewTimer("error");
|
|
29152
28172
|
}
|
|
29153
28173
|
};
|
|
29154
|
-
const finishCachedGeneration = async (sessionId2, acceptedCount) => {
|
|
29155
|
-
if (await runMapTokens2(sessionId2, true)) {
|
|
29156
|
-
finishSelectionToReviewTimer("cached");
|
|
29157
|
-
update(
|
|
29158
|
-
{
|
|
29159
|
-
acceptedCount,
|
|
29160
|
-
autoRejectedCount: 0,
|
|
29161
|
-
generateSessionId: sessionId2,
|
|
29162
|
-
generatedCount: acceptedCount,
|
|
29163
|
-
generateProgress: null,
|
|
29164
|
-
mapTokensStatus: "complete",
|
|
29165
|
-
step: "final-review"
|
|
29166
|
-
},
|
|
29167
|
-
{ clearScreen: false }
|
|
29168
|
-
);
|
|
29169
|
-
} else {
|
|
29170
|
-
finishSelectionToReviewTimer("error");
|
|
29171
|
-
}
|
|
29172
|
-
};
|
|
29173
28174
|
const advanceToPushFlow = (generatedAcceptedCount) => {
|
|
29174
28175
|
update({ generatedAcceptedCount });
|
|
29175
28176
|
void runSaveAndPush();
|
|
@@ -29354,14 +28355,8 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
29354
28355
|
}
|
|
29355
28356
|
}
|
|
29356
28357
|
if (await runAgentAuthCheck("generating", true)) {
|
|
29357
|
-
|
|
29358
|
-
|
|
29359
|
-
update({ step: "generating" });
|
|
29360
|
-
void finishCachedGeneration(sid, state.acceptedCount);
|
|
29361
|
-
} else {
|
|
29362
|
-
update({ step: "generating" });
|
|
29363
|
-
void runGenerate(sid, state.tokensPath, state.acceptedCount);
|
|
29364
|
-
}
|
|
28358
|
+
update({ step: "generating" });
|
|
28359
|
+
void runGenerate(sid, state.tokensPath, state.acceptedCount);
|
|
29365
28360
|
}
|
|
29366
28361
|
return;
|
|
29367
28362
|
}
|
|
@@ -29725,7 +28720,7 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
29725
28720
|
});
|
|
29726
28721
|
return { ok: false };
|
|
29727
28722
|
}
|
|
29728
|
-
await new Promise((
|
|
28723
|
+
await new Promise((resolve20) => setTimeout(resolve20, SAVE_CONFIRMATION_DELAY_MS));
|
|
29729
28724
|
update(nextStateAfterPrint({ skipGate: opts.skipGate, componentsPath }));
|
|
29730
28725
|
return { ok: true };
|
|
29731
28726
|
};
|
|
@@ -29802,12 +28797,6 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
29802
28797
|
tokenReuseChecked.current = true;
|
|
29803
28798
|
const tokenNextStep = state.projectPath ? "path-validation" : "credentials";
|
|
29804
28799
|
const existingTokensPath = join23(state.outDir, "tokens.json");
|
|
29805
|
-
if (effectiveNoCache) {
|
|
29806
|
-
tokenGenerationPromiseRef.current = runAgentAuthCheck(tokenNextStep).then(
|
|
29807
|
-
(ok2) => ok2 ? runGenerateTokens(state.rawTokensPath, state.outDir) : false
|
|
29808
|
-
);
|
|
29809
|
-
return;
|
|
29810
|
-
}
|
|
29811
28800
|
(async () => {
|
|
29812
28801
|
try {
|
|
29813
28802
|
await access7(existingTokensPath);
|
|
@@ -29891,7 +28880,7 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
29891
28880
|
const tokenNextStep = state.projectPath ? "path-validation" : "credentials";
|
|
29892
28881
|
update({ step: tokenNextStep });
|
|
29893
28882
|
if (await runAgentAuthCheck(tokenNextStep)) {
|
|
29894
|
-
tokenGenerationPromiseRef.current = runGenerateTokens(state.rawTokensPath, state.outDir
|
|
28883
|
+
tokenGenerationPromiseRef.current = runGenerateTokens(state.rawTokensPath, state.outDir);
|
|
29895
28884
|
}
|
|
29896
28885
|
},
|
|
29897
28886
|
onQuit: () => process.exit(0)
|
|
@@ -29990,29 +28979,6 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
29990
28979
|
acceptedCount: decisions.accepted.length,
|
|
29991
28980
|
rejectedCount: decisions.rejected.length
|
|
29992
28981
|
}) : null;
|
|
29993
|
-
const preflight = generationCachePreflightRef.current;
|
|
29994
|
-
const cachePromise = preflight?.sessionId === sessionId2 ? preflight.promise : checkGenerateCacheComponents(sessionId2, state.tokensPath, true);
|
|
29995
|
-
if (!preflight || preflight.sessionId !== sessionId2) {
|
|
29996
|
-
generationCachePreflightRef.current = { sessionId: sessionId2, promise: cachePromise };
|
|
29997
|
-
}
|
|
29998
|
-
const cacheWaitStartedAt = startWizardTimer("selection-cache-restoration-wait", {
|
|
29999
|
-
sessionId: sessionId2,
|
|
30000
|
-
preflight: Boolean(preflight?.sessionId === sessionId2)
|
|
30001
|
-
});
|
|
30002
|
-
try {
|
|
30003
|
-
const cachedNames = await cachePromise;
|
|
30004
|
-
finishWizardTimer("selection-cache-restoration-wait", cacheWaitStartedAt, {
|
|
30005
|
-
status: "complete",
|
|
30006
|
-
cachedCount: cachedNames.size
|
|
30007
|
-
});
|
|
30008
|
-
} catch (error) {
|
|
30009
|
-
finishWizardTimer("selection-cache-restoration-wait", cacheWaitStartedAt, {
|
|
30010
|
-
status: "error",
|
|
30011
|
-
error: error instanceof Error ? error.message : String(error)
|
|
30012
|
-
});
|
|
30013
|
-
finishSelectionToReviewTimer("error");
|
|
30014
|
-
throw error;
|
|
30015
|
-
}
|
|
30016
28982
|
await runScopeGate({
|
|
30017
28983
|
sessionId: sessionId2,
|
|
30018
28984
|
decisions,
|
|
@@ -30021,35 +28987,12 @@ If using a custom host configuration, make sure the space exists on that host.`
|
|
|
30021
28987
|
if (shouldGenerateAfterScopeGate({ acceptedCount })) {
|
|
30022
28988
|
const authPromise = runAgentAuthCheck("generating", true);
|
|
30023
28989
|
if (await authPromise) {
|
|
30024
|
-
|
|
30025
|
-
|
|
30026
|
-
|
|
30027
|
-
|
|
30028
|
-
let cachedNames = await cachePromise;
|
|
30029
|
-
const acceptedNames = decisions?.accepted ?? [];
|
|
30030
|
-
let cacheHit = !effectiveNoCache && acceptedNames.length > 0 && acceptedNames.every((name) => cachedNames.has(name));
|
|
30031
|
-
if (!cacheHit && !effectiveNoCache && acceptedNames.length > 0) {
|
|
30032
|
-
cachedNames = await checkGenerateCacheComponents(sid, state.tokensPath, true);
|
|
30033
|
-
cacheHit = acceptedNames.every((name) => cachedNames.has(name));
|
|
30034
|
-
}
|
|
30035
|
-
finishWizardTimer("generation-cache-set-comparison", comparisonStartedAt, {
|
|
30036
|
-
status: "complete",
|
|
30037
|
-
cacheHit,
|
|
30038
|
-
cachedCount: cachedNames.size,
|
|
30039
|
-
acceptedCount: acceptedNames.length
|
|
28990
|
+
update({
|
|
28991
|
+
step: "generating",
|
|
28992
|
+
generateProgress: null,
|
|
28993
|
+
acceptedCount
|
|
30040
28994
|
});
|
|
30041
|
-
|
|
30042
|
-
void finishCachedGeneration(sid, acceptedCount);
|
|
30043
|
-
} else {
|
|
30044
|
-
const acceptedNameSet = new Set(acceptedNames);
|
|
30045
|
-
const restoredCachedNames = [...cachedNames].filter((name) => acceptedNameSet.has(name));
|
|
30046
|
-
update({
|
|
30047
|
-
step: "generating",
|
|
30048
|
-
generateProgress: null,
|
|
30049
|
-
acceptedCount
|
|
30050
|
-
});
|
|
30051
|
-
void runGenerate(sid, state.tokensPath, acceptedCount, false, restoredCachedNames);
|
|
30052
|
-
}
|
|
28995
|
+
void runGenerate(sid, state.tokensPath, acceptedCount);
|
|
30053
28996
|
} else {
|
|
30054
28997
|
finishSelectionToReviewTimer("error");
|
|
30055
28998
|
}
|
|
@@ -30415,7 +29358,7 @@ function registerImportCommand(program) {
|
|
|
30415
29358
|
"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",
|
|
30416
29359
|
(v, acc) => [...acc, v],
|
|
30417
29360
|
[]
|
|
30418
|
-
).
|
|
29361
|
+
).action(async (opts) => {
|
|
30419
29362
|
const interactiveTerminalSupported = getInteractiveTerminalSupport().supported;
|
|
30420
29363
|
if (opts.tokens !== void 0) {
|
|
30421
29364
|
const { access: access9 } = await import("node:fs/promises");
|
|
@@ -30452,7 +29395,6 @@ function registerImportCommand(program) {
|
|
|
30452
29395
|
...resolvedModel ? { initialModel: resolvedModel } : {},
|
|
30453
29396
|
initialProjectPath: opts.project !== "." ? normalizePath(opts.project) : void 0,
|
|
30454
29397
|
...buildCompositionForwardingOptions(opts),
|
|
30455
|
-
noCache: opts.cache === false,
|
|
30456
29398
|
skipMapTokens: false,
|
|
30457
29399
|
livePreview: true,
|
|
30458
29400
|
generatePromptPath: creds.generatePromptPath,
|
|
@@ -30540,7 +29482,7 @@ async function pathExists3(path) {
|
|
|
30540
29482
|
return access8(path).then(() => true).catch(() => false);
|
|
30541
29483
|
}
|
|
30542
29484
|
function runSpawn(cmd, args, opts = {}) {
|
|
30543
|
-
return new Promise((
|
|
29485
|
+
return new Promise((resolve20) => {
|
|
30544
29486
|
const child = spawn6(cmd, args, {
|
|
30545
29487
|
cwd: opts.cwd,
|
|
30546
29488
|
env: opts.env ?? process.env,
|
|
@@ -30552,7 +29494,7 @@ function runSpawn(cmd, args, opts = {}) {
|
|
|
30552
29494
|
const settle = (result) => {
|
|
30553
29495
|
if (settled) return;
|
|
30554
29496
|
settled = true;
|
|
30555
|
-
|
|
29497
|
+
resolve20(result);
|
|
30556
29498
|
};
|
|
30557
29499
|
child.on("error", (err) => settle({ exitCode: 1, stdout: "", stderr: err.message }));
|
|
30558
29500
|
child.stdout.on("data", (d) => {
|
|
@@ -31753,13 +30695,13 @@ function PrerequisitesScreen({
|
|
|
31753
30695
|
const driver = {
|
|
31754
30696
|
...base,
|
|
31755
30697
|
emit: (event) => setEvents((current) => [...current, event]),
|
|
31756
|
-
confirm: (question, defaultYes = true) => new Promise((
|
|
30698
|
+
confirm: (question, defaultYes = true) => new Promise((resolve20) => {
|
|
31757
30699
|
setConfirm({
|
|
31758
30700
|
question,
|
|
31759
30701
|
defaultYes,
|
|
31760
30702
|
resolve: (answer) => {
|
|
31761
30703
|
setConfirm(null);
|
|
31762
|
-
|
|
30704
|
+
resolve20(answer);
|
|
31763
30705
|
}
|
|
31764
30706
|
});
|
|
31765
30707
|
})
|
|
@@ -31834,8 +30776,8 @@ function SetupScreen({
|
|
|
31834
30776
|
useEffect21(() => {
|
|
31835
30777
|
if (startedRef.current) return;
|
|
31836
30778
|
startedRef.current = true;
|
|
31837
|
-
const runScreen = (build) => new Promise((
|
|
31838
|
-
setScreen(build(
|
|
30779
|
+
const runScreen = (build) => new Promise((resolve20) => {
|
|
30780
|
+
setScreen(build(resolve20));
|
|
31839
30781
|
});
|
|
31840
30782
|
void (async () => {
|
|
31841
30783
|
const results = [];
|
|
@@ -32443,11 +31385,8 @@ var init_source_call_site_evidence = __esm({
|
|
|
32443
31385
|
});
|
|
32444
31386
|
|
|
32445
31387
|
// packages/experience-design-system-cli-legacy/src/analyze/extract-command.ts
|
|
32446
|
-
import { mkdir as mkdir6, readdir as readdir3, readFile as
|
|
32447
|
-
import { isAbsolute as isAbsolute2, join as join27, relative as relative2, resolve as
|
|
32448
|
-
function resolveExtractNoCache(opts) {
|
|
32449
|
-
return opts.noCache === true || opts.cache === false;
|
|
32450
|
-
}
|
|
31388
|
+
import { mkdir as mkdir6, readdir as readdir3, readFile as readFile18, stat as stat6 } from "node:fs/promises";
|
|
31389
|
+
import { isAbsolute as isAbsolute2, join as join27, relative as relative2, resolve as resolve18 } from "node:path";
|
|
32451
31390
|
function isDenylistedNoiseFile(name) {
|
|
32452
31391
|
return DENYLISTED_EXACT_FILE_NAMES.has(name) || DENYLISTED_FILE_NAME_PATTERNS.some((pattern) => pattern.test(name));
|
|
32453
31392
|
}
|
|
@@ -32461,12 +31400,12 @@ async function retryDatabaseWrite(operation, attempts = 8) {
|
|
|
32461
31400
|
} catch (error) {
|
|
32462
31401
|
const message = error instanceof Error ? error.message : String(error);
|
|
32463
31402
|
if (!/database is locked|database is busy/i.test(message) || attempt >= attempts) throw error;
|
|
32464
|
-
await new Promise((
|
|
31403
|
+
await new Promise((resolve20) => setTimeout(resolve20, Math.min(250 * attempt, 2e3)));
|
|
32465
31404
|
}
|
|
32466
31405
|
}
|
|
32467
31406
|
}
|
|
32468
31407
|
function resolveFromProjectRoot(projectRoot, inputPath) {
|
|
32469
|
-
return isAbsolute2(inputPath) ? inputPath :
|
|
31408
|
+
return isAbsolute2(inputPath) ? inputPath : resolve18(projectRoot, inputPath);
|
|
32470
31409
|
}
|
|
32471
31410
|
async function pathExists4(path) {
|
|
32472
31411
|
return Boolean(await stat6(path).catch(() => null));
|
|
@@ -32513,7 +31452,7 @@ async function readCandidateFiles(components, extraFiles = []) {
|
|
|
32513
31452
|
await Promise.all(
|
|
32514
31453
|
[...paths].map(async (p) => {
|
|
32515
31454
|
try {
|
|
32516
|
-
const content = await
|
|
31455
|
+
const content = await readFile18(p, "utf8");
|
|
32517
31456
|
out.push({ path: p, content });
|
|
32518
31457
|
} catch {
|
|
32519
31458
|
}
|
|
@@ -32526,8 +31465,7 @@ function registerInternalExtractCommand(program) {
|
|
|
32526
31465
|
"--resolve-unreachable <mode>",
|
|
32527
31466
|
"Retry pass for unresolved Svelte Props types: 'auto' (default), 'always', or 'never'",
|
|
32528
31467
|
"auto"
|
|
32529
|
-
).
|
|
32530
|
-
const noCache = resolveExtractNoCache(opts);
|
|
31468
|
+
).action(async (opts) => {
|
|
32531
31469
|
const resolveUnreachable = (() => {
|
|
32532
31470
|
const v = opts.resolveUnreachable ?? "auto";
|
|
32533
31471
|
if (v !== "auto" && v !== "always" && v !== "never") {
|
|
@@ -32537,7 +31475,7 @@ function registerInternalExtractCommand(program) {
|
|
|
32537
31475
|
}
|
|
32538
31476
|
return v;
|
|
32539
31477
|
})();
|
|
32540
|
-
const projectRoot =
|
|
31478
|
+
const projectRoot = resolve18(opts.project);
|
|
32541
31479
|
const outDir = join27(projectRoot, ".contentful");
|
|
32542
31480
|
let sourceDirectory;
|
|
32543
31481
|
if (opts.dir !== void 0) {
|
|
@@ -32561,50 +31499,16 @@ function registerInternalExtractCommand(program) {
|
|
|
32561
31499
|
process.stderr.write(`progress=scan-done:${sourceFiles.length}
|
|
32562
31500
|
`);
|
|
32563
31501
|
}
|
|
32564
|
-
const
|
|
32565
|
-
|
|
32566
|
-
|
|
32567
|
-
try {
|
|
32568
|
-
const cacheVersion = await getCliCacheVersion();
|
|
32569
|
-
const cachedByPath = /* @__PURE__ */ new Map();
|
|
32570
|
-
if (!noCache && sourceFiles.length > 0) {
|
|
32571
|
-
const hashes = await Promise.all(
|
|
32572
|
-
sourceFiles.map(async (filePath) => [filePath, await hashFile(filePath)])
|
|
32573
|
-
);
|
|
32574
|
-
for (const [filePath, fileHash] of hashes) {
|
|
32575
|
-
cachedByPath.set(filePath, lookupExtractCache(extractionCacheDb, fileHash, cacheVersion));
|
|
32576
|
-
}
|
|
32577
|
-
}
|
|
32578
|
-
const allFilesCached = !noCache && sourceFiles.length > 0 && sourceFiles.every((filePath) => cachedByPath.get(filePath) !== null);
|
|
32579
|
-
if (allFilesCached) {
|
|
32580
|
-
const cachedComponents = sourceFiles.flatMap((filePath) => cachedByPath.get(filePath).components);
|
|
32581
|
-
extractionCacheHits = sourceFiles.length;
|
|
32582
|
-
extraction = { components: cachedComponents, warnings: [], exclusions: [] };
|
|
31502
|
+
const extraction = await extractComponents(
|
|
31503
|
+
sourceFiles,
|
|
31504
|
+
({ filesProcessed, componentsFound }) => {
|
|
32583
31505
|
if (!process.stdout.isTTY) {
|
|
32584
|
-
process.stderr.write(
|
|
32585
|
-
`progress=extract:${sourceFiles.length}/${sourceFiles.length}:${cachedComponents.length}
|
|
32586
|
-
`
|
|
32587
|
-
);
|
|
32588
|
-
}
|
|
32589
|
-
getDebugLogger().event("analyze", "extract.cache-hit", {
|
|
32590
|
-
files: sourceFiles.length,
|
|
32591
|
-
components: cachedComponents.length
|
|
32592
|
-
});
|
|
32593
|
-
} else {
|
|
32594
|
-
extraction = await extractComponents(
|
|
32595
|
-
sourceFiles,
|
|
32596
|
-
({ filesProcessed, componentsFound }) => {
|
|
32597
|
-
if (!process.stdout.isTTY) {
|
|
32598
|
-
process.stderr.write(`progress=extract:${filesProcessed}/${sourceFiles.length}:${componentsFound}
|
|
31506
|
+
process.stderr.write(`progress=extract:${filesProcessed}/${sourceFiles.length}:${componentsFound}
|
|
32599
31507
|
`);
|
|
32600
|
-
|
|
32601
|
-
|
|
32602
|
-
|
|
32603
|
-
|
|
32604
|
-
}
|
|
32605
|
-
} finally {
|
|
32606
|
-
extractionCacheDb.close();
|
|
32607
|
-
}
|
|
31508
|
+
}
|
|
31509
|
+
},
|
|
31510
|
+
{ resolveUnreachable, projectRoot }
|
|
31511
|
+
);
|
|
32608
31512
|
await mkdir6(outDir, { recursive: true });
|
|
32609
31513
|
const db = openPipelineDb();
|
|
32610
31514
|
const { sessionId: sessionId2 } = getOrCreateSession(db, void 0, void 0, {
|
|
@@ -32619,25 +31523,6 @@ function registerInternalExtractCommand(program) {
|
|
|
32619
31523
|
const stepId = createStep(db, sessionId2, "analyze extract", {
|
|
32620
31524
|
project: projectRoot
|
|
32621
31525
|
});
|
|
32622
|
-
if (extractionCacheHits === 0 && !noCache) {
|
|
32623
|
-
const cacheVersion = await getCliCacheVersion();
|
|
32624
|
-
const componentsBySourcePath = /* @__PURE__ */ new Map();
|
|
32625
|
-
for (const component of extraction.components) {
|
|
32626
|
-
if (!component.sourcePath) continue;
|
|
32627
|
-
const components = componentsBySourcePath.get(component.sourcePath) ?? [];
|
|
32628
|
-
components.push(component);
|
|
32629
|
-
componentsBySourcePath.set(component.sourcePath, components);
|
|
32630
|
-
}
|
|
32631
|
-
for (const filePath of sourceFiles) {
|
|
32632
|
-
storeExtractCache(
|
|
32633
|
-
db,
|
|
32634
|
-
filePath,
|
|
32635
|
-
await hashFile(filePath),
|
|
32636
|
-
cacheVersion,
|
|
32637
|
-
componentsBySourcePath.get(filePath) ?? []
|
|
32638
|
-
);
|
|
32639
|
-
}
|
|
32640
|
-
}
|
|
32641
31526
|
const classifiedComponents = extraction.components.map(preClassifyComponent);
|
|
32642
31527
|
for (const exclusion of extraction.exclusions ?? []) {
|
|
32643
31528
|
getDebugLogger().event("filter", "extract.excluded", { ...exclusion });
|
|
@@ -32742,7 +31627,6 @@ var init_extract_command = __esm({
|
|
|
32742
31627
|
"use strict";
|
|
32743
31628
|
init_src2();
|
|
32744
31629
|
init_db();
|
|
32745
|
-
init_cache_keys();
|
|
32746
31630
|
init_cycle_detection();
|
|
32747
31631
|
init_resolve_mapping();
|
|
32748
31632
|
init_manifest_doc_evidence();
|
|
@@ -32841,7 +31725,7 @@ __export(program_exports, {
|
|
|
32841
31725
|
});
|
|
32842
31726
|
import { spawn as spawn7 } from "node:child_process";
|
|
32843
31727
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
32844
|
-
import { dirname as dirname18, join as join28, resolve as
|
|
31728
|
+
import { dirname as dirname18, join as join28, resolve as resolve19 } from "node:path";
|
|
32845
31729
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
32846
31730
|
import { Command } from "commander";
|
|
32847
31731
|
async function runBuild(opts) {
|
|
@@ -32871,7 +31755,7 @@ function resolveBedrockFromAncestors(actionCommand) {
|
|
|
32871
31755
|
}
|
|
32872
31756
|
function registerBuildCommand(program) {
|
|
32873
31757
|
program.command("build").description("Rebuild from source and re-link exo/experiences binaries to this build").helpOption(false).action(async () => {
|
|
32874
|
-
const pkgRoot =
|
|
31758
|
+
const pkgRoot = resolve19(dirname18(fileURLToPath3(import.meta.url)), "..", "..");
|
|
32875
31759
|
process.stderr.write("\u2699 Building from source...\n");
|
|
32876
31760
|
const { exitCode } = await runBuild({
|
|
32877
31761
|
spawnFn: () => spawn7("pnpm", ["build"], { cwd: pkgRoot, stdio: "inherit" }),
|