@contentful/experience-design-system-cli 2.26.7-dev-build-ccb2aff.0 → 2.26.7-dev-build-6f3b072.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 +77 -39
- package/package.json +5 -5
package/dist/package.json
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -23,23 +23,87 @@ 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
|
-
const
|
|
26
|
+
function scanJsonObjects(line) {
|
|
27
|
+
const objects = [];
|
|
28
|
+
let i = 0;
|
|
29
|
+
while (i < line.length) {
|
|
30
|
+
while (i < line.length && /\s/.test(line[i]))
|
|
31
|
+
i++;
|
|
32
|
+
if (i >= line.length)
|
|
33
|
+
break;
|
|
34
|
+
if (line[i] !== "{")
|
|
35
|
+
return { objects, trailing: line.slice(i), malformed: objects.length === 0 };
|
|
36
|
+
let depth = 0;
|
|
37
|
+
let inString = false;
|
|
38
|
+
let escaped = false;
|
|
39
|
+
let end = -1;
|
|
40
|
+
for (let j = i; j < line.length; j++) {
|
|
41
|
+
const ch = line[j];
|
|
42
|
+
if (escaped) {
|
|
43
|
+
escaped = false;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (ch === "\\") {
|
|
47
|
+
if (inString)
|
|
48
|
+
escaped = true;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (ch === '"') {
|
|
52
|
+
inString = !inString;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (inString)
|
|
56
|
+
continue;
|
|
57
|
+
if (ch === "{")
|
|
58
|
+
depth++;
|
|
59
|
+
else if (ch === "}") {
|
|
60
|
+
depth--;
|
|
61
|
+
if (depth === 0) {
|
|
62
|
+
end = j;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (end === -1)
|
|
68
|
+
return { objects, trailing: "", malformed: true };
|
|
69
|
+
let parsed;
|
|
70
|
+
try {
|
|
71
|
+
parsed = JSON.parse(line.slice(i, end + 1));
|
|
72
|
+
} catch {
|
|
73
|
+
return { objects, trailing: "", malformed: true };
|
|
74
|
+
}
|
|
75
|
+
if (typeof parsed === "object" && parsed !== null)
|
|
76
|
+
objects.push(parsed);
|
|
77
|
+
i = end + 1;
|
|
78
|
+
}
|
|
79
|
+
return { objects, trailing: "", malformed: false };
|
|
80
|
+
}
|
|
81
|
+
function readToolCallObjects(stdout) {
|
|
82
|
+
const objects = [];
|
|
28
83
|
const warnings = [];
|
|
29
84
|
for (const raw of stdout.split("\n")) {
|
|
30
85
|
const line = raw.trim();
|
|
31
86
|
if (!line.startsWith("{"))
|
|
32
87
|
continue;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
obj = JSON.parse(line);
|
|
36
|
-
} catch {
|
|
88
|
+
const { objects: found, trailing, malformed } = scanJsonObjects(line);
|
|
89
|
+
if (malformed) {
|
|
37
90
|
warnings.push(`unparseable line: ${line.slice(0, 120)}`);
|
|
38
91
|
continue;
|
|
39
92
|
}
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
93
|
+
if (trailing.trim()) {
|
|
94
|
+
warnings.push(`ignored trailing content after JSON: ${trailing.trim().slice(0, 120)}`);
|
|
95
|
+
}
|
|
96
|
+
for (const obj of found) {
|
|
97
|
+
if ("tool" in obj)
|
|
98
|
+
objects.push(obj);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return { objects, warnings };
|
|
102
|
+
}
|
|
103
|
+
function parseSelectToolCallLines(stdout) {
|
|
104
|
+
const calls = [];
|
|
105
|
+
const { objects, warnings } = readToolCallObjects(stdout);
|
|
106
|
+
for (const rec of objects) {
|
|
43
107
|
if (!VALID_SELECT_TOOL_NAMES.has(rec.tool))
|
|
44
108
|
continue;
|
|
45
109
|
if (typeof rec.name !== "string" || !rec.name) {
|
|
@@ -65,21 +129,8 @@ function parseSelectToolCallLines(stdout) {
|
|
|
65
129
|
}
|
|
66
130
|
function parseToolCallLines(stdout) {
|
|
67
131
|
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;
|
|
132
|
+
const { objects, warnings } = readToolCallObjects(stdout);
|
|
133
|
+
for (const rec of objects) {
|
|
83
134
|
if (!VALID_TOOL_NAMES.has(rec.tool)) {
|
|
84
135
|
warnings.push(`unknown tool: ${String(rec.tool)}`);
|
|
85
136
|
continue;
|
|
@@ -167,21 +218,8 @@ function parseToolCallLines(stdout) {
|
|
|
167
218
|
}
|
|
168
219
|
function parseTokenToolCallLines(stdout) {
|
|
169
220
|
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;
|
|
221
|
+
const { objects, warnings } = readToolCallObjects(stdout);
|
|
222
|
+
for (const rec of objects) {
|
|
185
223
|
if (!VALID_TOKEN_TOOL_NAMES.has(rec.tool))
|
|
186
224
|
continue;
|
|
187
225
|
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-6f3b072.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-6f3b072.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-
|
|
55
|
-
"@contentful/experience-design-system-
|
|
56
|
-
"@contentful/experience-design-system-
|
|
54
|
+
"@contentful/experience-design-system-client": "2.26.7-dev-build-6f3b072.0",
|
|
55
|
+
"@contentful/experience-design-system-extraction": "2.26.7-dev-build-6f3b072.0",
|
|
56
|
+
"@contentful/experience-design-system-generation": "2.26.7-dev-build-6f3b072.0"
|
|
57
57
|
},
|
|
58
58
|
"repository": {
|
|
59
59
|
"type": "git",
|