Files
oh-my-pi/packages/coding-agent/test/internal-urls/docs-tool-coverage.test.ts
T
roboomp 92740d3c4f docs(coding-agent): completed full omp docs sync
Added a contributor-facing native crate map (docs/native-crates.md) covering pi-natives, pi-shell, pi-ast, pi-iso, pi-walker, pi_uu_grep, pi-uutils-ctx, and vendored brush crates, and linked it from natives-architecture.md and user-facing-packages.md.

Added a docs-index tool coverage test asserting every BUILTIN_TOOL_NAMES entry and injected custom tool (generate_image, tts) has a docs/tools/<name>.md page served by omp://.

Inlined tiny fail/buildPayloadText/checkDocsIndexFreshness helpers in generate-docs-index.ts per the project rule against single-expression named functions.

Fixes #3934
2026-07-01 00:00:52 +00:00

38 lines
1.7 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import * as fs from "node:fs";
import * as path from "node:path";
import { BUILTIN_TOOL_NAMES } from "@oh-my-pi/pi-coding-agent/tools/builtin-names";
// Every shipped built-in tool that is exposed to the model in normal sessions
// must have a docs/tools/<name>.md root doc served by `omp://`. File names use
// underscores or hyphens; the test accepts either form so renaming the on-disk
// page does not require coordinating with the wire name.
const docsToolsDir = path.resolve(import.meta.dir, "../../../../docs/tools");
const expectedDocPaths = (name: string): string[] => [
path.join(docsToolsDir, `${name}.md`),
path.join(docsToolsDir, `${name.replace(/_/g, "-")}.md`),
];
// Custom tools injected by the SDK (`packages/coding-agent/src/sdk.ts`) when
// their settings are enabled. Built-in tool factories live in BUILTIN_TOOLS but
// these custom tools are not present there, so the coverage list is explicit.
const CUSTOM_TOOL_NAMES = ["generate_image", "tts"] as const;
describe("omp:// root docs coverage", () => {
it.each([...BUILTIN_TOOL_NAMES])("documents builtin tool %s", name => {
const candidates = expectedDocPaths(name);
const present = candidates.find(candidate => fs.existsSync(candidate));
expect(
present,
`Missing docs/tools/<name>.md for built-in tool "${name}". Tried: ${candidates.join(", ")}.`,
).toBeDefined();
});
it.each([...CUSTOM_TOOL_NAMES])("documents injected custom tool %s", name => {
const candidates = expectedDocPaths(name);
const present = candidates.find(candidate => fs.existsSync(candidate));
expect(present, `Missing docs/tools/<name>.md for injected custom tool "${name}".`).toBeDefined();
});
});