mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-27 20:00:51 +00:00
Includes all Phase 3 rounds (1-5), Node unit test mock compatibility fixes, and Codex review fixes (pinyin readiness subscribers & KnownHostsManager mount retention).
82 lines
2.6 KiB
JavaScript
82 lines
2.6 KiB
JavaScript
"use strict";
|
|
|
|
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const fs = require("node:fs");
|
|
const path = require("node:path");
|
|
|
|
const { AGENT_KINDS, listAgentToolSpecs, listCattyToolSpecs } = require("../electron/capabilities/codegen/toolSurfaces.cjs");
|
|
|
|
const GENERATED_DIR = path.join(
|
|
__dirname,
|
|
"..",
|
|
"infrastructure",
|
|
"ai",
|
|
"harness",
|
|
"generated",
|
|
);
|
|
|
|
test("committed cattyToolSpecs.json matches listCattyToolSpecs()", () => {
|
|
const committed = JSON.parse(
|
|
fs.readFileSync(path.join(GENERATED_DIR, "cattyToolSpecs.json"), "utf8"),
|
|
);
|
|
const fresh = listCattyToolSpecs();
|
|
assert.deepEqual(committed, fresh);
|
|
});
|
|
|
|
test("committed globalAgentToolSpecs.json matches listAgentToolSpecs(global)", () => {
|
|
const committed = JSON.parse(
|
|
fs.readFileSync(path.join(GENERATED_DIR, "globalAgentToolSpecs.json"), "utf8"),
|
|
);
|
|
const fresh = listAgentToolSpecs(AGENT_KINDS.GLOBAL);
|
|
assert.deepEqual(committed, fresh);
|
|
});
|
|
|
|
test("committed toolNameIndex.json matches sidebar and global capability tool specs", () => {
|
|
const committed = JSON.parse(
|
|
fs.readFileSync(path.join(GENERATED_DIR, "toolNameIndex.json"), "utf8"),
|
|
);
|
|
const globalByCapabilityId = {};
|
|
for (const spec of listAgentToolSpecs(AGENT_KINDS.GLOBAL)) {
|
|
if (spec.capabilityId && spec.toolName && !globalByCapabilityId[spec.capabilityId]) {
|
|
globalByCapabilityId[spec.capabilityId] = spec.toolName;
|
|
}
|
|
}
|
|
const sidebarByRpcMethod = {};
|
|
const sidebarToolNameToCapability = {};
|
|
const sidebarRpcMethodToCapability = {};
|
|
const freshApprovalSet = new Set();
|
|
const grantableSet = new Set();
|
|
for (const spec of listCattyToolSpecs()) {
|
|
if (spec.rpcMethod && spec.toolName && !sidebarByRpcMethod[spec.rpcMethod]) {
|
|
sidebarByRpcMethod[spec.rpcMethod] = spec.toolName;
|
|
}
|
|
if (spec.toolName && spec.capabilityId) {
|
|
sidebarToolNameToCapability[spec.toolName] = spec.capabilityId;
|
|
}
|
|
if (spec.rpcMethod && spec.capabilityId) {
|
|
sidebarRpcMethodToCapability[spec.rpcMethod] = spec.capabilityId;
|
|
}
|
|
if (spec.policy?.requiresFreshApproval && spec.capabilityId) {
|
|
freshApprovalSet.add(spec.capabilityId);
|
|
}
|
|
if (
|
|
spec.policy?.write
|
|
&& !spec.policy?.bypassesApproval
|
|
&& !spec.policy?.requiresFreshApproval
|
|
&& spec.capabilityId
|
|
) {
|
|
grantableSet.add(spec.capabilityId);
|
|
}
|
|
}
|
|
assert.deepEqual(committed, {
|
|
globalByCapabilityId,
|
|
sidebarByRpcMethod,
|
|
sidebarToolNameToCapability,
|
|
sidebarRpcMethodToCapability,
|
|
freshApprovalOnlyCapabilities: [...freshApprovalSet].sort(),
|
|
grantableCapabilityIds: [...grantableSet].sort(),
|
|
});
|
|
});
|
|
|