# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.0] - 2026-03-01

### Added

- **Vibe Audit Phase 2: Internal Code Audit** — 5 new Tier 1 tools + 1 Tier 2 workflow for local project security scanning (reads project files, no HTTP calls):
  - `check_env_exposure` — Checks .env files for secret leaks (Supabase service_role, Stripe, AWS, DB URL, OpenAI, GitHub tokens), verifies .gitignore exclusion, .env.example best practice
  - `check_rls_config` — Checks Supabase RLS configuration in SQL migrations: ENABLE/FORCE RLS, policy definitions, detects permissive USING(true) anti-pattern, skips system tables
  - `check_api_auth` — Checks API route authentication for Next.js App Router and Pages Router: detects 20+ auth patterns, global middleware auth, recognizes public routes (health, webhooks)
  - `check_client_secrets` — Detects secrets exposed in client-side code: NEXT_PUBLIC_ env vars with service keys, hardcoded Stripe/AWS/OpenAI/GitHub/PEM keys in client vs server files
  - `check_injection_risk` — Detects injection risks across 3 categories (SQL: 3 patterns, XSS: 3 patterns, Command: 4 patterns) with context lines and line numbers
  - `run_vibe_audit` — Tier 2 workflow: chains all 5 Tier 1 tools with 100-point scoring (Critical: -20, High: -10, Medium: -5, Low: -2), 60s workflow timeout, 15s per-tool timeout, progress notifications
- New shared utility: `file-scanner.ts` — Secure file system operations with path traversal prevention, symlink blocking, 1MB file size limit, 100-file scan limit
- New types: `VibeAuditFinding`, `VibeAuditToolResult`, `VibeAuditReport`, `VibeAuditSeverity`, `VibeAuditFindingStatus`
- New format-summary functions: `summarizeVibeAuditFindings()`, `summarizeVibeAuditReport()` for Markdown output
- Comprehensive test suite: file-scanner tests (path traversal, symlinks, size limits) and vibe-audit tests (all 5 Tier 1 tools + Tier 2 workflow with temp project fixtures)

### Changed

- **Stripe detection regex broadened**: `check_env_exposure` and `check_client_secrets` now detect both `sk_live_` and `sk_test_` Stripe key prefixes (test keys should also not be committed to source code)
- **`generate_jsonld` data property limit**: Added `.refine(max 50 keys)` to the `data` record parameter to prevent unbounded input
- **`generate_htaccess` RewriteRule pattern escaping**: Added `escapeRewritePattern()` to escape regex metacharacters (`.`, `*`, `+`, etc.) in redirect `from` paths for literal matching (e.g., `/page.html` → `^page\.html$`)

### Fixed

- **Timer leak in `executeTool()`**: `clearTimeout(timeoutTimer)` was not called in the catch block because the timer variable was declared inside the try block. Moved declaration outside try and added cleanup in catch.
- **`scanProjectFiles` excludeDirs replacing defaults**: When `options.excludeDirs` was provided, it replaced `DEFAULT_EXCLUDE_DIRS` instead of merging. Now uses spread to merge both arrays.
- **`format-summary.ts` multi-line fix code truncation**: `summarizeVibeAuditReport()` only showed the first line of multi-line fix suggestions. Now renders all lines with proper indentation.
- **`check-injection-risk.ts` single-match per pattern**: `content.match(pattern)` without `g` flag only found the first occurrence. Changed to `matchAll` with global flag to find ALL occurrences.
- **`check-client-secrets.ts` overly broad CLIENT_FILE_PATTERNS**: `/src\/.*\.tsx?$/` matched ALL files under `src/`, including server-side code. Narrowed to specific client-side path patterns (app/**/page.*, components/, pages/ excluding api/, hooks/).
- **Unused imports in `file-scanner.ts`**: Removed unused `access` and `constants` imports from `node:fs/promises`.
- **`formatError()` path sanitization**: Extended sanitization to ALL error types, not just `ApiError`. Now sanitizes `/home/`, `/usr/`, `/tmp/`, and Windows paths from all error messages (mcp-dev-checklist 2-A compliance).
- **Standalone Tier 1 Vibe Audit tools timeout**: Added 15-second timeout wrapper (`withTimeout()`) for all 5 standalone Tier 1 Vibe Audit tool calls, matching mcp-dev-checklist 2-A requirement (Tier 1: 15s).

## [0.5.0] - 2026-02-21

### Added

- 4 new Tier 1 SEO inspection tools:
  - `check_cache_headers` — Check browser/CDN cache headers (Cache-Control, ETag, Last-Modified, etc.) with scoring (0-100)
  - `check_schema_completeness` — Check structured data (JSON-LD/microdata) completeness against Schema.org requirements with per-type validation
  - `check_redirect_chain` — Trace redirect chain (301/302/307/308) with loop detection and HTTP downgrade detection
  - `check_image_optimization` — Check image optimization (next-gen formats, file size, lazy loading, width/height attributes) with scoring (0-100)
- Tier 2 workflow checklists expanded with new inspection items:
  - **SEO Audit**: 4 new items (cache headers, structured data completeness, redirect chain, image optimization) — now chains 10 tools with 20 auto-verified items (was 6 tools / 16 items)
  - **Web Launch Audit**: 4 new items (cache headers, structured data completeness, image optimization, redirect chain) — now chains 11 tools with 21 auto + 1 manual items (was 7 tools / 17 auto + 1 manual)
  - **Freelance Delivery Audit**: 2 new items (image optimization, redirect chain) — now chains 8 tools with 12 auto + 3 manual items (was 7 tools / 10 auto + 3 manual)
- New Zod response schemas: `cacheCheckerResponseSchema`, `schemaCheckerResponseSchema`, `redirectCheckerResponseSchema`, `imageCheckerResponseSchema`
- New evaluation functions: `evalCacheHeaders()`, `evalSchemaCompleteness()`, `evalRedirectChain()`, `evalImageOptimization()`

### Fixed

- SSRF protection: `validateUrl()` now blocks `.local` and `.internal` domain suffixes (can resolve to private IPs)

## [0.4.1] - 2026-02-18

### Fixed

- Speed checker (`check_page_speed`) timeout extended from 15s to 30s to match the upstream PageSpeed Insights API timeout, reducing timeout failures in Tier 2 workflow audits

## [0.4.0] - 2026-02-18

### Added

- 5 Tier 3 config file generation tools ("Config as a Tool" — AI agents can safely generate validated config files):
  - `generate_robots_txt` — Generate valid robots.txt from structured input (sitemap URL, disallow/allow paths, user-agent, crawl-delay). Output validation ensures only valid directives. Path sanitization removes control characters.
  - `generate_sitemap_xml` — Generate valid XML sitemap from URL list (up to 50,000 entries with optional lastmod, changefreq, priority). XML special characters safely escaped as entities. Validates URL format, date format, changefreq values, and priority range.
  - `generate_htaccess` — Generate valid Apache .htaccess with redirect rules (301/302/307/308), gzip compression, cache control, force HTTPS, and trailing slash removal. Injection prevention: blocks backtick execution, `$()` substitution, `%{ENV:}` injection, newline injection, and null bytes in RewriteRule patterns.
  - `generate_jsonld` — Generate Schema.org-compliant JSON-LD structured data supporting 16 schema types. Uses JSON.stringify for safe serialization. Validates required fields per type. Returns both raw JSON and `<script>` tag with XSS prevention.
  - `generate_meta_tags` — Generate SEO-optimized HTML meta tags (title, description, keywords, OGP, Twitter Card, canonical URL, robots). HTML attribute escaping prevents injection. Includes SEO analysis with title/description length status.
- All Tier 3 tools follow mcp-dev-checklist.md section 2-D: output validation, injection prevention, no browser-dependent APIs, runtime input validation, rate limiting, error handling

## [0.3.0] - 2026-02-18

### Added

- New Tier 1 tool: `check_security_headers` — checks 6 HTTP security headers (HSTS, CSP, X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy) with pass/warn/fail status and overall security score (0-100)
- OGP checker (`check_ogp`) now returns `favicon` data: `<link>` icon tags (rel, href, type, sizes), apple-touch-icon detection, and `/favicon.ico` existence check
- Speed checker (`check_page_speed`) now returns `accessibility` data: accessibility score and color-contrast violations (snippet + explanation, up to 10 items)
- 6 checklist items converted from manual to auto-verified across Tier 2 workflows:
  - **Web Launch Audit**: color contrast (via speed checker accessibility), favicon (via OGP checker favicon), security headers (replaces admin password check)
  - **Freelance Delivery Audit**: color contrast, favicon, security headers (replaces admin password check)
- Web launch audit now runs 7 Tier 1 tools (was 6) — 17 auto-verified + 1 manual item (was 14 auto + 4 manual)
- Freelance delivery audit now runs 7 Tier 1 tools — 10 auto-verified + 3 manual items (was 7 auto + 6 manual)
- Zod response schemas added: `accessibilityResultSchema`, `contrastViolationSchema`, `faviconResultSchema`, `faviconItemSchema`, `securityHeadersCheckerResponseSchema`
- New evaluation functions: `evalFavicon()`, `evalColorContrast()`, `evalSecurityHeaders()`

## [0.2.2] - 2026-02-17

### Fixed

- SSRF: site-config-checker API route changed from `redirect: "follow"` to `redirect: "manual"` with per-hop `isValidUrl()` validation
- OGP result summary now includes `canonical` URL and `jsonLd` items (type + validity) in `buildToolResultSummary()`
- Site config result summary now includes `robots.content` (actual robots.txt text) in `buildToolResultSummary()`
- McpServer version and User-Agent now match package.json (`0.2.2`)
- Tool descriptions updated: `check_ogp` mentions canonical/JSON-LD, `run_web_launch_audit` mentions 6 tools
- JSDoc corrected: seo-audit handler documents 6 Tier 1 tools (was 5)
- README.md updated: Tier 1 tool count (6→7), `check_site_config` added, Tier 2 auto/manual item counts corrected

## [0.2.1] - 2026-02-16

### Added

- New Tier 1 tool: `check_site_config` — checks robots.txt syntax/rules and XML sitemap structure/URL count for a website
- OGP checker (`check_ogp`) now returns `canonical` URL and `jsonLd` structured data items
- 7 SEO audit checklist items converted from manual to auto-verified:
  - canonical URL (via OGP checker)
  - JSON-LD structured data (via OGP checker)
  - robots.txt validation (via site config checker)
  - XML sitemap validation (via site config checker)
  - robots.txt in web-launch-audit
  - sitemap in web-launch-audit
  - JSON-LD in web-launch-audit
- SEO audit now runs 6 Tier 1 tools (was 5) — all 16 checklist items are auto-verified (0 manual)
- Web launch audit now runs 6 Tier 1 tools — 14 auto-verified + 4 manual items

### Fixed

- Workflow output information parity: `buildToolResultSummary()` now includes all fields from site-side tools (OGP title/description/image/type/siteName, Speed 6 metrics + top 5 opportunities, Alt missing image URLs up to 10, Headings full list + hierarchy skip info, Links text + internal/external classification)
- Checklist evaluation details now include actual data (real title/description text, image URLs, top improvement suggestions)
- Link check evaluation now distinguishes bot-blocked (403) from true broken links using the API's `warning` field — bot-blocked URLs are reported as "warn" instead of "fail"
- Added tests for bot-blocked only and mixed (broken + bot-blocked) scenarios

## [0.2.0] - 2026-02-16

### Added

- 3 Tier 2 workflow tools ("Workflow as a Tool" — chain multiple Tier 1 tools in a single call):
  - `run_seo_audit` — Comprehensive SEO audit: chains OGP, heading, link, speed, and alt checks into a unified report with scoring (0-100)
  - `run_web_launch_audit` — Pre-launch quality audit: SEO, performance, link integrity, accessibility, branding checks
  - `run_freelance_delivery_audit` — Pre-delivery audit for freelance projects: quality, SEO, and manual checklist items
- Checklist-driven evaluation: each workflow defines checklist items with auto-verifiable evaluation functions
- Weighted scoring: pass = full weight, warn = half weight, fail = 0
- Partial failure resilience: individual tool failures do not stop the workflow (reported as "error" status)
- Workflow timeout: 60-second limit enforced via `Promise.race` during tool execution
- Manual check items: non-automatable items (contrast, favicon, etc.) listed as "manual" for human/AI review
- Progress reporting via MCP SDK `notifications/progress` protocol (with stderr fallback)
- Score calculation excludes error items from maxScore ("未評価" — unevaluated items)
- New types: `AuditReport`, `CheckItemDefinition`, `CheckItemResult`, `CollectedToolResults`, etc.

## [0.1.0] - 2026-02-16

### Added

- Initial release with 6 Tier 1 tools (API wrappers):
  - `check_alt_attributes` — Check alt attributes of all images on a webpage
  - `check_links` — Check all links on a webpage for broken URLs
  - `check_page_speed` — Analyze webpage performance via Google PageSpeed Insights
  - `check_ogp` — Check OGP and Twitter Card meta tags
  - `extract_headings` — Extract heading hierarchy (H1-H6)
  - `check_x_card` — Validate X (Twitter) Card settings with OGP fallback
- SSRF protection: protocol validation + private IP / localhost blocking
- Rate limiting: 10 requests per minute per tool (sliding window)
- API response schema validation with Zod
- Retry logic: 1 retry with 2s wait on network/server errors
- Configurable API base URL via `ZERONOVA_API_URL` environment variable
