/** * @fileoverview Agent-skill injection on POST /api/sessions (docs/agent-control-plan.md ยง2). * * The quick-start half of this is covered end-to-end in test/quick-start.test.ts; * the plain create path had NO coverage, because the shared mock context hardcoded * `getAgentSkillEnabled` to false and nothing could flip it. This exercises the real * `applyAgentSkill` against a temp working dir, so it asserts bytes on disk rather * than a spy call. * * Uses app.inject(), so no real HTTP port is needed. */ import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import Fastify, { type FastifyInstance } from 'fastify'; import fastifyCookie from '@fastify/cookie'; import { mkdtemp, rm, readFile } from 'node:fs/promises'; import { existsSync } from 'node:fs'; import { join } from 'node:path'; import { tmpdir } from 'node:os'; import { createMockRouteContext, type MockRouteContext } from '../mocks/index.js'; import { installRouteErrorHandler } from '../../src/web/route-error-handler.js'; import { registerSessionRoutes } from '../../src/web/routes/session-routes.js'; const MARKER_PREFIX = '