@voodocs/cli 0.1.2 → 0.3.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.
@@ -0,0 +1,619 @@
1
+ """
2
+ AI-specific integration templates for VooDocs Context System.
3
+
4
+ This module provides native integration with different AI assistants:
5
+ - Claude Code (skills)
6
+ - Cursor (rules)
7
+ - GitHub Copilot (instructions)
8
+ - Windsurf (rules)
9
+ - Cline (rules)
10
+ - And more...
11
+ """
12
+
13
+ from typing import Dict, List, Optional
14
+ from pathlib import Path
15
+
16
+
17
+ def generate_claude_skill(project_name: str, project_purpose: str) -> Dict[str, str]:
18
+ """
19
+ Generate Claude Code skill for VooDocs context system.
20
+
21
+ Args:
22
+ project_name: Name of the project
23
+ project_purpose: Brief purpose of the project
24
+
25
+ Returns:
26
+ Dictionary mapping file paths to content
27
+ """
28
+ skill_md = f"""---
29
+ name: voodocs-context
30
+ description: Access and query the VooDocs context system for project understanding, invariants, and architecture
31
+ ---
32
+
33
+ # VooDocs Context System Skill
34
+
35
+ ## Project: {project_name}
36
+ {project_purpose}
37
+
38
+ This skill provides access to the VooDocs context system for understanding project architecture, invariants, and assumptions.
39
+
40
+ ## Available Commands
41
+
42
+ ### View Full Context
43
+ ```bash
44
+ voodocs context view
45
+ ```
46
+
47
+ ### Query Context
48
+ ```bash
49
+ voodocs context query "search term" --section invariants
50
+ voodocs context query "auth" --format json
51
+ ```
52
+
53
+ ### Check Invariants
54
+ ```bash
55
+ voodocs context check
56
+ voodocs context check --invariant "password"
57
+ ```
58
+
59
+ ### Generate Diagrams
60
+ ```bash
61
+ voodocs context diagram --type modules
62
+ voodocs context diagram --type all --output docs/arch
63
+ ```
64
+
65
+ ### Update Context
66
+ ```bash
67
+ voodocs context generate --update
68
+ voodocs context update --description "what changed"
69
+ ```
70
+
71
+ ## When to Use This Skill
72
+
73
+ Use this skill when:
74
+ - User asks about project architecture or structure
75
+ - User asks about security requirements or invariants
76
+ - User asks about system assumptions
77
+ - User wants to understand dependencies
78
+ - User wants to see architecture diagrams
79
+ - Before making significant code changes
80
+ - When documenting new features
81
+
82
+ ## Workflow
83
+
84
+ 1. **Before Changes**: Always check context first
85
+ ```bash
86
+ voodocs context view
87
+ ```
88
+
89
+ 2. **During Development**: Update context from code
90
+ ```bash
91
+ voodocs context generate --update
92
+ ```
93
+
94
+ 3. **Before Commit**: Validate invariants
95
+ ```bash
96
+ voodocs context check
97
+ ```
98
+
99
+ ## Context File
100
+
101
+ The context is stored in `.voodocs.context` (YAML format) with:
102
+ - **Invariants**: Rules that must always hold
103
+ - **Assumptions**: System-wide assumptions
104
+ - **Architecture**: Modules and dependencies
105
+ - **Critical Paths**: Important workflows
106
+ - **Known Issues**: Bugs and limitations
107
+
108
+ ## Examples
109
+
110
+ **Q: "What are the security requirements?"**
111
+ ```bash
112
+ voodocs context query "security" --section invariants
113
+ ```
114
+
115
+ **Q: "Show me the architecture"**
116
+ ```bash
117
+ voodocs context diagram --type modules
118
+ ```
119
+
120
+ **Q: "Are there any invariant violations?"**
121
+ ```bash
122
+ voodocs context check
123
+ ```
124
+
125
+ ## Important
126
+
127
+ - Context is the source of truth for project understanding
128
+ - Always respect documented invariants
129
+ - Update context when adding features
130
+ - Check context before architectural decisions
131
+ """
132
+
133
+ return {
134
+ ".claude/skills/voodocs-context/SKILL.md": skill_md
135
+ }
136
+
137
+
138
+ def generate_cursor_rules(project_name: str, project_purpose: str) -> Dict[str, str]:
139
+ """
140
+ Generate Cursor rules for VooDocs context system.
141
+
142
+ Args:
143
+ project_name: Name of the project
144
+ project_purpose: Brief purpose of the project
145
+
146
+ Returns:
147
+ Dictionary mapping file paths to content
148
+ """
149
+
150
+ main_rule = f"""# VooDocs Context System
151
+
152
+ ## Project: {project_name}
153
+ {project_purpose}
154
+
155
+ This project uses the VooDocs Context System (v0.2.0+) for documentation and validation.
156
+
157
+ ## Context File
158
+ - **Location**: `.voodocs.context`
159
+ - **Format**: YAML
160
+ - **Purpose**: Single source of truth for project understanding
161
+
162
+ ## Before Starting Work
163
+
164
+ Always check the context first:
165
+
166
+ ```bash
167
+ voodocs context view
168
+ ```
169
+
170
+ This shows:
171
+ - Global invariants (rules that must hold)
172
+ - System assumptions
173
+ - Architecture and modules
174
+ - Dependencies
175
+ - Known issues
176
+
177
+ ## Essential Commands
178
+
179
+ ### Read Context
180
+ ```bash
181
+ voodocs context view # View as Markdown
182
+ voodocs context query "term" # Search context
183
+ voodocs context query "security" --section invariants
184
+ ```
185
+
186
+ ### Validate Code
187
+ ```bash
188
+ voodocs context check # Check invariants
189
+ voodocs context validate --check-invariants
190
+ ```
191
+
192
+ ### Update Context
193
+ ```bash
194
+ voodocs context generate --update # Auto-generate from code
195
+ voodocs context update --description "what changed"
196
+ ```
197
+
198
+ ### Visualize
199
+ ```bash
200
+ voodocs context diagram --type modules # Architecture diagram
201
+ voodocs context diagram --type all --output docs/arch
202
+ ```
203
+
204
+ ## @voodocs Annotations
205
+
206
+ Document your code with @voodocs annotations:
207
+
208
+ **Python:**
209
+ ```python
210
+ \"\"\"@voodocs
211
+ module_purpose: "What this module does"
212
+ dependencies: ["other-module", "external-lib"]
213
+ assumptions: ["Database is initialized"]
214
+ invariants: ["All inputs must be validated"]
215
+ \"\"\"
216
+ ```
217
+
218
+ **TypeScript:**
219
+ ```typescript
220
+ /**@voodocs
221
+ module_purpose: "What this module does"
222
+ dependencies: ["react", "axios"]
223
+ assumptions: ["API endpoint is available"]
224
+ invariants: ["All responses must be validated"]
225
+ */
226
+ ```
227
+
228
+ ## Workflow
229
+
230
+ 1. **Before Changes**: `voodocs context view`
231
+ 2. **During Development**: Add @voodocs annotations
232
+ 3. **After Changes**: `voodocs context generate --update`
233
+ 4. **Before Commit**: `voodocs context check`
234
+ 5. **Update Version**: `voodocs context update --description "..."`
235
+
236
+ ## Invariants
237
+
238
+ The context contains global invariants that must ALWAYS hold:
239
+ - Check them: `voodocs context query "." --section invariants`
240
+ - Validate code: `voodocs context check`
241
+ - Never violate documented invariants
242
+
243
+ ## Architecture
244
+
245
+ View module structure:
246
+ ```bash
247
+ voodocs context diagram --type modules
248
+ ```
249
+
250
+ Query architecture:
251
+ ```bash
252
+ voodocs context query "module-name" --section architecture
253
+ ```
254
+
255
+ ## Remember
256
+
257
+ - Context is your source of truth
258
+ - Always check context before making changes
259
+ - Respect all documented invariants
260
+ - Update context when adding features
261
+ - Validate before committing
262
+ """
263
+
264
+ return {
265
+ ".cursor/rules/voodocs-context.mdc": main_rule
266
+ }
267
+
268
+
269
+ def generate_copilot_instructions(project_name: str, project_purpose: str) -> Dict[str, str]:
270
+ """
271
+ Generate GitHub Copilot instructions for VooDocs context system.
272
+
273
+ Args:
274
+ project_name: Name of the project
275
+ project_purpose: Brief purpose of the project
276
+
277
+ Returns:
278
+ Dictionary mapping file paths to content
279
+ """
280
+
281
+ instructions = f"""# GitHub Copilot Instructions - {project_name}
282
+
283
+ ## Project Overview
284
+ {project_purpose}
285
+
286
+ ## VooDocs Context System
287
+
288
+ This project uses VooDocs Context System (v0.2.0+) for documentation and validation.
289
+
290
+ ### Context File
291
+ - **Location**: `.voodocs.context` (YAML format)
292
+ - **Purpose**: Single source of truth for project understanding
293
+ - **Contains**: Invariants, assumptions, architecture, dependencies
294
+
295
+ ### Before Coding
296
+
297
+ Always check the context:
298
+ ```bash
299
+ voodocs context view
300
+ ```
301
+
302
+ ### Key Commands
303
+
304
+ ```bash
305
+ # View context
306
+ voodocs context view
307
+
308
+ # Search context
309
+ voodocs context query "search term"
310
+
311
+ # Check invariants
312
+ voodocs context check
313
+
314
+ # Generate diagrams
315
+ voodocs context diagram --type modules
316
+
317
+ # Update context
318
+ voodocs context generate --update
319
+ ```
320
+
321
+ ### @voodocs Annotations
322
+
323
+ Document code with @voodocs annotations:
324
+
325
+ **Python:**
326
+ ```python
327
+ \"\"\"@voodocs
328
+ module_purpose: "Brief description"
329
+ dependencies: ["list", "of", "deps"]
330
+ assumptions: ["What must be true"]
331
+ invariants: ["Rules that must hold"]
332
+ \"\"\"
333
+ ```
334
+
335
+ **TypeScript:**
336
+ ```typescript
337
+ /**@voodocs
338
+ module_purpose: "Brief description"
339
+ dependencies: ["react", "axios"]
340
+ assumptions: ["API is available"]
341
+ invariants: ["Responses validated"]
342
+ */
343
+ ```
344
+
345
+ ### Invariants (Must Always Hold)
346
+
347
+ Check invariants before suggesting code:
348
+ ```bash
349
+ voodocs context query "." --section invariants
350
+ ```
351
+
352
+ Common invariants:
353
+ - All passwords must be hashed
354
+ - API keys must never be logged
355
+ - All database queries must use parameterized statements
356
+ - User input must be validated
357
+
358
+ ### Workflow
359
+
360
+ 1. Check context: `voodocs context view`
361
+ 2. Add @voodocs annotations to new code
362
+ 3. Update context: `voodocs context generate --update`
363
+ 4. Validate: `voodocs context check`
364
+ 5. Update version: `voodocs context update`
365
+
366
+ ### Architecture
367
+
368
+ View module structure:
369
+ ```bash
370
+ voodocs context diagram --type modules
371
+ ```
372
+
373
+ ### Remember
374
+
375
+ - Context is the source of truth
376
+ - Respect all documented invariants
377
+ - Update context when adding features
378
+ - Validate before committing
379
+ """
380
+
381
+ return {
382
+ ".github/copilot-instructions.md": instructions
383
+ }
384
+
385
+
386
+ def generate_windsurf_rules(project_name: str, project_purpose: str) -> Dict[str, str]:
387
+ """
388
+ Generate Windsurf rules for VooDocs context system.
389
+
390
+ Args:
391
+ project_name: Name of the project
392
+ project_purpose: Brief purpose of the project
393
+
394
+ Returns:
395
+ Dictionary mapping file paths to content
396
+ """
397
+
398
+ rules = f"""# Windsurf Rules - {project_name}
399
+
400
+ ## Project
401
+ {project_purpose}
402
+
403
+ ## VooDocs Context System
404
+
405
+ This project uses VooDocs (v0.2.0+) for context management.
406
+
407
+ ### Context Commands
408
+
409
+ ```bash
410
+ voodocs context view # View full context
411
+ voodocs context query "term" # Search context
412
+ voodocs context check # Validate invariants
413
+ voodocs context diagram --type modules # Architecture
414
+ voodocs context generate --update # Update from code
415
+ ```
416
+
417
+ ### Before Coding
418
+
419
+ Check context first:
420
+ ```bash
421
+ voodocs context view
422
+ ```
423
+
424
+ ### Invariants
425
+
426
+ Rules that must ALWAYS hold. Check them:
427
+ ```bash
428
+ voodocs context query "." --section invariants
429
+ voodocs context check
430
+ ```
431
+
432
+ ### @voodocs Annotations
433
+
434
+ ```python
435
+ \"\"\"@voodocs
436
+ module_purpose: "What this does"
437
+ dependencies: ["deps"]
438
+ assumptions: ["assumptions"]
439
+ invariants: ["rules"]
440
+ \"\"\"
441
+ ```
442
+
443
+ ### Workflow
444
+
445
+ 1. Check: `voodocs context view`
446
+ 2. Code with @voodocs annotations
447
+ 3. Update: `voodocs context generate --update`
448
+ 4. Validate: `voodocs context check`
449
+ 5. Commit: `voodocs context update`
450
+
451
+ ### Remember
452
+
453
+ - Context = source of truth
454
+ - Respect invariants
455
+ - Update context with features
456
+ - Validate before commit
457
+ """
458
+
459
+ return {
460
+ ".windsurfrules": rules
461
+ }
462
+
463
+
464
+ def generate_cline_rules(project_name: str, project_purpose: str) -> Dict[str, str]:
465
+ """
466
+ Generate Cline rules for VooDocs context system.
467
+
468
+ Args:
469
+ project_name: Name of the project
470
+ project_purpose: Brief purpose of the project
471
+
472
+ Returns:
473
+ Dictionary mapping file paths to content
474
+ """
475
+
476
+ rules = f"""# Cline Rules - {project_name}
477
+
478
+ ## Project
479
+ {project_purpose}
480
+
481
+ ## VooDocs Context System
482
+
483
+ Context file: `.voodocs.context` (YAML)
484
+
485
+ ### Commands
486
+
487
+ ```bash
488
+ voodocs context view # View context
489
+ voodocs context query "term" # Search
490
+ voodocs context check # Validate
491
+ voodocs context generate --update # Update
492
+ ```
493
+
494
+ ### Before Coding
495
+
496
+ ```bash
497
+ voodocs context view
498
+ ```
499
+
500
+ ### Invariants
501
+
502
+ Check before coding:
503
+ ```bash
504
+ voodocs context check
505
+ ```
506
+
507
+ ### Annotations
508
+
509
+ ```python
510
+ \"\"\"@voodocs
511
+ module_purpose: "Description"
512
+ dependencies: ["list"]
513
+ assumptions: ["assumptions"]
514
+ invariants: ["rules"]
515
+ \"\"\"
516
+ ```
517
+
518
+ ### Workflow
519
+
520
+ 1. Check context
521
+ 2. Add annotations
522
+ 3. Update context
523
+ 4. Validate
524
+ 5. Commit
525
+
526
+ ### Remember
527
+
528
+ - Context = truth
529
+ - Respect invariants
530
+ - Update with features
531
+ """
532
+
533
+ return {
534
+ ".clinerules": rules
535
+ }
536
+
537
+
538
+ def detect_ai_assistants(project_root: Path) -> List[str]:
539
+ """
540
+ Detect which AI assistants are already configured in the project.
541
+
542
+ Args:
543
+ project_root: Path to project root
544
+
545
+ Returns:
546
+ List of detected AI assistant names
547
+ """
548
+ detected = []
549
+
550
+ checks = {
551
+ "claude": [".claude", ".claude/skills"],
552
+ "cursor": [".cursorrules", ".cursor", ".cursor/rules"],
553
+ "copilot": [".github/copilot-instructions.md"],
554
+ "windsurf": [".windsurfrules"],
555
+ "cline": [".clinerules"],
556
+ "gemini": [".gemini"],
557
+ "junie": [".junie"],
558
+ }
559
+
560
+ for ai_name, paths in checks.items():
561
+ for path in paths:
562
+ if (project_root / path).exists():
563
+ detected.append(ai_name)
564
+ break
565
+
566
+ return detected
567
+
568
+
569
+ def generate_ai_integration(
570
+ project_name: str,
571
+ project_purpose: str,
572
+ ai_type: str
573
+ ) -> Dict[str, str]:
574
+ """
575
+ Generate AI-specific integration files.
576
+
577
+ Args:
578
+ project_name: Name of the project
579
+ project_purpose: Brief purpose of the project
580
+ ai_type: AI assistant type (claude, cursor, copilot, windsurf, cline, all)
581
+
582
+ Returns:
583
+ Dictionary mapping file paths to content
584
+ """
585
+ integrations = {}
586
+
587
+ generators = {
588
+ "claude": generate_claude_skill,
589
+ "cursor": generate_cursor_rules,
590
+ "copilot": generate_copilot_instructions,
591
+ "windsurf": generate_windsurf_rules,
592
+ "cline": generate_cline_rules,
593
+ }
594
+
595
+ if ai_type == "all":
596
+ for generator in generators.values():
597
+ integrations.update(generator(project_name, project_purpose))
598
+ elif ai_type in generators:
599
+ integrations.update(generators[ai_type](project_name, project_purpose))
600
+
601
+ return integrations
602
+
603
+
604
+ def get_ai_assistant_choices() -> List[tuple]:
605
+ """
606
+ Get list of AI assistant choices for user prompt.
607
+
608
+ Returns:
609
+ List of (name, description) tuples
610
+ """
611
+ return [
612
+ ("claude", "Claude Code (uses .claude/skills/)"),
613
+ ("cursor", "Cursor (uses .cursor/rules/ or .cursorrules)"),
614
+ ("copilot", "GitHub Copilot (uses .github/copilot-instructions.md)"),
615
+ ("windsurf", "Windsurf (uses .windsurfrules)"),
616
+ ("cline", "Cline/VSCode (uses .clinerules)"),
617
+ ("all", "All of the above"),
618
+ ("none", "Skip AI integration"),
619
+ ]