Commit Graph

114 Commits

Author SHA1 Message Date
John Lindquist 0f9a36f392 fix(hooks): replace js-yaml with inline frontmatter parser
Remove the external js-yaml dependency from skill frontmatter parsing and
implement an inline YAML subset parser in hooks/skill-map-frontmatter.mjs.

The new parser handles key/value pairs, nested objects by indentation,
block lists, inline arrays, number scalars, quoted strings, and strict
yaml-structure errors with readable Invalid YAML frontmatter messages.

Verified: bun test tests/skill-map-frontmatter.test.ts --test-name-pattern '^extractFrontmatter' (7 passed)
Verified: bun test tests/skill-map-frontmatter.test.ts --test-name-pattern '^parseSkillFrontmatter' (6 passed)
Verified: bun test tests/skill-map-frontmatter.test.ts --test-name-pattern 'scans actual skills directory and finds all skills' (1 passed)
Verified: bun test tests/skill-map-frontmatter.test.ts --test-name-pattern 'no warnings emitted for well-formed skills directory' (1 passed)
Verified: bun -e "import { buildSkillMap } from './hooks/skill-map-frontmatter.mjs'; const map = buildSkillMap('./skills'); console.log(JSON.stringify({skillCount:Object.keys(map.skills).length, diagnostics:map.diagnostics.length, warnings:map.warnings.length}, null, 2));" (skillCount=28 diagnostics=0 warnings=0)
Verified: bun -e "import { parseSkillFrontmatter } from './hooks/skill-map-frontmatter.mjs'; const yaml = 'name: demo\ndescription: one:two\nmetadata:\n  priority: 7\n  filePattern: [\'app/**\', \'src/**\']\n  bashPattern:\n    - \'\\bnpm\\s+run\\b\'\n    -\n      nested: value\n'; const parsed = parseSkillFrontmatter(yaml); if (parsed.name !== 'demo') throw new Error('name mismatch'); if (parsed.description !== 'one:two') throw new Error('description mismatch'); if (parsed.metadata.priority !== 7) throw new Error('priority mismatch'); if (!Array.isArray(parsed.metadata.filePattern) || parsed.metadata.filePattern.length !== 2) throw new Error('filePattern mismatch'); if (parsed.metadata.bashPattern[0] !== '\\bnpm\\s+run\\b') throw new Error('bashPattern mismatch'); if (parsed.metadata.bashPattern[1]?.nested !== 'value') throw new Error('nested list object mismatch');" (pass)
Swarm-Agent: inline-yaml-frontmatter-parser
2026-03-05 21:29:34 -07:00
John Lindquist f0a1a52cd4 test(skill-map-frontmatter): add focused frontmatter regressions
Add targeted Bun tests for BOM extraction, YAML parsing stability, scalar coercion warnings, and scan diagnostics behavior.
These cases lock behavior while parser internals are being refactored.

Verified: bun test hooks/skill-map-frontmatter.test.ts (5 pass)
How to test: bun test hooks/skill-map-frontmatter.test.ts
Swarm-Agent: skill-frontmatter-regression-tests
2026-03-05 21:26:37 -07:00
John Lindquist f838270eac refactor(hooks): extract shared patterns module and add validation
Extract glob-to-regex and seen-skills file utilities into hooks/patterns.mjs
for reuse across the PreToolUse hook and validation script. Add
validateSkillMap to skill-map-frontmatter.mjs. Expand plugin tags for
chat-sdk/bot variants. Comprehensive tests for all new modules.
2026-03-05 20:45:14 -07:00
John Lindquist 8adc0eabdb feat(hooks): bootstrap seen-skills file on SessionStart
SessionStart now creates a per-session seen-skills text file and exports
VERCEL_PLUGIN_SEEN_SKILLS through CLAUDE_ENV_FILE before PreToolUse runs.
This enables env-file dedup bootstrap without altering existing PreToolUse hook wiring.

Verified: bun test tests/session-start-seen-skills.test.ts
Verified: bun test tests/pretooluse-skill-inject.test.ts -t "hooks.json PreToolUse config"
Swarm-Agent: session-start-hook-bootstrap
2026-03-05 20:21:58 -07:00
John Lindquist 138090762e Migrate skill triggers from skill-map.json to SKILL.md frontmatter
Replace centralized skill-map.json with frontmatter-based triggers in
each SKILL.md. Add hooks/skill-map-frontmatter.mjs to parse triggers
at runtime. Update validation, tests, and hook logic accordingly.
2026-03-05 15:35:05 -07:00
John Lindquist 753292ffd6 Create three new Vercel skills (cron-jobs, deployments-cicd, env-vars) with SKILL.md files covering setup, CLI commands, and gotchas. Harden the PreToolUse hook (hooks/pretooluse-skill-inject.mjs) by wrapping output in hookSpecificOutput, adding atomic file writes with renameSync, supporting VERCEL_PLUGIN_DEBUG env var alongside VERCEL_PLUGIN_HOOK_DEBUG, and using a safeNow() shim for performance.now compatibility. Expand skill-map.json with new trigger patterns for the added skills and broader coverage for existing ones. Rewrite and expand tests/pretooluse-skill-inject.test.ts to cover the new hook behavior, atomic writes, debug output, and deduplication logic. Add hooks/HOOKS.md documenting the hook architecture. Update vercel.md with new skill references. Add README.txt and vercel.txt with project overview and Vercel platform reference docs. Add .claude/settings.json for project-level Claude settings. 2026-03-05 08:05:14 -07:00
John Lindquist 69031ac64e chore: expand skill-map trigger coverage and refactor PreToolUse hook 2026-03-04 17:38:29 -07:00
John Lindquist 86d0152a76 Expand skill-map trigger coverage and refactor PreToolUse hook script.
In hooks/skill-map.json: add tailwind.config.*, postcss.config.*, tsconfig.json, and tsconfig.*.json to the nextjs pathPatterns. Add bun/yarn install patterns for @ai-sdk/gateway to ai-gateway bashPatterns. Add bun/yarn install patterns for @vercel/functions to runtime-cache bashPatterns. Add bun/yarn install patterns for @vercel/speed-insights to observability bashPatterns.

In hooks/pretooluse-skill-inject.mjs: refactor the hook script for clarity and robustness.

In tests/pretooluse-skill-inject.test.ts: expand test coverage for the new trigger patterns and refactored hook logic.
2026-03-04 13:51:38 -07:00
John Lindquist dab39f5bb6 Add three new skills (ai-elements, shadcn, json-render) and make OIDC the documented default auth for AI Gateway across the plugin.
Create skills/ai-elements/SKILL.md covering the AI Elements component library — 40+ React components for AI chat UIs (Message, Conversation, Tool, Reasoning, CodeBlock, PromptInput) built as a custom shadcn/ui registry. Document installation via `npx ai-elements`, integration with AI SDK v6 useChat/UIMessage parts, server-side patterns (convertToModelMessages async + toUIMessageStreamResponse), and the DefaultChatTransport client pattern.

Create skills/shadcn/SKILL.md covering shadcn/ui — CLI commands (init, add, build, search, migrate), components.json configuration, namespaced custom registries (@v0, @acme), CSS variable theming with oklch, dark mode setup, the cn() utility, TooltipProvider requirement, RTL support, and framework compatibility (Next.js, Vite, Remix, Astro, Laravel).

Create skills/json-render/SKILL.md covering AI chat response rendering — the UIMessage parts format (text, tool-*, reasoning, step-start), manual rendering patterns for custom chat UIs without AI Elements, ToolResultCard patterns for structured tool output display instead of raw JSON, and the 5 most common v6 rendering mistakes (raw JSON from message.content, tool JSON blobs, convertToModelMessages not awaited, toDataStreamResponse vs toUIMessageStreamResponse, v5 useChat API pattern).

In skills/ai-gateway/SKILL.md, add a full "Authentication (OIDC — Default)" section documenting: VERCEL_OIDC_TOKEN provisioned by `vercel env pull`, @vercel/oidc reading the token automatically, ~24h expiry with re-pull for local dev, auto-refresh on Vercel deployments, AI_GATEWAY_API_KEY as manual alternative, and the auth priority order (API key first, then OIDC fallback).

In skills/ai-sdk/SKILL.md, update the setup section to document OIDC as default auth flow (vercel link → enable gateway → vercel env pull → OIDC token auto-provisioned), rewrite the UI Hooks section with both AI Elements (recommended) and manual rendering patterns showing v6 API changes (DefaultChatTransport, sendMessage, status, message.parts), update Key Patterns to include OIDC, AI Elements, and server-side v6 patterns, and expand the migration section with useChat transport, sendMessage, toUIMessageStreamResponse, and message.parts entries.

In vercel.md ecosystem graph: add AI Elements product entry under AI SDK UI Layer with component list and shadcn dependency, add shadcn/ui product entry under Frameworks with CLI commands and registry system, add OIDC Authentication subsection under AI Gateway with token flow, add AI Elements and custom rendering rows to AI Features decision matrix, update "Build an AI Chatbot" workflow with OIDC steps and AI Elements, add 6 new migration table entries (useChat transport, sendMessage, toUIMessageStreamResponse, message.parts, manual API keys → OIDC), and update AI SDK v6 conventions with OIDC-first auth, AI Elements recommendation, and server/client v6 patterns.

In hooks/skill-map.json, add trigger entries for all 3 new skills: ai-elements (components/ai-elements/**, npx ai-elements, shadcn registry URL patterns), shadcn (components.json, components/ui/**, npx shadcn patterns), json-render (components/chat**, components/message*, chat sidebar patterns).

Run the validator (bun run scripts/validate.ts --coverage skip) to confirm all 8 checks pass with 24 skills, 0 orphans, and all skill-map entries valid.
2026-03-04 13:30:50 -07:00
John Lindquist 39940f6acb fix: update model IDs to latest and remove PreToolUse hook
- Remove PreToolUse hook entirely (gateway preference belongs in
  SessionStart conventions, not per-write checks)
- Fix model ID format: use dots not dashes (claude-sonnet-4.6,
  claude-opus-4.6, claude-haiku-4.5)
- Update to latest flagship models from AI Gateway catalog:
  OpenAI: gpt-5.2 (was gpt-5-mini), gpt-5.3-codex, gpt-5-nano
  Anthropic: claude-sonnet-4.6, claude-opus-4.6
  Google: gemini-3-flash (was gemini-2.5-flash),
          gemini-3.1-pro-preview (was gemini-2.5-pro)
- Update providers reference table with current model lineup
2026-03-04 12:24:22 -07:00
John Lindquist ef3a7bbfb6 feat: enforce AI Gateway as default over direct provider SDKs
Addresses a gap where the plugin allowed agents to use direct provider
SDKs (@ai-sdk/anthropic, @ai-sdk/openai) with manual API keys instead
of routing through Vercel AI Gateway, which provides auto-provisioned
credentials, failover, cost tracking, and observability.

Changes:
- PreToolUse hook: add 3 new checks (10-12) for AI Gateway preference,
  deprecated generateObject/streamObject, and provider API key env vars
- vercel.md: update AI Features decision matrix to make AI Gateway the
  default row, add AI project bootstrap workflow, update Conventions to
  lead with gateway-first and vercel-link-first guidance
- ai-sdk SKILL.md: rewrite Installation, add Setup for AI Projects
  section, update all code examples to use gateway() instead of direct
  provider imports, update Key Patterns to prioritize gateway
2026-03-04 11:20:08 -07:00
John Lindquist 909db57f41 feat: inject vercel.md via SessionStart hook instead of CLAUDE.md
Plugins don't support CLAUDE.md natively. Rename CLAUDE.md to vercel.md
and add a SessionStart hook that cats it into the session context.
2026-03-04 10:45:53 -07:00
John Lindquist 211611ade6 docs(skills,commands): expand command guides, skill docs, and validation logic
Add detailed command conventions, enrich deploy/env/marketplace/status
command docs, strengthen validation script with CLI reference tooling,
and expand skill documentation for marketplace, observability, API,
CLI, and storage skills. Update ecosystem graph and verification checklist.
2026-03-04 08:58:53 -07:00
John Lindquist 2a56636bbe Initial commit: vercel-plugin project setup 2026-03-03 15:13:06 -07:00