@zebralabs/context-cli 0.1.3 → 0.1.5
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/README.md +472 -0
- package/package.json +1 -1
- package/src/application/compile/compile-context.js +119 -0
- package/src/application/compile/stage1-discovery.js +125 -0
- package/src/application/compile/stage2-extraction.js +97 -0
- package/src/application/compile/stage4-consolidation.js +235 -0
- package/src/application/compile/stage5-assets.js +61 -0
- package/src/application/compile/stage6-validation.js +133 -0
- package/src/application/ports/asset-generator.js +33 -0
- package/src/context.js +274 -10
- package/src/domain/compilation.js +77 -0
- package/src/domain/preference.js +23 -0
- package/src/domain/rule.js +71 -0
- package/src/domain/scope.js +30 -0
- package/src/infrastructure/assets/claude/claude-generator.js +95 -0
- package/src/infrastructure/assets/cursor/cursor-rules-generator.js +119 -0
- package/src/infrastructure/assets/cursor/cursor-skills-generator.js +115 -0
- package/src/infrastructure/file-system/file-reader.js +67 -0
- package/src/infrastructure/file-system/file-writer.js +40 -0
- package/src/infrastructure/parsing/markdown-parser.js +95 -0
- package/src/infrastructure/parsing/rule-extractor.js +219 -0
- package/src/infrastructure/parsing/skill-extractor.js +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
# @zebralabs/context-cli
|
|
2
|
+
|
|
3
|
+
> Install engineering standards into your repository. AI remembers forever.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@zebralabs/context-cli)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
**Context CLI** is the command-line tool for installing and managing [Context Packs](https://www.zebralabs.io/context-packs) — professional engineering standards that teach your AI tools (Cursor, Claude) how to generate consistent, standards-compliant output.
|
|
9
|
+
|
|
10
|
+
## What is Context CLI?
|
|
11
|
+
|
|
12
|
+
AI coding assistants are fast, but they generate inconsistent output. Without standards, you spend time fixing AI mistakes instead of building features.
|
|
13
|
+
|
|
14
|
+
**Context Packs** solve this by injecting professional standards directly into your repository. Once installed, AI automatically follows your rules — no re-explaining, no drift, consistent output every time.
|
|
15
|
+
|
|
16
|
+
### Key Benefits
|
|
17
|
+
|
|
18
|
+
- ✅ **Standards live in your repo** — Version-controlled, reviewable, evolvable
|
|
19
|
+
- ✅ **Automatic enforcement** — AI reads standards automatically, no activation needed
|
|
20
|
+
- ✅ **Modular knowledge** — Install only what you need, add more over time
|
|
21
|
+
- ✅ **Built for AI tools** — Designed for how Cursor and Claude actually work
|
|
22
|
+
|
|
23
|
+
> **Learn more:** Visit [zebralabs.io/context-packs](https://www.zebralabs.io/context-packs) for product overview, available packs, and purchasing.
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### 1. Install the CLI
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g @zebralabs/context-cli
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 2. Install Your First Pack
|
|
34
|
+
|
|
35
|
+
After purchasing a pack, you'll receive a download link and authentication token. Install it:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
ctx pack install pack-01-documentation-management \
|
|
39
|
+
--registry https://www.zebralabs.io/api \
|
|
40
|
+
--token YOUR_TOKEN_HERE
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 3. Verify Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
ctx list
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
You should see your installed pack listed. The pack is now part of your repository and works automatically with Cursor and Claude.
|
|
50
|
+
|
|
51
|
+
### 4. Start Using
|
|
52
|
+
|
|
53
|
+
Ask Cursor or Claude to generate documentation following your standards:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
Generate a component specification following our documentation standards
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
AI will automatically use your installed standards — no re-explaining needed.
|
|
60
|
+
|
|
61
|
+
> **Need a pack?** Browse available packs at [zebralabs.io/context-packs](https://www.zebralabs.io/context-packs)
|
|
62
|
+
|
|
63
|
+
## Commands
|
|
64
|
+
|
|
65
|
+
### `ctx help`
|
|
66
|
+
|
|
67
|
+
Show help information and command usage.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
ctx help
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### `ctx pack install <packId>`
|
|
74
|
+
|
|
75
|
+
Install a context pack into your repository.
|
|
76
|
+
|
|
77
|
+
**Options:**
|
|
78
|
+
- `--repo-root <path>` — Repository root directory (default: auto-detect)
|
|
79
|
+
- `--mode <SkipExisting|Overwrite>` — File merge mode (default: SkipExisting)
|
|
80
|
+
- `--zip <path>` — Install from local ZIP file
|
|
81
|
+
- `--registry <url>` — Registry URL for downloading packs
|
|
82
|
+
- `--token <token>` — Authentication token for registry
|
|
83
|
+
- `--version <x.y.z>` — Specific pack version (default: latest)
|
|
84
|
+
|
|
85
|
+
**Examples:**
|
|
86
|
+
|
|
87
|
+
Install from registry (requires token):
|
|
88
|
+
```bash
|
|
89
|
+
ctx pack install pack-01-documentation-management \
|
|
90
|
+
--registry https://www.zebralabs.io/api \
|
|
91
|
+
--token YOUR_TOKEN
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Install specific version:
|
|
95
|
+
```bash
|
|
96
|
+
ctx pack install pack-01-documentation-management \
|
|
97
|
+
--registry https://www.zebralabs.io/api \
|
|
98
|
+
--token YOUR_TOKEN \
|
|
99
|
+
--version 0.4.0
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Install from local ZIP (for testing):
|
|
103
|
+
```bash
|
|
104
|
+
ctx pack install pack-01-documentation-management \
|
|
105
|
+
--zip ./pack-01-documentation-management-v0.4.0.zip
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**What happens:**
|
|
109
|
+
- Pack files are extracted and merged into `docs/practices-and-standards/`
|
|
110
|
+
- Cursor rules (`.cursor/rules/`) are copied to repository root
|
|
111
|
+
- Cursor skills (`.cursor/skills/`) are copied to repository root
|
|
112
|
+
- `CLAUDE.md` is copied to repository root
|
|
113
|
+
- `context.yaml` is created/updated with pack information
|
|
114
|
+
|
|
115
|
+
### `ctx list`
|
|
116
|
+
|
|
117
|
+
List all installed context packs and their contributions.
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
ctx list
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Output:**
|
|
124
|
+
```
|
|
125
|
+
Installed Context Packs
|
|
126
|
+
-----------------------
|
|
127
|
+
|
|
128
|
+
- pack-01-documentation-management @ 0.4.0
|
|
129
|
+
Contributes:
|
|
130
|
+
- docs/practices-and-standards/01-engineering-practices/01-documentation-methodology
|
|
131
|
+
- docs/practices-and-standards/01-engineering-practices/00-methodologies
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Options:**
|
|
135
|
+
- `--context-yaml <path>` — Path to `context.yaml` file (default: auto-detect)
|
|
136
|
+
|
|
137
|
+
### `ctx compile`
|
|
138
|
+
|
|
139
|
+
Compile standards from installed packs into consolidated outputs.
|
|
140
|
+
|
|
141
|
+
**Options:**
|
|
142
|
+
- `--pack <packId>` — Compile a specific pack only
|
|
143
|
+
- `--context-yaml <path>` — Path to `context.yaml` file (default: auto-detect)
|
|
144
|
+
|
|
145
|
+
**Examples:**
|
|
146
|
+
|
|
147
|
+
Compile all installed packs:
|
|
148
|
+
```bash
|
|
149
|
+
ctx compile
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Compile a specific pack:
|
|
153
|
+
```bash
|
|
154
|
+
ctx compile --pack pack-01-documentation-management
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Output:**
|
|
158
|
+
- `docs/practices-and-standards/.compiled/system-prompt.md` — Consolidated standards
|
|
159
|
+
- `docs/practices-and-standards/.compiled/sources.md` — Source file list
|
|
160
|
+
- `docs/practices-and-standards/.compiled/report.md` — Compilation report
|
|
161
|
+
|
|
162
|
+
**Pack-specific compilation:**
|
|
163
|
+
When using `--pack`, outputs are generated in the pack directory:
|
|
164
|
+
- `docs/practices-and-standards/packs/<pack-id>/.cursor/rules/` — Cursor rules
|
|
165
|
+
- `docs/practices-and-standards/packs/<pack-id>/.cursor/skills/` — Cursor skills
|
|
166
|
+
- `docs/practices-and-standards/packs/<pack-id>/CLAUDE.md` — Claude instructions
|
|
167
|
+
- `docs/practices-and-standards/packs/<pack-id>/CONSOLIDATED-STANDARDS.md` — Human-readable standards
|
|
168
|
+
|
|
169
|
+
### `ctx validate`
|
|
170
|
+
|
|
171
|
+
Validate your `context.yaml` configuration and installed packs.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
ctx validate
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Checks:**
|
|
178
|
+
- Schema version compatibility
|
|
179
|
+
- Installed pack manifests exist
|
|
180
|
+
- Precedence list references valid packs
|
|
181
|
+
- Pack file structure integrity
|
|
182
|
+
|
|
183
|
+
**Options:**
|
|
184
|
+
- `--context-yaml <path>` — Path to `context.yaml` file (default: auto-detect)
|
|
185
|
+
|
|
186
|
+
### `ctx version`
|
|
187
|
+
|
|
188
|
+
Show the CLI version.
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
ctx version
|
|
192
|
+
# or
|
|
193
|
+
ctx -v
|
|
194
|
+
# or
|
|
195
|
+
ctx --version
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## How It Works
|
|
199
|
+
|
|
200
|
+
### Repository Structure
|
|
201
|
+
|
|
202
|
+
After installing a pack, your repository structure looks like:
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
your-repo/
|
|
206
|
+
├── .cursor/
|
|
207
|
+
│ ├── rules/ # Cursor rules (auto-loaded)
|
|
208
|
+
│ │ ├── index.md
|
|
209
|
+
│ │ └── doc-process.md
|
|
210
|
+
│ └── skills/ # Cursor skills (on-demand)
|
|
211
|
+
│ └── Domain Discovery Process/
|
|
212
|
+
│ └── SKILL.md
|
|
213
|
+
├── CLAUDE.md # Claude instructions
|
|
214
|
+
├── docs/
|
|
215
|
+
│ └── practices-and-standards/
|
|
216
|
+
│ ├── context.yaml # Pack registry and configuration
|
|
217
|
+
│ ├── 01-engineering-practices/
|
|
218
|
+
│ │ ├── 00-methodologies/
|
|
219
|
+
│ │ └── 01-documentation-methodology/
|
|
220
|
+
│ └── packs/
|
|
221
|
+
│ └── pack-01-documentation-management/
|
|
222
|
+
│ ├── pack.yaml
|
|
223
|
+
│ └── ...
|
|
224
|
+
└── ...
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Context Configuration
|
|
228
|
+
|
|
229
|
+
The `context.yaml` file tracks installed packs and their precedence:
|
|
230
|
+
|
|
231
|
+
```yaml
|
|
232
|
+
schema: context-install/v1
|
|
233
|
+
registry: https://www.zebralabs.io/api
|
|
234
|
+
|
|
235
|
+
installed_packs:
|
|
236
|
+
- id: pack-01-documentation-management
|
|
237
|
+
version: 0.4.0
|
|
238
|
+
manifest: docs/practices-and-standards/packs/pack-01-documentation-management/pack.yaml
|
|
239
|
+
|
|
240
|
+
precedence:
|
|
241
|
+
- pack-01-documentation-management
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Precedence:** When multiple packs define conflicting rules, packs listed earlier in `precedence` take priority.
|
|
245
|
+
|
|
246
|
+
### Integration with AI Tools
|
|
247
|
+
|
|
248
|
+
**Cursor:**
|
|
249
|
+
- Rules in `.cursor/rules/` are automatically loaded — AI follows them in every conversation
|
|
250
|
+
- Skills in `.cursor/skills/` are available on-demand — invoke by name when needed
|
|
251
|
+
- Methodology files in `docs/practices-and-standards/` are indexed automatically
|
|
252
|
+
|
|
253
|
+
**Claude:**
|
|
254
|
+
- `CLAUDE.md` provides consolidated standards at repository root
|
|
255
|
+
- Methodology files can be referenced in conversations
|
|
256
|
+
- Standards are version-controlled with your code
|
|
257
|
+
|
|
258
|
+
## Examples & Workflows
|
|
259
|
+
|
|
260
|
+
### Workflow 1: First-Time Installation
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# 1. Install CLI
|
|
264
|
+
npm install -g @zebralabs/context-cli
|
|
265
|
+
|
|
266
|
+
# 2. Install pack (after purchase)
|
|
267
|
+
ctx pack install pack-01-documentation-management \
|
|
268
|
+
--registry https://www.zebralabs.io/api \
|
|
269
|
+
--token YOUR_TOKEN
|
|
270
|
+
|
|
271
|
+
# 3. Verify
|
|
272
|
+
ctx list
|
|
273
|
+
|
|
274
|
+
# 4. Start using with Cursor/Claude
|
|
275
|
+
# AI now automatically follows your standards
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Workflow 2: Updating a Pack
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
# Install newer version
|
|
282
|
+
ctx pack install pack-01-documentation-management \
|
|
283
|
+
--registry https://www.zebralabs.io/api \
|
|
284
|
+
--token YOUR_TOKEN \
|
|
285
|
+
--version 0.5.0 \
|
|
286
|
+
--mode Overwrite
|
|
287
|
+
|
|
288
|
+
# Recompile to regenerate assets
|
|
289
|
+
ctx compile --pack pack-01-documentation-management
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Workflow 3: Local Development
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Install from local ZIP (for pack development/testing)
|
|
296
|
+
ctx pack install pack-01-documentation-management \
|
|
297
|
+
--zip ./my-pack-v0.1.0.zip \
|
|
298
|
+
--mode Overwrite
|
|
299
|
+
|
|
300
|
+
# Compile to test asset generation
|
|
301
|
+
ctx compile --pack pack-01-documentation-management
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Workflow 4: Multiple Packs
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# Install first pack
|
|
308
|
+
ctx pack install pack-01-documentation-management \
|
|
309
|
+
--registry https://www.zebralabs.io/api \
|
|
310
|
+
--token YOUR_TOKEN
|
|
311
|
+
|
|
312
|
+
# Install second pack (when available)
|
|
313
|
+
ctx pack install pack-02-pr-review \
|
|
314
|
+
--registry https://www.zebralabs.io/api \
|
|
315
|
+
--token YOUR_TOKEN
|
|
316
|
+
|
|
317
|
+
# Set precedence (edit context.yaml manually or via future command)
|
|
318
|
+
# Then compile all packs
|
|
319
|
+
ctx compile
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Troubleshooting
|
|
323
|
+
|
|
324
|
+
### "Could not find context.yaml"
|
|
325
|
+
|
|
326
|
+
**Problem:** CLI can't locate `context.yaml` in your repository.
|
|
327
|
+
|
|
328
|
+
**Solutions:**
|
|
329
|
+
- Ensure you're running commands from your repository root
|
|
330
|
+
- Use `--context-yaml <path>` to specify the path explicitly
|
|
331
|
+
- Check that `context.yaml` exists in `docs/practices-and-standards/` or `practices-and-standards/`
|
|
332
|
+
|
|
333
|
+
### "Pack manifest not found"
|
|
334
|
+
|
|
335
|
+
**Problem:** Installed pack's `pack.yaml` file is missing.
|
|
336
|
+
|
|
337
|
+
**Solutions:**
|
|
338
|
+
- Reinstall the pack: `ctx pack install <pack-id> --mode Overwrite`
|
|
339
|
+
- Check that the pack directory exists in `docs/practices-and-standards/packs/`
|
|
340
|
+
|
|
341
|
+
### "Missing required --token for registry install"
|
|
342
|
+
|
|
343
|
+
**Problem:** Registry installation requires authentication token.
|
|
344
|
+
|
|
345
|
+
**Solutions:**
|
|
346
|
+
- Ensure you have a valid token from your pack purchase
|
|
347
|
+
- Use `--token YOUR_TOKEN` flag
|
|
348
|
+
- For local testing, use `--zip <path>` instead
|
|
349
|
+
|
|
350
|
+
### Installation Files Skipped
|
|
351
|
+
|
|
352
|
+
**Problem:** Files weren't copied during installation.
|
|
353
|
+
|
|
354
|
+
**Solutions:**
|
|
355
|
+
- Check installation mode: `--mode SkipExisting` skips existing files
|
|
356
|
+
- Use `--mode Overwrite` to replace existing files
|
|
357
|
+
- Check merge report in `docs/practices-and-standards/.install/`
|
|
358
|
+
|
|
359
|
+
### Compilation Errors
|
|
360
|
+
|
|
361
|
+
**Problem:** `ctx compile` fails with module errors.
|
|
362
|
+
|
|
363
|
+
**Solutions:**
|
|
364
|
+
- Ensure you're running from the repository root
|
|
365
|
+
- Check Node.js version (requires Node.js 18+)
|
|
366
|
+
- Verify all pack files are intact: `ctx validate`
|
|
367
|
+
- Try compiling a specific pack: `ctx compile --pack <pack-id>`
|
|
368
|
+
|
|
369
|
+
## Advanced Usage
|
|
370
|
+
|
|
371
|
+
### Custom Pack Development
|
|
372
|
+
|
|
373
|
+
To develop your own packs:
|
|
374
|
+
|
|
375
|
+
1. Create pack structure following the standard format
|
|
376
|
+
2. Include `pack.yaml` manifest with `contributes.roots`
|
|
377
|
+
3. Include `install.ps1` installer script
|
|
378
|
+
4. Test installation: `ctx pack install <pack-id> --zip <path>`
|
|
379
|
+
5. Test compilation: `ctx compile --pack <pack-id>`
|
|
380
|
+
|
|
381
|
+
### Precedence Configuration
|
|
382
|
+
|
|
383
|
+
Edit `docs/practices-and-standards/context.yaml` to set pack precedence:
|
|
384
|
+
|
|
385
|
+
```yaml
|
|
386
|
+
precedence:
|
|
387
|
+
- pack-01-documentation-management # Highest priority
|
|
388
|
+
- pack-02-pr-review # Lower priority
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Packs listed earlier take precedence when rules conflict.
|
|
392
|
+
|
|
393
|
+
### Custom Registry
|
|
394
|
+
|
|
395
|
+
Use a custom registry for private or internal packs:
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
ctx pack install my-pack \
|
|
399
|
+
--registry https://my-company.com/api \
|
|
400
|
+
--token INTERNAL_TOKEN
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
Or set default registry in `context.yaml`:
|
|
404
|
+
```yaml
|
|
405
|
+
registry: https://my-company.com/api
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## What's to Come
|
|
409
|
+
|
|
410
|
+
We're actively developing new features to make Context CLI even more powerful. Here's what's coming:
|
|
411
|
+
|
|
412
|
+
### Enhanced Compilation Engine
|
|
413
|
+
|
|
414
|
+
- **Rule Extraction** — Automatic extraction of structured rules from markdown documents using `@context.rules` markers
|
|
415
|
+
- **Conflict Detection** — Intelligent detection of conflicting rules across multiple packs
|
|
416
|
+
- **Semantic Conflict Resolution** — Beyond ID-based conflicts, detect when rules semantically conflict
|
|
417
|
+
- **Custom Documentation Support** — Include your own custom standards alongside installed packs
|
|
418
|
+
- **Change Tracking** — Only recompile what's changed since last compilation
|
|
419
|
+
|
|
420
|
+
### Multi-Pack Improvements
|
|
421
|
+
|
|
422
|
+
- **Interactive Conflict Resolution** — Guided workflow for resolving conflicts between packs
|
|
423
|
+
- **Granular Precedence** — Set precedence at rule level, not just pack level
|
|
424
|
+
- **Conflict Reports** — Detailed reports showing all conflicts and resolutions
|
|
425
|
+
- **Pack Dependencies** — Declare dependencies between packs
|
|
426
|
+
|
|
427
|
+
### Developer Experience
|
|
428
|
+
|
|
429
|
+
- **Precedence Management** — CLI commands to manage pack precedence without editing YAML
|
|
430
|
+
- **Pack Updates** — `ctx pack update` command to update all packs to latest versions
|
|
431
|
+
- **Pack Removal** — `ctx pack uninstall` to cleanly remove packs
|
|
432
|
+
- **Better Error Messages** — More helpful error messages with suggested fixes
|
|
433
|
+
- **Progress Indicators** — Visual feedback during long operations
|
|
434
|
+
|
|
435
|
+
### Integration Enhancements
|
|
436
|
+
|
|
437
|
+
- **GitHub Copilot Support** — Generate `.github/copilot-instructions.md` from compiled standards
|
|
438
|
+
- **VS Code Integration** — VS Code extension for managing packs and standards
|
|
439
|
+
- **CI/CD Integration** — Validate standards in CI pipelines
|
|
440
|
+
- **Diff Viewing** — See what changed when updating packs
|
|
441
|
+
|
|
442
|
+
### Performance & Reliability
|
|
443
|
+
|
|
444
|
+
- **Incremental Compilation** — Faster compilations by only processing changed files
|
|
445
|
+
- **Parallel Processing** — Process multiple packs in parallel
|
|
446
|
+
- **Caching** — Cache compilation results for faster subsequent runs
|
|
447
|
+
- **Validation Improvements** — More comprehensive validation with better error reporting
|
|
448
|
+
|
|
449
|
+
### Documentation & Learning
|
|
450
|
+
|
|
451
|
+
- **Interactive Tutorial** — Guided walkthrough for first-time users
|
|
452
|
+
- **Pack Marketplace** — Browse and discover packs from the CLI
|
|
453
|
+
- **Examples Library** — Curated examples of custom packs and configurations
|
|
454
|
+
|
|
455
|
+
---
|
|
456
|
+
|
|
457
|
+
**Have ideas or feedback?** We'd love to hear from you! Visit [zebralabs.io/context-packs](https://www.zebralabs.io/context-packs) to share your thoughts.
|
|
458
|
+
|
|
459
|
+
## Links & Resources
|
|
460
|
+
|
|
461
|
+
- **Product Website:** [zebralabs.io/context-packs](https://www.zebralabs.io/context-packs)
|
|
462
|
+
- **Available Packs:** Browse packs and purchase at [zebralabs.io/context-packs](https://www.zebralabs.io/context-packs)
|
|
463
|
+
- **Support:** Contact support through the website
|
|
464
|
+
|
|
465
|
+
## License
|
|
466
|
+
|
|
467
|
+
MIT License — see [LICENSE](LICENSE) file for details.
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
**Ready to get started?** Install the CLI and visit [zebralabs.io/context-packs](https://www.zebralabs.io/context-packs) to browse available packs.
|
|
472
|
+
|
package/package.json
CHANGED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Stage1Discovery } from "./stage1-discovery.js";
|
|
2
|
+
import { Stage2Extraction } from "./stage2-extraction.js";
|
|
3
|
+
import { Stage4Consolidation } from "./stage4-consolidation.js";
|
|
4
|
+
import { Stage5Assets } from "./stage5-assets.js";
|
|
5
|
+
import { Stage6Validation } from "./stage6-validation.js";
|
|
6
|
+
import YAML from "yaml";
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Main compilation orchestrator
|
|
12
|
+
* Coordinates all compilation stages
|
|
13
|
+
*/
|
|
14
|
+
export class CompileContext {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.stage1 = new Stage1Discovery();
|
|
17
|
+
this.stage2 = new Stage2Extraction();
|
|
18
|
+
this.stage4 = new Stage4Consolidation();
|
|
19
|
+
this.stage5 = new Stage5Assets();
|
|
20
|
+
this.stage6 = new Stage6Validation();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Compile context for a specific pack
|
|
25
|
+
* @param {string} repoRoot - Repository root
|
|
26
|
+
* @param {string} packId - Pack ID to compile
|
|
27
|
+
* @param {string} outputPath - Output path (defaults to pack directory)
|
|
28
|
+
* @returns {Object} Compilation result
|
|
29
|
+
*/
|
|
30
|
+
async compilePack(repoRoot, packId, outputPath = null) {
|
|
31
|
+
// Try both locations for context.yaml
|
|
32
|
+
const installedPath = path.join(repoRoot, "docs", "practices-and-standards", "context.yaml");
|
|
33
|
+
const sourcePath = path.join(repoRoot, "practices-and-standards", "context.yaml");
|
|
34
|
+
|
|
35
|
+
let contextPath;
|
|
36
|
+
if (fs.existsSync(installedPath)) {
|
|
37
|
+
contextPath = installedPath;
|
|
38
|
+
} else if (fs.existsSync(sourcePath)) {
|
|
39
|
+
contextPath = sourcePath;
|
|
40
|
+
} else {
|
|
41
|
+
throw new Error(`context.yaml not found. Checked:\n - ${installedPath}\n - ${sourcePath}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const contextYaml = YAML.parse(fs.readFileSync(contextPath, "utf8"));
|
|
45
|
+
|
|
46
|
+
// Find the pack in installed packs
|
|
47
|
+
const pack = (contextYaml.installed_packs || []).find(p => p.id === packId);
|
|
48
|
+
if (!pack) {
|
|
49
|
+
throw new Error(`Pack ${packId} not found in context.yaml`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Determine output path
|
|
53
|
+
if (!outputPath) {
|
|
54
|
+
// Output to pack directory
|
|
55
|
+
const packDir = path.dirname(path.join(repoRoot, pack.manifest));
|
|
56
|
+
outputPath = packDir;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const stageReports = {};
|
|
60
|
+
|
|
61
|
+
// Stage 1: Discovery
|
|
62
|
+
console.log("Stage 1: Discovery & Collection...");
|
|
63
|
+
const discovery = this.stage1.execute(repoRoot, contextYaml);
|
|
64
|
+
|
|
65
|
+
// Filter to only files from the specified pack
|
|
66
|
+
const packSourceFiles = discovery.sourceFiles.filter(f => f.packId === packId);
|
|
67
|
+
|
|
68
|
+
console.log(` Found ${packSourceFiles.length} source files`);
|
|
69
|
+
stageReports.stage1 = discovery;
|
|
70
|
+
|
|
71
|
+
// Stage 2: Extraction
|
|
72
|
+
console.log("Stage 2: Rule Extraction & Parsing...");
|
|
73
|
+
const extraction = this.stage2.execute(packSourceFiles);
|
|
74
|
+
|
|
75
|
+
console.log(` Extracted ${extraction.report.rulesExtracted} rules`);
|
|
76
|
+
console.log(` Extracted ${extraction.report.preferencesExtracted} preferences`);
|
|
77
|
+
console.log(` Extracted ${extraction.report.scopesExtracted} scopes`);
|
|
78
|
+
|
|
79
|
+
if (extraction.report.errors.length > 0) {
|
|
80
|
+
console.warn(` Errors: ${extraction.report.errors.length}`);
|
|
81
|
+
extraction.report.errors.forEach(e => {
|
|
82
|
+
console.warn(` - ${e.file}: ${e.error}`);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
stageReports.stage2 = extraction.report;
|
|
86
|
+
|
|
87
|
+
// Stage 4: Consolidation
|
|
88
|
+
console.log("Stage 4: Consolidation & Standard Generation...");
|
|
89
|
+
const consolidation = this.stage4.execute(extraction.compilation, outputPath);
|
|
90
|
+
console.log(` Generated ${consolidation.filesGenerated.length} consolidated files`);
|
|
91
|
+
|
|
92
|
+
// Stage 5: Asset Generation
|
|
93
|
+
console.log("Stage 5: Integration Asset Generation...");
|
|
94
|
+
const assets = await this.stage5.execute(extraction.compilation, packSourceFiles, outputPath);
|
|
95
|
+
console.log(` Generated Cursor rules: ${assets.results.cursorRules.filesGenerated.length} files`);
|
|
96
|
+
if (assets.skillsExtracted > 0) {
|
|
97
|
+
console.log(` Generated Cursor skills: ${assets.results.cursorSkills.filesGenerated.length} files`);
|
|
98
|
+
}
|
|
99
|
+
console.log(` Generated Claude.md`);
|
|
100
|
+
|
|
101
|
+
// Stage 6: Validation & Reporting
|
|
102
|
+
console.log("Stage 6: Validation & Reporting...");
|
|
103
|
+
const validation = this.stage6.execute(extraction.compilation, stageReports, outputPath);
|
|
104
|
+
console.log(` Validation: ${validation.validation.rulesValid ? "✅ Passed" : "❌ Failed"}`);
|
|
105
|
+
console.log(` Generated ${validation.reportsGenerated.length} reports`);
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
compilation: extraction.compilation,
|
|
109
|
+
outputPath,
|
|
110
|
+
stageReports: {
|
|
111
|
+
...stageReports,
|
|
112
|
+
stage4: consolidation,
|
|
113
|
+
stage5: assets,
|
|
114
|
+
stage6: validation
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|