@bernierllc/content-workflow-ai-review-step 0.1.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/README.md +338 -0
- package/dist/ai-review-step.d.ts +45 -0
- package/dist/ai-review-step.d.ts.map +1 -0
- package/dist/ai-review-step.js +224 -0
- package/dist/ai-review-step.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/prompt-builder.d.ts +25 -0
- package/dist/prompt-builder.d.ts.map +1 -0
- package/dist/prompt-builder.js +162 -0
- package/dist/prompt-builder.js.map +1 -0
- package/dist/response-parser.d.ts +13 -0
- package/dist/response-parser.d.ts.map +1 -0
- package/dist/response-parser.js +277 -0
- package/dist/response-parser.js.map +1 -0
- package/dist/scoring.d.ts +54 -0
- package/dist/scoring.d.ts.map +1 -0
- package/dist/scoring.js +174 -0
- package/dist/scoring.js.map +1 -0
- package/dist/types.d.ts +205 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +32 -0
- package/dist/types.js.map +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# @bernierllc/content-workflow-ai-review-step
|
|
2
|
+
|
|
3
|
+
AI-powered content review workflow step with comprehensive analysis for grammar, SEO, tone, engagement, and readability.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Multi-Provider Support**: Works with OpenAI GPT-4 and Anthropic Claude via AI Provider Router
|
|
8
|
+
- **Comprehensive Analysis**: Grammar, SEO optimization, tone consistency, engagement potential, and readability
|
|
9
|
+
- **Structured Suggestions**: Location-aware suggestions with severity levels (critical, warning, suggestion)
|
|
10
|
+
- **Scoring System**: Overall score (0-100) plus category-specific scores
|
|
11
|
+
- **Custom Prompts**: Configurable review prompts per workflow
|
|
12
|
+
- **Cost Tracking**: Token usage and cost tracking per review
|
|
13
|
+
- **Event Publishing**: Optional NeverHub integration for real-time progress updates
|
|
14
|
+
- **Type-Safe**: Full TypeScript support with strict mode
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @bernierllc/content-workflow-ai-review-step
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { AIReviewStep } from '@bernierllc/content-workflow-ai-review-step';
|
|
26
|
+
import { AIProviderRouter } from '@bernierllc/ai-provider-router';
|
|
27
|
+
import { Logger } from '@bernierllc/logger';
|
|
28
|
+
|
|
29
|
+
// Initialize dependencies
|
|
30
|
+
const aiRouter = new AIProviderRouter({
|
|
31
|
+
providers: [
|
|
32
|
+
{
|
|
33
|
+
name: 'openai',
|
|
34
|
+
priority: 1,
|
|
35
|
+
enabled: true,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const logger = new Logger({ level: 'info' });
|
|
41
|
+
|
|
42
|
+
// Create review step
|
|
43
|
+
const reviewStep = new AIReviewStep(aiRouter, logger);
|
|
44
|
+
|
|
45
|
+
// Execute review
|
|
46
|
+
const result = await reviewStep.execute(
|
|
47
|
+
{
|
|
48
|
+
id: 'review-step-1',
|
|
49
|
+
name: 'AI Review',
|
|
50
|
+
type: 'ai_review',
|
|
51
|
+
enabled: true,
|
|
52
|
+
order: 0,
|
|
53
|
+
aiConfig: {
|
|
54
|
+
provider: 'openai',
|
|
55
|
+
model: 'gpt-4',
|
|
56
|
+
temperature: 0.3,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
content: {
|
|
61
|
+
id: 'article-123',
|
|
62
|
+
title: 'How to Write Great Content',
|
|
63
|
+
body: 'This is the article body...',
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (result.success && result.data) {
|
|
69
|
+
console.log('Overall Score:', result.data.overallScore);
|
|
70
|
+
console.log('Suggestions:', result.data.suggestions.length);
|
|
71
|
+
console.log('Summary:', result.data.summary);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
### Step Configuration
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
interface WorkflowStepConfig {
|
|
81
|
+
id: string; // Unique step identifier
|
|
82
|
+
name: string; // Step display name
|
|
83
|
+
type: 'ai_review'; // Must be 'ai_review'
|
|
84
|
+
enabled: boolean; // Whether step is active
|
|
85
|
+
order: number; // Execution order
|
|
86
|
+
aiConfig?: {
|
|
87
|
+
provider?: string; // 'openai', 'anthropic', or 'auto'
|
|
88
|
+
model?: string; // Specific model (e.g., 'gpt-4')
|
|
89
|
+
prompt?: string; // Custom review prompt
|
|
90
|
+
temperature?: number; // 0-1, default 0.3
|
|
91
|
+
maxTokens?: number; // 100-10000, default 2000
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Content Context
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
interface WorkflowContext {
|
|
100
|
+
content: {
|
|
101
|
+
id: string;
|
|
102
|
+
title?: string;
|
|
103
|
+
body: string;
|
|
104
|
+
metadata?: Record<string, unknown>;
|
|
105
|
+
};
|
|
106
|
+
userId?: string;
|
|
107
|
+
metadata?: Record<string, unknown>;
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Review Result Structure
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
interface AIReviewResult {
|
|
115
|
+
// Overall quality score (0-100)
|
|
116
|
+
overallScore: number;
|
|
117
|
+
|
|
118
|
+
// Category scores
|
|
119
|
+
scores: {
|
|
120
|
+
grammar: number; // 0-100
|
|
121
|
+
seo: number; // 0-100
|
|
122
|
+
tone: number; // 0-100
|
|
123
|
+
engagement: number; // 0-100
|
|
124
|
+
readability: number; // 0-100
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Actionable suggestions
|
|
128
|
+
suggestions: AIReviewSuggestion[];
|
|
129
|
+
|
|
130
|
+
// Summary of review
|
|
131
|
+
summary: string;
|
|
132
|
+
|
|
133
|
+
// Provider metadata
|
|
134
|
+
provider: string; // 'openai', 'anthropic'
|
|
135
|
+
model: string; // Model used
|
|
136
|
+
tokensUsed: number; // Tokens consumed
|
|
137
|
+
costUsd: number; // Estimated cost
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Suggestion Format
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
interface AIReviewSuggestion {
|
|
145
|
+
type: 'grammar' | 'seo' | 'tone' | 'engagement' | 'readability' | 'clarity';
|
|
146
|
+
severity: 'critical' | 'warning' | 'suggestion';
|
|
147
|
+
|
|
148
|
+
// Original problematic text
|
|
149
|
+
original: string;
|
|
150
|
+
|
|
151
|
+
// Suggested improvement
|
|
152
|
+
suggestion: string;
|
|
153
|
+
|
|
154
|
+
// Explanation
|
|
155
|
+
reason: string;
|
|
156
|
+
|
|
157
|
+
// Location (optional)
|
|
158
|
+
location?: {
|
|
159
|
+
line?: number;
|
|
160
|
+
column?: number;
|
|
161
|
+
offset?: number;
|
|
162
|
+
length?: number;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// User acceptance (optional)
|
|
166
|
+
accepted?: boolean;
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Advanced Usage
|
|
171
|
+
|
|
172
|
+
### Custom Review Prompts
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
const result = await reviewStep.execute(
|
|
176
|
+
{
|
|
177
|
+
id: 'custom-review',
|
|
178
|
+
name: 'Technical Blog Review',
|
|
179
|
+
type: 'ai_review',
|
|
180
|
+
enabled: true,
|
|
181
|
+
order: 0,
|
|
182
|
+
aiConfig: {
|
|
183
|
+
provider: 'openai',
|
|
184
|
+
prompt: `Review this technical blog post for:
|
|
185
|
+
1. Technical accuracy
|
|
186
|
+
2. Code example quality
|
|
187
|
+
3. Developer-friendly tone
|
|
188
|
+
4. SEO optimization for technical keywords
|
|
189
|
+
Provide specific, actionable feedback.`,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
context
|
|
193
|
+
);
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### With NeverHub Events
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
import { NeverHubAdapter } from '@bernierllc/neverhub-adapter';
|
|
200
|
+
|
|
201
|
+
const neverhub = new NeverHubAdapter();
|
|
202
|
+
await neverhub.register({
|
|
203
|
+
type: 'content-workflow',
|
|
204
|
+
capabilities: ['ai-review'],
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const reviewStep = new AIReviewStep(aiRouter, logger, neverhub);
|
|
208
|
+
|
|
209
|
+
// Events published:
|
|
210
|
+
// - ai.review.started
|
|
211
|
+
// - ai.review.completed
|
|
212
|
+
// - ai.review.failed
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Validation
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
const validation = reviewStep.validate(config);
|
|
219
|
+
|
|
220
|
+
if (!validation.valid) {
|
|
221
|
+
console.error('Config errors:', validation.errors);
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Utility Functions
|
|
226
|
+
|
|
227
|
+
### Prompt Building
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
import {
|
|
231
|
+
buildReviewPrompt,
|
|
232
|
+
buildQuickReviewPrompt,
|
|
233
|
+
estimateTokenCount
|
|
234
|
+
} from '@bernierllc/content-workflow-ai-review-step';
|
|
235
|
+
|
|
236
|
+
const prompt = buildReviewPrompt(content);
|
|
237
|
+
const quickPrompt = buildQuickReviewPrompt(content, ['grammar', 'clarity']);
|
|
238
|
+
const tokenEstimate = estimateTokenCount(prompt);
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Scoring Utilities
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import {
|
|
245
|
+
calculateOverallScore,
|
|
246
|
+
getQualityLevel,
|
|
247
|
+
getWeakestCategory,
|
|
248
|
+
compareScores,
|
|
249
|
+
} from '@bernierllc/content-workflow-ai-review-step';
|
|
250
|
+
|
|
251
|
+
const overall = calculateOverallScore(scores);
|
|
252
|
+
const quality = getQualityLevel(overall);
|
|
253
|
+
const weakness = getWeakestCategory(scores);
|
|
254
|
+
const improvement = compareScores(oldScores, newScores);
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Response Parsing
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
import {
|
|
261
|
+
parseReviewResponse,
|
|
262
|
+
validateReviewResult
|
|
263
|
+
} from '@bernierllc/content-workflow-ai-review-step';
|
|
264
|
+
|
|
265
|
+
const result = parseReviewResponse(
|
|
266
|
+
aiResponse,
|
|
267
|
+
'openai',
|
|
268
|
+
'gpt-4',
|
|
269
|
+
500,
|
|
270
|
+
0.01
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
const validation = validateReviewResult(result);
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Error Handling
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const result = await reviewStep.execute(config, context);
|
|
280
|
+
|
|
281
|
+
if (!result.success) {
|
|
282
|
+
console.error('Review failed:', result.error);
|
|
283
|
+
|
|
284
|
+
// Check metadata for partial info
|
|
285
|
+
if (result.metadata?.durationMs) {
|
|
286
|
+
console.log('Failed after', result.metadata.durationMs, 'ms');
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Performance Considerations
|
|
292
|
+
|
|
293
|
+
- **Token Usage**: Default maxTokens is 2000. Adjust based on content length.
|
|
294
|
+
- **Temperature**: Lower temperature (0.2-0.4) provides more consistent reviews.
|
|
295
|
+
- **Provider Selection**: Use 'auto' for automatic provider selection with failover.
|
|
296
|
+
- **Caching**: Results are NOT cached by default. Implement your own caching if needed.
|
|
297
|
+
|
|
298
|
+
## Testing
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Run tests
|
|
302
|
+
npm test
|
|
303
|
+
|
|
304
|
+
# Run with coverage
|
|
305
|
+
npm run test:coverage
|
|
306
|
+
|
|
307
|
+
# Run without watch mode
|
|
308
|
+
npm run test:run
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Requirements
|
|
312
|
+
|
|
313
|
+
- **Dependencies**:
|
|
314
|
+
- `@bernierllc/ai-provider-router` - AI provider routing
|
|
315
|
+
- `@bernierllc/logger` - Logging
|
|
316
|
+
- `@bernierllc/neverhub-adapter` (optional) - Event publishing
|
|
317
|
+
- **Environment**:
|
|
318
|
+
- Node.js 18+
|
|
319
|
+
- TypeScript 5.3+
|
|
320
|
+
|
|
321
|
+
## License
|
|
322
|
+
|
|
323
|
+
Copyright (c) 2025 Bernier LLC
|
|
324
|
+
|
|
325
|
+
This file is licensed to the client under a limited-use license.
|
|
326
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
327
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
328
|
+
|
|
329
|
+
## Related Packages
|
|
330
|
+
|
|
331
|
+
- [@bernierllc/ai-provider-router](../ai-provider-router) - AI provider selection and routing
|
|
332
|
+
- [@bernierllc/ai-content-reviewer](../ai-content-reviewer) - Content review logic
|
|
333
|
+
- [@bernierllc/content-editorial-workflow](../../core/content-editorial-workflow) - Workflow state machine
|
|
334
|
+
- [@bernierllc/content-workflow-step-manager](../content-workflow-step-manager) - Step orchestration
|
|
335
|
+
|
|
336
|
+
## Support
|
|
337
|
+
|
|
338
|
+
For issues and questions, please contact Bernier LLC.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Logger } from '@bernierllc/logger';
|
|
2
|
+
import type { AIProviderRouter } from '@bernierllc/ai-provider-router';
|
|
3
|
+
import type { NeverHubAdapter } from '@bernierllc/neverhub-adapter';
|
|
4
|
+
import type { BaseWorkflowStep, WorkflowStepConfig, WorkflowContext, WorkflowStepExecutionResult, ValidationResult, StepRequirements } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* AI-powered content review workflow step
|
|
7
|
+
*
|
|
8
|
+
* Analyzes content for:
|
|
9
|
+
* - Grammar and spelling
|
|
10
|
+
* - SEO optimization
|
|
11
|
+
* - Tone consistency
|
|
12
|
+
* - Engagement potential
|
|
13
|
+
* - Readability
|
|
14
|
+
*
|
|
15
|
+
* Returns structured suggestions with location information and severity levels.
|
|
16
|
+
*/
|
|
17
|
+
export declare class AIReviewStep implements BaseWorkflowStep {
|
|
18
|
+
private aiRouter;
|
|
19
|
+
private logger;
|
|
20
|
+
private neverhub?;
|
|
21
|
+
readonly id = "ai-review-step";
|
|
22
|
+
readonly type = "ai_review";
|
|
23
|
+
constructor(aiRouter: AIProviderRouter, logger: Logger, neverhub?: NeverHubAdapter | undefined);
|
|
24
|
+
/**
|
|
25
|
+
* Execute the AI review step
|
|
26
|
+
*/
|
|
27
|
+
execute(config: WorkflowStepConfig, context: WorkflowContext): Promise<WorkflowStepExecutionResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Perform the AI review using the router
|
|
30
|
+
*/
|
|
31
|
+
private performAIReview;
|
|
32
|
+
/**
|
|
33
|
+
* Validate step configuration
|
|
34
|
+
*/
|
|
35
|
+
validate(config: WorkflowStepConfig): ValidationResult;
|
|
36
|
+
/**
|
|
37
|
+
* Get step requirements
|
|
38
|
+
*/
|
|
39
|
+
getRequirements(): StepRequirements;
|
|
40
|
+
/**
|
|
41
|
+
* Publish NeverHub event if adapter is available
|
|
42
|
+
*/
|
|
43
|
+
private publishEvent;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=ai-review-step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-review-step.d.ts","sourceRoot":"","sources":["../src/ai-review-step.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,2BAA2B,EAC3B,gBAAgB,EAChB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAIpB;;;;;;;;;;;GAWG;AACH,qBAAa,YAAa,YAAW,gBAAgB;IAKjD,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,QAAQ,CAAC;IANnB,QAAQ,CAAC,EAAE,oBAAoB;IAC/B,QAAQ,CAAC,IAAI,eAAe;gBAGlB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,eAAe,YAAA;IAGpC;;OAEG;IACG,OAAO,CACX,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,2BAA2B,CAAC;IAoGvC;;OAEG;YACW,eAAe;IA+C7B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,gBAAgB;IAkDtD;;OAEG;IACH,eAAe,IAAI,gBAAgB;IAWnC;;OAEG;YACW,YAAY;CAsB3B"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2025 Bernier LLC
|
|
3
|
+
|
|
4
|
+
This file is licensed to the client under a limited-use license.
|
|
5
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
6
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
7
|
+
*/
|
|
8
|
+
import { buildReviewPrompt } from './prompt-builder.js';
|
|
9
|
+
import { parseReviewResponse } from './response-parser.js';
|
|
10
|
+
/**
|
|
11
|
+
* AI-powered content review workflow step
|
|
12
|
+
*
|
|
13
|
+
* Analyzes content for:
|
|
14
|
+
* - Grammar and spelling
|
|
15
|
+
* - SEO optimization
|
|
16
|
+
* - Tone consistency
|
|
17
|
+
* - Engagement potential
|
|
18
|
+
* - Readability
|
|
19
|
+
*
|
|
20
|
+
* Returns structured suggestions with location information and severity levels.
|
|
21
|
+
*/
|
|
22
|
+
export class AIReviewStep {
|
|
23
|
+
aiRouter;
|
|
24
|
+
logger;
|
|
25
|
+
neverhub;
|
|
26
|
+
id = 'ai-review-step';
|
|
27
|
+
type = 'ai_review';
|
|
28
|
+
constructor(aiRouter, logger, neverhub) {
|
|
29
|
+
this.aiRouter = aiRouter;
|
|
30
|
+
this.logger = logger;
|
|
31
|
+
this.neverhub = neverhub;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Execute the AI review step
|
|
35
|
+
*/
|
|
36
|
+
async execute(config, context) {
|
|
37
|
+
const startTime = Date.now();
|
|
38
|
+
this.logger.info(`Executing AI Review step for content: ${context.content.id}`);
|
|
39
|
+
try {
|
|
40
|
+
// Validate step is enabled
|
|
41
|
+
if (!config.enabled) {
|
|
42
|
+
return {
|
|
43
|
+
success: false,
|
|
44
|
+
error: 'Step is disabled',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Publish review started event
|
|
48
|
+
await this.publishEvent('ai.review.started', {
|
|
49
|
+
contentId: context.content.id,
|
|
50
|
+
stepId: config.id,
|
|
51
|
+
});
|
|
52
|
+
// Get AI configuration
|
|
53
|
+
const aiConfig = config.aiConfig || {};
|
|
54
|
+
const provider = aiConfig.provider || 'auto';
|
|
55
|
+
const customPrompt = aiConfig.prompt;
|
|
56
|
+
// Build review prompt
|
|
57
|
+
const prompt = buildReviewPrompt(context.content, customPrompt);
|
|
58
|
+
this.logger.debug('Built AI review prompt', {
|
|
59
|
+
promptLength: prompt.length,
|
|
60
|
+
provider,
|
|
61
|
+
});
|
|
62
|
+
// Perform AI review
|
|
63
|
+
const reviewResult = await this.performAIReview(prompt, provider, aiConfig.model, aiConfig.temperature, aiConfig.maxTokens);
|
|
64
|
+
const durationMs = Date.now() - startTime;
|
|
65
|
+
// Publish review completed event
|
|
66
|
+
await this.publishEvent('ai.review.completed', {
|
|
67
|
+
contentId: context.content.id,
|
|
68
|
+
stepId: config.id,
|
|
69
|
+
overallScore: reviewResult.overallScore,
|
|
70
|
+
suggestionCount: reviewResult.suggestions.length,
|
|
71
|
+
provider: reviewResult.provider,
|
|
72
|
+
durationMs,
|
|
73
|
+
});
|
|
74
|
+
this.logger.info('AI Review step completed successfully', {
|
|
75
|
+
contentId: context.content.id,
|
|
76
|
+
overallScore: reviewResult.overallScore,
|
|
77
|
+
suggestionCount: reviewResult.suggestions.length,
|
|
78
|
+
durationMs,
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
success: true,
|
|
82
|
+
data: reviewResult,
|
|
83
|
+
metadata: {
|
|
84
|
+
provider: reviewResult.provider,
|
|
85
|
+
model: reviewResult.model,
|
|
86
|
+
tokensUsed: reviewResult.tokensUsed,
|
|
87
|
+
costUsd: reviewResult.costUsd,
|
|
88
|
+
durationMs,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
const durationMs = Date.now() - startTime;
|
|
94
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
95
|
+
const errorObj = error instanceof Error ? error : new Error(errorMessage);
|
|
96
|
+
this.logger.error('AI Review step failed', errorObj, {
|
|
97
|
+
contentId: context.content.id,
|
|
98
|
+
durationMs,
|
|
99
|
+
});
|
|
100
|
+
// Publish review failed event
|
|
101
|
+
await this.publishEvent('ai.review.failed', {
|
|
102
|
+
contentId: context.content.id,
|
|
103
|
+
stepId: config.id,
|
|
104
|
+
error: errorMessage,
|
|
105
|
+
durationMs,
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
success: false,
|
|
109
|
+
error: errorMessage,
|
|
110
|
+
metadata: {
|
|
111
|
+
durationMs,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Perform the AI review using the router
|
|
118
|
+
*/
|
|
119
|
+
async performAIReview(prompt, provider, model, temperature, maxTokens) {
|
|
120
|
+
this.logger.debug('Routing AI review request', { provider, model });
|
|
121
|
+
// Route the request through the AI provider router
|
|
122
|
+
const routingResult = await this.aiRouter.route({
|
|
123
|
+
prompt,
|
|
124
|
+
maxTokens: maxTokens || 2000,
|
|
125
|
+
temperature: temperature ?? 0.3, // Lower temperature for more consistent reviews
|
|
126
|
+
model,
|
|
127
|
+
preferences: {
|
|
128
|
+
preferredProvider: provider === 'auto' ? undefined : provider,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
if (!routingResult.success || !routingResult.response) {
|
|
132
|
+
throw new Error(routingResult.error || 'AI provider routing failed with no response');
|
|
133
|
+
}
|
|
134
|
+
const response = routingResult.response;
|
|
135
|
+
const metadata = routingResult.metadata;
|
|
136
|
+
this.logger.debug('Received AI review response', {
|
|
137
|
+
provider: metadata.selectedProvider,
|
|
138
|
+
tokensUsed: response.tokensUsed,
|
|
139
|
+
cost: metadata.cost,
|
|
140
|
+
});
|
|
141
|
+
// Parse the AI response into structured review result
|
|
142
|
+
const reviewResult = parseReviewResponse(response.content, metadata.selectedProvider, response.model, response.tokensUsed, metadata.cost);
|
|
143
|
+
return reviewResult;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Validate step configuration
|
|
147
|
+
*/
|
|
148
|
+
validate(config) {
|
|
149
|
+
const errors = [];
|
|
150
|
+
// Check required fields
|
|
151
|
+
if (!config.id) {
|
|
152
|
+
errors.push('Step config must have an id');
|
|
153
|
+
}
|
|
154
|
+
if (!config.name) {
|
|
155
|
+
errors.push('Step config must have a name');
|
|
156
|
+
}
|
|
157
|
+
if (!config.type) {
|
|
158
|
+
errors.push('Step config must have a type');
|
|
159
|
+
}
|
|
160
|
+
// Check step type matches
|
|
161
|
+
if (config.type !== 'ai_review') {
|
|
162
|
+
errors.push('Step type must be "ai_review"');
|
|
163
|
+
}
|
|
164
|
+
// Validate AI config if present
|
|
165
|
+
if (config.aiConfig) {
|
|
166
|
+
const aiConfig = config.aiConfig;
|
|
167
|
+
if (aiConfig.temperature !== undefined) {
|
|
168
|
+
if (aiConfig.temperature < 0 || aiConfig.temperature > 1) {
|
|
169
|
+
errors.push('Temperature must be between 0 and 1');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (aiConfig.maxTokens !== undefined) {
|
|
173
|
+
if (aiConfig.maxTokens < 100 || aiConfig.maxTokens > 10000) {
|
|
174
|
+
errors.push('maxTokens must be between 100 and 10000');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (aiConfig.prompt !== undefined) {
|
|
178
|
+
if (typeof aiConfig.prompt !== 'string' || aiConfig.prompt.trim().length === 0) {
|
|
179
|
+
errors.push('Custom prompt must be a non-empty string');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
valid: errors.length === 0,
|
|
185
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get step requirements
|
|
190
|
+
*/
|
|
191
|
+
getRequirements() {
|
|
192
|
+
return {
|
|
193
|
+
permissions: ['ai:review', 'content:read'],
|
|
194
|
+
dependencies: [
|
|
195
|
+
'@bernierllc/ai-provider-router',
|
|
196
|
+
'@bernierllc/ai-content-reviewer',
|
|
197
|
+
'@bernierllc/logger',
|
|
198
|
+
],
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Publish NeverHub event if adapter is available
|
|
203
|
+
*/
|
|
204
|
+
async publishEvent(eventType, data) {
|
|
205
|
+
if (!this.neverhub) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
await this.neverhub.publishEvent({
|
|
210
|
+
type: eventType,
|
|
211
|
+
data,
|
|
212
|
+
timestamp: new Date().toISOString(),
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
// Log but don't fail the step if event publishing fails
|
|
217
|
+
this.logger.warn('Failed to publish NeverHub event', {
|
|
218
|
+
eventType,
|
|
219
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=ai-review-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-review-step.js","sourceRoot":"","sources":["../src/ai-review-step.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAcF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,YAAY;IAKb;IACA;IACA;IAND,EAAE,GAAG,gBAAgB,CAAC;IACtB,IAAI,GAAG,WAAW,CAAC;IAE5B,YACU,QAA0B,EAC1B,MAAc,EACd,QAA0B;QAF1B,aAAQ,GAAR,QAAQ,CAAkB;QAC1B,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAkB;IACjC,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,MAA0B,EAC1B,OAAwB;QAExB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yCAAyC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QAEhF,IAAI,CAAC;YACH,2BAA2B;YAC3B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;g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
2
|
+
export type { AIReviewSuggestion, AIReviewResult, ReviewScores, SuggestionType, SeverityLevel, SuggestionLocation, WorkflowStepConfig, WorkflowContent, WorkflowContext, WorkflowStepExecutionResult, ValidationResult, StepRequirements, WorkflowStep, BaseWorkflowStep, } from './types.js';
|
|
3
|
+
export { buildReviewPrompt, buildQuickReviewPrompt, validatePrompt, estimateTokenCount, DEFAULT_REVIEW_PROMPT, } from './prompt-builder.js';
|
|
4
|
+
export { parseReviewResponse, validateReviewResult } from './response-parser.js';
|
|
5
|
+
export { calculateOverallScore, calculateSimpleAverage, getQualityLevel, calculateImprovementPotential, compareScores, getWeakestCategory, getStrongestCategory, calculateConsistencyScore, } from './scoring.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,2BAA2B,EAC3B,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,6BAA6B,EAC7B,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2025 Bernier LLC
|
|
3
|
+
|
|
4
|
+
This file is licensed to the client under a limited-use license.
|
|
5
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
6
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
7
|
+
*/
|
|
8
|
+
// Main step class
|
|
9
|
+
export { AIReviewStep } from './ai-review-step.js';
|
|
10
|
+
// Utilities
|
|
11
|
+
export { buildReviewPrompt, buildQuickReviewPrompt, validatePrompt, estimateTokenCount, DEFAULT_REVIEW_PROMPT, } from './prompt-builder.js';
|
|
12
|
+
export { parseReviewResponse, validateReviewResult } from './response-parser.js';
|
|
13
|
+
export { calculateOverallScore, calculateSimpleAverage, getQualityLevel, calculateImprovementPotential, compareScores, getWeakestCategory, getStrongestCategory, calculateConsistencyScore, } from './scoring.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,kBAAkB;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAoBnD,YAAY;AACZ,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,EACf,6BAA6B,EAC7B,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { WorkflowContent } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Default system prompt for AI content review
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_REVIEW_PROMPT = "You are an expert content reviewer and editor. Analyze the provided content for:\n\n1. Grammar and spelling errors\n2. SEO optimization (keyword usage, readability, structure)\n3. Tone consistency and appropriateness\n4. Engagement potential (hooks, call-to-actions, readability)\n5. Clarity and readability\n\nProvide actionable, specific suggestions for improvement with exact locations.";
|
|
6
|
+
/**
|
|
7
|
+
* Build a comprehensive review prompt for AI
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildReviewPrompt(content: WorkflowContent, customPrompt?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Build a simplified prompt for quick reviews
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildQuickReviewPrompt(content: WorkflowContent, focusAreas?: string[]): string;
|
|
14
|
+
/**
|
|
15
|
+
* Validate that a prompt is well-formed
|
|
16
|
+
*/
|
|
17
|
+
export declare function validatePrompt(prompt: string): {
|
|
18
|
+
valid: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Estimate token count for a prompt (rough approximation)
|
|
23
|
+
*/
|
|
24
|
+
export declare function estimateTokenCount(prompt: string): number;
|
|
25
|
+
//# sourceMappingURL=prompt-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../src/prompt-builder.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,qBAAqB,0YAQ6C,CAAC;AAEhF;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,eAAe,EACxB,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAcR;AAiFD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,eAAe,EACxB,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,MAAM,CA6BR;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAUjF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAGzD"}
|