@prenta/plugin-ai 0.6.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/CHANGELOG.md +326 -0
- package/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/__tests__/alt-text-prompt.test.d.ts +2 -0
- package/dist/__tests__/alt-text-prompt.test.d.ts.map +1 -0
- package/dist/__tests__/alt-text-prompt.test.js +15 -0
- package/dist/__tests__/alt-text-prompt.test.js.map +1 -0
- package/dist/__tests__/audit.test.d.ts +2 -0
- package/dist/__tests__/audit.test.d.ts.map +1 -0
- package/dist/__tests__/audit.test.js +65 -0
- package/dist/__tests__/audit.test.js.map +1 -0
- package/dist/__tests__/content-generator.test.d.ts +2 -0
- package/dist/__tests__/content-generator.test.d.ts.map +1 -0
- package/dist/__tests__/content-generator.test.js +200 -0
- package/dist/__tests__/content-generator.test.js.map +1 -0
- package/dist/__tests__/hooks-embedding-noprovider.test.d.ts +2 -0
- package/dist/__tests__/hooks-embedding-noprovider.test.d.ts.map +1 -0
- package/dist/__tests__/hooks-embedding-noprovider.test.js +32 -0
- package/dist/__tests__/hooks-embedding-noprovider.test.js.map +1 -0
- package/dist/__tests__/hooks.test.d.ts +2 -0
- package/dist/__tests__/hooks.test.d.ts.map +1 -0
- package/dist/__tests__/hooks.test.js +124 -0
- package/dist/__tests__/hooks.test.js.map +1 -0
- package/dist/__tests__/http.test.d.ts +2 -0
- package/dist/__tests__/http.test.d.ts.map +1 -0
- package/dist/__tests__/http.test.js +44 -0
- package/dist/__tests__/http.test.js.map +1 -0
- package/dist/__tests__/index.test.d.ts +2 -0
- package/dist/__tests__/index.test.d.ts.map +1 -0
- package/dist/__tests__/index.test.js +35 -0
- package/dist/__tests__/index.test.js.map +1 -0
- package/dist/__tests__/media-vision.test.d.ts +2 -0
- package/dist/__tests__/media-vision.test.d.ts.map +1 -0
- package/dist/__tests__/media-vision.test.js +83 -0
- package/dist/__tests__/media-vision.test.js.map +1 -0
- package/dist/__tests__/meta-generator.test.d.ts +2 -0
- package/dist/__tests__/meta-generator.test.d.ts.map +1 -0
- package/dist/__tests__/meta-generator.test.js +28 -0
- package/dist/__tests__/meta-generator.test.js.map +1 -0
- package/dist/__tests__/plugin-config.test.d.ts +2 -0
- package/dist/__tests__/plugin-config.test.d.ts.map +1 -0
- package/dist/__tests__/plugin-config.test.js +104 -0
- package/dist/__tests__/plugin-config.test.js.map +1 -0
- package/dist/__tests__/prompt.test.d.ts +2 -0
- package/dist/__tests__/prompt.test.d.ts.map +1 -0
- package/dist/__tests__/prompt.test.js +28 -0
- package/dist/__tests__/prompt.test.js.map +1 -0
- package/dist/admin/AIScorePanel.d.ts +19 -0
- package/dist/admin/AIScorePanel.d.ts.map +1 -0
- package/dist/admin/AIScorePanel.js +52 -0
- package/dist/admin/AIScorePanel.js.map +1 -0
- package/dist/admin/BrandVoiceSettings.d.ts +11 -0
- package/dist/admin/BrandVoiceSettings.d.ts.map +1 -0
- package/dist/admin/BrandVoiceSettings.js +162 -0
- package/dist/admin/BrandVoiceSettings.js.map +1 -0
- package/dist/admin/ContentScoreDashboard.d.ts +15 -0
- package/dist/admin/ContentScoreDashboard.d.ts.map +1 -0
- package/dist/admin/ContentScoreDashboard.js +64 -0
- package/dist/admin/ContentScoreDashboard.js.map +1 -0
- package/dist/admin/WritingAssistantToolbar.d.ts +13 -0
- package/dist/admin/WritingAssistantToolbar.d.ts.map +1 -0
- package/dist/admin/WritingAssistantToolbar.js +49 -0
- package/dist/admin/WritingAssistantToolbar.js.map +1 -0
- package/dist/audit/document-auditor.d.ts +82 -0
- package/dist/audit/document-auditor.d.ts.map +1 -0
- package/dist/audit/document-auditor.js +184 -0
- package/dist/audit/document-auditor.js.map +1 -0
- package/dist/brand/consistency-checker.d.ts +17 -0
- package/dist/brand/consistency-checker.d.ts.map +1 -0
- package/dist/brand/consistency-checker.js +47 -0
- package/dist/brand/consistency-checker.js.map +1 -0
- package/dist/brand/profile-builder.d.ts +10 -0
- package/dist/brand/profile-builder.d.ts.map +1 -0
- package/dist/brand/profile-builder.js +94 -0
- package/dist/brand/profile-builder.js.map +1 -0
- package/dist/brand/voice-profile.d.ts +30 -0
- package/dist/brand/voice-profile.d.ts.map +1 -0
- package/dist/brand/voice-profile.js +2 -0
- package/dist/brand/voice-profile.js.map +1 -0
- package/dist/collections.d.ts +3 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +2 -0
- package/dist/collections.js.map +1 -0
- package/dist/fields.d.ts +3 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +2 -0
- package/dist/fields.js.map +1 -0
- package/dist/hooks.d.ts +3 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +84 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/links/smart-links.d.ts +18 -0
- package/dist/links/smart-links.d.ts.map +1 -0
- package/dist/links/smart-links.js +44 -0
- package/dist/links/smart-links.js.map +1 -0
- package/dist/media/alt-text-generator.d.ts +27 -0
- package/dist/media/alt-text-generator.d.ts.map +1 -0
- package/dist/media/alt-text-generator.js +68 -0
- package/dist/media/alt-text-generator.js.map +1 -0
- package/dist/media/alt-text-prompt.d.ts +6 -0
- package/dist/media/alt-text-prompt.d.ts.map +1 -0
- package/dist/media/alt-text-prompt.js +32 -0
- package/dist/media/alt-text-prompt.js.map +1 -0
- package/dist/media/auto-tagger.d.ts +30 -0
- package/dist/media/auto-tagger.d.ts.map +1 -0
- package/dist/media/auto-tagger.js +54 -0
- package/dist/media/auto-tagger.js.map +1 -0
- package/dist/media/json.d.ts +4 -0
- package/dist/media/json.d.ts.map +1 -0
- package/dist/media/json.js +8 -0
- package/dist/media/json.js.map +1 -0
- package/dist/page-builder/generate.d.ts +23 -0
- package/dist/page-builder/generate.d.ts.map +1 -0
- package/dist/page-builder/generate.js +422 -0
- package/dist/page-builder/generate.js.map +1 -0
- package/dist/page-builder/index.d.ts +3 -0
- package/dist/page-builder/index.d.ts.map +1 -0
- package/dist/page-builder/index.js +2 -0
- package/dist/page-builder/index.js.map +1 -0
- package/dist/prompt.d.ts +30 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +46 -0
- package/dist/prompt.js.map +1 -0
- package/dist/providers/anthropic.d.ts +8 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +156 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/http.d.ts +25 -0
- package/dist/providers/http.d.ts.map +1 -0
- package/dist/providers/http.js +40 -0
- package/dist/providers/http.js.map +1 -0
- package/dist/providers/index.d.ts +49 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +35 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/openai.d.ts +7 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +143 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/scoring/accessibility.d.ts +24 -0
- package/dist/scoring/accessibility.d.ts.map +1 -0
- package/dist/scoring/accessibility.js +87 -0
- package/dist/scoring/accessibility.js.map +1 -0
- package/dist/scoring/brand-alignment.d.ts +12 -0
- package/dist/scoring/brand-alignment.d.ts.map +1 -0
- package/dist/scoring/brand-alignment.js +48 -0
- package/dist/scoring/brand-alignment.js.map +1 -0
- package/dist/scoring/composite.d.ts +19 -0
- package/dist/scoring/composite.d.ts.map +1 -0
- package/dist/scoring/composite.js +38 -0
- package/dist/scoring/composite.js.map +1 -0
- package/dist/scoring/freshness.d.ts +15 -0
- package/dist/scoring/freshness.d.ts.map +1 -0
- package/dist/scoring/freshness.js +35 -0
- package/dist/scoring/freshness.js.map +1 -0
- package/dist/scoring/readability.d.ts +16 -0
- package/dist/scoring/readability.d.ts.map +1 -0
- package/dist/scoring/readability.js +77 -0
- package/dist/scoring/readability.js.map +1 -0
- package/dist/scoring/seo-score.d.ts +26 -0
- package/dist/scoring/seo-score.d.ts.map +1 -0
- package/dist/scoring/seo-score.js +119 -0
- package/dist/scoring/seo-score.js.map +1 -0
- package/dist/search/clustering.d.ts +20 -0
- package/dist/search/clustering.d.ts.map +1 -0
- package/dist/search/clustering.js +89 -0
- package/dist/search/clustering.js.map +1 -0
- package/dist/search/embeddings.d.ts +14 -0
- package/dist/search/embeddings.d.ts.map +1 -0
- package/dist/search/embeddings.js +42 -0
- package/dist/search/embeddings.js.map +1 -0
- package/dist/search/semantic-search.d.ts +31 -0
- package/dist/search/semantic-search.d.ts.map +1 -0
- package/dist/search/semantic-search.js +59 -0
- package/dist/search/semantic-search.js.map +1 -0
- package/dist/translation/translator.d.ts +24 -0
- package/dist/translation/translator.d.ts.map +1 -0
- package/dist/translation/translator.js +48 -0
- package/dist/translation/translator.js.map +1 -0
- package/dist/writing/assistant.d.ts +28 -0
- package/dist/writing/assistant.d.ts.map +1 -0
- package/dist/writing/assistant.js +126 -0
- package/dist/writing/assistant.js.map +1 -0
- package/dist/writing/content-generator.d.ts +107 -0
- package/dist/writing/content-generator.d.ts.map +1 -0
- package/dist/writing/content-generator.js +290 -0
- package/dist/writing/content-generator.js.map +1 -0
- package/dist/writing/inline-suggestions.d.ts +18 -0
- package/dist/writing/inline-suggestions.d.ts.map +1 -0
- package/dist/writing/inline-suggestions.js +41 -0
- package/dist/writing/inline-suggestions.js.map +1 -0
- package/dist/writing/meta-generator.d.ts +19 -0
- package/dist/writing/meta-generator.d.ts.map +1 -0
- package/dist/writing/meta-generator.js +68 -0
- package/dist/writing/meta-generator.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
const ACTIONS = [
|
|
4
|
+
{ label: 'Generate', icon: '✦', action: 'onGenerate' },
|
|
5
|
+
{ label: 'Expand', icon: '↔', action: 'onExpand', requiresSelection: true },
|
|
6
|
+
{ label: 'Compress', icon: '⊘', action: 'onCompress', requiresSelection: true },
|
|
7
|
+
{ label: 'Rewrite', icon: '⟳', action: 'onRewrite', requiresSelection: true },
|
|
8
|
+
{ label: 'Proofread', icon: '✓', action: 'onProofread', requiresSelection: true },
|
|
9
|
+
];
|
|
10
|
+
/** Toolbar with AI writing actions for use alongside a rich text editor. */
|
|
11
|
+
export function WritingAssistantToolbar({ onGenerate, onExpand, onCompress, onRewrite, onProofread, isProcessing, selectedText, }) {
|
|
12
|
+
const handlers = {
|
|
13
|
+
onGenerate,
|
|
14
|
+
onExpand,
|
|
15
|
+
onCompress,
|
|
16
|
+
onRewrite,
|
|
17
|
+
onProofread,
|
|
18
|
+
};
|
|
19
|
+
return (_jsxs("div", { style: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
gap: 4,
|
|
23
|
+
padding: '6px 8px',
|
|
24
|
+
borderRadius: 8,
|
|
25
|
+
border: '1px solid #e5e7eb',
|
|
26
|
+
backgroundColor: '#fafafa',
|
|
27
|
+
}, children: [_jsx("span", { style: { fontSize: 12, color: '#6b7280', marginRight: 8, fontWeight: 500 }, children: "AI" }), ACTIONS.map((action) => {
|
|
28
|
+
const disabled = isProcessing || (action.requiresSelection && !selectedText);
|
|
29
|
+
return (_jsxs("button", { onClick: () => handlers[action.action]?.(), disabled: disabled, title: action.label, style: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
gap: 4,
|
|
33
|
+
padding: '4px 10px',
|
|
34
|
+
fontSize: 13,
|
|
35
|
+
border: '1px solid transparent',
|
|
36
|
+
borderRadius: 6,
|
|
37
|
+
backgroundColor: 'transparent',
|
|
38
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
39
|
+
opacity: disabled ? 0.4 : 1,
|
|
40
|
+
transition: 'background-color 0.15s',
|
|
41
|
+
}, onMouseEnter: (e) => {
|
|
42
|
+
if (!disabled)
|
|
43
|
+
e.currentTarget.style.backgroundColor = '#f3f4f6';
|
|
44
|
+
}, onMouseLeave: (e) => {
|
|
45
|
+
e.currentTarget.style.backgroundColor = 'transparent';
|
|
46
|
+
}, children: [_jsx("span", { children: action.icon }), _jsx("span", { children: action.label })] }, action.action));
|
|
47
|
+
}), isProcessing && (_jsx("span", { style: { fontSize: 12, color: '#6b7280', marginLeft: 8 }, children: "Processing..." }))] }));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=WritingAssistantToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WritingAssistantToolbar.js","sourceRoot":"","sources":["../../src/admin/WritingAssistantToolbar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAqBZ,MAAM,OAAO,GAAoB;IAC/B,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE;IACtD,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,IAAI,EAAE;IAC3E,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,IAAI,EAAE;IAC/E,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE;IAC7E,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,IAAI,EAAE;CAClF,CAAA;AAED,4EAA4E;AAC5E,MAAM,UAAU,uBAAuB,CAAC,EACtC,UAAU,EACV,QAAQ,EACR,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,YAAY,GACiB;IAC7B,MAAM,QAAQ,GAA+B;QAC3C,UAAU;QACV,QAAQ;QACR,UAAU;QACV,SAAS;QACT,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AAC,EACD,YAAY,EAAE,CAAC,CAAC,EAAE,EAAE;wBAClB,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,eAAe,GAAG,aAAa,CAAA;oBACvD,CAAC,aAED,yBAAO,MAAM,CAAC,IAAI,GAAQ,EAC1B,yBAAO,MAAM,CAAC,KAAK,GAAQ,KAzBtB,MAAM,CAAC,MAAM,CA0BX,CACV,CAAA;YACH,CAAC,CAAC,EACD,YAAY,IAAI,CACf,eAAM,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,EAAE,8BAAsB,CACrF,IACG,CACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { CompositeScore } from '../scoring/composite.js';
|
|
2
|
+
/**
|
|
3
|
+
* Document audit input shape.
|
|
4
|
+
*
|
|
5
|
+
* Callers may supply already-extracted content (title/body/etc.) OR a raw
|
|
6
|
+
* document object — the auditor coerces what it can and degrades gracefully
|
|
7
|
+
* when fields are missing.
|
|
8
|
+
*/
|
|
9
|
+
export interface AuditDocumentInput {
|
|
10
|
+
title: string;
|
|
11
|
+
body: string;
|
|
12
|
+
metaTitle?: string;
|
|
13
|
+
metaDescription?: string;
|
|
14
|
+
targetKeyword?: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
headings?: string[];
|
|
17
|
+
images?: Array<{
|
|
18
|
+
src: string;
|
|
19
|
+
alt?: string;
|
|
20
|
+
}>;
|
|
21
|
+
internalLinks?: string[];
|
|
22
|
+
externalLinks?: string[];
|
|
23
|
+
publishedAt?: Date | string | null;
|
|
24
|
+
updatedAt?: Date | string | null;
|
|
25
|
+
contentType?: string;
|
|
26
|
+
}
|
|
27
|
+
/** A single human-readable issue surfaced by the audit. */
|
|
28
|
+
export interface AuditIssue {
|
|
29
|
+
severity: 'error' | 'warning' | 'info';
|
|
30
|
+
category: 'seo' | 'accessibility' | 'readability' | 'freshness' | 'structure';
|
|
31
|
+
rule: string;
|
|
32
|
+
message: string;
|
|
33
|
+
field?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Full audit result combining a composite score and the underlying breakdowns. */
|
|
36
|
+
export interface AuditDocumentResult {
|
|
37
|
+
composite: CompositeScore;
|
|
38
|
+
scores: {
|
|
39
|
+
seo: number;
|
|
40
|
+
readability: number;
|
|
41
|
+
accessibility: number;
|
|
42
|
+
freshness?: number;
|
|
43
|
+
};
|
|
44
|
+
readability: {
|
|
45
|
+
averageGradeLevel: number;
|
|
46
|
+
difficulty: 'easy' | 'moderate' | 'difficult' | 'expert';
|
|
47
|
+
};
|
|
48
|
+
issues: AuditIssue[];
|
|
49
|
+
/**
|
|
50
|
+
* Raw per-dimension diagnostics — useful for surfacing breakdown rows in
|
|
51
|
+
* the admin AI Score panel without re-running individual scorers.
|
|
52
|
+
*/
|
|
53
|
+
diagnostics: {
|
|
54
|
+
seoBreakdown: Array<{
|
|
55
|
+
criterion: string;
|
|
56
|
+
score: number;
|
|
57
|
+
maxScore: number;
|
|
58
|
+
suggestion?: string;
|
|
59
|
+
}>;
|
|
60
|
+
accessibilityIssues: Array<{
|
|
61
|
+
type: 'error' | 'warning' | 'info';
|
|
62
|
+
rule: string;
|
|
63
|
+
message: string;
|
|
64
|
+
}>;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Composite content quality audit.
|
|
69
|
+
*
|
|
70
|
+
* Runs SEO, readability, accessibility, and (when timestamps are present)
|
|
71
|
+
* freshness scoring against a document, plus structural checks that catch
|
|
72
|
+
* common authoring mistakes the scorers don't flag on their own. Returns a
|
|
73
|
+
* single composite grade plus the per-dimension breakdowns so admin UIs can
|
|
74
|
+
* surface a high-level letter grade with drill-down.
|
|
75
|
+
*
|
|
76
|
+
* Intentionally provider-agnostic: this function does NOT call any LLM. It
|
|
77
|
+
* only inspects the content the caller provides and runs deterministic
|
|
78
|
+
* scoring functions. That keeps the endpoint cheap, cacheable, and safe to
|
|
79
|
+
* call on every save.
|
|
80
|
+
*/
|
|
81
|
+
export declare function auditDocument(input: AuditDocumentInput): AuditDocumentResult;
|
|
82
|
+
//# sourceMappingURL=document-auditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-auditor.d.ts","sourceRoot":"","sources":["../../src/audit/document-auditor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC7C,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,WAAW,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAClC,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;IAChC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,2DAA2D;AAC3D,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;IACtC,QAAQ,EAAE,KAAK,GAAG,eAAe,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW,CAAA;IAC7E,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,mFAAmF;AACnF,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,cAAc,CAAA;IACzB,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,CAAA;QACX,WAAW,EAAE,MAAM,CAAA;QACnB,aAAa,EAAE,MAAM,CAAA;QACrB,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,WAAW,EAAE;QACX,iBAAiB,EAAE,MAAM,CAAA;QACzB,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAA;KACzD,CAAA;IACD,MAAM,EAAE,UAAU,EAAE,CAAA;IACpB;;;OAGG;IACH,WAAW,EAAE;QACX,YAAY,EAAE,KAAK,CAAC;YAClB,SAAS,EAAE,MAAM,CAAA;YACjB,KAAK,EAAE,MAAM,CAAA;YACb,QAAQ,EAAE,MAAM,CAAA;YAChB,UAAU,CAAC,EAAE,MAAM,CAAA;SACpB,CAAC,CAAA;QACF,mBAAmB,EAAE,KAAK,CAAC;YACzB,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;YAClC,IAAI,EAAE,MAAM,CAAA;YACZ,OAAO,EAAE,MAAM,CAAA;SAChB,CAAC,CAAA;KACH,CAAA;CACF;AAeD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,CAiK5E"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { calculateSEOScore } from '../scoring/seo-score.js';
|
|
2
|
+
import { getReadabilityScore } from '../scoring/readability.js';
|
|
3
|
+
import { calculateAccessibilityScore } from '../scoring/accessibility.js';
|
|
4
|
+
import { calculateFreshnessScore } from '../scoring/freshness.js';
|
|
5
|
+
import { calculateCompositeScore } from '../scoring/composite.js';
|
|
6
|
+
/**
|
|
7
|
+
* Converts a reading grade level into a 0-100 readability score. Lower grade
|
|
8
|
+
* levels (i.e. easier to read) score higher because most marketing /
|
|
9
|
+
* content-marketing material targets a 6-9th grade reading level. We treat
|
|
10
|
+
* grade 8 as the inflection point: everything at or below 8 gets full marks;
|
|
11
|
+
* each grade above 8 deducts 8 points (so grade 13+ scores ~60).
|
|
12
|
+
*/
|
|
13
|
+
function readabilityToScore(grade) {
|
|
14
|
+
if (!Number.isFinite(grade) || grade <= 0)
|
|
15
|
+
return 0;
|
|
16
|
+
const excess = Math.max(0, grade - 8);
|
|
17
|
+
return Math.max(0, Math.min(100, Math.round(100 - excess * 8)));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Composite content quality audit.
|
|
21
|
+
*
|
|
22
|
+
* Runs SEO, readability, accessibility, and (when timestamps are present)
|
|
23
|
+
* freshness scoring against a document, plus structural checks that catch
|
|
24
|
+
* common authoring mistakes the scorers don't flag on their own. Returns a
|
|
25
|
+
* single composite grade plus the per-dimension breakdowns so admin UIs can
|
|
26
|
+
* surface a high-level letter grade with drill-down.
|
|
27
|
+
*
|
|
28
|
+
* Intentionally provider-agnostic: this function does NOT call any LLM. It
|
|
29
|
+
* only inspects the content the caller provides and runs deterministic
|
|
30
|
+
* scoring functions. That keeps the endpoint cheap, cacheable, and safe to
|
|
31
|
+
* call on every save.
|
|
32
|
+
*/
|
|
33
|
+
export function auditDocument(input) {
|
|
34
|
+
const issues = [];
|
|
35
|
+
const title = input.title ?? '';
|
|
36
|
+
const body = input.body ?? '';
|
|
37
|
+
const metaTitle = input.metaTitle ?? title;
|
|
38
|
+
const metaDescription = input.metaDescription ?? '';
|
|
39
|
+
const seoContent = {
|
|
40
|
+
title: metaTitle,
|
|
41
|
+
metaDescription,
|
|
42
|
+
body,
|
|
43
|
+
...(input.targetKeyword ? { targetKeyword: input.targetKeyword } : {}),
|
|
44
|
+
...(input.url ? { url: input.url } : {}),
|
|
45
|
+
...(input.headings ? { headings: input.headings } : {}),
|
|
46
|
+
...(input.images ? { images: input.images } : {}),
|
|
47
|
+
...(input.internalLinks ? { internalLinks: input.internalLinks } : {}),
|
|
48
|
+
...(input.externalLinks ? { externalLinks: input.externalLinks } : {}),
|
|
49
|
+
};
|
|
50
|
+
const seoResult = calculateSEOScore(seoContent);
|
|
51
|
+
for (const row of seoResult.breakdown) {
|
|
52
|
+
if (row.suggestion) {
|
|
53
|
+
issues.push({
|
|
54
|
+
severity: row.score === 0 ? 'warning' : 'info',
|
|
55
|
+
category: 'seo',
|
|
56
|
+
rule: row.criterion,
|
|
57
|
+
message: row.suggestion,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const readability = getReadabilityScore(body);
|
|
62
|
+
const readabilityScore = readabilityToScore(readability.averageGradeLevel);
|
|
63
|
+
if (readability.difficulty === 'difficult' || readability.difficulty === 'expert') {
|
|
64
|
+
issues.push({
|
|
65
|
+
severity: 'info',
|
|
66
|
+
category: 'readability',
|
|
67
|
+
rule: 'reading-grade',
|
|
68
|
+
message: `Content reads at grade ${Math.round(readability.averageGradeLevel)} (${readability.difficulty}). Aim for 6-9th grade for general audiences.`,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
// The accessibility scorer wants `html` and structured headings/links.
|
|
72
|
+
// We feed it the body as plain text (it strips tags itself) plus the
|
|
73
|
+
// image/link/heading metadata the caller provided, since rich-text bodies
|
|
74
|
+
// in CMS payloads usually aren't HTML at rest.
|
|
75
|
+
const accessibility = calculateAccessibilityScore({
|
|
76
|
+
html: body,
|
|
77
|
+
images: input.images ?? [],
|
|
78
|
+
headings: input.headings ?? [],
|
|
79
|
+
links: (input.internalLinks ?? []).concat(input.externalLinks ?? []).map((href) => ({
|
|
80
|
+
text: href,
|
|
81
|
+
href,
|
|
82
|
+
})),
|
|
83
|
+
});
|
|
84
|
+
for (const a11yIssue of accessibility.issues) {
|
|
85
|
+
issues.push({
|
|
86
|
+
severity: a11yIssue.type,
|
|
87
|
+
category: 'accessibility',
|
|
88
|
+
rule: a11yIssue.rule,
|
|
89
|
+
message: a11yIssue.message,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
let freshnessScore;
|
|
93
|
+
const publishedAt = input.publishedAt instanceof Date
|
|
94
|
+
? input.publishedAt
|
|
95
|
+
: input.publishedAt
|
|
96
|
+
? new Date(input.publishedAt)
|
|
97
|
+
: undefined;
|
|
98
|
+
const updatedAt = input.updatedAt instanceof Date
|
|
99
|
+
? input.updatedAt
|
|
100
|
+
: input.updatedAt
|
|
101
|
+
? new Date(input.updatedAt)
|
|
102
|
+
: undefined;
|
|
103
|
+
if (publishedAt && !Number.isNaN(publishedAt.getTime())) {
|
|
104
|
+
const freshness = calculateFreshnessScore({
|
|
105
|
+
publishedAt,
|
|
106
|
+
...(updatedAt && !Number.isNaN(updatedAt.getTime()) ? { updatedAt } : {}),
|
|
107
|
+
contentType: input.contentType ?? 'blog',
|
|
108
|
+
});
|
|
109
|
+
freshnessScore = freshness.score;
|
|
110
|
+
if (freshness.recommendation === 'stale' || freshness.recommendation === 'outdated') {
|
|
111
|
+
issues.push({
|
|
112
|
+
severity: freshness.recommendation === 'outdated' ? 'warning' : 'info',
|
|
113
|
+
category: 'freshness',
|
|
114
|
+
rule: 'content-age',
|
|
115
|
+
message: `Content is ${freshness.daysOld} days old (${freshness.recommendation}). Consider reviewing.`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Structural checks that complement the scorers — these catch fields the
|
|
120
|
+
// scorers don't see (because they receive only normalized content).
|
|
121
|
+
if (!title.trim()) {
|
|
122
|
+
issues.push({
|
|
123
|
+
severity: 'error',
|
|
124
|
+
category: 'structure',
|
|
125
|
+
rule: 'missing-title',
|
|
126
|
+
message: 'Document is missing a title.',
|
|
127
|
+
field: 'title',
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (!metaDescription.trim()) {
|
|
131
|
+
issues.push({
|
|
132
|
+
severity: 'warning',
|
|
133
|
+
category: 'structure',
|
|
134
|
+
rule: 'missing-meta-description',
|
|
135
|
+
message: 'Document is missing a meta description.',
|
|
136
|
+
field: 'metaDescription',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (input.images && input.images.length > 0) {
|
|
140
|
+
const missingAlt = input.images.filter((i) => !i.alt || !i.alt.trim()).length;
|
|
141
|
+
if (missingAlt > 0) {
|
|
142
|
+
issues.push({
|
|
143
|
+
severity: 'warning',
|
|
144
|
+
category: 'structure',
|
|
145
|
+
rule: 'missing-alt-text',
|
|
146
|
+
message: `${missingAlt} image${missingAlt === 1 ? '' : 's'} missing alt text.`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (body.trim().split(/\s+/).filter(Boolean).length < 50) {
|
|
151
|
+
issues.push({
|
|
152
|
+
severity: 'warning',
|
|
153
|
+
category: 'structure',
|
|
154
|
+
rule: 'insufficient-body',
|
|
155
|
+
message: 'Body content is very short — fewer than 50 words.',
|
|
156
|
+
field: 'body',
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const composite = calculateCompositeScore({
|
|
160
|
+
seo: seoResult.score,
|
|
161
|
+
readability: readabilityScore,
|
|
162
|
+
accessibility: accessibility.score,
|
|
163
|
+
...(freshnessScore !== undefined ? { freshness: freshnessScore } : {}),
|
|
164
|
+
});
|
|
165
|
+
return {
|
|
166
|
+
composite,
|
|
167
|
+
scores: {
|
|
168
|
+
seo: seoResult.score,
|
|
169
|
+
readability: readabilityScore,
|
|
170
|
+
accessibility: accessibility.score,
|
|
171
|
+
...(freshnessScore !== undefined ? { freshness: freshnessScore } : {}),
|
|
172
|
+
},
|
|
173
|
+
readability: {
|
|
174
|
+
averageGradeLevel: readability.averageGradeLevel,
|
|
175
|
+
difficulty: readability.difficulty,
|
|
176
|
+
},
|
|
177
|
+
issues,
|
|
178
|
+
diagnostics: {
|
|
179
|
+
seoBreakdown: seoResult.breakdown,
|
|
180
|
+
accessibilityIssues: accessibility.issues,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=document-auditor.js.map
|
|
@@ -0,0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mB;YACzB,OAAO,EAAE,mDAAmD;YAC5D,KAAK,EAAE,MAAM;SACd,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,uBAAuB,CAAC;QACxC,GAAG,EAAE,SAAS,CAAC,KAAK;QACpB,WAAW,EAAE,gBAAgB;QAC7B,aAAa,EAAE,aAAa,CAAC,KAAK;QAClC,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvE,CAAC,CAAA;IAEF,OAAO;QACL,SAAS;QACT,MAAM,EAAE;YACN,GAAG,EAAE,SAAS,CAAC,KAAK;YACpB,WAAW,EAAE,gBAAgB;YAC7B,aAAa,EAAE,aAAa,CAAC,KAAK;YAClC,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvE;QACD,WAAW,EAAE;YACX,iBAAiB,EAAE,WAAW,CAAC,iBAAiB;YAChD,UAAU,EAAE,WAAW,CAAC,UAAU;SACnC;QACD,MAAM;QACN,WAAW,EAAE;YACX,YAAY,EAAE,SAAS,CAAC,SAAS;YACjC,mBAAmB,EAAE,aAAa,CAAC,MAAM;SAC1C;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BrandVoiceProfile } from './voice-profile.js';
|
|
2
|
+
export interface ConsistencyResult {
|
|
3
|
+
score: number;
|
|
4
|
+
issues: Array<{
|
|
5
|
+
type: string;
|
|
6
|
+
location: string;
|
|
7
|
+
suggestion: string;
|
|
8
|
+
severity: 'low' | 'medium' | 'high';
|
|
9
|
+
}>;
|
|
10
|
+
highlights: Array<{
|
|
11
|
+
text: string;
|
|
12
|
+
type: 'good' | 'off-brand';
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
/** Checks content for consistency against a brand voice profile. */
|
|
16
|
+
export declare function checkConsistency(content: string, profile: BrandVoiceProfile): Promise<ConsistencyResult>;
|
|
17
|
+
//# sourceMappingURL=consistency-checker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consistency-checker.d.ts","sourceRoot":"","sources":["../../src/brand/consistency-checker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,QAAQ,EAAE,MAAM,CAAA;QAChB,UAAU,EAAE,MAAM,CAAA;QAClB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;KACpC,CAAC,CAAA;IACF,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAC,CAAA;CAChE;AAED,oEAAoE;AACpE,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAkD5B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Checks content for consistency against a brand voice profile. */
|
|
2
|
+
export async function checkConsistency(content, profile) {
|
|
3
|
+
const issues = [];
|
|
4
|
+
const highlights = [];
|
|
5
|
+
for (const avoided of profile.vocabulary.avoided) {
|
|
6
|
+
const regex = new RegExp(`\\b${avoided}\\b`, 'gi');
|
|
7
|
+
let match;
|
|
8
|
+
while ((match = regex.exec(content)) !== null) {
|
|
9
|
+
issues.push({
|
|
10
|
+
type: 'vocabulary',
|
|
11
|
+
location: `character ${match.index}`,
|
|
12
|
+
suggestion: `Replace "${avoided}" with a brand-appropriate alternative`,
|
|
13
|
+
severity: 'medium',
|
|
14
|
+
});
|
|
15
|
+
highlights.push({ text: match[0], type: 'off-brand' });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
for (const preferred of profile.vocabulary.preferred) {
|
|
19
|
+
if (content.toLowerCase().includes(preferred.toLowerCase())) {
|
|
20
|
+
highlights.push({ text: preferred, type: 'good' });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const sentences = content.split(/[.!?]+/).filter(Boolean);
|
|
24
|
+
const targetLengths = {
|
|
25
|
+
short: [5, 15],
|
|
26
|
+
medium: [10, 25],
|
|
27
|
+
long: [20, 40],
|
|
28
|
+
varied: [5, 40],
|
|
29
|
+
};
|
|
30
|
+
const [minLen, maxLen] = targetLengths[profile.style.sentenceLength] ?? [5, 40];
|
|
31
|
+
for (let i = 0; i < sentences.length; i++) {
|
|
32
|
+
const wordCount = sentences[i].trim().split(/\s+/).filter(Boolean).length;
|
|
33
|
+
if (wordCount < minLen || wordCount > maxLen) {
|
|
34
|
+
issues.push({
|
|
35
|
+
type: 'sentence-length',
|
|
36
|
+
location: `sentence ${i + 1}`,
|
|
37
|
+
suggestion: `Sentence has ${wordCount} words — target is ${minLen}-${maxLen}`,
|
|
38
|
+
severity: 'low',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const totalPossibleIssues = sentences.length + profile.vocabulary.avoided.length;
|
|
43
|
+
const issueRatio = totalPossibleIssues > 0 ? issues.length / totalPossibleIssues : 0;
|
|
44
|
+
const score = Math.round(Math.max(0, Math.min(100, 100 - issueRatio * 100)));
|
|
45
|
+
return { score, issues, highlights };
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=consistency-checker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consistency-checker.js","sourceRoot":"","sources":["../../src/brand/consistency-checker.ts"],"names":[],"mappings":"AAaA,oEAAoE;AACpE,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAe,EACf,OAA0B;IAE1B,MAAM,MAAM,GAAgC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
|
|
|
1
|
+
import type { AIProvider } from '../providers/index.js';
|
|
2
|
+
import type { BrandVoiceProfile } from './voice-profile.js';
|
|
3
|
+
export interface ProfileBuilderOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
sampleSize?: number;
|
|
6
|
+
provider?: AIProvider;
|
|
7
|
+
}
|
|
8
|
+
/** Analyzes content samples to build a brand voice profile. */
|
|
9
|
+
export declare function buildBrandProfile(content: string[], options?: ProfileBuilderOptions): Promise<BrandVoiceProfile>;
|
|
10
|
+
//# sourceMappingURL=profile-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-builder.d.ts","sourceRoot":"","sources":["../../src/brand/profile-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,UAAU,CAAA;CACtB;AAED,+DAA+D;AAC/D,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,iBAAiB,CAAC,CA0G5B"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** Analyzes content samples to build a brand voice profile. */
|
|
2
|
+
export async function buildBrandProfile(content, options) {
|
|
3
|
+
const samples = options?.sampleSize ? content.slice(0, options.sampleSize) : content;
|
|
4
|
+
const totalWords = samples.reduce((sum, s) => sum + s.split(/\s+/).filter(Boolean).length, 0);
|
|
5
|
+
const totalSentences = samples.reduce((sum, s) => sum + (s.match(/[.!?]+/g)?.length ?? 1), 0);
|
|
6
|
+
const avgSentenceLength = totalSentences > 0 ? totalWords / totalSentences : 15;
|
|
7
|
+
let sentenceLength;
|
|
8
|
+
if (avgSentenceLength < 12)
|
|
9
|
+
sentenceLength = 'short';
|
|
10
|
+
else if (avgSentenceLength < 22)
|
|
11
|
+
sentenceLength = 'medium';
|
|
12
|
+
else if (avgSentenceLength < 30)
|
|
13
|
+
sentenceLength = 'long';
|
|
14
|
+
else
|
|
15
|
+
sentenceLength = 'varied';
|
|
16
|
+
const baseProfile = {
|
|
17
|
+
id: crypto.randomUUID(),
|
|
18
|
+
name: options?.name ?? 'Untitled Profile',
|
|
19
|
+
tone: [
|
|
20
|
+
{ dimension: 'professional', value: 0.7 },
|
|
21
|
+
{ dimension: 'friendly', value: 0.5 },
|
|
22
|
+
{ dimension: 'authoritative', value: 0.6 },
|
|
23
|
+
],
|
|
24
|
+
vocabulary: {
|
|
25
|
+
preferred: [],
|
|
26
|
+
avoided: [],
|
|
27
|
+
jargonLevel: 'minimal',
|
|
28
|
+
},
|
|
29
|
+
style: {
|
|
30
|
+
sentenceLength,
|
|
31
|
+
paragraphLength: 'medium',
|
|
32
|
+
formality: 0.6,
|
|
33
|
+
activeVoiceRatio: 0.7,
|
|
34
|
+
},
|
|
35
|
+
audience: {
|
|
36
|
+
expertise: 'intermediate',
|
|
37
|
+
},
|
|
38
|
+
examples: samples.slice(0, 3).map((text) => ({
|
|
39
|
+
text: text.slice(0, 200),
|
|
40
|
+
score: 0.8,
|
|
41
|
+
})),
|
|
42
|
+
};
|
|
43
|
+
if (!options?.provider) {
|
|
44
|
+
return baseProfile;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const analysis = await options.provider.generateText(`Analyze the tone, style, and voice of the following content samples. Return a JSON object with:
|
|
48
|
+
- "tone": array of { "dimension": string, "value": number (0-1) } for dimensions like professional, friendly, authoritative, casual, technical, empathetic
|
|
49
|
+
- "preferred": array of commonly used words/phrases to keep
|
|
50
|
+
- "avoided": array of words/phrases that don't fit the voice
|
|
51
|
+
- "jargonLevel": "none" | "minimal" | "moderate" | "heavy"
|
|
52
|
+
- "formality": number 0-1 (0 = very casual, 1 = very formal)
|
|
53
|
+
- "activeVoiceRatio": estimated ratio 0-1 of active vs passive voice
|
|
54
|
+
- "expertise": "beginner" | "intermediate" | "expert"
|
|
55
|
+
|
|
56
|
+
Content samples:
|
|
57
|
+
${samples.slice(0, 5).join('\n---\n')}`, {
|
|
58
|
+
systemPrompt: 'You are a brand voice analyst. Analyze writing patterns and return valid JSON only.',
|
|
59
|
+
maxTokens: 1024,
|
|
60
|
+
temperature: 0.3,
|
|
61
|
+
});
|
|
62
|
+
const cleaned = analysis.text
|
|
63
|
+
.replace(/```json?\n?/g, '')
|
|
64
|
+
.replace(/```/g, '')
|
|
65
|
+
.trim();
|
|
66
|
+
const parsed = JSON.parse(cleaned);
|
|
67
|
+
if (parsed.tone?.length) {
|
|
68
|
+
baseProfile.tone = parsed.tone;
|
|
69
|
+
}
|
|
70
|
+
if (parsed.preferred?.length) {
|
|
71
|
+
baseProfile.vocabulary.preferred = parsed.preferred;
|
|
72
|
+
}
|
|
73
|
+
if (parsed.avoided?.length) {
|
|
74
|
+
baseProfile.vocabulary.avoided = parsed.avoided;
|
|
75
|
+
}
|
|
76
|
+
if (parsed.jargonLevel) {
|
|
77
|
+
baseProfile.vocabulary.jargonLevel = parsed.jargonLevel;
|
|
78
|
+
}
|
|
79
|
+
if (typeof parsed.formality === 'number') {
|
|
80
|
+
baseProfile.style.formality = parsed.formality;
|
|
81
|
+
}
|
|
82
|
+
if (typeof parsed.activeVoiceRatio === 'number') {
|
|
83
|
+
baseProfile.style.activeVoiceRatio = parsed.activeVoiceRatio;
|
|
84
|
+
}
|
|
85
|
+
if (parsed.expertise) {
|
|
86
|
+
baseProfile.audience.expertise = parsed.expertise;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Fall back to heuristic profile if LLM analysis fails
|
|
91
|
+
}
|
|
92
|
+
return baseProfile;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=profile-builder.js.map
|
|
@@ -0,0 +1 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AAO,CAQhC,CAAA;QAED,IAAI,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;YACxB,WAAW,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;QAChC,CAAC;QACD,IAAI,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;YAC7B,WAAW,CAAC,UAAU,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACrD,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YAC3B,WAAW,CAAC,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QACjD,CAAC;QACD,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACvB,WAAW,CAAC,UAAU,CAAC,WAAW,GAAG,MAAM,CAAC,WAAkB,CAAA;QAChE,CAAC;QACD,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YACzC,WAAW,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QAChD,CAAC;QACD,IAAI,OAAO,MAAM,CAAC,gBAAgB,KAAK,QAAQ,EAAE,CAAC;YAChD,WAAW,CAAC,KAAK,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAA;QAC9D,CAAC;QACD,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACrB,WAAW,CAAC,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,SAAgB,CAAA;QAC1D,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,uDAAuD;IACzD,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface BrandVoiceProfile {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
tone: Array<{
|
|
5
|
+
dimension: string;
|
|
6
|
+
value: number;
|
|
7
|
+
}>;
|
|
8
|
+
vocabulary: {
|
|
9
|
+
preferred: string[];
|
|
10
|
+
avoided: string[];
|
|
11
|
+
jargonLevel: 'none' | 'minimal' | 'moderate' | 'technical';
|
|
12
|
+
};
|
|
13
|
+
style: {
|
|
14
|
+
sentenceLength: 'short' | 'medium' | 'long' | 'varied';
|
|
15
|
+
paragraphLength: 'short' | 'medium' | 'long';
|
|
16
|
+
formality: number;
|
|
17
|
+
activeVoiceRatio: number;
|
|
18
|
+
};
|
|
19
|
+
audience: {
|
|
20
|
+
expertise: 'beginner' | 'intermediate' | 'expert';
|
|
21
|
+
ageRange?: string;
|
|
22
|
+
persona?: string;
|
|
23
|
+
};
|
|
24
|
+
examples: Array<{
|
|
25
|
+
text: string;
|
|
26
|
+
score: number;
|
|
27
|
+
notes?: string;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=voice-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voice-profile.d.ts","sourceRoot":"","sources":["../../src/brand/voice-profile.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACjD,UAAU,EAAE;QACV,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,EAAE,MAAM,EAAE,CAAA;QACjB,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAA;KAC3D,CAAA;IACD,KAAK,EAAE;QACL,cAAc,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAA;QACtD,eAAe,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAA;QAC5C,SAAS,EAAE,MAAM,CAAA;QACjB,gBAAgB,EAAE,MAAM,CAAA;KACzB,CAAA;IACD,QAAQ,EAAE;QACR,SAAS,EAAE,UAAU,GAAG,cAAc,GAAG,QAAQ,CAAA;QACjD,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voice-profile.js","sourceRoot":"","sources":["../../src/brand/voice-profile.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAExD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAyC,EAAE,CAAA"}
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAM,CAAA"}
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAoC,EAAE,CAAA"}
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C,eAAO,MAAM,OAAO,EAAE,UAAU,EAoF/B,CAAA"}
|