Files
gitmost/packages/mcp/test/unit/drawio-guide.test.mjs
T
agent_coder 7cb3199d09 refactor(mcp)!: BREAKING — все имена MCP-тулов snake_case → camelCase (унификация с in-app) (#412)
Один логический тул жил под двумя именами: внешний 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>
2026-07-10 19:10:38 +03:00

52 lines
1.9 KiB
JavaScript

// Unit tests for the drawioGuide progressive-disclosure reference (issue #424).
// Acceptance #2: every section is returned and each is <= ~4KB so pulling one
// does not bloat the model's context.
import { test } from "node:test";
import assert from "node:assert/strict";
import {
getGuideSection,
GUIDE_SECTIONS,
} from "../../build/lib/drawio-guide.js";
const MAX_BYTES = 4096; // "<= ~4KB" acceptance bound.
test("every section is returned and is under ~4KB", () => {
assert.deepEqual(GUIDE_SECTIONS, [
"skeleton",
"layout",
"containers",
"icons-aws",
"icons-azure",
]);
for (const s of GUIDE_SECTIONS) {
const { section, content } = getGuideSection(s);
assert.equal(section, s);
assert.ok(content.length > 200, `${s}: suspiciously short`);
const bytes = Buffer.byteLength(content, "utf8");
assert.ok(bytes <= MAX_BYTES, `${s}: ${bytes} bytes exceeds ${MAX_BYTES}`);
}
});
test("each section's content matches its topic", () => {
assert.match(getGuideSection("skeleton").content, /mxGraphModel/);
assert.match(getGuideSection("skeleton").content, /adaptiveColors="auto"/);
assert.match(getGuideSection("layout").content, /elk/i);
assert.match(getGuideSection("layout").content, /150px|<150/);
assert.match(getGuideSection("containers").content, /fillColor=none/);
assert.match(getGuideSection("icons-aws").content, /resourceIcon/);
assert.match(getGuideSection("icons-aws").content, /elasticsearch_service/);
assert.match(getGuideSection("icons-azure").content, /img\/lib\/azure2/);
});
test("omitting the section returns the index of sections", () => {
const idx = getGuideSection();
assert.equal(idx.section, "index");
for (const s of GUIDE_SECTIONS) assert.ok(idx.content.includes(s));
assert.ok(Buffer.byteLength(idx.content, "utf8") <= MAX_BYTES);
});
test("an unknown section falls back to the index", () => {
const idx = getGuideSection("nonsense");
assert.equal(idx.section, "index");
});