fix: align aggregate tools with session capabilities
This commit is contained in:
@@ -94,6 +94,10 @@ describe("analysis context queries", () => {
|
||||
const bookmarkInputs: Readonly<Record<string, unknown>>[] = [];
|
||||
const analysis: AnalysisOperationPort = {
|
||||
execute: (operation, input) => {
|
||||
if (operation === "current_document")
|
||||
return Promise.resolve(
|
||||
ok(createAnalysisExecution("fixture", provider)),
|
||||
);
|
||||
if (operation === "comment")
|
||||
return Promise.resolve(
|
||||
err(new AnalysisProtocolError("comments unavailable")),
|
||||
@@ -145,6 +149,7 @@ describe("analysis context queries", () => {
|
||||
expect(result).toMatchObject({
|
||||
ok: true,
|
||||
value: {
|
||||
document: "fixture",
|
||||
name: { state: "available", value: "entry" },
|
||||
comment: {
|
||||
state: "unavailable",
|
||||
@@ -156,7 +161,7 @@ describe("analysis context queries", () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(bookmarkInputs).toEqual([{}]);
|
||||
expect(bookmarkInputs).toEqual([{ document: "fixture" }]);
|
||||
});
|
||||
|
||||
it("propagates cancellation instead of degrading it to an unavailable facet", async () => {
|
||||
@@ -171,7 +176,10 @@ describe("analysis context queries", () => {
|
||||
};
|
||||
|
||||
await expect(
|
||||
inspectAddressContext(analysis, { address: "0x401000" }),
|
||||
inspectAddressContext(analysis, {
|
||||
address: "0x401000",
|
||||
document: "fixture",
|
||||
}),
|
||||
).resolves.toEqual(err(cancelled));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -194,4 +194,36 @@ describe("capability inventory", () => {
|
||||
missing_optional: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("advertises navigation context only when every cursor operation is available", () => {
|
||||
const capabilities = [
|
||||
"current_document",
|
||||
"current_address",
|
||||
"resolve_containing_procedure",
|
||||
].map((operation) => ({
|
||||
operation,
|
||||
available: true,
|
||||
reason: null,
|
||||
}));
|
||||
expect(
|
||||
entry(
|
||||
"get_navigation_context",
|
||||
status({ open: true, kind: "executable", capabilities }),
|
||||
),
|
||||
).toMatchObject({ available: true, reason: "available" });
|
||||
expect(
|
||||
entry(
|
||||
"get_navigation_context",
|
||||
status({
|
||||
open: true,
|
||||
kind: "executable",
|
||||
capabilities: capabilities.slice(0, 2),
|
||||
}),
|
||||
),
|
||||
).toMatchObject({
|
||||
available: false,
|
||||
reason: "provider_missing",
|
||||
remediation: expect.stringContaining("resolve_containing_procedure"),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -136,9 +136,14 @@ describe("target-free MCP lifecycle", () => {
|
||||
});
|
||||
const mcp = new Client({ name: "session-test", version: "1.0.0" });
|
||||
let resourceListChanges = 0;
|
||||
let unknownResourceUpdates = 0;
|
||||
mcp.setNotificationHandler("notifications/resources/list_changed", () => {
|
||||
resourceListChanges += 1;
|
||||
});
|
||||
mcp.setNotificationHandler("notifications/resources/updated", (notice) => {
|
||||
if (notice.params.uri.startsWith("rea://unknown/"))
|
||||
unknownResourceUpdates += 1;
|
||||
});
|
||||
const [clientTransport, serverTransport] =
|
||||
InMemoryTransport.createLinkedPair();
|
||||
resources.push(mcp, server);
|
||||
@@ -297,6 +302,7 @@ describe("target-free MCP lifecycle", () => {
|
||||
});
|
||||
expect(resolved.isError).not.toBe(true);
|
||||
await new Promise<void>((resolve) => setImmediate(resolve));
|
||||
expect(unknownResourceUpdates).toBe(1);
|
||||
expect(resourceListChanges).toBe(changesBeforeMutation);
|
||||
expect(
|
||||
structured(
|
||||
|
||||
Reference in New Issue
Block a user