mirror of
https://github.com/vercel/vercel-plugin.git
synced 2026-09-14 15:39:47 +08:00
8e24d0694a
Add a chainTo frontmatter field to skills that triggers follow-up skill injection when PostToolUse file contents match regex patterns. Add upgradeToSkill/upgradeWhy fields to validation rules so validate errors can recommend loading a specific skill. Register posttooluse-bash-chain.mjs in hooks.json. Add ChainToRule interface to patterns.mts and skill-map-frontmatter.mts, with parseChainToRules() parser. Add duplicate-key detection to the YAML parser. Reset dedup claim dir and session file on clear/compact events in session-start-seen-skills so skills re-inject into fresh context windows. Add chainTo rules to: agent-browser-verify, agent-browser, ai-elements, ai-gateway, ai-generation-persistence, ai-sdk, auth, bootstrap, chat-sdk, cms, cron-jobs, deployments-cicd, email, env-vars, geist, investigation-mode, json-render, marketplace, micro, ncc, next-forge, nextjs, observability, payments, react-best-practices, routing-middleware, runtime-cache, satori, shadcn, sign-in-with-vercel, swr, turbopack, turborepo, v0-dev, vercel-agent, vercel-api, vercel-cli, vercel-firewall, vercel-flags, vercel-functions, vercel-queues, vercel-sandbox, vercel-storage, verification, workflow. Add upgradeToSkill to ai-elements and ai-sdk validate rules. Expand ai-sdk validate messages with Run Skill() hints. Update nextjs, vercel-storage, runtime-cache, workflow, turborepo skill bodies. Add new skills: geistdocs (Geist design system docs), zzz-test-meta-name-mask (test fixture). Add skills/_chain-audit.md chain coverage audit doc. Delete .claude-plugin/marketplace.json, .claude-plugin/plugin.json (deprecated), skills/edge-runtime/SKILL.md (consolidated into vercel-functions). Add tests: posttooluse-chain.test.ts (4699 lines, chain injection e2e), ai-sdk-companion.test.ts (181 lines). Expand build-skill-map.test.ts (+335 lines), validate-rules.test.ts (+936 lines), session-start-seen-skills.test.ts (+74 lines), skill-map-frontmatter.test.ts (+50 lines), verification-skill.test.ts (+20 lines). Update build-manifest.ts to emit chainTo rules and upgradeToSkill fields. Rebuild generated/skill-manifest.json, generated/skill-catalog.md, generated/build-from-skills.manifest.json. Rebuild all compiled hooks/*.mjs. Update CLAUDE.md lexical prompt default to on. Update vercel.md ecosystem graph, docs, and cli-reference.
68 lines
2.1 KiB
JavaScript
68 lines
2.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// hooks/src/inject-claude-md.mts
|
|
import { readFileSync } from "fs";
|
|
import { join, resolve } from "path";
|
|
import { fileURLToPath } from "url";
|
|
import { formatOutput } from "./compat.mjs";
|
|
import { pluginRoot, safeReadFile } from "./hook-env.mjs";
|
|
var GREENFIELD_CONTEXT = `<!-- vercel-plugin:greenfield-execution -->
|
|
## Greenfield execution mode
|
|
|
|
This directory is empty.
|
|
Do not stop in planning mode or spin up a read-only planning subagent.
|
|
Choose sensible defaults immediately.
|
|
Start executing with real tool calls.
|
|
Use non-interactive scaffolding commands (--yes) where available.
|
|
Only ask follow-up questions when blocked by missing credentials or irreversible decisions.`;
|
|
function parseInjectClaudeMdInput(raw) {
|
|
try {
|
|
if (!raw.trim()) return null;
|
|
return JSON.parse(raw);
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
function detectInjectClaudeMdPlatform(input, _env = process.env) {
|
|
if (input && ("conversation_id" in input || "cursor_version" in input)) {
|
|
return "cursor";
|
|
}
|
|
return "claude-code";
|
|
}
|
|
function buildInjectClaudeMdParts(content, env = process.env) {
|
|
const parts = [];
|
|
if (content !== null) {
|
|
parts.push(content);
|
|
}
|
|
if (env.VERCEL_PLUGIN_GREENFIELD === "true") {
|
|
parts.push(GREENFIELD_CONTEXT);
|
|
}
|
|
return parts;
|
|
}
|
|
function formatInjectClaudeMdOutput(platform, content) {
|
|
if (platform === "cursor") {
|
|
return JSON.stringify(formatOutput(platform, { additionalContext: content }));
|
|
}
|
|
return content;
|
|
}
|
|
function main() {
|
|
const input = parseInjectClaudeMdInput(readFileSync(0, "utf8"));
|
|
const platform = detectInjectClaudeMdPlatform(input);
|
|
const parts = buildInjectClaudeMdParts(safeReadFile(join(pluginRoot(), "vercel.md")));
|
|
if (parts.length === 0) {
|
|
return;
|
|
}
|
|
process.stdout.write(formatInjectClaudeMdOutput(platform, parts.join("\n\n")));
|
|
}
|
|
var INJECT_CLAUDE_MD_ENTRYPOINT = fileURLToPath(import.meta.url);
|
|
var isInjectClaudeMdEntrypoint = process.argv[1] ? resolve(process.argv[1]) === INJECT_CLAUDE_MD_ENTRYPOINT : false;
|
|
if (isInjectClaudeMdEntrypoint) {
|
|
main();
|
|
}
|
|
export {
|
|
buildInjectClaudeMdParts,
|
|
detectInjectClaudeMdPlatform,
|
|
formatInjectClaudeMdOutput,
|
|
parseInjectClaudeMdInput
|
|
};
|