fix: regenerate pi-claude-cli MCP config per session and auto-sync skill tools
The MCP config was generated lazily once and locked, so engine session-scoped tools (fn_review_spec, fn_review_step) never reached the Claude CLI subprocess and triage/executor sessions failed with "unknown tool" errors. Now the config is hashed per call and rewritten when the tool set changes. Also adds scripts/sync-fusion-skill-tools.mjs to regenerate the SKILL.md tool-categories block from extension.ts at build time, with a --check mode wired into skill-sync tests so drift fails CI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -269,4 +269,26 @@ describe("writeMcpConfig", () => {
|
||||
expect(result).toMatch(/pi-claude-mcp-config/);
|
||||
expect(result).toMatch(/\.json$/);
|
||||
});
|
||||
|
||||
it("includes cacheKey in filenames when provided so distinct tool sets do not collide", () => {
|
||||
const toolDefs: McpToolDef[] = [
|
||||
{
|
||||
name: "search",
|
||||
description: "Search",
|
||||
inputSchema: { type: "object" },
|
||||
},
|
||||
];
|
||||
|
||||
const pathA = writeMcpConfig(toolDefs, "aaaaaaaaaaaa");
|
||||
const pathB = writeMcpConfig(toolDefs, "bbbbbbbbbbbb");
|
||||
|
||||
expect(pathA).toContain("aaaaaaaaaaaa");
|
||||
expect(pathB).toContain("bbbbbbbbbbbb");
|
||||
expect(pathA).not.toBe(pathB);
|
||||
|
||||
const schemaPathA = mocks.writeFileSync.mock.calls[0][0];
|
||||
const schemaPathB = mocks.writeFileSync.mock.calls[2][0];
|
||||
expect(schemaPathA).toContain("aaaaaaaaaaaa");
|
||||
expect(schemaPathB).toContain("bbbbbbbbbbbb");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,13 +75,21 @@ export function getCustomToolDefs(pi: PiInstance): McpToolDef[] {
|
||||
* 2. Config file: MCP config pointing to the schema-only server
|
||||
*
|
||||
* @param toolDefs - Array of custom tool definitions
|
||||
* @param cacheKey - Optional suffix appended to filenames so that distinct
|
||||
* tool sets (e.g. session-scoped tool registrations) get distinct files
|
||||
* and don't race on a single shared path.
|
||||
* @returns Path to the MCP config file
|
||||
*/
|
||||
export function writeMcpConfig(toolDefs: McpToolDef[]): string {
|
||||
export function writeMcpConfig(
|
||||
toolDefs: McpToolDef[],
|
||||
cacheKey?: string,
|
||||
): string {
|
||||
const suffix = cacheKey ? `${process.pid}-${cacheKey}` : `${process.pid}`;
|
||||
|
||||
// Write tool schemas to temp file
|
||||
const schemaFilePath = join(
|
||||
tmpdir(),
|
||||
`pi-claude-mcp-schemas-${process.pid}.json`,
|
||||
`pi-claude-mcp-schemas-${suffix}.json`,
|
||||
);
|
||||
writeFileSync(schemaFilePath, JSON.stringify(toolDefs));
|
||||
|
||||
@@ -103,7 +111,7 @@ export function writeMcpConfig(toolDefs: McpToolDef[]): string {
|
||||
// Write config to temp file
|
||||
const configFilePath = join(
|
||||
tmpdir(),
|
||||
`pi-claude-mcp-config-${process.pid}.json`,
|
||||
`pi-claude-mcp-config-${suffix}.json`,
|
||||
);
|
||||
writeFileSync(configFilePath, JSON.stringify(config));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user