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.
This commit is contained in:
shumeiko.it
2026-11-01 00:35:13 +01:00
parent 46687a823a
commit 2edfd01e6e
32 changed files with 168 additions and 2575 deletions

View File

@@ -5,13 +5,11 @@ import { z } from 'zod';
import {
detectInstalledTools,
launchTool,
runHookCommand,
ToolProcessTracker,
ToolOutputBuffer,
getToolRegistry,
type HookAction,
} from '@waggle/agent';
import { SUPPORTED_TOOLS, applyPromptArgTemplate, type ToolId, type ToolManifest } from '@waggle/shared';
import { applyPromptArgTemplate, type ToolManifest } from '@waggle/shared';
import { resolveWorkspaceExecutionRoot } from '../workspace-execution-root.js';
import { canonicalWorkspaceRoot } from '../workspace-turn-coordinator.js';
@@ -62,7 +60,7 @@ declare module 'fastify' {
}
/**
* AI-OS — tool-detection + launcher + hook-management routes.
* AI-OS — tool-detection + launcher routes.
*
* Endpoints:
*
@@ -75,17 +73,11 @@ declare module 'fastify' {
* Spawn the tool detached with workspace-context env injection.
* (Phase 2A)
*
* POST /api/tools/hooks
* Body: { id, action: 'install' | 'verify' | 'uninstall', cliPath? }
* Run `npx @waggle/hive-mind-hooks-<id> <action>`.
* (Phase 2A)
*
* All routes are read-only by intent (detect) or surface only the
* user's own machine (launch/hooks). The local sidecar is loopback-
* user's own machine (launch). The local sidecar is loopback-
* bound; tool detection is not sensitive.
*/
const TOOL_ID_VALUES = SUPPORTED_TOOLS as readonly string[];
const TOOL_ID_SAFE = /^[A-Za-z0-9._-]+$/;
const PROCESS_RECONCILE_INTERVAL_MS = 5_000;
@@ -103,13 +95,6 @@ const launchBodySchema = z.object({
prompt: z.string().max(8000).optional(),
});
const hooksBodySchema = z.object({
id: z.string().refine((s): s is ToolId => TOOL_ID_VALUES.includes(s), {
message: 'unknown tool id',
}),
action: z.enum(['install', 'verify', 'uninstall']),
}).strict();
const killBodySchema = z.object({
pid: z.number().int().positive(),
});
@@ -748,34 +733,6 @@ const toolsRoutesImpl: FastifyPluginAsync = async (server) => {
res.on('close', () => unsubscribe());
return reply;
});
// ── POST /api/tools/hooks (Phase 2A) ─────────────────────────────
server.post('/api/tools/hooks', async (request, reply) => {
const parsed = hooksBodySchema.safeParse(request.body);
if (!parsed.success) {
return reply
.code(400)
.send({ error: 'Validation failed', details: parsed.error.flatten() });
}
const body = parsed.data;
try {
const result = await runHookCommand({
id: body.id,
action: body.action as HookAction,
dataDir: server.localConfig.dataDir,
});
if (!result.ok) {
return reply.code(result.errorCode === 'hook_runtime_missing' ? 503 : 400).send(result);
}
return reply.code(200).send(result);
} catch (err) {
const message = err instanceof Error ? err.message : 'unknown error';
server.log.error({ err }, 'hook command failed');
return reply
.code(500)
.send({ error: 'hook command failed', message });
}
});
};
/**

View File

@@ -11,8 +11,6 @@ const manifest = (promptArgTemplate?: string[]): ToolManifest => ({
id: 'foo',
displayName: 'Foo',
launchable: true,
hookCapable: false,
hookPointer: '.foo/hm.json',
detect: { kind: 'path', binaryName: 'foo' },
...(promptArgTemplate ? { promptArgTemplate } : {}),
builtin: false,

View File

@@ -26,8 +26,6 @@ function detectedTool(id: string, installed = true): DetectedTool {
installed,
installedPath: installed ? `/tools/${id}` : null,
version: installed ? '1.0.0' : null,
hooksInstalled: false,
hookPointerPath: null,
};
}

View File

@@ -34,8 +34,6 @@ describe('external tool roadmap gate', () => {
installed: true,
installedPath: 'C:\\tools\\openclaw.cmd',
version: 'test',
hooksInstalled: false,
hookPointerPath: null,
}],
}));
server.decorate('externalToolRunner', runner);

View File

@@ -189,7 +189,6 @@ describe('external tool run routes', () => {
tools: [{
id: 'codex', displayName: 'Codex CLI', installed: true,
installedPath: 'C:\\trusted\\codex.cmd', version: 'test',
hooksInstalled: true, hookPointerPath: null,
}],
}));
server.decorate('externalToolRunner', async (request) => {
@@ -418,7 +417,7 @@ describe('external tool run routes', () => {
} as never);
server.decorate('externalToolDetector', async () => ({
platform: 'win32', detectedAt: new Date().toISOString(),
tools: [{ id: 'codex', displayName: 'Codex CLI', installed: true, installedPath: 'C:\\trusted\\codex.cmd', version: 'test', hooksInstalled: true, hookPointerPath: null }],
tools: [{ id: 'codex', displayName: 'Codex CLI', installed: true, installedPath: 'C:\\trusted\\codex.cmd', version: 'test' }],
}));
server.decorate('externalToolRunner', async (request) => {
calls.push({
@@ -551,10 +550,10 @@ describe('external tool run routes', () => {
server.decorate('externalToolDetector', async () => ({
platform: 'win32', detectedAt: new Date().toISOString(),
tools: [
{ id: 'claude-code', displayName: 'Claude Code', installed: true, installedPath: 'claude.exe', version: 'test', hooksInstalled: true, hookPointerPath: null },
{ id: 'codex', displayName: 'Codex CLI', installed: true, installedPath: 'codex.exe', version: 'test', hooksInstalled: true, hookPointerPath: null },
{ id: 'hermes', displayName: 'Hermes', installed: true, installedPath: 'hermes.exe', version: 'test', hooksInstalled: true, hookPointerPath: null },
{ id: 'openclaw', displayName: 'OpenClaw', installed: true, installedPath: 'openclaw.exe', version: openClawVersion, hooksInstalled: true, hookPointerPath: null },
{ id: 'claude-code', displayName: 'Claude Code', installed: true, installedPath: 'claude.exe', version: 'test' },
{ id: 'codex', displayName: 'Codex CLI', installed: true, installedPath: 'codex.exe', version: 'test' },
{ id: 'hermes', displayName: 'Hermes', installed: true, installedPath: 'hermes.exe', version: 'test' },
{ id: 'openclaw', displayName: 'OpenClaw', installed: true, installedPath: 'openclaw.exe', version: openClawVersion },
],
}));
server.decorate('externalToolRunner', async (request) => {
@@ -845,7 +844,7 @@ describe('external tool run routes', () => {
} as never);
server.decorate('externalToolDetector', async () => ({
platform: 'win32', detectedAt: new Date().toISOString(),
tools: [{ id: 'codex', displayName: 'Codex CLI', installed: true, installedPath: 'codex.cmd', version: 'test', hooksInstalled: false, hookPointerPath: null }],
tools: [{ id: 'codex', displayName: 'Codex CLI', installed: true, installedPath: 'codex.cmd', version: 'test' }],
}));
server.decorate('externalToolRunner', async () => ({
status: 'failed', exitCode: 1, summary: 'Partial provider answer', stdoutTail: '',
@@ -890,7 +889,7 @@ describe('external tool run routes', () => {
server.decorate('externalCollaborationRuntime', collaborationRuntime);
server.decorate('externalToolDetector', async () => ({
platform: 'win32', detectedAt: new Date().toISOString(),
tools: [{ id: 'codex', displayName: 'Codex CLI', installed: true, installedPath: 'codex.cmd', version: 'test', hooksInstalled: false, hookPointerPath: null }],
tools: [{ id: 'codex', displayName: 'Codex CLI', installed: true, installedPath: 'codex.cmd', version: 'test' }],
}));
server.decorate('externalToolRunner', (request) => new Promise<ExternalToolRunResult>((resolve) => {
request.onEvent?.({
@@ -968,7 +967,6 @@ describe('external tool run routes', () => {
tools: [{
id: 'codex', displayName: 'Codex CLI', installed: true,
installedPath: 'codex.cmd', version: 'test',
hooksInstalled: false, hookPointerPath: null,
}],
}));
server.decorate('externalToolRunner', async (request) => {
@@ -1083,7 +1081,6 @@ describe('external tool run routes', () => {
tools: [{
id: 'openclaw', displayName: 'OpenClaw', installed: true,
installedPath: 'openclaw.cmd', version: 'test',
hooksInstalled: false, hookPointerPath: null,
}],
}));
server.decorate('externalToolRunner', runner);
@@ -1153,7 +1150,6 @@ describe('external tool run routes', () => {
tools: [{
id: 'openclaw', displayName: 'OpenClaw', installed: true,
installedPath: 'openclaw.cmd', version: 'test',
hooksInstalled: false, hookPointerPath: null,
}],
}));
server.decorate('externalToolRunner', async (request) => {
@@ -1380,7 +1376,6 @@ describe('external tool run routes', () => {
tools: [{
id: 'openclaw', displayName: 'OpenClaw', installed: true,
installedPath, version: binaryVersion,
hooksInstalled: false, hookPointerPath: null,
}],
}));
server.decorate('externalToolRunner', async (request) => {
@@ -1469,7 +1464,6 @@ describe('external tool run routes', () => {
tools: [{
id: 'openclaw', displayName: 'OpenClaw', installed: true,
installedPath: 'openclaw.cmd', version: 'test',
hooksInstalled: false, hookPointerPath: null,
}],
}));
server.decorate('externalToolRunner', async (request) => {
@@ -1571,7 +1565,6 @@ describe('external tool run routes', () => {
tools: [{
id: 'openclaw' as const, displayName: 'OpenClaw', installed: true,
installedPath: 'openclaw.cmd', version: 'test',
hooksInstalled: false, hookPointerPath: null,
}],
};
});
@@ -1622,7 +1615,7 @@ describe('external tool run routes', () => {
platform: 'win32', detectedAt: new Date().toISOString(),
tools: [{
id: 'codex', displayName: 'Codex CLI', installed: true, installedPath: 'codex.cmd',
version: 'test', hooksInstalled: false, hookPointerPath: null,
version: 'test',
}],
}));
server.decorate('externalToolRunner', async () => {
@@ -1678,7 +1671,7 @@ describe('external tool run routes', () => {
tools: [{
id: 'codex', displayName: 'Codex CLI', installed: true,
installedPath: 'C:\\Program Files\\WindowsApps\\OpenAI.Codex\\resources\\codex.exe',
version: null, hooksInstalled: false, hookPointerPath: null,
version: null,
launchable: false, diagnostic: 'The Store resource CLI cannot launch outside its package.',
}],
}));

View File

@@ -1,12 +1,9 @@
/**
* AI-OS Phase 2A — integration tests for /api/tools/launch and
* /api/tools/hooks.
* AI-OS Phase 2A — integration tests for /api/tools/launch.
*
* The launch + hook routes call into `@waggle/agent`'s launchTool /
* runHookCommand. To keep these tests hermetic AND non-destructive
* (`npx --yes @waggle/hive-mind-hooks-claude-code install` would
* actually modify ~/.claude/settings.json on the test machine), we
* mock the launcher module at the module level.
* The launch route calls into `@waggle/agent`'s launchTool. To keep these
* tests hermetic AND non-destructive (a real launch would start the tool on
* the test machine), we mock the launcher module at the module level.
*
* The launcher unit tests (`packages/agent/tests/tool-launcher.test.ts`)
* cover the actual spawn / exec paths with injected deps — this
@@ -32,8 +29,6 @@ vi.mock('@waggle/agent', async (importOriginal) => {
id: 'foo-cli',
displayName: 'Foo CLI',
launchable: true,
hookCapable: false,
hookPointer: '.foo/hive-mind-install.json',
detect: { kind: 'path' as const, binaryName: 'foo' },
promptArgTemplate: ['--print', '{prompt}'],
builtin: false,
@@ -50,8 +45,6 @@ vi.mock('@waggle/agent', async (importOriginal) => {
installed: true,
installedPath: `/server-detected/${manifest.id}`,
version: 'test',
hooksInstalled: false,
hookPointerPath: null,
})),
})),
launchTool: vi.fn((opts: { id: string; installedPath: string }) => ({
@@ -59,22 +52,12 @@ vi.mock('@waggle/agent', async (importOriginal) => {
pid: 99999,
executed: { binary: opts.installedPath, args: [] },
})),
runHookCommand: vi.fn(
async (opts: { id: string; action: string }) => ({
ok: true,
action: opts.action,
packageName: `@waggle/hive-mind-hooks-${opts.id}`,
stdout: 'mock install output',
stderr: '',
code: 0,
}),
),
};
});
import { buildLocalServer } from '../src/local/index.js';
import { injectWithAuth } from './test-utils.js';
import { detectInstalledTools, launchTool, runHookCommand } from '@waggle/agent';
import { detectInstalledTools, launchTool } from '@waggle/agent';
import { loopbackSidecarUrl } from '../src/local/routes/tools.js';
import { resolveWorkspaceExecutionRoot } from '../src/local/workspace-execution-root.js';
@@ -240,7 +223,7 @@ describe('POST /api/tools/launch', () => {
tools: [{
id: 'codex', displayName: 'Codex CLI', installed: true,
installedPath: 'C:\\Program Files\\WindowsApps\\OpenAI.Codex\\resources\\codex.exe',
version: null, hooksInstalled: false, hookPointerPath: null,
version: null,
launchable: false, diagnostic: 'The Store resource CLI cannot launch outside its package.',
}],
});
@@ -935,112 +918,14 @@ describe('POST /api/tools/hooks', () => {
if (tmpDir) cleanupDir(tmpDir);
});
it('runs install action and returns 200 + stdout', async () => {
vi.mocked(runHookCommand).mockClear();
it('is gone: coding-agent hooks are not part of the community edition (ADR-0002)', async () => {
const res = await injectWithAuth(server, {
method: 'POST',
url: '/api/tools/hooks',
headers: { 'content-type': 'application/json' },
payload: { id: 'claude-code', action: 'install' },
});
expect(res.statusCode).toBe(200);
const body = res.json();
expect(body.ok).toBe(true);
expect(body.action).toBe('install');
expect(body.stdout).toBe('mock install output');
expect(runHookCommand).toHaveBeenCalledWith(
expect.objectContaining({ id: 'claude-code', action: 'install' }),
);
});
it('rejects a client-supplied CLI path instead of executing it', async () => {
vi.mocked(runHookCommand).mockClear();
const response = await injectWithAuth(server, {
method: 'POST',
url: '/api/tools/hooks',
headers: { 'content-type': 'application/json' },
payload: {
id: 'claude-code',
action: 'install',
cliPath: 'C:\\hive-mind-cli.js',
},
});
expect(response.statusCode).toBe(400);
expect(runHookCommand).not.toHaveBeenCalled();
});
it.each(['install', 'verify', 'uninstall'])(
'accepts action=%s',
async (action) => {
vi.mocked(runHookCommand).mockClear();
const res = await injectWithAuth(server, {
method: 'POST',
url: '/api/tools/hooks',
headers: { 'content-type': 'application/json' },
payload: { id: 'cursor', action },
});
expect(res.statusCode).toBe(200);
expect(runHookCommand).toHaveBeenCalledWith(
expect.objectContaining({ id: 'cursor', action }),
);
},
);
it('rejects unknown action', async () => {
const res = await injectWithAuth(server, {
method: 'POST',
url: '/api/tools/hooks',
headers: { 'content-type': 'application/json' },
payload: { id: 'claude-code', action: 'destroy' },
});
expect(res.statusCode).toBe(400);
});
it('rejects unknown tool id', async () => {
const res = await injectWithAuth(server, {
method: 'POST',
url: '/api/tools/hooks',
headers: { 'content-type': 'application/json' },
payload: { id: 'unknown-tool', action: 'install' },
});
expect(res.statusCode).toBe(400);
});
it('returns 400 when the underlying command fails', async () => {
vi.mocked(runHookCommand).mockResolvedValueOnce({
ok: false,
action: 'install',
packageName: '@waggle/hive-mind-hooks-claude-code',
stdout: '',
stderr: 'permission denied writing settings.json',
code: 1,
});
const res = await injectWithAuth(server, {
method: 'POST',
url: '/api/tools/hooks',
headers: { 'content-type': 'application/json' },
payload: { id: 'claude-code', action: 'install' },
});
expect(res.statusCode).toBe(400);
expect(res.json().stderr).toContain('permission denied');
});
it('returns 503 when the packaged hook runtime is missing', async () => {
vi.mocked(runHookCommand).mockResolvedValueOnce({
ok: false,
action: 'install',
packageName: '@waggle/hive-mind-hooks-claude-code',
stdout: '', stderr: '', code: -1,
errorCode: 'hook_runtime_missing',
error: 'runtime missing',
});
const res = await injectWithAuth(server, {
method: 'POST', url: '/api/tools/hooks',
headers: { 'content-type': 'application/json' },
payload: { id: 'claude-code', action: 'install' },
});
expect(res.statusCode).toBe(503);
expect(res.json().errorCode).toBe('hook_runtime_missing');
expect(res.statusCode).toBe(404);
});
});

View File

@@ -25,8 +25,6 @@ vi.mock('@waggle/agent', async (importOriginal) => {
installed: true,
installedPath: '/server-detected/claude-code',
version: 'test',
hooksInstalled: false,
hookPointerPath: null,
}],
})),
launchTool: vi.fn((opts: { id: string; installedPath: string }) => ({

View File

@@ -93,10 +93,8 @@ describe('GET /api/tools/detect', () => {
expect(t).toHaveProperty('installed');
expect(t).toHaveProperty('installedPath');
expect(t).toHaveProperty('version');
expect(t).toHaveProperty('hooksInstalled');
expect(t).toHaveProperty('hookPointerPath');
expect(t).not.toHaveProperty('hooksInstalled');
expect(typeof t.installed).toBe('boolean');
expect(typeof t.hooksInstalled).toBe('boolean');
}
});