onto-mcp 0.4.3 → 0.4.4
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.
|
@@ -110,8 +110,46 @@ function parseDomainConstraints(sectionText, lensId) {
|
|
|
110
110
|
};
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Parse a lens section that is a list of free-text strings (e.g. Domain Context
|
|
115
|
+
* Assumptions).
|
|
116
|
+
*
|
|
117
|
+
* The lens-output contract asks for a YAML list, but lens output is LLM-authored
|
|
118
|
+
* prose and models routinely emit natural markdown bullets such as
|
|
119
|
+
* `- "PATH resolution" means ...`, which are valid markdown yet invalid YAML (a
|
|
120
|
+
* quoted scalar followed by more text -> "Unexpected scalar at node end"). That
|
|
121
|
+
* brittleness failed real ReviewRecord assembly. Accept a valid YAML string list
|
|
122
|
+
* first (preserves `[]`, `- none`, and clean YAML lists), then fall back to
|
|
123
|
+
* parsing markdown bullet lines as literal strings. Structured object sections
|
|
124
|
+
* (e.g. Domain Constraints Used) stay strict via parseYamlList/parseDomainConstraints.
|
|
125
|
+
*
|
|
126
|
+
* Exported for unit testing.
|
|
127
|
+
*/
|
|
128
|
+
export function parseStringList(sectionText, label) {
|
|
129
|
+
const source = extractYamlFence(sectionText);
|
|
130
|
+
if (source.length === 0)
|
|
131
|
+
return [];
|
|
132
|
+
let yamlParsed;
|
|
133
|
+
let yamlParseOk = true;
|
|
134
|
+
try {
|
|
135
|
+
yamlParsed = YAML.parse(source);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
yamlParseOk = false;
|
|
139
|
+
}
|
|
140
|
+
if (yamlParseOk &&
|
|
141
|
+
Array.isArray(yamlParsed) &&
|
|
142
|
+
yamlParsed.every((item) => typeof item === "string" && item.trim().length > 0)) {
|
|
143
|
+
return yamlParsed.map((item) => item.trim());
|
|
144
|
+
}
|
|
145
|
+
// Fallback: treat markdown bullet lines as literal strings.
|
|
146
|
+
const bullets = source
|
|
147
|
+
.split(/\r?\n/u)
|
|
148
|
+
.map((line) => /^\s*[-*]\s+(.*\S)\s*$/u.exec(line)?.[1]?.trim())
|
|
149
|
+
.filter((item) => Boolean(item && item.length > 0));
|
|
150
|
+
if (bullets.length > 0)
|
|
151
|
+
return bullets;
|
|
152
|
+
throw new Error(`Expected a YAML list of strings or a markdown bullet list in ${label}.`);
|
|
115
153
|
}
|
|
116
154
|
async function deriveLensProvenance(lensResultPathsById, participatingLensIds) {
|
|
117
155
|
const perLensProvenance = {};
|
package/package.json
CHANGED