@bernierllc/ai-social-generator 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +5 -0
- package/README.md +215 -0
- package/dist/ai-social-generator.d.ts +45 -0
- package/dist/ai-social-generator.d.ts.map +1 -0
- package/dist/ai-social-generator.js +277 -0
- package/dist/ai-social-generator.js.map +1 -0
- package/dist/factory.d.ts +7 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +15 -0
- package/dist/factory.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +68 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +84 -0
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/README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# @bernierllc/ai-social-generator
|
|
2
|
+
|
|
3
|
+
AI-powered social media post generation service with platform-specific optimization and validation.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The `@bernierllc/ai-social-generator` package provides a specialized service for generating social media posts from source content (blog posts, articles, etc.) with platform-specific optimization, character limits, hashtag generation, and content validation using social media content type validators.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Multi-Platform Generation**: Generate posts for Twitter, LinkedIn, Facebook, Instagram, Mastodon, and BlueSky
|
|
12
|
+
- **Platform-Specific Optimization**: Character limits, tone, and formatting optimized for each platform
|
|
13
|
+
- **Content Validation**: Validates generated content against platform constraints
|
|
14
|
+
- **Hashtag & Mention Extraction**: Automatically extracts hashtags and mentions from generated content
|
|
15
|
+
- **Thread Generation**: Automatically splits long Twitter content into threads
|
|
16
|
+
- **Multi-Platform Batch**: Generate posts for multiple platforms in parallel
|
|
17
|
+
- **Uses AI Content Generator**: Leverages `@bernierllc/ai-content-generator` for actual generation
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @bernierllc/ai-social-generator
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { AISocialGenerator, createAISocialGenerator } from '@bernierllc/ai-social-generator';
|
|
29
|
+
import { OpenAIProvider } from '@bernierllc/ai-provider-openai';
|
|
30
|
+
|
|
31
|
+
// Create AI provider
|
|
32
|
+
const provider = new OpenAIProvider({
|
|
33
|
+
providerName: 'openai',
|
|
34
|
+
apiKey: process.env.OPENAI_API_KEY!
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Create social generator
|
|
38
|
+
const generator = createAISocialGenerator({
|
|
39
|
+
contentGenerator: {
|
|
40
|
+
provider
|
|
41
|
+
},
|
|
42
|
+
enableValidation: true
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Generate a single post
|
|
46
|
+
const result = await generator.generatePost(
|
|
47
|
+
'Excited to announce our new TypeScript features that improve developer productivity by 50%!',
|
|
48
|
+
'twitter',
|
|
49
|
+
{
|
|
50
|
+
tone: 'professional',
|
|
51
|
+
includeHashtags: true,
|
|
52
|
+
maxHashtags: 3,
|
|
53
|
+
includeEmojis: true,
|
|
54
|
+
includeCTA: true,
|
|
55
|
+
generateThread: false
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
if (result.success) {
|
|
60
|
+
console.log('Generated:', result.content);
|
|
61
|
+
console.log('Hashtags:', result.hashtags);
|
|
62
|
+
console.log('Mentions:', result.mentions);
|
|
63
|
+
if (result.thread) {
|
|
64
|
+
console.log('Thread:', result.thread);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Generate for multiple platforms
|
|
69
|
+
const multiResult = await generator.generateMultiPlatform(
|
|
70
|
+
'Source content for social posts',
|
|
71
|
+
['twitter', 'linkedin', 'facebook'],
|
|
72
|
+
{
|
|
73
|
+
tone: 'professional',
|
|
74
|
+
includeHashtags: true
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
console.log(`Generated ${multiResult.successCount} of ${multiResult.totalGenerated} posts`);
|
|
79
|
+
for (const [platform, post] of multiResult.results) {
|
|
80
|
+
if (post.success) {
|
|
81
|
+
console.log(`${platform}: ${post.content}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## API
|
|
87
|
+
|
|
88
|
+
### `AISocialGenerator`
|
|
89
|
+
|
|
90
|
+
#### Constructor
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
new AISocialGenerator(config: AISocialGeneratorConfig)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Config Options:**
|
|
97
|
+
- `contentGenerator` (required) - AI Content Generator configuration
|
|
98
|
+
- `provider` (required) - AI provider instance
|
|
99
|
+
- `fallbackProvider` (optional) - Fallback provider for failover
|
|
100
|
+
- `enableValidation` (optional) - Enable content validation (default: true)
|
|
101
|
+
- `enableNeverHub` (optional) - Enable NeverHub integration (default: false)
|
|
102
|
+
|
|
103
|
+
#### Methods
|
|
104
|
+
|
|
105
|
+
- `generatePost(sourceContent: string, platform: SocialPlatform, options?: SocialGenerationOptions): Promise<GeneratedSocialPost>` - Generate a single social post
|
|
106
|
+
- `generateMultiPlatform(sourceContent: string, platforms: SocialPlatform[], options?: SocialGenerationOptions): Promise<MultiPlatformResult>` - Generate posts for multiple platforms
|
|
107
|
+
- `shutdown(): void` - Shutdown the generator gracefully
|
|
108
|
+
|
|
109
|
+
### Social Generation Options
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
interface SocialGenerationOptions {
|
|
113
|
+
tone?: 'professional' | 'casual' | 'humorous' | 'informative' | 'promotional';
|
|
114
|
+
includeHashtags?: boolean;
|
|
115
|
+
maxHashtags?: number;
|
|
116
|
+
includeCTA?: boolean;
|
|
117
|
+
generateThread?: boolean; // For Twitter
|
|
118
|
+
includeEmojis?: boolean;
|
|
119
|
+
audience?: string;
|
|
120
|
+
customPrompt?: string;
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Generated Social Post
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
interface GeneratedSocialPost {
|
|
128
|
+
success: boolean;
|
|
129
|
+
content: string;
|
|
130
|
+
platform: SocialPlatform;
|
|
131
|
+
characterCount: number;
|
|
132
|
+
hashtags?: string[];
|
|
133
|
+
mentions?: string[];
|
|
134
|
+
thread?: string[]; // For Twitter threads
|
|
135
|
+
metadata: {
|
|
136
|
+
generatedAt: Date;
|
|
137
|
+
model: string;
|
|
138
|
+
tokensUsed: number;
|
|
139
|
+
costUsd: number;
|
|
140
|
+
durationMs: number;
|
|
141
|
+
};
|
|
142
|
+
error?: string;
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Platform Specifications
|
|
147
|
+
|
|
148
|
+
| Platform | Max Length | Default Tone |
|
|
149
|
+
|----------|-----------|--------------|
|
|
150
|
+
| Twitter | 280 | Concise and engaging |
|
|
151
|
+
| LinkedIn | 3000 | Professional |
|
|
152
|
+
| Facebook | 5000 | Conversational |
|
|
153
|
+
| Instagram | 2200 | Visual and engaging |
|
|
154
|
+
| Mastodon | 500 | Community-focused |
|
|
155
|
+
| BlueSky | 300 | Authentic |
|
|
156
|
+
|
|
157
|
+
## Thread Generation
|
|
158
|
+
|
|
159
|
+
For Twitter, when content exceeds 280 characters and `generateThread: true` is set, the generator automatically splits the content into a thread:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
const result = await generator.generatePost(
|
|
163
|
+
'Very long content that exceeds 280 characters...',
|
|
164
|
+
'twitter',
|
|
165
|
+
{ generateThread: true }
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
if (result.thread) {
|
|
169
|
+
// result.thread is an array of tweets
|
|
170
|
+
console.log(`Thread has ${result.thread.length} tweets`);
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Content Validation
|
|
175
|
+
|
|
176
|
+
When `enableValidation` is true, generated content is validated against platform constraints:
|
|
177
|
+
|
|
178
|
+
- **Character Limits**: Content is checked against platform-specific limits
|
|
179
|
+
- **Twitter Validation**: Uses `@bernierllc/social-media-content-type-twitter` validator
|
|
180
|
+
- **Auto-Truncation**: Content exceeding limits is automatically truncated (unless thread generation is enabled)
|
|
181
|
+
|
|
182
|
+
## Integration Status
|
|
183
|
+
|
|
184
|
+
- **Logger**: ✅ Integrated - Uses `@bernierllc/logger` for all logging operations
|
|
185
|
+
- **Docs-Suite**: ✅ Ready - Full TypeDoc API documentation available
|
|
186
|
+
- **NeverHub**: ⚠️ Optional - Can emit social generation events to NeverHub event bus for distributed observability
|
|
187
|
+
|
|
188
|
+
## Dependencies
|
|
189
|
+
|
|
190
|
+
- `@bernierllc/ai-content-generator` - Content generation service
|
|
191
|
+
- `@bernierllc/content-type-registry` - Content type management
|
|
192
|
+
- `@bernierllc/social-media-content-type-*` - Platform validators (6 packages)
|
|
193
|
+
- `@bernierllc/logger` - Logging
|
|
194
|
+
- `@bernierllc/retry-policy` - Retry logic
|
|
195
|
+
- `@bernierllc/neverhub-adapter` - Service discovery (optional)
|
|
196
|
+
|
|
197
|
+
## Testing
|
|
198
|
+
|
|
199
|
+
Run tests with:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
npm test
|
|
203
|
+
npm run test:coverage
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Target coverage: 85%+ (service package standard)
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
Copyright (c) 2025 Bernier LLC
|
|
211
|
+
|
|
212
|
+
This file is licensed to the client under a limited-use license.
|
|
213
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
214
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
215
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { SocialPlatform, SocialGenerationOptions, GeneratedSocialPost, MultiPlatformResult, AISocialGeneratorConfig } from './types';
|
|
2
|
+
export declare class AISocialGenerator {
|
|
3
|
+
private logger;
|
|
4
|
+
private contentGenerator;
|
|
5
|
+
private config;
|
|
6
|
+
private twitterValidator;
|
|
7
|
+
constructor(config: AISocialGeneratorConfig);
|
|
8
|
+
/**
|
|
9
|
+
* Generate social post for a single platform
|
|
10
|
+
*/
|
|
11
|
+
generatePost(sourceContent: string, platform: SocialPlatform, options?: SocialGenerationOptions): Promise<GeneratedSocialPost>;
|
|
12
|
+
/**
|
|
13
|
+
* Generate posts for multiple platforms
|
|
14
|
+
*/
|
|
15
|
+
generateMultiPlatform(sourceContent: string, platforms: SocialPlatform[], options?: SocialGenerationOptions): Promise<MultiPlatformResult>;
|
|
16
|
+
/**
|
|
17
|
+
* Validate post against platform content type
|
|
18
|
+
*/
|
|
19
|
+
private validatePost;
|
|
20
|
+
/**
|
|
21
|
+
* Get platform max length
|
|
22
|
+
*/
|
|
23
|
+
private getPlatformMaxLength;
|
|
24
|
+
/**
|
|
25
|
+
* Extract hashtags from content
|
|
26
|
+
*/
|
|
27
|
+
private extractHashtags;
|
|
28
|
+
/**
|
|
29
|
+
* Extract mentions from content
|
|
30
|
+
*/
|
|
31
|
+
private extractMentions;
|
|
32
|
+
/**
|
|
33
|
+
* Generate Twitter thread
|
|
34
|
+
*/
|
|
35
|
+
private generateThread;
|
|
36
|
+
/**
|
|
37
|
+
* Calculate cost based on metadata
|
|
38
|
+
*/
|
|
39
|
+
private calculateCost;
|
|
40
|
+
/**
|
|
41
|
+
* Shutdown service
|
|
42
|
+
*/
|
|
43
|
+
shutdown(): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=ai-social-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-social-generator.d.ts","sourceRoot":"","sources":["../src/ai-social-generator.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAEjB,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAqB;IAC7C,OAAO,CAAC,MAAM,CAAoH;IAClI,OAAO,CAAC,gBAAgB,CAA0B;gBAEtC,MAAM,EAAE,uBAAuB;IAyB3C;;OAEG;IACG,YAAY,CAChB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,mBAAmB,CAAC;IAsI/B;;OAEG;IACG,qBAAqB,CACzB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,cAAc,EAAE,EAC3B,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,mBAAmB,CAAC;IA2B/B;;OAEG;IACH,OAAO,CAAC,YAAY;IA4BpB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAY5B;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,cAAc;IA6BtB;;OAEG;IACH,OAAO,CAAC,aAAa;IASrB;;OAEG;IACH,QAAQ,IAAI,IAAI;CAIjB"}
|
|
@@ -0,0 +1,277 @@
|
|
|
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 { createLogger } from '@bernierllc/logger';
|
|
9
|
+
import { AIContentGenerator } from '@bernierllc/ai-content-generator';
|
|
10
|
+
import { TwitterContentValidator } from '@bernierllc/social-media-content-type-twitter';
|
|
11
|
+
export class AISocialGenerator {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.logger = createLogger({
|
|
14
|
+
context: {
|
|
15
|
+
service: '@bernierllc/ai-social-generator'
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
this.config = {
|
|
19
|
+
enableValidation: config.enableValidation ?? true,
|
|
20
|
+
enableNeverHub: config.enableNeverHub ?? false,
|
|
21
|
+
...config
|
|
22
|
+
};
|
|
23
|
+
// Initialize content generator
|
|
24
|
+
this.contentGenerator = new AIContentGenerator(config.contentGenerator);
|
|
25
|
+
// Initialize validators
|
|
26
|
+
this.twitterValidator = new TwitterContentValidator();
|
|
27
|
+
this.logger.info('AISocialGenerator initialized', {
|
|
28
|
+
enableValidation: this.config.enableValidation,
|
|
29
|
+
enableNeverHub: this.config.enableNeverHub
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Generate social post for a single platform
|
|
34
|
+
*/
|
|
35
|
+
async generatePost(sourceContent, platform, options) {
|
|
36
|
+
const startTime = Date.now();
|
|
37
|
+
try {
|
|
38
|
+
// Validate source content
|
|
39
|
+
if (!sourceContent || sourceContent.trim().length === 0) {
|
|
40
|
+
return {
|
|
41
|
+
success: false,
|
|
42
|
+
content: '',
|
|
43
|
+
platform,
|
|
44
|
+
characterCount: 0,
|
|
45
|
+
metadata: {
|
|
46
|
+
generatedAt: new Date(),
|
|
47
|
+
model: '',
|
|
48
|
+
tokensUsed: 0,
|
|
49
|
+
costUsd: 0,
|
|
50
|
+
durationMs: Date.now() - startTime
|
|
51
|
+
},
|
|
52
|
+
error: 'Source content cannot be empty'
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// Convert social options to generation options
|
|
56
|
+
const generationOptions = {
|
|
57
|
+
creativity: options?.tone === 'humorous' ? 0.8 : 0.7,
|
|
58
|
+
tone: options?.tone,
|
|
59
|
+
targetAudience: options?.audience,
|
|
60
|
+
includeHashtags: options?.includeHashtags,
|
|
61
|
+
hashtagCount: options?.maxHashtags,
|
|
62
|
+
includeEmojis: options?.includeEmojis,
|
|
63
|
+
callToAction: options?.includeCTA
|
|
64
|
+
};
|
|
65
|
+
// Generate using ai-content-generator
|
|
66
|
+
const generationResult = await this.contentGenerator.generateSocialPost(sourceContent, platform, generationOptions);
|
|
67
|
+
if (!generationResult.success || !generationResult.content) {
|
|
68
|
+
return {
|
|
69
|
+
success: false,
|
|
70
|
+
content: '',
|
|
71
|
+
platform,
|
|
72
|
+
characterCount: 0,
|
|
73
|
+
metadata: {
|
|
74
|
+
generatedAt: new Date(),
|
|
75
|
+
model: generationResult.metadata?.model || '',
|
|
76
|
+
tokensUsed: generationResult.metadata?.totalTokens || 0,
|
|
77
|
+
costUsd: 0,
|
|
78
|
+
durationMs: Date.now() - startTime
|
|
79
|
+
},
|
|
80
|
+
error: generationResult.error || 'Generation failed'
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// Store original content length for thread generation check
|
|
84
|
+
const originalContentLength = generationResult.content.length;
|
|
85
|
+
// Extract hashtags and mentions
|
|
86
|
+
const hashtags = this.extractHashtags(generationResult.content);
|
|
87
|
+
const mentions = this.extractMentions(generationResult.content);
|
|
88
|
+
// Validate against platform content type if enabled
|
|
89
|
+
if (this.config.enableValidation) {
|
|
90
|
+
const validationResult = this.validatePost(generationResult.content, platform);
|
|
91
|
+
if (!validationResult.valid && validationResult.errors.length > 0) {
|
|
92
|
+
this.logger.warn(`Generated post failed validation for ${platform}`, {
|
|
93
|
+
errors: validationResult.errors
|
|
94
|
+
});
|
|
95
|
+
// Try to fix common issues (truncate if too long) - but only if not generating thread
|
|
96
|
+
if (validationResult.errors.some(e => e.includes('character limit'))) {
|
|
97
|
+
const maxLength = this.getPlatformMaxLength(platform);
|
|
98
|
+
// Don't truncate if we're generating a thread (thread will handle splitting)
|
|
99
|
+
if (generationResult.content.length > maxLength && !(platform === 'twitter' && options?.generateThread)) {
|
|
100
|
+
generationResult.content = generationResult.content.substring(0, maxLength - 3) + '...';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Handle thread generation for Twitter (check original length before validation truncation)
|
|
106
|
+
let thread;
|
|
107
|
+
if (platform === 'twitter' && options?.generateThread && originalContentLength > 280) {
|
|
108
|
+
thread = this.generateThread(generationResult.content, options);
|
|
109
|
+
}
|
|
110
|
+
const result = {
|
|
111
|
+
success: true,
|
|
112
|
+
content: generationResult.content,
|
|
113
|
+
platform,
|
|
114
|
+
characterCount: generationResult.content.length,
|
|
115
|
+
hashtags: hashtags.length > 0 ? hashtags : undefined,
|
|
116
|
+
mentions: mentions.length > 0 ? mentions : undefined,
|
|
117
|
+
thread,
|
|
118
|
+
metadata: {
|
|
119
|
+
generatedAt: new Date(),
|
|
120
|
+
model: generationResult.metadata?.model || '',
|
|
121
|
+
tokensUsed: generationResult.metadata?.totalTokens || 0,
|
|
122
|
+
costUsd: this.calculateCost(generationResult.metadata),
|
|
123
|
+
durationMs: Date.now() - startTime
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
this.logger.info('Social post generated successfully', {
|
|
127
|
+
platform,
|
|
128
|
+
characterCount: result.characterCount,
|
|
129
|
+
durationMs: result.metadata.durationMs
|
|
130
|
+
});
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
135
|
+
this.logger.error('Error generating social post', error instanceof Error ? error : new Error(errorMessage), {
|
|
136
|
+
platform
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
success: false,
|
|
140
|
+
content: '',
|
|
141
|
+
platform,
|
|
142
|
+
characterCount: 0,
|
|
143
|
+
metadata: {
|
|
144
|
+
generatedAt: new Date(),
|
|
145
|
+
model: '',
|
|
146
|
+
tokensUsed: 0,
|
|
147
|
+
costUsd: 0,
|
|
148
|
+
durationMs: Date.now() - startTime
|
|
149
|
+
},
|
|
150
|
+
error: errorMessage
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Generate posts for multiple platforms
|
|
156
|
+
*/
|
|
157
|
+
async generateMultiPlatform(sourceContent, platforms, options) {
|
|
158
|
+
const results = new Map();
|
|
159
|
+
// Generate in parallel for all platforms
|
|
160
|
+
const generationPromises = platforms.map(async (platform) => {
|
|
161
|
+
const result = await this.generatePost(sourceContent, platform, options);
|
|
162
|
+
return { platform, result };
|
|
163
|
+
});
|
|
164
|
+
const generationResults = await Promise.all(generationPromises);
|
|
165
|
+
for (const { platform, result } of generationResults) {
|
|
166
|
+
results.set(platform, result);
|
|
167
|
+
}
|
|
168
|
+
const successCount = Array.from(results.values()).filter(r => r.success).length;
|
|
169
|
+
const failureCount = results.size - successCount;
|
|
170
|
+
return {
|
|
171
|
+
success: successCount > 0,
|
|
172
|
+
results,
|
|
173
|
+
totalGenerated: results.size,
|
|
174
|
+
successCount,
|
|
175
|
+
failureCount
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Validate post against platform content type
|
|
180
|
+
*/
|
|
181
|
+
validatePost(content, platform) {
|
|
182
|
+
const errors = [];
|
|
183
|
+
// Basic validation - check character limits
|
|
184
|
+
const maxLength = this.getPlatformMaxLength(platform);
|
|
185
|
+
if (content.length > maxLength) {
|
|
186
|
+
errors.push(`Content exceeds ${platform} character limit of ${maxLength}`);
|
|
187
|
+
}
|
|
188
|
+
// Platform-specific validation
|
|
189
|
+
if (platform === 'twitter') {
|
|
190
|
+
const validationResult = this.twitterValidator.validate({
|
|
191
|
+
text: content
|
|
192
|
+
});
|
|
193
|
+
if (!validationResult.valid) {
|
|
194
|
+
errors.push(...validationResult.errors.map(e => e.message));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
valid: errors.length === 0,
|
|
199
|
+
errors
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get platform max length
|
|
204
|
+
*/
|
|
205
|
+
getPlatformMaxLength(platform) {
|
|
206
|
+
const specs = {
|
|
207
|
+
twitter: 280,
|
|
208
|
+
linkedin: 3000,
|
|
209
|
+
facebook: 5000,
|
|
210
|
+
instagram: 2200,
|
|
211
|
+
mastodon: 500,
|
|
212
|
+
bluesky: 300
|
|
213
|
+
};
|
|
214
|
+
return specs[platform];
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Extract hashtags from content
|
|
218
|
+
*/
|
|
219
|
+
extractHashtags(content) {
|
|
220
|
+
const hashtagRegex = /#\w+/g;
|
|
221
|
+
const matches = content.match(hashtagRegex);
|
|
222
|
+
return matches || [];
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Extract mentions from content
|
|
226
|
+
*/
|
|
227
|
+
extractMentions(content) {
|
|
228
|
+
const mentionRegex = /@\w+/g;
|
|
229
|
+
const matches = content.match(mentionRegex);
|
|
230
|
+
return matches || [];
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Generate Twitter thread
|
|
234
|
+
*/
|
|
235
|
+
generateThread(firstTweet, _options) {
|
|
236
|
+
// Simple thread generation - split by sentences or paragraphs
|
|
237
|
+
// In a real implementation, this would use AI to create a coherent thread
|
|
238
|
+
const sentences = firstTweet.split(/[.!?]+/).filter(s => s.trim().length > 0);
|
|
239
|
+
const thread = [];
|
|
240
|
+
let currentTweet = '';
|
|
241
|
+
for (const sentence of sentences) {
|
|
242
|
+
const sentenceWithPunctuation = sentence.trim() + '.';
|
|
243
|
+
if (currentTweet.length + sentenceWithPunctuation.length + 1 <= 280) {
|
|
244
|
+
currentTweet += (currentTweet ? ' ' : '') + sentenceWithPunctuation;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
if (currentTweet) {
|
|
248
|
+
thread.push(currentTweet);
|
|
249
|
+
}
|
|
250
|
+
currentTweet = sentenceWithPunctuation;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (currentTweet) {
|
|
254
|
+
thread.push(currentTweet);
|
|
255
|
+
}
|
|
256
|
+
return thread.length > 1 ? thread : [firstTweet];
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Calculate cost based on metadata
|
|
260
|
+
*/
|
|
261
|
+
calculateCost(metadata) {
|
|
262
|
+
// Placeholder - would calculate based on model pricing
|
|
263
|
+
if (!metadata?.totalTokens) {
|
|
264
|
+
return 0;
|
|
265
|
+
}
|
|
266
|
+
// Rough estimate: $0.002 per 1K tokens
|
|
267
|
+
return (metadata.totalTokens / 1000) * 0.002;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Shutdown service
|
|
271
|
+
*/
|
|
272
|
+
shutdown() {
|
|
273
|
+
this.logger.info('AISocialGenerator shutting down');
|
|
274
|
+
// Cleanup would go here
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=ai-social-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-social-generator.js","sourceRoot":"","sources":["../src/ai-social-generator.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,YAAY,EAAU,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAA0B,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AASxF,MAAM,OAAO,iBAAiB;IAM5B,YAAY,MAA+B;QACzC,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;YACzB,OAAO,EAAE;gBACP,OAA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M,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,QAAmD;QACvE,uDAAuD;QACvD,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;YAC3B,OAAO,CAAC,CAAC;QACX,CAAC;QACD,uCAAuC;QACvC,OAAO,CAAC,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QACpD,wBAAwB;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AISocialGenerator } from './ai-social-generator';
|
|
2
|
+
import type { AISocialGeneratorConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Create a new AISocialGenerator instance
|
|
5
|
+
*/
|
|
6
|
+
export declare function createAISocialGenerator(config: AISocialGeneratorConfig): AISocialGenerator;
|
|
7
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,uBAAuB,GAAG,iBAAiB,CAE1F"}
|
package/dist/factory.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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 { AISocialGenerator } from './ai-social-generator';
|
|
9
|
+
/**
|
|
10
|
+
* Create a new AISocialGenerator instance
|
|
11
|
+
*/
|
|
12
|
+
export function createAISocialGenerator(config) {
|
|
13
|
+
return new AISocialGenerator(config);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1D;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAA+B;IACrE,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AISocialGenerator } from './ai-social-generator';
|
|
2
|
+
export { createAISocialGenerator } from './factory';
|
|
3
|
+
export type { SocialPlatform, SocialGenerationOptions, GeneratedSocialPost, MultiPlatformResult, AISocialGeneratorConfig } from './types';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,YAAY,EACV,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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 { AISocialGenerator } from './ai-social-generator';
|
|
9
|
+
export { createAISocialGenerator } from './factory';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { AIContentGeneratorConfig } from '@bernierllc/ai-content-generator';
|
|
2
|
+
/**
|
|
3
|
+
* Social media platform type
|
|
4
|
+
*/
|
|
5
|
+
export type SocialPlatform = 'twitter' | 'linkedin' | 'facebook' | 'instagram' | 'mastodon' | 'bluesky';
|
|
6
|
+
/**
|
|
7
|
+
* Social generation options
|
|
8
|
+
*/
|
|
9
|
+
export interface SocialGenerationOptions {
|
|
10
|
+
/** Tone/style for the post */
|
|
11
|
+
tone?: 'professional' | 'casual' | 'humorous' | 'informative' | 'promotional';
|
|
12
|
+
/** Include hashtags */
|
|
13
|
+
includeHashtags?: boolean;
|
|
14
|
+
/** Maximum hashtag count */
|
|
15
|
+
maxHashtags?: number;
|
|
16
|
+
/** Include call-to-action */
|
|
17
|
+
includeCTA?: boolean;
|
|
18
|
+
/** Generate thread (for Twitter) */
|
|
19
|
+
generateThread?: boolean;
|
|
20
|
+
/** Include emojis */
|
|
21
|
+
includeEmojis?: boolean;
|
|
22
|
+
/** Target audience */
|
|
23
|
+
audience?: string;
|
|
24
|
+
/** Custom prompt additions */
|
|
25
|
+
customPrompt?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Generated social post result
|
|
29
|
+
*/
|
|
30
|
+
export interface GeneratedSocialPost {
|
|
31
|
+
success: boolean;
|
|
32
|
+
content: string;
|
|
33
|
+
platform: SocialPlatform;
|
|
34
|
+
characterCount: number;
|
|
35
|
+
hashtags?: string[];
|
|
36
|
+
mentions?: string[];
|
|
37
|
+
thread?: string[];
|
|
38
|
+
metadata: {
|
|
39
|
+
generatedAt: Date;
|
|
40
|
+
model: string;
|
|
41
|
+
tokensUsed: number;
|
|
42
|
+
costUsd: number;
|
|
43
|
+
durationMs: number;
|
|
44
|
+
};
|
|
45
|
+
error?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Multi-platform generation result
|
|
49
|
+
*/
|
|
50
|
+
export interface MultiPlatformResult {
|
|
51
|
+
success: boolean;
|
|
52
|
+
results: Map<SocialPlatform, GeneratedSocialPost>;
|
|
53
|
+
totalGenerated: number;
|
|
54
|
+
successCount: number;
|
|
55
|
+
failureCount: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* AI Social Generator configuration
|
|
59
|
+
*/
|
|
60
|
+
export interface AISocialGeneratorConfig {
|
|
61
|
+
/** AI Content Generator configuration */
|
|
62
|
+
contentGenerator: AIContentGeneratorConfig;
|
|
63
|
+
/** Enable validation */
|
|
64
|
+
enableValidation?: boolean;
|
|
65
|
+
/** Enable NeverHub integration */
|
|
66
|
+
enableNeverHub?: boolean;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEjF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAExG;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,8BAA8B;IAC9B,IAAI,CAAC,EAAE,cAAc,GAAG,Q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AC;IAC3C,wBAAwB;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kCAAkC;IAClC,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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 {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;EAME"}
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bernierllc/ai-social-generator",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "AI-powered social media post generation service with platform-specific optimization and validation",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/**/*",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"ai",
|
|
15
|
+
"social-media",
|
|
16
|
+
"content-generation",
|
|
17
|
+
"twitter",
|
|
18
|
+
"linkedin",
|
|
19
|
+
"facebook",
|
|
20
|
+
"instagram",
|
|
21
|
+
"mastodon",
|
|
22
|
+
"bluesky",
|
|
23
|
+
"service",
|
|
24
|
+
"bernierllc"
|
|
25
|
+
],
|
|
26
|
+
"author": "Bernier LLC",
|
|
27
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@bernierllc/ai-content-generator": "1.0.2",
|
|
30
|
+
"@bernierllc/content-type-registry": "1.1.0",
|
|
31
|
+
"@bernierllc/social-media-content-type-twitter": "1.0.0",
|
|
32
|
+
"@bernierllc/social-media-content-type-linkedin": "1.0.0",
|
|
33
|
+
"@bernierllc/social-media-content-type-facebook": "1.0.0",
|
|
34
|
+
"@bernierllc/social-media-content-type-instagram": "1.0.0",
|
|
35
|
+
"@bernierllc/social-media-content-type-mastodon": "1.0.0",
|
|
36
|
+
"@bernierllc/social-media-content-type-bluesky": "1.0.0",
|
|
37
|
+
"@bernierllc/logger": "1.0.3",
|
|
38
|
+
"@bernierllc/retry-policy": "0.1.6",
|
|
39
|
+
"@bernierllc/neverhub-adapter": "0.1.2"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/jest": "^29.5.0",
|
|
43
|
+
"@types/node": "^20.0.0",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
45
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
46
|
+
"eslint": "^8.0.0",
|
|
47
|
+
"jest": "^29.0.0",
|
|
48
|
+
"rimraf": "^5.0.0",
|
|
49
|
+
"ts-jest": "^29.0.0",
|
|
50
|
+
"typescript": "^5.0.0"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/bernierllc/tools.git",
|
|
55
|
+
"directory": "packages/service/ai-social-generator"
|
|
56
|
+
},
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/bernierllc/tools/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/bernierllc/tools/tree/main/packages/service/ai-social-generator#readme",
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public",
|
|
63
|
+
"registry": "https://registry.npmjs.org/"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=18.0.0"
|
|
67
|
+
},
|
|
68
|
+
"bernierllc": {
|
|
69
|
+
"integration": {
|
|
70
|
+
"logger": "integrated",
|
|
71
|
+
"docsIntegration": "ready",
|
|
72
|
+
"neverhub": "required"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"scripts": {
|
|
76
|
+
"build": "tsc",
|
|
77
|
+
"prebuild": "npm run clean",
|
|
78
|
+
"clean": "rimraf dist",
|
|
79
|
+
"test": "jest",
|
|
80
|
+
"test:run": "jest --passWithNoTests",
|
|
81
|
+
"test:coverage": "jest --coverage",
|
|
82
|
+
"lint": "eslint src --ext .ts"
|
|
83
|
+
}
|
|
84
|
+
}
|