@directive-run/cli 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jason Comes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,188 @@
1
+ # @directive-run/cli
2
+
3
+ CLI for [Directive](https://directive.run) — project scaffolding, system introspection, AI coding rules, and more.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Run directly (no install needed)
9
+ npx directive --help
10
+
11
+ # Or install globally
12
+ npm install -g @directive-run/cli
13
+ ```
14
+
15
+ The binary is aliased as both `directive` and `dr`.
16
+
17
+ ## Commands
18
+
19
+ ### `directive init`
20
+
21
+ Interactive project scaffolding wizard. Creates a starter module + system entry file.
22
+
23
+ ```bash
24
+ directive init # Interactive wizard
25
+ directive init --template counter # Skip prompts, use counter template
26
+ directive init --template auth-flow # Constraints + resolvers starter
27
+ directive init --template ai-orchestrator # AI agent starter
28
+ directive init --no-interactive # Defaults only (counter template)
29
+ directive init --dir ./my-project # Target directory
30
+ ```
31
+
32
+ Templates:
33
+ - **counter** — Minimal: schema, init, derive, events
34
+ - **auth-flow** — Login flow with constraints, resolvers, retry, and effects
35
+ - **ai-orchestrator** — Agent module with memory, guardrails, and streaming
36
+
37
+ ### `directive new module <name>`
38
+
39
+ Generate a typed module file.
40
+
41
+ ```bash
42
+ directive new module auth # Full module (all sections)
43
+ directive new module auth --minimal # Schema + init only
44
+ directive new module auth --with derive,constraints,resolvers
45
+ directive new module auth --dir ./src/modules
46
+ ```
47
+
48
+ ### `directive new orchestrator <name>`
49
+
50
+ Generate an AI orchestrator module with `@directive-run/ai`.
51
+
52
+ ```bash
53
+ directive new orchestrator my-agent
54
+ directive new orchestrator my-agent --dir ./src
55
+ ```
56
+
57
+ ### `directive inspect <file>`
58
+
59
+ Load a Directive system and print structured overview: facts, constraints, resolvers, unmet requirements, inflight status.
60
+
61
+ ```bash
62
+ directive inspect src/main.ts # Pretty-printed table
63
+ directive inspect src/main.ts --json # JSON output
64
+ directive inspect src/main.ts --module auth # Specific module
65
+ ```
66
+
67
+ Warns on unresolved requirements (no matching resolver).
68
+
69
+ ### `directive explain <file> [requirement-id]`
70
+
71
+ Explain why a requirement exists. Wraps `system.explain()` for terminal use.
72
+
73
+ ```bash
74
+ directive explain src/main.ts # List all requirements + status
75
+ directive explain src/main.ts req-123 # Detailed explanation for one
76
+ ```
77
+
78
+ ### `directive graph <file>`
79
+
80
+ Visual dependency graph: facts → constraints → requirements → resolvers.
81
+
82
+ ```bash
83
+ directive graph src/main.ts # HTML output, opens in browser
84
+ directive graph src/main.ts --ascii # Terminal-only box-drawing output
85
+ directive graph src/main.ts --no-open # Generate HTML but don't open
86
+ directive graph src/main.ts --output graph.html
87
+ ```
88
+
89
+ ### `directive doctor`
90
+
91
+ Non-interactive health check for project setup.
92
+
93
+ ```bash
94
+ directive doctor # Check current directory
95
+ directive doctor --dir ./my-project # Check specific directory
96
+ ```
97
+
98
+ Checks:
99
+ - `@directive-run/core` installed
100
+ - Package version compatibility
101
+ - TypeScript 5.3+ with `strict: true` and correct `moduleResolution`
102
+ - No duplicate Directive instances in `node_modules`
103
+ - AI rules freshness (if installed)
104
+
105
+ Exits non-zero on failures.
106
+
107
+ ### `directive ai-rules init`
108
+
109
+ Install AI coding rules for your AI coding assistant.
110
+
111
+ ```bash
112
+ directive ai-rules init # Interactive — detect tools, prompt
113
+ directive ai-rules init --tool cursor # Specific tool
114
+ directive ai-rules init --force # Overwrite existing files
115
+ directive ai-rules init --merge # Update Directive section only
116
+ directive ai-rules init --dir ./project
117
+ ```
118
+
119
+ ### `directive ai-rules update`
120
+
121
+ Regenerate all existing rule files to the latest knowledge version.
122
+
123
+ ```bash
124
+ directive ai-rules update
125
+ directive ai-rules update --dir ./project
126
+ ```
127
+
128
+ ### `directive ai-rules check`
129
+
130
+ Validate rules are current. Exits non-zero if stale — designed for CI.
131
+
132
+ ```bash
133
+ directive ai-rules check
134
+ directive ai-rules check --dir ./project
135
+ ```
136
+
137
+ ### `directive examples list`
138
+
139
+ Browse available examples from `@directive-run/knowledge`.
140
+
141
+ ```bash
142
+ directive examples list # All examples, grouped by category
143
+ directive examples list --filter ai # Filter by category or name
144
+ ```
145
+
146
+ ### `directive examples copy <name>`
147
+
148
+ Extract an example to your project. Rewrites workspace imports to published package names.
149
+
150
+ ```bash
151
+ directive examples copy counter
152
+ directive examples copy auth-flow --dest ./src/examples
153
+ ```
154
+
155
+ ## Supported AI Tools
156
+
157
+ | Tool | Output File |
158
+ |------|-------------|
159
+ | Cursor | `.cursorrules` |
160
+ | Cline | `.clinerules` |
161
+ | GitHub Copilot | `.github/copilot-instructions.md` |
162
+ | Windsurf | `windsurf.md` |
163
+ | Claude Code | `CLAUDE.md` |
164
+ | LLMs.txt | `llms.txt` |
165
+
166
+ ## Programmatic API
167
+
168
+ ```typescript
169
+ import { getTemplate, loadSystem, detectTools } from "@directive-run/cli";
170
+
171
+ // Generate AI rules content
172
+ const cursorRules = getTemplate("cursor");
173
+
174
+ // Load a Directive system from a TS file
175
+ const system = await loadSystem("./src/main.ts");
176
+ const inspection = system.inspect();
177
+
178
+ // Detect AI coding tools in a directory
179
+ const tools = detectTools("./my-project");
180
+ ```
181
+
182
+ ## Development
183
+
184
+ ```bash
185
+ pnpm --filter @directive-run/cli build
186
+ pnpm --filter @directive-run/cli test
187
+ pnpm --filter @directive-run/cli typecheck
188
+ ```