@zebralabs/context-cli 0.1.4 → 0.1.6

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 (3) hide show
  1. package/README.md +472 -0
  2. package/package.json +1 -1
  3. package/src/context.js +29 -1
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
+ [![npm version](https://img.shields.io/npm/v/@zebralabs/context-cli.svg)](https://www.npmjs.com/package/@zebralabs/context-cli)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zebralabs/context-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Context-as-Code CLI (help/list/compile/validate)",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/context.js CHANGED
@@ -520,6 +520,31 @@ function ensureDir(p) {
520
520
  fs.mkdirSync(p, { recursive: true });
521
521
  }
522
522
 
523
+ /**
524
+ * After pack install: ensure docs/local/ exists and .gitignore has /docs/local/
525
+ * (create .gitignore if missing; append entry if present but pattern not found).
526
+ */
527
+ function ensureDocsLocalAndGitignore(repoRoot) {
528
+ const docsLocalDir = path.join(repoRoot, "docs", "local");
529
+ ensureDir(docsLocalDir);
530
+
531
+ const gitignorePath = path.join(repoRoot, ".gitignore");
532
+ const entry = "\n# Local-only documentation (excluded from AI context and version control)\n/docs/local/\n";
533
+ const pattern = "/docs/local/";
534
+
535
+ if (!fs.existsSync(gitignorePath)) {
536
+ fs.writeFileSync(gitignorePath, entry.trimStart(), "utf8");
537
+ return;
538
+ }
539
+
540
+ const content = fs.readFileSync(gitignorePath, "utf8");
541
+ if (content.includes(pattern) || content.includes("docs/local/")) return;
542
+
543
+ const trimmed = content.trimEnd();
544
+ const suffix = trimmed.endsWith("\n") ? entry : "\n" + entry;
545
+ fs.writeFileSync(gitignorePath, trimmed + suffix, "utf8");
546
+ }
547
+
523
548
  function writeYamlFile(filePath, obj) {
524
549
  const text = YAML.stringify(obj, { indent: 2 });
525
550
  fs.writeFileSync(filePath, text.endsWith("\n") ? text : (text + "\n"), "utf8");
@@ -717,6 +742,9 @@ async function cmdPackInstall(repoRoot, packId, opts) {
717
742
  const installCmd = `& "${installer}" -TargetRoot "${repoRoot}" -PackId "${packId}" -Mode "${mode}"`;
718
743
  runPwsh(installCmd, { cwd: extractDir });
719
744
 
745
+ // Ensure docs/local/ exists and .gitignore has /docs/local/
746
+ ensureDocsLocalAndGitignore(repoRoot);
747
+
720
748
  // Update context.yaml (safe read + repair)
721
749
  let ctx2 = readYamlFileSafe(ctxPath);
722
750
  if (!ctx2) {
@@ -772,7 +800,7 @@ async function main() {
772
800
 
773
801
  if (cmd === "--version" || cmd === "-v" || cmd === "version") {
774
802
  // Make sure package.json has version (or hardcode a constant)
775
- console.log("0.1.4");
803
+ console.log("0.1.6");
776
804
  return;
777
805
  }
778
806