refactor(artifacts): consolidate inventory into inspection

This commit is contained in:
morluto
2026-09-29 09:22:24 +08:00
parent a66e43a99d
commit 0fe96d92df
28 changed files with 375 additions and 280 deletions
@@ -37,23 +37,58 @@ it("returns every artifact occurrence in one MCP call", async () => {
arguments: { path: archive },
});
expect(opened.isError).not.toBe(true);
const names = (await client.listTools()).tools.map(({ name }) => name);
expect(names).toContain("inspect_artifact");
expect(names).not.toContain("inventory_artifact");
const status = await client.callTool({
name: "binary_session",
arguments: {},
});
expect(
z
.object({
result: z.object({
capabilities: z.array(z.object({ operation: z.string() })),
}),
})
.parse(status.structuredContent)
.result.capabilities.map(({ operation }) => operation),
).not.toContain("inventory_artifact");
const result = await client.callTool({
name: "inventory_artifact",
name: "inspect_artifact",
arguments: {},
});
expect(result.isError, JSON.stringify(result.structuredContent)).not.toBe(
true,
);
const inventory = z
const inspection = z
.object({
occurrences: z.array(z.object({ logical_path: z.string() })),
substeps: z.array(
z.object({
evidence: z.object({
normalized_result: z.object({
occurrences: z.array(z.object({ logical_path: z.string() })),
}),
}),
}),
),
observations: z.array(z.unknown()),
derived_relationships: z.array(z.unknown()),
hypotheses: z.array(z.unknown()),
unexplored_branches: z.array(z.unknown()),
next_probes: z.array(z.unknown()),
})
.parse(
z.object({ result: z.unknown() }).parse(result.structuredContent)
.result,
);
expect(inventory.occurrences).toHaveLength(fileCount + 1);
expect(inventory.occurrences.length).toBe(fileCount + 1);
const occurrences =
inspection.substeps[0]?.evidence.normalized_result.occurrences;
if (occurrences === undefined)
throw new Error("inspection omitted the artifact inventory");
expect(occurrences).toHaveLength(fileCount + 1);
expect(inspection.observations.length).toBeGreaterThan(0);
expect(inspection.derived_relationships.length).toBeGreaterThan(0);
} finally {
await Promise.allSettled([client.close(), server.close(), session.close()]);
}