@bernierllc/content-workflow-ai-review-step 0.8.1 → 0.8.3
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/LICENSE +5 -0
- package/package.json +5 -5
- package/dist/ai-review-step.d.ts +0 -45
- package/dist/ai-review-step.d.ts.map +0 -1
- package/dist/ai-review-step.js +0 -224
- package/dist/ai-review-step.js.map +0 -1
- package/dist/errors.d.ts +0 -12
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -21
- package/dist/errors.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -15
- package/dist/index.js.map +0 -1
- package/dist/prompt-builder.d.ts +0 -25
- package/dist/prompt-builder.d.ts.map +0 -1
- package/dist/prompt-builder.js +0 -162
- package/dist/prompt-builder.js.map +0 -1
- package/dist/response-parser.d.ts +0 -13
- package/dist/response-parser.d.ts.map +0 -1
- package/dist/response-parser.js +0 -277
- package/dist/response-parser.js.map +0 -1
- package/dist/scoring.d.ts +0 -54
- package/dist/scoring.d.ts.map +0 -1
- package/dist/scoring.js +0 -174
- package/dist/scoring.js.map +0 -1
- package/dist/types.d.ts +0 -205
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -32
- package/dist/types.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Copyright (c) 2025 Bernier LLC
|
|
2
|
+
|
|
3
|
+
This file is licensed to the client under a limited-use license.
|
|
4
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
5
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bernierllc/content-workflow-ai-review-step",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "AI-powered content review workflow step with grammar, SEO, tone, and engagement analysis",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"registry": "https://registry.npmjs.org/"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@bernierllc/
|
|
44
|
-
"@bernierllc/ai-provider-router": "1.7.
|
|
45
|
-
"@bernierllc/
|
|
46
|
-
"@bernierllc/
|
|
43
|
+
"@bernierllc/ai-content-reviewer": "^1.4.3",
|
|
44
|
+
"@bernierllc/ai-provider-router": "^1.7.3",
|
|
45
|
+
"@bernierllc/logger": "^2.0.0",
|
|
46
|
+
"@bernierllc/neverhub-adapter": "^0.4.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/jest": "^29.5.12",
|
package/dist/ai-review-step.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/ai-review-step.js
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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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AC,YAAY,CACxB,SAAiB,EACjB,IAA6B;QAE7B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;gBAC/B,IAAI,EAAE,SAAS;gBACf,IAAI;gBACJ,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACpC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,wDAAwD;YACxD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE;gBACnD,SAAS;gBACT,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;aAChE,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
|
package/dist/errors.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type ContentWorkflowAiReviewStepErrorCode = 'CONTENT_WORKFLOW_AI_REVIEW_STEP_ERROR' | 'INVALID_INPUT' | 'OPERATION_FAILED';
|
|
2
|
-
export interface ContentWorkflowAiReviewStepErrorOptions {
|
|
3
|
-
cause?: Error;
|
|
4
|
-
code?: ContentWorkflowAiReviewStepErrorCode;
|
|
5
|
-
context?: Record<string, unknown>;
|
|
6
|
-
}
|
|
7
|
-
export declare class ContentWorkflowAiReviewStepError extends Error {
|
|
8
|
-
readonly code: ContentWorkflowAiReviewStepErrorCode;
|
|
9
|
-
readonly context?: Record<string, unknown>;
|
|
10
|
-
constructor(message: string, options?: ContentWorkflowAiReviewStepErrorOptions);
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,oCAAoC,GAC5C,uCAAuC,GACvC,eAAe,GACf,kBAAkB,CAAC;AAEvB,MAAM,WAAW,uCAAuC;IACtD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,oCAAoC,CAAC;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,qBAAa,gCAAiC,SAAQ,KAAK;IACzD,QAAQ,CAAC,IAAI,EAAE,oCAAoC,CAAC;IACpD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAE/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,uCAAuC;CAS/E"}
|
package/dist/errors.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
export class ContentWorkflowAiReviewStepError extends Error {
|
|
9
|
-
code;
|
|
10
|
-
context;
|
|
11
|
-
constructor(message, options) {
|
|
12
|
-
super(message, options?.cause ? { cause: options.cause } : undefined);
|
|
13
|
-
this.name = 'ContentWorkflowAiReviewStepError';
|
|
14
|
-
this.code = options?.code ?? 'CONTENT_WORKFLOW_AI_REVIEW_STEP_ERROR';
|
|
15
|
-
if (options?.context !== undefined) {
|
|
16
|
-
this.context = options.context;
|
|
17
|
-
}
|
|
18
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAaF,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IAChD,IAAI,CAAuC;IAC3C,OAAO,CAA2B;IAE3C,YAAY,OAAe,EAAE,OAAiD;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,uCAAuC,CAAC;QACrE,IAAI,OAAO,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACF"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { AIReviewStep } from './ai-review-step.js';
|
|
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
|
-
export { ContentWorkflowAiReviewStepError, type ContentWorkflowAiReviewStepErrorCode, type ContentWorkflowAiReviewStepErrorOptions } from './errors.js';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AAEtB,OAAO,EAAE,gCAAgC,EAAE,KAAK,oCAAoC,EAAE,KAAK,uCAAuC,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
export { ContentWorkflowAiReviewStepError } from './errors.js';
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AAEtB,OAAO,EAAE,gCAAgC,EAA2F,MAAM,aAAa,CAAC"}
|
package/dist/prompt-builder.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/prompt-builder.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
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
|
-
/**
|
|
9
|
-
* Default system prompt for AI content review
|
|
10
|
-
*/
|
|
11
|
-
export const DEFAULT_REVIEW_PROMPT = `You are an expert content reviewer and editor. Analyze the provided content for:
|
|
12
|
-
|
|
13
|
-
1. Grammar and spelling errors
|
|
14
|
-
2. SEO optimization (keyword usage, readability, structure)
|
|
15
|
-
3. Tone consistency and appropriateness
|
|
16
|
-
4. Engagement potential (hooks, call-to-actions, readability)
|
|
17
|
-
5. Clarity and readability
|
|
18
|
-
|
|
19
|
-
Provide actionable, specific suggestions for improvement with exact locations.`;
|
|
20
|
-
/**
|
|
21
|
-
* Build a comprehensive review prompt for AI
|
|
22
|
-
*/
|
|
23
|
-
export function buildReviewPrompt(content, customPrompt) {
|
|
24
|
-
const basePrompt = customPrompt || DEFAULT_REVIEW_PROMPT;
|
|
25
|
-
const contentSection = formatContentSection(content);
|
|
26
|
-
const instructionsSection = formatInstructionsSection();
|
|
27
|
-
const outputFormatSection = formatOutputFormatSection();
|
|
28
|
-
return `${basePrompt}
|
|
29
|
-
|
|
30
|
-
${contentSection}
|
|
31
|
-
|
|
32
|
-
${instructionsSection}
|
|
33
|
-
|
|
34
|
-
${outputFormatSection}`;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Format the content section of the prompt
|
|
38
|
-
*/
|
|
39
|
-
function formatContentSection(content) {
|
|
40
|
-
const title = content.title || 'Untitled';
|
|
41
|
-
const body = content.body.trim();
|
|
42
|
-
return `## Content to Review
|
|
43
|
-
|
|
44
|
-
**Title:** ${title}
|
|
45
|
-
|
|
46
|
-
**Body:**
|
|
47
|
-
${body}`;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Format the instructions section
|
|
51
|
-
*/
|
|
52
|
-
function formatInstructionsSection() {
|
|
53
|
-
return `## Review Instructions
|
|
54
|
-
|
|
55
|
-
Analyze the content and provide:
|
|
56
|
-
1. An overall quality score (0-100)
|
|
57
|
-
2. Individual scores for each category (grammar, SEO, tone, engagement, readability)
|
|
58
|
-
3. Specific, actionable suggestions with:
|
|
59
|
-
- Type of issue (grammar/seo/tone/engagement/readability/clarity)
|
|
60
|
-
- Severity (critical/warning/suggestion)
|
|
61
|
-
- Original text
|
|
62
|
-
- Suggested replacement
|
|
63
|
-
- Reason for the suggestion
|
|
64
|
-
- Location (line number, character offset if possible)
|
|
65
|
-
4. A brief summary of the review`;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Format the output format section with JSON schema
|
|
69
|
-
*/
|
|
70
|
-
function formatOutputFormatSection() {
|
|
71
|
-
return `## Output Format
|
|
72
|
-
|
|
73
|
-
Return your response as valid JSON matching this structure:
|
|
74
|
-
|
|
75
|
-
\`\`\`json
|
|
76
|
-
{
|
|
77
|
-
"overallScore": <number 0-100>,
|
|
78
|
-
"scores": {
|
|
79
|
-
"grammar": <number 0-100>,
|
|
80
|
-
"seo": <number 0-100>,
|
|
81
|
-
"tone": <number 0-100>,
|
|
82
|
-
"engagement": <number 0-100>,
|
|
83
|
-
"readability": <number 0-100>
|
|
84
|
-
},
|
|
85
|
-
"suggestions": [
|
|
86
|
-
{
|
|
87
|
-
"type": "grammar|seo|tone|engagement|readability|clarity",
|
|
88
|
-
"severity": "critical|warning|suggestion",
|
|
89
|
-
"original": "the problematic text",
|
|
90
|
-
"suggestion": "the improved text",
|
|
91
|
-
"reason": "explanation of why this change improves the content",
|
|
92
|
-
"location": {
|
|
93
|
-
"line": <line number>,
|
|
94
|
-
"column": <column number>,
|
|
95
|
-
"offset": <character offset>,
|
|
96
|
-
"length": <text length>
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
],
|
|
100
|
-
"summary": "A brief summary of the overall review and key findings"
|
|
101
|
-
}
|
|
102
|
-
\`\`\`
|
|
103
|
-
|
|
104
|
-
**Important:**
|
|
105
|
-
- Return ONLY valid JSON, no markdown code fences or additional text
|
|
106
|
-
- All scores must be numbers between 0 and 100
|
|
107
|
-
- Include at least 3-5 suggestions if issues are found
|
|
108
|
-
- Provide specific locations when possible
|
|
109
|
-
- Make suggestions actionable and specific`;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Build a simplified prompt for quick reviews
|
|
113
|
-
*/
|
|
114
|
-
export function buildQuickReviewPrompt(content, focusAreas) {
|
|
115
|
-
const areas = focusAreas || ['grammar', 'clarity'];
|
|
116
|
-
const areaList = areas.join(', ');
|
|
117
|
-
return `Review this content focusing on ${areaList}.
|
|
118
|
-
|
|
119
|
-
**Title:** ${content.title || 'Untitled'}
|
|
120
|
-
|
|
121
|
-
**Content:**
|
|
122
|
-
${content.body}
|
|
123
|
-
|
|
124
|
-
Provide a score (0-100) and top 3 suggestions as JSON:
|
|
125
|
-
|
|
126
|
-
\`\`\`json
|
|
127
|
-
{
|
|
128
|
-
"score": <number>,
|
|
129
|
-
"suggestions": [
|
|
130
|
-
{
|
|
131
|
-
"type": "${areas[0]}",
|
|
132
|
-
"severity": "critical|warning|suggestion",
|
|
133
|
-
"original": "text",
|
|
134
|
-
"suggestion": "improved text",
|
|
135
|
-
"reason": "explanation"
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
}
|
|
139
|
-
\`\`\`
|
|
140
|
-
|
|
141
|
-
Return only valid JSON, no markdown.`;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Validate that a prompt is well-formed
|
|
145
|
-
*/
|
|
146
|
-
export function validatePrompt(prompt) {
|
|
147
|
-
if (!prompt || prompt.trim().length === 0) {
|
|
148
|
-
return { valid: false, error: 'Prompt cannot be empty' };
|
|
149
|
-
}
|
|
150
|
-
if (prompt.length > 50000) {
|
|
151
|
-
return { valid: false, error: 'Prompt exceeds maximum length of 50,000 characters' };
|
|
152
|
-
}
|
|
153
|
-
return { valid: true };
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Estimate token count for a prompt (rough approximation)
|
|
157
|
-
*/
|
|
158
|
-
export function estimateTokenCount(prompt) {
|
|
159
|
-
// Rough estimate: ~4 characters per token
|
|
160
|
-
return Math.ceil(prompt.length / 4);
|
|
161
|
-
}
|
|
162
|
-
//# sourceMappingURL=prompt-builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../src/prompt-builder.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;+EAQ0C,CAAC;AAEhF;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAwB,EACxB,YAAqB;IAErB,MAAM,UAAU,GAAG,YAAY,IAAI,qBAAqB,CAAC;IAEzD,MAAM,cAAc,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACrD,MAAM,mBAAmB,GAAG,yBAAyB,EAAE,CAAC;IACxD,MAAM,mBAAmB,GAAG,yBAAyB,EAAE,CAAC;IAExD,OAAO,GAAG,UAAU;;EAEpB,cAAc;;EAEd,mBAAmB;;EAEnB,mBAAmB,EAAE,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,OAAwB;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAEjC,OAAO;;aAEI,KAAK;;;EAGhB,IAAI,EAAE,CAAC;AACT,CAAC;AAED;;GAEG;AACH,SAAS,yBAAyB;IAChC,OAAO;;;;;;;;;;;;iCAYwB,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAS,yBAAyB;IAChC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAsCkC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAwB,EACxB,UAAqB;IAErB,MAAM,KAAK,GAAG,UAAU,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElC,OAAO,mCAAmC,QAAQ;;aAEvC,OAAO,CAAC,KAAK,IAAI,UAAU;;;EAGtC,OAAO,CAAC,IAAI;;;;;;;;;iBASG,KAAK,CAAC,CAAC,CAAC;;;;;;;;;;qCAUY,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,wBAAwB,EAAE,CAAC;IAC3D,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;QAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,oDAAoD,EAAE,CAAC;IACvF,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,0CAA0C;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { AIReviewResult } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Parse AI response into structured review result
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseReviewResponse(responseContent: string, provider: string, model: string, tokensUsed: number, costUsd: number): AIReviewResult;
|
|
6
|
-
/**
|
|
7
|
-
* Validate that a parsed result is well-formed
|
|
8
|
-
*/
|
|
9
|
-
export declare function validateReviewResult(result: AIReviewResult): {
|
|
10
|
-
valid: boolean;
|
|
11
|
-
errors: string[];
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=response-parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-parser.d.ts","sourceRoot":"","sources":["../src/response-parser.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EAKf,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,GACd,cAAc,CAuChB;AAyOD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG;IAC5D,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CA6CA"}
|