@directive-run/claude-plugin 1.16.0

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.
Files changed (83) hide show
  1. package/.claude-plugin/plugin.json +6 -0
  2. package/LICENSE +26 -0
  3. package/README.md +113 -0
  4. package/dist/index.cjs +2 -0
  5. package/dist/index.cjs.map +1 -0
  6. package/dist/index.d.cts +66 -0
  7. package/dist/index.d.ts +66 -0
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -0
  10. package/package.json +64 -0
  11. package/skills/README.md +9 -0
  12. package/skills/building-ai-agents/SKILL.md +414 -0
  13. package/skills/building-ai-agents/ai-adapters.md +257 -0
  14. package/skills/building-ai-agents/ai-agents-streaming.md +307 -0
  15. package/skills/building-ai-agents/ai-communication.md +304 -0
  16. package/skills/building-ai-agents/api-skeleton.md +5 -0
  17. package/skills/building-ai-agents/examples.md +849 -0
  18. package/skills/building-ai-orchestrators/SKILL.md +401 -0
  19. package/skills/building-ai-orchestrators/ai-multi-agent.md +375 -0
  20. package/skills/building-ai-orchestrators/ai-orchestrator.md +466 -0
  21. package/skills/building-ai-orchestrators/ai-tasks.md +268 -0
  22. package/skills/building-ai-orchestrators/api-skeleton.md +5 -0
  23. package/skills/building-ai-orchestrators/examples.md +1609 -0
  24. package/skills/building-directive-systems/SKILL.md +499 -0
  25. package/skills/building-directive-systems/api-skeleton.md +5 -0
  26. package/skills/building-directive-systems/examples.md +4149 -0
  27. package/skills/building-directive-systems/multi-module.md +327 -0
  28. package/skills/building-directive-systems/plugins.md +361 -0
  29. package/skills/building-directive-systems/react-adapter.md +376 -0
  30. package/skills/building-directive-systems/system-api.md +463 -0
  31. package/skills/getting-started-with-directive/SKILL.md +198 -0
  32. package/skills/getting-started-with-directive/api-skeleton.md +5 -0
  33. package/skills/getting-started-with-directive/core-patterns.md +240 -0
  34. package/skills/getting-started-with-directive/examples.md +87 -0
  35. package/skills/getting-started-with-directive/sitemap.md +202 -0
  36. package/skills/hardening-ai-systems/SKILL.md +377 -0
  37. package/skills/hardening-ai-systems/ai-budget-resilience.md +408 -0
  38. package/skills/hardening-ai-systems/ai-guardrails-memory.md +370 -0
  39. package/skills/hardening-ai-systems/ai-security.md +400 -0
  40. package/skills/hardening-ai-systems/api-skeleton.md +5 -0
  41. package/skills/hardening-ai-systems/examples.md +628 -0
  42. package/skills/migrating-to-directive/SKILL.md +249 -0
  43. package/skills/migrating-to-directive/anti-patterns.md +382 -0
  44. package/skills/migrating-to-directive/api-skeleton.md +5 -0
  45. package/skills/migrating-to-directive/core-patterns.md +240 -0
  46. package/skills/migrating-to-directive/examples.md +511 -0
  47. package/skills/migrating-to-directive/schema-types.md +273 -0
  48. package/skills/reviewing-directive-code/SKILL.md +232 -0
  49. package/skills/reviewing-directive-code/anti-patterns.md +382 -0
  50. package/skills/reviewing-directive-code/api-skeleton.md +5 -0
  51. package/skills/reviewing-directive-code/core-patterns.md +240 -0
  52. package/skills/reviewing-directive-code/examples.md +463 -0
  53. package/skills/reviewing-directive-code/naming.md +321 -0
  54. package/skills/scaffolding-directive-modules/SKILL.md +218 -0
  55. package/skills/scaffolding-directive-modules/api-skeleton.md +5 -0
  56. package/skills/scaffolding-directive-modules/core-patterns.md +240 -0
  57. package/skills/scaffolding-directive-modules/examples.md +1386 -0
  58. package/skills/scaffolding-directive-modules/naming.md +321 -0
  59. package/skills/scaffolding-directive-modules/schema-types.md +273 -0
  60. package/skills/testing-ai-systems/SKILL.md +398 -0
  61. package/skills/testing-ai-systems/ai-debug-observability.md +329 -0
  62. package/skills/testing-ai-systems/ai-mcp-rag.md +293 -0
  63. package/skills/testing-ai-systems/ai-testing-evals.md +485 -0
  64. package/skills/testing-ai-systems/api-skeleton.md +5 -0
  65. package/skills/testing-ai-systems/examples.md +1261 -0
  66. package/skills/testing-directive-code/SKILL.md +479 -0
  67. package/skills/testing-directive-code/api-skeleton.md +5 -0
  68. package/skills/testing-directive-code/examples.md +156 -0
  69. package/skills/testing-directive-code/history.md +351 -0
  70. package/skills/testing-directive-code/testing.md +412 -0
  71. package/skills/writing-directive-constraints/SKILL.md +486 -0
  72. package/skills/writing-directive-constraints/api-skeleton.md +5 -0
  73. package/skills/writing-directive-constraints/constraints.md +274 -0
  74. package/skills/writing-directive-constraints/error-boundaries.md +330 -0
  75. package/skills/writing-directive-constraints/examples.md +1361 -0
  76. package/skills/writing-directive-constraints/resolvers.md +367 -0
  77. package/skills/writing-directive-modules/SKILL.md +342 -0
  78. package/skills/writing-directive-modules/anti-patterns.md +382 -0
  79. package/skills/writing-directive-modules/api-skeleton.md +5 -0
  80. package/skills/writing-directive-modules/core-patterns.md +240 -0
  81. package/skills/writing-directive-modules/examples.md +1639 -0
  82. package/skills/writing-directive-modules/naming.md +321 -0
  83. package/skills/writing-directive-modules/schema-types.md +273 -0
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "directive",
3
+ "version": "0.1.0",
4
+ "description": "Coding guidance for Directive — the constraint-driven TypeScript runtime. 12 skills covering modules, constraints, systems, testing, AI orchestrators, agents, guardrails, code review, scaffolding, and migration from Redux/Zustand/XState.",
5
+ "skills_dir": "../skills"
6
+ }
package/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sizls ∞ Jason Comes
4
+
5
+ This project is dual-licensed under MIT OR Apache-2.0. You may choose
6
+ either license. See LICENSE-APACHE for the Apache License, Version 2.0.
7
+
8
+ ---
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # `@directive-run/claude-plugin`
2
+
3
+ Claude Code plugin providing coding guidance for the [Directive](https://directive.run) runtime. Delivers 12 skills that Claude automatically invokes when you're working with Directive code.
4
+
5
+ The package has two install paths: **Claude Code's plugin marketplace** for end users (the canonical path), and **npm** for tool authors who want to consume the skill bundles programmatically.
6
+
7
+ ## Install for Claude Code (canonical)
8
+
9
+ Two steps in a Claude Code session — first register the marketplace, then install the plugin:
10
+
11
+ ```
12
+ /plugin marketplace add directive-run/directive
13
+ /plugin install directive@directive-plugins
14
+ ```
15
+
16
+ After install, verify the plugin is active with `/plugins` — you should see `directive` in the list.
17
+
18
+ ## Install for tool authors (npm)
19
+
20
+ ```bash
21
+ npm install @directive-run/claude-plugin
22
+ ```
23
+
24
+ The npm package ships the pre-built `skills/` directory and exposes it through a small programmatic API. Use this when you're building a custom skill registry, doc-generation pipeline, evals harness, or AI orchestrator that wants to expose Directive skills via its own routing layer.
25
+
26
+ ```typescript
27
+ import {
28
+ listSkills,
29
+ getSkill,
30
+ getAllSkills,
31
+ getSkillFile,
32
+ type Skill,
33
+ } from "@directive-run/claude-plugin";
34
+
35
+ // All skill names, alphabetical
36
+ const names = listSkills();
37
+ // → ["building-ai-agents", "building-ai-orchestrators", ...]
38
+
39
+ // One skill — manifest + supporting files
40
+ const skill = getSkill("building-ai-orchestrators");
41
+ skill?.manifest; // SKILL.md (with YAML frontmatter)
42
+ skill?.files.get("examples"); // examples.md contents
43
+
44
+ // All skills, keyed by name
45
+ const all = getAllSkills(); // Map<string, Skill>
46
+
47
+ // One supporting file
48
+ const ex = getSkillFile("building-ai-orchestrators", "examples");
49
+ ```
50
+
51
+ The npm install path is not a replacement for the Claude Code plugin install — it does not register the skills with Claude Code itself. It only exposes the same `skills/` directory as a typed module so other tools can read it.
52
+
53
+ ## What happens after install
54
+
55
+ Skills are **model-invoked**: Claude reads each skill's description and automatically loads the relevant skill when your task matches. There is nothing to invoke manually. You write code, Claude pulls in the right skill.
56
+
57
+ Each of the 12 skills bundles:
58
+
59
+ - A concise `SKILL.md` with a decision tree and quick-reference patterns
60
+ - Supporting knowledge `.md` files copied from [`@directive-run/knowledge`](../knowledge)
61
+ - Working code examples extracted from the [`examples/`](../../examples) directory
62
+
63
+ When Claude invokes a skill, the skill name appears in the response (`/<plugin>:<skill>` namespaced). You can also call a skill directly:
64
+
65
+ ```
66
+ /directive:writing-directive-modules
67
+ /directive:writing-directive-constraints
68
+ /directive:hardening-ai-systems
69
+ ```
70
+
71
+ ## Skills
72
+
73
+ | Skill | Description |
74
+ |-------|-------------|
75
+ | `getting-started-with-directive` | Understand Directive fundamentals and mental model |
76
+ | `writing-directive-modules` | Write modules with correct schema, type builders, naming |
77
+ | `writing-directive-constraints` | Write constraints and resolvers with error boundaries |
78
+ | `building-directive-systems` | Build multi-module systems with plugins and React |
79
+ | `testing-directive-code` | Test with createTestSystem, mockResolver, time-travel |
80
+ | `building-ai-orchestrators` | Build single and multi-agent AI orchestrators |
81
+ | `building-ai-agents` | Create agents with streaming, adapters, communication |
82
+ | `hardening-ai-systems` | Add guardrails, budgets, security to AI systems |
83
+ | `testing-ai-systems` | Test AI systems with mock runners and evaluations |
84
+ | `reviewing-directive-code` | Review code for anti-patterns and naming violations |
85
+ | `scaffolding-directive-modules` | Generate module scaffolds with matching test files |
86
+ | `migrating-to-directive` | Migrate from Redux, Zustand, XState, MobX to Directive |
87
+
88
+ ## Development
89
+
90
+ ```bash
91
+ # Build skills from knowledge package
92
+ pnpm --filter @directive-run/claude-plugin build
93
+
94
+ # Run tests
95
+ pnpm --filter @directive-run/claude-plugin test
96
+
97
+ # Test locally with Claude Code
98
+ claude --plugin-dir packages/claude-plugin
99
+ ```
100
+
101
+ Skills are built from `@directive-run/knowledge` + hand-authored templates in `templates/`. The build script (`scripts/build-skills.ts`) assembles the `skills/` directories.
102
+
103
+ ## Not using Claude Code?
104
+
105
+ The same knowledge ships through [`@directive-run/cli`](../cli) as rules files for every other AI assistant. Run it from your project:
106
+
107
+ ```bash
108
+ npx directive ai-rules init
109
+ ```
110
+
111
+ Generates `.cursorrules`, `.clinerules`, `copilot-instructions.md`, `windsurf.md`, OpenAI Codex `AGENTS.md`, and `CLAUDE.md` files tuned to each assistant's ingestion conventions.
112
+
113
+ See [/docs/ide-integration](https://directive.run/docs/ide-integration) for the full decision tree across Claude Code, Cursor, Copilot, Windsurf, Cline, and Codex.
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';var fs=require('fs'),path=require('path'),url=require('url');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var L=path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))),m=path.resolve(L,"..");function M(t){let r=path.join(m,t);if(fs.existsSync(r))return r;let n=path.join(m,"..",t);return fs.existsSync(n)?n:r}var S=M("skills"),i=null;function l(){if(i)return i;let t=new Map,r;try{r=fs.readdirSync(S);}catch(n){if(n.code==="ENOENT")return i=t,t;throw n}for(let n of r){let s=path.join(S,n);if(!fs.statSync(s).isDirectory())continue;let f=path.join(s,"SKILL.md");if(!fs.existsSync(f))continue;let d=fs.readFileSync(f,"utf-8"),a=new Map;for(let o of fs.readdirSync(s)){if(!o.endsWith(".md")||o==="SKILL.md")continue;let p=o.replace(/\.md$/,"");a.set(p,fs.readFileSync(path.join(s,o),"utf-8"));}t.set(n,{name:n,manifest:d,files:a});}return i=t,t}function K(){return Array.from(l().keys()).sort()}function N(t){return l().get(t)}function _(){return new Map(l())}function v(t,r){return l().get(t)?.files.get(r)}function A(){i=null;}exports.clearCache=A;exports.getAllSkills=_;exports.getSkill=N;exports.getSkillFile=v;exports.listSkills=K;//# sourceMappingURL=index.cjs.map
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["__dirname","dirname","fileURLToPath","PKG_ROOT","resolve","resolveAsset","name","fromDist","join","existsSync","fromSrc","SKILLS_DIR","skillCache","loadSkills","cache","entries","readdirSync","err","dir","statSync","manifestPath","manifest","readFileSync","files","file","baseName","listSkills","getSkill","getAllSkills","getSkillFile","skillName","fileName","clearCache"],"mappings":"+JAqBA,IAAMA,CAAAA,CAAYC,YAAAA,CAAQC,iBAAAA,CAAc,2PAAe,CAAC,CAAA,CAClDC,CAAAA,CAAWC,YAAAA,CAAQJ,CAAAA,CAAW,IAAI,CAAA,CAOxC,SAASK,CAAAA,CAAaC,CAAAA,CAAsB,CAC1C,IAAMC,CAAAA,CAAWC,SAAAA,CAAKL,CAAAA,CAAUG,CAAI,CAAA,CACpC,GAAIG,aAAAA,CAAWF,CAAQ,CAAA,CACrB,OAAOA,CAAAA,CAGT,IAAMG,CAAAA,CAAUF,SAAAA,CAAKL,CAAAA,CAAU,IAAA,CAAMG,CAAI,CAAA,CACzC,OAAIG,aAAAA,CAAWC,CAAO,CAAA,CACbA,EAGFH,CACT,CAEA,IAAMI,CAAAA,CAAaN,CAAAA,CAAa,QAAQ,CAAA,CAgBpCO,CAAAA,CAAwC,IAAA,CAE5C,SAASC,CAAAA,EAAiC,CACxC,GAAID,CAAAA,CACF,OAAOA,CAAAA,CAGT,IAAME,CAAAA,CAAQ,IAAI,GAAA,CACdC,CAAAA,CACJ,GAAI,CACFA,CAAAA,CAAUC,cA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ASc,CAAAA,CAASrB,CAAAA,CAAiC,CACxD,OAAOO,CAAAA,EAAW,CAAE,GAAA,CAAIP,CAAI,CAC9B,CAQO,SAASsB,CAAAA,EAAmC,CACjD,OAAO,IAAI,GAAA,CAAIf,CAAAA,EAAY,CAC7B,CAWO,SAASgB,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACoB,CACpB,OAAOlB,CAAAA,EAAW,CAAE,GAAA,CAAIiB,CAAS,CAAA,EAAG,KAAA,CAAM,GAAA,CAAIC,CAAQ,CACxD,CAMO,SAASC,CAAAA,EAAmB,CACjCpB,CAAAA,CAAa,KACf","file":"index.cjs","sourcesContent":["/**\n * Programmatic API for `@directive-run/claude-plugin`.\n *\n * The canonical install path for end users is Claude Code's plugin\n * marketplace (`/plugin marketplace add directive-run/directive`\n * then `/plugin install directive@directive-plugins`). This module\n * is the alternative install path for tool authors who want to\n * consume the skill bundles programmatically — custom skill\n * registries, doc-generation pipelines, eval harnesses, or AI\n * orchestrators that want to expose Directive skills via their own\n * routing layer.\n *\n * The package ships the pre-built skill bundles in `skills/`. This\n * module exposes them as functions: list the skills, read a SKILL.md,\n * read a supporting knowledge file, or grab the whole skill tree.\n */\n\nimport { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst PKG_ROOT = resolve(__dirname, \"..\");\n\n/**\n * Resolve a path relative to the package root. Tries the published\n * layout (`dist/` sibling of `skills/`) first, then the dev layout\n * (running from `src/` in the monorepo).\n */\nfunction resolveAsset(name: string): string {\n const fromDist = join(PKG_ROOT, name);\n if (existsSync(fromDist)) {\n return fromDist;\n }\n\n const fromSrc = join(PKG_ROOT, \"..\", name);\n if (existsSync(fromSrc)) {\n return fromSrc;\n }\n\n return fromDist;\n}\n\nconst SKILLS_DIR = resolveAsset(\"skills\");\n\n/**\n * One bundled skill — the `SKILL.md` plus its supporting knowledge\n * files (which are copied in from `@directive-run/knowledge` at\n * build time) and the auto-generated `examples.md` when present.\n */\nexport interface Skill {\n /** Skill name (matches the directory under `skills/`). */\n name: string;\n /** Full `SKILL.md` contents — the Claude-facing skill manifest. */\n manifest: string;\n /** Supporting files keyed by base name (no `.md` suffix). */\n files: Map<string, string>;\n}\n\nlet skillCache: Map<string, Skill> | null = null;\n\nfunction loadSkills(): Map<string, Skill> {\n if (skillCache) {\n return skillCache;\n }\n\n const cache = new Map<string, Skill>();\n let entries: string[];\n try {\n entries = readdirSync(SKILLS_DIR);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") {\n skillCache = cache;\n return cache;\n }\n throw err;\n }\n\n for (const name of entries) {\n const dir = join(SKILLS_DIR, name);\n if (!statSync(dir).isDirectory()) {\n continue;\n }\n\n const manifestPath = join(dir, \"SKILL.md\");\n if (!existsSync(manifestPath)) {\n continue;\n }\n\n const manifest = readFileSync(manifestPath, \"utf-8\");\n const files = new Map<string, string>();\n for (const file of readdirSync(dir)) {\n if (!file.endsWith(\".md\") || file === \"SKILL.md\") {\n continue;\n }\n const baseName = file.replace(/\\.md$/, \"\");\n files.set(baseName, readFileSync(join(dir, file), \"utf-8\"));\n }\n\n cache.set(name, { name, manifest, files });\n }\n\n skillCache = cache;\n return cache;\n}\n\n/**\n * List the names of every bundled skill.\n *\n * Returns an alphabetically-sorted array — stable for snapshot tests.\n */\nexport function listSkills(): string[] {\n return Array.from(loadSkills().keys()).sort();\n}\n\n/**\n * Get a single skill by name.\n *\n * @param name - Skill name (e.g. `\"writing-directive-modules\"`).\n * @returns The skill, or `undefined` if no skill by that name exists.\n */\nexport function getSkill(name: string): Skill | undefined {\n return loadSkills().get(name);\n}\n\n/**\n * Get every bundled skill, keyed by name.\n *\n * Returns a defensive copy — mutating the returned Map won't affect\n * subsequent calls.\n */\nexport function getAllSkills(): Map<string, Skill> {\n return new Map(loadSkills());\n}\n\n/**\n * Read one supporting file from a skill bundle.\n *\n * @param skillName - Skill name (e.g. `\"writing-directive-modules\"`).\n * @param fileName - Supporting file base name without `.md`\n * (e.g. `\"core-patterns\"`, `\"anti-patterns\"`, `\"examples\"`).\n * @returns File contents, or `undefined` if the skill or file is not\n * present.\n */\nexport function getSkillFile(\n skillName: string,\n fileName: string,\n): string | undefined {\n return loadSkills().get(skillName)?.files.get(fileName);\n}\n\n/**\n * Clear the in-memory skill cache. Useful in tests or watch-mode\n * tooling that regenerates the `skills/` directory between calls.\n */\nexport function clearCache(): void {\n skillCache = null;\n}\n"]}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Programmatic API for `@directive-run/claude-plugin`.
3
+ *
4
+ * The canonical install path for end users is Claude Code's plugin
5
+ * marketplace (`/plugin marketplace add directive-run/directive`
6
+ * then `/plugin install directive@directive-plugins`). This module
7
+ * is the alternative install path for tool authors who want to
8
+ * consume the skill bundles programmatically — custom skill
9
+ * registries, doc-generation pipelines, eval harnesses, or AI
10
+ * orchestrators that want to expose Directive skills via their own
11
+ * routing layer.
12
+ *
13
+ * The package ships the pre-built skill bundles in `skills/`. This
14
+ * module exposes them as functions: list the skills, read a SKILL.md,
15
+ * read a supporting knowledge file, or grab the whole skill tree.
16
+ */
17
+ /**
18
+ * One bundled skill — the `SKILL.md` plus its supporting knowledge
19
+ * files (which are copied in from `@directive-run/knowledge` at
20
+ * build time) and the auto-generated `examples.md` when present.
21
+ */
22
+ interface Skill {
23
+ /** Skill name (matches the directory under `skills/`). */
24
+ name: string;
25
+ /** Full `SKILL.md` contents — the Claude-facing skill manifest. */
26
+ manifest: string;
27
+ /** Supporting files keyed by base name (no `.md` suffix). */
28
+ files: Map<string, string>;
29
+ }
30
+ /**
31
+ * List the names of every bundled skill.
32
+ *
33
+ * Returns an alphabetically-sorted array — stable for snapshot tests.
34
+ */
35
+ declare function listSkills(): string[];
36
+ /**
37
+ * Get a single skill by name.
38
+ *
39
+ * @param name - Skill name (e.g. `"writing-directive-modules"`).
40
+ * @returns The skill, or `undefined` if no skill by that name exists.
41
+ */
42
+ declare function getSkill(name: string): Skill | undefined;
43
+ /**
44
+ * Get every bundled skill, keyed by name.
45
+ *
46
+ * Returns a defensive copy — mutating the returned Map won't affect
47
+ * subsequent calls.
48
+ */
49
+ declare function getAllSkills(): Map<string, Skill>;
50
+ /**
51
+ * Read one supporting file from a skill bundle.
52
+ *
53
+ * @param skillName - Skill name (e.g. `"writing-directive-modules"`).
54
+ * @param fileName - Supporting file base name without `.md`
55
+ * (e.g. `"core-patterns"`, `"anti-patterns"`, `"examples"`).
56
+ * @returns File contents, or `undefined` if the skill or file is not
57
+ * present.
58
+ */
59
+ declare function getSkillFile(skillName: string, fileName: string): string | undefined;
60
+ /**
61
+ * Clear the in-memory skill cache. Useful in tests or watch-mode
62
+ * tooling that regenerates the `skills/` directory between calls.
63
+ */
64
+ declare function clearCache(): void;
65
+
66
+ export { type Skill, clearCache, getAllSkills, getSkill, getSkillFile, listSkills };
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Programmatic API for `@directive-run/claude-plugin`.
3
+ *
4
+ * The canonical install path for end users is Claude Code's plugin
5
+ * marketplace (`/plugin marketplace add directive-run/directive`
6
+ * then `/plugin install directive@directive-plugins`). This module
7
+ * is the alternative install path for tool authors who want to
8
+ * consume the skill bundles programmatically — custom skill
9
+ * registries, doc-generation pipelines, eval harnesses, or AI
10
+ * orchestrators that want to expose Directive skills via their own
11
+ * routing layer.
12
+ *
13
+ * The package ships the pre-built skill bundles in `skills/`. This
14
+ * module exposes them as functions: list the skills, read a SKILL.md,
15
+ * read a supporting knowledge file, or grab the whole skill tree.
16
+ */
17
+ /**
18
+ * One bundled skill — the `SKILL.md` plus its supporting knowledge
19
+ * files (which are copied in from `@directive-run/knowledge` at
20
+ * build time) and the auto-generated `examples.md` when present.
21
+ */
22
+ interface Skill {
23
+ /** Skill name (matches the directory under `skills/`). */
24
+ name: string;
25
+ /** Full `SKILL.md` contents — the Claude-facing skill manifest. */
26
+ manifest: string;
27
+ /** Supporting files keyed by base name (no `.md` suffix). */
28
+ files: Map<string, string>;
29
+ }
30
+ /**
31
+ * List the names of every bundled skill.
32
+ *
33
+ * Returns an alphabetically-sorted array — stable for snapshot tests.
34
+ */
35
+ declare function listSkills(): string[];
36
+ /**
37
+ * Get a single skill by name.
38
+ *
39
+ * @param name - Skill name (e.g. `"writing-directive-modules"`).
40
+ * @returns The skill, or `undefined` if no skill by that name exists.
41
+ */
42
+ declare function getSkill(name: string): Skill | undefined;
43
+ /**
44
+ * Get every bundled skill, keyed by name.
45
+ *
46
+ * Returns a defensive copy — mutating the returned Map won't affect
47
+ * subsequent calls.
48
+ */
49
+ declare function getAllSkills(): Map<string, Skill>;
50
+ /**
51
+ * Read one supporting file from a skill bundle.
52
+ *
53
+ * @param skillName - Skill name (e.g. `"writing-directive-modules"`).
54
+ * @param fileName - Supporting file base name without `.md`
55
+ * (e.g. `"core-patterns"`, `"anti-patterns"`, `"examples"`).
56
+ * @returns File contents, or `undefined` if the skill or file is not
57
+ * present.
58
+ */
59
+ declare function getSkillFile(skillName: string, fileName: string): string | undefined;
60
+ /**
61
+ * Clear the in-memory skill cache. Useful in tests or watch-mode
62
+ * tooling that regenerates the `skills/` directory between calls.
63
+ */
64
+ declare function clearCache(): void;
65
+
66
+ export { type Skill, clearCache, getAllSkills, getSkill, getSkillFile, listSkills };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import {existsSync,readdirSync,statSync,readFileSync}from'fs';import {dirname,resolve,join}from'path';import {fileURLToPath}from'url';var L=dirname(fileURLToPath(import.meta.url)),m=resolve(L,"..");function M(t){let r=join(m,t);if(existsSync(r))return r;let n=join(m,"..",t);return existsSync(n)?n:r}var S=M("skills"),i=null;function l(){if(i)return i;let t=new Map,r;try{r=readdirSync(S);}catch(n){if(n.code==="ENOENT")return i=t,t;throw n}for(let n of r){let s=join(S,n);if(!statSync(s).isDirectory())continue;let f=join(s,"SKILL.md");if(!existsSync(f))continue;let d=readFileSync(f,"utf-8"),a=new Map;for(let o of readdirSync(s)){if(!o.endsWith(".md")||o==="SKILL.md")continue;let p=o.replace(/\.md$/,"");a.set(p,readFileSync(join(s,o),"utf-8"));}t.set(n,{name:n,manifest:d,files:a});}return i=t,t}function K(){return Array.from(l().keys()).sort()}function N(t){return l().get(t)}function _(){return new Map(l())}function v(t,r){return l().get(t)?.files.get(r)}function A(){i=null;}export{A as clearCache,_ as getAllSkills,N as getSkill,v as getSkillFile,K as listSkills};//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["__dirname","dirname","fileURLToPath","PKG_ROOT","resolve","resolveAsset","name","fromDist","join","existsSync","fromSrc","SKILLS_DIR","skillCache","loadSkills","cache","entries","readdirSync","err","dir","statSync","manifestPath","manifest","readFileSync","files","file","baseName","listSkills","getSkill","getAllSkills","getSkillFile","skillName","fileName","clearCache"],"mappings":"sIAqBA,IAAMA,CAAAA,CAAYC,OAAAA,CAAQC,aAAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA,CAClDC,CAAAA,CAAWC,OAAAA,CAAQJ,CAAAA,CAAW,IAAI,CAAA,CAOxC,SAASK,CAAAA,CAAaC,CAAAA,CAAsB,CAC1C,IAAMC,CAAAA,CAAWC,IAAAA,CAAKL,CAAAA,CAAUG,CAAI,CAAA,CACpC,GAAIG,UAAAA,CAAWF,CAAQ,CAAA,CACrB,OAAOA,CAAAA,CAGT,IAAMG,CAAAA,CAAUF,IAAAA,CAAKL,CAAAA,CAAU,IAAA,CAAMG,CAAI,CAAA,CACzC,OAAIG,UAAAA,CAAWC,CAAO,CAAA,CACbA,EAGFH,CACT,CAEA,IAAMI,CAAAA,CAAaN,CAAAA,CAAa,QAAQ,CAAA,CAgBpCO,CAAAA,CAAwC,IAAA,CAE5C,SAASC,CAAAA,EAAiC,CACxC,GAAID,CAAAA,CACF,OAAOA,CAAAA,CAGT,IAAME,CAAAA,CAAQ,IAAI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AAW,CAAE,IAAA,EAAM,CAAA,CAAE,IAAA,EACzC,CAQO,SAASc,CAAAA,CAASrB,CAAAA,CAAiC,CACxD,OAAOO,CAAAA,EAAW,CAAE,GAAA,CAAIP,CAAI,CAC9B,CAQO,SAASsB,CAAAA,EAAmC,CACjD,OAAO,IAAI,GAAA,CAAIf,CAAAA,EAAY,CAC7B,CAWO,SAASgB,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACoB,CACpB,OAAOlB,CAAAA,EAAW,CAAE,GAAA,CAAIiB,CAAS,CAAA,EAAG,KAAA,CAAM,GAAA,CAAIC,CAAQ,CACxD,CAMO,SAASC,CAAAA,EAAmB,CACjCpB,CAAAA,CAAa,KACf","file":"index.js","sourcesContent":["/**\n * Programmatic API for `@directive-run/claude-plugin`.\n *\n * The canonical install path for end users is Claude Code's plugin\n * marketplace (`/plugin marketplace add directive-run/directive`\n * then `/plugin install directive@directive-plugins`). This module\n * is the alternative install path for tool authors who want to\n * consume the skill bundles programmatically — custom skill\n * registries, doc-generation pipelines, eval harnesses, or AI\n * orchestrators that want to expose Directive skills via their own\n * routing layer.\n *\n * The package ships the pre-built skill bundles in `skills/`. This\n * module exposes them as functions: list the skills, read a SKILL.md,\n * read a supporting knowledge file, or grab the whole skill tree.\n */\n\nimport { existsSync, readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst PKG_ROOT = resolve(__dirname, \"..\");\n\n/**\n * Resolve a path relative to the package root. Tries the published\n * layout (`dist/` sibling of `skills/`) first, then the dev layout\n * (running from `src/` in the monorepo).\n */\nfunction resolveAsset(name: string): string {\n const fromDist = join(PKG_ROOT, name);\n if (existsSync(fromDist)) {\n return fromDist;\n }\n\n const fromSrc = join(PKG_ROOT, \"..\", name);\n if (existsSync(fromSrc)) {\n return fromSrc;\n }\n\n return fromDist;\n}\n\nconst SKILLS_DIR = resolveAsset(\"skills\");\n\n/**\n * One bundled skill — the `SKILL.md` plus its supporting knowledge\n * files (which are copied in from `@directive-run/knowledge` at\n * build time) and the auto-generated `examples.md` when present.\n */\nexport interface Skill {\n /** Skill name (matches the directory under `skills/`). */\n name: string;\n /** Full `SKILL.md` contents — the Claude-facing skill manifest. */\n manifest: string;\n /** Supporting files keyed by base name (no `.md` suffix). */\n files: Map<string, string>;\n}\n\nlet skillCache: Map<string, Skill> | null = null;\n\nfunction loadSkills(): Map<string, Skill> {\n if (skillCache) {\n return skillCache;\n }\n\n const cache = new Map<string, Skill>();\n let entries: string[];\n try {\n entries = readdirSync(SKILLS_DIR);\n } catch (err: unknown) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") {\n skillCache = cache;\n return cache;\n }\n throw err;\n }\n\n for (const name of entries) {\n const dir = join(SKILLS_DIR, name);\n if (!statSync(dir).isDirectory()) {\n continue;\n }\n\n const manifestPath = join(dir, \"SKILL.md\");\n if (!existsSync(manifestPath)) {\n continue;\n }\n\n const manifest = readFileSync(manifestPath, \"utf-8\");\n const files = new Map<string, string>();\n for (const file of readdirSync(dir)) {\n if (!file.endsWith(\".md\") || file === \"SKILL.md\") {\n continue;\n }\n const baseName = file.replace(/\\.md$/, \"\");\n files.set(baseName, readFileSync(join(dir, file), \"utf-8\"));\n }\n\n cache.set(name, { name, manifest, files });\n }\n\n skillCache = cache;\n return cache;\n}\n\n/**\n * List the names of every bundled skill.\n *\n * Returns an alphabetically-sorted array — stable for snapshot tests.\n */\nexport function listSkills(): string[] {\n return Array.from(loadSkills().keys()).sort();\n}\n\n/**\n * Get a single skill by name.\n *\n * @param name - Skill name (e.g. `\"writing-directive-modules\"`).\n * @returns The skill, or `undefined` if no skill by that name exists.\n */\nexport function getSkill(name: string): Skill | undefined {\n return loadSkills().get(name);\n}\n\n/**\n * Get every bundled skill, keyed by name.\n *\n * Returns a defensive copy — mutating the returned Map won't affect\n * subsequent calls.\n */\nexport function getAllSkills(): Map<string, Skill> {\n return new Map(loadSkills());\n}\n\n/**\n * Read one supporting file from a skill bundle.\n *\n * @param skillName - Skill name (e.g. `\"writing-directive-modules\"`).\n * @param fileName - Supporting file base name without `.md`\n * (e.g. `\"core-patterns\"`, `\"anti-patterns\"`, `\"examples\"`).\n * @returns File contents, or `undefined` if the skill or file is not\n * present.\n */\nexport function getSkillFile(\n skillName: string,\n fileName: string,\n): string | undefined {\n return loadSkills().get(skillName)?.files.get(fileName);\n}\n\n/**\n * Clear the in-memory skill cache. Useful in tests or watch-mode\n * tooling that regenerates the `skills/` directory between calls.\n */\nexport function clearCache(): void {\n skillCache = null;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@directive-run/claude-plugin",
3
+ "version": "1.16.0",
4
+ "description": "Claude Code plugin for Directive — 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.",
5
+ "license": "(MIT OR Apache-2.0)",
6
+ "author": "Jason Comes",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/directive-run/directive",
10
+ "directory": "packages/claude-plugin"
11
+ },
12
+ "homepage": "https://directive.run/docs/ide-integration",
13
+ "bugs": {
14
+ "url": "https://github.com/directive-run/directive/issues"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org"
19
+ },
20
+ "engines": {
21
+ "node": ">=18"
22
+ },
23
+ "keywords": [
24
+ "directive",
25
+ "claude",
26
+ "claude-code",
27
+ "skills",
28
+ "ai-rules",
29
+ "plugin",
30
+ "agents",
31
+ "knowledge"
32
+ ],
33
+ "type": "module",
34
+ "main": "./dist/index.cjs",
35
+ "module": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
37
+ "exports": {
38
+ ".": {
39
+ "types": "./dist/index.d.ts",
40
+ "require": "./dist/index.cjs",
41
+ "import": "./dist/index.js"
42
+ }
43
+ },
44
+ "files": [
45
+ "dist",
46
+ "skills",
47
+ ".claude-plugin"
48
+ ],
49
+ "devDependencies": {
50
+ "@types/node": "^25.2.0",
51
+ "tsup": "^8.3.5",
52
+ "tsx": "^4.19.2",
53
+ "typescript": "^5.7.2",
54
+ "vitest": "^3.0.0",
55
+ "@directive-run/knowledge": "1.16.0"
56
+ },
57
+ "scripts": {
58
+ "build": "tsx scripts/build-skills.ts && tsup",
59
+ "build:skills": "tsx scripts/build-skills.ts",
60
+ "test": "vitest run",
61
+ "typecheck": "tsc --noEmit",
62
+ "clean": "rm -rf skills/* dist"
63
+ }
64
+ }
@@ -0,0 +1,9 @@
1
+ # Generated – Do Not Edit
2
+
3
+ This directory is auto-generated by `scripts/build-skills.ts` from templates + `@directive-run/knowledge`.
4
+
5
+ To modify skills, edit files in `templates/` and rebuild:
6
+
7
+ ```bash
8
+ pnpm --filter @directive-run/claude-plugin build
9
+ ```