clavix 4.9.0 → 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.
- package/dist/cli/commands/analyze.d.ts +14 -0
- package/dist/cli/commands/analyze.js +127 -0
- package/dist/templates/slash-commands/_canonical/deep.md +48 -13
- package/dist/templates/slash-commands/_canonical/execute.md +13 -0
- package/dist/templates/slash-commands/_canonical/fast.md +45 -13
- package/dist/templates/slash-commands/_canonical/implement.md +28 -0
- package/dist/templates/slash-commands/_components/agent-protocols/cli-reference.md +12 -0
- package/dist/templates/slash-commands/_components/agent-protocols/self-correction.md +20 -1
- 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
|
|
@@ -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
|
-
##
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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."**
|
|
@@ -381,6 +388,34 @@ Consider using `/clavix:prd` if this login page is part of a larger authenticati
|
|
|
381
388
|
- **Deep mode** (`/clavix:deep`): Comprehensive analysis - best for complex prompts needing exploration
|
|
382
389
|
- **PRD mode** (`/clavix:prd`): Strategic planning - best for features requiring architecture/business decisions
|
|
383
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
|
+
|
|
384
419
|
## Next Steps
|
|
385
420
|
|
|
386
421
|
### Saving the Prompt (REQUIRED)
|
|
@@ -213,6 +213,19 @@ After I finish implementing and verification passes:
|
|
|
213
213
|
|
|
214
214
|
---
|
|
215
215
|
|
|
216
|
+
## Finding Your Way Around
|
|
217
|
+
|
|
218
|
+
Need to see what projects exist or check progress? I use these commands:
|
|
219
|
+
|
|
220
|
+
| What I Need | Command I Run |
|
|
221
|
+
|-------------|---------------|
|
|
222
|
+
| See all projects | `clavix list` |
|
|
223
|
+
| Check a specific project | `clavix show --output <project>` |
|
|
224
|
+
| See active sessions | `clavix list --sessions` |
|
|
225
|
+
| Find archived work | `clavix list --archived` |
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
216
229
|
## When Things Go Wrong
|
|
217
230
|
|
|
218
231
|
### No Prompts Found
|
|
@@ -7,19 +7,26 @@ description: Quick prompt improvements with smart quality assessment and triage
|
|
|
7
7
|
|
|
8
8
|
**THIS IS A PROMPT OPTIMIZATION WORKFLOW. YOU MUST NOT IMPLEMENT ANYTHING.**
|
|
9
9
|
|
|
10
|
-
##
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 using the workflow below
|
|
27
|
+
3. ✅ Output the analysis (intent, quality, optimized prompt)
|
|
28
|
+
4. ✅ Save to `.clavix/outputs/prompts/fast/`
|
|
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."**
|
|
@@ -290,6 +297,31 @@ Success Criteria:
|
|
|
290
297
|
[Actionability] Converted vague "create" into specific implementation requirements with measurable success criteria
|
|
291
298
|
```
|
|
292
299
|
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## ⛔ CHECKPOINT: Analysis Complete?
|
|
303
|
+
|
|
304
|
+
**Before proceeding to save, verify you have output ALL of the following:**
|
|
305
|
+
|
|
306
|
+
- [ ] **Intent Analysis** section with type and confidence %
|
|
307
|
+
- [ ] **Quality Assessment** with all 6 dimensions scored
|
|
308
|
+
- [ ] **Optimized Prompt** in a code block
|
|
309
|
+
- [ ] **Improvements Applied** list with dimension labels
|
|
310
|
+
|
|
311
|
+
**If ANY checkbox above is unchecked, STOP. Go back and complete the analysis.**
|
|
312
|
+
|
|
313
|
+
**Self-Check Before Any Action:**
|
|
314
|
+
- Am I about to write/edit code files? → STOP (only `.clavix/` files allowed)
|
|
315
|
+
- Am I about to run a command that modifies the project? → STOP
|
|
316
|
+
- Am I exploring the codebase to "understand" before showing analysis? → STOP
|
|
317
|
+
- Have I shown the user the optimized prompt yet? → If NO, do that first
|
|
318
|
+
|
|
319
|
+
If any tripwire triggered: Output "I was about to [action]. Let me return to prompt optimization."
|
|
320
|
+
|
|
321
|
+
Only after ALL items are checked should you proceed to the "Saving the Prompt" section below.
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
293
325
|
## Next Steps
|
|
294
326
|
|
|
295
327
|
### Saving the Prompt (REQUIRED)
|
|
@@ -94,6 +94,23 @@ Me: "All tasks complete! Your project is built."
|
|
|
94
94
|
No problem! Just run `/clavix:implement` again and I pick up where we left off.
|
|
95
95
|
The checkboxes in tasks.md track exactly what's done.
|
|
96
96
|
|
|
97
|
+
## ⚠️ Critical Command: task-complete
|
|
98
|
+
|
|
99
|
+
**After finishing EACH task, I MUST run:**
|
|
100
|
+
```bash
|
|
101
|
+
clavix task-complete <task-id>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Why this matters:**
|
|
105
|
+
- Updates tasks.md automatically (checkboxes)
|
|
106
|
+
- Tracks progress correctly in config
|
|
107
|
+
- Triggers git commits (if enabled)
|
|
108
|
+
- Shows me the next task
|
|
109
|
+
|
|
110
|
+
**NEVER manually edit tasks.md checkboxes** - always use this command.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
97
114
|
## How I Mark Tasks Complete
|
|
98
115
|
|
|
99
116
|
**I handle this automatically - you don't need to do anything.**
|
|
@@ -141,6 +158,17 @@ Starting now...
|
|
|
141
158
|
- Guess what you want - I'll ask instead
|
|
142
159
|
- Edit checkboxes manually (I use the command)
|
|
143
160
|
|
|
161
|
+
## Finding Your Way Around
|
|
162
|
+
|
|
163
|
+
Need to see what projects exist or check progress? I use these commands:
|
|
164
|
+
|
|
165
|
+
| What I Need | Command I Run |
|
|
166
|
+
|-------------|---------------|
|
|
167
|
+
| See all projects | `clavix list` |
|
|
168
|
+
| Check a specific project | `clavix show --output <project>` |
|
|
169
|
+
| See active sessions | `clavix list --sessions` |
|
|
170
|
+
| Find archived work | `clavix list --archived` |
|
|
171
|
+
|
|
144
172
|
## When I Can't Continue (Blocked Tasks)
|
|
145
173
|
|
|
146
174
|
Sometimes I hit a wall. Here's what happens:
|
|
@@ -24,6 +24,18 @@ clavix fast "build a todo app"
|
|
|
24
24
|
clavix deep "create authentication system with OAuth"
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
#### `clavix analyze "prompt"`
|
|
28
|
+
**What it does:** Returns structured JSON with intent, quality scores, and escalation recommendation
|
|
29
|
+
**When to run:** When you need data-driven decision on which mode to use
|
|
30
|
+
**You say:** Nothing - this is for internal decision-making
|
|
31
|
+
**Example:**
|
|
32
|
+
```bash
|
|
33
|
+
clavix analyze "build a login page"
|
|
34
|
+
```
|
|
35
|
+
**Output:** JSON with `intent`, `confidence`, `quality` (6 dimensions), `escalation` (score + recommendation)
|
|
36
|
+
**Flags:**
|
|
37
|
+
- `--pretty` - Pretty-print the JSON output
|
|
38
|
+
|
|
27
39
|
#### `clavix prompts list`
|
|
28
40
|
**What it does:** Shows all saved prompts with their status
|
|
29
41
|
**When to run:** To verify a prompt was saved, or find prompt IDs
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
- Writing test files for the user's feature
|
|
10
10
|
- Creating database schemas/migrations
|
|
11
11
|
- Writing configuration files for deployment
|
|
12
|
+
- **Reading project files to "understand context" before showing analysis**
|
|
13
|
+
- **Exploring the codebase before outputting optimized prompt**
|
|
12
14
|
|
|
13
15
|
### Mistake Type 2: Skipping Quality Assessment
|
|
14
16
|
- Not scoring all 6 quality dimensions
|
|
@@ -37,6 +39,23 @@
|
|
|
37
39
|
|
|
38
40
|
**STOP**: Immediately halt the incorrect action
|
|
39
41
|
|
|
40
|
-
**CORRECT**: Output an acknowledgment
|
|
42
|
+
**CORRECT**: Output an acknowledgment:
|
|
43
|
+
> "I was about to [describe action]. Let me return to [fast/deep] prompt analysis."
|
|
41
44
|
|
|
42
45
|
**RESUME**: Return to the appropriate Clavix workflow for this mode
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Anti-Implementation Tripwires
|
|
50
|
+
|
|
51
|
+
**Before your next tool call or action, check:**
|
|
52
|
+
|
|
53
|
+
| Action | Tripwire | Response |
|
|
54
|
+
|--------|----------|----------|
|
|
55
|
+
| About to read project files | STOP | "I don't need to explore the codebase for prompt optimization" |
|
|
56
|
+
| About to write code files | STOP | "Only `.clavix/` files are allowed in optimization mode" |
|
|
57
|
+
| About to run build/test commands | STOP | "Project commands are for `/clavix:execute`, not optimization" |
|
|
58
|
+
| About to make git commits | STOP | "Git operations belong in implementation mode" |
|
|
59
|
+
| Haven't shown optimized prompt yet | STOP | "I need to show the analysis first" |
|
|
60
|
+
|
|
61
|
+
**If any tripwire triggers:** Output the response and return to prompt analysis.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavix",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "Clavix Intelligence™ for AI coding. Automatically optimizes prompts with intent detection, quality assessment, and adaptive patterns—no framework to learn. Works with Claude Code, Cursor, Windsurf, and 19+ other AI coding tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|