7cb3199d09
Один логический тул жил под двумя именами: внешний MCP snake_case (edit_page_text), in-app camelCase (editPageText) — дублирование доков, путаница при переносе промптов/скиллов, помеха шарингу спек (#294). Решение владельца: единый camelCase везде, включая внешний MCP. После этого mcpName === inAppKey. - tool-specs.ts: mcpName ВЫВЕДЕН из ключа спеки (mcpName == inAppKey) для всех 43 shared-спек — раньше divergent snake, теперь равен ключу (проверено: mcpName читается только структурно — цикл регистрации, генератор <tool_inventory>, TOOL_FAMILY). +5 inline-регистраций (tableGet/updateComment/deleteComment/ docmostTransform; search без изменений). Рантайм: 47 тулов, все camelCase, ноль подчёркиваний. - Контракт-конвенция ИНВЕРТИРОВАНА: shared-tool-specs.contract.spec `mcpName === toSnake(inAppKey)` → `mcpName === inAppKey`; tool-specs.test и tool-inventory.test обновлены. - ROUTING_PROSE/TOOL_FAMILY/INLINE_MCP_INVENTORY (server-instructions.ts) → camelCase (105 замен). ai-chat.prompt/guard уже на in-app camelCase-ключах — без изменений (guard прошёл). comment-signal EXCLUDED_TOOLS схлопнут с дублей snake+camel до camelCase. - Некоторое неочевидное: assertUnambiguousMatch(op: "patch_node"|"delete_node") в prosemirror-markdown/node-ops — op интерполируется в model-facing ошибку; литерал-юнион + call-sites → "patchNode"|"deleteNode". - Все snake-имена в описаниях/error-строках/комментах/тестах/доках → camelCase (whole-token, longest-match-first). CHANGELOG: BREAKING-таблица 46 строк + миграция (allowlists mcp__gitmost-*__get_node→__getNode, промпты/скиллы, .mcp.json, метрики по tool-label); релизится вместе с #411. Внутренние имена методов (PageService.updatePageContent и т.п.) НЕ тронуты — переименованы только ИМЕНА ТУЛОВ. Гейт: mcp node --test 677/677; tsc -p apps/server чисто; jest ai-chat-tools. service + shared-tool-specs.contract + tool-tiers + ai-chat.prompt + comment-signal-inapp → 323. Второй линк breaking-окна (#411→ЭТОТ→#413→#415). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
61 lines
2.7 KiB
JavaScript
61 lines
2.7 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { footnoteWarningsField } from "../../build/lib/footnote-analyze.js";
|
|
import {
|
|
serializeDocmostMarkdown,
|
|
parseDocmostMarkdown,
|
|
} from "../../build/lib/markdown-document.js";
|
|
|
|
// Pins the footnoteWarnings PLUMBING contract (#169 review; reduced in #414): the
|
|
// field is present only when legacy reference-style `[^id]:` syntax is used and
|
|
// omitted otherwise, AND `importPageMarkdown` analyzes the BODY (after the
|
|
// docmost:meta / docmost:comments blocks) — so a footnote-like token inside those
|
|
// JSON blocks never warns, while a real definition in the body does.
|
|
// importPageMarkdown does exactly `footnoteWarningsField(parseDocmostMarkdown(full).body)`
|
|
// over a collab socket this harness does not stand up, so we test the same pure
|
|
// composition directly.
|
|
|
|
test("footnoteWarningsField is present on legacy syntax and omitted on the inline form", () => {
|
|
const legacy = footnoteWarningsField("See[^a].\n\n[^a]: defined");
|
|
assert.ok(Array.isArray(legacy.footnoteWarnings));
|
|
assert.match(legacy.footnoteWarnings.join("\n"), /reference-style footnotes/i);
|
|
|
|
const inline = footnoteWarningsField("A note.^[the body] reused.^[the body]");
|
|
assert.deepEqual(inline, {}); // no key at all on inline-footnote input
|
|
});
|
|
|
|
test("import analyzes the BODY only — tokens inside meta/comments never warn", () => {
|
|
// meta + comments JSON carry `[^metaonly]:` / `[^commentonly]:`-looking text;
|
|
// the BODY has a genuine legacy `[^bodyref]:` definition.
|
|
const full = serializeDocmostMarkdown(
|
|
{ pageId: "p1", note: "front-matter mentions [^metaonly]: in text" },
|
|
"Body with a legacy[^bodyref] marker.\n\n[^bodyref]: the definition",
|
|
[{ id: "c1", content: "a comment that says [^commentonly]: text" }],
|
|
);
|
|
|
|
const { body } = parseDocmostMarkdown(full);
|
|
// Sanity: the meta/comments markers are NOT in the parsed body.
|
|
assert.ok(!body.includes("[^metaonly]"));
|
|
assert.ok(!body.includes("[^commentonly]"));
|
|
|
|
const field = footnoteWarningsField(body);
|
|
// ONLY the body's legacy definition triggers the advisory.
|
|
assert.ok(Array.isArray(field.footnoteWarnings));
|
|
assert.match(field.footnoteWarnings.join("\n"), /reference-style footnotes/i);
|
|
|
|
// The meta/comments tokens, analyzed on their own, would NOT have warned in a
|
|
// way that leaks here — the field is computed over the body only.
|
|
assert.deepEqual(footnoteWarningsField("front-matter mentions text"), {});
|
|
});
|
|
|
|
test("import on an inline-footnote body yields no footnoteWarnings field", () => {
|
|
const full = serializeDocmostMarkdown(
|
|
{ pageId: "p1" },
|
|
"Clean body.^[a note] reusing.^[a note]",
|
|
[],
|
|
);
|
|
const { body } = parseDocmostMarkdown(full);
|
|
assert.deepEqual(footnoteWarningsField(body), {});
|
|
});
|