clavix 2.8.2 → 3.0.1

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 (55) hide show
  1. package/README.md +26 -6
  2. package/dist/cli/commands/deep.d.ts +3 -4
  3. package/dist/cli/commands/deep.js +162 -261
  4. package/dist/cli/commands/fast.d.ts +3 -4
  5. package/dist/cli/commands/fast.js +126 -303
  6. package/dist/cli/commands/init.js +184 -22
  7. package/dist/cli/commands/prd.d.ts +7 -6
  8. package/dist/cli/commands/prd.js +113 -132
  9. package/dist/cli/commands/summarize.d.ts +1 -12
  10. package/dist/cli/commands/summarize.js +63 -131
  11. package/dist/core/intelligence/index.d.ts +10 -0
  12. package/dist/core/intelligence/index.js +13 -0
  13. package/dist/core/intelligence/intent-detector.d.ts +33 -0
  14. package/dist/core/intelligence/intent-detector.js +311 -0
  15. package/dist/core/intelligence/pattern-library.d.ts +44 -0
  16. package/dist/core/intelligence/pattern-library.js +103 -0
  17. package/dist/core/intelligence/patterns/actionability-enhancer.d.ts +27 -0
  18. package/dist/core/intelligence/patterns/actionability-enhancer.js +162 -0
  19. package/dist/core/intelligence/patterns/base-pattern.d.ts +31 -0
  20. package/dist/core/intelligence/patterns/base-pattern.js +39 -0
  21. package/dist/core/intelligence/patterns/completeness-validator.d.ts +27 -0
  22. package/dist/core/intelligence/patterns/completeness-validator.js +135 -0
  23. package/dist/core/intelligence/patterns/conciseness-filter.d.ts +12 -0
  24. package/dist/core/intelligence/patterns/conciseness-filter.js +61 -0
  25. package/dist/core/intelligence/patterns/objective-clarifier.d.ts +14 -0
  26. package/dist/core/intelligence/patterns/objective-clarifier.js +97 -0
  27. package/dist/core/intelligence/patterns/structure-organizer.d.ts +31 -0
  28. package/dist/core/intelligence/patterns/structure-organizer.js +185 -0
  29. package/dist/core/intelligence/patterns/technical-context-enricher.d.ts +16 -0
  30. package/dist/core/intelligence/patterns/technical-context-enricher.js +132 -0
  31. package/dist/core/intelligence/quality-assessor.d.ts +42 -0
  32. package/dist/core/intelligence/quality-assessor.js +296 -0
  33. package/dist/core/intelligence/types.d.ts +81 -0
  34. package/dist/core/intelligence/types.js +3 -0
  35. package/dist/core/intelligence/universal-optimizer.d.ts +31 -0
  36. package/dist/core/intelligence/universal-optimizer.js +118 -0
  37. package/dist/core/prd-generator.d.ts +2 -2
  38. package/dist/core/task-manager.js +18 -5
  39. package/dist/templates/agents/agents.md +2 -2
  40. package/dist/templates/agents/copilot-instructions.md +15 -15
  41. package/dist/templates/agents/octo.md +35 -30
  42. package/dist/templates/agents/warp.md +3 -3
  43. package/dist/templates/full-prd-template.hbs +1 -1
  44. package/dist/templates/prd-questions.md +1 -1
  45. package/dist/templates/quick-prd-template.hbs +1 -1
  46. package/dist/templates/slash-commands/_canonical/deep.md +261 -122
  47. package/dist/templates/slash-commands/_canonical/fast.md +101 -69
  48. package/dist/templates/slash-commands/_canonical/implement.md +1 -1
  49. package/dist/templates/slash-commands/_canonical/plan.md +12 -12
  50. package/dist/templates/slash-commands/_canonical/prd.md +34 -24
  51. package/dist/templates/slash-commands/_canonical/start.md +13 -12
  52. package/dist/templates/slash-commands/_canonical/summarize.md +42 -25
  53. package/dist/utils/error-utils.d.ts +7 -0
  54. package/dist/utils/error-utils.js +17 -0
  55. package/package.json +21 -12
@@ -1,21 +1,17 @@
1
1
  import { Command, Args, Flags } from '@oclif/core';
2
2
  import chalk from 'chalk';
3
3
  import inquirer from 'inquirer';
4
- import { PromptOptimizer } from '../../core/prompt-optimizer.js';
4
+ import { UniversalOptimizer } from '../../core/intelligence/index.js';
5
5
  import { PromptManager } from '../../core/prompt-manager.js';
6
6
  export default class Fast extends Command {
7
- static description = 'Quickly improve a prompt using CLEAR framework (Concise, Logical, Explicit) with smart triage';
7
+ static description = 'Quickly improve a prompt with smart quality assessment and triage';
8
8
  static examples = [
9
9
  '<%= config.bin %> <%= command.id %> "Create a login page"',
10
10
  '<%= config.bin %> <%= command.id %> "Build an API for user management"',
11
11
  ];
12
12
  static flags = {
13
- 'clear-only': Flags.boolean({
14
- description: 'Show only CLEAR analysis without improved prompt',
15
- default: false,
16
- }),
17
- 'framework-info': Flags.boolean({
18
- description: 'Display CLEAR framework information',
13
+ 'analysis-only': Flags.boolean({
14
+ description: 'Show only quality analysis without improved prompt',
19
15
  default: false,
20
16
  }),
21
17
  };
@@ -27,43 +23,28 @@ export default class Fast extends Command {
27
23
  };
28
24
  async run() {
29
25
  const { args, flags } = await this.parse(Fast);
30
- // Handle --framework-info flag
31
- if (flags['framework-info']) {
32
- this.displayFrameworkInfo();
33
- return;
34
- }
35
26
  if (!args.prompt || args.prompt.trim().length === 0) {
36
27
  console.log(chalk.red('\nāœ— Please provide a prompt to improve\n'));
37
28
  console.log(chalk.gray('Example:'), chalk.cyan('clavix fast "Create a login page"'));
38
29
  return;
39
30
  }
40
- console.log(chalk.bold.cyan('\nšŸ” Analyzing prompt using CLEAR framework (fast mode)...\n'));
41
- const optimizer = new PromptOptimizer();
42
- // Get CLEAR analysis
43
- const clearResult = optimizer.applyCLEARFramework(args.prompt, 'fast');
44
- const clearScore = optimizer.calculateCLEARScore(clearResult);
45
- // Also get the full improvement result for triage
46
- const result = optimizer.improve(args.prompt, 'fast');
47
- // Check CLEAR-aware triage result (low scores indicate need for deep mode)
48
- const needsDeepAnalysis = result.triageResult?.needsDeepAnalysis ||
49
- clearScore.conciseness < 60 ||
50
- clearScore.logic < 60 ||
51
- clearScore.explicitness < 50;
52
- if (needsDeepAnalysis) {
53
- console.log(chalk.bold.yellow('āš ļø CLEAR Framework Triage Alert\n'));
31
+ console.log(chalk.bold.cyan('\nšŸ” Analyzing and optimizing prompt...\n'));
32
+ const optimizer = new UniversalOptimizer();
33
+ const result = await optimizer.optimize(args.prompt, 'fast');
34
+ // Check if deep mode is recommended
35
+ const shouldRecommendDeep = optimizer.shouldRecommendDeepMode(result);
36
+ if (shouldRecommendDeep) {
37
+ console.log(chalk.bold.yellow('āš ļø Smart Triage Alert\n'));
54
38
  console.log(chalk.yellow('Deep analysis is recommended for this prompt because:'));
55
- if (clearScore.conciseness < 60) {
56
- console.log(chalk.yellow(` • Low Conciseness score (${clearScore.conciseness.toFixed(0)}%) - needs detailed verbosity analysis`));
39
+ if (result.intent.primaryIntent === 'planning') {
40
+ console.log(chalk.yellow(` • Planning intent detected - benefits from comprehensive exploration`));
57
41
  }
58
- if (clearScore.logic < 60) {
59
- console.log(chalk.yellow(` • Low Logic score (${clearScore.logic.toFixed(0)}%) - needs comprehensive flow analysis`));
42
+ if (result.quality.overall < 65) {
43
+ console.log(chalk.yellow(` • Quality score ${result.quality.overall.toFixed(0)}% - can be significantly improved`));
60
44
  }
61
- if (clearScore.explicitness < 50) {
62
- console.log(chalk.yellow(` • Low Explicitness score (${clearScore.explicitness.toFixed(0)}%) - needs complete specification check`));
45
+ if (result.intent.characteristics.isOpenEnded && result.intent.characteristics.needsStructure) {
46
+ console.log(chalk.yellow(` • Open-ended prompt without clear structure`));
63
47
  }
64
- result.triageResult?.reasons.forEach((reason) => {
65
- console.log(chalk.yellow(` • ${reason}`));
66
- });
67
48
  console.log();
68
49
  const { proceed } = await inquirer.prompt([
69
50
  {
@@ -72,34 +53,36 @@ export default class Fast extends Command {
72
53
  message: 'How would you like to proceed?',
73
54
  choices: [
74
55
  { name: 'Switch to deep mode (recommended)', value: 'deep' },
75
- { name: 'Continue with fast mode (at my own risk)', value: 'fast' },
56
+ { name: 'Continue with fast mode', value: 'fast' },
76
57
  ],
77
58
  },
78
59
  ]);
79
60
  if (proceed === 'deep') {
80
61
  console.log(chalk.cyan('\nšŸ” Switching to deep mode...\n'));
81
- const deepClearResult = optimizer.applyCLEARFramework(args.prompt, 'deep');
82
- const deepClearScore = optimizer.calculateCLEARScore(deepClearResult);
83
- const deepResult = optimizer.improve(args.prompt, 'deep');
84
- this.displayDeepModeOutput(deepResult, deepClearResult, deepClearScore);
62
+ const deepResult = await optimizer.optimize(args.prompt, 'deep');
63
+ this.displayDeepModeOutput(deepResult);
64
+ await this.savePrompt(deepResult);
85
65
  return;
86
66
  }
87
67
  console.log(chalk.yellow('\nāš ļø Proceeding with fast mode as requested\n'));
88
68
  }
89
- // Handle --clear-only flag
90
- if (flags['clear-only']) {
91
- this.displayCLEAROnlyAnalysis(clearResult, clearScore);
69
+ // Handle --analysis-only flag
70
+ if (flags['analysis-only']) {
71
+ this.displayAnalysisOnly(result);
92
72
  return;
93
73
  }
94
74
  // Display full analysis
95
- this.displayFastModeOutput(result, clearResult, clearScore);
75
+ this.displayFastModeOutput(result);
96
76
  // Save prompt to file system
97
- await this.savePrompt(clearResult.improvedPrompt, args.prompt, clearScore);
77
+ await this.savePrompt(result);
98
78
  }
99
- displayFastModeOutput(result, clearResult, clearScore) {
100
- console.log(chalk.bold.cyan('šŸŽÆ CLEAR Analysis (Fast Mode)\n'));
101
- // Display CLEAR Assessment
102
- console.log(chalk.bold('šŸ“Š CLEAR Framework Assessment:\n'));
79
+ displayFastModeOutput(result) {
80
+ // Display intent detection
81
+ console.log(chalk.bold.cyan('šŸŽÆ Intent Analysis:\n'));
82
+ console.log(chalk.cyan(` Type: ${result.intent.primaryIntent}`));
83
+ console.log(chalk.cyan(` Confidence: ${result.intent.confidence}%\n`));
84
+ // Display quality assessment
85
+ console.log(chalk.bold('šŸ“Š Quality Assessment:\n'));
103
86
  const getScoreColor = (score) => {
104
87
  if (score >= 80)
105
88
  return chalk.green;
@@ -107,61 +90,58 @@ export default class Fast extends Command {
107
90
  return chalk.yellow;
108
91
  return chalk.red;
109
92
  };
110
- // Conciseness
111
- const cColor = getScoreColor(clearScore.conciseness);
112
- console.log(cColor(` [C] Conciseness: ${clearScore.conciseness.toFixed(0)}%`));
113
- if (clearResult.conciseness.issues.length > 0) {
114
- clearResult.conciseness.issues.forEach((issue) => {
115
- console.log(cColor(` • ${issue}`));
116
- });
117
- }
118
- console.log();
119
- // Logic
120
- const lColor = getScoreColor(clearScore.logic);
121
- console.log(lColor(` [L] Logic: ${clearScore.logic.toFixed(0)}%`));
122
- if (clearResult.logic.issues.length > 0) {
123
- clearResult.logic.issues.forEach((issue) => {
124
- console.log(lColor(` • ${issue}`));
93
+ console.log(getScoreColor(result.quality.clarity)(` Clarity: ${result.quality.clarity.toFixed(0)}%`));
94
+ console.log(getScoreColor(result.quality.efficiency)(` Efficiency: ${result.quality.efficiency.toFixed(0)}%`));
95
+ console.log(getScoreColor(result.quality.structure)(` Structure: ${result.quality.structure.toFixed(0)}%`));
96
+ console.log(getScoreColor(result.quality.completeness)(` Completeness: ${result.quality.completeness.toFixed(0)}%`));
97
+ console.log(getScoreColor(result.quality.actionability)(` Actionability: ${result.quality.actionability.toFixed(0)}%`));
98
+ console.log(getScoreColor(result.quality.overall).bold(`\n Overall: ${result.quality.overall.toFixed(0)}%\n`));
99
+ // Display strengths if any
100
+ if (result.quality.strengths.length > 0) {
101
+ console.log(chalk.bold.green('āœ… Strengths:\n'));
102
+ result.quality.strengths.forEach((strength) => {
103
+ console.log(chalk.green(` • ${strength}`));
125
104
  });
105
+ console.log();
126
106
  }
127
- console.log();
128
- // Explicitness
129
- const eColor = getScoreColor(clearScore.explicitness);
130
- console.log(eColor(` [E] Explicitness: ${clearScore.explicitness.toFixed(0)}%`));
131
- if (clearResult.explicitness.issues.length > 0) {
132
- clearResult.explicitness.issues.forEach((issue) => {
133
- console.log(eColor(` • ${issue}`));
107
+ // Display improvements applied
108
+ if (result.improvements.length > 0) {
109
+ console.log(chalk.bold.magenta('✨ Improvements Applied:\n'));
110
+ result.improvements.forEach((improvement) => {
111
+ const emoji = improvement.impact === 'high' ? 'šŸ”„' : improvement.impact === 'medium' ? '⚔' : 'šŸ’”';
112
+ console.log(chalk.magenta(` ${emoji} ${improvement.description}`));
134
113
  });
114
+ console.log();
135
115
  }
136
- console.log();
137
- // Overall score
138
- const overallColor = getScoreColor(clearScore.overall);
139
- console.log(overallColor.bold(` Overall CLEAR Score: ${clearScore.overall.toFixed(0)}% (${clearScore.rating})\n`));
140
- // Recommendation for deep mode
141
- console.log(chalk.blue.bold('šŸ’” Recommendation:'));
142
- console.log(chalk.blue(' For Adaptive variations (A) and Reflective validation (R), use:'));
143
- console.log(chalk.cyan(' clavix deep "<your prompt>"\n'));
144
- // Display improved prompt
145
- console.log(chalk.bold.cyan('✨ CLEAR-Optimized Prompt:\n'));
116
+ // Display enhanced prompt
117
+ console.log(chalk.bold.cyan('✨ Enhanced Prompt:\n'));
146
118
  console.log(chalk.dim('─'.repeat(80)));
147
- console.log(clearResult.improvedPrompt);
119
+ console.log(result.enhanced);
148
120
  console.log(chalk.dim('─'.repeat(80)));
149
121
  console.log();
150
- // Changes made (CLEAR-labeled)
151
- if (clearResult.changesSummary.length > 0) {
152
- console.log(chalk.bold.magenta('šŸ“ CLEAR Changes Made:\n'));
153
- clearResult.changesSummary.forEach((change) => {
154
- const label = chalk.bold(`[${change.component}]`);
155
- console.log(chalk.magenta(` ${label} ${change.change}`));
156
- });
157
- console.log();
122
+ // Recommendation
123
+ const recommendation = new UniversalOptimizer().getRecommendation(result);
124
+ if (recommendation) {
125
+ console.log(chalk.blue.bold('šŸ’” Recommendation:'));
126
+ console.log(chalk.blue(` ${recommendation}\n`));
158
127
  }
159
- console.log(chalk.gray('šŸ’” Tip: Copy the CLEAR-optimized prompt above and use it with your AI agent\n'));
128
+ console.log(chalk.gray(`⚔ Processed in ${result.processingTimeMs}ms\n`));
129
+ console.log(chalk.gray('šŸ’” Tip: Copy the enhanced prompt above and use it with your AI agent\n'));
160
130
  }
161
- displayDeepModeOutput(result, clearResult, clearScore) {
162
- console.log(chalk.bold.cyan('šŸŽÆ CLEAR Framework Deep Analysis\n'));
163
- // Display CLEAR Assessment (all 5 components for deep mode)
164
- console.log(chalk.bold('šŸ“Š Framework Assessment:\n'));
131
+ displayDeepModeOutput(result) {
132
+ console.log(chalk.bold.cyan('šŸ” Deep Analysis Complete\n'));
133
+ // Intent Analysis
134
+ console.log(chalk.bold.cyan('šŸŽÆ Intent Analysis:\n'));
135
+ console.log(chalk.cyan(` Type: ${result.intent.primaryIntent}`));
136
+ console.log(chalk.cyan(` Confidence: ${result.intent.confidence}%`));
137
+ console.log(chalk.cyan(` Characteristics:`));
138
+ console.log(chalk.cyan(` • Has code context: ${result.intent.characteristics.hasCodeContext ? 'Yes' : 'No'}`));
139
+ console.log(chalk.cyan(` • Technical terms: ${result.intent.characteristics.hasTechnicalTerms ? 'Yes' : 'No'}`));
140
+ console.log(chalk.cyan(` • Open-ended: ${result.intent.characteristics.isOpenEnded ? 'Yes' : 'No'}`));
141
+ console.log(chalk.cyan(` • Needs structure: ${result.intent.characteristics.needsStructure ? 'Yes' : 'No'}`));
142
+ console.log();
143
+ // Quality Metrics
144
+ console.log(chalk.bold('šŸ“Š Quality Metrics:\n'));
165
145
  const getScoreColor = (score) => {
166
146
  if (score >= 80)
167
147
  return chalk.green;
@@ -169,228 +149,71 @@ export default class Fast extends Command {
169
149
  return chalk.yellow;
170
150
  return chalk.red;
171
151
  };
172
- // C, L, E (same as fast mode)
173
- const cColor = getScoreColor(clearScore.conciseness);
174
- console.log(cColor(` [C] Concise: ${clearScore.conciseness.toFixed(0)}%`));
175
- clearResult.conciseness.suggestions.forEach((s) => console.log(cColor(` ${s}`)));
176
- console.log();
177
- const lColor = getScoreColor(clearScore.logic);
178
- console.log(lColor(` [L] Logical: ${clearScore.logic.toFixed(0)}%`));
179
- clearResult.logic.suggestions.forEach((s) => console.log(lColor(` ${s}`)));
180
- console.log();
181
- const eColor = getScoreColor(clearScore.explicitness);
182
- console.log(eColor(` [E] Explicit: ${clearScore.explicitness.toFixed(0)}%`));
183
- clearResult.explicitness.suggestions.forEach((s) => console.log(eColor(` ${s}`)));
184
- console.log();
185
- // A, R (deep mode only)
186
- if (clearResult.adaptiveness) {
187
- const aColor = getScoreColor(clearScore.adaptiveness || 0);
188
- console.log(aColor(` [A] Adaptive: ${(clearScore.adaptiveness || 0).toFixed(0)}%`));
189
- console.log(aColor(` See "Adaptive Variations" section below`));
190
- console.log();
191
- }
192
- if (clearResult.reflectiveness) {
193
- const rColor = getScoreColor(clearScore.reflectiveness || 0);
194
- console.log(rColor(` [R] Reflective: ${(clearScore.reflectiveness || 0).toFixed(0)}%`));
195
- console.log(rColor(` See "Reflection Checklist" section below`));
152
+ console.log(getScoreColor(result.quality.clarity)(` Clarity: ${result.quality.clarity.toFixed(0)}%`));
153
+ console.log(getScoreColor(result.quality.efficiency)(` Efficiency: ${result.quality.efficiency.toFixed(0)}%`));
154
+ console.log(getScoreColor(result.quality.structure)(` Structure: ${result.quality.structure.toFixed(0)}%`));
155
+ console.log(getScoreColor(result.quality.completeness)(` Completeness: ${result.quality.completeness.toFixed(0)}%`));
156
+ console.log(getScoreColor(result.quality.actionability)(` Actionability: ${result.quality.actionability.toFixed(0)}%`));
157
+ console.log(getScoreColor(result.quality.overall).bold(`\n Overall: ${result.quality.overall.toFixed(0)}%\n`));
158
+ // Improvements Applied
159
+ if (result.improvements.length > 0) {
160
+ console.log(chalk.bold.magenta('✨ Improvements Applied:\n'));
161
+ result.improvements.forEach((improvement) => {
162
+ const emoji = improvement.impact === 'high' ? 'šŸ”„' : improvement.impact === 'medium' ? '⚔' : 'šŸ’”';
163
+ console.log(chalk.magenta(` ${emoji} ${improvement.description} [${improvement.dimension}]`));
164
+ });
196
165
  console.log();
197
166
  }
198
- // Overall
199
- const overallColor = getScoreColor(clearScore.overall);
200
- console.log(overallColor.bold(` Overall CLEAR Score: ${clearScore.overall.toFixed(0)}% (${clearScore.rating})\n`));
201
- // Display improved prompt
202
- console.log(chalk.bold.cyan('✨ CLEAR-Optimized Prompt:\n'));
167
+ // Enhanced Prompt
168
+ console.log(chalk.bold.cyan('✨ Enhanced Prompt:\n'));
203
169
  console.log(chalk.dim('─'.repeat(80)));
204
- console.log(clearResult.improvedPrompt);
170
+ console.log(result.enhanced);
205
171
  console.log(chalk.dim('─'.repeat(80)));
206
172
  console.log();
207
- // Changes made
208
- if (clearResult.changesSummary.length > 0) {
209
- console.log(chalk.bold.magenta('šŸ“ CLEAR Changes Made:\n'));
210
- clearResult.changesSummary.forEach((change) => {
211
- console.log(chalk.magenta(` [${change.component}] ${change.change}`));
173
+ // Deep mode features would go here (alternatives, edge cases, validation)
174
+ // TODO: Implement deep mode patterns to generate these
175
+ // Patterns Applied
176
+ if (result.appliedPatterns.length > 0) {
177
+ console.log(chalk.bold.blue('🧩 Patterns Applied:\n'));
178
+ result.appliedPatterns.forEach((pattern) => {
179
+ console.log(chalk.blue(` • ${pattern.name}: ${pattern.description}`));
212
180
  });
213
181
  console.log();
214
182
  }
215
- // Adaptive Variations (A)
216
- if (clearResult.adaptiveness) {
217
- console.log(chalk.bold.cyan('šŸ”„ Adaptive Variations:\n'));
218
- if (clearResult.adaptiveness.alternativePhrasings.length > 0) {
219
- console.log(chalk.cyan(' Alternative Phrasings:'));
220
- clearResult.adaptiveness.alternativePhrasings.forEach((p, i) => {
221
- console.log(chalk.cyan(` ${i + 1}. ${p}`));
222
- });
223
- console.log();
224
- }
225
- if (clearResult.adaptiveness.alternativeStructures.length > 0) {
226
- console.log(chalk.cyan(' Alternative Structures:'));
227
- clearResult.adaptiveness.alternativeStructures.forEach((alt, i) => {
228
- console.log(chalk.cyan(` ${i + 1}. ${alt.name}`));
229
- console.log(chalk.gray(` ${alt.benefits}`));
230
- });
231
- console.log();
232
- }
233
- if (clearResult.adaptiveness.temperatureRecommendation !== undefined) {
234
- console.log(chalk.cyan(` Recommended Temperature: ${clearResult.adaptiveness.temperatureRecommendation}`));
235
- console.log();
236
- }
237
- }
238
- // Reflection Checklist (R)
239
- if (clearResult.reflectiveness) {
240
- console.log(chalk.bold.yellow('šŸ¤” Reflection Checklist:\n'));
241
- if (clearResult.reflectiveness.validationChecklist.length > 0) {
242
- console.log(chalk.yellow(' Validation Steps:'));
243
- clearResult.reflectiveness.validationChecklist.forEach((item) => {
244
- console.log(chalk.yellow(` ☐ ${item}`));
245
- });
246
- console.log();
247
- }
248
- if (clearResult.reflectiveness.edgeCases.length > 0) {
249
- console.log(chalk.yellow(' Edge Cases to Consider:'));
250
- clearResult.reflectiveness.edgeCases.forEach((ec) => {
251
- console.log(chalk.yellow(` • ${ec}`));
252
- });
253
- console.log();
254
- }
255
- if (clearResult.reflectiveness.potentialIssues.length > 0) {
256
- console.log(chalk.yellow(' What Could Go Wrong:'));
257
- clearResult.reflectiveness.potentialIssues.forEach((issue) => {
258
- console.log(chalk.yellow(` • ${issue}`));
259
- });
260
- console.log();
261
- }
262
- if (clearResult.reflectiveness.factCheckingSteps.length > 0) {
263
- console.log(chalk.yellow(' Fact-Checking Steps:'));
264
- clearResult.reflectiveness.factCheckingSteps.forEach((step) => {
265
- console.log(chalk.yellow(` • ${step}`));
266
- });
267
- console.log();
268
- }
269
- }
270
- console.log(chalk.gray('šŸ’” Full CLEAR framework analysis complete!\n'));
183
+ console.log(chalk.gray(`⚔ Processed in ${result.processingTimeMs}ms\n`));
184
+ console.log(chalk.gray('šŸ’” Tip: Consider the alternatives and validation items above\n'));
271
185
  }
272
- displayCLEAROnlyAnalysis(clearResult, clearScore) {
273
- console.log(chalk.bold.cyan('šŸŽÆ CLEAR Framework Analysis Only\n'));
274
- const getScoreColor = (score) => {
275
- if (score >= 80)
276
- return chalk.green;
277
- if (score >= 60)
278
- return chalk.yellow;
279
- return chalk.red;
280
- };
281
- console.log(chalk.bold('šŸ“Š CLEAR Assessment:\n'));
282
- // Conciseness
283
- const cColor = getScoreColor(clearScore.conciseness);
284
- console.log(cColor.bold(` [C] Conciseness: ${clearScore.conciseness.toFixed(0)}%`));
285
- console.log(cColor(` Verbosity: ${clearResult.conciseness.verbosityCount} instances`));
286
- console.log(cColor(` Pleasantries: ${clearResult.conciseness.pleasantriesCount} instances`));
287
- console.log(cColor(` Signal-to-noise: ${clearResult.conciseness.signalToNoiseRatio.toFixed(2)}`));
288
- clearResult.conciseness.issues.forEach((issue) => {
289
- console.log(cColor(` • ${issue}`));
290
- });
291
- console.log();
292
- // Logic
293
- const lColor = getScoreColor(clearScore.logic);
294
- console.log(lColor.bold(` [L] Logic: ${clearScore.logic.toFixed(0)}%`));
295
- console.log(lColor(` Coherent Flow: ${clearResult.logic.hasCoherentFlow ? 'Yes' : 'No'}`));
296
- clearResult.logic.issues.forEach((issue) => {
297
- console.log(lColor(` • ${issue}`));
298
- });
299
- console.log();
300
- // Explicitness
301
- const eColor = getScoreColor(clearScore.explicitness);
302
- console.log(eColor.bold(` [E] Explicitness: ${clearScore.explicitness.toFixed(0)}%`));
303
- console.log(eColor(` Persona: ${clearResult.explicitness.hasPersona ? 'āœ“' : 'āœ—'}`));
304
- console.log(eColor(` Output Format: ${clearResult.explicitness.hasOutputFormat ? 'āœ“' : 'āœ—'}`));
305
- console.log(eColor(` Tone/Style: ${clearResult.explicitness.hasToneStyle ? 'āœ“' : 'āœ—'}`));
306
- console.log(eColor(` Success Criteria: ${clearResult.explicitness.hasSuccessCriteria ? 'āœ“' : 'āœ—'}`));
307
- console.log(eColor(` Examples: ${clearResult.explicitness.hasExamples ? 'āœ“' : 'āœ—'}`));
308
- clearResult.explicitness.issues.forEach((issue) => {
309
- console.log(eColor(` • ${issue}`));
310
- });
311
- console.log();
312
- // Overall
313
- const overallColor = getScoreColor(clearScore.overall);
314
- console.log(overallColor.bold(` Overall Score: ${clearScore.overall.toFixed(0)}% (${clearScore.rating})\n`));
315
- console.log(chalk.gray('Use without --clear-only flag to see improved prompt and changes.\n'));
186
+ displayAnalysisOnly(result) {
187
+ console.log(chalk.bold.cyan('šŸŽÆ Intent: '), chalk.cyan(result.intent.primaryIntent));
188
+ console.log(chalk.bold.cyan('šŸŽÆ Confidence: '), chalk.cyan(`${result.intent.confidence}%\n`));
189
+ console.log(chalk.bold('šŸ“Š Quality Scores:\n'));
190
+ console.log(chalk.white(` Clarity: ${result.quality.clarity.toFixed(0)}%`));
191
+ console.log(chalk.white(` Efficiency: ${result.quality.efficiency.toFixed(0)}%`));
192
+ console.log(chalk.white(` Structure: ${result.quality.structure.toFixed(0)}%`));
193
+ console.log(chalk.white(` Completeness: ${result.quality.completeness.toFixed(0)}%`));
194
+ console.log(chalk.white(` Actionability: ${result.quality.actionability.toFixed(0)}%`));
195
+ console.log(chalk.bold(`\n Overall: ${result.quality.overall.toFixed(0)}%\n`));
316
196
  }
317
- async savePrompt(improvedPrompt, originalPrompt, clearScore) {
197
+ async savePrompt(result) {
318
198
  try {
319
- const promptManager = new PromptManager();
320
- // Build content with CLEAR scores
321
- const content = `# Improved Prompt
322
-
323
- ${improvedPrompt}
324
-
325
- ## CLEAR Scores
326
- - **C** (Conciseness): ${clearScore.conciseness.toFixed(0)}%
327
- - **L** (Logic): ${clearScore.logic.toFixed(0)}%
328
- - **E** (Explicitness): ${clearScore.explicitness.toFixed(0)}%
329
- - **Overall**: ${clearScore.overall.toFixed(0)}% (${clearScore.rating})
330
-
331
- ## Original Prompt
332
- \`\`\`
333
- ${originalPrompt}
334
- \`\`\`
335
- `;
336
- const metadata = await promptManager.savePrompt(content, 'fast', originalPrompt);
337
- console.log(chalk.green(`\nāœ… Prompt saved to: ${metadata.filename}`));
338
- console.log(chalk.cyan(`\nšŸ’” Next steps:`));
339
- console.log(chalk.cyan(` /clavix:execute - Implement this prompt`));
340
- console.log(chalk.cyan(` /clavix:prompts - Review all saved prompts`));
341
- console.log();
199
+ const manager = new PromptManager();
200
+ // Format enhanced prompt as content
201
+ const content = result.enhanced;
202
+ await manager.savePrompt(content, 'fast', result.original);
203
+ console.log(chalk.gray(`šŸ’¾ Saved prompt to .clavix/outputs/prompts/fast/\n`));
342
204
  }
343
205
  catch (error) {
344
- // Don't fail the command if saving fails
345
- console.log(chalk.yellow(`\nāš ļø Could not save prompt: ${error}`));
206
+ console.log(chalk.yellow('āš ļø Could not save prompt to file system'));
346
207
  }
347
208
  }
348
- displayFrameworkInfo() {
349
- console.log(chalk.bold.cyan('\nšŸŽÆ CLEAR Framework for Prompt Engineering\n'));
350
- console.log(chalk.bold('What is CLEAR?\n'));
351
- console.log('CLEAR is an academically-validated framework for creating effective prompts:');
352
- console.log();
353
- console.log(chalk.green.bold(' [C] Concise'));
354
- console.log(chalk.green(' Eliminate verbosity and pleasantries'));
355
- console.log(chalk.green(' Focus on essential information'));
356
- console.log(chalk.green(' Example: "Please could you maybe help" → "Create"'));
357
- console.log();
358
- console.log(chalk.blue.bold(' [L] Logical'));
359
- console.log(chalk.blue(' Ensure coherent sequencing'));
360
- console.log(chalk.blue(' Structure: Context → Requirements → Constraints → Output'));
361
- console.log(chalk.blue(' Example: Put background before asking for results'));
362
- console.log();
363
- console.log(chalk.yellow.bold(' [E] Explicit'));
364
- console.log(chalk.yellow(' Specify persona, format, tone, and success criteria'));
365
- console.log(chalk.yellow(' Define exactly what you want'));
366
- console.log(chalk.yellow(' Example: "Build a dashboard" → "Build a React analytics dashboard with charts"'));
367
- console.log();
368
- console.log(chalk.magenta.bold(' [A] Adaptive (Deep Mode Only)'));
369
- console.log(chalk.magenta(' Provide alternative approaches'));
370
- console.log(chalk.magenta(' Flexibility and customization'));
371
- console.log(chalk.magenta(' Example: User story, job story, or structured formats'));
372
- console.log();
373
- console.log(chalk.cyan.bold(' [R] Reflective (Deep Mode Only)'));
374
- console.log(chalk.cyan(' Enable validation and quality checks'));
375
- console.log(chalk.cyan(' Edge cases and "what could go wrong"'));
376
- console.log(chalk.cyan(' Example: Fact-checking steps, success criteria validation'));
377
- console.log();
378
- console.log(chalk.bold('Academic Foundation:\n'));
379
- console.log(' Developed by: Dr. Leo Lo');
380
- console.log(' Institution: Dean of Libraries, University of New Mexico');
381
- console.log(' Published: Journal of Academic Librarianship, July 2023');
382
- console.log(' Paper: "The CLEAR Path: A Framework for Enhancing Information');
383
- console.log(' Literacy through Prompt Engineering"');
384
- console.log();
385
- console.log(chalk.bold('Resources:\n'));
386
- console.log(' • Framework Guide: https://guides.library.tamucc.edu/prompt-engineering/clear');
387
- console.log(' • Research Paper: https://digitalrepository.unm.edu/cgi/viewcontent.cgi?article=1214&context=ulls_fsp');
388
- console.log();
389
- console.log(chalk.bold('Usage in Clavix:\n'));
390
- console.log(chalk.cyan(' clavix fast "prompt"') + chalk.gray(' # Uses C, L, E components'));
391
- console.log(chalk.cyan(' clavix deep "prompt"') + chalk.gray(' # Uses full CLEAR (C, L, E, A, R)'));
392
- console.log(chalk.cyan(' clavix fast --clear-only') + chalk.gray(' # Show scores only, no improvement'));
393
- console.log();
209
+ generateShortHash(text) {
210
+ let hash = 0;
211
+ for (let i = 0; i < text.length; i++) {
212
+ const char = text.charCodeAt(i);
213
+ hash = ((hash << 5) - hash) + char;
214
+ hash = hash & hash;
215
+ }
216
+ return Math.abs(hash).toString(16).slice(0, 4);
394
217
  }
395
218
  }
396
219
  //# sourceMappingURL=fast.js.map