@contentful/experience-design-system-generation 2.35.1-dev-build-b8da2525.0 → 2.35.1-dev-build-4f1ad8cb.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/agent-names.js +7 -13
- package/dist/src/controller/create-generation-endpoint.d.ts +2 -2
- package/dist/src/controller/create-generation-endpoint.js +3 -3
- package/dist/src/controller/helpers/validate-generation-request.d.ts +1 -1
- package/dist/src/controller/helpers/validate-generation-request.js +9 -11
- package/dist/src/index.d.ts +21 -21
- package/dist/src/index.js +14 -14
- package/dist/src/orchestrator/execute-generation-orchestrator.d.ts +2 -2
- package/dist/src/orchestrator/execute-generation-orchestrator.js +1 -1
- package/dist/src/services/agent/helpers/build-agent-args.d.ts +1 -1
- package/dist/src/services/agent/helpers/build-agent-args.js +26 -45
- package/dist/src/services/agent/helpers/check-agent-auth.d.ts +2 -2
- package/dist/src/services/agent/helpers/check-agent-auth.js +10 -10
- package/dist/src/services/agent/helpers/check-claude-auth.d.ts +1 -1
- package/dist/src/services/agent/helpers/check-claude-auth.js +11 -11
- package/dist/src/services/agent/helpers/describe-agent-failure.d.ts +1 -1
- package/dist/src/services/agent/helpers/describe-agent-failure.js +2 -6
- package/dist/src/services/agent/helpers/extract-sentinel-output.d.ts +1 -1
- package/dist/src/services/agent/helpers/extract-sentinel-output.js +4 -4
- package/dist/src/services/agent/helpers/resolve-agent-binary.d.ts +1 -1
- package/dist/src/services/agent/helpers/resolve-agent-binary.js +1 -1
- package/dist/src/services/agent/local-cli-agent-invoker.d.ts +1 -1
- package/dist/src/services/agent/local-cli-agent-invoker.js +2 -2
- package/dist/src/services/agent/run-agent.d.ts +4 -4
- package/dist/src/services/agent/run-agent.js +17 -17
- package/dist/src/services/parsing/helpers/parse-selection-slot-evidence.d.ts +1 -1
- package/dist/src/services/parsing/helpers/parse-selection-slot-evidence.js +11 -13
- package/dist/src/services/parsing/helpers/read-tool-call-objects.js +6 -6
- package/dist/src/services/parsing/parse-map-token-tool-calls.d.ts +1 -1
- package/dist/src/services/parsing/parse-map-token-tool-calls.js +9 -9
- package/dist/src/services/parsing/parse-prop-tool-calls.d.ts +1 -1
- package/dist/src/services/parsing/parse-prop-tool-calls.js +36 -52
- package/dist/src/services/parsing/parse-select-tool-calls.d.ts +1 -1
- package/dist/src/services/parsing/parse-select-tool-calls.js +8 -13
- package/dist/src/services/parsing/parse-token-tool-calls.d.ts +1 -1
- package/dist/src/services/parsing/parse-token-tool-calls.js +14 -14
- package/dist/src/services/prompts/build-prompt.d.ts +2 -2
- package/dist/src/services/prompts/build-prompt.js +4 -5
- package/dist/src/services/prompts/helpers/build-preamble.d.ts +1 -1
- package/dist/src/services/prompts/helpers/build-preamble.js +10 -15
- package/dist/src/services/prompts/helpers/format-source-refs.d.ts +1 -1
- package/dist/src/services/prompts/helpers/format-source-refs.js +8 -8
- package/dist/src/services/prompts/helpers/format-token-candidates.d.ts +1 -1
- package/dist/src/services/prompts/helpers/format-token-candidates.js +27 -27
- package/dist/src/services/prompts/helpers/resolve-skill-file.d.ts +2 -2
- package/dist/src/services/prompts/helpers/resolve-skill-file.js +12 -12
- package/dist/src/types/agent.d.ts +2 -2
- package/dist/src/types/contract.d.ts +3 -3
- package/dist/src/types/invoker.d.ts +2 -2
- package/dist/src/types/prompt.d.ts +3 -3
- package/dist/src/types/tool-calls.d.ts +10 -10
- package/package.json +2 -2
|
@@ -2,32 +2,32 @@ export function parseSelectionSlotEvidence(value, warnings) {
|
|
|
2
2
|
if (value === undefined)
|
|
3
3
|
return undefined;
|
|
4
4
|
if (!Array.isArray(value)) {
|
|
5
|
-
warnings.push(
|
|
5
|
+
warnings.push('slot_evidence must be an array — ignored');
|
|
6
6
|
return undefined;
|
|
7
7
|
}
|
|
8
8
|
const evidence = [];
|
|
9
9
|
for (const [index, candidate] of value.entries()) {
|
|
10
|
-
if (typeof candidate !==
|
|
10
|
+
if (typeof candidate !== 'object' || candidate === null) {
|
|
11
11
|
warnings.push(`slot_evidence[${index}] must be an object — skipped`);
|
|
12
12
|
continue;
|
|
13
13
|
}
|
|
14
14
|
const record = candidate;
|
|
15
15
|
const evidenceItems = record.evidence;
|
|
16
|
-
if (typeof record.name !==
|
|
17
|
-
typeof record.is_real_slot !==
|
|
18
|
-
typeof record.reason !==
|
|
16
|
+
if (typeof record.name !== 'string' ||
|
|
17
|
+
typeof record.is_real_slot !== 'boolean' ||
|
|
18
|
+
typeof record.reason !== 'string' ||
|
|
19
19
|
!Array.isArray(evidenceItems)) {
|
|
20
20
|
warnings.push(`slot_evidence[${index}] is missing name, is_real_slot, reason, or evidence — skipped`);
|
|
21
21
|
continue;
|
|
22
22
|
}
|
|
23
23
|
const citations = [];
|
|
24
24
|
for (const [citationIndex, citation] of evidenceItems.entries()) {
|
|
25
|
-
if (typeof citation !==
|
|
25
|
+
if (typeof citation !== 'object' || citation === null)
|
|
26
26
|
continue;
|
|
27
27
|
const citationRecord = citation;
|
|
28
|
-
if (typeof citationRecord.source ===
|
|
29
|
-
typeof citationRecord.line ===
|
|
30
|
-
typeof citationRecord.quote ===
|
|
28
|
+
if (typeof citationRecord.source === 'string' &&
|
|
29
|
+
typeof citationRecord.line === 'string' &&
|
|
30
|
+
typeof citationRecord.quote === 'string') {
|
|
31
31
|
citations.push({
|
|
32
32
|
source: citationRecord.source,
|
|
33
33
|
line: citationRecord.line,
|
|
@@ -44,13 +44,11 @@ export function parseSelectionSlotEvidence(value, warnings) {
|
|
|
44
44
|
}
|
|
45
45
|
const allowedComponents = record.allowed_components;
|
|
46
46
|
if (allowedComponents !== undefined &&
|
|
47
|
-
(!Array.isArray(allowedComponents) ||
|
|
48
|
-
!allowedComponents.every((component) => typeof component === "string"))) {
|
|
47
|
+
(!Array.isArray(allowedComponents) || !allowedComponents.every((component) => typeof component === 'string'))) {
|
|
49
48
|
warnings.push(`slot_evidence[${index}].allowed_components must be an array of names — skipped`);
|
|
50
49
|
continue;
|
|
51
50
|
}
|
|
52
|
-
if (record.is_real_slot &&
|
|
53
|
-
(!Array.isArray(allowedComponents) || allowedComponents.length === 0)) {
|
|
51
|
+
if (record.is_real_slot && (!Array.isArray(allowedComponents) || allowedComponents.length === 0)) {
|
|
54
52
|
warnings.push(`slot_evidence[${index}] marks a real slot without allowed_components — skipped`);
|
|
55
53
|
continue;
|
|
56
54
|
}
|
|
@@ -7,16 +7,16 @@ function findJsonObjectEnd(line) {
|
|
|
7
7
|
if (escaped) {
|
|
8
8
|
escaped = false;
|
|
9
9
|
}
|
|
10
|
-
else if (ch ===
|
|
10
|
+
else if (ch === '\\' && inString) {
|
|
11
11
|
escaped = true;
|
|
12
12
|
}
|
|
13
13
|
else if (ch === '"') {
|
|
14
14
|
inString = !inString;
|
|
15
15
|
}
|
|
16
|
-
else if (!inString && ch ===
|
|
16
|
+
else if (!inString && ch === '{') {
|
|
17
17
|
depth++;
|
|
18
18
|
}
|
|
19
|
-
else if (!inString && ch ===
|
|
19
|
+
else if (!inString && ch === '}' && --depth === 0) {
|
|
20
20
|
return i;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -25,9 +25,9 @@ function findJsonObjectEnd(line) {
|
|
|
25
25
|
export function readToolCallObjects(stdout) {
|
|
26
26
|
const objects = [];
|
|
27
27
|
const warnings = [];
|
|
28
|
-
for (const raw of stdout.split(
|
|
28
|
+
for (const raw of stdout.split('\n')) {
|
|
29
29
|
const line = raw.trim();
|
|
30
|
-
if (!line.startsWith(
|
|
30
|
+
if (!line.startsWith('{'))
|
|
31
31
|
continue;
|
|
32
32
|
const end = findJsonObjectEnd(line);
|
|
33
33
|
if (end === -1) {
|
|
@@ -46,7 +46,7 @@ export function readToolCallObjects(stdout) {
|
|
|
46
46
|
if (trailing.trim()) {
|
|
47
47
|
warnings.push(`ignored trailing content after JSON: ${trailing.trim().slice(0, 120)}`);
|
|
48
48
|
}
|
|
49
|
-
if (typeof parsed ===
|
|
49
|
+
if (typeof parsed === 'object' && parsed !== null && 'tool' in parsed) {
|
|
50
50
|
objects.push(parsed);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ParsedMapTokenPropToolCalls } from
|
|
1
|
+
import type { ParsedMapTokenPropToolCalls } from '../../types/tool-calls.js';
|
|
2
2
|
export declare function parseMapTokenPropToolCallLines(stdout: string): ParsedMapTokenPropToolCalls;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
function isStringArray(value) {
|
|
2
|
-
return Array.isArray(value) && value.every((v) => typeof v ===
|
|
2
|
+
return Array.isArray(value) && value.every((v) => typeof v === 'string');
|
|
3
3
|
}
|
|
4
4
|
export function parseMapTokenPropToolCallLines(stdout) {
|
|
5
5
|
const calls = [];
|
|
6
6
|
const warnings = [];
|
|
7
|
-
for (const raw of stdout.split(
|
|
7
|
+
for (const raw of stdout.split('\n')) {
|
|
8
8
|
const line = raw.trim();
|
|
9
|
-
if (!line.startsWith(
|
|
9
|
+
if (!line.startsWith('{'))
|
|
10
10
|
continue;
|
|
11
11
|
let obj;
|
|
12
12
|
try {
|
|
@@ -16,16 +16,16 @@ export function parseMapTokenPropToolCallLines(stdout) {
|
|
|
16
16
|
warnings.push(`unparseable line: ${line.slice(0, 120)}`);
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
|
-
if (typeof obj !==
|
|
19
|
+
if (typeof obj !== 'object' || obj === null || !('tool' in obj))
|
|
20
20
|
continue;
|
|
21
21
|
const rec = obj;
|
|
22
|
-
if (rec.tool !==
|
|
22
|
+
if (rec.tool !== 'map_token_prop')
|
|
23
23
|
continue;
|
|
24
|
-
if (typeof rec.component !==
|
|
25
|
-
warnings.push(
|
|
24
|
+
if (typeof rec.component !== 'string' || !rec.component) {
|
|
25
|
+
warnings.push('map_token_prop missing component — skipped');
|
|
26
26
|
continue;
|
|
27
27
|
}
|
|
28
|
-
if (typeof rec.prop !==
|
|
28
|
+
if (typeof rec.prop !== 'string' || !rec.prop) {
|
|
29
29
|
warnings.push(`map_token_prop '${rec.component}': missing prop — skipped`);
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
@@ -34,7 +34,7 @@ export function parseMapTokenPropToolCallLines(stdout) {
|
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
calls.push({
|
|
37
|
-
tool:
|
|
37
|
+
tool: 'map_token_prop',
|
|
38
38
|
component: rec.component,
|
|
39
39
|
prop: rec.prop,
|
|
40
40
|
token_allowed: rec.token_allowed,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ParsedToolCalls } from
|
|
1
|
+
import type { ParsedToolCalls } from '../../types/tool-calls.js';
|
|
2
2
|
export declare function parsePropToolCallLines(stdout: string): ParsedToolCalls;
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { readToolCallObjects } from
|
|
2
|
-
const VALID_TOOL_NAMES = new Set([
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"classify_component",
|
|
6
|
-
"classify_slot",
|
|
7
|
-
]);
|
|
8
|
-
const VALID_CDF_TYPES = new Set([
|
|
9
|
-
"string",
|
|
10
|
-
"richtext",
|
|
11
|
-
"media",
|
|
12
|
-
"enum",
|
|
13
|
-
"token",
|
|
14
|
-
"boolean",
|
|
15
|
-
]);
|
|
16
|
-
const VALID_CATEGORIES = new Set(["content", "design", "state"]);
|
|
1
|
+
import { readToolCallObjects } from './helpers/read-tool-call-objects.js';
|
|
2
|
+
const VALID_TOOL_NAMES = new Set(['classify_prop', 'exclude_prop', 'classify_component', 'classify_slot']);
|
|
3
|
+
const VALID_CDF_TYPES = new Set(['string', 'richtext', 'media', 'enum', 'token', 'boolean']);
|
|
4
|
+
const VALID_CATEGORIES = new Set(['content', 'design', 'state']);
|
|
17
5
|
export function parsePropToolCallLines(stdout) {
|
|
18
6
|
const calls = [];
|
|
19
7
|
const { objects, warnings } = readToolCallObjects(stdout);
|
|
@@ -23,86 +11,82 @@ export function parsePropToolCallLines(stdout) {
|
|
|
23
11
|
continue;
|
|
24
12
|
}
|
|
25
13
|
const tool = rec.tool;
|
|
26
|
-
if (tool ===
|
|
27
|
-
if (typeof rec.prop !==
|
|
28
|
-
warnings.push(
|
|
14
|
+
if (tool === 'classify_prop') {
|
|
15
|
+
if (typeof rec.prop !== 'string' || !rec.prop) {
|
|
16
|
+
warnings.push('classify_prop missing prop name — skipped');
|
|
29
17
|
continue;
|
|
30
18
|
}
|
|
31
|
-
if (typeof rec.cdf_type !==
|
|
32
|
-
!VALID_CDF_TYPES.has(rec.cdf_type)) {
|
|
19
|
+
if (typeof rec.cdf_type !== 'string' || !VALID_CDF_TYPES.has(rec.cdf_type)) {
|
|
33
20
|
warnings.push(`classify_prop '${rec.prop}': invalid cdf_type '${String(rec.cdf_type)}' — skipped`);
|
|
34
21
|
continue;
|
|
35
22
|
}
|
|
36
|
-
if (typeof rec.cdf_category !==
|
|
37
|
-
!VALID_CATEGORIES.has(rec.cdf_category)) {
|
|
23
|
+
if (typeof rec.cdf_category !== 'string' || !VALID_CATEGORIES.has(rec.cdf_category)) {
|
|
38
24
|
warnings.push(`classify_prop '${rec.prop}': invalid cdf_category '${String(rec.cdf_category)}' — skipped`);
|
|
39
25
|
continue;
|
|
40
26
|
}
|
|
41
27
|
const call = {
|
|
42
|
-
tool:
|
|
28
|
+
tool: 'classify_prop',
|
|
43
29
|
prop: rec.prop,
|
|
44
30
|
cdf_type: rec.cdf_type,
|
|
45
31
|
cdf_category: rec.cdf_category,
|
|
46
32
|
};
|
|
47
|
-
if (Array.isArray(rec.values) &&
|
|
48
|
-
rec.values.every((v) => typeof v === "string"))
|
|
33
|
+
if (Array.isArray(rec.values) && rec.values.every((v) => typeof v === 'string'))
|
|
49
34
|
call.values = rec.values;
|
|
50
|
-
if (typeof rec.token_kind ===
|
|
35
|
+
if (typeof rec.token_kind === 'string')
|
|
51
36
|
call.token_kind = rec.token_kind;
|
|
52
|
-
if (typeof rec.required ===
|
|
37
|
+
if (typeof rec.required === 'boolean')
|
|
53
38
|
call.required = rec.required;
|
|
54
|
-
if (typeof rec.description ===
|
|
39
|
+
if (typeof rec.description === 'string')
|
|
55
40
|
call.description = rec.description;
|
|
56
|
-
if (typeof rec.default ===
|
|
41
|
+
if (typeof rec.default === 'string' || typeof rec.default === 'boolean')
|
|
57
42
|
call.default = rec.default;
|
|
58
|
-
if (typeof rec.reason ===
|
|
43
|
+
if (typeof rec.reason === 'string')
|
|
59
44
|
call.reason = rec.reason;
|
|
60
45
|
calls.push(call);
|
|
61
46
|
}
|
|
62
|
-
else if (tool ===
|
|
63
|
-
if (typeof rec.prop !==
|
|
64
|
-
warnings.push(
|
|
47
|
+
else if (tool === 'exclude_prop') {
|
|
48
|
+
if (typeof rec.prop !== 'string' || !rec.prop) {
|
|
49
|
+
warnings.push('exclude_prop missing prop name — skipped');
|
|
65
50
|
continue;
|
|
66
51
|
}
|
|
67
52
|
calls.push({
|
|
68
|
-
tool:
|
|
53
|
+
tool: 'exclude_prop',
|
|
69
54
|
prop: rec.prop,
|
|
70
|
-
reason: typeof rec.reason ===
|
|
55
|
+
reason: typeof rec.reason === 'string' ? rec.reason : '',
|
|
71
56
|
});
|
|
72
57
|
}
|
|
73
|
-
else if (tool ===
|
|
74
|
-
const call = { tool:
|
|
75
|
-
if (typeof rec.description ===
|
|
58
|
+
else if (tool === 'classify_component') {
|
|
59
|
+
const call = { tool: 'classify_component' };
|
|
60
|
+
if (typeof rec.description === 'string')
|
|
76
61
|
call.description = rec.description;
|
|
77
|
-
if (typeof rec.rationale ===
|
|
62
|
+
if (typeof rec.rationale === 'object' && rec.rationale !== null) {
|
|
78
63
|
const r = rec.rationale;
|
|
79
64
|
const rationale = {};
|
|
80
|
-
if (typeof r.description ===
|
|
65
|
+
if (typeof r.description === 'string')
|
|
81
66
|
rationale.description = r.description;
|
|
82
|
-
if (typeof r.props ===
|
|
67
|
+
if (typeof r.props === 'string')
|
|
83
68
|
rationale.props = r.props;
|
|
84
|
-
if (typeof r.slots ===
|
|
69
|
+
if (typeof r.slots === 'string')
|
|
85
70
|
rationale.slots = r.slots;
|
|
86
71
|
if (Object.keys(rationale).length > 0)
|
|
87
72
|
call.rationale = rationale;
|
|
88
73
|
}
|
|
89
74
|
calls.push(call);
|
|
90
75
|
}
|
|
91
|
-
else if (tool ===
|
|
92
|
-
if (typeof rec.slot !==
|
|
93
|
-
warnings.push(
|
|
76
|
+
else if (tool === 'classify_slot') {
|
|
77
|
+
if (typeof rec.slot !== 'string' || !rec.slot) {
|
|
78
|
+
warnings.push('classify_slot missing slot name — skipped');
|
|
94
79
|
continue;
|
|
95
80
|
}
|
|
96
|
-
const call = { tool:
|
|
97
|
-
if (typeof rec.required ===
|
|
81
|
+
const call = { tool: 'classify_slot', slot: rec.slot };
|
|
82
|
+
if (typeof rec.required === 'boolean')
|
|
98
83
|
call.required = rec.required;
|
|
99
|
-
if (Array.isArray(rec.allowed_components) &&
|
|
100
|
-
rec.allowed_components.every((v) => typeof v === "string")) {
|
|
84
|
+
if (Array.isArray(rec.allowed_components) && rec.allowed_components.every((v) => typeof v === 'string')) {
|
|
101
85
|
call.allowed_components = rec.allowed_components;
|
|
102
86
|
}
|
|
103
|
-
if (typeof rec.description ===
|
|
87
|
+
if (typeof rec.description === 'string')
|
|
104
88
|
call.description = rec.description;
|
|
105
|
-
if (typeof rec.rationale ===
|
|
89
|
+
if (typeof rec.rationale === 'string')
|
|
106
90
|
call.rationale = rec.rationale;
|
|
107
91
|
calls.push(call);
|
|
108
92
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ParsedSelectToolCalls } from
|
|
1
|
+
import type { ParsedSelectToolCalls } from '../../types/tool-calls.js';
|
|
2
2
|
export declare function parseSelectToolCallLines(stdout: string): ParsedSelectToolCalls;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { parseSelectionSlotEvidence } from
|
|
2
|
-
import { readToolCallObjects } from
|
|
3
|
-
const VALID_SELECT_TOOL_NAMES = new Set([
|
|
4
|
-
"select_component",
|
|
5
|
-
"reject_component",
|
|
6
|
-
]);
|
|
1
|
+
import { parseSelectionSlotEvidence } from './helpers/parse-selection-slot-evidence.js';
|
|
2
|
+
import { readToolCallObjects } from './helpers/read-tool-call-objects.js';
|
|
3
|
+
const VALID_SELECT_TOOL_NAMES = new Set(['select_component', 'reject_component']);
|
|
7
4
|
export function parseSelectToolCallLines(stdout) {
|
|
8
5
|
const calls = [];
|
|
9
6
|
const { objects, warnings } = readToolCallObjects(stdout);
|
|
10
7
|
for (const rec of objects) {
|
|
11
8
|
if (!VALID_SELECT_TOOL_NAMES.has(rec.tool))
|
|
12
9
|
continue;
|
|
13
|
-
if (typeof rec.name !==
|
|
10
|
+
if (typeof rec.name !== 'string' || !rec.name) {
|
|
14
11
|
warnings.push(`${String(rec.tool)} missing name — skipped`);
|
|
15
12
|
continue;
|
|
16
13
|
}
|
|
@@ -18,19 +15,17 @@ export function parseSelectToolCallLines(stdout) {
|
|
|
18
15
|
tool: rec.tool,
|
|
19
16
|
name: rec.name,
|
|
20
17
|
};
|
|
21
|
-
if (typeof rec.reason ===
|
|
18
|
+
if (typeof rec.reason === 'string')
|
|
22
19
|
call.reason = rec.reason;
|
|
23
|
-
if (typeof rec.confidence ===
|
|
24
|
-
|
|
25
|
-
rec.confidence <= 5) {
|
|
26
|
-
if (call.tool === "select_component") {
|
|
20
|
+
if (typeof rec.confidence === 'number' && rec.confidence >= 1 && rec.confidence <= 5) {
|
|
21
|
+
if (call.tool === 'select_component') {
|
|
27
22
|
call.confidence = rec.confidence;
|
|
28
23
|
}
|
|
29
24
|
else {
|
|
30
25
|
call.confidence = rec.confidence;
|
|
31
26
|
}
|
|
32
27
|
}
|
|
33
|
-
if (call.tool ===
|
|
28
|
+
if (call.tool === 'select_component') {
|
|
34
29
|
const slotEvidence = parseSelectionSlotEvidence(rec.slot_evidence, warnings);
|
|
35
30
|
if (slotEvidence !== undefined)
|
|
36
31
|
call.slot_evidence = slotEvidence;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ParsedTokenToolCalls } from
|
|
1
|
+
import type { ParsedTokenToolCalls } from '../../types/tool-calls.js';
|
|
2
2
|
export declare function parseTokenToolCallLines(stdout: string): ParsedTokenToolCalls;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { readToolCallObjects } from
|
|
2
|
-
const VALID_TOKEN_TOOL_NAMES = new Set([
|
|
1
|
+
import { readToolCallObjects } from './helpers/read-tool-call-objects.js';
|
|
2
|
+
const VALID_TOKEN_TOOL_NAMES = new Set(['set_token', 'set_group']);
|
|
3
3
|
export function parseTokenToolCallLines(stdout) {
|
|
4
4
|
const calls = [];
|
|
5
5
|
const { objects, warnings } = readToolCallObjects(stdout);
|
|
6
6
|
for (const rec of objects) {
|
|
7
7
|
if (!VALID_TOKEN_TOOL_NAMES.has(rec.tool))
|
|
8
8
|
continue;
|
|
9
|
-
if (rec.tool ===
|
|
10
|
-
if (typeof rec.path !==
|
|
11
|
-
warnings.push(
|
|
9
|
+
if (rec.tool === 'set_token') {
|
|
10
|
+
if (typeof rec.path !== 'string' || !rec.path) {
|
|
11
|
+
warnings.push('set_token missing path — skipped');
|
|
12
12
|
continue;
|
|
13
13
|
}
|
|
14
|
-
if (typeof rec.type !==
|
|
14
|
+
if (typeof rec.type !== 'string' || !rec.type) {
|
|
15
15
|
warnings.push(`set_token '${rec.path}': missing type — skipped`);
|
|
16
16
|
continue;
|
|
17
17
|
}
|
|
18
|
-
if (!(
|
|
18
|
+
if (!('value' in rec)) {
|
|
19
19
|
warnings.push(`set_token '${rec.path}': missing value — skipped`);
|
|
20
20
|
continue;
|
|
21
21
|
}
|
|
22
22
|
const call = {
|
|
23
|
-
tool:
|
|
23
|
+
tool: 'set_token',
|
|
24
24
|
path: rec.path,
|
|
25
25
|
type: rec.type,
|
|
26
26
|
value: rec.value,
|
|
27
27
|
};
|
|
28
|
-
if (typeof rec.description ===
|
|
28
|
+
if (typeof rec.description === 'string')
|
|
29
29
|
call.description = rec.description;
|
|
30
30
|
calls.push(call);
|
|
31
31
|
}
|
|
32
|
-
else if (rec.tool ===
|
|
33
|
-
if (typeof rec.path !==
|
|
34
|
-
warnings.push(
|
|
32
|
+
else if (rec.tool === 'set_group') {
|
|
33
|
+
if (typeof rec.path !== 'string' || !rec.path) {
|
|
34
|
+
warnings.push('set_group missing path — skipped');
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
|
-
const call = { tool:
|
|
38
|
-
if (typeof rec.description ===
|
|
37
|
+
const call = { tool: 'set_group', path: rec.path };
|
|
38
|
+
if (typeof rec.description === 'string')
|
|
39
39
|
call.description = rec.description;
|
|
40
40
|
calls.push(call);
|
|
41
41
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PromptOptions, Skill } from
|
|
2
|
-
export { resolveSkillPath, formatCustomPromptBanner
|
|
1
|
+
import type { PromptOptions, Skill } from '../../types/prompt.js';
|
|
2
|
+
export { resolveSkillPath, formatCustomPromptBanner } from './helpers/resolve-skill-file.js';
|
|
3
3
|
export type { Skill };
|
|
4
4
|
export declare function buildPrompt(options: PromptOptions): Promise<string>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { readSkillFile } from
|
|
2
|
-
import { buildPreamble } from
|
|
3
|
-
export { resolveSkillPath, formatCustomPromptBanner
|
|
1
|
+
import { readSkillFile } from './helpers/resolve-skill-file.js';
|
|
2
|
+
import { buildPreamble } from './helpers/build-preamble.js';
|
|
3
|
+
export { resolveSkillPath, formatCustomPromptBanner } from './helpers/resolve-skill-file.js';
|
|
4
4
|
export async function buildPrompt(options) {
|
|
5
|
-
const skillContent = options.skillContentOverride ??
|
|
6
|
-
(await readSkillFile(options.skill, options.skillPathOverride));
|
|
5
|
+
const skillContent = options.skillContentOverride ?? (await readSkillFile(options.skill, options.skillPathOverride));
|
|
7
6
|
const preamble = buildPreamble(options);
|
|
8
7
|
return `${preamble}\n\nSkill instructions follow:\n---\n${skillContent}`;
|
|
9
8
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { PromptOptions } from
|
|
1
|
+
import type { PromptOptions } from '../../../types/prompt.js';
|
|
2
2
|
export declare function buildPreamble(options: PromptOptions): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { inferFenceLang, filterDesignTokenProps, buildTokenCandidateSections
|
|
2
|
-
import { formatSourceRefsSection } from
|
|
3
|
-
import { buildComponentsAutonomousPreamble, buildSelectAutonomousPreamble, buildMapTokensAutonomousPreamble, buildTokensAutonomousPreamble, } from
|
|
1
|
+
import { inferFenceLang, filterDesignTokenProps, buildTokenCandidateSections } from './format-token-candidates.js';
|
|
2
|
+
import { formatSourceRefsSection } from './format-source-refs.js';
|
|
3
|
+
import { buildComponentsAutonomousPreamble, buildSelectAutonomousPreamble, buildMapTokensAutonomousPreamble, buildTokensAutonomousPreamble, } from './build-skill-preambles.js';
|
|
4
4
|
export function buildPreamble(options) {
|
|
5
5
|
const { skill, rawComponentsInline, propBucketsInline, rawTokensInline, rawTokensFilename, tokensInline, tokenMapInline, generatedCdf, tokenTree, componentSourceRefs, existingComponentsInline, existingTokensInline, componentAllowlistInline, } = options;
|
|
6
6
|
const sections = [];
|
|
@@ -21,9 +21,7 @@ export function buildPreamble(options) {
|
|
|
21
21
|
}
|
|
22
22
|
if (rawTokensInline) {
|
|
23
23
|
const lang = inferFenceLang(rawTokensFilename);
|
|
24
|
-
const label = rawTokensFilename
|
|
25
|
-
? `Raw token source (${rawTokensFilename})`
|
|
26
|
-
: "Raw token source";
|
|
24
|
+
const label = rawTokensFilename ? `Raw token source (${rawTokensFilename})` : 'Raw token source';
|
|
27
25
|
sections.push(`${label}:\n\`\`\`${lang}\n${rawTokensInline}\n\`\`\``);
|
|
28
26
|
}
|
|
29
27
|
if (tokensInline) {
|
|
@@ -32,11 +30,8 @@ export function buildPreamble(options) {
|
|
|
32
30
|
if (tokenMapInline) {
|
|
33
31
|
sections.push(`Token-name sidecar (raw name → DTCG path):\n\`\`\`json\n${tokenMapInline}\n\`\`\``);
|
|
34
32
|
}
|
|
35
|
-
const filteredTokenProps = generatedCdf
|
|
36
|
-
|
|
37
|
-
: undefined;
|
|
38
|
-
if (filteredTokenProps &&
|
|
39
|
-
Object.keys(filteredTokenProps.filtered).length > 0) {
|
|
33
|
+
const filteredTokenProps = generatedCdf ? filterDesignTokenProps(generatedCdf) : undefined;
|
|
34
|
+
if (filteredTokenProps && Object.keys(filteredTokenProps.filtered).length > 0) {
|
|
40
35
|
sections.push(`Generated CDF so far — design-category token props only (JSON):\n\`\`\`json\n${JSON.stringify(filteredTokenProps.filtered)}\n\`\`\``);
|
|
41
36
|
}
|
|
42
37
|
if (tokenTree) {
|
|
@@ -45,12 +40,12 @@ export function buildPreamble(options) {
|
|
|
45
40
|
if (componentSourceRefs && componentSourceRefs.length > 0) {
|
|
46
41
|
sections.push(...formatSourceRefsSection(componentSourceRefs, skill));
|
|
47
42
|
}
|
|
48
|
-
const inputBlock = sections.length > 0 ? `\n\n${sections.join(
|
|
49
|
-
if (skill ===
|
|
43
|
+
const inputBlock = sections.length > 0 ? `\n\n${sections.join('\n\n')}` : '';
|
|
44
|
+
if (skill === 'components')
|
|
50
45
|
return buildComponentsAutonomousPreamble(inputBlock);
|
|
51
|
-
if (skill ===
|
|
46
|
+
if (skill === 'select')
|
|
52
47
|
return buildSelectAutonomousPreamble(inputBlock);
|
|
53
|
-
if (skill ===
|
|
48
|
+
if (skill === 'map-tokens')
|
|
54
49
|
return buildMapTokensAutonomousPreamble(inputBlock);
|
|
55
50
|
return buildTokensAutonomousPreamble(inputBlock);
|
|
56
51
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ComponentSourceRef, Skill } from
|
|
1
|
+
import type { ComponentSourceRef, Skill } from '../../../types/prompt.js';
|
|
2
2
|
export declare function formatSourceRefsSection(refs: ComponentSourceRef[], skill: Skill): string[];
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { inferFenceLang } from
|
|
1
|
+
import { inferFenceLang } from './format-token-candidates.js';
|
|
2
2
|
function formatSourceRefBlock(ref) {
|
|
3
3
|
const mainBlock = `#### ${ref.component} (\`${ref.sourcePath}\`)\n\`\`\`${inferFenceLang(ref.sourcePath)}\n${ref.content}\n\`\`\``;
|
|
4
4
|
const siblingBlocks = (ref.siblingFiles ?? []).map((sibling) => `##### ${ref.component} — imported file \`${sibling.path}\`\n\`\`\`${inferFenceLang(sibling.path)}\n${sibling.content}\n\`\`\``);
|
|
5
5
|
const truncationNote = ref.truncatedSiblingCount && ref.truncatedSiblingCount > 0
|
|
6
6
|
? [
|
|
7
|
-
`##### ${ref.component} — +${ref.truncatedSiblingCount} more imported file${ref.truncatedSiblingCount === 1 ?
|
|
7
|
+
`##### ${ref.component} — +${ref.truncatedSiblingCount} more imported file${ref.truncatedSiblingCount === 1 ? '' : 's'} not shown (evidence may be incomplete)`,
|
|
8
8
|
]
|
|
9
9
|
: [];
|
|
10
10
|
const notShownNote = ref.usesNotShown && ref.usesNotShown.length > 0
|
|
11
11
|
? [
|
|
12
|
-
`##### ${ref.component} — uses not shown: ${ref.usesNotShown.join(
|
|
12
|
+
`##### ${ref.component} — uses not shown: ${ref.usesNotShown.join(', ')}\n\nThe files above are excerpts, and each of these properties has at least one use that fell outside the excerpt budget. Treat their consumption as unknown, not absent: do not classify them \`token\` on what is shown, and do not conclude they are unread.`,
|
|
13
13
|
]
|
|
14
14
|
: [];
|
|
15
|
-
return [mainBlock, ...siblingBlocks, ...truncationNote, ...notShownNote].join(
|
|
15
|
+
return [mainBlock, ...siblingBlocks, ...truncationNote, ...notShownNote].join('\n\n');
|
|
16
16
|
}
|
|
17
17
|
export function formatSourceRefsSection(refs, skill) {
|
|
18
18
|
const sections = [];
|
|
19
19
|
const withContent = refs.filter((ref) => ref.content != null);
|
|
20
20
|
const withoutContent = refs.filter((ref) => ref.content == null);
|
|
21
21
|
if (withContent.length > 0) {
|
|
22
|
-
sections.push(`### Component source references\n\n${withContent.map(formatSourceRefBlock).join(
|
|
22
|
+
sections.push(`### Component source references\n\n${withContent.map(formatSourceRefBlock).join('\n\n')}`);
|
|
23
23
|
}
|
|
24
24
|
if (withoutContent.length > 0) {
|
|
25
|
-
const guidance = skill ===
|
|
26
|
-
?
|
|
27
|
-
:
|
|
25
|
+
const guidance = skill === 'components'
|
|
26
|
+
? 'there is no consumption evidence for these, so `token` cannot be earned for any of their props — classify from the prop signature alone, and any prop that would otherwise be enum-versus-token is `enum` (or `string`)'
|
|
27
|
+
: 'there is no source evidence to narrow from — emit nothing for their props';
|
|
28
28
|
sections.push(`Component source unavailable for (JSON) — ${guidance}:\n\`\`\`json\n${JSON.stringify(withoutContent.map((ref) => ({ component: ref.component, sourcePath: ref.sourcePath })))}\n\`\`\``);
|
|
29
29
|
}
|
|
30
30
|
return sections;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GeneratedCdf } from
|
|
1
|
+
import type { GeneratedCdf } from '../../../types/prompt.js';
|
|
2
2
|
export declare function inferFenceLang(filename: string | undefined): string;
|
|
3
3
|
export declare function filterDesignTokenProps(cdf: GeneratedCdf): {
|
|
4
4
|
filtered: GeneratedCdf;
|