mirror of
https://bitbucket.org/siakitem/my-pi.git
synced 2026-08-28 08:35:57 +00:00
feat(tool-search): expand dynamic group activation
This commit is contained in:
@@ -11,7 +11,9 @@ import {
|
||||
parseGeneratedCatalog,
|
||||
rankGroups,
|
||||
readCachedCatalog,
|
||||
selectConfidentGroup,
|
||||
writeCachedCatalog,
|
||||
type ToolCatalog,
|
||||
} from "../extensions/catalog.ts";
|
||||
|
||||
function tool(name: string, description: string): ToolInfo {
|
||||
@@ -62,6 +64,29 @@ test("validates exact generated assignments and ranks generated metadata", () =>
|
||||
);
|
||||
});
|
||||
|
||||
test("prefers exact tool names and refuses weak or ambiguous query activation", () => {
|
||||
const catalog: ToolCatalog = {
|
||||
version: 1,
|
||||
manifestHash: "test",
|
||||
generatedAt: new Date(0).toISOString(),
|
||||
groups: [
|
||||
{ id: "remote-files", title: "Remote files", summary: "Read remote files", useWhen: [], avoidWhen: [], tools: ["ssh_read"] },
|
||||
{ id: "web-reader", title: "Web reader", summary: "Read web pages", useWhen: [], avoidWhen: [], tools: ["web_read"] },
|
||||
],
|
||||
tools: [
|
||||
{ name: "ssh_read", summary: "Read a remote file", useWhen: [], avoidWhen: [], keywords: ["SSH"], primaryGroup: "remote-files" },
|
||||
{ name: "web_read", summary: "Read a web page", useWhen: [], avoidWhen: [], keywords: ["web"], primaryGroup: "web-reader" },
|
||||
],
|
||||
};
|
||||
|
||||
assert.equal(selectConfidentGroup(rankGroups(catalog, "ssh_read"), "ssh_read")?.id, "remote-files");
|
||||
assert.equal(selectConfidentGroup(rankGroups(catalog, "read"), "read"), undefined);
|
||||
assert.equal(
|
||||
selectConfidentGroup(rankGroups(catalog, "completely unrelated capability"), "completely unrelated capability"),
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
test("writes a private cache and rejects a stale manifest hash", async () => {
|
||||
const directory = await mkdtemp(join(tmpdir(), "tool-search-catalog-"));
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user