@tpmjs/content-calendar-plan 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +259 -0
- package/package.json +91 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 TPMJS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as ai from 'ai';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Content Calendar Plan Tool for TPMJS
|
|
5
|
+
* Generates content calendar structure with themes, topics, and posting schedule
|
|
6
|
+
*
|
|
7
|
+
* This is a proper AI SDK v6 tool that can be used with streamText()
|
|
8
|
+
* Uses jsonSchema() to avoid Zod 4 JSON Schema conversion issues with OpenAI
|
|
9
|
+
*/
|
|
10
|
+
interface ContentItem {
|
|
11
|
+
date: string;
|
|
12
|
+
channel: string;
|
|
13
|
+
contentType: string;
|
|
14
|
+
theme?: string;
|
|
15
|
+
topic: string;
|
|
16
|
+
objective: string;
|
|
17
|
+
suggestedFormat?: string;
|
|
18
|
+
}
|
|
19
|
+
interface ContentCalendar {
|
|
20
|
+
duration: string;
|
|
21
|
+
startDate: string;
|
|
22
|
+
endDate: string;
|
|
23
|
+
channels: string[];
|
|
24
|
+
themes: string[];
|
|
25
|
+
items: ContentItem[];
|
|
26
|
+
summary: {
|
|
27
|
+
totalPosts: number;
|
|
28
|
+
postsByChannel: Record<string, number>;
|
|
29
|
+
postsByTheme: Record<string, number>;
|
|
30
|
+
averagePostsPerWeek: number;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Input type for Content Calendar Plan Tool
|
|
35
|
+
*/
|
|
36
|
+
type ContentCalendarPlanInput = {
|
|
37
|
+
duration: string;
|
|
38
|
+
channels: string[];
|
|
39
|
+
themes?: string[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Content Calendar Plan Tool
|
|
43
|
+
* Generates content calendar structure with themes, topics, and posting schedule
|
|
44
|
+
*
|
|
45
|
+
* This is a proper AI SDK v6 tool that can be used with streamText()
|
|
46
|
+
*/
|
|
47
|
+
declare const contentCalendarPlanTool: ai.Tool<ContentCalendarPlanInput, {
|
|
48
|
+
duration: string;
|
|
49
|
+
startDate: string;
|
|
50
|
+
endDate: string;
|
|
51
|
+
channels: string[];
|
|
52
|
+
themes: string[];
|
|
53
|
+
items: ContentItem[];
|
|
54
|
+
summary: {
|
|
55
|
+
totalPosts: number;
|
|
56
|
+
postsByChannel: Record<string, number>;
|
|
57
|
+
postsByTheme: Record<string, number>;
|
|
58
|
+
averagePostsPerWeek: number;
|
|
59
|
+
};
|
|
60
|
+
}>;
|
|
61
|
+
|
|
62
|
+
export { type ContentCalendar, type ContentItem, contentCalendarPlanTool, contentCalendarPlanTool as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { tool, jsonSchema } from 'ai';
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
function calculateDateRange(duration) {
|
|
5
|
+
const startDate = /* @__PURE__ */ new Date();
|
|
6
|
+
startDate.setHours(0, 0, 0, 0);
|
|
7
|
+
const endDate = new Date(startDate);
|
|
8
|
+
let weeks = 1;
|
|
9
|
+
const durationLower = duration.toLowerCase();
|
|
10
|
+
if (durationLower.includes("week")) {
|
|
11
|
+
const weekMatch = durationLower.match(/(\d+)\s*week/);
|
|
12
|
+
weeks = weekMatch?.[1] ? Number.parseInt(weekMatch[1]) : 1;
|
|
13
|
+
endDate.setDate(endDate.getDate() + weeks * 7);
|
|
14
|
+
} else if (durationLower.includes("month")) {
|
|
15
|
+
const monthMatch = durationLower.match(/(\d+)\s*month/);
|
|
16
|
+
const months = monthMatch?.[1] ? Number.parseInt(monthMatch[1]) : 1;
|
|
17
|
+
endDate.setMonth(endDate.getMonth() + months);
|
|
18
|
+
weeks = Math.ceil((endDate.getTime() - startDate.getTime()) / (7 * 24 * 60 * 60 * 1e3));
|
|
19
|
+
} else if (durationLower.includes("quarter")) {
|
|
20
|
+
endDate.setMonth(endDate.getMonth() + 3);
|
|
21
|
+
weeks = 13;
|
|
22
|
+
} else {
|
|
23
|
+
endDate.setDate(endDate.getDate() + 7);
|
|
24
|
+
weeks = 1;
|
|
25
|
+
}
|
|
26
|
+
return { startDate, endDate, weeks };
|
|
27
|
+
}
|
|
28
|
+
function getChannelFrequency(channel) {
|
|
29
|
+
const frequencies = {
|
|
30
|
+
twitter: 7,
|
|
31
|
+
// Daily
|
|
32
|
+
instagram: 5,
|
|
33
|
+
// 5 times per week
|
|
34
|
+
linkedin: 3,
|
|
35
|
+
// 3 times per week
|
|
36
|
+
facebook: 5,
|
|
37
|
+
// 5 times per week
|
|
38
|
+
blog: 2,
|
|
39
|
+
// 2 times per week
|
|
40
|
+
youtube: 1,
|
|
41
|
+
// Weekly
|
|
42
|
+
tiktok: 7,
|
|
43
|
+
// Daily
|
|
44
|
+
email: 1,
|
|
45
|
+
// Weekly
|
|
46
|
+
newsletter: 1,
|
|
47
|
+
// Weekly
|
|
48
|
+
podcast: 1
|
|
49
|
+
// Weekly
|
|
50
|
+
};
|
|
51
|
+
const channelLower = channel.toLowerCase();
|
|
52
|
+
for (const [key, freq] of Object.entries(frequencies)) {
|
|
53
|
+
if (channelLower.includes(key)) {
|
|
54
|
+
return freq;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return 3;
|
|
58
|
+
}
|
|
59
|
+
function getContentTypes(channel) {
|
|
60
|
+
const contentTypes = {
|
|
61
|
+
twitter: ["tweet", "thread", "poll", "quote tweet"],
|
|
62
|
+
instagram: ["post", "reel", "story", "carousel"],
|
|
63
|
+
linkedin: ["article", "post", "poll", "document"],
|
|
64
|
+
facebook: ["post", "video", "live stream", "poll"],
|
|
65
|
+
blog: ["article", "tutorial", "case study", "listicle"],
|
|
66
|
+
youtube: ["video", "short", "live stream"],
|
|
67
|
+
tiktok: ["video", "duet", "stitch"],
|
|
68
|
+
email: ["newsletter", "promotional", "educational"],
|
|
69
|
+
newsletter: ["digest", "featured article", "roundup"],
|
|
70
|
+
podcast: ["episode", "interview", "solo show"]
|
|
71
|
+
};
|
|
72
|
+
const channelLower = channel.toLowerCase();
|
|
73
|
+
for (const [key, types] of Object.entries(contentTypes)) {
|
|
74
|
+
if (channelLower.includes(key)) {
|
|
75
|
+
return types;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return ["post", "article", "video"];
|
|
79
|
+
}
|
|
80
|
+
function generateDefaultThemes() {
|
|
81
|
+
return ["Educational", "Promotional", "Inspirational", "Engagement", "Behind-the-scenes"];
|
|
82
|
+
}
|
|
83
|
+
function getObjective(theme) {
|
|
84
|
+
const objectives = {
|
|
85
|
+
educational: "Provide valuable information and insights",
|
|
86
|
+
promotional: "Drive conversions and sales",
|
|
87
|
+
inspirational: "Inspire and motivate audience",
|
|
88
|
+
engagement: "Encourage interaction and community building",
|
|
89
|
+
"behind-the-scenes": "Build trust and transparency",
|
|
90
|
+
awareness: "Increase brand visibility",
|
|
91
|
+
entertainment: "Entertain and delight audience",
|
|
92
|
+
"user-generated": "Showcase community content"
|
|
93
|
+
};
|
|
94
|
+
const themeLower = theme.toLowerCase();
|
|
95
|
+
for (const [key, objective] of Object.entries(objectives)) {
|
|
96
|
+
if (themeLower.includes(key)) {
|
|
97
|
+
return objective;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return "Engage and inform audience";
|
|
101
|
+
}
|
|
102
|
+
function generateTopic(theme, _channel, index) {
|
|
103
|
+
const topics = {
|
|
104
|
+
educational: [
|
|
105
|
+
"How-to guide",
|
|
106
|
+
"Industry insights",
|
|
107
|
+
"Best practices",
|
|
108
|
+
"Tips and tricks",
|
|
109
|
+
"Common mistakes",
|
|
110
|
+
"Beginner tutorial",
|
|
111
|
+
"Advanced techniques",
|
|
112
|
+
"Explainer content"
|
|
113
|
+
],
|
|
114
|
+
promotional: [
|
|
115
|
+
"Product showcase",
|
|
116
|
+
"Feature highlight",
|
|
117
|
+
"Customer testimonial",
|
|
118
|
+
"Limited offer",
|
|
119
|
+
"New release",
|
|
120
|
+
"Product comparison",
|
|
121
|
+
"Success story"
|
|
122
|
+
],
|
|
123
|
+
inspirational: [
|
|
124
|
+
"Success story",
|
|
125
|
+
"Motivational quote",
|
|
126
|
+
"Transformation story",
|
|
127
|
+
"Industry leader spotlight",
|
|
128
|
+
"Achievement celebration"
|
|
129
|
+
],
|
|
130
|
+
engagement: [
|
|
131
|
+
"Poll question",
|
|
132
|
+
"Ask Me Anything",
|
|
133
|
+
"Caption contest",
|
|
134
|
+
"Community spotlight",
|
|
135
|
+
"Discussion prompt",
|
|
136
|
+
"Quiz"
|
|
137
|
+
],
|
|
138
|
+
"behind-the-scenes": [
|
|
139
|
+
"Team introduction",
|
|
140
|
+
"Office tour",
|
|
141
|
+
"Process reveal",
|
|
142
|
+
"Day in the life",
|
|
143
|
+
"Product development"
|
|
144
|
+
]
|
|
145
|
+
};
|
|
146
|
+
const themeLower = theme.toLowerCase();
|
|
147
|
+
for (const [key, topicList] of Object.entries(topics)) {
|
|
148
|
+
if (themeLower.includes(key)) {
|
|
149
|
+
return topicList[index % topicList.length] || topicList[0] || "Content topic";
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return `Content topic ${index + 1}`;
|
|
153
|
+
}
|
|
154
|
+
function generateContentItems(startDate, endDate, channels, themes) {
|
|
155
|
+
const items = [];
|
|
156
|
+
let themeIndex = 0;
|
|
157
|
+
for (const channel of channels) {
|
|
158
|
+
const frequency = getChannelFrequency(channel);
|
|
159
|
+
const contentTypes = getContentTypes(channel);
|
|
160
|
+
const totalDays = Math.ceil((endDate.getTime() - startDate.getTime()) / (24 * 60 * 60 * 1e3));
|
|
161
|
+
const totalPosts = Math.ceil(totalDays / 7 * frequency);
|
|
162
|
+
const daysBetweenPosts = Math.floor(totalDays / totalPosts);
|
|
163
|
+
for (let i = 0; i < totalPosts; i++) {
|
|
164
|
+
const postDate = new Date(startDate);
|
|
165
|
+
postDate.setDate(postDate.getDate() + i * daysBetweenPosts);
|
|
166
|
+
if (postDate > endDate) break;
|
|
167
|
+
const theme = themes[themeIndex % themes.length] ?? "";
|
|
168
|
+
const contentType = contentTypes[i % contentTypes.length] ?? "post";
|
|
169
|
+
const topic = generateTopic(theme, channel, i);
|
|
170
|
+
const objective = getObjective(theme);
|
|
171
|
+
const formattedDate = postDate.toISOString().split("T")[0];
|
|
172
|
+
if (formattedDate) {
|
|
173
|
+
items.push({
|
|
174
|
+
date: formattedDate,
|
|
175
|
+
channel,
|
|
176
|
+
contentType,
|
|
177
|
+
theme,
|
|
178
|
+
topic,
|
|
179
|
+
objective,
|
|
180
|
+
suggestedFormat: contentType
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
themeIndex++;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
items.sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
|
|
187
|
+
return items;
|
|
188
|
+
}
|
|
189
|
+
function calculateSummary(items, channels, themes, weeks) {
|
|
190
|
+
const postsByChannel = {};
|
|
191
|
+
const postsByTheme = {};
|
|
192
|
+
for (const channel of channels) {
|
|
193
|
+
postsByChannel[channel] = 0;
|
|
194
|
+
}
|
|
195
|
+
for (const theme of themes) {
|
|
196
|
+
postsByTheme[theme] = 0;
|
|
197
|
+
}
|
|
198
|
+
for (const item of items) {
|
|
199
|
+
postsByChannel[item.channel] = (postsByChannel[item.channel] || 0) + 1;
|
|
200
|
+
if (item.theme) {
|
|
201
|
+
postsByTheme[item.theme] = (postsByTheme[item.theme] || 0) + 1;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
totalPosts: items.length,
|
|
206
|
+
postsByChannel,
|
|
207
|
+
postsByTheme,
|
|
208
|
+
averagePostsPerWeek: Math.round(items.length / weeks * 10) / 10
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
var contentCalendarPlanTool = tool({
|
|
212
|
+
description: "Generates a structured content calendar with posting schedule, themes, topics, and content types. Organizes content by date, channel, and theme while maintaining consistent posting frequency.",
|
|
213
|
+
inputSchema: jsonSchema({
|
|
214
|
+
type: "object",
|
|
215
|
+
properties: {
|
|
216
|
+
duration: {
|
|
217
|
+
type: "string",
|
|
218
|
+
description: 'Calendar duration (e.g., "1 week", "1 month", "quarter")'
|
|
219
|
+
},
|
|
220
|
+
channels: {
|
|
221
|
+
type: "array",
|
|
222
|
+
items: { type: "string" },
|
|
223
|
+
description: 'Content channels to plan for (e.g., ["Twitter", "Instagram", "Blog", "LinkedIn"])',
|
|
224
|
+
minItems: 1
|
|
225
|
+
},
|
|
226
|
+
themes: {
|
|
227
|
+
type: "array",
|
|
228
|
+
items: { type: "string" },
|
|
229
|
+
description: "Content themes or pillars (optional, defaults will be generated)"
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
required: ["duration", "channels"],
|
|
233
|
+
additionalProperties: false
|
|
234
|
+
}),
|
|
235
|
+
async execute({ duration, channels, themes }) {
|
|
236
|
+
if (!duration || duration.trim().length === 0) {
|
|
237
|
+
throw new Error("Duration is required");
|
|
238
|
+
}
|
|
239
|
+
if (!channels || channels.length === 0) {
|
|
240
|
+
throw new Error("At least one channel is required");
|
|
241
|
+
}
|
|
242
|
+
const { startDate, endDate, weeks } = calculateDateRange(duration);
|
|
243
|
+
const finalThemes = themes && themes.length > 0 ? themes : generateDefaultThemes();
|
|
244
|
+
const items = generateContentItems(startDate, endDate, channels, finalThemes);
|
|
245
|
+
const summary = calculateSummary(items, channels, finalThemes, weeks);
|
|
246
|
+
return {
|
|
247
|
+
duration,
|
|
248
|
+
startDate: startDate.toISOString().split("T")[0] || "",
|
|
249
|
+
endDate: endDate.toISOString().split("T")[0] || "",
|
|
250
|
+
channels,
|
|
251
|
+
themes: finalThemes,
|
|
252
|
+
items,
|
|
253
|
+
summary
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
var index_default = contentCalendarPlanTool;
|
|
258
|
+
|
|
259
|
+
export { contentCalendarPlanTool, index_default as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tpmjs/content-calendar-plan",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Generate content calendar structure with themes, topics, and posting schedule",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"tpmjs",
|
|
8
|
+
"content-calendar",
|
|
9
|
+
"marketing",
|
|
10
|
+
"planning",
|
|
11
|
+
"ai"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"tsup": "^8.3.5",
|
|
24
|
+
"typescript": "^5.9.3",
|
|
25
|
+
"@tpmjs/tsconfig": "0.0.0"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/ajaxdavis/tpmjs.git",
|
|
33
|
+
"directory": "packages/tools/official/content-calendar-plan"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://tpmjs.com",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"tpmjs": {
|
|
38
|
+
"category": "marketing",
|
|
39
|
+
"frameworks": [
|
|
40
|
+
"vercel-ai"
|
|
41
|
+
],
|
|
42
|
+
"tools": [
|
|
43
|
+
{
|
|
44
|
+
"exportName": "contentCalendarPlanTool",
|
|
45
|
+
"description": "Generates a structured content calendar with posting schedule, themes, topics, and content types. Organizes content by date, channel, and theme while maintaining consistent posting frequency.",
|
|
46
|
+
"parameters": [
|
|
47
|
+
{
|
|
48
|
+
"name": "duration",
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Calendar duration (e.g., '1 week', '1 month', 'quarter')",
|
|
51
|
+
"required": true
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "channels",
|
|
55
|
+
"type": "string[]",
|
|
56
|
+
"description": "Content channels to plan for (e.g., ['Twitter', 'Instagram', 'Blog', 'LinkedIn'])",
|
|
57
|
+
"required": true
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "themes",
|
|
61
|
+
"type": "string[]",
|
|
62
|
+
"description": "Content themes or pillars (optional, defaults will be generated)",
|
|
63
|
+
"required": false
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"returns": {
|
|
67
|
+
"type": "ContentCalendar",
|
|
68
|
+
"description": "Structured content calendar with items (date, channel, type, theme, topic, objective), summary statistics, and posting frequency breakdown"
|
|
69
|
+
},
|
|
70
|
+
"aiAgent": {
|
|
71
|
+
"useCase": "Use this tool when users need to plan content calendars for social media, blogs, or multi-channel marketing. Automatically distributes content across channels with appropriate frequency and variety.",
|
|
72
|
+
"limitations": "Generates content structure and topics, not actual content. Posting frequency is based on best practices and may need adjustment based on resources.",
|
|
73
|
+
"examples": [
|
|
74
|
+
"Create a 1 month content calendar for Twitter and Instagram",
|
|
75
|
+
"Plan a quarterly content calendar for our blog and LinkedIn",
|
|
76
|
+
"Generate a week of content ideas across all our social channels"
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"ai": "6.0.0-beta.124"
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"build": "tsup",
|
|
87
|
+
"dev": "tsup --watch",
|
|
88
|
+
"type-check": "tsc --noEmit",
|
|
89
|
+
"clean": "rm -rf dist .turbo"
|
|
90
|
+
}
|
|
91
|
+
}
|