@contentful/experience-design-system-cli 2.34.5-dev-build-fcf31517.0 → 2.34.5-dev-build-ea694b2.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 +1 -1
- package/dist/src/analyze/composition/interchange-schema.d.ts +4 -24
- package/dist/src/analyze/composition/resolve-mapping-cli.d.ts +0 -11
- package/dist/src/analyze/composition/resolve-mapping.d.ts +5 -7
- package/dist/src/import/agent-model-resolve.d.ts +8 -4
- package/dist/src/import/composition-options.d.ts +0 -2
- package/dist/src/import/tui/WizardApp.d.ts +3 -2
- package/dist/src/import/tui/run-selection-agent.d.ts +8 -0
- package/dist/src/index.js +256 -204
- package/dist/src/lib/agent-model-options.d.ts +4 -4
- package/dist/src/lib/debug-logger.d.ts +2 -3
- package/dist/src/program.d.ts +1 -1
- package/package.json +6 -6
package/dist/package.json
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The CLI-owned composition interchange format (spec T1).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `--composition-map` consumes and the resolver can emit.
|
|
8
|
-
* - `CompositionEdge[]` — the flat internal runtime view, one edge per
|
|
9
|
-
* parent→child relationship, carrying optional `slot` (T7), `confidence`,
|
|
10
|
-
* and `provenance`. Easier to merge/dedupe across sources (T2).
|
|
11
|
-
*
|
|
12
|
-
* This module owns both shapes and the converters between them.
|
|
4
|
+
* `CompositionEdge[]` is the flat internal runtime view, one edge per
|
|
5
|
+
* parent→child relationship, carrying optional `slot` (T7), `confidence`,
|
|
6
|
+
* and `provenance`. It is easier to merge and dedupe across sources (T2).
|
|
13
7
|
*/
|
|
14
|
-
export type EdgeProvenance = '
|
|
8
|
+
export type EdgeProvenance = 'typed-slot' | 'structural' | 'manifest' | 'doc' | `adapter:${string}` | 'agent';
|
|
15
9
|
export type CompositionEdge = {
|
|
16
10
|
parent: string;
|
|
17
11
|
child: string;
|
|
@@ -21,17 +15,3 @@ export type CompositionEdge = {
|
|
|
21
15
|
confidence?: number;
|
|
22
16
|
provenance: EdgeProvenance;
|
|
23
17
|
};
|
|
24
|
-
export type InterchangeMap = {
|
|
25
|
-
version: 1;
|
|
26
|
-
groups: Record<string, string[]>;
|
|
27
|
-
};
|
|
28
|
-
export type ValidateResult = {
|
|
29
|
-
valid: true;
|
|
30
|
-
map: InterchangeMap;
|
|
31
|
-
} | {
|
|
32
|
-
valid: false;
|
|
33
|
-
errors: string[];
|
|
34
|
-
};
|
|
35
|
-
export declare function validateInterchangeMap(input: unknown): ValidateResult;
|
|
36
|
-
export declare function groupsToEdges(map: InterchangeMap, provenance: EdgeProvenance): CompositionEdge[];
|
|
37
|
-
export declare function edgesToGroups(edges: CompositionEdge[]): InterchangeMap;
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import { type InterchangeMap } from './interchange-schema.js';
|
|
2
1
|
export type CompositionCliOptions = {
|
|
3
|
-
/** `--composition-map <path>` — hand-authored interchange file. */
|
|
4
|
-
compositionMap?: string;
|
|
5
2
|
/** `--composition-refresh` — force edge emission to run even over resolved residue. */
|
|
6
3
|
compositionRefresh?: boolean;
|
|
7
4
|
};
|
|
8
|
-
export type LoadUserMapResult = {
|
|
9
|
-
ok: true;
|
|
10
|
-
map: InterchangeMap;
|
|
11
|
-
} | {
|
|
12
|
-
ok: false;
|
|
13
|
-
error: string;
|
|
14
|
-
};
|
|
15
|
-
export declare function loadUserMap(path: string): Promise<LoadUserMapResult>;
|
|
16
5
|
export type ResolvedCompositionSources = {
|
|
17
6
|
forceAgent: boolean;
|
|
18
7
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { RawComponentDefinition } from '../../types.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { CompositionEdge } from './interchange-schema.js';
|
|
3
3
|
import { type EdgeConflict } from './merge-edges.js';
|
|
4
4
|
export type ResolveMappingResult = {
|
|
5
5
|
components: RawComponentDefinition[];
|
|
6
|
-
userMap?: InterchangeMap;
|
|
7
6
|
edges: CompositionEdge[];
|
|
8
7
|
conflicts: EdgeConflict[];
|
|
9
8
|
warnings: string[];
|
|
@@ -11,9 +10,9 @@ export type ResolveMappingResult = {
|
|
|
11
10
|
/**
|
|
12
11
|
* Orchestrate composition-edge acquisition and enrichment.
|
|
13
12
|
*
|
|
14
|
-
* Sources by rank:
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* Sources by rank: typed-slot / "code slots" (2) > structural usage evidence
|
|
14
|
+
* (3) > manifest (4) > doc (5) > adapter-resolved / extraEdges (6) >
|
|
15
|
+
* edge-emitting agent (7). Manifest/doc edges are computed deterministically outside
|
|
17
16
|
* this function (see manifest-doc-evidence.ts) and joined via `extraEdges`.
|
|
18
17
|
* ALL sources — including the code slots already on the incoming components —
|
|
19
18
|
* are fed into one ranked merge and unioned; non-conflicting edges from every
|
|
@@ -28,7 +27,6 @@ export type ResolveMappingResult = {
|
|
|
28
27
|
*/
|
|
29
28
|
export declare function resolveMapping(input: {
|
|
30
29
|
components: RawComponentDefinition[];
|
|
31
|
-
userMap?: InterchangeMap;
|
|
32
30
|
forceAgent?: boolean;
|
|
33
31
|
files: Array<{
|
|
34
32
|
path: string;
|
|
@@ -55,7 +53,7 @@ export declare function resolveMapping(input: {
|
|
|
55
53
|
/**
|
|
56
54
|
* Pre-resolved edges from an external source (e.g. manifest or documentation)
|
|
57
55
|
* path). They join the ranked merge at their own provenance rank alongside
|
|
58
|
-
* code slots and
|
|
56
|
+
* code slots and other automatic mapping sources.
|
|
59
57
|
*/
|
|
60
58
|
extraEdges?: CompositionEdge[];
|
|
61
59
|
}): Promise<ResolveMappingResult>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolution chain for
|
|
2
|
+
* Resolution chain for the combined `--agent` override on `experiences import`.
|
|
3
3
|
*
|
|
4
4
|
* The wizard path previously hard-defaulted `--agent` to `'claude'` at the
|
|
5
5
|
* commander layer, which (a) shadowed the stored `credentials.json` value when
|
|
6
6
|
* the user passed no flag, and (b) made it impossible to distinguish "user
|
|
7
|
-
* explicitly passed --agent claude" from "user passed nothing".
|
|
8
|
-
*
|
|
7
|
+
* explicitly passed --agent claude" from "user passed nothing". The combined
|
|
8
|
+
* flag accepts either `agent:model` or `agent model`.
|
|
9
9
|
*
|
|
10
10
|
* These helpers produce the resolved values to feed into `WizardApp` /
|
|
11
11
|
* the import wizard:
|
|
@@ -15,9 +15,13 @@
|
|
|
15
15
|
* `experiences setup`) is used.
|
|
16
16
|
* 3. Otherwise, the built-in default (currently `'claude'`) is used for
|
|
17
17
|
* the agent. Model has no default — agents pick a small/fast model
|
|
18
|
-
* themselves when
|
|
18
|
+
* themselves when no model is included in `--agent`.
|
|
19
19
|
*/
|
|
20
20
|
/** Built-in fallback agent when neither a flag nor a stored preference is set. */
|
|
21
21
|
export declare const DEFAULT_AGENT = "claude";
|
|
22
|
+
export declare function parseAgentModel(value: string | undefined): {
|
|
23
|
+
agent?: string;
|
|
24
|
+
model?: string;
|
|
25
|
+
};
|
|
22
26
|
export declare function resolveAgent(flagValue: string | undefined, storedValue: string | undefined): string;
|
|
23
27
|
export declare function resolveModel(flagValue: string | undefined, storedValue: string | undefined): string | undefined;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export type CompositionOptionInput = {
|
|
2
|
-
compositionMap?: string;
|
|
3
2
|
prompt?: string[];
|
|
4
3
|
};
|
|
5
4
|
export type CompositionForwardingOptions = {
|
|
6
|
-
compositionMap?: string;
|
|
7
5
|
promptOverrides?: string[];
|
|
8
6
|
};
|
|
9
7
|
export declare function buildCompositionForwardingOptions(options: CompositionOptionInput): CompositionForwardingOptions;
|
|
@@ -17,6 +17,7 @@ export declare function buildGenerateTokensArgs(opts: {
|
|
|
17
17
|
model?: string;
|
|
18
18
|
bedrock?: boolean;
|
|
19
19
|
noCache?: boolean;
|
|
20
|
+
promptOverrides?: string[];
|
|
20
21
|
}): string[];
|
|
21
22
|
export declare function buildMapTokensArgs(opts: {
|
|
22
23
|
sessionId: string;
|
|
@@ -24,6 +25,7 @@ export declare function buildMapTokensArgs(opts: {
|
|
|
24
25
|
model?: string;
|
|
25
26
|
noCache?: boolean;
|
|
26
27
|
skipAgent?: boolean;
|
|
28
|
+
promptOverrides?: string[];
|
|
27
29
|
existingEntitiesPath?: string;
|
|
28
30
|
}): string[];
|
|
29
31
|
export declare function shouldRunMapTokens(opts: {
|
|
@@ -51,7 +53,6 @@ export type WizardAppProps = {
|
|
|
51
53
|
bedrock?: boolean;
|
|
52
54
|
initialProjectPath?: string;
|
|
53
55
|
host?: string;
|
|
54
|
-
compositionMap?: string;
|
|
55
56
|
promptOverrides?: string[];
|
|
56
57
|
noCache?: boolean;
|
|
57
58
|
livePreview?: boolean;
|
|
@@ -59,4 +60,4 @@ export type WizardAppProps = {
|
|
|
59
60
|
skipMapTokens?: boolean;
|
|
60
61
|
initialRawTokensPath?: string;
|
|
61
62
|
};
|
|
62
|
-
export declare function WizardApp({ initialSpaceId, initialEnvironmentId, initialCmaToken, initialHost, initialAgent, initialModel, bedrock, initialProjectPath, host,
|
|
63
|
+
export declare function WizardApp({ initialSpaceId, initialEnvironmentId, initialCmaToken, initialHost, initialAgent, initialModel, bedrock, initialProjectPath, host, promptOverrides, noCache, livePreview, generatePromptPath, skipMapTokens, initialRawTokensPath, }?: WizardAppProps): React.ReactElement;
|
package/dist/src/index.js
CHANGED
|
@@ -4146,12 +4146,17 @@ var init_persistence = __esm({
|
|
|
4146
4146
|
|
|
4147
4147
|
// packages/experience-design-system-cli/src/lib/agent-model-options.ts
|
|
4148
4148
|
function addAgentModelOptions(cmd, config = {}) {
|
|
4149
|
-
const {
|
|
4149
|
+
const {
|
|
4150
|
+
agentDescription = AGENT_DESCRIPTION,
|
|
4151
|
+
includeModel = true,
|
|
4152
|
+
includeBedrock = true,
|
|
4153
|
+
modelDescription = MODEL_DESCRIPTION
|
|
4154
|
+
} = config;
|
|
4150
4155
|
cmd.option("--agent <name>", agentDescription);
|
|
4151
4156
|
if (includeModel) {
|
|
4152
4157
|
cmd.option("--model <name>", modelDescription);
|
|
4153
4158
|
}
|
|
4154
|
-
cmd.option("--bedrock", BEDROCK_DESCRIPTION);
|
|
4159
|
+
if (includeBedrock) cmd.option("--bedrock", BEDROCK_DESCRIPTION);
|
|
4155
4160
|
return cmd;
|
|
4156
4161
|
}
|
|
4157
4162
|
var AGENT_DESCRIPTION, MODEL_DESCRIPTION, BEDROCK_AGENTS, BEDROCK_DESCRIPTION;
|
|
@@ -4910,7 +4915,8 @@ async function runGenerateSkill(skill, opts, verbose = false) {
|
|
|
4910
4915
|
const { overrides: promptOverrides, errors: promptErrors } = parsePromptOverrides(opts.prompt ?? []);
|
|
4911
4916
|
if (promptErrors.length > 0) die(`Error: ${promptErrors.join("; ")}`);
|
|
4912
4917
|
let generatePrompt;
|
|
4913
|
-
const
|
|
4918
|
+
const promptStage = skill === "tokens" ? "tokens" : "generate";
|
|
4919
|
+
const generateOverride = promptOverrides.get(promptStage);
|
|
4914
4920
|
if (generateOverride) {
|
|
4915
4921
|
try {
|
|
4916
4922
|
generatePrompt = await resolvePromptOverride(generateOverride);
|
|
@@ -5260,7 +5266,12 @@ function registerInternalGenerateCommand(program) {
|
|
|
5260
5266
|
addAgentFlags(componentsCmd).action(async (opts) => {
|
|
5261
5267
|
await runGenerateSkill("components", opts, opts.verbose ?? false);
|
|
5262
5268
|
});
|
|
5263
|
-
const tokensCmd = generate.command("tokens").description("Invoke a coding agent to produce tokens.json from raw token data").option("--raw-tokens <path>", "Path to raw token input file")
|
|
5269
|
+
const tokensCmd = generate.command("tokens").description("Invoke a coding agent to produce tokens.json from raw token data").option("--raw-tokens <path>", "Path to raw token input file").option(
|
|
5270
|
+
"--prompt <stage=value>",
|
|
5271
|
+
"Override a stage prompt (repeatable). Used here for the tokens stage.",
|
|
5272
|
+
(v, acc) => [...acc, v],
|
|
5273
|
+
[]
|
|
5274
|
+
);
|
|
5264
5275
|
addAgentFlags(tokensCmd).action(async (opts) => {
|
|
5265
5276
|
await runGenerateSkill("tokens", opts, opts.verbose ?? false);
|
|
5266
5277
|
});
|
|
@@ -7532,7 +7543,7 @@ function buildApplyOutput(operation, spaceId, environmentId, host) {
|
|
|
7532
7543
|
};
|
|
7533
7544
|
}
|
|
7534
7545
|
function registerApplyCommand(program) {
|
|
7535
|
-
const applyCmd = program.command("apply").description("Write component types and design tokens to Contentful ExO").argument("<file>", "CDF file containing all component and design token definitions");
|
|
7546
|
+
const applyCmd = program.command("apply").description("Write component types and design tokens to Contentful ExO").helpOption(false).argument("<file>", "CDF file containing all component and design token definitions");
|
|
7536
7547
|
applyCmd.action(async (file) => {
|
|
7537
7548
|
const isTTY = getInteractiveTerminalSupport().supported;
|
|
7538
7549
|
const inputs = await resolveSharedInputsOrDie(file);
|
|
@@ -8480,6 +8491,20 @@ async function runMapTokens(opts) {
|
|
|
8480
8491
|
);
|
|
8481
8492
|
}
|
|
8482
8493
|
const resultAgent = configuredAgent ?? "skipped";
|
|
8494
|
+
const { overrides: promptOverrides, errors: promptErrors } = parsePromptOverrides(opts.prompt ?? []);
|
|
8495
|
+
if (promptErrors.length > 0) die(`Error: ${promptErrors.join("; ")}`);
|
|
8496
|
+
const mapPromptOverride = promptOverrides.get("map-tokens");
|
|
8497
|
+
let mapPromptText;
|
|
8498
|
+
let mapPromptPath;
|
|
8499
|
+
if (mapPromptOverride?.kind === "text") mapPromptText = mapPromptOverride.value;
|
|
8500
|
+
if (mapPromptOverride?.kind === "path") {
|
|
8501
|
+
mapPromptPath = resolve8(mapPromptOverride.value);
|
|
8502
|
+
try {
|
|
8503
|
+
await resolvePromptOverride(mapPromptOverride);
|
|
8504
|
+
} catch (error) {
|
|
8505
|
+
die(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
8506
|
+
}
|
|
8507
|
+
}
|
|
8483
8508
|
const db = openPipelineDb();
|
|
8484
8509
|
try {
|
|
8485
8510
|
const sessionId2 = opts.session ?? findLatestSessionForCommand(db, "generate components");
|
|
@@ -8582,16 +8607,19 @@ ${defaultDiagnostics.map((diagnostic) => ` ${diagnostic}`).join("\n")}
|
|
|
8582
8607
|
);
|
|
8583
8608
|
}
|
|
8584
8609
|
}
|
|
8610
|
+
const buildMapPrompt = () => buildPrompt({
|
|
8611
|
+
skill: "map-tokens",
|
|
8612
|
+
mode: "autonomous",
|
|
8613
|
+
generatedCdf,
|
|
8614
|
+
tokenTree,
|
|
8615
|
+
componentSourceRefs,
|
|
8616
|
+
outDir: process.cwd(),
|
|
8617
|
+
existingTokensInline,
|
|
8618
|
+
...mapPromptText !== void 0 ? { skillContentOverride: mapPromptText } : {},
|
|
8619
|
+
...mapPromptText === void 0 && mapPromptPath ? { skillPathOverride: mapPromptPath } : {}
|
|
8620
|
+
});
|
|
8585
8621
|
if (opts.printPrompt) {
|
|
8586
|
-
const prompt2 = await
|
|
8587
|
-
skill: "map-tokens",
|
|
8588
|
-
mode: "autonomous",
|
|
8589
|
-
generatedCdf,
|
|
8590
|
-
tokenTree,
|
|
8591
|
-
componentSourceRefs,
|
|
8592
|
-
outDir: process.cwd(),
|
|
8593
|
-
existingTokensInline
|
|
8594
|
-
});
|
|
8622
|
+
const prompt2 = await buildMapPrompt();
|
|
8595
8623
|
process.stdout.write(prompt2 + "\n");
|
|
8596
8624
|
await exitWithAnalytics(0);
|
|
8597
8625
|
return;
|
|
@@ -8613,7 +8641,8 @@ ${defaultDiagnostics.map((diagnostic) => ` ${diagnostic}`).join("\n")}
|
|
|
8613
8641
|
agent,
|
|
8614
8642
|
model,
|
|
8615
8643
|
void 0,
|
|
8616
|
-
existingTokensInline ? [hashContent(existingTokensInline)] : []
|
|
8644
|
+
existingTokensInline ? [hashContent(existingTokensInline)] : [],
|
|
8645
|
+
mapPromptText
|
|
8617
8646
|
);
|
|
8618
8647
|
const inputHash = computeMapTokensInputHash(db, sessionId2, componentSourceRefs);
|
|
8619
8648
|
if (!noCache) {
|
|
@@ -8635,15 +8664,7 @@ Install it, choose another agent with --agent, or use --print-prompt to run the
|
|
|
8635
8664
|
);
|
|
8636
8665
|
}
|
|
8637
8666
|
const stepId = createStep(db, sessionId2, "map tokens", { agent, model: model ?? "" });
|
|
8638
|
-
const prompt = await
|
|
8639
|
-
skill: "map-tokens",
|
|
8640
|
-
mode: "autonomous",
|
|
8641
|
-
generatedCdf,
|
|
8642
|
-
tokenTree,
|
|
8643
|
-
componentSourceRefs,
|
|
8644
|
-
outDir: process.cwd(),
|
|
8645
|
-
existingTokensInline
|
|
8646
|
-
});
|
|
8667
|
+
const prompt = await buildMapPrompt();
|
|
8647
8668
|
const invoker2 = createLocalCliAgentInvoker();
|
|
8648
8669
|
const result = await invoker2.invoke({ agent, model, prompt, timeoutMs: DEFAULT_TIMEOUT_MS2 });
|
|
8649
8670
|
if (result.timedOut || result.exitCode !== 0) {
|
|
@@ -8669,7 +8690,12 @@ ${warnings.map((w) => ` ${w}`).join("\n")}
|
|
|
8669
8690
|
}
|
|
8670
8691
|
function registerMapTokensCommand(program) {
|
|
8671
8692
|
const map = program.command("map", { hidden: true }).description("Suggest token restrictions for generated design-token props");
|
|
8672
|
-
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("--no-cache", "Bypass the map-tokens cache and force a re-run").option(
|
|
8693
|
+
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("--no-cache", "Bypass the map-tokens cache and force a re-run").option(
|
|
8694
|
+
"--prompt <stage=value>",
|
|
8695
|
+
"Override a stage prompt (repeatable). Used here for the map-tokens stage.",
|
|
8696
|
+
(v, acc) => [...acc, v],
|
|
8697
|
+
[]
|
|
8698
|
+
).option("--token-map <path>", "Path to token-name-map.json sidecar").option(
|
|
8673
8699
|
"--existing-entities-path <path>",
|
|
8674
8700
|
"Path to the .existing-entities.json file written after CMA credentials are supplied. When present, the agent gets a list of the space's existing design tokens so it can prefer binding to them. Missing/malformed files are treated as no-op."
|
|
8675
8701
|
);
|
|
@@ -8694,6 +8720,7 @@ var init_command4 = __esm({
|
|
|
8694
8720
|
init_MapTokensView();
|
|
8695
8721
|
init_resolve_defaults();
|
|
8696
8722
|
init_cli_errors();
|
|
8723
|
+
init_prompt_overrides();
|
|
8697
8724
|
DEFAULT_TIMEOUT_MS2 = Number(process.env.EDS_AGENT_TIMEOUT_MS ?? 5 * 60 * 1e3);
|
|
8698
8725
|
}
|
|
8699
8726
|
});
|
|
@@ -8722,6 +8749,19 @@ var init_path_utils = __esm({
|
|
|
8722
8749
|
});
|
|
8723
8750
|
|
|
8724
8751
|
// packages/experience-design-system-cli/src/import/agent-model-resolve.ts
|
|
8752
|
+
function parseAgentModel(value) {
|
|
8753
|
+
if (!value?.trim()) return {};
|
|
8754
|
+
const trimmed = value.trim();
|
|
8755
|
+
const separator = trimmed.indexOf(":");
|
|
8756
|
+
if (separator >= 0) {
|
|
8757
|
+
return {
|
|
8758
|
+
agent: trimmed.slice(0, separator).trim() || void 0,
|
|
8759
|
+
model: trimmed.slice(separator + 1).trim() || void 0
|
|
8760
|
+
};
|
|
8761
|
+
}
|
|
8762
|
+
const [agent, ...modelParts] = trimmed.split(/\s+/);
|
|
8763
|
+
return { agent, ...modelParts.length > 0 ? { model: modelParts.join(" ") } : {} };
|
|
8764
|
+
}
|
|
8725
8765
|
function resolveAgent(flagValue, storedValue) {
|
|
8726
8766
|
if (flagValue && flagValue.length > 0) return flagValue;
|
|
8727
8767
|
if (storedValue && storedValue.length > 0) return storedValue;
|
|
@@ -8743,7 +8783,6 @@ var init_agent_model_resolve = __esm({
|
|
|
8743
8783
|
// packages/experience-design-system-cli/src/import/composition-options.ts
|
|
8744
8784
|
function buildCompositionForwardingOptions(options) {
|
|
8745
8785
|
return {
|
|
8746
|
-
...options.compositionMap ? { compositionMap: options.compositionMap } : {},
|
|
8747
8786
|
...options.prompt && options.prompt.length > 0 ? { promptOverrides: options.prompt } : {}
|
|
8748
8787
|
};
|
|
8749
8788
|
}
|
|
@@ -26650,6 +26689,70 @@ var init_wizard_state_transitions = __esm({
|
|
|
26650
26689
|
}
|
|
26651
26690
|
});
|
|
26652
26691
|
|
|
26692
|
+
// packages/experience-design-system-cli/src/import/tui/run-selection-agent.ts
|
|
26693
|
+
async function runSelectionAgent(options) {
|
|
26694
|
+
const db = openPipelineDb();
|
|
26695
|
+
let components;
|
|
26696
|
+
try {
|
|
26697
|
+
components = loadRawComponents(db, options.sessionId);
|
|
26698
|
+
} finally {
|
|
26699
|
+
db.close();
|
|
26700
|
+
}
|
|
26701
|
+
if (components.length === 0) return;
|
|
26702
|
+
const invoker2 = createLocalCliAgentInvoker({
|
|
26703
|
+
onDebugEvent: (name, payload) => getDebugLogger().event("agent", name, payload)
|
|
26704
|
+
});
|
|
26705
|
+
const prompt = await buildPrompt({
|
|
26706
|
+
skill: "select",
|
|
26707
|
+
mode: "autonomous",
|
|
26708
|
+
rawComponentsInline: JSON.stringify(components, null, 2),
|
|
26709
|
+
outDir: process.cwd(),
|
|
26710
|
+
...options.promptText !== void 0 ? { skillContentOverride: options.promptText } : {},
|
|
26711
|
+
...options.promptText === void 0 && options.promptPath ? { skillPathOverride: options.promptPath } : {}
|
|
26712
|
+
});
|
|
26713
|
+
const { result } = await invokeAgentWithOutput(
|
|
26714
|
+
invoker2,
|
|
26715
|
+
{ agent: options.agent, model: options.model, prompt, timeoutMs: DEFAULT_TIMEOUT_MS4 },
|
|
26716
|
+
false
|
|
26717
|
+
);
|
|
26718
|
+
if (result.timedOut) throw new Error("selection agent timed out");
|
|
26719
|
+
if (result.exitCode !== 0) throw new Error(`selection agent exited with code ${result.exitCode}`);
|
|
26720
|
+
const { calls, warnings } = parseSelectToolCallLines(result.stdout);
|
|
26721
|
+
for (const warning of warnings) process.stderr.write(`Warning: selection agent: ${warning}
|
|
26722
|
+
`);
|
|
26723
|
+
const byName = new Map(calls.map((call) => [call.name, call]));
|
|
26724
|
+
const writeDb = openPipelineDb();
|
|
26725
|
+
try {
|
|
26726
|
+
const update = writeDb.prepare(
|
|
26727
|
+
`UPDATE raw_components SET status = ?, reject_reason = ? WHERE session_id = ? AND component_id = ?`
|
|
26728
|
+
);
|
|
26729
|
+
for (const component of components) {
|
|
26730
|
+
const call = byName.get(component.name);
|
|
26731
|
+
if (!call) continue;
|
|
26732
|
+
const rejected = call.tool === "reject_component";
|
|
26733
|
+
update.run(
|
|
26734
|
+
rejected ? "rejected" : "accepted",
|
|
26735
|
+
rejected ? call.reason ?? null : null,
|
|
26736
|
+
options.sessionId,
|
|
26737
|
+
component.component_id
|
|
26738
|
+
);
|
|
26739
|
+
}
|
|
26740
|
+
} finally {
|
|
26741
|
+
writeDb.close();
|
|
26742
|
+
}
|
|
26743
|
+
}
|
|
26744
|
+
var DEFAULT_TIMEOUT_MS4;
|
|
26745
|
+
var init_run_selection_agent = __esm({
|
|
26746
|
+
"packages/experience-design-system-cli/src/import/tui/run-selection-agent.ts"() {
|
|
26747
|
+
"use strict";
|
|
26748
|
+
init_src();
|
|
26749
|
+
init_debug_logger();
|
|
26750
|
+
init_agent_output();
|
|
26751
|
+
init_db();
|
|
26752
|
+
DEFAULT_TIMEOUT_MS4 = Number(process.env.EDS_AGENT_TIMEOUT_MS ?? 5 * 60 * 1e3);
|
|
26753
|
+
}
|
|
26754
|
+
});
|
|
26755
|
+
|
|
26653
26756
|
// packages/experience-design-system-cli/src/import/tui/WizardApp.tsx
|
|
26654
26757
|
var WizardApp_exports = {};
|
|
26655
26758
|
__export(WizardApp_exports, {
|
|
@@ -26688,6 +26791,7 @@ function buildGenerateTokensArgs(opts) {
|
|
|
26688
26791
|
if (opts.model) args.push("--model", opts.model);
|
|
26689
26792
|
if (opts.bedrock) args.push("--bedrock");
|
|
26690
26793
|
if (opts.noCache) args.push("--no-cache");
|
|
26794
|
+
for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
|
|
26691
26795
|
return args;
|
|
26692
26796
|
}
|
|
26693
26797
|
function buildMapTokensArgs(opts) {
|
|
@@ -26695,6 +26799,7 @@ function buildMapTokensArgs(opts) {
|
|
|
26695
26799
|
if (opts.model) args.push("--model", opts.model);
|
|
26696
26800
|
if (opts.noCache) args.push("--no-cache");
|
|
26697
26801
|
if (opts.skipAgent) args.push("--skip-agent");
|
|
26802
|
+
for (const prompt of opts.promptOverrides ?? []) args.push("--prompt", prompt);
|
|
26698
26803
|
if (opts.existingEntitiesPath) args.push("--existing-entities-path", opts.existingEntitiesPath);
|
|
26699
26804
|
return args;
|
|
26700
26805
|
}
|
|
@@ -26770,7 +26875,6 @@ function WizardApp({
|
|
|
26770
26875
|
bedrock = false,
|
|
26771
26876
|
initialProjectPath,
|
|
26772
26877
|
host,
|
|
26773
|
-
compositionMap,
|
|
26774
26878
|
promptOverrides,
|
|
26775
26879
|
noCache = false,
|
|
26776
26880
|
livePreview = true,
|
|
@@ -26940,7 +27044,8 @@ If you are using AWS Bedrock, run:
|
|
|
26940
27044
|
agent: state.agent,
|
|
26941
27045
|
...state.agentModel ? { model: state.agentModel } : {},
|
|
26942
27046
|
...state.bedrock ? { bedrock: true } : {},
|
|
26943
|
-
noCache: effectiveNoCache
|
|
27047
|
+
noCache: effectiveNoCache,
|
|
27048
|
+
promptOverrides
|
|
26944
27049
|
});
|
|
26945
27050
|
const result = await runSpawnedCli(tokenArgs);
|
|
26946
27051
|
if (result.exitCode !== 0) {
|
|
@@ -27020,6 +27125,7 @@ If you are using AWS Bedrock, run:
|
|
|
27020
27125
|
...state.agentModel ? { model: state.agentModel } : {},
|
|
27021
27126
|
noCache: effectiveNoCache,
|
|
27022
27127
|
skipAgent: skipMapTokens,
|
|
27128
|
+
promptOverrides,
|
|
27023
27129
|
...state.existingEntitiesPath ? { existingEntitiesPath: state.existingEntitiesPath } : {}
|
|
27024
27130
|
});
|
|
27025
27131
|
const result = await runCli(args);
|
|
@@ -27038,7 +27144,6 @@ If you are using AWS Bedrock, run:
|
|
|
27038
27144
|
update({ step: "extracting", outDir, extractProgress: null, compositionPhase: null });
|
|
27039
27145
|
const extractArgs = [findCliPath(), "__extract", "--project", projectPath];
|
|
27040
27146
|
if (noCache) extractArgs.push("--composition-refresh");
|
|
27041
|
-
if (compositionMap) extractArgs.push("--composition-map", compositionMap);
|
|
27042
27147
|
for (const p of promptOverrides ?? []) extractArgs.push("--prompt", p);
|
|
27043
27148
|
if (state.agent) extractArgs.push("--agent", state.agent);
|
|
27044
27149
|
if (state.bedrock) extractArgs.push("--bedrock");
|
|
@@ -27103,6 +27208,34 @@ Make sure this path contains TypeScript/React/Vue component files (.tsx, .ts, .v
|
|
|
27103
27208
|
});
|
|
27104
27209
|
return;
|
|
27105
27210
|
}
|
|
27211
|
+
try {
|
|
27212
|
+
const { overrides, errors } = parsePromptOverrides(promptOverrides ?? []);
|
|
27213
|
+
if (errors.length > 0) throw new Error(errors.join("; "));
|
|
27214
|
+
const selectOverride = overrides.get("select");
|
|
27215
|
+
let promptText;
|
|
27216
|
+
let promptPath;
|
|
27217
|
+
if (selectOverride?.kind === "text") promptText = selectOverride.value;
|
|
27218
|
+
if (selectOverride?.kind === "path") {
|
|
27219
|
+
promptPath = resolve17(selectOverride.value);
|
|
27220
|
+
await resolvePromptOverride(selectOverride);
|
|
27221
|
+
}
|
|
27222
|
+
if (state.agent) {
|
|
27223
|
+
await runSelectionAgent({
|
|
27224
|
+
sessionId: extractSessionId ?? "",
|
|
27225
|
+
agent: state.agent,
|
|
27226
|
+
...state.agentModel ? { model: state.agentModel } : {},
|
|
27227
|
+
...promptText !== void 0 ? { promptText } : {},
|
|
27228
|
+
...promptPath ? { promptPath } : {}
|
|
27229
|
+
});
|
|
27230
|
+
}
|
|
27231
|
+
} catch (error) {
|
|
27232
|
+
update({
|
|
27233
|
+
step: "error",
|
|
27234
|
+
errorStep: "selection agent",
|
|
27235
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
27236
|
+
});
|
|
27237
|
+
return;
|
|
27238
|
+
}
|
|
27106
27239
|
update({
|
|
27107
27240
|
step: "scope-gate",
|
|
27108
27241
|
extractSessionId
|
|
@@ -28349,6 +28482,8 @@ var init_WizardApp = __esm({
|
|
|
28349
28482
|
init_fetch_and_persist_existing_contentful_entities();
|
|
28350
28483
|
init_wizard_state_transitions();
|
|
28351
28484
|
init_cli_path();
|
|
28485
|
+
init_prompt_overrides();
|
|
28486
|
+
init_run_selection_agent();
|
|
28352
28487
|
WIZARD_LOG = join20(tmpdir(), "experiences-import-wizard.log");
|
|
28353
28488
|
}
|
|
28354
28489
|
});
|
|
@@ -28356,80 +28491,71 @@ var init_WizardApp = __esm({
|
|
|
28356
28491
|
// packages/experience-design-system-cli/src/import/command.ts
|
|
28357
28492
|
function registerImportCommand(program) {
|
|
28358
28493
|
const cmd = program.command("import").description("Run the full pipeline: analyze \u2192 select \u2192 generate \u2192 push").option("--project <path>", "Path to the project root to analyze", ".");
|
|
28359
|
-
|
|
28360
|
-
|
|
28361
|
-
modelDescription: "Model to use for generate components (defaults to a lightweight per-agent model; override with EDS_AGENT_MODEL_<AGENT>)"
|
|
28362
|
-
}).option(
|
|
28363
|
-
"--raw-tokens <path>",
|
|
28494
|
+
cmd.option(
|
|
28495
|
+
"--tokens <path>",
|
|
28364
28496
|
"Path to a raw token source file (SCSS, CSS variables, JS/TS, Style Dictionary, etc.) to classify and import alongside components. Bypasses the interactive token prompt."
|
|
28365
|
-
)
|
|
28366
|
-
|
|
28367
|
-
|
|
28368
|
-
|
|
28369
|
-
|
|
28497
|
+
);
|
|
28498
|
+
addAgentModelOptions(cmd, {
|
|
28499
|
+
agentDescription: 'Agent and optional model as agent:model or "agent model" (overrides credentials.json; falls back to "claude")',
|
|
28500
|
+
includeModel: false,
|
|
28501
|
+
includeBedrock: false
|
|
28502
|
+
});
|
|
28503
|
+
cmd.option(
|
|
28370
28504
|
"--prompt <stage=value>",
|
|
28371
|
-
"Override a
|
|
28505
|
+
"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",
|
|
28372
28506
|
(v, acc) => [...acc, v],
|
|
28373
28507
|
[]
|
|
28374
|
-
).action(
|
|
28375
|
-
|
|
28376
|
-
|
|
28377
|
-
|
|
28378
|
-
|
|
28379
|
-
|
|
28380
|
-
|
|
28381
|
-
|
|
28382
|
-
process.stderr.write(`Error: --raw-tokens: file not found: ${opts.rawTokens}
|
|
28383
|
-
`);
|
|
28384
|
-
process.exit(1);
|
|
28385
|
-
return;
|
|
28386
|
-
}
|
|
28387
|
-
}
|
|
28388
|
-
if (!interactiveTerminalSupported) {
|
|
28389
|
-
requireInteractiveTerminal({
|
|
28390
|
-
alternative: "run experiences import in an interactive terminal"
|
|
28391
|
-
});
|
|
28392
|
-
}
|
|
28393
|
-
{
|
|
28394
|
-
const { render: render5 } = await import("ink");
|
|
28395
|
-
const { createElement: createElement6 } = await import("react");
|
|
28396
|
-
const { WizardApp: WizardApp2 } = await Promise.resolve().then(() => (init_WizardApp(), WizardApp_exports));
|
|
28397
|
-
const creds = await readExperiencesCredentials();
|
|
28398
|
-
const resolvedAgent = resolveAgent(opts.agent, creds.agent);
|
|
28399
|
-
const resolvedModel = resolveModel(opts.model, creds.agentModel);
|
|
28400
|
-
if (opts.bedrock && !(isAgentName(resolvedAgent) && agentSupportsBedrock(resolvedAgent))) {
|
|
28401
|
-
process.stderr.write(`Error: --bedrock is not supported for --agent ${resolvedAgent}
|
|
28508
|
+
).option("--no-cache", "Re-run all steps even if output already exists").action(async (opts) => {
|
|
28509
|
+
const interactiveTerminalSupported = getInteractiveTerminalSupport().supported;
|
|
28510
|
+
if (opts.tokens !== void 0) {
|
|
28511
|
+
const { access: access9 } = await import("node:fs/promises");
|
|
28512
|
+
try {
|
|
28513
|
+
await access9(normalizePath(opts.tokens));
|
|
28514
|
+
} catch {
|
|
28515
|
+
process.stderr.write(`Error: --tokens: file not found: ${opts.tokens}
|
|
28402
28516
|
`);
|
|
28403
|
-
|
|
28404
|
-
}
|
|
28405
|
-
const { waitUntilExit } = render5(
|
|
28406
|
-
createElement6(WizardApp2, {
|
|
28407
|
-
initialSpaceId: creds.spaceId,
|
|
28408
|
-
initialEnvironmentId: creds.environmentId || "master",
|
|
28409
|
-
initialCmaToken: creds.cmaToken,
|
|
28410
|
-
initialHost: toConfiguredHost(creds.host) ?? DEFAULT_CONFIGURED_HOST,
|
|
28411
|
-
initialAgent: resolvedAgent,
|
|
28412
|
-
...resolvedModel ? { initialModel: resolvedModel } : {},
|
|
28413
|
-
...opts.bedrock ? { bedrock: true } : {},
|
|
28414
|
-
initialProjectPath: opts.project !== "." ? normalizePath(opts.project) : void 0,
|
|
28415
|
-
...buildCompositionForwardingOptions(opts),
|
|
28416
|
-
noCache: opts.cache === false,
|
|
28417
|
-
skipMapTokens: opts.skipMapTokens ?? false,
|
|
28418
|
-
livePreview: true,
|
|
28419
|
-
generatePromptPath: creds.generatePromptPath,
|
|
28420
|
-
...opts.rawTokens ? { initialRawTokensPath: normalizePath(opts.rawTokens) } : {}
|
|
28421
|
-
})
|
|
28422
|
-
);
|
|
28423
|
-
await waitUntilExit();
|
|
28517
|
+
process.exit(1);
|
|
28424
28518
|
return;
|
|
28425
28519
|
}
|
|
28426
28520
|
}
|
|
28427
|
-
|
|
28521
|
+
if (!interactiveTerminalSupported) {
|
|
28522
|
+
requireInteractiveTerminal({
|
|
28523
|
+
alternative: "run experiences import in an interactive terminal"
|
|
28524
|
+
});
|
|
28525
|
+
}
|
|
28526
|
+
{
|
|
28527
|
+
const { render: render5 } = await import("ink");
|
|
28528
|
+
const { createElement: createElement6 } = await import("react");
|
|
28529
|
+
const { WizardApp: WizardApp2 } = await Promise.resolve().then(() => (init_WizardApp(), WizardApp_exports));
|
|
28530
|
+
const creds = await readExperiencesCredentials();
|
|
28531
|
+
const parsedAgentModel = parseAgentModel(opts.agent);
|
|
28532
|
+
const resolvedAgent = resolveAgent(parsedAgentModel.agent, creds.agent);
|
|
28533
|
+
const resolvedModel = resolveModel(parsedAgentModel.model, creds.agentModel);
|
|
28534
|
+
const { waitUntilExit } = render5(
|
|
28535
|
+
createElement6(WizardApp2, {
|
|
28536
|
+
initialSpaceId: creds.spaceId,
|
|
28537
|
+
initialEnvironmentId: creds.environmentId || "master",
|
|
28538
|
+
initialCmaToken: creds.cmaToken,
|
|
28539
|
+
initialHost: toConfiguredHost(creds.host) ?? DEFAULT_CONFIGURED_HOST,
|
|
28540
|
+
initialAgent: resolvedAgent,
|
|
28541
|
+
...resolvedModel ? { initialModel: resolvedModel } : {},
|
|
28542
|
+
initialProjectPath: opts.project !== "." ? normalizePath(opts.project) : void 0,
|
|
28543
|
+
...buildCompositionForwardingOptions(opts),
|
|
28544
|
+
noCache: opts.cache === false,
|
|
28545
|
+
skipMapTokens: false,
|
|
28546
|
+
livePreview: true,
|
|
28547
|
+
generatePromptPath: creds.generatePromptPath,
|
|
28548
|
+
...opts.tokens ? { initialRawTokensPath: normalizePath(opts.tokens) } : {}
|
|
28549
|
+
})
|
|
28550
|
+
);
|
|
28551
|
+
await waitUntilExit();
|
|
28552
|
+
return;
|
|
28553
|
+
}
|
|
28554
|
+
});
|
|
28428
28555
|
}
|
|
28429
28556
|
var init_command6 = __esm({
|
|
28430
28557
|
"packages/experience-design-system-cli/src/import/command.ts"() {
|
|
28431
28558
|
"use strict";
|
|
28432
|
-
init_src();
|
|
28433
28559
|
init_path_utils();
|
|
28434
28560
|
init_agent_model_resolve();
|
|
28435
28561
|
init_agent_model_options();
|
|
@@ -28742,7 +28868,7 @@ var init_checks2 = __esm({
|
|
|
28742
28868
|
});
|
|
28743
28869
|
|
|
28744
28870
|
// packages/experience-design-system-cli/src/doctor/command.ts
|
|
28745
|
-
async function runChecks(
|
|
28871
|
+
async function runChecks() {
|
|
28746
28872
|
const pkgRoot = findPkgRoot();
|
|
28747
28873
|
const results = [];
|
|
28748
28874
|
const record = (name, passed, required = true) => {
|
|
@@ -28751,13 +28877,11 @@ async function runChecks(opts) {
|
|
|
28751
28877
|
};
|
|
28752
28878
|
if (record("Node.js version", await reportNode())) {
|
|
28753
28879
|
const pnpmOk = record("pnpm", await reportPnpm(pkgRoot));
|
|
28754
|
-
if (
|
|
28755
|
-
info("\nSkipping install + build (--skip-build)");
|
|
28756
|
-
} else if (pnpmOk && record("dependencies", await reportDependencies(pkgRoot))) {
|
|
28880
|
+
if (pnpmOk && record("dependencies", await reportDependencies(pkgRoot))) {
|
|
28757
28881
|
record("build", await reportBuild(pkgRoot));
|
|
28758
28882
|
}
|
|
28759
28883
|
}
|
|
28760
|
-
|
|
28884
|
+
record("coding agent", await reportAgent(), false);
|
|
28761
28885
|
return results;
|
|
28762
28886
|
}
|
|
28763
28887
|
function printSummary(results) {
|
|
@@ -28797,13 +28921,13 @@ ${c.red(c.bold(`\u2717 ${requiredFailed} required check${requiredFailed === 1 ?
|
|
|
28797
28921
|
`);
|
|
28798
28922
|
return 1;
|
|
28799
28923
|
}
|
|
28800
|
-
async function runDoctor(
|
|
28924
|
+
async function runDoctor() {
|
|
28801
28925
|
process.stderr.write(`${c.bold("experiences doctor")} \u2014 checking your environment
|
|
28802
28926
|
`);
|
|
28803
|
-
process.exitCode = printSummary(await runChecks(
|
|
28927
|
+
process.exitCode = printSummary(await runChecks());
|
|
28804
28928
|
}
|
|
28805
28929
|
function registerDoctorCommand(program) {
|
|
28806
|
-
program.command("doctor").description("Check prerequisites so experiences import runs without errors").
|
|
28930
|
+
program.command("doctor").description("Check prerequisites so experiences import runs without errors").helpOption(false).action(() => runDoctor());
|
|
28807
28931
|
}
|
|
28808
28932
|
var init_command7 = __esm({
|
|
28809
28933
|
"packages/experience-design-system-cli/src/doctor/command.ts"() {
|
|
@@ -29943,7 +30067,7 @@ async function runSetup(opts) {
|
|
|
29943
30067
|
process.exit(finished.exitCode);
|
|
29944
30068
|
}
|
|
29945
30069
|
function registerSetupCommand(program) {
|
|
29946
|
-
program.command("setup").description("Interactive setup: installs prerequisites and configures credentials for experiences import").
|
|
30070
|
+
program.command("setup").description("Interactive setup: installs prerequisites and configures credentials for experiences import").helpOption(false).action(() => runSetup({}));
|
|
29947
30071
|
}
|
|
29948
30072
|
var SETUP_REQUIRES_TTY_MESSAGE;
|
|
29949
30073
|
var init_command8 = __esm({
|
|
@@ -29955,57 +30079,14 @@ var init_command8 = __esm({
|
|
|
29955
30079
|
}
|
|
29956
30080
|
});
|
|
29957
30081
|
|
|
29958
|
-
// packages/experience-design-system-cli/src/analyze/composition/interchange-schema.ts
|
|
29959
|
-
function validateInterchangeMap(input) {
|
|
29960
|
-
const errors = [];
|
|
29961
|
-
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
29962
|
-
return { valid: false, errors: ["interchange map must be a JSON object"] };
|
|
29963
|
-
}
|
|
29964
|
-
const obj = input;
|
|
29965
|
-
if (obj.version !== 1) {
|
|
29966
|
-
errors.push(`unsupported interchange version: expected 1, got ${JSON.stringify(obj.version)}`);
|
|
29967
|
-
}
|
|
29968
|
-
if (typeof obj.groups !== "object" || obj.groups === null || Array.isArray(obj.groups)) {
|
|
29969
|
-
errors.push("interchange map must have a `groups` object");
|
|
29970
|
-
return { valid: false, errors };
|
|
29971
|
-
}
|
|
29972
|
-
const groups = obj.groups;
|
|
29973
|
-
for (const [parent, children] of Object.entries(groups)) {
|
|
29974
|
-
if (!Array.isArray(children) || !children.every((c2) => typeof c2 === "string")) {
|
|
29975
|
-
errors.push(`groups["${parent}"] must be an array of strings`);
|
|
29976
|
-
}
|
|
29977
|
-
}
|
|
29978
|
-
if (errors.length > 0) return { valid: false, errors };
|
|
29979
|
-
return { valid: true, map: { version: 1, groups } };
|
|
29980
|
-
}
|
|
29981
|
-
function groupsToEdges(map, provenance) {
|
|
29982
|
-
const seen = /* @__PURE__ */ new Set();
|
|
29983
|
-
const edges = [];
|
|
29984
|
-
for (const [parent, children] of Object.entries(map.groups)) {
|
|
29985
|
-
for (const child of children) {
|
|
29986
|
-
const key = `${parent}::${child}`;
|
|
29987
|
-
if (seen.has(key)) continue;
|
|
29988
|
-
seen.add(key);
|
|
29989
|
-
edges.push({ parent, child, provenance });
|
|
29990
|
-
}
|
|
29991
|
-
}
|
|
29992
|
-
return edges;
|
|
29993
|
-
}
|
|
29994
|
-
var init_interchange_schema = __esm({
|
|
29995
|
-
"packages/experience-design-system-cli/src/analyze/composition/interchange-schema.ts"() {
|
|
29996
|
-
"use strict";
|
|
29997
|
-
}
|
|
29998
|
-
});
|
|
29999
|
-
|
|
30000
30082
|
// packages/experience-design-system-cli/src/analyze/composition/merge-edges.ts
|
|
30001
30083
|
function rank(p) {
|
|
30002
|
-
if (p === "
|
|
30003
|
-
if (p === "
|
|
30004
|
-
if (p === "
|
|
30005
|
-
if (p === "
|
|
30006
|
-
if (p
|
|
30007
|
-
|
|
30008
|
-
return 7;
|
|
30084
|
+
if (p === "typed-slot") return 1;
|
|
30085
|
+
if (p === "structural") return 2;
|
|
30086
|
+
if (p === "manifest") return 3;
|
|
30087
|
+
if (p === "doc") return 4;
|
|
30088
|
+
if (p.startsWith("adapter:")) return 5;
|
|
30089
|
+
return 6;
|
|
30009
30090
|
}
|
|
30010
30091
|
function mergeEdges(all) {
|
|
30011
30092
|
const byKey = /* @__PURE__ */ new Map();
|
|
@@ -30111,7 +30192,7 @@ function applyMapping(components, edges) {
|
|
|
30111
30192
|
}))
|
|
30112
30193
|
}));
|
|
30113
30194
|
const byName = new Map(cloned.map((c2) => [c2.name, c2]));
|
|
30114
|
-
const isHighTrust = (p) => p === "
|
|
30195
|
+
const isHighTrust = (p) => p === "typed-slot" || p.startsWith("adapter:");
|
|
30115
30196
|
const addAllowed = (slot, child) => {
|
|
30116
30197
|
const set = new Set(slot.allowedComponents ?? []);
|
|
30117
30198
|
set.add(child);
|
|
@@ -30210,7 +30291,6 @@ async function resolveMapping(input) {
|
|
|
30210
30291
|
}
|
|
30211
30292
|
}
|
|
30212
30293
|
}
|
|
30213
|
-
if (input.userMap) collected.push(...groupsToEdges(input.userMap, "user"));
|
|
30214
30294
|
if (input.extraEdges) {
|
|
30215
30295
|
collected.push(...input.extraEdges);
|
|
30216
30296
|
}
|
|
@@ -30258,7 +30338,6 @@ ${f.content}`).join("\n\n");
|
|
|
30258
30338
|
var init_resolve_mapping = __esm({
|
|
30259
30339
|
"packages/experience-design-system-cli/src/analyze/composition/resolve-mapping.ts"() {
|
|
30260
30340
|
"use strict";
|
|
30261
|
-
init_interchange_schema();
|
|
30262
30341
|
init_merge_edges();
|
|
30263
30342
|
init_parse_map_edges();
|
|
30264
30343
|
init_apply_mapping();
|
|
@@ -30267,24 +30346,6 @@ var init_resolve_mapping = __esm({
|
|
|
30267
30346
|
});
|
|
30268
30347
|
|
|
30269
30348
|
// packages/experience-design-system-cli/src/analyze/composition/resolve-mapping-cli.ts
|
|
30270
|
-
import { readFile as readFile18 } from "node:fs/promises";
|
|
30271
|
-
async function loadUserMap(path) {
|
|
30272
|
-
let text;
|
|
30273
|
-
try {
|
|
30274
|
-
text = await readFile18(path, "utf8");
|
|
30275
|
-
} catch {
|
|
30276
|
-
return { ok: false, error: `--composition-map: file not found: ${path}` };
|
|
30277
|
-
}
|
|
30278
|
-
let parsed;
|
|
30279
|
-
try {
|
|
30280
|
-
parsed = JSON.parse(text);
|
|
30281
|
-
} catch {
|
|
30282
|
-
return { ok: false, error: `--composition-map: not valid JSON: ${path}` };
|
|
30283
|
-
}
|
|
30284
|
-
const result = validateInterchangeMap(parsed);
|
|
30285
|
-
if (!result.valid) return { ok: false, error: `--composition-map: ${result.errors.join("; ")}` };
|
|
30286
|
-
return { ok: true, map: result.map };
|
|
30287
|
-
}
|
|
30288
30349
|
function resolveCompositionSources(opts) {
|
|
30289
30350
|
return {
|
|
30290
30351
|
forceAgent: !!opts.compositionRefresh
|
|
@@ -30293,7 +30354,6 @@ function resolveCompositionSources(opts) {
|
|
|
30293
30354
|
var init_resolve_mapping_cli = __esm({
|
|
30294
30355
|
"packages/experience-design-system-cli/src/analyze/composition/resolve-mapping-cli.ts"() {
|
|
30295
30356
|
"use strict";
|
|
30296
|
-
init_interchange_schema();
|
|
30297
30357
|
}
|
|
30298
30358
|
});
|
|
30299
30359
|
|
|
@@ -30455,7 +30515,7 @@ var init_manifest_doc_evidence = __esm({
|
|
|
30455
30515
|
});
|
|
30456
30516
|
|
|
30457
30517
|
// packages/experience-design-system-cli/src/analyze/extract-command.ts
|
|
30458
|
-
import { mkdir as mkdir6, readdir as readdir3, readFile as
|
|
30518
|
+
import { mkdir as mkdir6, readdir as readdir3, readFile as readFile18, stat as stat6 } from "node:fs/promises";
|
|
30459
30519
|
import { isAbsolute as isAbsolute2, join as join25, relative as relative2, resolve as resolve19 } from "node:path";
|
|
30460
30520
|
function isDenylistedNoiseFile(name) {
|
|
30461
30521
|
return DENYLISTED_EXACT_FILE_NAMES.has(name) || DENYLISTED_FILE_NAME_PATTERNS.some((pattern) => pattern.test(name));
|
|
@@ -30522,7 +30582,7 @@ async function readCandidateFiles(components, extraFiles = []) {
|
|
|
30522
30582
|
await Promise.all(
|
|
30523
30583
|
[...paths].map(async (p) => {
|
|
30524
30584
|
try {
|
|
30525
|
-
const content = await
|
|
30585
|
+
const content = await readFile18(p, "utf8");
|
|
30526
30586
|
out.push({ path: p, content });
|
|
30527
30587
|
} catch {
|
|
30528
30588
|
}
|
|
@@ -30535,7 +30595,7 @@ function registerInternalExtractCommand(program) {
|
|
|
30535
30595
|
"--resolve-unreachable <mode>",
|
|
30536
30596
|
"Retry pass for unresolved Svelte Props types: 'auto' (default), 'always', or 'never'",
|
|
30537
30597
|
"auto"
|
|
30538
|
-
).option("--composition-refresh", "Force the mapping agent to run even where deterministic sources answered").option(
|
|
30598
|
+
).option("--composition-refresh", "Force the mapping agent to run even where deterministic sources answered").option(
|
|
30539
30599
|
"--prompt <stage=value>",
|
|
30540
30600
|
"Override a stage prompt (repeatable). value is a file path or literal text, e.g. --prompt composition=./p.md",
|
|
30541
30601
|
(v, acc) => [...acc, v],
|
|
@@ -30651,16 +30711,6 @@ function registerInternalExtractCommand(program) {
|
|
|
30651
30711
|
let validatedComponents = validateExtractedComponents(filteredComponents);
|
|
30652
30712
|
{
|
|
30653
30713
|
const sources = resolveCompositionSources(opts);
|
|
30654
|
-
let userMap;
|
|
30655
|
-
if (opts.compositionMap) {
|
|
30656
|
-
const loaded = await loadUserMap(opts.compositionMap);
|
|
30657
|
-
if (!loaded.ok) {
|
|
30658
|
-
process.stderr.write(`Error: ${loaded.error}
|
|
30659
|
-
`);
|
|
30660
|
-
process.exit(1);
|
|
30661
|
-
}
|
|
30662
|
-
userMap = loaded.map;
|
|
30663
|
-
}
|
|
30664
30714
|
const { overrides: promptOverrides, errors: promptErrors } = parsePromptOverrides(opts.prompt ?? []);
|
|
30665
30715
|
for (const err of promptErrors) {
|
|
30666
30716
|
process.stderr.write(`Error: ${err}
|
|
@@ -30722,7 +30772,6 @@ function registerInternalExtractCommand(program) {
|
|
|
30722
30772
|
});
|
|
30723
30773
|
const result = await resolveMapping({
|
|
30724
30774
|
components: validatedComponents,
|
|
30725
|
-
...userMap ? { userMap } : {},
|
|
30726
30775
|
...extraEdges.length > 0 ? { extraEdges } : {},
|
|
30727
30776
|
forceAgent: sources.forceAgent,
|
|
30728
30777
|
files: promptFiles,
|
|
@@ -30929,7 +30978,7 @@ function resolveBedrockFromAncestors(actionCommand) {
|
|
|
30929
30978
|
return false;
|
|
30930
30979
|
}
|
|
30931
30980
|
function registerImportV2Command(program) {
|
|
30932
|
-
program.command("importv2").description("Launch the v2 import TUI (experience-design-system-cli-v2)").action(async () => {
|
|
30981
|
+
program.command("importv2").description("Launch the v2 import TUI (experience-design-system-cli-v2)").helpOption(false).action(async () => {
|
|
30933
30982
|
const { render: render5 } = await import("ink");
|
|
30934
30983
|
const { createElement: createElement6 } = await import("react");
|
|
30935
30984
|
const { App } = await import("@contentful/experience-design-system-cli-v2/app");
|
|
@@ -30938,7 +30987,7 @@ function registerImportV2Command(program) {
|
|
|
30938
30987
|
});
|
|
30939
30988
|
}
|
|
30940
30989
|
function registerBuildCommand(program) {
|
|
30941
|
-
program.command("build").description("Rebuild from source and re-link exo/experiences binaries to this build").action(async () => {
|
|
30990
|
+
program.command("build").description("Rebuild from source and re-link exo/experiences binaries to this build").helpOption(false).action(async () => {
|
|
30942
30991
|
const pkgRoot = resolve20(dirname13(fileURLToPath4(import.meta.url)), "..", "..");
|
|
30943
30992
|
process.stderr.write("\u2699 Building from source...\n");
|
|
30944
30993
|
const { exitCode } = await runBuild({
|
|
@@ -30948,32 +30997,35 @@ function registerBuildCommand(program) {
|
|
|
30948
30997
|
process.exit(exitCode);
|
|
30949
30998
|
});
|
|
30950
30999
|
}
|
|
31000
|
+
function configureRootHelpOrder(program) {
|
|
31001
|
+
const order = ["build", "help", "import", "apply", "importv2", "setup", "doctor"];
|
|
31002
|
+
const rank2 = new Map(order.map((name, index) => [name, index]));
|
|
31003
|
+
program.configureHelp({
|
|
31004
|
+
visibleCommands(command) {
|
|
31005
|
+
const internals = command;
|
|
31006
|
+
const visible = command.commands.filter((entry) => !entry._hidden);
|
|
31007
|
+
const helpCommand = internals._getHelpCommand?.();
|
|
31008
|
+
if (helpCommand && !helpCommand._hidden) visible.push(helpCommand);
|
|
31009
|
+
if (command !== program) return visible;
|
|
31010
|
+
return visible.sort((a, b) => (rank2.get(a.name()) ?? order.length) - (rank2.get(b.name()) ?? order.length));
|
|
31011
|
+
}
|
|
31012
|
+
});
|
|
31013
|
+
}
|
|
30951
31014
|
function createProgram() {
|
|
30952
31015
|
const program = new Command().name("experience-design-system-cli").description("Static analysis, validation, generation, and import of Contentful design system artifacts").version(pkg3.version, "--version", "Print version number");
|
|
30953
31016
|
registerInternalGenerateCommand(program);
|
|
30954
31017
|
registerInternalExtractCommand(program);
|
|
30955
31018
|
registerPrintCommand(program);
|
|
30956
31019
|
registerMapTokensCommand(program);
|
|
30957
|
-
|
|
31020
|
+
registerBuildCommand(program);
|
|
31021
|
+
program.helpCommand("help [command]", "display help for command");
|
|
30958
31022
|
registerImportCommand(program);
|
|
31023
|
+
registerApplyCommand(program);
|
|
30959
31024
|
registerImportV2Command(program);
|
|
30960
|
-
registerDoctorCommand(program);
|
|
30961
31025
|
registerSetupCommand(program);
|
|
30962
|
-
|
|
30963
|
-
program
|
|
30964
|
-
"--debug",
|
|
30965
|
-
"Write a JSONL trace of every decision to ~/.contentful/experience-design-system-cli/debug/"
|
|
30966
|
-
);
|
|
30967
|
-
program.option("--no-debug", "Force debug logging off (overrides EDSI_DEBUG and persisted setup preference)");
|
|
31026
|
+
registerDoctorCommand(program);
|
|
31027
|
+
configureRootHelpOrder(program);
|
|
30968
31028
|
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
30969
|
-
let debug;
|
|
30970
|
-
for (let c2 = actionCommand; c2; c2 = c2.parent) {
|
|
30971
|
-
const opts = c2.opts();
|
|
30972
|
-
if (opts.debug !== void 0) {
|
|
30973
|
-
debug = opts.debug;
|
|
30974
|
-
break;
|
|
30975
|
-
}
|
|
30976
|
-
}
|
|
30977
31029
|
if (resolveBedrockFromAncestors(actionCommand)) {
|
|
30978
31030
|
process.env.EDS_BEDROCK = "1";
|
|
30979
31031
|
}
|
|
@@ -30983,7 +31035,7 @@ function createProgram() {
|
|
|
30983
31035
|
const { analyticsDisabled } = await readExperiencesCredentials();
|
|
30984
31036
|
setPersistedAnalyticsDisabled(analyticsDisabled ?? false);
|
|
30985
31037
|
noteCommandStart(commandChain);
|
|
30986
|
-
await beginCommand(commandChain, {
|
|
31038
|
+
await beginCommand(commandChain, {});
|
|
30987
31039
|
});
|
|
30988
31040
|
program.hook("postAction", async () => {
|
|
30989
31041
|
await completeActiveCommand();
|
|
@@ -4,12 +4,12 @@ export declare const MODEL_DESCRIPTION = "Model to use (defaults to a lightweigh
|
|
|
4
4
|
export interface AgentModelOptionsConfig {
|
|
5
5
|
agentDescription?: string;
|
|
6
6
|
includeModel?: boolean;
|
|
7
|
+
includeBedrock?: boolean;
|
|
7
8
|
modelDescription?: string;
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
|
-
* Register --agent
|
|
11
|
-
* command.
|
|
12
|
-
*
|
|
13
|
-
* and is always registered alongside --agent.
|
|
11
|
+
* Register --agent plus optional --model and --bedrock flags with a Commander
|
|
12
|
+
* command. The optional flags can be omitted for commands with a narrower
|
|
13
|
+
* public surface.
|
|
14
14
|
*/
|
|
15
15
|
export declare function addAgentModelOptions(cmd: Command, config?: AgentModelOptionsConfig): Command;
|
|
@@ -29,9 +29,8 @@ export declare function __resetDebugLoggerForTest(): void;
|
|
|
29
29
|
* Resolve effective debug-mode setting from three sources.
|
|
30
30
|
*
|
|
31
31
|
* Precedence (highest first):
|
|
32
|
-
* 1.
|
|
33
|
-
* 2. `
|
|
34
|
-
* 3. Persisted `debug` field in credentials.json
|
|
32
|
+
* 1. `EDSI_DEBUG` env var (truthy: 1, true, yes, on)
|
|
33
|
+
* 2. Persisted `debug` field in credentials.json
|
|
35
34
|
* 4. Default: OFF
|
|
36
35
|
*/
|
|
37
36
|
export declare function resolveDebugMode(opts: {
|
package/dist/src/program.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function runBuild(opts: {
|
|
|
17
17
|
}>;
|
|
18
18
|
/**
|
|
19
19
|
* Walks `actionCommand` and its ancestors for a truthy `--bedrock`. --bedrock
|
|
20
|
-
* is registered per-subcommand
|
|
20
|
+
* is registered per-subcommand, so a
|
|
21
21
|
* root-level or subcommand-level setting can each carry it.
|
|
22
22
|
*/
|
|
23
23
|
export declare function resolveBedrockFromAncestors(actionCommand: Command): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experience-design-system-cli",
|
|
3
|
-
"version": "2.34.5-dev-build-
|
|
3
|
+
"version": "2.34.5-dev-build-ea694b2.0",
|
|
4
4
|
"description": "Contentful Experiences design system import CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"svelte": "^5.56.4",
|
|
42
42
|
"ts-morph": "^27.0.2",
|
|
43
43
|
"typescript": "^5.9.3",
|
|
44
|
-
"@contentful/experience-design-system-cli-v2": "2.34.5-dev-build-
|
|
45
|
-
"@contentful/experience-design-system-types": "2.34.5-dev-build-
|
|
44
|
+
"@contentful/experience-design-system-cli-v2": "2.34.5-dev-build-ea694b2.0",
|
|
45
|
+
"@contentful/experience-design-system-types": "2.34.5-dev-build-ea694b2.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@tsconfig/node24": "^24.0.4",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"ink-testing-library": "^4.0.0",
|
|
55
55
|
"typescript-eslint": "^8.67.0",
|
|
56
56
|
"vitest": "^4.0.16",
|
|
57
|
-
"@contentful/experience-design-system-
|
|
58
|
-
"@contentful/experience-design-system-
|
|
59
|
-
"@contentful/experience-design-system-
|
|
57
|
+
"@contentful/experience-design-system-extraction": "2.34.5-dev-build-ea694b2.0",
|
|
58
|
+
"@contentful/experience-design-system-generation": "2.34.5-dev-build-ea694b2.0",
|
|
59
|
+
"@contentful/experience-design-system-client": "2.34.5-dev-build-ea694b2.0"
|
|
60
60
|
},
|
|
61
61
|
"repository": {
|
|
62
62
|
"type": "git",
|