@contentful/experience-design-system-cli 2.37.1-dev-build-a3cb19fa.0 → 2.37.1-dev-build-8757f66c.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.js CHANGED
@@ -1,3 +1,884 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __esm = (fn, res) => function __init() {
3
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
+ };
5
+
6
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/constants/vocabularies.js
7
+ var CDF_PROPERTY_TYPES, CDF_PROPERTY_CATEGORIES;
8
+ var init_vocabularies = __esm({
9
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/constants/vocabularies.js"() {
10
+ "use strict";
11
+ CDF_PROPERTY_TYPES = [
12
+ "string",
13
+ "richtext",
14
+ "number",
15
+ "media",
16
+ "link",
17
+ "enum",
18
+ "token",
19
+ "boolean"
20
+ ];
21
+ CDF_PROPERTY_CATEGORIES = ["content", "design", "state", "unattached"];
22
+ }
23
+ });
24
+
25
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/constants/token-types.js
26
+ var DESIGN_TOKEN_TYPES;
27
+ var init_token_types = __esm({
28
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/constants/token-types.js"() {
29
+ "use strict";
30
+ DESIGN_TOKEN_TYPES = [
31
+ "color",
32
+ "dimension",
33
+ "fontFamily",
34
+ "fontWeight",
35
+ "duration",
36
+ "cubicBezier",
37
+ "number",
38
+ "strokeStyle",
39
+ "border",
40
+ "transition",
41
+ "shadow",
42
+ "gradient",
43
+ "typography"
44
+ ];
45
+ }
46
+ });
47
+
48
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/constants/schema.js
49
+ var CDF_SCHEMA_URL, cdfJsonSchema;
50
+ var init_schema = __esm({
51
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/constants/schema.js"() {
52
+ "use strict";
53
+ init_vocabularies();
54
+ init_token_types();
55
+ CDF_SCHEMA_URL = "https://contentful.com/schemas/cdf";
56
+ cdfJsonSchema = {
57
+ $schema: "http://json-schema.org/draft-07/schema#",
58
+ $id: CDF_SCHEMA_URL,
59
+ title: "CDF Component + Design Token Definition Format",
60
+ type: "object",
61
+ required: ["$schema"],
62
+ properties: {
63
+ $schema: { type: "string", const: CDF_SCHEMA_URL }
64
+ },
65
+ additionalProperties: { $ref: "#/definitions/groupOrEntry" },
66
+ definitions: {
67
+ groupOrEntry: {
68
+ oneOf: [{ $ref: "#/definitions/component" }, { $ref: "#/definitions/token" }, { $ref: "#/definitions/group" }]
69
+ },
70
+ component: {
71
+ type: "object",
72
+ required: ["$type", "$properties"],
73
+ properties: {
74
+ $type: { type: "string", const: "component" },
75
+ $description: { type: "string" },
76
+ $properties: {
77
+ type: "object",
78
+ additionalProperties: { $ref: "#/definitions/property" }
79
+ },
80
+ $slots: {
81
+ type: "object",
82
+ additionalProperties: { $ref: "#/definitions/slot" }
83
+ }
84
+ },
85
+ additionalProperties: false
86
+ },
87
+ property: {
88
+ type: "object",
89
+ required: ["$type", "$category"],
90
+ properties: {
91
+ $type: { type: "string", enum: [...CDF_PROPERTY_TYPES] },
92
+ $category: { type: "string", enum: [...CDF_PROPERTY_CATEGORIES] },
93
+ $description: { type: "string" },
94
+ $required: { type: "boolean" },
95
+ $default: {},
96
+ $values: { type: "array", items: { type: "string" } },
97
+ "$token.kind": { type: "string" },
98
+ "$token.allowed": { type: "array", items: { type: "string" } }
99
+ },
100
+ additionalProperties: false
101
+ },
102
+ slot: {
103
+ type: "object",
104
+ properties: {
105
+ $description: { type: "string" },
106
+ $required: { type: "boolean" },
107
+ $allowedComponents: { type: "array", items: { type: "string" } }
108
+ },
109
+ additionalProperties: false
110
+ },
111
+ token: {
112
+ type: "object",
113
+ required: ["$type", "$value"],
114
+ properties: {
115
+ $type: { type: "string", enum: [...DESIGN_TOKEN_TYPES] },
116
+ $value: {},
117
+ $description: { type: "string" }
118
+ },
119
+ additionalProperties: false
120
+ },
121
+ group: {
122
+ type: "object",
123
+ properties: { $description: { type: "string" } },
124
+ additionalProperties: { $ref: "#/definitions/groupOrEntry" }
125
+ }
126
+ }
127
+ };
128
+ }
129
+ });
130
+
131
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/helpers/validate.js
132
+ import { Ajv } from "ajv";
133
+ var ajv, validate, TOKEN_TYPE_SET;
134
+ var init_validate = __esm({
135
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/helpers/validate.js"() {
136
+ "use strict";
137
+ init_schema();
138
+ init_token_types();
139
+ ajv = new Ajv({ allErrors: true });
140
+ validate = ajv.compile(cdfJsonSchema);
141
+ TOKEN_TYPE_SET = new Set(DESIGN_TOKEN_TYPES);
142
+ }
143
+ });
144
+
145
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/types/agent-name.js
146
+ var init_agent_name = __esm({
147
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/types/agent-name.js"() {
148
+ "use strict";
149
+ }
150
+ });
151
+
152
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/types/agent-run.js
153
+ var init_agent_run = __esm({
154
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/types/agent-run.js"() {
155
+ "use strict";
156
+ }
157
+ });
158
+
159
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/types/invoker.js
160
+ var init_invoker = __esm({
161
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/types/invoker.js"() {
162
+ "use strict";
163
+ }
164
+ });
165
+
166
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/types/prompts.js
167
+ var init_prompts = __esm({
168
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/types/prompts.js"() {
169
+ "use strict";
170
+ }
171
+ });
172
+
173
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/types/tool-calls.js
174
+ var init_tool_calls = __esm({
175
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/types/tool-calls.js"() {
176
+ "use strict";
177
+ }
178
+ });
179
+
180
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/types/index.js
181
+ var init_types = __esm({
182
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/types/index.js"() {
183
+ "use strict";
184
+ init_agent_name();
185
+ init_agent_run();
186
+ init_invoker();
187
+ init_prompts();
188
+ init_tool_calls();
189
+ }
190
+ });
191
+
192
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/constants/models.js
193
+ var init_models = __esm({
194
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/constants/models.js"() {
195
+ "use strict";
196
+ }
197
+ });
198
+
199
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/is-agent-name.js
200
+ var init_is_agent_name = __esm({
201
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/is-agent-name.js"() {
202
+ "use strict";
203
+ init_agent_name();
204
+ }
205
+ });
206
+
207
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/constants/binaries.js
208
+ var init_binaries = __esm({
209
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/constants/binaries.js"() {
210
+ "use strict";
211
+ }
212
+ });
213
+
214
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/resolve-binary.js
215
+ var init_resolve_binary = __esm({
216
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/resolve-binary.js"() {
217
+ "use strict";
218
+ init_binaries();
219
+ }
220
+ });
221
+
222
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/constants/bedrock.js
223
+ var init_bedrock = __esm({
224
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/constants/bedrock.js"() {
225
+ "use strict";
226
+ }
227
+ });
228
+
229
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/bedrock/with-bedrock-provider-prefix.js
230
+ var init_with_bedrock_provider_prefix = __esm({
231
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/bedrock/with-bedrock-provider-prefix.js"() {
232
+ "use strict";
233
+ }
234
+ });
235
+
236
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/resolve-agent-model.js
237
+ var init_resolve_agent_model = __esm({
238
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/resolve-agent-model.js"() {
239
+ "use strict";
240
+ init_bedrock();
241
+ init_models();
242
+ init_with_bedrock_provider_prefix();
243
+ }
244
+ });
245
+
246
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/bedrock/agent-supports-bedrock.js
247
+ var init_agent_supports_bedrock = __esm({
248
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/bedrock/agent-supports-bedrock.js"() {
249
+ "use strict";
250
+ init_bedrock();
251
+ }
252
+ });
253
+
254
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-args/build-claude-args.js
255
+ var init_build_claude_args = __esm({
256
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-args/build-claude-args.js"() {
257
+ "use strict";
258
+ }
259
+ });
260
+
261
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/bedrock/codex-bedrock-config-args.js
262
+ var init_codex_bedrock_config_args = __esm({
263
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/bedrock/codex-bedrock-config-args.js"() {
264
+ "use strict";
265
+ init_bedrock();
266
+ }
267
+ });
268
+
269
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-args/build-codex-args.js
270
+ var init_build_codex_args = __esm({
271
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-args/build-codex-args.js"() {
272
+ "use strict";
273
+ init_codex_bedrock_config_args();
274
+ }
275
+ });
276
+
277
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-args/build-copilot-args.js
278
+ var init_build_copilot_args = __esm({
279
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-args/build-copilot-args.js"() {
280
+ "use strict";
281
+ init_resolve_agent_model();
282
+ }
283
+ });
284
+
285
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-args/build-cursor-args.js
286
+ var init_build_cursor_args = __esm({
287
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-args/build-cursor-args.js"() {
288
+ "use strict";
289
+ }
290
+ });
291
+
292
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-args/build-opencode-args.js
293
+ var init_build_opencode_args = __esm({
294
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-args/build-opencode-args.js"() {
295
+ "use strict";
296
+ }
297
+ });
298
+
299
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-agent-args.js
300
+ var init_build_agent_args = __esm({
301
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/build-agent-args.js"() {
302
+ "use strict";
303
+ init_build_claude_args();
304
+ init_build_codex_args();
305
+ init_build_copilot_args();
306
+ init_build_cursor_args();
307
+ init_build_opencode_args();
308
+ init_resolve_agent_model();
309
+ }
310
+ });
311
+
312
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/metadata/describe-agent-failure.js
313
+ var init_describe_agent_failure = __esm({
314
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/metadata/describe-agent-failure.js"() {
315
+ "use strict";
316
+ }
317
+ });
318
+
319
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/metadata/extract-sentinel-output.js
320
+ var init_extract_sentinel_output = __esm({
321
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/metadata/extract-sentinel-output.js"() {
322
+ "use strict";
323
+ }
324
+ });
325
+
326
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/metadata/format-generate-progress-line.js
327
+ var init_format_generate_progress_line = __esm({
328
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/metadata/format-generate-progress-line.js"() {
329
+ "use strict";
330
+ }
331
+ });
332
+
333
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/parse-agent-model.js
334
+ var init_parse_agent_model = __esm({
335
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/parse-agent-model.js"() {
336
+ "use strict";
337
+ }
338
+ });
339
+
340
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/resolve-agent.js
341
+ var init_resolve_agent = __esm({
342
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/resolve-agent.js"() {
343
+ "use strict";
344
+ }
345
+ });
346
+
347
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/resolve-model.js
348
+ var init_resolve_model = __esm({
349
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/resolve-model.js"() {
350
+ "use strict";
351
+ }
352
+ });
353
+
354
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/prompt-overrides/looks-like-path.js
355
+ var init_looks_like_path = __esm({
356
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/prompt-overrides/looks-like-path.js"() {
357
+ "use strict";
358
+ }
359
+ });
360
+
361
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/prompt-overrides/parse-prompt-overrides.js
362
+ var init_parse_prompt_overrides = __esm({
363
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/prompt-overrides/parse-prompt-overrides.js"() {
364
+ "use strict";
365
+ init_looks_like_path();
366
+ }
367
+ });
368
+
369
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/prompt-overrides/resolve-prompt-override.js
370
+ var init_resolve_prompt_override = __esm({
371
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/prompt-overrides/resolve-prompt-override.js"() {
372
+ "use strict";
373
+ }
374
+ });
375
+
376
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/metadata/build-user-agent.js
377
+ var init_build_user_agent = __esm({
378
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/metadata/build-user-agent.js"() {
379
+ "use strict";
380
+ }
381
+ });
382
+
383
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/constants/tool-names.js
384
+ var init_tool_names = __esm({
385
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/constants/tool-names.js"() {
386
+ "use strict";
387
+ }
388
+ });
389
+
390
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/helpers/find-json-object-end.js
391
+ var init_find_json_object_end = __esm({
392
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/helpers/find-json-object-end.js"() {
393
+ "use strict";
394
+ }
395
+ });
396
+
397
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/helpers/read-tool-call-objects.js
398
+ var init_read_tool_call_objects = __esm({
399
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/helpers/read-tool-call-objects.js"() {
400
+ "use strict";
401
+ init_find_json_object_end();
402
+ }
403
+ });
404
+
405
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/parse-select-tool-calls.js
406
+ var init_parse_select_tool_calls = __esm({
407
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/parse-select-tool-calls.js"() {
408
+ "use strict";
409
+ init_tool_names();
410
+ init_read_tool_call_objects();
411
+ }
412
+ });
413
+
414
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/parse-tool-calls.js
415
+ var init_parse_tool_calls = __esm({
416
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/parse-tool-calls.js"() {
417
+ "use strict";
418
+ init_tool_names();
419
+ init_read_tool_call_objects();
420
+ }
421
+ });
422
+
423
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/parse-token-tool-calls.js
424
+ var init_parse_token_tool_calls = __esm({
425
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/parse-token-tool-calls.js"() {
426
+ "use strict";
427
+ init_tool_names();
428
+ init_read_tool_call_objects();
429
+ }
430
+ });
431
+
432
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/helpers/is-string-array.js
433
+ var init_is_string_array = __esm({
434
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/helpers/is-string-array.js"() {
435
+ "use strict";
436
+ }
437
+ });
438
+
439
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/parse-map-token-prop-tool-calls.js
440
+ var init_parse_map_token_prop_tool_calls = __esm({
441
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/parsers/parse-map-token-prop-tool-calls.js"() {
442
+ "use strict";
443
+ init_is_string_array();
444
+ init_read_tool_call_objects();
445
+ }
446
+ });
447
+
448
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/services/run-agent.js
449
+ var init_run_agent = __esm({
450
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/services/run-agent.js"() {
451
+ "use strict";
452
+ init_bedrock();
453
+ init_build_agent_args();
454
+ init_resolve_binary();
455
+ }
456
+ });
457
+
458
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/services/check-agent-auth.js
459
+ var init_check_agent_auth = __esm({
460
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/services/check-agent-auth.js"() {
461
+ "use strict";
462
+ init_resolve_binary();
463
+ }
464
+ });
465
+
466
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/output-formatter/colors.js
467
+ function detectColorSupport() {
468
+ if (process.env["NO_COLOR"] !== void 0)
469
+ return false;
470
+ if (process.env["FORCE_COLOR"] !== void 0)
471
+ return true;
472
+ return process.stderr.isTTY === true;
473
+ }
474
+ var colorsEnabled, wrap, ansi;
475
+ var init_colors = __esm({
476
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/output-formatter/colors.js"() {
477
+ "use strict";
478
+ colorsEnabled = detectColorSupport();
479
+ wrap = (code) => (text) => colorsEnabled ? `\x1B[${code}m${text}\x1B[0m` : text;
480
+ ansi = {
481
+ green: wrap(32),
482
+ red: wrap(31),
483
+ cyan: wrap(36),
484
+ yellow: wrap(33),
485
+ dim: wrap(2),
486
+ bold: wrap(1)
487
+ };
488
+ }
489
+ });
490
+
491
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/output-formatter/format-tool-call.js
492
+ var init_format_tool_call = __esm({
493
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/output-formatter/format-tool-call.js"() {
494
+ "use strict";
495
+ init_colors();
496
+ }
497
+ });
498
+
499
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/output-formatter/output-formatter.js
500
+ var init_output_formatter = __esm({
501
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/output-formatter/output-formatter.js"() {
502
+ "use strict";
503
+ init_colors();
504
+ init_format_tool_call();
505
+ }
506
+ });
507
+
508
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/output-formatter/index.js
509
+ var init_output_formatter2 = __esm({
510
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/output-formatter/index.js"() {
511
+ "use strict";
512
+ init_output_formatter();
513
+ init_colors();
514
+ init_format_tool_call();
515
+ }
516
+ });
517
+
518
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/services/invoke-agent-with-output.js
519
+ var init_invoke_agent_with_output = __esm({
520
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/services/invoke-agent-with-output.js"() {
521
+ "use strict";
522
+ init_output_formatter2();
523
+ }
524
+ });
525
+
526
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/invoker/create-local-cli-agent-invoker.js
527
+ var init_create_local_cli_agent_invoker = __esm({
528
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/invoker/create-local-cli-agent-invoker.js"() {
529
+ "use strict";
530
+ init_check_agent_auth();
531
+ init_run_agent();
532
+ }
533
+ });
534
+
535
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/candidate-file.js
536
+ var init_candidate_file = __esm({
537
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/candidate-file.js"() {
538
+ "use strict";
539
+ }
540
+ });
541
+
542
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/types/types.js
543
+ import * as z from "zod/mini";
544
+ var CDFPropertySchema, CDFSlotSchema, CDFComponentSchema, CDFTokenSchema;
545
+ var init_types2 = __esm({
546
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/types/types.js"() {
547
+ "use strict";
548
+ init_vocabularies();
549
+ init_token_types();
550
+ CDFPropertySchema = z.strictObject({
551
+ $type: z.enum(CDF_PROPERTY_TYPES),
552
+ $category: z.enum(CDF_PROPERTY_CATEGORIES),
553
+ $description: z.optional(z.string()),
554
+ $required: z.optional(z.boolean()),
555
+ $default: z.optional(z.any()),
556
+ $values: z.optional(z.array(z.string())),
557
+ "$token.kind": z.optional(z.string()),
558
+ "$token.allowed": z.optional(z.array(z.string()))
559
+ });
560
+ CDFSlotSchema = z.strictObject({
561
+ $description: z.optional(z.string()),
562
+ $allowedComponents: z.optional(z.array(z.string())),
563
+ $required: z.optional(z.boolean())
564
+ });
565
+ CDFComponentSchema = z.strictObject({
566
+ $type: z.literal("component"),
567
+ $description: z.optional(z.string()),
568
+ $properties: z.record(z.string(), CDFPropertySchema),
569
+ $slots: z.optional(z.record(z.string(), CDFSlotSchema))
570
+ });
571
+ CDFTokenSchema = z.strictObject({
572
+ $type: z.enum(DESIGN_TOKEN_TYPES),
573
+ $value: z.unknown(),
574
+ $description: z.optional(z.string())
575
+ });
576
+ }
577
+ });
578
+
579
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/types/index.js
580
+ var init_types3 = __esm({
581
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/types/index.js"() {
582
+ "use strict";
583
+ init_types2();
584
+ }
585
+ });
586
+
587
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/constants/index.js
588
+ var init_constants = __esm({
589
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/constants/index.js"() {
590
+ "use strict";
591
+ init_schema();
592
+ init_vocabularies();
593
+ }
594
+ });
595
+
596
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/helpers/build.js
597
+ var init_build = __esm({
598
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/helpers/build.js"() {
599
+ "use strict";
600
+ init_schema();
601
+ }
602
+ });
603
+
604
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/helpers/index.js
605
+ var init_helpers = __esm({
606
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/helpers/index.js"() {
607
+ "use strict";
608
+ init_build();
609
+ init_validate();
610
+ }
611
+ });
612
+
613
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/index.js
614
+ var init_cdf = __esm({
615
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/index.js"() {
616
+ "use strict";
617
+ init_types3();
618
+ init_constants();
619
+ init_helpers();
620
+ }
621
+ });
622
+
623
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/types/types.js
624
+ import * as z2 from "zod/mini";
625
+ var DTCGTokenSchema;
626
+ var init_types4 = __esm({
627
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/types/types.js"() {
628
+ "use strict";
629
+ init_token_types();
630
+ DTCGTokenSchema = z2.strictObject({
631
+ path: z2.string(),
632
+ $type: z2.enum(DESIGN_TOKEN_TYPES),
633
+ $value: z2.unknown(),
634
+ $description: z2.optional(z2.string())
635
+ });
636
+ }
637
+ });
638
+
639
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/types/index.js
640
+ var init_types5 = __esm({
641
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/types/index.js"() {
642
+ "use strict";
643
+ init_types4();
644
+ }
645
+ });
646
+
647
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/constants/index.js
648
+ var init_constants2 = __esm({
649
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/constants/index.js"() {
650
+ "use strict";
651
+ init_token_types();
652
+ }
653
+ });
654
+
655
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/helpers/flatten.js
656
+ var init_flatten = __esm({
657
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/helpers/flatten.js"() {
658
+ "use strict";
659
+ }
660
+ });
661
+
662
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/helpers/validate.js
663
+ var TOKEN_TYPE_SET2;
664
+ var init_validate2 = __esm({
665
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/helpers/validate.js"() {
666
+ "use strict";
667
+ init_token_types();
668
+ init_flatten();
669
+ TOKEN_TYPE_SET2 = new Set(DESIGN_TOKEN_TYPES);
670
+ }
671
+ });
672
+
673
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/helpers/index.js
674
+ var init_helpers2 = __esm({
675
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/helpers/index.js"() {
676
+ "use strict";
677
+ init_flatten();
678
+ init_validate2();
679
+ }
680
+ });
681
+
682
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/index.js
683
+ var init_dtcg = __esm({
684
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/index.js"() {
685
+ "use strict";
686
+ init_types5();
687
+ init_constants2();
688
+ init_helpers2();
689
+ }
690
+ });
691
+
692
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/sources-api/types/apply.js
693
+ var init_apply = __esm({
694
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/sources-api/types/apply.js"() {
695
+ "use strict";
696
+ }
697
+ });
698
+
699
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/sources-api/types/preview.js
700
+ var init_preview = __esm({
701
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/sources-api/types/preview.js"() {
702
+ "use strict";
703
+ }
704
+ });
705
+
706
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/sources-api/types/index.js
707
+ var init_types6 = __esm({
708
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/sources-api/types/index.js"() {
709
+ "use strict";
710
+ init_apply();
711
+ init_preview();
712
+ }
713
+ });
714
+
715
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/sources-api/index.js
716
+ var init_sources_api = __esm({
717
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/sources-api/index.js"() {
718
+ "use strict";
719
+ init_types6();
720
+ }
721
+ });
722
+
723
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/index.js
724
+ var init_shared = __esm({
725
+ "packages/experience-design-system-backend-pipeline/dist/src/steps/shared/index.js"() {
726
+ "use strict";
727
+ init_candidate_file();
728
+ init_cdf();
729
+ init_dtcg();
730
+ init_sources_api();
731
+ }
732
+ });
733
+
734
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/helpers/filter-design-token-props.js
735
+ var init_filter_design_token_props = __esm({
736
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/helpers/filter-design-token-props.js"() {
737
+ "use strict";
738
+ }
739
+ });
740
+
741
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/helpers/format-token-candidates.js
742
+ var init_format_token_candidates = __esm({
743
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/helpers/format-token-candidates.js"() {
744
+ "use strict";
745
+ }
746
+ });
747
+
748
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/helpers/infer-fence-lang.js
749
+ var init_infer_fence_lang = __esm({
750
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/helpers/infer-fence-lang.js"() {
751
+ "use strict";
752
+ }
753
+ });
754
+
755
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/helpers/build-input-sections.js
756
+ var init_build_input_sections = __esm({
757
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/helpers/build-input-sections.js"() {
758
+ "use strict";
759
+ init_shared();
760
+ init_filter_design_token_props();
761
+ init_format_token_candidates();
762
+ init_infer_fence_lang();
763
+ }
764
+ });
765
+
766
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/constants/skill-files.js
767
+ var init_skill_files = __esm({
768
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/constants/skill-files.js"() {
769
+ "use strict";
770
+ }
771
+ });
772
+
773
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/resolve-skill-path.js
774
+ var init_resolve_skill_path = __esm({
775
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/resolve-skill-path.js"() {
776
+ "use strict";
777
+ init_skill_files();
778
+ }
779
+ });
780
+
781
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/helpers/read-skill-file.js
782
+ var init_read_skill_file = __esm({
783
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/helpers/read-skill-file.js"() {
784
+ "use strict";
785
+ init_resolve_skill_path();
786
+ }
787
+ });
788
+
789
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/preambles/build-components-preamble.js
790
+ var init_build_components_preamble = __esm({
791
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/preambles/build-components-preamble.js"() {
792
+ "use strict";
793
+ }
794
+ });
795
+
796
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/preambles/build-map-tokens-preamble.js
797
+ var init_build_map_tokens_preamble = __esm({
798
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/preambles/build-map-tokens-preamble.js"() {
799
+ "use strict";
800
+ }
801
+ });
802
+
803
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/preambles/build-select-preamble.js
804
+ var init_build_select_preamble = __esm({
805
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/preambles/build-select-preamble.js"() {
806
+ "use strict";
807
+ }
808
+ });
809
+
810
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/preambles/build-tokens-preamble.js
811
+ var init_build_tokens_preamble = __esm({
812
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/preambles/build-tokens-preamble.js"() {
813
+ "use strict";
814
+ }
815
+ });
816
+
817
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/build-prompt.js
818
+ var init_build_prompt = __esm({
819
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/build-prompt.js"() {
820
+ "use strict";
821
+ init_build_input_sections();
822
+ init_read_skill_file();
823
+ init_build_components_preamble();
824
+ init_build_map_tokens_preamble();
825
+ init_build_select_preamble();
826
+ init_build_tokens_preamble();
827
+ }
828
+ });
829
+
830
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/format-custom-prompt-banner.js
831
+ var init_format_custom_prompt_banner = __esm({
832
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/prompts/format-custom-prompt-banner.js"() {
833
+ "use strict";
834
+ }
835
+ });
836
+
837
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/index.js
838
+ var init_agents = __esm({
839
+ "packages/experience-design-system-backend-pipeline/dist/src/agents/index.js"() {
840
+ "use strict";
841
+ init_types();
842
+ init_models();
843
+ init_is_agent_name();
844
+ init_resolve_binary();
845
+ init_resolve_agent_model();
846
+ init_agent_supports_bedrock();
847
+ init_build_agent_args();
848
+ init_describe_agent_failure();
849
+ init_extract_sentinel_output();
850
+ init_format_generate_progress_line();
851
+ init_parse_agent_model();
852
+ init_resolve_agent();
853
+ init_resolve_model();
854
+ init_looks_like_path();
855
+ init_parse_prompt_overrides();
856
+ init_resolve_prompt_override();
857
+ init_build_user_agent();
858
+ init_parse_select_tool_calls();
859
+ init_parse_tool_calls();
860
+ init_parse_token_tool_calls();
861
+ init_parse_map_token_prop_tool_calls();
862
+ init_parse_map_token_prop_tool_calls();
863
+ init_run_agent();
864
+ init_check_agent_auth();
865
+ init_invoke_agent_with_output();
866
+ init_output_formatter2();
867
+ init_create_local_cli_agent_invoker();
868
+ init_build_prompt();
869
+ init_resolve_skill_path();
870
+ init_format_custom_prompt_banner();
871
+ }
872
+ });
873
+
874
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/helpers/cache-keys.js
875
+ var init_cache_keys = __esm({
876
+ "packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/helpers/cache-keys.js"() {
877
+ "use strict";
878
+ init_agents();
879
+ }
880
+ });
881
+
1
882
  // packages/experience-design-system-cli/app.tsx
2
883
  import { useEffect as useEffect9, useState as useState13 } from "react";
3
884
 
@@ -283,8 +1164,8 @@ function WelcomeScreen({ onContinue, onQuit, initialPath = "" }) {
283
1164
  const [projectPath, setProjectPath] = useState3(initialPath);
284
1165
  useWelcomeControls(onQuit);
285
1166
  const submit = (value) => {
286
- const path = toProjectPath(value);
287
- if (path) onContinue(path);
1167
+ const path5 = toProjectPath(value);
1168
+ if (path5) onContinue(path5);
288
1169
  };
289
1170
  return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
290
1171
  /* @__PURE__ */ jsx4(Text4, { bold: true, color: PALETTE.success, children: "\u{1F44B} Hey! Let's import your design system into Contentful." }),
@@ -314,311 +1195,1836 @@ function WelcomeScreen({ onContinue, onQuit, initialPath = "" }) {
314
1195
  ] });
315
1196
  }
316
1197
 
317
- // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/screen.tsx
318
- import { useState as useState4 } from "react";
319
- import { Box as Box4, Text as Text5 } from "ink";
320
- import TextInput2 from "ink-text-input";
1198
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/screen.tsx
1199
+ import { useState as useState4 } from "react";
1200
+ import { Box as Box4, Text as Text5 } from "ink";
1201
+ import TextInput2 from "ink-text-input";
1202
+
1203
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/controls.ts
1204
+ import { useInput as useInput4 } from "ink";
1205
+
1206
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/logic.ts
1207
+ function shouldGoBack(key) {
1208
+ return key.escape;
1209
+ }
1210
+ function toTokenPath(value) {
1211
+ const tokenPath = value.trim();
1212
+ return tokenPath === "" ? null : tokenPath;
1213
+ }
1214
+
1215
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/controls.ts
1216
+ var TOKEN_INPUT_CONTROLS = [
1217
+ { keys: "Enter", label: "Continue" },
1218
+ { keys: "Esc", label: "Back" }
1219
+ ];
1220
+ function useTokenInputControls(onBack) {
1221
+ useInput4((_input, key) => {
1222
+ if (shouldGoBack(key)) onBack();
1223
+ });
1224
+ }
1225
+
1226
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/validate-path.ts
1227
+ import { statSync } from "node:fs";
1228
+
1229
+ // packages/experience-design-system-cli/src/tui/import/resolve-user-path.ts
1230
+ import { homedir } from "node:os";
1231
+ import { resolve } from "node:path";
1232
+ function stripQuotes(value) {
1233
+ const quoted = value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'");
1234
+ return value.length >= 2 && quoted ? value.slice(1, -1) : value;
1235
+ }
1236
+ function expandHome(value) {
1237
+ return value === "~" || value.startsWith("~/") || value.startsWith("~\\") ? homedir() + value.slice(1) : value;
1238
+ }
1239
+ function resolveUserPath(raw) {
1240
+ return resolve(expandHome(stripQuotes(raw.trim())));
1241
+ }
1242
+
1243
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/validate-path.ts
1244
+ function validateTokenPath(rawPath) {
1245
+ const path5 = resolveUserPath(rawPath);
1246
+ let stats;
1247
+ try {
1248
+ stats = statSync(path5);
1249
+ } catch {
1250
+ return { ok: false, error: `Path not found: ${path5}`, resolvedPath: path5 };
1251
+ }
1252
+ if (stats.isDirectory()) {
1253
+ return {
1254
+ ok: false,
1255
+ error: "That's a directory \u2014 provide a path to a token file (e.g. tokens.json), not a folder.",
1256
+ resolvedPath: path5
1257
+ };
1258
+ }
1259
+ if (!stats.isFile()) {
1260
+ return { ok: false, error: `Not a regular file: ${path5}`, resolvedPath: path5 };
1261
+ }
1262
+ return { ok: true, path: path5 };
1263
+ }
1264
+
1265
+ // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/screen.tsx
1266
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1267
+ function TokenInputScreen({ onConfirm, onBack, initialPath = "" }) {
1268
+ const [tokenPath, setTokenPath] = useState4(initialPath);
1269
+ const [failure, setFailure] = useState4(null);
1270
+ useTokenInputControls(onBack);
1271
+ const change = (value) => {
1272
+ setTokenPath(value);
1273
+ setFailure(null);
1274
+ };
1275
+ const submit = (value) => {
1276
+ const rawPath = toTokenPath(value);
1277
+ if (!rawPath) {
1278
+ setFailure({ error: "Enter the path to your token file." });
1279
+ return;
1280
+ }
1281
+ const check = validateTokenPath(rawPath);
1282
+ if (check.ok) onConfirm(check.path);
1283
+ else setFailure({ error: check.error, resolvedPath: check.resolvedPath });
1284
+ };
1285
+ return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
1286
+ /* @__PURE__ */ jsx5(Text5, { bold: true, children: "Design tokens" }),
1287
+ /* @__PURE__ */ jsx5(Text5, { color: PALETTE.muted, children: "Point me to your raw token file (e.g. ~/design-tokens/tokens.json). You can use ~, relative, or absolute paths. Claude will map it to Design Token Group Format (DTCG)." }),
1288
+ /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
1289
+ /* @__PURE__ */ jsxs4(Box4, { gap: 1, children: [
1290
+ /* @__PURE__ */ jsx5(Text5, { color: PALETTE.accent, children: "?" }),
1291
+ /* @__PURE__ */ jsx5(Text5, { children: "Token path:" }),
1292
+ /* @__PURE__ */ jsx5(TextInput2, { value: tokenPath, onChange: change, onSubmit: submit })
1293
+ ] }),
1294
+ failure && /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
1295
+ /* @__PURE__ */ jsxs4(Text5, { color: PALETTE.error, children: [
1296
+ "\u2717 ",
1297
+ failure.error
1298
+ ] }),
1299
+ failure.resolvedPath && /* @__PURE__ */ jsxs4(Text5, { color: PALETTE.muted, children: [
1300
+ " Resolved to: ",
1301
+ failure.resolvedPath
1302
+ ] })
1303
+ ] })
1304
+ ] }),
1305
+ /* @__PURE__ */ jsx5(Box4, { marginTop: 1, gap: 3, children: TOKEN_INPUT_CONTROLS.map((control) => /* @__PURE__ */ jsxs4(Text5, { children: [
1306
+ "[",
1307
+ control.keys,
1308
+ "] ",
1309
+ control.label
1310
+ ] }, control.keys)) })
1311
+ ] });
1312
+ }
1313
+
1314
+ // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/screen.tsx
1315
+ import { useEffect as useEffect3, useMemo, useState as useState5 } from "react";
1316
+ import { Box as Box5, Text as Text6 } from "ink";
1317
+
1318
+ // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/controls.ts
1319
+ import { useInput as useInput5 } from "ink";
1320
+
1321
+ // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/logic.ts
1322
+ var COMPONENT_CATEGORIES = ["tsx", "ts", "vue", "astro", "jsx", "js"];
1323
+ var ROW_LABELS = {
1324
+ tsx: ".tsx files",
1325
+ ts: ".ts files",
1326
+ vue: ".vue files",
1327
+ astro: ".astro files",
1328
+ jsx: ".jsx files",
1329
+ js: ".js files",
1330
+ json: ".json files (design tokens)",
1331
+ other: "other (ignored)"
1332
+ };
1333
+ var ROW_ORDER = ["tsx", "ts", "vue", "astro", "jsx", "js", "json", "other"];
1334
+ function describeFailure(failure, path5) {
1335
+ switch (failure) {
1336
+ case "is-file":
1337
+ return {
1338
+ headline: "That's a file, not a directory.",
1339
+ hints: [
1340
+ "Provide the path to your component library's root folder, not a specific file.",
1341
+ "Example: ~/projects/my-design-system"
1342
+ ]
1343
+ };
1344
+ case "not-found":
1345
+ return {
1346
+ headline: `Directory not found: ${path5}`,
1347
+ hints: ["Double-check the path and try again. Tip: you can use ~, relative, or absolute paths."]
1348
+ };
1349
+ case "permission-denied":
1350
+ return {
1351
+ headline: `Permission denied: ${path5}`,
1352
+ hints: ["You don't have read access to this directory."]
1353
+ };
1354
+ case "not-directory":
1355
+ return { headline: `Not a directory: ${path5}`, hints: [] };
1356
+ case "unreadable":
1357
+ return { headline: `Cannot access: ${path5}`, hints: [] };
1358
+ }
1359
+ }
1360
+ function summarize(counts) {
1361
+ const rows = ROW_ORDER.filter((category) => counts[category] > 0).map((category) => {
1362
+ const tone = category === "json" ? "accent" : category === "other" ? "muted" : "default";
1363
+ return { label: ROW_LABELS[category], count: counts[category], tone };
1364
+ });
1365
+ const componentFiles = COMPONENT_CATEGORIES.reduce((sum, category) => sum + counts[category], 0);
1366
+ if (componentFiles > 0) return { total: counts.total, rows };
1367
+ if (counts.json > 0) {
1368
+ return { total: counts.total, rows, warning: "No component files found \u2014 only token files detected." };
1369
+ }
1370
+ return {
1371
+ total: counts.total,
1372
+ rows,
1373
+ warning: "No component or token files found. Try a different path."
1374
+ };
1375
+ }
1376
+ function phaseOf(scan) {
1377
+ if (scan === void 0) return "scanning";
1378
+ return scan.ok ? "ready" : "failed";
1379
+ }
1380
+ function keyAction(phase, input, key) {
1381
+ if (key.escape) return "back";
1382
+ if (phase === "ready") {
1383
+ if (key.return) return "confirm";
1384
+ if (input === "e") return "change-path";
1385
+ }
1386
+ if (phase === "failed" && (key.return || input === "e")) return "change-path";
1387
+ return void 0;
1388
+ }
1389
+
1390
+ // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/controls.ts
1391
+ var CONTROLS = {
1392
+ scanning: [{ keys: "Esc", label: "Back" }],
1393
+ ready: [
1394
+ { keys: "Enter", label: "Yes, continue" },
1395
+ { keys: "e", label: "Change path" },
1396
+ { keys: "Esc", label: "Back" }
1397
+ ],
1398
+ failed: [
1399
+ { keys: "Enter/e", label: "Try a different path" },
1400
+ { keys: "Esc", label: "Back" }
1401
+ ]
1402
+ };
1403
+ function controlsFor(phase) {
1404
+ return CONTROLS[phase];
1405
+ }
1406
+ function usePathValidationControls(phase, handlers) {
1407
+ useInput5((input, key) => {
1408
+ const action = keyAction(phase, input, key);
1409
+ if (action === "confirm") handlers.onConfirm();
1410
+ else if (action === "change-path") handlers.onChangePath();
1411
+ else if (action === "back") handlers.onBack();
1412
+ });
1413
+ }
1414
+
1415
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/db.js
1416
+ import { DatabaseSync } from "node:sqlite";
1417
+
1418
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/export/export-cdf-document.js
1419
+ init_schema();
1420
+
1421
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/cdf/validators/validate-cdf-file.js
1422
+ init_validate();
1423
+
1424
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/shared/dtcg/validators/helpers/walk-dtcg.js
1425
+ init_token_types();
1426
+
1427
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/stencil/extract-stencil-components.js
1428
+ import { Project as Project2, Node as Node2, SyntaxKind as SyntaxKind2 } from "ts-morph";
1429
+
1430
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/shared/extract-tsx-components.js
1431
+ import { Node, Project, SyntaxKind } from "ts-morph";
1432
+ import ts from "typescript";
1433
+
1434
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/react/extract-react-components.js
1435
+ import { Node as Node4, SyntaxKind as SyntaxKind4 } from "ts-morph";
1436
+
1437
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/helpers/evidence/structural-slot-evidence.js
1438
+ import { Node as Node3, SyntaxKind as SyntaxKind3 } from "ts-morph";
1439
+
1440
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/react/extract-react-components.js
1441
+ function createTextControlSurface(onChangeType, specificProps) {
1442
+ return [
1443
+ { name: "autoComplete", type: "string", required: false },
1444
+ ...specificProps,
1445
+ { name: "disabled", type: "boolean", required: false },
1446
+ { name: "name", type: "string", required: false },
1447
+ { name: "onChange", type: onChangeType, required: false },
1448
+ { name: "placeholder", type: "string", required: false },
1449
+ { name: "readOnly", type: "boolean", required: false },
1450
+ { name: "required", type: "boolean", required: false },
1451
+ {
1452
+ name: "value",
1453
+ type: "string | number | readonly string[]",
1454
+ required: false
1455
+ }
1456
+ ];
1457
+ }
1458
+ var DOM_ATTRIBUTE_PROP_SURFACES = {
1459
+ HTMLProps: [],
1460
+ HTMLAttributes: [
1461
+ { name: "className", type: "string", required: false },
1462
+ { name: "hidden", type: "boolean", required: false },
1463
+ { name: "id", type: "string", required: false },
1464
+ {
1465
+ name: "onClick",
1466
+ type: "MouseEventHandler<HTMLElement>",
1467
+ required: false
1468
+ },
1469
+ { name: "style", type: "CSSProperties", required: false },
1470
+ { name: "tabIndex", type: "number", required: false },
1471
+ { name: "title", type: "string", required: false }
1472
+ ],
1473
+ ImgHTMLAttributes: [
1474
+ { name: "alt", type: "string", required: false },
1475
+ { name: "crossOrigin", type: "string", required: false },
1476
+ { name: "height", type: "number | string", required: false },
1477
+ {
1478
+ name: "loading",
1479
+ type: "string",
1480
+ required: false,
1481
+ allowedValues: ["eager", "lazy"]
1482
+ },
1483
+ { name: "sizes", type: "string", required: false },
1484
+ { name: "src", type: "string", required: false },
1485
+ { name: "srcSet", type: "string", required: false },
1486
+ { name: "width", type: "number | string", required: false }
1487
+ ],
1488
+ LiHTMLAttributes: [],
1489
+ AnchorHTMLAttributes: [
1490
+ { name: "download", type: "boolean | string", required: false },
1491
+ { name: "href", type: "string", required: false },
1492
+ { name: "hrefLang", type: "string", required: false },
1493
+ { name: "referrerPolicy", type: "string", required: false },
1494
+ { name: "rel", type: "string", required: false },
1495
+ {
1496
+ name: "target",
1497
+ type: "string",
1498
+ required: false,
1499
+ allowedValues: ["_blank", "_parent", "_self", "_top"]
1500
+ }
1501
+ ],
1502
+ ButtonHTMLAttributes: [
1503
+ { name: "autoFocus", type: "boolean", required: false },
1504
+ { name: "disabled", type: "boolean", required: false },
1505
+ { name: "form", type: "string", required: false },
1506
+ { name: "formAction", type: "string", required: false },
1507
+ { name: "formMethod", type: "string", required: false },
1508
+ { name: "formNoValidate", type: "boolean", required: false },
1509
+ { name: "formTarget", type: "string", required: false },
1510
+ { name: "name", type: "string", required: false },
1511
+ {
1512
+ name: "type",
1513
+ type: "string",
1514
+ required: false,
1515
+ allowedValues: ["button", "reset", "submit"]
1516
+ },
1517
+ {
1518
+ name: "value",
1519
+ type: "string | number | readonly string[]",
1520
+ required: false
1521
+ }
1522
+ ],
1523
+ InputHTMLAttributes: createTextControlSurface("ChangeEventHandler<HTMLInputElement>", [
1524
+ { name: "checked", type: "boolean", required: false },
1525
+ { name: "max", type: "number | string", required: false },
1526
+ { name: "maxLength", type: "number", required: false },
1527
+ { name: "min", type: "number | string", required: false },
1528
+ { name: "minLength", type: "number", required: false },
1529
+ { name: "type", type: "string", required: false }
1530
+ ]),
1531
+ FieldsetHTMLAttributes: [
1532
+ { name: "disabled", type: "boolean", required: false },
1533
+ { name: "form", type: "string", required: false },
1534
+ { name: "name", type: "string", required: false }
1535
+ ],
1536
+ LabelHTMLAttributes: [
1537
+ { name: "form", type: "string", required: false },
1538
+ { name: "htmlFor", type: "string", required: false }
1539
+ ],
1540
+ SelectHTMLAttributes: [
1541
+ { name: "autoComplete", type: "string", required: false },
1542
+ { name: "disabled", type: "boolean", required: false },
1543
+ { name: "form", type: "string", required: false },
1544
+ { name: "multiple", type: "boolean", required: false },
1545
+ { name: "name", type: "string", required: false },
1546
+ {
1547
+ name: "onChange",
1548
+ type: "ChangeEventHandler<HTMLSelectElement>",
1549
+ required: false
1550
+ },
1551
+ { name: "required", type: "boolean", required: false },
1552
+ { name: "size", type: "number", required: false },
1553
+ {
1554
+ name: "value",
1555
+ type: "string | number | readonly string[]",
1556
+ required: false
1557
+ }
1558
+ ],
1559
+ SVGAttributes: [
1560
+ {
1561
+ name: "focusable",
1562
+ type: 'boolean | "auto"',
1563
+ required: false,
1564
+ allowedValues: ["auto"]
1565
+ },
1566
+ { name: "height", type: "number | string", required: false },
1567
+ { name: "viewBox", type: "string", required: false },
1568
+ { name: "width", type: "number | string", required: false }
1569
+ ],
1570
+ SVGProps: [],
1571
+ TextareaHTMLAttributes: createTextControlSurface("ChangeEventHandler<HTMLTextAreaElement>", [
1572
+ { name: "cols", type: "number", required: false },
1573
+ { name: "rows", type: "number", required: false },
1574
+ { name: "wrap", type: "string", required: false }
1575
+ ]),
1576
+ TdHTMLAttributes: [
1577
+ {
1578
+ name: "align",
1579
+ type: "string",
1580
+ required: false,
1581
+ allowedValues: ["center", "char", "justify", "left", "right"]
1582
+ },
1583
+ { name: "colSpan", type: "number", required: false },
1584
+ { name: "headers", type: "string", required: false },
1585
+ { name: "rowSpan", type: "number", required: false },
1586
+ { name: "scope", type: "string", required: false }
1587
+ ]
1588
+ };
1589
+
1590
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/vue-tsx/extract-vue-tsx-components.js
1591
+ import { Node as Node5, SyntaxKind as SyntaxKind5 } from "ts-morph";
1592
+
1593
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/vue/extract-vue-components.js
1594
+ import { parse as parseSFC } from "@vue/compiler-sfc";
1595
+ import { Project as Project3, Node as Node6 } from "ts-morph";
1596
+
1597
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/astro/extract-astro-components.js
1598
+ import { Project as Project4, Node as Node7 } from "ts-morph";
1599
+
1600
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/web-components/extract-web-components.js
1601
+ import { Project as Project5, Node as Node8, SyntaxKind as SyntaxKind6 } from "ts-morph";
321
1602
 
322
- // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/controls.ts
323
- import { useInput as useInput4 } from "ink";
1603
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/extraction/src/framework-adapters/svelte/extract-svelte-components.js
1604
+ import { parse as parseSvelte } from "svelte/compiler";
1605
+ import { Project as Project6, Node as Node9, ScriptTarget, ModuleKind, ts as ts2 } from "ts-morph";
324
1606
 
325
- // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/logic.ts
326
- function shouldGoBack(key) {
327
- return key.escape;
1607
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/composition/src/controller/endpoint/compose-components-endpoint.js
1608
+ init_agents();
1609
+
1610
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/composition/src/services/run-composition-service.js
1611
+ init_agents();
1612
+
1613
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/selection/src/controller/select-components-endpoint.js
1614
+ init_agents();
1615
+
1616
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/selection/src/services/run-selection-service.js
1617
+ init_agents();
1618
+ var DEFAULT_TIMEOUT_MS = Number(process.env.EDS_AGENT_TIMEOUT_MS ?? 5 * 60 * 1e3);
1619
+
1620
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/collect-files.js
1621
+ import { statSync as statSync2 } from "node:fs";
1622
+ import path4 from "node:path";
1623
+
1624
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/build-scan-warnings.js
1625
+ function buildScanWarnings(counts) {
1626
+ const warnings = [];
1627
+ if (counts.total === 0) {
1628
+ warnings.push("No source files found. Double-check the path points at your component code.");
1629
+ return warnings;
1630
+ }
1631
+ const frameworkFiles = counts.tsx + counts.ts + counts.jsx + counts.js + counts.vue + counts.astro + counts.svelte;
1632
+ if (frameworkFiles === 0) {
1633
+ warnings.push("No framework source files found (.tsx, .ts, .vue, .svelte, .astro, .jsx, .js).");
1634
+ }
1635
+ return warnings;
328
1636
  }
329
- function toTokenPath(value) {
330
- const tokenPath = value.trim();
331
- return tokenPath === "" ? null : tokenPath;
1637
+
1638
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/classify-stat-error.js
1639
+ function classifyStatError(code) {
1640
+ switch (code) {
1641
+ case "ENOENT":
1642
+ return "not-found";
1643
+ case "EACCES":
1644
+ case "EPERM":
1645
+ return "permission-denied";
1646
+ default:
1647
+ return "unreadable";
1648
+ }
332
1649
  }
333
1650
 
334
- // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/controls.ts
335
- var TOKEN_INPUT_CONTROLS = [
336
- { keys: "Enter", label: "Continue" },
337
- { keys: "Esc", label: "Back" }
338
- ];
339
- function useTokenInputControls(onBack) {
340
- useInput4((_input, key) => {
341
- if (shouldGoBack(key)) onBack();
342
- });
1651
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/empty-file-counts.js
1652
+ function emptyFileCounts() {
1653
+ return { tsx: 0, ts: 0, vue: 0, astro: 0, svelte: 0, jsx: 0, js: 0, json: 0, md: 0, other: 0, total: 0 };
343
1654
  }
344
1655
 
345
- // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/validate-path.ts
346
- import { statSync } from "node:fs";
1656
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/walk-project-tree.js
1657
+ import { readFileSync as readFileSync3 } from "node:fs";
1658
+ import path3 from "node:path";
347
1659
 
348
- // packages/experience-design-system-cli/src/tui/import/resolve-user-path.ts
349
- import { homedir } from "node:os";
350
- import { resolve } from "node:path";
351
- function stripQuotes(value) {
352
- const quoted = value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'");
353
- return value.length >= 2 && quoted ? value.slice(1, -1) : value;
1660
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/constants/file-patterns.js
1661
+ var INCLUDED_EXTENSIONS = /* @__PURE__ */ new Set([".astro", ".js", ".jsx", ".svelte", ".ts", ".tsx", ".vue"]);
1662
+ var DENYLIST_GATED_EXTENSIONS = /* @__PURE__ */ new Set([".json", ".md"]);
1663
+ var EXCLUDED_SUFFIXES = [
1664
+ ".d.ts",
1665
+ ".stories.ts",
1666
+ ".stories.tsx",
1667
+ ".stories.js",
1668
+ ".stories.jsx",
1669
+ ".story.ts",
1670
+ ".story.tsx",
1671
+ ".story.js",
1672
+ ".story.jsx",
1673
+ ".spec.ts",
1674
+ ".spec.tsx",
1675
+ ".test.ts",
1676
+ ".test.tsx"
1677
+ ];
1678
+ var IGNORED_DIRS = /* @__PURE__ */ new Set([
1679
+ ".changeset",
1680
+ ".git",
1681
+ ".github",
1682
+ ".idea",
1683
+ ".next",
1684
+ ".nuxt",
1685
+ ".nx",
1686
+ ".vscode",
1687
+ "build",
1688
+ "coverage",
1689
+ "demo",
1690
+ "demos",
1691
+ "dist",
1692
+ "example",
1693
+ "examples",
1694
+ "node_modules",
1695
+ "out",
1696
+ "storybook-static"
1697
+ ]);
1698
+ var DENYLISTED_EXACT_FILE_NAMES = /* @__PURE__ */ new Set([
1699
+ "package.json",
1700
+ "package-lock.json",
1701
+ "npm-shrinkwrap.json",
1702
+ "nx.json",
1703
+ "project.json",
1704
+ "turbo.json",
1705
+ "lerna.json",
1706
+ "jsconfig.json"
1707
+ ]);
1708
+ var DENYLISTED_FILE_NAME_PATTERNS = [
1709
+ /^tsconfig(\..+)?\.json$/,
1710
+ /^\.?eslintrc(\..+)?\.json$/,
1711
+ /^\.?prettierrc(\..+)?\.json$/,
1712
+ /^(readme|changelog|contributing|code_of_conduct|license|security)(\..+)?\.md$/i
1713
+ ];
1714
+
1715
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/categorize-file.js
1716
+ import path from "node:path";
1717
+
1718
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/constants/file-categories.js
1719
+ var CATEGORY_BY_EXTENSION = {
1720
+ ".tsx": "tsx",
1721
+ ".ts": "ts",
1722
+ ".vue": "vue",
1723
+ ".astro": "astro",
1724
+ ".svelte": "svelte",
1725
+ ".jsx": "jsx",
1726
+ ".js": "js",
1727
+ ".json": "json",
1728
+ ".md": "md"
1729
+ };
1730
+
1731
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/categorize-file.js
1732
+ function categorizeFile(name) {
1733
+ if (name.endsWith(".d.ts"))
1734
+ return "other";
1735
+ const ext = path.extname(name);
1736
+ return CATEGORY_BY_EXTENSION[ext] ?? "other";
354
1737
  }
355
- function expandHome(value) {
356
- return value === "~" || value.startsWith("~/") || value.startsWith("~\\") ? homedir() + value.slice(1) : value;
1738
+
1739
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/is-source-file.js
1740
+ import path2 from "node:path";
1741
+
1742
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/is-noise-config-file.js
1743
+ function isNoiseConfigFile(name) {
1744
+ return DENYLISTED_EXACT_FILE_NAMES.has(name) || DENYLISTED_FILE_NAME_PATTERNS.some((pattern) => pattern.test(name));
357
1745
  }
358
- function resolveUserPath(raw) {
359
- return resolve(expandHome(stripQuotes(raw.trim())));
1746
+
1747
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/is-source-file.js
1748
+ function isSourceFile(name) {
1749
+ if (name.endsWith(".d.ts"))
1750
+ return false;
1751
+ if (EXCLUDED_SUFFIXES.some((suffix) => name.endsWith(suffix)))
1752
+ return false;
1753
+ const ext = path2.extname(name);
1754
+ if (INCLUDED_EXTENSIONS.has(ext))
1755
+ return true;
1756
+ if (DENYLIST_GATED_EXTENSIONS.has(ext) && !isNoiseConfigFile(name))
1757
+ return true;
1758
+ return false;
360
1759
  }
361
1760
 
362
- // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/validate-path.ts
363
- function validateTokenPath(rawPath) {
364
- const path = resolveUserPath(rawPath);
365
- let stats;
1761
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/read-dir-safely.js
1762
+ import { readdirSync } from "node:fs";
1763
+ function readDirSafely(dir) {
366
1764
  try {
367
- stats = statSync(path);
1765
+ return readdirSync(dir, { withFileTypes: true });
368
1766
  } catch {
369
- return { ok: false, error: `Path not found: ${path}`, resolvedPath: path };
1767
+ return "unreadable";
370
1768
  }
371
- if (stats.isDirectory()) {
372
- return {
373
- ok: false,
374
- error: "That's a directory \u2014 provide a path to a token file (e.g. tokens.json), not a folder.",
375
- resolvedPath: path
376
- };
1769
+ }
1770
+
1771
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/walk-project-tree.js
1772
+ function walkProjectTree(dir, result, includeContent) {
1773
+ const entries = readDirSafely(dir);
1774
+ if (entries === "unreadable") {
1775
+ result.warnings.push(`Could not read directory: ${dir}`);
1776
+ return;
377
1777
  }
378
- if (!stats.isFile()) {
379
- return { ok: false, error: `Not a regular file: ${path}`, resolvedPath: path };
1778
+ for (const entry of entries) {
1779
+ const full = path3.join(dir, entry.name);
1780
+ if (entry.isDirectory()) {
1781
+ if (!IGNORED_DIRS.has(entry.name))
1782
+ walkProjectTree(full, result, includeContent);
1783
+ continue;
1784
+ }
1785
+ if (!entry.isFile())
1786
+ continue;
1787
+ if (!isSourceFile(entry.name))
1788
+ continue;
1789
+ const category = categorizeFile(entry.name);
1790
+ result.counts[category] += 1;
1791
+ result.counts.total += 1;
1792
+ result.filePaths.push(full);
1793
+ if (includeContent) {
1794
+ try {
1795
+ const content = readFileSync3(full, "utf8");
1796
+ (result.candidateFiles ??= []).push({ path: full, content });
1797
+ } catch {
1798
+ }
1799
+ }
380
1800
  }
381
- return { ok: true, path };
382
1801
  }
383
1802
 
384
- // packages/experience-design-system-cli/src/tui/import/steps/02-token-input/screen.tsx
385
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
386
- function TokenInputScreen({ onConfirm, onBack, initialPath = "" }) {
387
- const [tokenPath, setTokenPath] = useState4(initialPath);
388
- const [failure, setFailure] = useState4(null);
389
- useTokenInputControls(onBack);
390
- const change = (value) => {
391
- setTokenPath(value);
392
- setFailure(null);
1803
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/helpers/collect-files/collect-files.js
1804
+ function collectFiles(root, options = {}) {
1805
+ const resolved = path4.resolve(root);
1806
+ let stat;
1807
+ try {
1808
+ stat = statSync2(resolved);
1809
+ } catch (err) {
1810
+ return { ok: false, failure: classifyStatError(err.code), rootPath: resolved };
1811
+ }
1812
+ if (stat.isFile())
1813
+ return { ok: false, failure: "is-file", rootPath: resolved };
1814
+ if (!stat.isDirectory())
1815
+ return { ok: false, failure: "not-directory", rootPath: resolved };
1816
+ const result = {
1817
+ filePaths: [],
1818
+ counts: emptyFileCounts(),
1819
+ warnings: [],
1820
+ rootPath: resolved
393
1821
  };
394
- const submit = (value) => {
395
- const rawPath = toTokenPath(value);
396
- if (!rawPath) {
397
- setFailure({ error: "Enter the path to your token file." });
398
- return;
1822
+ if (options.includeContent)
1823
+ result.candidateFiles = [];
1824
+ walkProjectTree(resolved, result, options.includeContent === true);
1825
+ result.filePaths.sort();
1826
+ if (result.candidateFiles)
1827
+ result.candidateFiles.sort((a, b) => a.path.localeCompare(b.path));
1828
+ result.warnings.push(...buildScanWarnings(result.counts));
1829
+ return { ok: true, result };
1830
+ }
1831
+
1832
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/index.js
1833
+ import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
1834
+
1835
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/session/repositories/migration.js
1836
+ import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
1837
+
1838
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/credentials/helpers/host-utils.js
1839
+ var DEFAULT_CONFIGURED_HOST = "api.contentful.com";
1840
+
1841
+ // packages/experience-design-system-backend-pipeline/dist/src/persistence/src/index.js
1842
+ init_cache_keys();
1843
+
1844
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/generate-cdf-components-endpoint.js
1845
+ init_agents();
1846
+
1847
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/services/run-cdf-generation-service.js
1848
+ init_agents();
1849
+
1850
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/services/run-apply-service.js
1851
+ init_shared();
1852
+
1853
+ // packages/experience-design-system-client/dist/src/generated/core/bodySerializer.gen.js
1854
+ var jsonBodySerializer = {
1855
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
1856
+ };
1857
+
1858
+ // packages/experience-design-system-client/dist/src/generated/core/params.gen.js
1859
+ var extraPrefixesMap = {
1860
+ $body_: "body",
1861
+ $headers_: "headers",
1862
+ $path_: "path",
1863
+ $query_: "query"
1864
+ };
1865
+ var extraPrefixes = Object.entries(extraPrefixesMap);
1866
+
1867
+ // packages/experience-design-system-client/dist/src/generated/core/auth.gen.js
1868
+ var getAuthToken = async (auth, callback) => {
1869
+ const token = typeof callback === "function" ? await callback(auth) : callback;
1870
+ if (!token) {
1871
+ return;
1872
+ }
1873
+ if (auth.scheme === "bearer") {
1874
+ return `Bearer ${token}`;
1875
+ }
1876
+ if (auth.scheme === "basic") {
1877
+ return `Basic ${btoa(token)}`;
1878
+ }
1879
+ return token;
1880
+ };
1881
+
1882
+ // packages/experience-design-system-client/dist/src/generated/core/pathSerializer.gen.js
1883
+ var separatorArrayExplode = (style) => {
1884
+ switch (style) {
1885
+ case "label":
1886
+ return ".";
1887
+ case "matrix":
1888
+ return ";";
1889
+ case "simple":
1890
+ return ",";
1891
+ default:
1892
+ return "&";
1893
+ }
1894
+ };
1895
+ var separatorArrayNoExplode = (style) => {
1896
+ switch (style) {
1897
+ case "form":
1898
+ return ",";
1899
+ case "pipeDelimited":
1900
+ return "|";
1901
+ case "spaceDelimited":
1902
+ return "%20";
1903
+ default:
1904
+ return ",";
1905
+ }
1906
+ };
1907
+ var separatorObjectExplode = (style) => {
1908
+ switch (style) {
1909
+ case "label":
1910
+ return ".";
1911
+ case "matrix":
1912
+ return ";";
1913
+ case "simple":
1914
+ return ",";
1915
+ default:
1916
+ return "&";
1917
+ }
1918
+ };
1919
+ var serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
1920
+ if (!explode) {
1921
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
1922
+ switch (style) {
1923
+ case "label":
1924
+ return `.${joinedValues2}`;
1925
+ case "matrix":
1926
+ return `;${name}=${joinedValues2}`;
1927
+ case "simple":
1928
+ return joinedValues2;
1929
+ default:
1930
+ return `${name}=${joinedValues2}`;
399
1931
  }
400
- const check = validateTokenPath(rawPath);
401
- if (check.ok) onConfirm(check.path);
402
- else setFailure({ error: check.error, resolvedPath: check.resolvedPath });
1932
+ }
1933
+ const separator = separatorArrayExplode(style);
1934
+ const joinedValues = value.map((v) => {
1935
+ if (style === "label" || style === "simple") {
1936
+ return allowReserved ? v : encodeURIComponent(v);
1937
+ }
1938
+ return serializePrimitiveParam({
1939
+ allowReserved,
1940
+ name,
1941
+ value: v
1942
+ });
1943
+ }).join(separator);
1944
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
1945
+ };
1946
+ var serializePrimitiveParam = ({ allowReserved, name, value }) => {
1947
+ if (value === void 0 || value === null) {
1948
+ return "";
1949
+ }
1950
+ if (typeof value === "object") {
1951
+ throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");
1952
+ }
1953
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
1954
+ };
1955
+ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
1956
+ if (value instanceof Date) {
1957
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
1958
+ }
1959
+ if (style !== "deepObject" && !explode) {
1960
+ let values = [];
1961
+ Object.entries(value).forEach(([key, v]) => {
1962
+ values = [
1963
+ ...values,
1964
+ key,
1965
+ allowReserved ? v : encodeURIComponent(v)
1966
+ ];
1967
+ });
1968
+ const joinedValues2 = values.join(",");
1969
+ switch (style) {
1970
+ case "form":
1971
+ return `${name}=${joinedValues2}`;
1972
+ case "label":
1973
+ return `.${joinedValues2}`;
1974
+ case "matrix":
1975
+ return `;${name}=${joinedValues2}`;
1976
+ default:
1977
+ return joinedValues2;
1978
+ }
1979
+ }
1980
+ const separator = separatorObjectExplode(style);
1981
+ const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
1982
+ allowReserved,
1983
+ name: style === "deepObject" ? `${name}[${key}]` : key,
1984
+ value: v
1985
+ })).join(separator);
1986
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
1987
+ };
1988
+
1989
+ // packages/experience-design-system-client/dist/src/generated/client/utils.gen.js
1990
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
1991
+ var defaultPathSerializer = ({ path: path5, url: _url }) => {
1992
+ let url = _url;
1993
+ const matches = _url.match(PATH_PARAM_RE);
1994
+ if (matches) {
1995
+ for (const match of matches) {
1996
+ let explode = false;
1997
+ let name = match.substring(1, match.length - 1);
1998
+ let style = "simple";
1999
+ if (name.endsWith("*")) {
2000
+ explode = true;
2001
+ name = name.substring(0, name.length - 1);
2002
+ }
2003
+ if (name.startsWith(".")) {
2004
+ name = name.substring(1);
2005
+ style = "label";
2006
+ } else if (name.startsWith(";")) {
2007
+ name = name.substring(1);
2008
+ style = "matrix";
2009
+ }
2010
+ const value = path5[name];
2011
+ if (value === void 0 || value === null) {
2012
+ continue;
2013
+ }
2014
+ if (Array.isArray(value)) {
2015
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
2016
+ continue;
2017
+ }
2018
+ if (typeof value === "object") {
2019
+ url = url.replace(match, serializeObjectParam({
2020
+ explode,
2021
+ name,
2022
+ style,
2023
+ value,
2024
+ valueOnly: true
2025
+ }));
2026
+ continue;
2027
+ }
2028
+ if (style === "matrix") {
2029
+ url = url.replace(match, `;${serializePrimitiveParam({
2030
+ name,
2031
+ value
2032
+ })}`);
2033
+ continue;
2034
+ }
2035
+ const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
2036
+ url = url.replace(match, replaceValue);
2037
+ }
2038
+ }
2039
+ return url;
2040
+ };
2041
+ var createQuerySerializer = ({ allowReserved, array: array2, object } = {}) => {
2042
+ const querySerializer = (queryParams) => {
2043
+ const search = [];
2044
+ if (queryParams && typeof queryParams === "object") {
2045
+ for (const name in queryParams) {
2046
+ const value = queryParams[name];
2047
+ if (value === void 0 || value === null) {
2048
+ continue;
2049
+ }
2050
+ if (Array.isArray(value)) {
2051
+ const serializedArray = serializeArrayParam({
2052
+ allowReserved,
2053
+ explode: true,
2054
+ name,
2055
+ style: "form",
2056
+ value,
2057
+ ...array2
2058
+ });
2059
+ if (serializedArray)
2060
+ search.push(serializedArray);
2061
+ } else if (typeof value === "object") {
2062
+ const serializedObject = serializeObjectParam({
2063
+ allowReserved,
2064
+ explode: true,
2065
+ name,
2066
+ style: "deepObject",
2067
+ value,
2068
+ ...object
2069
+ });
2070
+ if (serializedObject)
2071
+ search.push(serializedObject);
2072
+ } else {
2073
+ const serializedPrimitive = serializePrimitiveParam({
2074
+ allowReserved,
2075
+ name,
2076
+ value
2077
+ });
2078
+ if (serializedPrimitive)
2079
+ search.push(serializedPrimitive);
2080
+ }
2081
+ }
2082
+ }
2083
+ return search.join("&");
403
2084
  };
404
- return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
405
- /* @__PURE__ */ jsx5(Text5, { bold: true, children: "Design tokens" }),
406
- /* @__PURE__ */ jsx5(Text5, { color: PALETTE.muted, children: "Point me to your raw token file (e.g. ~/design-tokens/tokens.json). You can use ~, relative, or absolute paths. Claude will map it to Design Token Group Format (DTCG)." }),
407
- /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
408
- /* @__PURE__ */ jsxs4(Box4, { gap: 1, children: [
409
- /* @__PURE__ */ jsx5(Text5, { color: PALETTE.accent, children: "?" }),
410
- /* @__PURE__ */ jsx5(Text5, { children: "Token path:" }),
411
- /* @__PURE__ */ jsx5(TextInput2, { value: tokenPath, onChange: change, onSubmit: submit })
412
- ] }),
413
- failure && /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", children: [
414
- /* @__PURE__ */ jsxs4(Text5, { color: PALETTE.error, children: [
415
- "\u2717 ",
416
- failure.error
417
- ] }),
418
- failure.resolvedPath && /* @__PURE__ */ jsxs4(Text5, { color: PALETTE.muted, children: [
419
- " Resolved to: ",
420
- failure.resolvedPath
421
- ] })
422
- ] })
423
- ] }),
424
- /* @__PURE__ */ jsx5(Box4, { marginTop: 1, gap: 3, children: TOKEN_INPUT_CONTROLS.map((control) => /* @__PURE__ */ jsxs4(Text5, { children: [
425
- "[",
426
- control.keys,
427
- "] ",
428
- control.label
429
- ] }, control.keys)) })
430
- ] });
431
- }
2085
+ return querySerializer;
2086
+ };
2087
+ var getParseAs = (contentType) => {
2088
+ if (!contentType) {
2089
+ return "stream";
2090
+ }
2091
+ const cleanContent = contentType.split(";")[0]?.trim();
2092
+ if (!cleanContent) {
2093
+ return;
2094
+ }
2095
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
2096
+ return "json";
2097
+ }
2098
+ if (cleanContent === "multipart/form-data") {
2099
+ return "formData";
2100
+ }
2101
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
2102
+ return "blob";
2103
+ }
2104
+ if (cleanContent.startsWith("text/")) {
2105
+ return "text";
2106
+ }
2107
+ return;
2108
+ };
2109
+ var checkForExistence = (options, name) => {
2110
+ if (!name) {
2111
+ return false;
2112
+ }
2113
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
2114
+ return true;
2115
+ }
2116
+ return false;
2117
+ };
2118
+ var setAuthParams = async ({ security, ...options }) => {
2119
+ for (const auth of security) {
2120
+ if (checkForExistence(options, auth.name)) {
2121
+ continue;
2122
+ }
2123
+ const token = await getAuthToken(auth, options.auth);
2124
+ if (!token) {
2125
+ continue;
2126
+ }
2127
+ const name = auth.name ?? "Authorization";
2128
+ switch (auth.in) {
2129
+ case "query":
2130
+ if (!options.query) {
2131
+ options.query = {};
2132
+ }
2133
+ options.query[name] = token;
2134
+ break;
2135
+ case "cookie":
2136
+ options.headers.append("Cookie", `${name}=${token}`);
2137
+ break;
2138
+ case "header":
2139
+ default:
2140
+ options.headers.set(name, token);
2141
+ break;
2142
+ }
2143
+ }
2144
+ };
2145
+ var buildUrl = (options) => {
2146
+ const url = getUrl({
2147
+ baseUrl: options.baseUrl,
2148
+ path: options.path,
2149
+ query: options.query,
2150
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
2151
+ url: options.url
2152
+ });
2153
+ return url;
2154
+ };
2155
+ var getUrl = ({ baseUrl, path: path5, query, querySerializer, url: _url }) => {
2156
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
2157
+ let url = (baseUrl ?? "") + pathUrl;
2158
+ if (path5) {
2159
+ url = defaultPathSerializer({ path: path5, url });
2160
+ }
2161
+ let search = query ? querySerializer(query) : "";
2162
+ if (search.startsWith("?")) {
2163
+ search = search.substring(1);
2164
+ }
2165
+ if (search) {
2166
+ url += `?${search}`;
2167
+ }
2168
+ return url;
2169
+ };
2170
+ var mergeConfigs = (a, b) => {
2171
+ const config = { ...a, ...b };
2172
+ if (config.baseUrl?.endsWith("/")) {
2173
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
2174
+ }
2175
+ config.headers = mergeHeaders(a.headers, b.headers);
2176
+ return config;
2177
+ };
2178
+ var mergeHeaders = (...headers) => {
2179
+ const mergedHeaders = new Headers();
2180
+ for (const header of headers) {
2181
+ if (!header || typeof header !== "object") {
2182
+ continue;
2183
+ }
2184
+ const iterator = header instanceof Headers ? header.entries() : Object.entries(header);
2185
+ for (const [key, value] of iterator) {
2186
+ if (value === null) {
2187
+ mergedHeaders.delete(key);
2188
+ } else if (Array.isArray(value)) {
2189
+ for (const v of value) {
2190
+ mergedHeaders.append(key, v);
2191
+ }
2192
+ } else if (value !== void 0) {
2193
+ mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
2194
+ }
2195
+ }
2196
+ }
2197
+ return mergedHeaders;
2198
+ };
2199
+ var Interceptors = class {
2200
+ _fns;
2201
+ constructor() {
2202
+ this._fns = [];
2203
+ }
2204
+ clear() {
2205
+ this._fns = [];
2206
+ }
2207
+ getInterceptorIndex(id) {
2208
+ if (typeof id === "number") {
2209
+ return this._fns[id] ? id : -1;
2210
+ } else {
2211
+ return this._fns.indexOf(id);
2212
+ }
2213
+ }
2214
+ exists(id) {
2215
+ const index = this.getInterceptorIndex(id);
2216
+ return !!this._fns[index];
2217
+ }
2218
+ eject(id) {
2219
+ const index = this.getInterceptorIndex(id);
2220
+ if (this._fns[index]) {
2221
+ this._fns[index] = null;
2222
+ }
2223
+ }
2224
+ update(id, fn) {
2225
+ const index = this.getInterceptorIndex(id);
2226
+ if (this._fns[index]) {
2227
+ this._fns[index] = fn;
2228
+ return id;
2229
+ } else {
2230
+ return false;
2231
+ }
2232
+ }
2233
+ use(fn) {
2234
+ this._fns = [...this._fns, fn];
2235
+ return this._fns.length - 1;
2236
+ }
2237
+ };
2238
+ var createInterceptors = () => ({
2239
+ error: new Interceptors(),
2240
+ request: new Interceptors(),
2241
+ response: new Interceptors()
2242
+ });
2243
+ var defaultQuerySerializer = createQuerySerializer({
2244
+ allowReserved: false,
2245
+ array: {
2246
+ explode: true,
2247
+ style: "form"
2248
+ },
2249
+ object: {
2250
+ explode: true,
2251
+ style: "deepObject"
2252
+ }
2253
+ });
2254
+ var defaultHeaders = {
2255
+ "Content-Type": "application/json"
2256
+ };
2257
+ var createConfig = (override = {}) => ({
2258
+ ...jsonBodySerializer,
2259
+ headers: defaultHeaders,
2260
+ parseAs: "auto",
2261
+ querySerializer: defaultQuerySerializer,
2262
+ ...override
2263
+ });
432
2264
 
433
- // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/screen.tsx
434
- import { useEffect as useEffect3, useMemo, useState as useState5 } from "react";
435
- import { Box as Box5, Text as Text6 } from "ink";
2265
+ // packages/experience-design-system-client/dist/src/generated/client/client.gen.js
2266
+ var createClient = (config = {}) => {
2267
+ let _config = mergeConfigs(createConfig(), config);
2268
+ const getConfig = () => ({ ..._config });
2269
+ const setConfig = (config2) => {
2270
+ _config = mergeConfigs(_config, config2);
2271
+ return getConfig();
2272
+ };
2273
+ const interceptors = createInterceptors();
2274
+ const request = async (options) => {
2275
+ const opts = {
2276
+ ..._config,
2277
+ ...options,
2278
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
2279
+ headers: mergeHeaders(_config.headers, options.headers),
2280
+ serializedBody: void 0
2281
+ };
2282
+ if (opts.security) {
2283
+ await setAuthParams({
2284
+ ...opts,
2285
+ security: opts.security
2286
+ });
2287
+ }
2288
+ if (opts.requestValidator) {
2289
+ await opts.requestValidator(opts);
2290
+ }
2291
+ if (opts.body && opts.bodySerializer) {
2292
+ opts.serializedBody = opts.bodySerializer(opts.body);
2293
+ }
2294
+ if (opts.serializedBody === void 0 || opts.serializedBody === "") {
2295
+ opts.headers.delete("Content-Type");
2296
+ }
2297
+ const url = buildUrl(opts);
2298
+ const requestInit = {
2299
+ redirect: "follow",
2300
+ ...opts,
2301
+ body: opts.serializedBody
2302
+ };
2303
+ let request2 = new Request(url, requestInit);
2304
+ for (const fn of interceptors.request._fns) {
2305
+ if (fn) {
2306
+ request2 = await fn(request2, opts);
2307
+ }
2308
+ }
2309
+ const _fetch = opts.fetch;
2310
+ let response = await _fetch(request2);
2311
+ for (const fn of interceptors.response._fns) {
2312
+ if (fn) {
2313
+ response = await fn(response, request2, opts);
2314
+ }
2315
+ }
2316
+ const result = {
2317
+ request: request2,
2318
+ response
2319
+ };
2320
+ if (response.ok) {
2321
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
2322
+ return opts.responseStyle === "data" ? {} : {
2323
+ data: {},
2324
+ ...result
2325
+ };
2326
+ }
2327
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
2328
+ let data;
2329
+ switch (parseAs) {
2330
+ case "arrayBuffer":
2331
+ case "blob":
2332
+ case "formData":
2333
+ case "json":
2334
+ case "text":
2335
+ data = await response[parseAs]();
2336
+ break;
2337
+ case "stream":
2338
+ return opts.responseStyle === "data" ? response.body : {
2339
+ data: response.body,
2340
+ ...result
2341
+ };
2342
+ }
2343
+ if (parseAs === "json") {
2344
+ if (opts.responseValidator) {
2345
+ await opts.responseValidator(data);
2346
+ }
2347
+ if (opts.responseTransformer) {
2348
+ data = await opts.responseTransformer(data);
2349
+ }
2350
+ }
2351
+ return opts.responseStyle === "data" ? data : {
2352
+ data,
2353
+ ...result
2354
+ };
2355
+ }
2356
+ const textError = await response.text();
2357
+ let jsonError;
2358
+ try {
2359
+ jsonError = JSON.parse(textError);
2360
+ } catch {
2361
+ }
2362
+ const error = jsonError ?? textError;
2363
+ let finalError = error;
2364
+ for (const fn of interceptors.error._fns) {
2365
+ if (fn) {
2366
+ finalError = await fn(error, response, request2, opts);
2367
+ }
2368
+ }
2369
+ finalError = finalError || {};
2370
+ if (opts.throwOnError) {
2371
+ throw finalError;
2372
+ }
2373
+ return opts.responseStyle === "data" ? void 0 : {
2374
+ error: finalError,
2375
+ ...result
2376
+ };
2377
+ };
2378
+ return {
2379
+ buildUrl,
2380
+ connect: (options) => request({ ...options, method: "CONNECT" }),
2381
+ delete: (options) => request({ ...options, method: "DELETE" }),
2382
+ get: (options) => request({ ...options, method: "GET" }),
2383
+ getConfig,
2384
+ head: (options) => request({ ...options, method: "HEAD" }),
2385
+ interceptors,
2386
+ options: (options) => request({ ...options, method: "OPTIONS" }),
2387
+ patch: (options) => request({ ...options, method: "PATCH" }),
2388
+ post: (options) => request({ ...options, method: "POST" }),
2389
+ put: (options) => request({ ...options, method: "PUT" }),
2390
+ request,
2391
+ setConfig,
2392
+ trace: (options) => request({ ...options, method: "TRACE" })
2393
+ };
2394
+ };
436
2395
 
437
- // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/controls.ts
438
- import { useInput as useInput5 } from "ink";
2396
+ // packages/experience-design-system-client/dist/src/generated/client.gen.js
2397
+ var client = createClient(createConfig());
439
2398
 
440
- // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/logic.ts
441
- var IGNORED_DIRECTORIES = /* @__PURE__ */ new Set([
442
- "node_modules",
443
- "dist",
444
- "build",
445
- ".next",
446
- ".nuxt",
447
- "coverage",
448
- "storybook-static",
449
- "out",
450
- ".git"
451
- ]);
452
- var CATEGORY_BY_EXTENSION = /* @__PURE__ */ new Map([
453
- ["tsx", "tsx"],
454
- ["ts", "ts"],
455
- ["vue", "vue"],
456
- ["astro", "astro"],
457
- ["jsx", "jsx"],
458
- ["js", "js"],
459
- ["json", "json"]
460
- ]);
461
- var COMPONENT_CATEGORIES = ["tsx", "ts", "vue", "astro", "jsx", "js"];
462
- var ROW_LABELS = {
463
- tsx: ".tsx files",
464
- ts: ".ts files",
465
- vue: ".vue files",
466
- astro: ".astro files",
467
- jsx: ".jsx files",
468
- js: ".js files",
469
- json: ".json files (design tokens)",
470
- other: "other (ignored)"
2399
+ // packages/experience-design-system-client/dist/src/generated/sdk.gen.js
2400
+ var designSystemImportSourcelessPreview = (options) => {
2401
+ return (options.client ?? client).post({
2402
+ url: "/spaces/{spaceId}/environments/{environmentId}/design_systems/imports/preview",
2403
+ ...options,
2404
+ headers: {
2405
+ "Content-Type": "application/json",
2406
+ ...options.headers
2407
+ }
2408
+ });
471
2409
  };
472
- var ROW_ORDER = ["tsx", "ts", "vue", "astro", "jsx", "js", "json", "other"];
473
- function categorize(fileName) {
474
- if (fileName.endsWith(".d.ts")) return "other";
475
- const dot = fileName.lastIndexOf(".");
476
- const extension = dot === -1 ? "" : fileName.slice(dot + 1);
477
- return CATEGORY_BY_EXTENSION.get(extension) ?? "other";
2410
+ var designSystemImportApply = (options) => {
2411
+ return (options.client ?? client).post({
2412
+ url: "/spaces/{spaceId}/environments/{environmentId}/design_systems/imports/apply",
2413
+ ...options,
2414
+ headers: {
2415
+ "Content-Type": "application/json",
2416
+ ...options.headers
2417
+ }
2418
+ });
2419
+ };
2420
+ var designSystemImportGetOperation = (options) => {
2421
+ return (options.client ?? client).get({
2422
+ url: "/spaces/{spaceId}/environments/{environmentId}/design_systems/imports/apply/{operationId}",
2423
+ ...options
2424
+ });
2425
+ };
2426
+
2427
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/constants/api.js
2428
+ var PREVIEW_ERROR_PREFIX = "preview failed:";
2429
+ var APPLY_ERROR_PREFIX = "apply failed:";
2430
+ var USER_AGENT = "experience-design-system-backend-pipeline";
2431
+
2432
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/http-utils.js
2433
+ var MAX_RETRY_AFTER_MS = 6e4;
2434
+ function isTransientStatus(status) {
2435
+ return status >= 500 && status <= 599;
478
2436
  }
479
- function emptyCounts() {
480
- return { tsx: 0, ts: 0, vue: 0, astro: 0, jsx: 0, js: 0, json: 0, other: 0, total: 0 };
2437
+ function retryAfterMs(response) {
2438
+ const value = response.headers?.get("retry-after")?.trim();
2439
+ if (!value)
2440
+ return void 0;
2441
+ const seconds = Number(value);
2442
+ const delayMs = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(value) - Date.now();
2443
+ if (!Number.isFinite(delayMs) || delayMs < 0 || delayMs > MAX_RETRY_AFTER_MS)
2444
+ return void 0;
2445
+ return Math.round(delayMs);
481
2446
  }
482
- function addFile(counts, fileName) {
483
- const category = categorize(fileName);
484
- return { ...counts, [category]: counts[category] + 1, total: counts.total + 1 };
2447
+ function isApsDenialBody(body) {
2448
+ if (!body)
2449
+ return false;
2450
+ try {
2451
+ const parsed = JSON.parse(body);
2452
+ const id = parsed?.sys?.id;
2453
+ return id === "NotFound" || id === "AccessDenied";
2454
+ } catch {
2455
+ return false;
2456
+ }
485
2457
  }
486
- function mergeCounts(a, b) {
487
- return {
488
- tsx: a.tsx + b.tsx,
489
- ts: a.ts + b.ts,
490
- vue: a.vue + b.vue,
491
- astro: a.astro + b.astro,
492
- jsx: a.jsx + b.jsx,
493
- js: a.js + b.js,
494
- json: a.json + b.json,
495
- other: a.other + b.other,
496
- total: a.total + b.total
497
- };
2458
+ function stringifyError(error) {
2459
+ return typeof error === "string" ? error : JSON.stringify(error ?? {});
498
2460
  }
499
- function failureFromErrorCode(code) {
500
- if (code === "ENOENT") return "not-found";
501
- if (code === "EACCES") return "permission-denied";
502
- return "unreadable";
2461
+ function errorMessage(error) {
2462
+ return error instanceof Error && error.message ? error.message : String(error);
503
2463
  }
504
- function describeFailure(failure, path) {
505
- switch (failure) {
506
- case "is-file":
507
- return {
508
- headline: "That's a file, not a directory.",
509
- hints: [
510
- "Provide the path to your component library's root folder, not a specific file.",
511
- "Example: ~/projects/my-design-system"
512
- ]
513
- };
514
- case "not-found":
515
- return {
516
- headline: `Directory not found: ${path}`,
517
- hints: ["Double-check the path and try again. Tip: you can use ~, relative, or absolute paths."]
518
- };
519
- case "permission-denied":
520
- return {
521
- headline: `Permission denied: ${path}`,
522
- hints: ["You don't have read access to this directory."]
523
- };
524
- case "not-directory":
525
- return { headline: `Not a directory: ${path}`, hints: [] };
526
- case "unreadable":
527
- return { headline: `Cannot access: ${path}`, hints: [] };
2464
+ function defaultSleep(delayMs) {
2465
+ return new Promise((resolve2) => setTimeout(resolve2, delayMs));
2466
+ }
2467
+
2468
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/sanitize-preview.js
2469
+ var PROPERTY_BREAKING_REASONS = /* @__PURE__ */ new Set([
2470
+ "removed",
2471
+ "added_required_no_default",
2472
+ "type_changed",
2473
+ "validation_narrowed"
2474
+ ]);
2475
+ var SLOT_BREAKING_REASONS = /* @__PURE__ */ new Set(["slot_removed", "slot_allowed_components_narrowed"]);
2476
+ function sanitizeBreakingChanges(raw) {
2477
+ if (!Array.isArray(raw))
2478
+ return [];
2479
+ const out = [];
2480
+ for (const bc of raw) {
2481
+ if (typeof bc !== "object" || bc === null)
2482
+ continue;
2483
+ const reason = bc.reason;
2484
+ if (typeof reason !== "string")
2485
+ continue;
2486
+ if ("propertyId" in bc && typeof bc.propertyId === "string") {
2487
+ if (PROPERTY_BREAKING_REASONS.has(reason))
2488
+ out.push(bc);
2489
+ continue;
2490
+ }
2491
+ if ("slotId" in bc && typeof bc.slotId === "string") {
2492
+ if (SLOT_BREAKING_REASONS.has(reason))
2493
+ out.push(bc);
2494
+ continue;
2495
+ }
528
2496
  }
2497
+ return out;
529
2498
  }
530
- function summarize(counts) {
531
- const rows = ROW_ORDER.filter((category) => counts[category] > 0).map((category) => {
532
- const tone = category === "json" ? "accent" : category === "other" ? "muted" : "default";
533
- return { label: ROW_LABELS[category], count: counts[category], tone };
534
- });
535
- const componentFiles = COMPONENT_CATEGORIES.reduce((sum, category) => sum + counts[category], 0);
536
- if (componentFiles > 0) return { total: counts.total, rows };
537
- if (counts.json > 0) {
538
- return { total: counts.total, rows, warning: "No component files found \u2014 only token files detected." };
2499
+ function sanitizePreviewResponse(res) {
2500
+ for (const item of res.components?.changed ?? []) {
2501
+ const cc = item.changeClassification;
2502
+ if (cc && Array.isArray(cc.breakingChanges)) {
2503
+ cc.breakingChanges = sanitizeBreakingChanges(cc.breakingChanges);
2504
+ }
539
2505
  }
540
- return {
541
- total: counts.total,
542
- rows,
543
- warning: "No component or token files found. Try a different path."
544
- };
2506
+ return res;
545
2507
  }
546
- function phaseOf(scan) {
547
- if (scan === void 0) return "scanning";
548
- return scan.ok ? "ready" : "failed";
2508
+
2509
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/host-utils.js
2510
+ var DEFAULT_API_HOST = "https://api.contentful.com";
2511
+ function trimTrailingSlashes(value) {
2512
+ return value.replace(/\/+$/, "");
549
2513
  }
550
- function keyAction(phase, input, key) {
551
- if (key.escape) return "back";
552
- if (phase === "ready") {
553
- if (key.return) return "confirm";
554
- if (input === "e") return "change-path";
555
- }
556
- if (phase === "failed" && (key.return || input === "e")) return "change-path";
557
- return void 0;
2514
+ function normalizeHostInput(host) {
2515
+ const value = host?.trim();
2516
+ if (!value)
2517
+ return void 0;
2518
+ return trimTrailingSlashes(value);
2519
+ }
2520
+ function toConfiguredHost2(host) {
2521
+ const normalized = normalizeHostInput(host);
2522
+ if (!normalized)
2523
+ return void 0;
2524
+ return normalized.replace(/^https:\/\//i, "");
2525
+ }
2526
+ function toApiHost2(host) {
2527
+ const normalized = normalizeHostInput(host);
2528
+ if (!normalized)
2529
+ return DEFAULT_API_HOST;
2530
+ if (/^[a-z][a-z\d+\-.]*:\/\//i.test(normalized))
2531
+ return normalized;
2532
+ return `https://${normalized}`;
558
2533
  }
559
2534
 
560
- // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/controls.ts
561
- var CONTROLS = {
562
- scanning: [{ keys: "Esc", label: "Back" }],
563
- ready: [
564
- { keys: "Enter", label: "Yes, continue" },
565
- { keys: "e", label: "Change path" },
566
- { keys: "Esc", label: "Back" }
567
- ],
568
- failed: [
569
- { keys: "Enter/e", label: "Try a different path" },
570
- { keys: "Esc", label: "Back" }
571
- ]
2535
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/types/api-error.js
2536
+ var ERROR_BODY_LOG_CAP = 16384;
2537
+ var ApiError = class extends Error {
2538
+ status;
2539
+ body;
2540
+ guidance;
2541
+ constructor(message, status, body, guidance) {
2542
+ super(message);
2543
+ this.status = status;
2544
+ this.body = body;
2545
+ this.guidance = guidance;
2546
+ if (body) {
2547
+ const trimmed = body.length > ERROR_BODY_LOG_CAP ? body.slice(0, ERROR_BODY_LOG_CAP) + "\u2026" : body;
2548
+ this.message = `${message}
2549
+ ${trimmed}`;
2550
+ }
2551
+ }
572
2552
  };
573
- function controlsFor(phase) {
574
- return CONTROLS[phase];
575
- }
576
- function usePathValidationControls(phase, handlers) {
577
- useInput5((input, key) => {
578
- const action = keyAction(phase, input, key);
579
- if (action === "confirm") handlers.onConfirm();
580
- else if (action === "change-path") handlers.onChangePath();
581
- else if (action === "back") handlers.onBack();
582
- });
2553
+
2554
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/api-client/api-client.js
2555
+ var ApiClient = class {
2556
+ host;
2557
+ token;
2558
+ spaceId;
2559
+ environmentId;
2560
+ retry;
2561
+ lastRequestId;
2562
+ constructor(opts) {
2563
+ this.host = toApiHost2(opts.host);
2564
+ this.token = opts.cmaToken;
2565
+ this.spaceId = opts.spaceId;
2566
+ this.environmentId = opts.environmentId;
2567
+ const initialDelayMs = Math.max(0, opts.retry?.initialDelayMs ?? 250);
2568
+ this.retry = {
2569
+ maxAttempts: Math.max(1, Math.floor(opts.retry?.maxAttempts ?? 3)),
2570
+ initialDelayMs,
2571
+ maxDelayMs: Math.max(initialDelayMs, opts.retry?.maxDelayMs ?? 2e3),
2572
+ sleep: opts.retry?.sleep ?? defaultSleep
2573
+ };
2574
+ }
2575
+ getLastRequestId() {
2576
+ return this.lastRequestId;
2577
+ }
2578
+ noteRequestId(response) {
2579
+ const id = response.headers.get("x-contentful-request-id");
2580
+ if (id)
2581
+ this.lastRequestId = id;
2582
+ }
2583
+ headers() {
2584
+ return {
2585
+ Authorization: `Bearer ${this.token}`,
2586
+ "Content-Type": "application/json",
2587
+ "X-Contentful-User-Agent": USER_AGENT
2588
+ };
2589
+ }
2590
+ async requestWithRetry(phase, errorPrefix, makeCall) {
2591
+ for (let attempt = 1; attempt <= this.retry.maxAttempts; attempt++) {
2592
+ let result;
2593
+ try {
2594
+ result = await makeCall();
2595
+ } catch (error) {
2596
+ if (attempt === this.retry.maxAttempts) {
2597
+ const body = `The request failed after ${attempt} attempts because of a network error: ${errorMessage(error)}. Check your connection and try again.`;
2598
+ throw new ApiError(`${errorPrefix} 0`, 0, body);
2599
+ }
2600
+ await this.retry.sleep(Math.min(this.retry.initialDelayMs * 2 ** (attempt - 1), this.retry.maxDelayMs));
2601
+ continue;
2602
+ }
2603
+ if (!isTransientStatus(result.response.status)) {
2604
+ this.noteRequestId(result.response);
2605
+ return result;
2606
+ }
2607
+ if (attempt === this.retry.maxAttempts) {
2608
+ const body = stringifyError(result.error);
2609
+ const guidance = `The ${phase} request failed after ${attempt} attempts because the service remained unavailable. Wait a moment and try again.`;
2610
+ throw new ApiError(`${errorPrefix} ${result.response.status}`, result.response.status, body, guidance);
2611
+ }
2612
+ const backoffMs = Math.min(this.retry.initialDelayMs * 2 ** (attempt - 1), this.retry.maxDelayMs);
2613
+ await this.retry.sleep(retryAfterMs(result.response) ?? backoffMs);
2614
+ }
2615
+ throw new Error("Retry attempts exhausted");
2616
+ }
2617
+ async validateToken() {
2618
+ const res = await fetch(`${this.host}/users/me`, { headers: this.headers() });
2619
+ this.noteRequestId(res);
2620
+ if (res.status === 401) {
2621
+ throw new ApiError("CMA token is invalid or revoked", res.status, await res.text());
2622
+ }
2623
+ if (!res.ok) {
2624
+ throw new ApiError(`unexpected error validating token: ${res.status}`, res.status, await res.text());
2625
+ }
2626
+ await this.checkPreflight();
2627
+ }
2628
+ async checkPreflight() {
2629
+ const url = `${this.host}/spaces/${this.spaceId}/environments/${this.environmentId}/design_systems/preflight`;
2630
+ let res;
2631
+ try {
2632
+ res = await fetch(url, { headers: this.headers() });
2633
+ } catch {
2634
+ return;
2635
+ }
2636
+ this.noteRequestId(res);
2637
+ if (res.ok)
2638
+ return;
2639
+ if (res.status >= 500)
2640
+ return;
2641
+ const body = await res.text();
2642
+ if (res.status === 404 && !isApsDenialBody(body))
2643
+ return;
2644
+ throw new ApiError(`preflight failed: ${res.status}`, res.status, body);
2645
+ }
2646
+ async previewImport(cdf) {
2647
+ const result = await this.requestWithRetry("preview", PREVIEW_ERROR_PREFIX, () => designSystemImportSourcelessPreview({
2648
+ baseUrl: this.host,
2649
+ headers: this.headers(),
2650
+ path: { spaceId: this.spaceId, environmentId: this.environmentId },
2651
+ body: cdf,
2652
+ parseAs: "json"
2653
+ }));
2654
+ if (!result.response.ok) {
2655
+ throw new ApiError(`${PREVIEW_ERROR_PREFIX} ${result.response.status}`, result.response.status, stringifyError(result.error));
2656
+ }
2657
+ return sanitizePreviewResponse(result.data);
2658
+ }
2659
+ async applyImport(cdf, opts) {
2660
+ let result;
2661
+ try {
2662
+ result = await designSystemImportApply({
2663
+ baseUrl: this.host,
2664
+ headers: this.headers(),
2665
+ path: { spaceId: this.spaceId, environmentId: this.environmentId },
2666
+ body: { ...cdf, acknowledgeBreakingChanges: opts.acknowledgeBreakingChanges },
2667
+ parseAs: "json"
2668
+ });
2669
+ } catch (error) {
2670
+ const body = `The apply request was not retried because its outcome is unknown and retrying could start a duplicate operation. Cause: ${errorMessage(error)}`;
2671
+ throw new ApiError(`${APPLY_ERROR_PREFIX} 0`, 0, body);
2672
+ }
2673
+ if (!result.response.ok) {
2674
+ const body = stringifyError(result.error);
2675
+ const guidance = isTransientStatus(result.response.status) ? "The apply request was not retried because the server may already have started an operation and retrying could create a duplicate." : void 0;
2676
+ throw new ApiError(`${APPLY_ERROR_PREFIX} ${result.response.status}`, result.response.status, body, guidance);
2677
+ }
2678
+ this.noteRequestId(result.response);
2679
+ return result.data;
2680
+ }
2681
+ async pollOperation(operationId, opts = {}) {
2682
+ const intervalMs = opts.intervalMs ?? 2e3;
2683
+ const maxIntervalMs = opts.maxIntervalMs ?? Math.round(intervalMs * 2.5);
2684
+ const maxAttempts = opts.maxAttempts ?? 150;
2685
+ const terminalStatuses = /* @__PURE__ */ new Set(["succeeded", "partial", "failed"]);
2686
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
2687
+ const result = await this.requestWithRetry("poll", "poll failed:", () => designSystemImportGetOperation({
2688
+ baseUrl: this.host,
2689
+ headers: this.headers(),
2690
+ path: { spaceId: this.spaceId, environmentId: this.environmentId, operationId },
2691
+ parseAs: "json"
2692
+ }));
2693
+ if (!result.response.ok) {
2694
+ throw new ApiError(`poll failed: ${result.response.status}`, result.response.status, stringifyError(result.error));
2695
+ }
2696
+ const op = result.data;
2697
+ opts.onProgress?.(op);
2698
+ if (terminalStatuses.has(op.sys.status))
2699
+ return op;
2700
+ if (attempt < maxAttempts - 1) {
2701
+ const progress = maxAttempts > 1 ? attempt / (maxAttempts - 1) : 0;
2702
+ const baseDelay = intervalMs + (maxIntervalMs - intervalMs) * progress;
2703
+ const jitter = Math.random() * baseDelay * 0.15;
2704
+ await new Promise((resolve2) => setTimeout(resolve2, baseDelay + jitter));
2705
+ }
2706
+ }
2707
+ throw new Error(`Operation ${operationId} timed out after ${maxAttempts} attempts`);
2708
+ }
2709
+ };
2710
+
2711
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/controller/validation/assert-no-unresolved-slot-references.js
2712
+ init_shared();
2713
+
2714
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/parse-binding-diagnostics.js
2715
+ function parseBindingDiagnostics(body) {
2716
+ if (!/binding configurations are invalid|Pointer path does not exist/i.test(body))
2717
+ return null;
2718
+ const locationMatches = [...body.matchAll(/(?:^|\.\s)([A-Za-z0-9_$-]+(?:\s*›\s*[A-Za-z0-9_$-]+){2,})/g)];
2719
+ const location = locationMatches.at(-1)?.[1];
2720
+ const pointerMessage = body.match(/Pointer path does not exist for '\[object Object\]':\s*(.+?)(?=\.\s*Default\s*›|$)/i)?.[1];
2721
+ const graphQlMessage = body.match(/return GraphQL validation error:\s*(.+?)(?=\.\s*Default\s*›|$)/i)?.[1];
2722
+ const heading = body.match(/^(.*?)(?=\.?\s*Pointer path does not exist|\.?\s*Default\s*›)/i)?.[1]?.trim();
2723
+ const diagnostics = [];
2724
+ if (pointerMessage)
2725
+ diagnostics.push({ message: pointerMessage.trim(), ...location ? { path: location } : {} });
2726
+ if (graphQlMessage)
2727
+ diagnostics.push({ message: graphQlMessage.trim(), ...location ? { path: location } : {} });
2728
+ return {
2729
+ code: "BindingValidationFailed",
2730
+ message: heading || "One or more binding configurations are invalid.",
2731
+ ...diagnostics.length > 0 ? { diagnostics } : {}
2732
+ };
583
2733
  }
584
2734
 
585
- // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/loader.ts
586
- import { readdir, stat } from "node:fs/promises";
587
- import { join as join3 } from "node:path";
588
- async function isFile(path) {
2735
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/helpers.js
2736
+ function asRecord(value) {
2737
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
2738
+ }
2739
+ function displayValue(value) {
2740
+ if (typeof value === "string")
2741
+ return value;
2742
+ if (typeof value === "number" || typeof value === "boolean")
2743
+ return String(value);
2744
+ if (value === null || value === void 0)
2745
+ return null;
589
2746
  try {
590
- return (await stat(path)).isFile();
2747
+ return JSON.stringify(value);
591
2748
  } catch {
592
- return false;
2749
+ return null;
2750
+ }
2751
+ }
2752
+ function isPathSegment(value) {
2753
+ return typeof value === "string" || typeof value === "number" && Number.isFinite(value);
2754
+ }
2755
+ function formatPath(value) {
2756
+ if (isPathSegment(value))
2757
+ return String(value) ? { path: String(value) } : { path: null };
2758
+ if (Array.isArray(value)) {
2759
+ const parts = value.filter(isPathSegment);
2760
+ return parts.length > 0 ? { path: parts.join(" \u203A ") } : { path: null };
2761
+ }
2762
+ return {};
2763
+ }
2764
+ function componentFromPath(path5) {
2765
+ if (!path5)
2766
+ return void 0;
2767
+ const manifestMatch = path5.match(/manifest:components\/([^/›]+)/);
2768
+ if (manifestMatch?.[1])
2769
+ return manifestMatch[1];
2770
+ const parts = path5.split(/[›/]/).map((part) => part.trim()).filter(Boolean);
2771
+ const componentsIndex = parts.findIndex((part) => part === "components");
2772
+ return componentsIndex === -1 ? void 0 : parts[componentsIndex + 1];
2773
+ }
2774
+ function diagnosticMessage(error) {
2775
+ const candidates = [
2776
+ ["message", error.message],
2777
+ ["details", error.details],
2778
+ ["error", error.error],
2779
+ ["name", error.name]
2780
+ ];
2781
+ for (const [messageSource, value] of candidates) {
2782
+ const message = displayValue(value);
2783
+ if (message !== null)
2784
+ return { message, messageSource };
2785
+ }
2786
+ return { message: "Validation failed" };
2787
+ }
2788
+ function parseObjectLiteralTail(body) {
2789
+ const braceStart = body.lastIndexOf("{");
2790
+ if (braceStart === -1)
2791
+ return null;
2792
+ const tail = body.slice(braceStart);
2793
+ const codeMatch = tail.match(/code:\s*['"]([^'"]+)['"]/);
2794
+ const cycleMatch = tail.match(/cycle:\s*\[\s*([^\]]*)\s*\]/);
2795
+ if (!codeMatch && !cycleMatch)
2796
+ return null;
2797
+ const code = codeMatch ? codeMatch[1] : null;
2798
+ let cycle = null;
2799
+ if (cycleMatch) {
2800
+ cycle = cycleMatch[1].split(",").map((s) => s.trim().replace(/^['"]|['"]$/g, "")).filter((s) => s.length > 0);
2801
+ if (cycle.length === 0)
2802
+ cycle = null;
593
2803
  }
2804
+ return { code, cycle };
594
2805
  }
595
- async function countEntry(directory, entry) {
596
- const path = join3(directory, entry.name);
597
- if (entry.isDirectory()) return countFiles(path);
598
- if (entry.isFile() || entry.isSymbolicLink() && await isFile(path)) return addFile(emptyCounts(), entry.name);
599
- return emptyCounts();
2806
+
2807
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/parse-json-body.js
2808
+ function parseValidationDiagnostics(details) {
2809
+ if (!Array.isArray(details.errors))
2810
+ return [];
2811
+ const diagnostics = [];
2812
+ for (const rawError of details.errors) {
2813
+ const error = asRecord(rawError);
2814
+ if (!error)
2815
+ continue;
2816
+ const location = formatPath(error.path);
2817
+ const component = displayValue(error.component ?? error.componentName ?? error.componentId) ?? componentFromPath(location.path);
2818
+ diagnostics.push({ ...diagnosticMessage(error), ...location, ...component ? { component } : {} });
2819
+ }
2820
+ return diagnostics;
600
2821
  }
601
- async function countFiles(directory) {
602
- let entries;
2822
+ function parseJsonBody(body) {
2823
+ let parsed;
603
2824
  try {
604
- entries = await readdir(directory, { withFileTypes: true });
2825
+ parsed = JSON.parse(body);
605
2826
  } catch {
606
- return emptyCounts();
2827
+ return null;
607
2828
  }
608
- const counts = await Promise.all(
609
- entries.filter((entry) => !IGNORED_DIRECTORIES.has(entry.name)).map((entry) => countEntry(directory, entry))
610
- );
611
- return counts.reduce(mergeCounts, emptyCounts());
2829
+ const p = asRecord(parsed);
2830
+ if (!p)
2831
+ return null;
2832
+ const details = asRecord(p.details) ?? {};
2833
+ const pick = (k) => p[k] !== void 0 ? p[k] : details[k];
2834
+ const codeRaw = pick("code") ?? asRecord(p.sys)?.id;
2835
+ const messageRaw = pick("message");
2836
+ const cycleRaw = pick("cycle");
2837
+ const out = {};
2838
+ if (typeof codeRaw === "string")
2839
+ out.code = codeRaw;
2840
+ if (typeof messageRaw === "string")
2841
+ out.message = messageRaw;
2842
+ if (Array.isArray(cycleRaw)) {
2843
+ const strs = cycleRaw.filter((x) => typeof x === "string");
2844
+ if (strs.length > 0)
2845
+ out.cycle = strs;
2846
+ }
2847
+ const diagnostics = parseValidationDiagnostics(details);
2848
+ if (diagnostics.length > 0)
2849
+ out.diagnostics = diagnostics;
2850
+ return out;
612
2851
  }
613
- async function scanProject(directory) {
614
- try {
615
- const stats = await stat(directory);
616
- if (stats.isFile()) return { ok: false, failure: "is-file" };
617
- if (!stats.isDirectory()) return { ok: false, failure: "not-directory" };
618
- } catch (error) {
619
- return { ok: false, failure: failureFromErrorCode(error.code) };
2852
+
2853
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/strip-lambda-log-prefix.js
2854
+ var LAMBDA_LOG_PREFIX_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\s+[0-9a-f-]+\s+ERROR\s+(?:\[dd\.[^\]]*\]\s*)?/;
2855
+ var DD_TAG_RE = /\[dd\.(?:trace_id|span_id)=[^\]]*\]\s*/g;
2856
+ function stripLambdaLogPrefix(body) {
2857
+ return body.replace(LAMBDA_LOG_PREFIX_RE, "").replace(DD_TAG_RE, "").trim();
2858
+ }
2859
+
2860
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/parse-edsi-error.js
2861
+ var API_ERROR_PREFIX_RE = /^(?:apply|preview|poll) failed: \d+$/;
2862
+ function parseEdsiError(rawInput) {
2863
+ if (!rawInput)
2864
+ return { code: null, message: "", cycle: null, raw: true };
2865
+ const { body, prefix } = splitPhasePrefix(rawInput);
2866
+ const cleaned = stripLambdaLogPrefix(body);
2867
+ const json = parseJsonBody(cleaned) ?? parseJsonBody(body);
2868
+ const bindingFromJson = typeof json?.message === "string" ? parseBindingDiagnostics(json.message) : null;
2869
+ if (bindingFromJson) {
2870
+ return {
2871
+ code: bindingFromJson.code ?? json?.code ?? null,
2872
+ message: bindingFromJson.message ?? cleaned,
2873
+ cycle: null,
2874
+ raw: false,
2875
+ ...bindingFromJson.diagnostics ? { diagnostics: bindingFromJson.diagnostics } : {}
2876
+ };
2877
+ }
2878
+ if (json && (json.code || json.message || json.cycle)) {
2879
+ return {
2880
+ code: json.code ?? null,
2881
+ message: json.message ?? (cleaned || prefix),
2882
+ cycle: json.cycle ?? null,
2883
+ raw: false,
2884
+ ...json.diagnostics ? { diagnostics: json.diagnostics } : {}
2885
+ };
2886
+ }
2887
+ const binding = parseBindingDiagnostics(cleaned);
2888
+ if (binding) {
2889
+ return {
2890
+ code: binding.code ?? null,
2891
+ message: binding.message ?? cleaned,
2892
+ cycle: null,
2893
+ raw: false,
2894
+ ...binding.diagnostics ? { diagnostics: binding.diagnostics } : {}
2895
+ };
620
2896
  }
621
- return { ok: true, counts: await countFiles(directory) };
2897
+ const literal2 = parseObjectLiteralTail(cleaned);
2898
+ if (literal2 && (literal2.code || literal2.cycle)) {
2899
+ const braceStart = cleaned.lastIndexOf("{");
2900
+ const head = braceStart === -1 ? cleaned : cleaned.slice(0, braceStart).trim();
2901
+ return { code: literal2.code ?? null, message: head || cleaned, cycle: literal2.cycle ?? null, raw: false };
2902
+ }
2903
+ return { code: null, message: cleaned || prefix || rawInput, cycle: null, raw: true };
2904
+ }
2905
+ function splitPhasePrefix(input) {
2906
+ const nlIndex = input.indexOf("\n");
2907
+ if (nlIndex === -1)
2908
+ return { body: input, prefix: "" };
2909
+ const firstLine = input.slice(0, nlIndex);
2910
+ if (!API_ERROR_PREFIX_RE.test(firstLine))
2911
+ return { body: input, prefix: "" };
2912
+ return { body: input.slice(nlIndex + 1), prefix: firstLine };
2913
+ }
2914
+
2915
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/format-parsed-edsi-error.js
2916
+ function formatParsedEdsiError(parsed, opts = {}) {
2917
+ const lines = [];
2918
+ if (parsed.code)
2919
+ lines.push(`[${parsed.code}]`);
2920
+ if (parsed.message)
2921
+ lines.push(parsed.message);
2922
+ for (const diagnostic of parsed.diagnostics ?? []) {
2923
+ const context = [
2924
+ diagnostic.component ? `Component: ${diagnostic.component}` : null,
2925
+ diagnostic.path ? `Path: ${diagnostic.path}` : null
2926
+ ].filter(Boolean);
2927
+ lines.push(`- ${diagnostic.message}${context.length > 0 ? ` (${context.join("; ")})` : ""}`);
2928
+ if (diagnostic.path === null) {
2929
+ lines.push(" Location: not provided by the server. Review the submitted CDF file; no component or field was identified.");
2930
+ }
2931
+ if (opts.verbose && diagnostic.messageSource) {
2932
+ lines.push(` Message field: ${diagnostic.messageSource}`);
2933
+ }
2934
+ }
2935
+ if (parsed.code === "BindingValidationFailed") {
2936
+ const location = parsed.diagnostics?.find((d) => d.path)?.path;
2937
+ lines.push(location ? `Next action: review the binding at ${location} and correct its pointer or GraphQL selection.` : "Next action: review the binding pointer and GraphQL selection.");
2938
+ }
2939
+ if (parsed.code === "AccessDenied") {
2940
+ lines.push("Next action: this operation requires DesignToken and Component permissions in this environment. Ask a Contentful admin to grant both on your role.");
2941
+ }
2942
+ if (parsed.code === "NotFound") {
2943
+ lines.push("Next action: verify the resource id is correct. If it should exist, your role may lack read permission on DesignToken or Component.");
2944
+ }
2945
+ if (parsed.cycle && parsed.cycle.length > 0) {
2946
+ lines.push(`Cycle: ${parsed.cycle.join(" \u2192 ")} \u2192 ${parsed.cycle[0]}`);
2947
+ lines.push("Break the cycle by removing at least one $allowedComponents entry.");
2948
+ }
2949
+ if (opts.verbose && opts.raw) {
2950
+ lines.push("");
2951
+ lines.push("--- raw ---");
2952
+ lines.push(opts.raw);
2953
+ }
2954
+ return lines.filter(Boolean).join("\n");
2955
+ }
2956
+
2957
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/format-edsi-error.js
2958
+ function formatEdsiError(raw, opts = {}) {
2959
+ const input = typeof raw === "string" ? raw : displayValue(raw);
2960
+ if (!input)
2961
+ return "";
2962
+ return formatParsedEdsiError(parseEdsiError(input), { ...opts, raw: opts.raw ?? input });
2963
+ }
2964
+
2965
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/edsi-errors/format-api-error.js
2966
+ function formatApiError(error, verbose = false) {
2967
+ const formatted = formatEdsiError(error.body || error.message, { verbose, raw: error.body }) || error.message;
2968
+ const phase = error.message.split("\n", 1)[0];
2969
+ const withPhase = /^(?:apply|preview|poll) failed: \d+$/.test(phase) && formatted !== phase ? `${phase}
2970
+ ${formatted}` : formatted;
2971
+ return error.guidance ? `${withPhase}
2972
+ ${error.guidance}` : withPhase;
2973
+ }
2974
+
2975
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/controller/errors/format-api-error.js
2976
+ function formatApiError2(request) {
2977
+ return formatApiError(request.error, request.verbose ?? false);
2978
+ }
2979
+
2980
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/helpers/tokens/read-tokens-from-path.js
2981
+ init_shared();
2982
+
2983
+ // packages/experience-design-system-backend-pipeline/dist/src/index.js
2984
+ init_agents();
2985
+
2986
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/client/build-contentful-management-client.js
2987
+ import { createClient as createClient2 } from "contentful-management";
2988
+
2989
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/existing-entities/fetch-from-contentful.js
2990
+ import { fetchAll } from "contentful-management";
2991
+
2992
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/apply/src/controller/endpoint/resolve-shared-inputs.js
2993
+ init_validate();
2994
+
2995
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/map-tokens/run-map-tokens.js
2996
+ init_build_prompt();
2997
+ init_create_local_cli_agent_invoker();
2998
+ init_describe_agent_failure();
2999
+ init_resolve_binary();
3000
+ init_resolve_skill_path();
3001
+ init_parse_map_token_prop_tool_calls();
3002
+ init_cache_keys();
3003
+
3004
+ // packages/experience-design-system-backend-pipeline/dist/src/agents/helpers/resolution/binary-exists.js
3005
+ import { execFile } from "node:child_process";
3006
+ import { promisify } from "node:util";
3007
+ var execFileAsync = promisify(execFile);
3008
+
3009
+ // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/controller/map-tokens/run-map-tokens.js
3010
+ var DEFAULT_TIMEOUT_MS2 = 5 * 60 * 1e3;
3011
+
3012
+ // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/helpers/scan-files.ts
3013
+ function scanFiles(directory) {
3014
+ return toScanResult(collectFiles(directory));
3015
+ }
3016
+ function toScanResult(outcome) {
3017
+ if (!outcome.ok) return { ok: false, failure: outcome.failure };
3018
+ return {
3019
+ ok: true,
3020
+ counts: foldSvelteAndMdIntoOther(outcome.result.counts),
3021
+ filePaths: outcome.result.filePaths,
3022
+ warnings: outcome.result.warnings
3023
+ };
3024
+ }
3025
+ function foldSvelteAndMdIntoOther(counts) {
3026
+ const { svelte, md, ...rest } = counts;
3027
+ return { ...rest, other: rest.other + svelte + md };
622
3028
  }
623
3029
 
624
3030
  // packages/experience-design-system-cli/src/tui/import/steps/03-path-validation/screen.tsx
@@ -631,8 +3037,8 @@ function Row({ row }) {
631
3037
  row.label
632
3038
  ] });
633
3039
  }
634
- function Failure({ scan, path }) {
635
- const { headline, hints } = describeFailure(scan.failure, path);
3040
+ function Failure({ scan, path: path5 }) {
3041
+ const { headline, hints } = describeFailure(scan.failure, path5);
636
3042
  return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
637
3043
  /* @__PURE__ */ jsxs5(Text6, { color: PALETTE.error, children: [
638
3044
  "\u2717 ",
@@ -641,12 +3047,12 @@ function Failure({ scan, path }) {
641
3047
  hints.map((hint) => /* @__PURE__ */ jsx6(Text6, { dimColor: true, children: hint }, hint))
642
3048
  ] });
643
3049
  }
644
- function Summary({ scan, path }) {
3050
+ function Summary({ scan, path: path5 }) {
645
3051
  const { total, rows, warning } = summarize(scan.counts);
646
3052
  return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", gap: 1, children: [
647
3053
  /* @__PURE__ */ jsxs5(Text6, { children: [
648
3054
  "Scanned ",
649
- /* @__PURE__ */ jsx6(Text6, { bold: true, children: path })
3055
+ /* @__PURE__ */ jsx6(Text6, { bold: true, children: path5 })
650
3056
  ] }),
651
3057
  /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
652
3058
  /* @__PURE__ */ jsxs5(Text6, { color: PALETTE.success, children: [
@@ -672,17 +3078,16 @@ function PathValidationScreen({
672
3078
  const resolvedPath = useMemo(() => resolveUserPath(projectPath), [projectPath]);
673
3079
  const [scan, setScan] = useState5();
674
3080
  useEffect3(() => {
675
- let cancelled = false;
676
- setScan(void 0);
677
- void scanProject(resolvedPath).then((result) => {
678
- if (!cancelled) setScan(result);
679
- });
680
- return () => {
681
- cancelled = true;
682
- };
3081
+ setScan(scanFiles(resolvedPath));
683
3082
  }, [resolvedPath]);
684
3083
  const phase = phaseOf(scan);
685
- usePathValidationControls(phase, { onConfirm: () => onConfirm(resolvedPath), onChangePath, onBack });
3084
+ usePathValidationControls(phase, {
3085
+ onConfirm: () => {
3086
+ if (scan?.ok) onConfirm({ projectPath: resolvedPath, filePaths: scan.filePaths });
3087
+ },
3088
+ onChangePath,
3089
+ onBack
3090
+ });
686
3091
  return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", gap: 1, paddingX: 2, paddingY: 1, children: [
687
3092
  scan === void 0 && /* @__PURE__ */ jsxs5(Text6, { dimColor: true, children: [
688
3093
  "Scanning ",
@@ -710,7 +3115,6 @@ import { useInput as useInput6 } from "ink";
710
3115
 
711
3116
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/logic.ts
712
3117
  var FIELDS = ["spaceId", "environmentId", "cmaToken", "host"];
713
- var DEFAULT_HOST = "api.contentful.com";
714
3118
  function keyAction2(input, key) {
715
3119
  if (key.escape) return "back";
716
3120
  if (key.tab) return "next-field";
@@ -720,21 +3124,12 @@ function keyAction2(input, key) {
720
3124
  function nextField(field) {
721
3125
  return FIELDS[(FIELDS.indexOf(field) + 1) % FIELDS.length];
722
3126
  }
723
- function toConfiguredHost(host) {
724
- const value = (host ?? "").trim().replace(/\/+$/, "");
725
- return value === "" ? DEFAULT_HOST : value.replace(/^https:\/\//i, "");
726
- }
727
- function toApiHost(host) {
728
- const value = host.trim().replace(/\/+$/, "");
729
- if (value === "") return `https://${DEFAULT_HOST}`;
730
- return /^[a-z][a-z\d+\-.]*:\/\//i.test(value) ? value : `https://${value}`;
731
- }
732
3127
  function normalize(values) {
733
3128
  return {
734
3129
  spaceId: values.spaceId.trim(),
735
3130
  environmentId: values.environmentId.trim(),
736
3131
  cmaToken: values.cmaToken.trim(),
737
- host: toConfiguredHost(values.host)
3132
+ host: toConfiguredHost2(values.host) ?? DEFAULT_CONFIGURED_HOST
738
3133
  };
739
3134
  }
740
3135
  function missingField(values) {
@@ -762,59 +3157,30 @@ function useCredentialsControls(handlers) {
762
3157
  }
763
3158
 
764
3159
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/validate.ts
765
- var USER_AGENT = "app contentful.experience-design-system-cli";
766
- function headers(token) {
767
- return { Authorization: `Bearer ${token}`, "X-Contentful-User-Agent": USER_AGENT };
768
- }
769
- function isApsDenial(body) {
770
- try {
771
- const id = JSON.parse(body).sys?.id;
772
- return id === "NotFound" || id === "AccessDenied";
773
- } catch {
774
- return false;
775
- }
776
- }
777
- function messageFrom(body) {
778
- try {
779
- const message = JSON.parse(body).message;
780
- return typeof message === "string" && message !== "" ? message : void 0;
781
- } catch {
782
- return void 0;
783
- }
784
- }
785
3160
  async function validateCredentials(values) {
786
- const base = toApiHost(values.host);
787
- let me;
788
- try {
789
- me = await fetch(`${base}/users/me`, { headers: headers(values.cmaToken) });
790
- } catch (error) {
791
- return { ok: false, error: `Could not reach ${base}: ${error instanceof Error ? error.message : String(error)}` };
792
- }
793
- if (me.status === 401) return { ok: false, error: "CMA token is invalid or revoked." };
794
- if (!me.ok) return { ok: false, error: `Unexpected error validating the token (${me.status}).` };
795
- let preflight;
3161
+ const host = toApiHost2(values.host);
3162
+ const client2 = new ApiClient({
3163
+ host,
3164
+ spaceId: values.spaceId,
3165
+ environmentId: values.environmentId,
3166
+ cmaToken: values.cmaToken
3167
+ });
796
3168
  try {
797
- preflight = await fetch(
798
- `${base}/spaces/${values.spaceId}/environments/${values.environmentId}/design_systems/preflight`,
799
- { headers: headers(values.cmaToken) }
800
- );
801
- } catch {
3169
+ await client2.validateToken();
802
3170
  return { ok: true };
3171
+ } catch (error) {
3172
+ return { ok: false, error: toUserError(error, host) };
803
3173
  }
804
- if (preflight.ok || preflight.status >= 500) return { ok: true };
805
- const body = await preflight.text();
806
- if (preflight.status === 404 && !isApsDenial(body)) return { ok: true };
807
- const detail = messageFrom(body);
808
- if (preflight.status === 403) {
809
- return { ok: false, error: `Access denied. ${detail ?? "Your token cannot write design system components here."}` };
810
- }
811
- if (preflight.status === 404) {
812
- return {
813
- ok: false,
814
- error: `Not found. Check the space ID, environment and API host.${detail ? ` (${detail})` : ""}`
815
- };
3174
+ }
3175
+ function toUserError(error, host) {
3176
+ if (error instanceof ApiError) {
3177
+ if (error.status === 404 && error.message.startsWith("preflight failed:")) {
3178
+ return "Not found. Check the space ID, environment and API host.";
3179
+ }
3180
+ return formatApiError2({ error });
816
3181
  }
817
- return { ok: false, error: `Credential check failed (${preflight.status}).${detail ? ` ${detail}` : ""}` };
3182
+ if (error instanceof Error) return `Could not reach ${host}: ${error.message}`;
3183
+ return String(error);
818
3184
  }
819
3185
 
820
3186
  // packages/experience-design-system-cli/src/tui/import/steps/04-credentials/screen.tsx
@@ -829,7 +3195,7 @@ function CredentialsScreen({
829
3195
  onDone,
830
3196
  onBack,
831
3197
  initial = {},
832
- validate = validateCredentials
3198
+ validate: validate2 = validateCredentials
833
3199
  }) {
834
3200
  const initialValues = useRef(
835
3201
  normalize({
@@ -865,7 +3231,7 @@ function CredentialsScreen({
865
3231
  return;
866
3232
  }
867
3233
  setValidating(true);
868
- const result = await validate(credentials);
3234
+ const result = await validate2(credentials);
869
3235
  setValidating(false);
870
3236
  if (result.ok) onDone({ skipped: false, credentials });
871
3237
  else setError(result.error);
@@ -891,7 +3257,7 @@ function CredentialsScreen({
891
3257
  value: values[field],
892
3258
  focus: active === field && !validating,
893
3259
  mask: field === "cmaToken" ? "\u2022" : void 0,
894
- placeholder: field === "host" ? DEFAULT_HOST : void 0,
3260
+ placeholder: field === "host" ? DEFAULT_CONFIGURED_HOST : void 0,
895
3261
  onChange: change(field),
896
3262
  onSubmit: () => void submit(field)
897
3263
  }
@@ -918,13 +3284,13 @@ import { spawn } from "node:child_process";
918
3284
 
919
3285
  // packages/experience-design-system-cli/src/legacy/legacy-cli-path.ts
920
3286
  import { existsSync as existsSync2 } from "node:fs";
921
- import { join as join4 } from "node:path";
3287
+ import { join as join3 } from "node:path";
922
3288
  var PACKAGE_NAME2 = "@contentful/experience-design-system-cli";
923
3289
  function findLegacyCliPath() {
924
3290
  const root = findPackageRoot(import.meta.url, PACKAGE_NAME2);
925
3291
  const candidates = [
926
- join4(root, "legacy", "bin", "cli.js"),
927
- join4(root, "..", "experience-design-system-cli-legacy", "bin", "cli.js")
3292
+ join3(root, "legacy", "bin", "cli.js"),
3293
+ join3(root, "..", "experience-design-system-cli-legacy", "bin", "cli.js")
928
3294
  ];
929
3295
  const found = candidates.find((candidate) => existsSync2(candidate));
930
3296
  if (!found) {
@@ -935,10 +3301,10 @@ ${candidates.join("\n")}`);
935
3301
  }
936
3302
 
937
3303
  // packages/experience-design-system-cli/src/tui/import/spawn-v1-import.ts
938
- function buildArgs(options) {
3304
+ function buildArgs2(options) {
939
3305
  const args = ["import"];
940
- if (options.project) {
941
- args.push("--project", options.project);
3306
+ if (options.projectPath) {
3307
+ args.push("--project", options.projectPath);
942
3308
  }
943
3309
  if (options.tokens) {
944
3310
  args.push("--tokens", options.tokens);
@@ -947,7 +3313,7 @@ function buildArgs(options) {
947
3313
  }
948
3314
  async function spawnV1Import(options = {}) {
949
3315
  const cliPath = findLegacyCliPath();
950
- const args = buildArgs(options);
3316
+ const args = buildArgs2(options);
951
3317
  return new Promise((resolvePromise) => {
952
3318
  const child = spawn("node", [cliPath, ...args], {
953
3319
  stdio: "inherit",
@@ -986,36 +3352,36 @@ import { Box as Box7, Text as Text8, useInput as useInput7 } from "ink";
986
3352
 
987
3353
  // packages/experience-design-system-cli/src/tui/debug-store.ts
988
3354
  import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
989
- import { existsSync as existsSync3, readdirSync } from "node:fs";
990
- import { join as join6 } from "node:path";
3355
+ import { existsSync as existsSync3, readdirSync as readdirSync2 } from "node:fs";
3356
+ import { join as join5 } from "node:path";
991
3357
 
992
3358
  // packages/experience-design-system-types/dist/src/config/index.js
993
3359
  import { randomBytes } from "node:crypto";
994
3360
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
995
3361
  import { homedir as homedir2 } from "node:os";
996
- import { dirname as dirname2, join as join5 } from "node:path";
997
- function configRoot() {
998
- return process.env["EDS_HOME"] || join5(homedir2(), ".contentful", "experience-design-system-cli");
3362
+ import { dirname as dirname2, join as join4 } from "node:path";
3363
+ function configRoot2() {
3364
+ return process.env["EDS_HOME"] || join4(homedir2(), ".contentful", "experience-design-system-cli");
999
3365
  }
1000
- var configFilePath = () => join5(configRoot(), "config.json");
1001
- var debugSessionsDir = () => join5(configRoot(), "debug", "sessions");
1002
- async function readSettings() {
3366
+ var configFilePath2 = () => join4(configRoot2(), "config.json");
3367
+ var debugSessionsDir2 = () => join4(configRoot2(), "debug", "sessions");
3368
+ async function readSettings2() {
1003
3369
  try {
1004
- return JSON.parse(await readFile(configFilePath(), "utf8"));
3370
+ return JSON.parse(await readFile(configFilePath2(), "utf8"));
1005
3371
  } catch {
1006
3372
  return {};
1007
3373
  }
1008
3374
  }
1009
- async function writeSettings(settings) {
1010
- const path = configFilePath();
1011
- await mkdir(dirname2(path), { recursive: true });
1012
- const tmp = `${path}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
3375
+ async function writeSettings2(settings) {
3376
+ const path5 = configFilePath2();
3377
+ await mkdir(dirname2(path5), { recursive: true });
3378
+ const tmp = `${path5}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
1013
3379
  await writeFile(tmp, `${JSON.stringify(settings, null, 2)}
1014
3380
  `, { mode: 384 });
1015
- await rename(tmp, path);
3381
+ await rename(tmp, path5);
1016
3382
  }
1017
- async function updateSettings(patch) {
1018
- await writeSettings({ ...await readSettings(), ...patch });
3383
+ async function updateSettings2(patch) {
3384
+ await writeSettings2({ ...await readSettings2(), ...patch });
1019
3385
  }
1020
3386
 
1021
3387
  // packages/experience-design-system-cli/src/tui/settings/debug-mode/debug-mode-store.ts
@@ -1023,11 +3389,11 @@ var DEFAULT_DEBUG_MODE_SETTING = {
1023
3389
  enabled: true
1024
3390
  };
1025
3391
  async function readDebugModeSetting() {
1026
- const { debugMode } = await readSettings();
3392
+ const { debugMode } = await readSettings2();
1027
3393
  return { ...DEFAULT_DEBUG_MODE_SETTING, ...debugMode };
1028
3394
  }
1029
3395
  async function writeDebugModeSetting(setting) {
1030
- await updateSettings({ debugMode: setting });
3396
+ await updateSettings2({ debugMode: setting });
1031
3397
  }
1032
3398
 
1033
3399
  // packages/experience-design-system-cli/src/tui/debug-store.ts
@@ -1044,10 +3410,10 @@ function datePrefix(now = /* @__PURE__ */ new Date()) {
1044
3410
  function slugify(value) {
1045
3411
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
1046
3412
  }
1047
- function generateSessionId() {
3413
+ function generateSessionId3() {
1048
3414
  const today = datePrefix();
1049
- const root = debugSessionsDir();
1050
- const existing = existsSync3(root) ? readdirSync(root) : [];
3415
+ const root = debugSessionsDir2();
3416
+ const existing = existsSync3(root) ? readdirSync2(root) : [];
1051
3417
  const seqPattern = new RegExp(`^${today}-session-(\\d+)$`);
1052
3418
  const maxSeq = existing.reduce((max, entry) => {
1053
3419
  const match = seqPattern.exec(entry);
@@ -1055,9 +3421,9 @@ function generateSessionId() {
1055
3421
  }, 0);
1056
3422
  return `${today}-session-${maxSeq + 1}`;
1057
3423
  }
1058
- var SESSION_ID = generateSessionId();
3424
+ var SESSION_ID = generateSessionId3();
1059
3425
  function sessionDebugDir() {
1060
- return join6(debugSessionsDir(), SESSION_ID);
3426
+ return join5(debugSessionsDir2(), SESSION_ID);
1061
3427
  }
1062
3428
  function currentDebugSessionDir() {
1063
3429
  return sessionDebugDir();
@@ -1106,15 +3472,15 @@ async function finishDebugRun({
1106
3472
  const durationMs = Date.now() - run.startedAt;
1107
3473
  const content = renderMarkdown(run, { outputs: redact(outputs), status, exitMethod, durationMs });
1108
3474
  const flowSegments = run.flow.split("/");
1109
- const dir = join6(sessionDebugDir(), ...flowSegments);
3475
+ const dir = join5(sessionDebugDir(), ...flowSegments);
1110
3476
  await mkdir2(dir, { recursive: true });
1111
3477
  const filename = nextAttemptFilename(dir, run.menuOption);
1112
- await writeFile2(join6(dir, filename), content, { mode: 384 });
3478
+ await writeFile2(join5(dir, filename), content, { mode: 384 });
1113
3479
  }
1114
3480
  function nextAttemptFilename(dir, menuOption) {
1115
3481
  const today = datePrefix();
1116
3482
  const optionSlug = slugify(menuOption);
1117
- const existing = existsSync3(dir) ? readdirSync(dir) : [];
3483
+ const existing = existsSync3(dir) ? readdirSync2(dir) : [];
1118
3484
  const attemptPattern = new RegExp(`^${today}-${optionSlug}-attempt-(\\d+)\\.md$`);
1119
3485
  const maxAttempt = existing.reduce((max, entry) => {
1120
3486
  const match = attemptPattern.exec(entry);
@@ -1174,9 +3540,9 @@ async function readHelpInfo() {
1174
3540
  const debugMode = await readDebugModeSetting();
1175
3541
  return {
1176
3542
  storage: [
1177
- { label: "Config folder", value: configRoot() },
1178
- { label: "Settings file", value: configFilePath() },
1179
- { label: "Debug logs", value: debugSessionsDir() }
3543
+ { label: "Config folder", value: configRoot2() },
3544
+ { label: "Settings file", value: configFilePath2() },
3545
+ { label: "Debug logs", value: debugSessionsDir2() }
1180
3546
  ],
1181
3547
  troubleshooting: [
1182
3548
  { label: "CLI version", value: readPackageVersion() },
@@ -1302,8 +3668,8 @@ import { Box as Box9, Text as Text10, useInput as useInput9 } from "ink";
1302
3668
  import TextInput4 from "ink-text-input";
1303
3669
 
1304
3670
  // packages/experience-design-system-cli/src/tui/settings/utils/v1-store.ts
1305
- var readV1Store = readSettings;
1306
- var writeV1Store = writeSettings;
3671
+ var readV1Store = readSettings2;
3672
+ var writeV1Store = writeSettings2;
1307
3673
 
1308
3674
  // packages/experience-design-system-cli/src/tui/settings/contentful-configuration/config-store.ts
1309
3675
  async function readCredentials() {
@@ -1712,7 +4078,7 @@ function App({ onLaunchImport, importExitCode }) {
1712
4078
  const [showImportResult, setShowImportResult] = useState13(returnedFromImport);
1713
4079
  const [projectPath, setProjectPath] = useState13();
1714
4080
  const [tokensPath, setTokensPath] = useState13();
1715
- const [pathConfirmed, setPathConfirmed] = useState13(false);
4081
+ const [scannedFiles, setScannedFiles] = useState13();
1716
4082
  const [importDefaults, setImportDefaults] = useState13();
1717
4083
  useEffect9(() => {
1718
4084
  if (screen !== "import") {
@@ -1727,16 +4093,16 @@ function App({ onLaunchImport, importExitCode }) {
1727
4093
  })
1728
4094
  );
1729
4095
  }, [screen]);
1730
- const finishCredentials = async (result, project, tokens) => {
4096
+ const finishCredentials = async (result, projectPath2, tokens, filePaths) => {
1731
4097
  if (!result.skipped) await writeCredentials({ ...result.credentials });
1732
- onLaunchImport?.({ project, tokens, skipCredentials: result.skipped });
4098
+ onLaunchImport?.({ projectPath: projectPath2, tokens, filePaths, skipCredentials: result.skipped });
1733
4099
  };
1734
4100
  const goToStart = () => setScreen("start");
1735
4101
  const goToSettings = () => setScreen("settings");
1736
4102
  const resetImport = () => {
1737
4103
  setProjectPath(void 0);
1738
4104
  setTokensPath(void 0);
1739
- setPathConfirmed(false);
4105
+ setScannedFiles(void 0);
1740
4106
  };
1741
4107
  const finishImportResult = () => {
1742
4108
  setShowImportResult(false);
@@ -1764,12 +4130,12 @@ function App({ onLaunchImport, importExitCode }) {
1764
4130
  }
1765
4131
  );
1766
4132
  }
1767
- if (!pathConfirmed) {
4133
+ if (scannedFiles === void 0) {
1768
4134
  return /* @__PURE__ */ jsx14(
1769
4135
  PathValidationScreen,
1770
4136
  {
1771
4137
  projectPath,
1772
- onConfirm: () => setPathConfirmed(true),
4138
+ onConfirm: ({ filePaths }) => setScannedFiles(filePaths),
1773
4139
  onChangePath: resetImport,
1774
4140
  onBack: () => setTokensPath(void 0)
1775
4141
  }
@@ -1779,8 +4145,8 @@ function App({ onLaunchImport, importExitCode }) {
1779
4145
  CredentialsScreen,
1780
4146
  {
1781
4147
  initial: importDefaults.credentials,
1782
- onBack: () => setPathConfirmed(false),
1783
- onDone: (result) => void finishCredentials(result, projectPath, tokensPath)
4148
+ onBack: () => setScannedFiles(void 0),
4149
+ onDone: (result) => void finishCredentials(result, projectPath, tokensPath, scannedFiles)
1784
4150
  }
1785
4151
  );
1786
4152
  case "help":