diff --git a/docs/plans/analysis/2026-02-16-codebase-audit-report.md b/docs/plans/analysis/2026-02-16-codebase-audit-report.md index 4afbbd1..48b2d5d 100644 --- a/docs/plans/analysis/2026-02-16-codebase-audit-report.md +++ b/docs/plans/analysis/2026-02-16-codebase-audit-report.md @@ -20,7 +20,7 @@ Scope: Production-risk-first audit of bugs, code improvements, and feature oppor - ✅ F-015 addressed: retry defaults no longer classify timeout-style failures as non-retryable, improving resilience for transient timeout conditions. - ✅ F-011 addressed: Slack user-name resolution now uses bounded TTL+LRU caching to prevent unbounded growth. - ✅ F-013 addressed: shared channel utilities now cover reset normalization/building plus reusable allowlist, mention-gating, and pairing-gating flows across Discord/Slack/WhatsApp adapters. -- ◑ F-004 partially addressed: lint error baseline is restored (`pnpm lint` now passes with 0 errors) and warning burn-down has progressed from `466` to `212`; additional warning debt remains. +- ◑ F-004 partially addressed: lint error baseline is restored (`pnpm lint` now passes with 0 errors) and warning burn-down has progressed from `466` to `203`; additional warning debt remains. ## Executive Summary @@ -28,7 +28,7 @@ Current health snapshot: - `pnpm typecheck`: passing - `pnpm build`: passing - `pnpm test:run`: passing (`140/140` files, `1773/1773` tests) -- `pnpm lint`: passing with warnings only (`0 errors`, `212 warnings`) +- `pnpm lint`: passing with warnings only (`0 errors`, `203 warnings`) Top conclusions: - A critical Web UI security issue exists in markdown rendering (unsanitized HTML insertion). @@ -126,7 +126,7 @@ Remediation update (2026-02-16): - Severity: Medium - Impact: CI noise, reduced confidence in static analysis, and slower defect detection. - Evidence: - - `pnpm -s lint` => `0 errors`, `212 warnings` + - `pnpm -s lint` => `0 errors`, `203 warnings` - Error concentration: - `src/daemon/models.ts` (90 errors) - `src/cli/tui.ts` (25 errors) @@ -145,7 +145,7 @@ Remediation update (2026-02-16): Remediation update (2026-02-16): - Stage 1 complete: fixed all error-level ESLint violations in impacted high-error files so `pnpm lint` now passes with `0` errors. -- Stage 2 in progress: warning-burn-down reduced to `212` warnings via targeted hotspot cleanup in: +- Stage 2 in progress: warning-burn-down reduced to `203` warnings via targeted hotspot cleanup in: - `src/gateway/handlers/handlers.test.ts` - `src/daemon/routing.test.ts` - `src/frontends/tui/minimal.test.ts` @@ -158,6 +158,7 @@ Remediation update (2026-02-16): - `src/gateway/handlers/services.test.ts` - `src/models/local/llamacpp.test.ts` - `src/models/local/ollama.test.ts` + - `src/tools/builtin/image-analyze.test.ts` ### F-005 Medium: ESLint browser globals mismatch causes avoidable UI lint failures @@ -462,7 +463,7 @@ pnpm -s lint Observed outcomes: - Typecheck/build/test: passing. -- Lint: passing with warnings only (`0` errors, `212` warnings). +- Lint: passing with warnings only (`0` errors, `203` warnings). Historical pre-remediation lint error concentration snapshot: - `src/daemon/models.ts`: 90 errors diff --git a/docs/plans/state.json b/docs/plans/state.json index a2be42c..5e29544 100644 --- a/docs/plans/state.json +++ b/docs/plans/state.json @@ -2652,7 +2652,7 @@ "status": "in_progress", "date": "2026-02-16", "updated": "2026-02-16", - "summary": "Continued stage-2 lint warning reduction with hotspot-focused cleanup in `gateway/handlers/handlers.test.ts`, `daemon/routing.test.ts`, `frontends/tui/minimal.test.ts`, `gateway/tailscale.test.ts`, `automation/webhooks.test.ts`, `automation/cron.test.ts`, `automation/heartbeat.test.ts`, `frontends/tui/minimal.login.test.ts`, `daemon/clientFactory.test.ts`, `gateway/handlers/services.test.ts`, `models/local/llamacpp.test.ts`, and `models/local/ollama.test.ts`. Replaced broad `any` casts with typed helper casts/unknown-path accessors and removed non-null assertions in high-warning tests. Warning count reduced from 466 to 212 (254 warnings burned down) with lint/test suites still green.", + "summary": "Continued stage-2 lint warning reduction with hotspot-focused cleanup in `gateway/handlers/handlers.test.ts`, `daemon/routing.test.ts`, `frontends/tui/minimal.test.ts`, `gateway/tailscale.test.ts`, `automation/webhooks.test.ts`, `automation/cron.test.ts`, `automation/heartbeat.test.ts`, `frontends/tui/minimal.login.test.ts`, `daemon/clientFactory.test.ts`, `gateway/handlers/services.test.ts`, `models/local/llamacpp.test.ts`, `models/local/ollama.test.ts`, and `tools/builtin/image-analyze.test.ts`. Replaced broad `any` casts with typed helper casts/unknown-path accessors and removed non-null assertions in high-warning tests. Warning count reduced from 466 to 203 (263 warnings burned down) with lint/test suites still green.", "files_modified": [ "src/tools/builtin/browser/tools.test.ts", "src/channels/telegram/adapter.test.ts", @@ -2671,9 +2671,10 @@ "src/gateway/handlers/services.test.ts", "src/models/local/llamacpp.test.ts", "src/models/local/ollama.test.ts", + "src/tools/builtin/image-analyze.test.ts", "docs/plans/analysis/2026-02-16-codebase-audit-report.md" ], - "test_status": "pnpm test:run src/channels/utils.test.ts src/channels/discord/adapter.test.ts src/channels/slack/adapter.test.ts src/channels/whatsapp/adapter.test.ts src/daemon/routing.test.ts src/gateway/handlers/handlers.test.ts src/frontends/tui/minimal.test.ts src/gateway/tailscale.test.ts src/automation/webhooks.test.ts src/automation/cron.test.ts src/automation/heartbeat.test.ts src/frontends/tui/minimal.login.test.ts src/daemon/clientFactory.test.ts src/gateway/handlers/services.test.ts src/models/local/llamacpp.test.ts src/models/local/ollama.test.ts + pnpm lint passing (0 errors, 212 warnings)" + "test_status": "pnpm test:run src/channels/utils.test.ts src/channels/discord/adapter.test.ts src/channels/slack/adapter.test.ts src/channels/whatsapp/adapter.test.ts src/daemon/routing.test.ts src/gateway/handlers/handlers.test.ts src/frontends/tui/minimal.test.ts src/gateway/tailscale.test.ts src/automation/webhooks.test.ts src/automation/cron.test.ts src/automation/heartbeat.test.ts src/frontends/tui/minimal.login.test.ts src/daemon/clientFactory.test.ts src/gateway/handlers/services.test.ts src/models/local/llamacpp.test.ts src/models/local/ollama.test.ts src/tools/builtin/image-analyze.test.ts + pnpm lint passing (0 errors, 203 warnings)" } }, "overall_progress": { diff --git a/src/tools/builtin/image-analyze.test.ts b/src/tools/builtin/image-analyze.test.ts index 08d7abf..6c80a9c 100644 --- a/src/tools/builtin/image-analyze.test.ts +++ b/src/tools/builtin/image-analyze.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'; -import type { ModelClient, ChatRequest, ChatResponse } from '../../models/types.js'; +import type { ModelClient } from '../../models/types.js'; import { createImageAnalyzeTool } from './image-analyze.js'; describe('image.analyze tool', () => { @@ -242,20 +242,13 @@ describe('image.analyze tool', () => { }); it('uses custom system message prompt', async () => { - const mockRequest = { - messages: [] as any, - system: '', - maxTokens: 1024, - }; const mockResponse = { content: 'Analysis complete.', stopReason: 'end_turn', usage: { inputTokens: 100, outputTokens: 10 }, }; - mockClient.chat = vi.fn().mockResolvedValue(mockResponse).mockImplementationOnce(async (r) => { - return mockResponse; - }); + mockClient.chat = vi.fn().mockResolvedValue(mockResponse); const tool = createImageAnalyzeTool(mockClient); await tool.execute({ @@ -263,17 +256,12 @@ describe('image.analyze tool', () => { prompt: 'Analyze the colors.', }); - const callArgs = (mockClient.chat as any).mock.calls[0][0]; + const callArgs = vi.mocked(mockClient.chat).mock.calls[0]?.[0] as { system?: string }; expect(callArgs.system).toContain('vision assistant'); expect(callArgs.system).toContain('Analyze the provided image'); }); it('respects maxTokens parameter', async () => { - const mockRequest = { - messages: [] as any, - system: '', - maxTokens: 1024, - }; const mockResponse = { content: 'Short response', stopReason: 'end_turn', @@ -285,7 +273,7 @@ describe('image.analyze tool', () => { const tool = createImageAnalyzeTool(mockClient); await tool.execute({ url: 'https://example.com/image.jpg' }); - const callArgs = (mockClient.chat as any).mock.calls[0][0]; + const callArgs = vi.mocked(mockClient.chat).mock.calls[0]?.[0] as { maxTokens?: number }; expect(callArgs.maxTokens).toBe(1024); });