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.
- package/README.md +26 -6
- package/dist/cli/commands/deep.d.ts +3 -4
- package/dist/cli/commands/deep.js +162 -261
- package/dist/cli/commands/fast.d.ts +3 -4
- package/dist/cli/commands/fast.js +126 -303
- package/dist/cli/commands/init.js +184 -22
- package/dist/cli/commands/prd.d.ts +7 -6
- package/dist/cli/commands/prd.js +113 -132
- package/dist/cli/commands/summarize.d.ts +1 -12
- package/dist/cli/commands/summarize.js +63 -131
- package/dist/core/intelligence/index.d.ts +10 -0
- package/dist/core/intelligence/index.js +13 -0
- package/dist/core/intelligence/intent-detector.d.ts +33 -0
- package/dist/core/intelligence/intent-detector.js +311 -0
- package/dist/core/intelligence/pattern-library.d.ts +44 -0
- package/dist/core/intelligence/pattern-library.js +103 -0
- package/dist/core/intelligence/patterns/actionability-enhancer.d.ts +27 -0
- package/dist/core/intelligence/patterns/actionability-enhancer.js +162 -0
- package/dist/core/intelligence/patterns/base-pattern.d.ts +31 -0
- package/dist/core/intelligence/patterns/base-pattern.js +39 -0
- package/dist/core/intelligence/patterns/completeness-validator.d.ts +27 -0
- package/dist/core/intelligence/patterns/completeness-validator.js +135 -0
- package/dist/core/intelligence/patterns/conciseness-filter.d.ts +12 -0
- package/dist/core/intelligence/patterns/conciseness-filter.js +61 -0
- package/dist/core/intelligence/patterns/objective-clarifier.d.ts +14 -0
- package/dist/core/intelligence/patterns/objective-clarifier.js +97 -0
- package/dist/core/intelligence/patterns/structure-organizer.d.ts +31 -0
- package/dist/core/intelligence/patterns/structure-organizer.js +185 -0
- package/dist/core/intelligence/patterns/technical-context-enricher.d.ts +16 -0
- package/dist/core/intelligence/patterns/technical-context-enricher.js +132 -0
- package/dist/core/intelligence/quality-assessor.d.ts +42 -0
- package/dist/core/intelligence/quality-assessor.js +296 -0
- package/dist/core/intelligence/types.d.ts +81 -0
- package/dist/core/intelligence/types.js +3 -0
- package/dist/core/intelligence/universal-optimizer.d.ts +31 -0
- package/dist/core/intelligence/universal-optimizer.js +118 -0
- package/dist/core/prd-generator.d.ts +2 -2
- package/dist/core/task-manager.js +18 -5
- package/dist/templates/agents/agents.md +2 -2
- package/dist/templates/agents/copilot-instructions.md +15 -15
- package/dist/templates/agents/octo.md +35 -30
- package/dist/templates/agents/warp.md +3 -3
- package/dist/templates/full-prd-template.hbs +1 -1
- package/dist/templates/prd-questions.md +1 -1
- package/dist/templates/quick-prd-template.hbs +1 -1
- package/dist/templates/slash-commands/_canonical/deep.md +261 -122
- package/dist/templates/slash-commands/_canonical/fast.md +101 -69
- package/dist/templates/slash-commands/_canonical/implement.md +1 -1
- package/dist/templates/slash-commands/_canonical/plan.md +12 -12
- package/dist/templates/slash-commands/_canonical/prd.md +34 -24
- package/dist/templates/slash-commands/_canonical/start.md +13 -12
- package/dist/templates/slash-commands/_canonical/summarize.md +42 -25
- package/dist/utils/error-utils.d.ts +7 -0
- package/dist/utils/error-utils.js +17 -0
- 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 {
|
|
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
|
|
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
|
-
'
|
|
14
|
-
description: 'Show only
|
|
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
|
|
41
|
-
const optimizer = new
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
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 (
|
|
56
|
-
console.log(chalk.yellow(` ā¢
|
|
39
|
+
if (result.intent.primaryIntent === 'planning') {
|
|
40
|
+
console.log(chalk.yellow(` ⢠Planning intent detected - benefits from comprehensive exploration`));
|
|
57
41
|
}
|
|
58
|
-
if (
|
|
59
|
-
console.log(chalk.yellow(` ā¢
|
|
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 (
|
|
62
|
-
console.log(chalk.yellow(` ā¢
|
|
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
|
|
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
|
|
82
|
-
|
|
83
|
-
|
|
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 --
|
|
90
|
-
if (flags['
|
|
91
|
-
this.
|
|
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
|
|
75
|
+
this.displayFastModeOutput(result);
|
|
96
76
|
// Save prompt to file system
|
|
97
|
-
await this.savePrompt(
|
|
77
|
+
await this.savePrompt(result);
|
|
98
78
|
}
|
|
99
|
-
displayFastModeOutput(result
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
console.log(chalk.
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
console.log(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
|
|
137
|
-
|
|
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(
|
|
119
|
+
console.log(result.enhanced);
|
|
148
120
|
console.log(chalk.dim('ā'.repeat(80)));
|
|
149
121
|
console.log();
|
|
150
|
-
//
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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(
|
|
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
|
|
162
|
-
console.log(chalk.bold.cyan('
|
|
163
|
-
//
|
|
164
|
-
console.log(chalk.bold('
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
console.log(
|
|
175
|
-
|
|
176
|
-
console.log();
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
//
|
|
199
|
-
|
|
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(
|
|
170
|
+
console.log(result.enhanced);
|
|
205
171
|
console.log(chalk.dim('ā'.repeat(80)));
|
|
206
172
|
console.log();
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
216
|
-
|
|
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
|
-
|
|
273
|
-
console.log(chalk.bold.cyan('šÆ
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
};
|
|
281
|
-
console.log(chalk.bold(
|
|
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(
|
|
197
|
+
async savePrompt(result) {
|
|
318
198
|
try {
|
|
319
|
-
const
|
|
320
|
-
//
|
|
321
|
-
const content =
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
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
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
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
|