Files
waggle-os/packages/server/tests/tools-routes.test.ts
shumeiko.it 2edfd01e6e refactor: remove coding-agent hook management (P2.2)
The hooks for Claude Code, Codex and the other agents ran the
hive-mind-hooks-* packages, which left the repository; ADR-0002 hides
the feature in v1. Remove the hook installer surface from the tool
launcher, the POST /api/tools/hooks route, the hook status probe in
tool detection, and the hook fields of the tool manifest and detection
envelope (hookCapable, hookRoot, hookPointer, hooksInstalled,
hookPointerPath). Third-party adapter manifests no longer accept the
hook fields.

In the web UI, remove the hidden hook actions and the "How memory is
shared" explainer from the Launcher, adapter.manageHooks, the
hook-wired count in Mission Control and the agentHooks and memoryMcp
memory feature flags. Launch, watch and stop are unchanged; the
roadmap tool note no longer mentions hooks.
2026-11-01 00:35:13 +01:00

102 lines
3.3 KiB
TypeScript

/**
* AI-OS Phase 0 — integration test for the tool-detection route.
*
* Boots a real local server (with the same fixture pattern used by
* cross-platform.test.ts) and hits GET /api/tools/detect end-to-end.
*
* The detector itself is exhaustively unit-tested with injected deps
* in `packages/agent/tests/tool-detection.test.ts`. This test verifies
* that:
* 1. The route is wired into the local server.
* 2. The response envelope shape matches the shared contract.
* 3. Every SUPPORTED_TOOLS id appears in the response.
*
* We deliberately do NOT assert on specific tool installation state
* — that depends on the host machine running the tests and would
* make the suite non-hermetic. We also do not assert on auth
* rejection: the local sidecar is loopback-bound and intentionally
* permits read-only in-process calls; tool detection reports only
* what's already on the user's own machine and is not sensitive.
*/
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import type { FastifyInstance } from 'fastify';
import { SUPPORTED_TOOLS } from '@waggle/shared';
import { buildLocalServer } from '../src/local/index.js';
import { injectWithAuth } from './test-utils.js';
function createTmpDir(prefix: string): string {
return fs.mkdtempSync(path.join(os.tmpdir(), `waggle-tools-${prefix}-`));
}
function cleanupDir(dir: string): void {
try {
fs.rmSync(dir, { recursive: true, force: true });
} catch {
/* best-effort */
}
}
describe('GET /api/tools/detect', () => {
let server: FastifyInstance;
let tmpDir: string;
beforeAll(async () => {
tmpDir = createTmpDir('routes');
server = await buildLocalServer({ dataDir: tmpDir });
await server.ready();
});
afterAll(async () => {
if (server) await server.close();
if (tmpDir) cleanupDir(tmpDir);
});
it('returns 200 with a stable envelope shape', async () => {
const res = await injectWithAuth(server, {
method: 'GET',
url: '/api/tools/detect',
});
expect(res.statusCode).toBe(200);
const body = res.json();
expect(body).toHaveProperty('platform');
expect(body).toHaveProperty('detectedAt');
expect(body).toHaveProperty('tools');
expect(Array.isArray(body.tools)).toBe(true);
});
it('covers every supported tool id in the envelope', async () => {
const res = await injectWithAuth(server, {
method: 'GET',
url: '/api/tools/detect',
});
expect(res.statusCode).toBe(200);
const body = res.json();
const ids = body.tools.map((t: { id: string }) => t.id);
for (const id of SUPPORTED_TOOLS) {
expect(ids).toContain(id);
}
});
it('each tool entry has the expected fields', async () => {
const res = await injectWithAuth(server, {
method: 'GET',
url: '/api/tools/detect',
});
const body = res.json();
for (const t of body.tools) {
expect(t).toHaveProperty('id');
expect(t).toHaveProperty('displayName');
expect(t).toHaveProperty('installed');
expect(t).toHaveProperty('installedPath');
expect(t).toHaveProperty('version');
expect(t).not.toHaveProperty('hooksInstalled');
expect(typeof t.installed).toBe('boolean');
}
});
});