clavix 4.8.1 → 4.10.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 (25) hide show
  1. package/dist/cli/commands/analyze.d.ts +14 -0
  2. package/dist/cli/commands/analyze.js +127 -0
  3. package/dist/templates/slash-commands/_canonical/archive.md +67 -81
  4. package/dist/templates/slash-commands/_canonical/deep.md +88 -47
  5. package/dist/templates/slash-commands/_canonical/execute.md +200 -155
  6. package/dist/templates/slash-commands/_canonical/fast.md +78 -37
  7. package/dist/templates/slash-commands/_canonical/implement.md +310 -300
  8. package/dist/templates/slash-commands/_canonical/plan.md +33 -17
  9. package/dist/templates/slash-commands/_canonical/prd.md +36 -21
  10. package/dist/templates/slash-commands/_canonical/start.md +34 -33
  11. package/dist/templates/slash-commands/_canonical/summarize.md +39 -47
  12. package/dist/templates/slash-commands/_canonical/verify.md +324 -186
  13. package/dist/templates/slash-commands/_components/agent-protocols/cli-reference.md +214 -0
  14. package/dist/templates/slash-commands/_components/agent-protocols/error-handling.md +145 -88
  15. package/dist/templates/slash-commands/_components/agent-protocols/self-correction.md +20 -1
  16. package/dist/templates/slash-commands/_components/agent-protocols/supportive-companion.md +216 -0
  17. package/dist/templates/slash-commands/_components/agent-protocols/task-blocking.md +224 -0
  18. package/dist/templates/slash-commands/_components/references/quality-dimensions.md +152 -44
  19. package/dist/templates/slash-commands/_components/sections/conversation-examples.md +302 -0
  20. package/dist/templates/slash-commands/_components/sections/escalation-factors.md +119 -87
  21. package/dist/templates/slash-commands/_components/sections/improvement-explanations.md +171 -0
  22. package/dist/templates/slash-commands/_components/sections/pattern-impact.md +208 -0
  23. package/dist/templates/slash-commands/_components/sections/prd-examples.md +289 -0
  24. package/dist/templates/slash-commands/_components/troubleshooting/vibecoder-recovery.md +223 -0
  25. package/package.json +1 -1
@@ -0,0 +1,14 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Analyze extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ pretty: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ };
8
+ static args: {
9
+ prompt: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
10
+ };
11
+ run(): Promise<void>;
12
+ private calculateEscalation;
13
+ }
14
+ //# sourceMappingURL=analyze.d.ts.map
@@ -0,0 +1,127 @@
1
+ import { Command, Args, Flags } from '@oclif/core';
2
+ import { UniversalOptimizer } from '../../core/intelligence/index.js';
3
+ export default class Analyze extends Command {
4
+ static description = 'Analyze a prompt and return structured JSON with intent, quality, and escalation data';
5
+ static examples = [
6
+ '<%= config.bin %> <%= command.id %> "Create a login page"',
7
+ '<%= config.bin %> <%= command.id %> "Build an API for user management" --pretty',
8
+ ];
9
+ static flags = {
10
+ pretty: Flags.boolean({
11
+ char: 'p',
12
+ description: 'Pretty-print the JSON output',
13
+ default: false,
14
+ }),
15
+ };
16
+ static args = {
17
+ prompt: Args.string({
18
+ description: 'The prompt to analyze',
19
+ required: true,
20
+ }),
21
+ };
22
+ async run() {
23
+ const { args, flags } = await this.parse(Analyze);
24
+ if (!args.prompt || args.prompt.trim().length === 0) {
25
+ const errorOutput = {
26
+ error: 'No prompt provided',
27
+ message: 'Please provide a prompt to analyze',
28
+ };
29
+ console.log(JSON.stringify(errorOutput, null, flags.pretty ? 2 : 0));
30
+ this.exit(1);
31
+ return;
32
+ }
33
+ const optimizer = new UniversalOptimizer();
34
+ const result = await optimizer.optimize(args.prompt, 'fast');
35
+ // Calculate escalation score and recommendation
36
+ const escalation = this.calculateEscalation(result);
37
+ // Build the analysis result
38
+ const analysisResult = {
39
+ intent: result.intent.primaryIntent,
40
+ confidence: result.intent.confidence,
41
+ quality: {
42
+ overall: Math.round(result.quality.overall),
43
+ clarity: Math.round(result.quality.clarity),
44
+ efficiency: Math.round(result.quality.efficiency),
45
+ structure: Math.round(result.quality.structure),
46
+ completeness: Math.round(result.quality.completeness),
47
+ actionability: Math.round(result.quality.actionability),
48
+ specificity: Math.round(result.quality.specificity ?? 0),
49
+ },
50
+ escalation,
51
+ characteristics: {
52
+ hasCodeContext: result.intent.characteristics.hasCodeContext,
53
+ hasTechnicalTerms: result.intent.characteristics.hasTechnicalTerms,
54
+ isOpenEnded: result.intent.characteristics.isOpenEnded,
55
+ needsStructure: result.intent.characteristics.needsStructure,
56
+ },
57
+ };
58
+ // Output as JSON
59
+ console.log(JSON.stringify(analysisResult, null, flags.pretty ? 2 : 0));
60
+ }
61
+ calculateEscalation(result) {
62
+ const factors = [];
63
+ let score = 0;
64
+ // Quality-based factors
65
+ if (result.quality.overall < 50) {
66
+ score += 30;
67
+ factors.push('low overall quality');
68
+ }
69
+ else if (result.quality.overall < 65) {
70
+ score += 15;
71
+ factors.push('moderate quality - could be improved');
72
+ }
73
+ if (result.quality.clarity < 50) {
74
+ score += 15;
75
+ factors.push('unclear objective');
76
+ }
77
+ if (result.quality.completeness < 50) {
78
+ score += 20;
79
+ factors.push('missing technical requirements');
80
+ }
81
+ if (result.quality.actionability < 50) {
82
+ score += 15;
83
+ factors.push('vague scope');
84
+ }
85
+ // Intent-based factors
86
+ if (result.intent.primaryIntent === 'planning') {
87
+ score += 15;
88
+ factors.push('planning intent - benefits from exploration');
89
+ }
90
+ if (result.intent.primaryIntent === 'prd-generation') {
91
+ score += 25;
92
+ factors.push('PRD generation - needs strategic planning');
93
+ }
94
+ // Characteristics-based factors
95
+ if (result.intent.characteristics.isOpenEnded && result.intent.characteristics.needsStructure) {
96
+ score += 10;
97
+ factors.push('open-ended without structure');
98
+ }
99
+ // Confidence-based factors
100
+ if (result.intent.confidence < 70) {
101
+ score += 10;
102
+ factors.push('low intent confidence');
103
+ }
104
+ // Determine recommendation based on score and intent
105
+ let recommend = 'fast';
106
+ if (result.intent.primaryIntent === 'prd-generation') {
107
+ recommend = 'prd';
108
+ }
109
+ else if (score >= 60 || result.quality.overall < 50) {
110
+ recommend = 'deep';
111
+ }
112
+ else if (score >= 35) {
113
+ recommend = 'deep';
114
+ }
115
+ // Check for strategic keywords that suggest PRD mode
116
+ const strategicIntents = ['planning', 'prd-generation', 'documentation'];
117
+ if (strategicIntents.includes(result.intent.primaryIntent) && score >= 50) {
118
+ recommend = 'prd';
119
+ }
120
+ return {
121
+ score: Math.min(100, score),
122
+ recommend,
123
+ factors,
124
+ };
125
+ }
126
+ }
127
+ //# sourceMappingURL=analyze.js.map
@@ -3,47 +3,69 @@ name: "Clavix: Archive"
3
3
  description: Archive completed PRD projects
4
4
  ---
5
5
 
6
- # Clavix Archive - PRD Project Archival
6
+ # Clavix: Archive Your Completed Work
7
7
 
8
- > **⚠️ Agent Execution Note**: This command requires CLI execution. AI agents should run `clavix archive` via Bash tool to perform archival operations. Direct file manipulation is not recommended due to state tracking complexity.
8
+ Done with a project? I'll move it to the archive to keep your workspace tidy. You can always restore it later if needed.
9
9
 
10
- You are helping the user archive completed PRD projects to keep their workspace organized.
10
+ ---
11
11
 
12
- ## Instructions
12
+ ## What This Does
13
13
 
14
- ### Part A: Agent Execution Protocol
14
+ When you run `/clavix:archive`, I:
15
+ 1. **Find your completed projects** - Look for 100% done PRDs
16
+ 2. **Ask which to archive** - You pick, or I archive all completed ones
17
+ 3. **Move to archive folder** - Out of the way but not deleted
18
+ 4. **Track everything** - So you can restore later if needed
15
19
 
16
- **As an AI agent, you should:**
20
+ **Your work is never deleted, just organized.**
17
21
 
18
- 1. **Run the CLI command** to handle archival operations:
19
- ```bash
20
- clavix archive
21
- ```
22
+ ---
23
+
24
+ ## CLAVIX MODE: Archival
25
+
26
+ **I'm in archival mode. Organizing your completed work.**
27
+
28
+ **What I'll do:**
29
+ - ✓ Find projects ready for archive
30
+ - ✓ Show you what's complete (100% tasks done)
31
+ - ✓ Move projects to archive when you confirm
32
+ - ✓ Track everything so you can restore later
33
+
34
+ **What I won't do:**
35
+ - ✗ Delete anything without explicit confirmation
36
+ - ✗ Archive projects you're still working on (unless you use --force)
37
+ - ✗ Make decisions for you - you pick what to archive
38
+
39
+ ---
40
+
41
+ ## How I Archive Projects
42
+
43
+ **I handle all the commands - you just tell me what to do.**
22
44
 
23
- The CLI will:
24
- - Prompt user for project selection
25
- - Validate task completion status
26
- - Handle file operations safely
27
- - Update state tracking
45
+ ### What I Run (You Don't Need To)
28
46
 
29
- 2. **Choose the appropriate mode** based on user intent:
47
+ | What You Want | Command I Execute |
48
+ |---------------|-------------------|
49
+ | Archive completed project | `clavix archive` |
50
+ | Archive specific project | `clavix archive [name]` |
51
+ | Archive incomplete work | `clavix archive [name] --force` |
52
+ | Delete permanently | `clavix archive [name] --delete` |
53
+ | See what's archived | `clavix archive --list` |
54
+ | Restore from archive | `clavix archive --restore [name]` |
30
55
 
31
- - **Interactive mode** (no arguments): User selects from list
32
- - **Specific project**: `clavix archive [project-name]`
33
- - **Force archive incomplete**: `clavix archive [project-name] --force`
34
- - **Permanent delete**: `clavix archive [project-name] --delete`
35
- - **List archived**: `clavix archive --list`
36
- - **Restore**: `clavix archive --restore [project-name]`
56
+ ### Before I Archive
37
57
 
38
- 3. **Before running the command**, validate:
39
- - Check if `.clavix/outputs/` directory exists
40
- - Verify user intent (archive vs delete vs restore)
41
- - Confirm project name if specified
58
+ I check:
59
+ - Projects exist in `.clavix/outputs/`
60
+ - What you want to do (archive, delete, restore)
61
+ - Project name is correct
42
62
 
43
- 4. **After CLI completes**, communicate results:
44
- - Confirm where project was moved
45
- - Mention restoration is possible (unless deleted)
46
- - Update user on next steps
63
+ ### After Archiving
64
+
65
+ I tell you:
66
+ - Where the project went
67
+ - How to restore it (unless you deleted it)
68
+ - What to do next
47
69
 
48
70
  ### Part B: Understanding Archive Operations
49
71
 
@@ -238,57 +260,21 @@ User types: api-experiment-1
238
260
  Result: Project permanently deleted from .clavix/outputs/api-experiment-1/
239
261
  ```
240
262
 
241
- ## AI Agent Guidelines
242
-
243
- When user mentions archiving or cleaning up projects:
244
-
245
- 1. **Validate prerequisites before running CLI**:
246
- - Check if `.clavix/outputs/` directory exists
247
- - If not, inform user no projects exist to archive
248
- - Verify user intent (list, archive, restore, delete)
249
-
250
- 2. **Check completion status first**:
251
- - Run `clavix archive` (interactive mode) to see archivable projects
252
- - CLI will display projects with completion percentages
253
- - Review output and communicate options to user
254
-
255
- 3. **Execute the appropriate command**:
256
- - **Interactive selection**: `clavix archive` (let user pick from list)
257
- - **Specific project**: `clavix archive [project-name]`
258
- - **Force incomplete**: `clavix archive [project-name] --force`
259
- - **List archived**: `clavix archive --list`
260
- - **Restore**: `clavix archive --restore [project-name]`
261
- - **Delete**: `clavix archive [project-name] --delete` (with extra caution)
262
-
263
- 4. **Confirm before archiving**:
264
- - If using specific project mode, confirm project name with user
265
- - Mention the archive location (`.clavix/outputs/archive/`)
266
- - Explain that restoration is possible
267
-
268
- 5. **Use --force cautiously**:
269
- - Only when user explicitly wants to archive incomplete work
270
- - Run command and let CLI show incomplete task count
271
- - CLI will ask for user confirmation
272
- - Explain they won't lose data (just moving location)
273
-
274
- 6. **Suggest restoration when appropriate**:
275
- - If user mentions old/past work, check archive first
276
- - Run `clavix archive --list` to show what's archived
277
- - Offer to restore if needed via `clavix archive --restore [project]`
278
-
279
- 7. **Handle delete requests with extreme caution**:
280
- - Always ask: "Do you want to DELETE (permanent) or ARCHIVE (safe)?"
281
- - Explain that delete is permanent and irreversible
282
- - Suggest archive as the safer default
283
- - Use decision tree to help user decide
284
- - Only run `--delete` after clear confirmation from user
285
- - Double-check it's truly no-value content (failed experiments, duplicates, test data)
286
- - CLI will require typing project name to confirm - this is expected
287
-
288
- 8. **After CLI execution**:
289
- - Communicate success/failure clearly
290
- - Mention next steps (e.g., "Project archived, you can restore with `/clavix:archive --restore`")
291
- - If error occurs, explain and suggest recovery options
263
+ ---
264
+
265
+ ## Agent Transparency (v4.9)
266
+
267
+ ### CLI Reference (Commands I Execute)
268
+ {{INCLUDE:agent-protocols/cli-reference.md}}
269
+
270
+ ### Error Handling
271
+ {{INCLUDE:agent-protocols/error-handling.md}}
272
+
273
+ ### Recovery Patterns
274
+ {{INCLUDE:troubleshooting/vibecoder-recovery.md}}
275
+
276
+ ### Agent Decision Rules
277
+ {{INCLUDE:agent-protocols/decision-rules.md}}
292
278
 
293
279
  ## Workflow Navigation
294
280
 
@@ -7,19 +7,26 @@ description: Comprehensive analysis with alternatives, edge cases, and validatio
7
7
 
8
8
  **THIS IS A PROMPT ANALYSIS WORKFLOW. YOU MUST NOT IMPLEMENT ANYTHING.**
9
9
 
10
- ## YOU MUST NOT:
11
- - ❌ Write any application code
12
- - Create any new files (except prompt save files)
13
- - Modify any existing project code
14
- - ❌ Start implementing the prompt's requirements
15
- - Generate components, functions, or features
16
-
17
- ## YOU MUST:
18
- 1. Analyze the user's prompt comprehensively
19
- 2. Apply all intelligence patterns
20
- 3. Show the optimized prompt + alternatives + edge cases
21
- 4. Save the prompt (CLI command or manual)
22
- 5. **STOP and wait** for user to run `/clavix:execute`
10
+ ## Critical Understanding
11
+
12
+ This template exists because agents (including you) tend to "help" by doing work immediately.
13
+ **That's the wrong behavior here.** Your job is to ANALYZE and IMPROVE the prompt, then STOP.
14
+
15
+ ## What "Implementation" Looks Like (ALL FORBIDDEN)
16
+ - ❌ Reading project files to "understand context" before showing analysis
17
+ - Writing any code files (functions, classes, components)
18
+ - Creating components, features, or API endpoints
19
+ - Running build/test commands on the user's project
20
+ - Making git commits
21
+ - ANY action that modifies files outside `.clavix/`
22
+ - Exploring the codebase before outputting your analysis
23
+
24
+ ## The ONLY Actions Allowed
25
+ 1. ✅ Read the user's prompt text (the `{{ARGS}}` provided)
26
+ 2. ✅ Analyze it comprehensively using the workflow below
27
+ 3. ✅ Output the analysis (intent, quality, optimized prompt, alternatives, edge cases)
28
+ 4. ✅ Save to `.clavix/outputs/prompts/deep/`
29
+ 5. ✅ STOP and wait for `/clavix:execute`
23
30
 
24
31
  ## IF USER WANTS TO IMPLEMENT:
25
32
  Tell them: **"Run `/clavix:execute --latest` to implement this prompt."**
@@ -207,30 +214,35 @@ Deep mode provides **Clavix Intelligence™** with comprehensive analysis that g
207
214
 
208
215
  ---
209
216
 
210
- ## Agent Transparency (v4.6)
217
+ ## Agent Transparency (v4.9)
211
218
 
212
- ### Quality Output Format
213
- {{INCLUDE:agent-protocols/quality-output.md}}
219
+ ### How to Explain Improvements
220
+ {{INCLUDE:sections/improvement-explanations.md}}
221
+
222
+ ### Quality Dimensions (Plain English)
223
+ {{INCLUDE:references/quality-dimensions.md}}
224
+
225
+ ### When to Recommend PRD Mode
226
+ {{INCLUDE:sections/escalation-factors.md}}
227
+
228
+ ### What Made the Biggest Difference
229
+ {{INCLUDE:sections/pattern-impact.md}}
214
230
 
215
231
  ### Agent Decision Rules
216
232
  {{INCLUDE:agent-protocols/decision-rules.md}}
217
233
 
218
- ### Assertion Checkpoints
219
- {{INCLUDE:agent-protocols/assertion-checkpoints.md}}
220
-
221
- ### Patterns Applied
222
- {{INCLUDE:sections/pattern-visibility.md}}
234
+ ### Error Handling
235
+ {{INCLUDE:agent-protocols/error-handling.md}}
223
236
 
224
237
  ### Deep Mode Pattern Selection
225
- Deep mode has access to all patterns including deep-exclusive patterns:
226
- - **AlternativePhrasingGenerator**: Generates 2-3 alternative prompt structures
227
- - **EdgeCaseIdentifier**: Identifies domain-specific edge cases
228
- - **ValidationChecklistCreator**: Creates implementation verification checklist
229
- - **AssumptionExplicitizer**: Makes implicit assumptions explicit
230
- - **ScopeDefiner**: Adds explicit scope boundaries
231
- - **PRDStructureEnforcer**: Ensures PRD completeness (PRD mode only)
232
- - **ErrorToleranceEnhancer**: Adds error handling requirements
233
- - **PrerequisiteIdentifier**: Identifies prerequisites and dependencies
238
+ Deep mode has access to all patterns including comprehensive analysis:
239
+ - **Alternative Approaches**: 2-3 different ways to structure the request
240
+ - **Edge Cases**: Things that might go wrong or need special handling
241
+ - **Validation Checklist**: Steps to verify the implementation is complete
242
+ - **Hidden Assumptions**: Things you might be assuming but didn't say
243
+ - **Scope Boundaries**: What's in and out of scope
244
+ - **Error Handling**: How to deal with failures gracefully
245
+ - **Prerequisites**: What needs to exist before starting
234
246
 
235
247
  ---
236
248
 
@@ -376,6 +388,34 @@ Consider using `/clavix:prd` if this login page is part of a larger authenticati
376
388
  - **Deep mode** (`/clavix:deep`): Comprehensive analysis - best for complex prompts needing exploration
377
389
  - **PRD mode** (`/clavix:prd`): Strategic planning - best for features requiring architecture/business decisions
378
390
 
391
+ ---
392
+
393
+ ## ⛔ CHECKPOINT: Analysis Complete?
394
+
395
+ **Before proceeding to save, verify you have output ALL of the following:**
396
+
397
+ - [ ] **Intent Analysis** section with type and confidence %
398
+ - [ ] **Quality Assessment** with all 6 dimensions scored
399
+ - [ ] **Optimized Prompt** in a code block
400
+ - [ ] **Improvements Applied** list with dimension labels
401
+ - [ ] **Alternative Approaches** (2-3 alternatives)
402
+ - [ ] **Validation Checklist** for implementation verification
403
+ - [ ] **Edge Cases** to consider
404
+
405
+ **If ANY checkbox above is unchecked, STOP. Go back and complete the analysis.**
406
+
407
+ **Self-Check Before Any Action:**
408
+ - Am I about to write/edit code files? → STOP (only `.clavix/` files allowed)
409
+ - Am I about to run a command that modifies the project? → STOP
410
+ - Am I exploring the codebase to "understand" before showing analysis? → STOP
411
+ - Have I shown the user the optimized prompt yet? → If NO, do that first
412
+
413
+ If any tripwire triggered: Output "I was about to [action]. Let me return to deep prompt analysis."
414
+
415
+ Only after ALL items are checked should you proceed to the "Saving the Prompt" section below.
416
+
417
+ ---
418
+
379
419
  ## Next Steps
380
420
 
381
421
  ### Saving the Prompt (REQUIRED)
@@ -479,27 +519,26 @@ Confirm:
479
519
  - Index file updated with new entry
480
520
  - Display success message: `✓ Prompt saved: <prompt-id>.md`
481
521
 
482
- ### Executing the Saved Prompt
483
-
484
- After saving completes successfully:
522
+ ### After Saving
485
523
 
486
524
  ---
487
525
 
488
526
  ## ⛔ STOP HERE - Agent Verification Required
489
527
 
490
- **Your workflow ends here. Before responding to the user:**
528
+ **Your workflow ends here. After saving the prompt, verify it worked.**
491
529
 
492
530
  ### CLI Verification (Run This Command)
531
+ I run this command to confirm the save worked:
493
532
  ```bash
494
533
  clavix prompts list
495
534
  ```
496
535
 
497
- **Verify**: Your prompt appears in the list with status "pending" or "NEW".
536
+ **If it worked**: Your prompt appears in the list.
498
537
 
499
- **If verification fails**:
500
- - Check if file was saved to `.clavix/outputs/prompts/deep/`
501
- - Retry the save operation
502
- - Check file permissions
538
+ **If it failed**:
539
+ - I create the directory: `mkdir -p .clavix/outputs/prompts/deep`
540
+ - I try saving again
541
+ - If still failing, I tell you: "I had trouble saving, but here's your improved prompt..."
503
542
 
504
543
  ### Required Response Ending
505
544
 
@@ -507,26 +546,28 @@ clavix prompts list
507
546
  ```
508
547
  ✅ Deep analysis complete. Prompt optimized and saved.
509
548
 
510
- To implement this prompt, run:
549
+ Ready to build this? Just say "let's implement" or run:
511
550
  /clavix:execute --latest
512
551
  ```
513
552
 
514
- **DO NOT continue to implementation. DO NOT write any code. STOP HERE.**
553
+ **IMPORTANT: I don't start implementing. I don't write code. My job is done.**
554
+ I wait for you to decide what to do next.
515
555
 
516
556
  ---
517
557
 
518
- ### Prompt Management (CLI Commands)
558
+ ### Prompt Management (Commands I Run)
559
+
560
+ These are commands I execute when needed - you don't need to run them.
519
561
 
520
- **List all saved prompts:**
562
+ **Check saved prompts:**
521
563
  ```bash
522
564
  clavix prompts list
523
565
  ```
524
566
 
525
- **Cleanup after execution:**
567
+ **Cleanup (I run when you ask or during maintenance):**
526
568
  ```bash
527
- clavix prompts clear --executed # Remove executed prompts
528
- clavix prompts clear --stale # Remove >30 day old prompts
529
- clavix prompts clear --deep # Remove all deep prompts
569
+ clavix prompts clear --executed # Remove implemented prompts
570
+ clavix prompts clear --stale # Remove old prompts (>30 days)
530
571
  ```
531
572
 
532
573
  ## Workflow Navigation