@directive-run/mcp 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {createHash}from'crypto';import {getAllSkills,getSkill}from'@directive-run/claude-plugin';import {getAllKnowledge,getKnowledge,getAllExamples,getExample,getCompositionsFor,getReverseCompositionsFor,getAntiPatterns,getAntiPatternById,MIGRATION_SOURCES,getMigrationPattern}from'@directive-run/knowledge';import {MODULE_SECTIONS,validateModuleName,generateOrchestrator,generateModule,suggestFileNames,requiredPackages}from'@directive-run/scaffold';import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {z as z$1}from'zod';import {fileURLToPath}from'url';import {Worker}from'worker_threads';import {runRules,applyFix}from'@directive-run/lint';import {createServer}from'http';import {SSEServerTransport}from'@modelcontextprotocol/sdk/server/sse.js';var k=[{name:"@directive-run/ai",version:"1.17.0",description:"AI guardrails and orchestration for Directive. Prompt injection, PII detection, cost tracking, multi-agent patterns.",homepage:"https://directive.run",keywords:["directive","ai","agents","guardrails","orchestration","llm","constraint-driven","ai-safety","prompt-injection","pii-detection","cost-tracking","multi-agent","openai","anthropic","ollama","gemini"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:[".","./anthropic","./devtools","./evals","./gemini","./guardrails","./mcp","./multi-agent","./ollama","./openai","./predicate","./testing"],directory:"ai",published:true},{name:"@directive-run/claude-plugin",version:"1.17.0",description:"Claude Code plugin for Directive \u2014 12 skills covering modules, constraints, resolvers, derivations, AI orchestration, and adapters. Installable via Claude Code's plugin marketplace or consumable programmatically as an npm package.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","claude","claude-code","skills","ai-rules","plugin","agents","knowledge"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:["."],directory:"claude-plugin",published:true},{name:"@directive-run/cli",version:"1.17.0",description:"CLI tools for Directive \u2014 AI coding rules, scaffolding, and more.",homepage:"https://directive.run",keywords:["directive","cli","ai-rules","cursor","copilot","claude","windsurf","cline","llms-txt"],dependencies:["@clack/prompts","@directive-run/knowledge","@directive-run/scaffold","picocolors"],peerDependencies:["@directive-run/timeline"],optionalDependencies:[],exports:[".","./llms.txt"],directory:"cli",published:true},{name:"@directive-run/core",version:"1.17.0",description:"The constraint-driven runtime for TypeScript. Declare what must be true \u2014 the runtime makes it happen.",homepage:"https://directive.run",keywords:["directive","constraint-driven","state-management","constraints","reactive","runtime","typescript","ai-guardrails","zero-dependencies","auto-tracking","framework-agnostic","declarative"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:[".","./adapter-utils","./internals","./migration","./plugins","./testing","./worker"],directory:"core",published:true},{name:"@directive-run/el",version:"1.1.0",description:"Vanilla DOM adapter for Directive. Typed element creation + reactive bindings + JSX runtime.",homepage:"https://directive.run",keywords:["directive","vanilla","dom","elements","jsx","htm","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","htm"],optionalDependencies:[],exports:[".","./htm","./jsx-dev-runtime","./jsx-runtime"],directory:"el",published:true},{name:"@directive-run/knowledge",version:"1.17.0",description:"Knowledge files, examples, and validation for Directive \u2014 the constraint-driven TypeScript runtime.",homepage:"https://directive.run",keywords:["directive","knowledge","ai-rules","examples"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:["."],directory:"knowledge",published:true},{name:"@directive-run/lint",version:"0.1.0",description:"ts-morph-based static analysis for Directive code. Rule registry + executable checks + autofixes. Consumed by @directive-run/mcp (review_source, fix_code tools) and the future `directive doctor lint` CLI command. Anti-pattern data sourced from @directive-run/knowledge so rule IDs stay in lock-step.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","lint","ast","ts-morph","review","anti-patterns"],dependencies:[],peerDependencies:[],optionalDependencies:["ts-morph"],exports:[".","./worker"],directory:"lint",published:true},{name:"@directive-run/lit",version:"1.17.0",description:"Lit web components adapter for Directive.",homepage:"https://directive.run",keywords:["directive","lit","web-components","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","lit"],optionalDependencies:[],exports:["."],directory:"lit",published:true},{name:"@directive-run/mcp",version:"0.2.0",description:"Model Context Protocol server that exposes Directive to AI clients \u2014 knowledge files, code examples, and Claude Code skill bundles today, with room to grow into runtime introspection and tooling. stdio for local clients (Claude Desktop, Cursor, MCP Inspector), SSE for hosted deployments at mcp.directive.run.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","mcp","model-context-protocol","knowledge","ai-rules","sse","stdio"],dependencies:["@directive-run/claude-plugin","@directive-run/knowledge","@directive-run/lint","@directive-run/scaffold","@modelcontextprotocol/sdk","zod"],peerDependencies:[],optionalDependencies:["ts-morph"],exports:["."],directory:"mcp",published:true},{name:"@directive-run/mutator",version:"0.3.1",description:"Discriminated mutation helper for Directive \u2014 collapse the pendingAction ceremony to a typed handler map.",homepage:"https://directive.run",keywords:["directive","mutator","state-management","discriminated-union","optimistic-update"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:["."],directory:"mutator",published:true},{name:"@directive-run/optimistic",version:"0.2.0",description:"Resolver-scope optimistic update + automatic rollback for Directive.",homepage:"https://directive.run",keywords:["directive","optimistic","rollback","snapshot","state-management"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:["."],directory:"optimistic",published:true},{name:"@directive-run/query",version:"1.2.0",description:"Declarative data fetching for Directive. Constraint-driven queries with causal cache invalidation.",homepage:"https://directive.run",keywords:["directive","data-fetching","query","cache","stale-while-revalidate","constraint-driven","reactive","typescript"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:["."],directory:"query",published:true},{name:"@directive-run/react",version:"1.17.0",description:"React hooks and components for Directive.",homepage:"https://directive.run",keywords:["directive","react","hooks","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","react"],optionalDependencies:[],exports:["."],directory:"react",published:true},{name:"@directive-run/scaffold",version:"0.1.0",description:"Pure source-string generators for Directive modules and orchestrators. Shared substrate consumed by @directive-run/cli (its `directive new` command) and @directive-run/mcp (its `generate_module` tool). Zero runtime dependencies.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","scaffold","codegen","module-generator"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:["."],directory:"scaffold",published:true},{name:"@directive-run/solid",version:"1.17.0",description:"Solid.js signals adapter for Directive.",homepage:"https://directive.run",keywords:["directive","solid","solidjs","signals","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","solid-js"],optionalDependencies:[],exports:["."],directory:"solid",published:true},{name:"@directive-run/svelte",version:"1.17.0",description:"Svelte stores adapter for Directive.",homepage:"https://directive.run",keywords:["directive","svelte","stores","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","svelte"],optionalDependencies:[],exports:["."],directory:"svelte",published:true},{name:"@directive-run/timeline",version:"0.3.1",description:"Time-travel test REPL for Directive. Auto-renders the causal-graph timeline of any failing test.",homepage:"https://directive.run",keywords:["directive","time-travel","test-debugging","vitest","causal-graph","state-management"],dependencies:[],peerDependencies:["@directive-run/core","vitest"],optionalDependencies:[],exports:[".","./matchers","./reporter"],directory:"timeline",published:true},{name:"@directive-run/vite-plugin-api-proxy",version:"0.1.1",description:"",keywords:[],dependencies:[],peerDependencies:["vite"],optionalDependencies:[],exports:["."],directory:"vite-plugin-api-proxy",published:false},{name:"@directive-run/vue",version:"1.17.0",description:"Vue composition API adapter for Directive.",homepage:"https://directive.run",keywords:["directive","vue","composition-api","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","vue"],optionalDependencies:[],exports:["."],directory:"vue",published:true}],E="2026-06-03T13:37:41.769Z";var T=2e5,D=5e3,ee=/^[\w./-]{1,128}$/,l=class extends Error{constructor(r,i){super(r);this.code=i;}};function $(e){let t=Buffer.byteLength(e.source,"utf8");if(t>T)throw new l(`source is ${t} bytes (max ${T})`,"source-too-large");let r="fileName"in e?e.fileName:void 0;if(r!==void 0&&!ee.test(r))throw new l("invalid fileName","bad-filename")}async function te(){let e=await import.meta.resolve("@directive-run/lint/worker");return fileURLToPath(e)}async function R(e){let t=await te(),r=new Worker(t,{stderr:false}),i=null;try{return await new Promise((n,s)=>{let c=!1;r.once("message",a=>{c=!0,a.ok&&a.result!==void 0?n(a.result):s(new l(a.error??"worker returned without result","worker-error"));}),r.once("error",a=>{c=!0,s(new l(a.message,"worker-error"));}),r.once("exit",a=>{!c&&a!==0&&a!==null&&s(new l(`worker exited with code ${a} before responding`,"worker-error"));}),i=setTimeout(()=>{r.terminate(),s(new l(`parse exceeded ${D}ms budget`,"timeout"));},D),r.postMessage(e);})}finally{i&&clearTimeout(i),await r.terminate().catch(()=>{});}}function I(){return process.env.DIRECTIVE_MCP_USE_LINT_WORKER==="1"}async function C(e){return $(e),I()?R({kind:"run",source:e.source,options:{fileName:e.fileName,ruleFilter:e.ruleFilter}}):runRules(e.source,{fileName:e.fileName,ruleFilter:e.ruleFilter})}async function P(e){return $(e),I()?R({kind:"fix",source:e.source,finding:e.finding}):applyFix(e.source,e.finding)}var re=3600*1e3,ie=3e3,A=new Map;function O(){return k.map(e=>({name:e.name,summary:e.description,published:e.published}))}async function L(e){let t=k.find(n=>n.name===e);if(!t)return;let{liveVersion:r,stale:i}=await se(t);return ne(t,r,i)}function ne(e,t,r){return {name:e.name,description:e.description,homepage:e.homepage,keywords:e.keywords,dependencies:e.dependencies,peerDependencies:e.peerDependencies,optionalDependencies:e.optionalDependencies,exports:e.exports,published:e.published,npmUrl:e.published?`https://www.npmjs.com/package/${e.name}`:void 0,bakedVersion:e.version,liveVersion:t,stale:r}}async function se(e){if(!e.published)return {stale:true};let t=A.get(e.name);if(t&&Date.now()-t.fetchedAt<re)return {liveVersion:t.liveVersion,stale:t.liveVersion===void 0};let r=await oe(e.name);return A.set(e.name,{fetchedAt:Date.now(),liveVersion:r.liveVersion,latest:r.liveVersion,error:r.error}),{liveVersion:r.liveVersion,stale:r.liveVersion===void 0}}async function oe(e){let t=`https://registry.npmjs.org/${encodeURIComponent(e).replace(/%2F/g,"/")}/latest`,r=new AbortController,i=setTimeout(()=>r.abort(),ie);try{let n=await fetch(t,{signal:r.signal});if(!n.ok)return {error:`HTTP ${n.status}`};let s=await n.json();return typeof s.version=="string"?{liveVersion:s.version}:{error:"no version field"}}catch(n){return {error:n.message}}finally{clearTimeout(i);}}var N="0.2.0",j=50,V=200,F=512;function Se(e){return e.length>V?`${e.slice(0,V)}\u2026`:e}function U(e,t,r){let i=e.toLowerCase(),n=[];for(let[s,c]of t){let a=c.split(`
2
+ import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {createHash}from'crypto';import {getAllSkills,getSkill}from'@directive-run/claude-plugin';import {getAllKnowledge,getKnowledge,getAllExamples,getExample,getCompositionsFor,getReverseCompositionsFor,getAntiPatterns,getAntiPatternById,MIGRATION_SOURCES,getMigrationPattern}from'@directive-run/knowledge';import {MODULE_SECTIONS,validateModuleName,generateOrchestrator,generateModule,suggestFileNames,requiredPackages}from'@directive-run/scaffold';import {McpServer}from'@modelcontextprotocol/sdk/server/mcp.js';import {z as z$1}from'zod';import {fileURLToPath}from'url';import {Worker}from'worker_threads';import {runRules,applyFix}from'@directive-run/lint';import {createServer}from'http';import {SSEServerTransport}from'@modelcontextprotocol/sdk/server/sse.js';var k=[{name:"@directive-run/ai",version:"1.17.0",description:"AI guardrails and orchestration for Directive. Prompt injection, PII detection, cost tracking, multi-agent patterns.",homepage:"https://directive.run",keywords:["directive","ai","agents","guardrails","orchestration","llm","constraint-driven","ai-safety","prompt-injection","pii-detection","cost-tracking","multi-agent","openai","anthropic","ollama","gemini"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:[".","./anthropic","./devtools","./evals","./gemini","./guardrails","./mcp","./multi-agent","./ollama","./openai","./predicate","./testing"],directory:"ai",published:true},{name:"@directive-run/claude-plugin",version:"1.17.0",description:"Claude Code plugin for Directive \u2014 12 skills covering modules, constraints, resolvers, derivations, AI orchestration, and adapters. Installable via Claude Code's plugin marketplace or consumable programmatically as an npm package.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","claude","claude-code","skills","ai-rules","plugin","agents","knowledge"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:["."],directory:"claude-plugin",published:true},{name:"@directive-run/cli",version:"1.17.0",description:"CLI tools for Directive \u2014 AI coding rules, scaffolding, and more.",homepage:"https://directive.run",keywords:["directive","cli","ai-rules","cursor","copilot","claude","windsurf","cline","llms-txt"],dependencies:["@clack/prompts","@directive-run/knowledge","@directive-run/scaffold","picocolors"],peerDependencies:["@directive-run/timeline"],optionalDependencies:[],exports:[".","./llms.txt"],directory:"cli",published:true},{name:"@directive-run/core",version:"1.17.0",description:"The constraint-driven runtime for TypeScript. Declare what must be true \u2014 the runtime makes it happen.",homepage:"https://directive.run",keywords:["directive","constraint-driven","state-management","constraints","reactive","runtime","typescript","ai-guardrails","zero-dependencies","auto-tracking","framework-agnostic","declarative"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:[".","./adapter-utils","./internals","./migration","./plugins","./testing","./worker"],directory:"core",published:true},{name:"@directive-run/el",version:"1.1.0",description:"Vanilla DOM adapter for Directive. Typed element creation + reactive bindings + JSX runtime.",homepage:"https://directive.run",keywords:["directive","vanilla","dom","elements","jsx","htm","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","htm"],optionalDependencies:[],exports:[".","./htm","./jsx-dev-runtime","./jsx-runtime"],directory:"el",published:true},{name:"@directive-run/knowledge",version:"1.17.0",description:"Knowledge files, examples, and validation for Directive \u2014 the constraint-driven TypeScript runtime.",homepage:"https://directive.run",keywords:["directive","knowledge","ai-rules","examples"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:["."],directory:"knowledge",published:true},{name:"@directive-run/lint",version:"0.1.1",description:"ts-morph-based static analysis for Directive code. Rule registry + executable checks + autofixes. Consumed by @directive-run/mcp (review_source, fix_code tools) and the future `directive doctor lint` CLI command. Anti-pattern data sourced from @directive-run/knowledge so rule IDs stay in lock-step.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","lint","ast","ts-morph","review","anti-patterns"],dependencies:[],peerDependencies:[],optionalDependencies:["ts-morph"],exports:[".","./worker"],directory:"lint",published:true},{name:"@directive-run/lit",version:"1.17.0",description:"Lit web components adapter for Directive.",homepage:"https://directive.run",keywords:["directive","lit","web-components","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","lit"],optionalDependencies:[],exports:["."],directory:"lit",published:true},{name:"@directive-run/mcp",version:"0.2.2",description:"Model Context Protocol server that exposes Directive to AI clients \u2014 knowledge files, code examples, and Claude Code skill bundles today, with room to grow into runtime introspection and tooling. stdio for local clients (Claude Desktop, Cursor, MCP Inspector), SSE for hosted deployments at mcp.directive.run.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","mcp","model-context-protocol","knowledge","ai-rules","sse","stdio"],dependencies:["@directive-run/claude-plugin","@directive-run/knowledge","@directive-run/lint","@directive-run/scaffold","@modelcontextprotocol/sdk","zod"],peerDependencies:[],optionalDependencies:["ts-morph"],exports:["."],directory:"mcp",published:true},{name:"@directive-run/mutator",version:"0.3.1",description:"Discriminated mutation helper for Directive \u2014 collapse the pendingAction ceremony to a typed handler map.",homepage:"https://directive.run",keywords:["directive","mutator","state-management","discriminated-union","optimistic-update"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:["."],directory:"mutator",published:true},{name:"@directive-run/optimistic",version:"0.2.0",description:"Resolver-scope optimistic update + automatic rollback for Directive.",homepage:"https://directive.run",keywords:["directive","optimistic","rollback","snapshot","state-management"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:["."],directory:"optimistic",published:true},{name:"@directive-run/query",version:"1.2.0",description:"Declarative data fetching for Directive. Constraint-driven queries with causal cache invalidation.",homepage:"https://directive.run",keywords:["directive","data-fetching","query","cache","stale-while-revalidate","constraint-driven","reactive","typescript"],dependencies:[],peerDependencies:["@directive-run/core"],optionalDependencies:[],exports:["."],directory:"query",published:true},{name:"@directive-run/react",version:"1.17.0",description:"React hooks and components for Directive.",homepage:"https://directive.run",keywords:["directive","react","hooks","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","react"],optionalDependencies:[],exports:["."],directory:"react",published:true},{name:"@directive-run/scaffold",version:"0.1.0",description:"Pure source-string generators for Directive modules and orchestrators. Shared substrate consumed by @directive-run/cli (its `directive new` command) and @directive-run/mcp (its `generate_module` tool). Zero runtime dependencies.",homepage:"https://directive.run/docs/ide-integration",keywords:["directive","scaffold","codegen","module-generator"],dependencies:[],peerDependencies:[],optionalDependencies:[],exports:["."],directory:"scaffold",published:true},{name:"@directive-run/solid",version:"1.17.0",description:"Solid.js signals adapter for Directive.",homepage:"https://directive.run",keywords:["directive","solid","solidjs","signals","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","solid-js"],optionalDependencies:[],exports:["."],directory:"solid",published:true},{name:"@directive-run/svelte",version:"1.17.0",description:"Svelte stores adapter for Directive.",homepage:"https://directive.run",keywords:["directive","svelte","stores","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","svelte"],optionalDependencies:[],exports:["."],directory:"svelte",published:true},{name:"@directive-run/timeline",version:"0.3.1",description:"Time-travel test REPL for Directive. Auto-renders the causal-graph timeline of any failing test.",homepage:"https://directive.run",keywords:["directive","time-travel","test-debugging","vitest","causal-graph","state-management"],dependencies:[],peerDependencies:["@directive-run/core","vitest"],optionalDependencies:[],exports:[".","./matchers","./reporter"],directory:"timeline",published:true},{name:"@directive-run/vite-plugin-api-proxy",version:"0.1.1",description:"",keywords:[],dependencies:[],peerDependencies:["vite"],optionalDependencies:[],exports:["."],directory:"vite-plugin-api-proxy",published:false},{name:"@directive-run/vue",version:"1.17.0",description:"Vue composition API adapter for Directive.",homepage:"https://directive.run",keywords:["directive","vue","composition-api","state-management","reactive","constraint-driven"],dependencies:[],peerDependencies:["@directive-run/core","@directive-run/query","vue"],optionalDependencies:[],exports:["."],directory:"vue",published:true}],E="2026-06-04T01:56:10.722Z";var T=2e5,D=5e3,ee=/^[\w./-]{1,128}$/,l=class extends Error{constructor(r,i){super(r);this.code=i;}};function I(e){let t=Buffer.byteLength(e.source,"utf8");if(t>T)throw new l(`source is ${t} bytes (max ${T})`,"source-too-large");let r="fileName"in e?e.fileName:void 0;if(r!==void 0&&!ee.test(r))throw new l("invalid fileName","bad-filename")}async function te(){let e=await import.meta.resolve("@directive-run/lint/worker");return fileURLToPath(e)}async function R(e){let t=await te(),r=new Worker(t,{stderr:false}),i=null;try{return await new Promise((n,s)=>{let c=!1;r.once("message",a=>{c=!0,a.ok&&a.result!==void 0?n(a.result):s(new l(a.error??"worker returned without result","worker-error"));}),r.once("error",a=>{c=!0,s(new l(a.message,"worker-error"));}),r.once("exit",a=>{!c&&a!==0&&a!==null&&s(new l(`worker exited with code ${a} before responding`,"worker-error"));}),i=setTimeout(()=>{r.terminate(),s(new l(`parse exceeded ${D}ms budget`,"timeout"));},D),r.postMessage(e);})}finally{i&&clearTimeout(i),await r.terminate().catch(()=>{});}}function $(){return process.env.DIRECTIVE_MCP_USE_LINT_WORKER==="1"}async function C(e){return I(e),$()?R({kind:"run",source:e.source,options:{fileName:e.fileName,ruleFilter:e.ruleFilter}}):runRules(e.source,{fileName:e.fileName,ruleFilter:e.ruleFilter})}async function P(e){return I(e),$()?R({kind:"fix",source:e.source,finding:e.finding}):applyFix(e.source,e.finding)}var re=3600*1e3,ie=3e3,A=new Map;function O(){return k.map(e=>({name:e.name,summary:e.description,published:e.published}))}async function L(e){let t=k.find(n=>n.name===e);if(!t)return;let{liveVersion:r,stale:i}=await se(t);return ne(t,r,i)}function ne(e,t,r){return {name:e.name,description:e.description,homepage:e.homepage,keywords:e.keywords,dependencies:e.dependencies,peerDependencies:e.peerDependencies,optionalDependencies:e.optionalDependencies,exports:e.exports,published:e.published,npmUrl:e.published?`https://www.npmjs.com/package/${e.name}`:void 0,bakedVersion:e.version,liveVersion:t,stale:r}}async function se(e){if(!e.published)return {stale:true};let t=A.get(e.name);if(t&&Date.now()-t.fetchedAt<re)return {liveVersion:t.liveVersion,stale:t.liveVersion===void 0};let r=await oe(e.name);return A.set(e.name,{fetchedAt:Date.now(),liveVersion:r.liveVersion,latest:r.liveVersion,error:r.error}),{liveVersion:r.liveVersion,stale:r.liveVersion===void 0}}async function oe(e){let t=`https://registry.npmjs.org/${encodeURIComponent(e).replace(/%2F/g,"/")}/latest`,r=new AbortController,i=setTimeout(()=>r.abort(),ie);try{let n=await fetch(t,{signal:r.signal});if(!n.ok)return {error:`HTTP ${n.status}`};let s=await n.json();return typeof s.version=="string"?{liveVersion:s.version}:{error:"no version field"}}catch(n){return {error:n.message}}finally{clearTimeout(i);}}var N="0.2.2",j=50,V=200,F=512;function Se(e){return e.length>V?`${e.slice(0,V)}\u2026`:e}function U(e,t,r){let i=e.toLowerCase(),n=[];for(let[s,c]of t){let a=c.split(`
3
3
  `);for(let d=0;d<a.length;d++){let u=a[d];if(u.toLowerCase().includes(i)&&(n.push(`${s}${r}:${d+1}: ${Se(u)}`),n.length>=j))return n}}return n}function G(e,t){return t.length===0?`No matches for '${e}'.`:`${t.length===j?`${t.length}+ matches (truncated):`:`${t.length} matches:`}
4
4
  ${t.join(`
5
5
  `)}`}var v=null;function _e(){if(v)return v;let e=createHash("sha256");for(let[t,r]of Array.from(getAllKnowledge()).sort(([i],[n])=>i.localeCompare(n)))e.update(t),e.update("\0"),e.update(r),e.update("\0");return v=e.digest("hex").slice(0,16),v}var g={transport:"stdio",authEnabled:false};function f(e){g=e;}function h(e,t,r){r.length!==0&&e.push("",`**${t}:**`,...r.map(i=>`- ${i}`));}function Ee(e){let t=[`# ${e.name}`,e.description,"",`**Version (live):** ${e.liveVersion??"unknown"}`,`**Version (baked):** ${e.bakedVersion}${e.stale?" (live fetch failed; using baked)":""}`,`**Published to npm:** ${e.published?"yes":"no (private workspace package)"}`];return e.homepage&&t.push(`**Homepage:** ${e.homepage}`),e.npmUrl&&t.push(`**npm:** ${e.npmUrl}`),h(t,"Dependencies",e.dependencies),h(t,"Peer dependencies",e.peerDependencies),h(t,"Optional dependencies",e.optionalDependencies),h(t,"Exports",e.exports),t.join(`
@@ -43,7 +43,7 @@ ${r.manifest}`];for(let[n,s]of r.files)i.push(`---
43
43
 
44
44
  ${s}`);return {content:[{type:"text",text:i.join(`
45
45
 
46
- `)}]}}),e}var B="/messages",H="/sse",$e="/healthz",Re=1e6,Ie=64,Ce=300*1e3,Pe=3e4,Ae=new Set(["127.0.0.1","localhost","::1","0:0:0:0:0:0:0:1"]),S=class extends Error{};function Oe(e){return Ae.has(e.toLowerCase())}function Le(e){let t=e.port??3e3,r=e.host??"127.0.0.1",i=e.logger??console,n=e.token??process.env.DIRECTIVE_MCP_TOKEN??void 0;if(!Oe(r)&&!n)throw new S("Public hosts require a token. Pass --token <value> or set DIRECTIVE_MCP_TOKEN, or bind to 127.0.0.1 for local dev.");return {port:t,host:r,logger:i,token:n,allowOrigins:e.allowOrigins??[],bodyLimitBytes:e.bodyLimitBytes??Re,maxSessions:e.maxSessions??Ie,idleTimeoutMs:e.idleTimeoutMs??Ce}}function K(e,t){if(!t)return true;let r=e.headers.authorization;return typeof r!="string"?false:/^Bearer\s+(.+)$/i.exec(r)?.[1]?.trim()===t}function W(e,t){if(t.length===0)return true;let r=e.headers.origin;return typeof r!="string"?false:t.includes(r)}function p(e,t,r,i={}){e.writeHead(t,{"Content-Type":"text/plain",...i}),e.end(r);}function _(e,t){f({transport:"sse",authEnabled:t,sessionCount:e.size});}async function Me(e,t,r,i){if(!K(e,i.token)){p(t,401,"unauthorized");return}if(!W(e,i.allowOrigins)){p(t,403,"origin not allowed");return}if(r.size>=i.maxSessions){p(t,429,"session cap reached",{"Retry-After":"60"});return}let n=new SSEServerTransport(B,t),s=y();r.set(n.sessionId,{transport:n,lastActivity:Date.now()}),_(r,!!i.token);let c=()=>{r.delete(n.sessionId),_(r,!!i.token);};t.on("close",c),n.onclose=c,await s.connect(n),i.logger.log(`[directive-mcp] sse session opened: ${n.sessionId}`);}async function Ne(e,t,r,i,n){if(!K(e,n.token)){p(t,401,"unauthorized");return}if(!W(e,n.allowOrigins)){p(t,403,"origin not allowed");return}let s=Number(e.headers["content-length"]??"0");if(Number.isFinite(s)&&s>n.bodyLimitBytes){p(t,413,`body exceeds ${n.bodyLimitBytes} bytes`);return}let c=r.searchParams.get("sessionId");if(!c){p(t,400,"missing sessionId query parameter");return}let a=i.get(c);if(!a){p(t,404,`unknown session: ${c}`);return}a.lastActivity=Date.now();let d=0,u=false;e.on("data",Y=>{d+=Buffer.byteLength(Y),d>n.bodyLimitBytes&&!u&&(u=true,p(t,413,`body exceeds ${n.bodyLimitBytes} bytes`),e.destroy());}),!u&&await a.transport.handlePostMessage(e,t);}async function Ve(e,t,r,i){let n=new URL(e.url??"/",`http://${e.headers.host??i.host}`);if(e.method==="GET"&&n.pathname===$e){t.writeHead(200,{"Content-Type":"text/plain"}),t.end("ok");return}if(e.method==="GET"&&n.pathname===H){await Me(e,t,r,i);return}if(e.method==="POST"&&n.pathname===B){await Ne(e,t,n,r,i);return}p(t,404,"not found");}function Fe(e,t){return setInterval(()=>{let r=Date.now();for(let[i,n]of e)r-n.lastActivity>t.idleTimeoutMs&&(e.delete(i),n.transport.close().catch(()=>{}),_(e,!!t.token),t.logger.log(`[directive-mcp] pruned idle session: ${i}`));},Pe).unref()}async function z(e={}){let t=Le(e),r=new Map,i=createServer(async(s,c)=>{try{await Ve(s,c,r,t);}catch(a){t.logger.error("[directive-mcp] request error:",a),c.headersSent||c.writeHead(500,{"Content-Type":"text/plain"}),c.end("internal server error");}}),n=Fe(r,t);return i.on("close",()=>{clearInterval(n);}),await new Promise(s=>{i.listen(t.port,t.host,()=>{t.logger.log(`[directive-mcp] sse server listening at http://${t.host}:${t.port}${H}${t.token?" (auth: bearer-token)":" (auth: none, loopback only)"}`),s();});}),i}var Ge="0.2.0",X=`directive-mcp \u2014 MCP server exposing Directive to AI clients
46
+ `)}]}}),e}var B="/messages",H="/sse",Ie="/healthz",Re=1e6,$e=64,Ce=300*1e3,Pe=3e4,Ae=new Set(["127.0.0.1","localhost","::1","0:0:0:0:0:0:0:1"]),S=class extends Error{};function Oe(e){return Ae.has(e.toLowerCase())}function Le(e){let t=e.port??3e3,r=e.host??"127.0.0.1",i=e.logger??console,n=e.token??process.env.DIRECTIVE_MCP_TOKEN??void 0;if(!Oe(r)&&!n)throw new S("Public hosts require a token. Pass --token <value> or set DIRECTIVE_MCP_TOKEN, or bind to 127.0.0.1 for local dev.");return {port:t,host:r,logger:i,token:n,allowOrigins:e.allowOrigins??[],bodyLimitBytes:e.bodyLimitBytes??Re,maxSessions:e.maxSessions??$e,idleTimeoutMs:e.idleTimeoutMs??Ce}}function K(e,t){if(!t)return true;let r=e.headers.authorization;return typeof r!="string"?false:/^Bearer\s+(.+)$/i.exec(r)?.[1]?.trim()===t}function W(e,t){if(t.length===0)return true;let r=e.headers.origin;return typeof r!="string"?false:t.includes(r)}function p(e,t,r,i={}){e.writeHead(t,{"Content-Type":"text/plain",...i}),e.end(r);}function _(e,t){f({transport:"sse",authEnabled:t,sessionCount:e.size});}async function Me(e,t,r,i){if(!K(e,i.token)){p(t,401,"unauthorized");return}if(!W(e,i.allowOrigins)){p(t,403,"origin not allowed");return}if(r.size>=i.maxSessions){p(t,429,"session cap reached",{"Retry-After":"60"});return}let n=new SSEServerTransport(B,t),s=y();r.set(n.sessionId,{transport:n,lastActivity:Date.now()}),_(r,!!i.token);let c=()=>{r.delete(n.sessionId),_(r,!!i.token);};t.on("close",c),n.onclose=c,await s.connect(n),i.logger.log(`[directive-mcp] sse session opened: ${n.sessionId}`);}async function Ne(e,t,r,i,n){if(!K(e,n.token)){p(t,401,"unauthorized");return}if(!W(e,n.allowOrigins)){p(t,403,"origin not allowed");return}let s=Number(e.headers["content-length"]??"0");if(Number.isFinite(s)&&s>n.bodyLimitBytes){p(t,413,`body exceeds ${n.bodyLimitBytes} bytes`);return}let c=r.searchParams.get("sessionId");if(!c){p(t,400,"missing sessionId query parameter");return}let a=i.get(c);if(!a){p(t,404,`unknown session: ${c}`);return}a.lastActivity=Date.now();let d=0,u=false;e.on("data",Y=>{d+=Buffer.byteLength(Y),d>n.bodyLimitBytes&&!u&&(u=true,p(t,413,`body exceeds ${n.bodyLimitBytes} bytes`),e.destroy());}),!u&&await a.transport.handlePostMessage(e,t);}async function Ve(e,t,r,i){let n=new URL(e.url??"/",`http://${e.headers.host??i.host}`);if(e.method==="GET"&&n.pathname===Ie){t.writeHead(200,{"Content-Type":"text/plain"}),t.end("ok");return}if(e.method==="GET"&&n.pathname===H){await Me(e,t,r,i);return}if(e.method==="POST"&&n.pathname===B){await Ne(e,t,n,r,i);return}p(t,404,"not found");}function Fe(e,t){return setInterval(()=>{let r=Date.now();for(let[i,n]of e)r-n.lastActivity>t.idleTimeoutMs&&(e.delete(i),n.transport.close().catch(()=>{}),_(e,!!t.token),t.logger.log(`[directive-mcp] pruned idle session: ${i}`));},Pe).unref()}async function z(e={}){let t=Le(e),r=new Map,i=createServer(async(s,c)=>{try{await Ve(s,c,r,t);}catch(a){t.logger.error("[directive-mcp] request error:",a),c.headersSent||c.writeHead(500,{"Content-Type":"text/plain"}),c.end("internal server error");}}),n=Fe(r,t);return i.on("close",()=>{clearInterval(n);}),await new Promise(s=>{i.listen(t.port,t.host,()=>{t.logger.log(`[directive-mcp] sse server listening at http://${t.host}:${t.port}${H}${t.token?" (auth: bearer-token)":" (auth: none, loopback only)"}`),s();});}),i}var Ge="0.2.2",X=`directive-mcp \u2014 MCP server exposing Directive to AI clients
47
47
 
48
48
  Usage:
49
49
  directive-mcp Run stdio transport (default)