@contentful/experience-design-system-cli 2.26.7-dev-build-245a014.0 → 2.26.7-dev-build-6d2ed6d.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +1 -1
- package/dist/src/index.js +47 -37
- package/package.json +5 -5
package/dist/package.json
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -23,23 +23,59 @@ var init_agent_names = __esm({
|
|
|
23
23
|
|
|
24
24
|
// packages/experience-design-system-generation/dist/src/agent-runner.js
|
|
25
25
|
import { spawn } from "node:child_process";
|
|
26
|
-
function
|
|
27
|
-
|
|
26
|
+
function findJsonObjectEnd(line) {
|
|
27
|
+
let depth = 0;
|
|
28
|
+
let inString = false;
|
|
29
|
+
let escaped = false;
|
|
30
|
+
for (let i = 0; i < line.length; i++) {
|
|
31
|
+
const ch = line[i];
|
|
32
|
+
if (escaped) {
|
|
33
|
+
escaped = false;
|
|
34
|
+
} else if (ch === "\\" && inString) {
|
|
35
|
+
escaped = true;
|
|
36
|
+
} else if (ch === '"') {
|
|
37
|
+
inString = !inString;
|
|
38
|
+
} else if (!inString && ch === "{") {
|
|
39
|
+
depth++;
|
|
40
|
+
} else if (!inString && ch === "}" && --depth === 0) {
|
|
41
|
+
return i;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return -1;
|
|
45
|
+
}
|
|
46
|
+
function readToolCallObjects(stdout) {
|
|
47
|
+
const objects = [];
|
|
28
48
|
const warnings = [];
|
|
29
49
|
for (const raw of stdout.split("\n")) {
|
|
30
50
|
const line = raw.trim();
|
|
31
51
|
if (!line.startsWith("{"))
|
|
32
52
|
continue;
|
|
33
|
-
|
|
53
|
+
const end = findJsonObjectEnd(line);
|
|
54
|
+
if (end === -1) {
|
|
55
|
+
warnings.push(`unparseable line: ${line.slice(0, 120)}`);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
let parsed;
|
|
34
59
|
try {
|
|
35
|
-
|
|
60
|
+
parsed = JSON.parse(line.slice(0, end + 1));
|
|
36
61
|
} catch {
|
|
37
62
|
warnings.push(`unparseable line: ${line.slice(0, 120)}`);
|
|
38
63
|
continue;
|
|
39
64
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
65
|
+
const trailing = line.slice(end + 1);
|
|
66
|
+
if (trailing.trim()) {
|
|
67
|
+
warnings.push(`ignored trailing content after JSON: ${trailing.trim().slice(0, 120)}`);
|
|
68
|
+
}
|
|
69
|
+
if (typeof parsed === "object" && parsed !== null && "tool" in parsed) {
|
|
70
|
+
objects.push(parsed);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { objects, warnings };
|
|
74
|
+
}
|
|
75
|
+
function parseSelectToolCallLines(stdout) {
|
|
76
|
+
const calls = [];
|
|
77
|
+
const { objects, warnings } = readToolCallObjects(stdout);
|
|
78
|
+
for (const rec of objects) {
|
|
43
79
|
if (!VALID_SELECT_TOOL_NAMES.has(rec.tool))
|
|
44
80
|
continue;
|
|
45
81
|
if (typeof rec.name !== "string" || !rec.name) {
|
|
@@ -65,21 +101,8 @@ function parseSelectToolCallLines(stdout) {
|
|
|
65
101
|
}
|
|
66
102
|
function parseToolCallLines(stdout) {
|
|
67
103
|
const calls = [];
|
|
68
|
-
const warnings =
|
|
69
|
-
for (const
|
|
70
|
-
const line = raw.trim();
|
|
71
|
-
if (!line.startsWith("{"))
|
|
72
|
-
continue;
|
|
73
|
-
let obj;
|
|
74
|
-
try {
|
|
75
|
-
obj = JSON.parse(line);
|
|
76
|
-
} catch {
|
|
77
|
-
warnings.push(`unparseable line: ${line.slice(0, 120)}`);
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
if (typeof obj !== "object" || obj === null || !("tool" in obj))
|
|
81
|
-
continue;
|
|
82
|
-
const rec = obj;
|
|
104
|
+
const { objects, warnings } = readToolCallObjects(stdout);
|
|
105
|
+
for (const rec of objects) {
|
|
83
106
|
if (!VALID_TOOL_NAMES.has(rec.tool)) {
|
|
84
107
|
warnings.push(`unknown tool: ${String(rec.tool)}`);
|
|
85
108
|
continue;
|
|
@@ -167,21 +190,8 @@ function parseToolCallLines(stdout) {
|
|
|
167
190
|
}
|
|
168
191
|
function parseTokenToolCallLines(stdout) {
|
|
169
192
|
const calls = [];
|
|
170
|
-
const warnings =
|
|
171
|
-
for (const
|
|
172
|
-
const line = raw.trim();
|
|
173
|
-
if (!line.startsWith("{"))
|
|
174
|
-
continue;
|
|
175
|
-
let obj;
|
|
176
|
-
try {
|
|
177
|
-
obj = JSON.parse(line);
|
|
178
|
-
} catch {
|
|
179
|
-
warnings.push(`unparseable line: ${line.slice(0, 120)}`);
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
if (typeof obj !== "object" || obj === null || !("tool" in obj))
|
|
183
|
-
continue;
|
|
184
|
-
const rec = obj;
|
|
193
|
+
const { objects, warnings } = readToolCallObjects(stdout);
|
|
194
|
+
for (const rec of objects) {
|
|
185
195
|
if (!VALID_TOKEN_TOOL_NAMES.has(rec.tool))
|
|
186
196
|
continue;
|
|
187
197
|
if (rec.tool === "set_token") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experience-design-system-cli",
|
|
3
|
-
"version": "2.26.7-dev-build-
|
|
3
|
+
"version": "2.26.7-dev-build-6d2ed6d.0",
|
|
4
4
|
"description": "Contentful Experiences design system import CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"svelte": "^5.56.4",
|
|
40
40
|
"ts-morph": "^27.0.2",
|
|
41
41
|
"typescript": "^5.9.3",
|
|
42
|
-
"@contentful/experience-design-system-types": "2.26.7-dev-build-
|
|
42
|
+
"@contentful/experience-design-system-types": "2.26.7-dev-build-6d2ed6d.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@tsconfig/node24": "^24.0.4",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"ink-testing-library": "^4.0.0",
|
|
52
52
|
"typescript-eslint": "^8.67.0",
|
|
53
53
|
"vitest": "^4.0.16",
|
|
54
|
-
"@contentful/experience-design-system-client": "2.26.7-dev-build-
|
|
55
|
-
"@contentful/experience-design-system-
|
|
56
|
-
"@contentful/experience-design-system-
|
|
54
|
+
"@contentful/experience-design-system-client": "2.26.7-dev-build-6d2ed6d.0",
|
|
55
|
+
"@contentful/experience-design-system-generation": "2.26.7-dev-build-6d2ed6d.0",
|
|
56
|
+
"@contentful/experience-design-system-extraction": "2.26.7-dev-build-6d2ed6d.0"
|
|
57
57
|
},
|
|
58
58
|
"repository": {
|
|
59
59
|
"type": "git",
|