onto-mcp 0.4.2 → 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
- function parseStringList(sectionText, label) {
114
- return parseYamlList(sectionText, label).map((item, index) => requireNonEmptyString(item, `${label}[${index}]`));
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 = {};
@@ -326,37 +326,17 @@ const RECONSTRUCT_SESSION_INPUT_SCHEMA = {
326
326
  },
327
327
  },
328
328
  };
329
+ // NOTE: top-level `allOf`/`oneOf`/`anyOf` is rejected by the Anthropic tool API
330
+ // ("input_schema does not support oneOf/allOf/anyOf at the top level"), which 400s
331
+ // the whole request when onto is enabled. Per-`directiveKind` required-field rules
332
+ // are enforced at runtime by OntoValidateReconstructDirectiveToolInputSchema
333
+ // (a Zod discriminatedUnion) in the handler, so they are intentionally not encoded
334
+ // here. Keep this schema a flat object: common required fields plus optional
335
+ // per-kind properties documented in their descriptions.
329
336
  const VALIDATE_RECONSTRUCT_DIRECTIVE_INPUT_SCHEMA = {
330
337
  type: "object",
331
338
  additionalProperties: false,
332
339
  required: ["directiveKind", "sourceObservationsPath"],
333
- allOf: [
334
- {
335
- if: {
336
- properties: { directiveKind: { const: "source_observation" } },
337
- required: ["directiveKind"],
338
- },
339
- then: { required: ["directivePath"] },
340
- },
341
- {
342
- if: {
343
- properties: { directiveKind: { const: "candidate_disposition" } },
344
- required: ["directiveKind"],
345
- },
346
- then: {
347
- required: ["candidateInventoryPath", "candidateDispositionPath"],
348
- },
349
- },
350
- {
351
- if: {
352
- properties: { directiveKind: { const: "ontology_seed" } },
353
- required: ["directiveKind"],
354
- },
355
- then: {
356
- required: ["ontologySeedPath", "candidateDispositionPath"],
357
- },
358
- },
359
- ],
360
340
  properties: {
361
341
  directiveKind: {
362
342
  type: "string",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onto-mcp",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "MCP-native ontology review runtime with context-isolated lenses and controlled deliberation",
5
5
  "homepage": "https://github.com/kangminlee-maker/onto-mcp#readme",
6
6
  "bugs": {