feat: configure xdev prompt docs

This commit is contained in:
Joe Shull
2026-07-23 11:46:46 -06:00
committed by can1357
parent 3d64910bb0
commit f15191c37d
4 changed files with 51 additions and 13 deletions
@@ -186,6 +186,7 @@ describe("read and write route xd:// device URLs", () => {
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "write-xdev-docs-"));
try {
const session = xdevSession(tempDir);
expect(session.settings.get("tools.xdevDocs")).toBe("builtins");
await createTools(session);
const mounted = session.xdevRegistry?.list() ?? [];
expect(mounted.length).toBeGreaterThan(0);
@@ -208,30 +209,37 @@ describe("read and write route xd:// device URLs", () => {
}
});
it("docsAll truncates external (dynamic-mount) descriptions to the cap; built-ins and read xd:// stay full", async () => {
it("docsAll supports inline, builtins, and catalog prompt modes", async () => {
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "write-xdev-external-"));
try {
const session = xdevSession(tempDir);
expect(session.settings.get("tools.xdevDocs")).toBe("builtins");
await createTools(session);
const registry = session.xdevRegistry;
if (!registry) throw new Error("expected xdev registry");
const mounted = registry.list();
const longDescription = `LEDE ${"y".repeat(XdevRegistry.EXTERNAL_DESCRIPTION_CAP * 3)} TAIL`;
const longDescription = "LEDE " + "y".repeat(XdevRegistry.EXTERNAL_DESCRIPTION_CAP * 3) + " TAIL";
const external = Object.create(mounted[0]!) as (typeof mounted)[number];
Object.defineProperty(external, "name", { value: "mcp_external_tool" });
Object.defineProperty(external, "description", { value: longDescription });
registry.reconcile([external]);
const docs = registry.docsAll();
// External device: schema section present, description cut at the cap.
expect(docs).toContain("## mcp_external_tool");
expect(docs).toContain("LEDE ");
expect(docs).not.toContain("TAIL");
expect(docs).toContain("… (full docs: read xd://mcp_external_tool)");
// Built-in devices keep their full curated description.
expect(docs).toContain(mounted[0]!.description ?? "");
// On-demand docs return the untruncated text.
const inlineDocs = registry.docsAll("inline");
expect(inlineDocs).toContain("## mcp_external_tool");
expect(inlineDocs).toContain("LEDE ");
expect(inlineDocs).not.toContain("TAIL");
expect(inlineDocs).toContain("… (full docs: read xd://mcp_external_tool)");
const builtinsDocs = registry.docsAll("builtins");
expect(builtinsDocs).toContain("## ");
expect(builtinsDocs).not.toContain("## mcp_external_tool");
expect(builtinsDocs).toContain("- xd://mcp_external_tool —");
const catalogDocs = registry.docsAll("catalog");
expect(catalogDocs).not.toContain(`## ${mounted[0]!.name}`);
expect(catalogDocs).toContain("- xd://");
expect(catalogDocs).toContain("- xd://mcp_external_tool —");
expect(registry.docs("mcp_external_tool")).toContain("TAIL");
} finally {
await removeWithRetries(tempDir);