seshat-scribe 0.9.2 → 3.0.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.
Files changed (52) hide show
  1. package/README.md +47 -58
  2. package/dist/commands/check-due.d.ts +15 -0
  3. package/dist/commands/check-due.d.ts.map +1 -0
  4. package/dist/commands/check-due.js +53 -0
  5. package/dist/commands/check-due.js.map +1 -0
  6. package/dist/commands/generate.d.ts +4 -1
  7. package/dist/commands/generate.d.ts.map +1 -1
  8. package/dist/commands/generate.js +120 -97
  9. package/dist/commands/generate.js.map +1 -1
  10. package/dist/commands/init.d.ts.map +1 -1
  11. package/dist/commands/init.js +73 -338
  12. package/dist/commands/init.js.map +1 -1
  13. package/dist/config.d.ts +21 -179
  14. package/dist/config.d.ts.map +1 -1
  15. package/dist/config.js +43 -112
  16. package/dist/config.js.map +1 -1
  17. package/dist/core/analyzer.d.ts +1 -1
  18. package/dist/core/analyzer.d.ts.map +1 -1
  19. package/dist/core/analyzer.js +2 -115
  20. package/dist/core/analyzer.js.map +1 -1
  21. package/dist/core/artist.d.ts +1 -2
  22. package/dist/core/artist.d.ts.map +1 -1
  23. package/dist/core/artist.js +2 -5
  24. package/dist/core/artist.js.map +1 -1
  25. package/dist/core/planner.d.ts +2 -2
  26. package/dist/core/sanity.d.ts +36 -1
  27. package/dist/core/sanity.d.ts.map +1 -1
  28. package/dist/core/sanity.js +78 -2
  29. package/dist/core/sanity.js.map +1 -1
  30. package/dist/core/scheduler.d.ts +45 -0
  31. package/dist/core/scheduler.d.ts.map +1 -0
  32. package/dist/core/scheduler.js +136 -0
  33. package/dist/core/scheduler.js.map +1 -0
  34. package/dist/index.js +26 -3
  35. package/dist/index.js.map +1 -1
  36. package/dist/types.d.ts +52 -0
  37. package/dist/types.d.ts.map +1 -0
  38. package/dist/types.js +5 -0
  39. package/dist/types.js.map +1 -0
  40. package/package.json +7 -8
  41. package/dist/core/writer.d.ts +0 -7
  42. package/dist/core/writer.d.ts.map +0 -1
  43. package/dist/core/writer.js +0 -126
  44. package/dist/core/writer.js.map +0 -1
  45. package/dist/lib/detection.d.ts +0 -13
  46. package/dist/lib/detection.d.ts.map +0 -1
  47. package/dist/lib/detection.js +0 -158
  48. package/dist/lib/detection.js.map +0 -1
  49. package/dist/lib/frontmatter.d.ts +0 -28
  50. package/dist/lib/frontmatter.d.ts.map +0 -1
  51. package/dist/lib/frontmatter.js +0 -114
  52. package/dist/lib/frontmatter.js.map +0 -1
package/dist/config.d.ts CHANGED
@@ -1,27 +1,5 @@
1
1
  import { z } from 'zod';
2
- /**
3
- * Frontmatter configuration schema
4
- */
5
- export declare const FrontmatterConfigSchema: z.ZodObject<{
6
- dateField: z.ZodOptional<z.ZodString>;
7
- dateFormat: z.ZodOptional<z.ZodString>;
8
- imageField: z.ZodOptional<z.ZodString>;
9
- taxonomyField: z.ZodOptional<z.ZodString>;
10
- additionalFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
11
- }, "strip", z.ZodTypeAny, {
12
- dateField?: string | undefined;
13
- dateFormat?: string | undefined;
14
- imageField?: string | undefined;
15
- taxonomyField?: string | undefined;
16
- additionalFields?: Record<string, any> | undefined;
17
- }, {
18
- dateField?: string | undefined;
19
- dateFormat?: string | undefined;
20
- imageField?: string | undefined;
21
- taxonomyField?: string | undefined;
22
- additionalFields?: Record<string, any> | undefined;
23
- }>;
24
- export type FrontmatterConfig = z.infer<typeof FrontmatterConfigSchema>;
2
+ import type { SanityConnectionConfig } from './types.js';
25
3
  /**
26
4
  * Content generation options schema
27
5
  */
@@ -71,37 +49,11 @@ export type SanityConfig = z.infer<typeof SanityConfigSchema>;
71
49
  /**
72
50
  * Zod schema for Seshat configuration
73
51
  */
74
- export declare const SeshatConfigSchema: z.ZodEffects<z.ZodObject<{
75
- contentDir: z.ZodOptional<z.ZodString>;
76
- assetsDir: z.ZodOptional<z.ZodString>;
77
- publicAssetPath: z.ZodOptional<z.ZodString>;
52
+ export declare const SeshatConfigSchema: z.ZodObject<{
78
53
  topic: z.ZodString;
79
54
  tone: z.ZodString;
80
- framework: z.ZodOptional<z.ZodEnum<["remix", "next", "astro", "custom"]>>;
81
55
  schedule: z.ZodOptional<z.ZodString>;
82
- fileExtension: z.ZodOptional<z.ZodEnum<["mdx", "md"]>>;
83
56
  imageFormat: z.ZodOptional<z.ZodEnum<["png", "jpg", "svg"]>>;
84
- fileNameTemplate: z.ZodOptional<z.ZodString>;
85
- nestedDirectories: z.ZodOptional<z.ZodBoolean>;
86
- frontmatter: z.ZodOptional<z.ZodObject<{
87
- dateField: z.ZodOptional<z.ZodString>;
88
- dateFormat: z.ZodOptional<z.ZodString>;
89
- imageField: z.ZodOptional<z.ZodString>;
90
- taxonomyField: z.ZodOptional<z.ZodString>;
91
- additionalFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
92
- }, "strip", z.ZodTypeAny, {
93
- dateField?: string | undefined;
94
- dateFormat?: string | undefined;
95
- imageField?: string | undefined;
96
- taxonomyField?: string | undefined;
97
- additionalFields?: Record<string, any> | undefined;
98
- }, {
99
- dateField?: string | undefined;
100
- dateFormat?: string | undefined;
101
- imageField?: string | undefined;
102
- taxonomyField?: string | undefined;
103
- additionalFields?: Record<string, any> | undefined;
104
- }>>;
105
57
  generation: z.ZodOptional<z.ZodObject<{
106
58
  targetWordCount: z.ZodOptional<z.ZodNumber>;
107
59
  includeCodeExamples: z.ZodOptional<z.ZodBoolean>;
@@ -121,8 +73,7 @@ export declare const SeshatConfigSchema: z.ZodEffects<z.ZodObject<{
121
73
  customInstructions?: string | undefined;
122
74
  enableImageGeneration?: boolean | undefined;
123
75
  }>>;
124
- outputMode: z.ZodOptional<z.ZodEnum<["local", "sanity"]>>;
125
- sanity: z.ZodOptional<z.ZodObject<{
76
+ sanity: z.ZodObject<{
126
77
  projectId: z.ZodString;
127
78
  dataset: z.ZodString;
128
79
  token: z.ZodOptional<z.ZodString>;
@@ -140,60 +91,19 @@ export declare const SeshatConfigSchema: z.ZodEffects<z.ZodObject<{
140
91
  token?: string | undefined;
141
92
  apiVersion?: string | undefined;
142
93
  documentType?: string | undefined;
143
- }>>;
94
+ }>;
144
95
  }, "strip", z.ZodTypeAny, {
145
96
  topic: string;
146
97
  tone: string;
147
- contentDir?: string | undefined;
148
- assetsDir?: string | undefined;
149
- publicAssetPath?: string | undefined;
150
- framework?: "remix" | "next" | "astro" | "custom" | undefined;
151
- schedule?: string | undefined;
152
- fileExtension?: "mdx" | "md" | undefined;
153
- imageFormat?: "png" | "jpg" | "svg" | undefined;
154
- fileNameTemplate?: string | undefined;
155
- nestedDirectories?: boolean | undefined;
156
- frontmatter?: {
157
- dateField?: string | undefined;
158
- dateFormat?: string | undefined;
159
- imageField?: string | undefined;
160
- taxonomyField?: string | undefined;
161
- additionalFields?: Record<string, any> | undefined;
162
- } | undefined;
163
- generation?: {
164
- targetWordCount?: number | undefined;
165
- includeCodeExamples?: boolean | undefined;
166
- seoOptimized?: boolean | undefined;
167
- customInstructions?: string | undefined;
168
- enableImageGeneration?: boolean | undefined;
169
- } | undefined;
170
- sanity?: {
98
+ sanity: {
171
99
  projectId: string;
172
100
  dataset: string;
173
101
  token?: string | undefined;
174
102
  apiVersion?: string | undefined;
175
103
  documentType?: string | undefined;
176
- } | undefined;
177
- outputMode?: "local" | "sanity" | undefined;
178
- }, {
179
- topic: string;
180
- tone: string;
181
- contentDir?: string | undefined;
182
- assetsDir?: string | undefined;
183
- publicAssetPath?: string | undefined;
184
- framework?: "remix" | "next" | "astro" | "custom" | undefined;
104
+ };
185
105
  schedule?: string | undefined;
186
- fileExtension?: "mdx" | "md" | undefined;
187
106
  imageFormat?: "png" | "jpg" | "svg" | undefined;
188
- fileNameTemplate?: string | undefined;
189
- nestedDirectories?: boolean | undefined;
190
- frontmatter?: {
191
- dateField?: string | undefined;
192
- dateFormat?: string | undefined;
193
- imageField?: string | undefined;
194
- taxonomyField?: string | undefined;
195
- additionalFields?: Record<string, any> | undefined;
196
- } | undefined;
197
107
  generation?: {
198
108
  targetWordCount?: number | undefined;
199
109
  includeCodeExamples?: boolean | undefined;
@@ -201,67 +111,18 @@ export declare const SeshatConfigSchema: z.ZodEffects<z.ZodObject<{
201
111
  customInstructions?: string | undefined;
202
112
  enableImageGeneration?: boolean | undefined;
203
113
  } | undefined;
204
- sanity?: {
205
- projectId: string;
206
- dataset: string;
207
- token?: string | undefined;
208
- apiVersion?: string | undefined;
209
- documentType?: string | undefined;
210
- } | undefined;
211
- outputMode?: "local" | "sanity" | undefined;
212
- }>, {
114
+ }, {
213
115
  topic: string;
214
116
  tone: string;
215
- contentDir?: string | undefined;
216
- assetsDir?: string | undefined;
217
- publicAssetPath?: string | undefined;
218
- framework?: "remix" | "next" | "astro" | "custom" | undefined;
219
- schedule?: string | undefined;
220
- fileExtension?: "mdx" | "md" | undefined;
221
- imageFormat?: "png" | "jpg" | "svg" | undefined;
222
- fileNameTemplate?: string | undefined;
223
- nestedDirectories?: boolean | undefined;
224
- frontmatter?: {
225
- dateField?: string | undefined;
226
- dateFormat?: string | undefined;
227
- imageField?: string | undefined;
228
- taxonomyField?: string | undefined;
229
- additionalFields?: Record<string, any> | undefined;
230
- } | undefined;
231
- generation?: {
232
- targetWordCount?: number | undefined;
233
- includeCodeExamples?: boolean | undefined;
234
- seoOptimized?: boolean | undefined;
235
- customInstructions?: string | undefined;
236
- enableImageGeneration?: boolean | undefined;
237
- } | undefined;
238
- sanity?: {
117
+ sanity: {
239
118
  projectId: string;
240
119
  dataset: string;
241
120
  token?: string | undefined;
242
121
  apiVersion?: string | undefined;
243
122
  documentType?: string | undefined;
244
- } | undefined;
245
- outputMode?: "local" | "sanity" | undefined;
246
- }, {
247
- topic: string;
248
- tone: string;
249
- contentDir?: string | undefined;
250
- assetsDir?: string | undefined;
251
- publicAssetPath?: string | undefined;
252
- framework?: "remix" | "next" | "astro" | "custom" | undefined;
123
+ };
253
124
  schedule?: string | undefined;
254
- fileExtension?: "mdx" | "md" | undefined;
255
125
  imageFormat?: "png" | "jpg" | "svg" | undefined;
256
- fileNameTemplate?: string | undefined;
257
- nestedDirectories?: boolean | undefined;
258
- frontmatter?: {
259
- dateField?: string | undefined;
260
- dateFormat?: string | undefined;
261
- imageField?: string | undefined;
262
- taxonomyField?: string | undefined;
263
- additionalFields?: Record<string, any> | undefined;
264
- } | undefined;
265
126
  generation?: {
266
127
  targetWordCount?: number | undefined;
267
128
  includeCodeExamples?: boolean | undefined;
@@ -269,43 +130,24 @@ export declare const SeshatConfigSchema: z.ZodEffects<z.ZodObject<{
269
130
  customInstructions?: string | undefined;
270
131
  enableImageGeneration?: boolean | undefined;
271
132
  } | undefined;
272
- sanity?: {
273
- projectId: string;
274
- dataset: string;
275
- token?: string | undefined;
276
- apiVersion?: string | undefined;
277
- documentType?: string | undefined;
278
- } | undefined;
279
- outputMode?: "local" | "sanity" | undefined;
280
133
  }>;
281
134
  export type SeshatConfig = z.infer<typeof SeshatConfigSchema>;
282
135
  /**
283
- * Framework preset configurations
284
- * Note: 'custom' framework type has no preset and allows manual configuration
136
+ * Default image format
285
137
  */
286
- export declare const FRAMEWORK_PRESETS: Record<'remix' | 'next' | 'astro', Partial<SeshatConfig>>;
287
- /**
288
- * Default configuration values (for local output mode)
289
- */
290
- export declare const DEFAULT_CONFIG: {
291
- contentDir: string;
292
- assetsDir: string;
293
- publicAssetPath: string;
294
- topic: string;
295
- tone: string;
296
- framework: "remix";
297
- fileExtension: "mdx";
298
- imageFormat: "png";
299
- fileNameTemplate: string;
300
- nestedDirectories: boolean;
301
- outputMode: "local";
302
- };
303
- /**
304
- * Resolve configuration with framework presets and defaults
305
- */
306
- export declare function resolveConfig(config: SeshatConfig): SeshatConfig;
138
+ export declare const DEFAULT_IMAGE_FORMAT: "png";
307
139
  /**
308
140
  * Load and validate configuration from file
141
+ * @deprecated Use loadTopicFromSanity instead for Sanity-native configuration
309
142
  */
310
143
  export declare function loadConfig(configPath: string): Promise<SeshatConfig>;
144
+ /**
145
+ * Load configuration from a Sanity contentTopic document
146
+ * This is the primary configuration method for Seshat
147
+ *
148
+ * @param sanityConfig - Sanity connection configuration
149
+ * @param topicId - Content topic document ID
150
+ * @returns SeshatConfig transformed from the topic document
151
+ */
152
+ export declare function loadTopicFromSanity(sanityConfig: SanityConnectionConfig, topicId: string): Promise<SeshatConfig>;
311
153
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;EAMlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;EAMjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;EAM7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuC9B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,iBA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AmB,CACvC,YAAY,EAAE,sBAAsB,EACpC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,CAAC,CA4BvB"}
package/dist/config.js CHANGED
@@ -1,14 +1,5 @@
1
1
  import { z } from 'zod';
2
- /**
3
- * Frontmatter configuration schema
4
- */
5
- export const FrontmatterConfigSchema = z.object({
6
- dateField: z.string().optional().describe('Field name for date (e.g., "date", "pubDate", "publishedAt")'),
7
- dateFormat: z.string().optional().describe('Date format: "iso" (default), "date-only", or custom format'),
8
- imageField: z.string().optional().describe('Field name for image (e.g., "image", "coverImage", "heroImage")'),
9
- taxonomyField: z.string().optional().describe('Field name for primary taxonomy (e.g., "tag", "category")'),
10
- additionalFields: z.record(z.any()).optional().describe('Additional custom frontmatter fields'),
11
- });
2
+ import { createSanityClientFromConfig, fetchContentTopic } from './core/sanity.js';
12
3
  /**
13
4
  * Content generation options schema
14
5
  */
@@ -33,126 +24,66 @@ export const SanityConfigSchema = z.object({
33
24
  * Zod schema for Seshat configuration
34
25
  */
35
26
  export const SeshatConfigSchema = z.object({
36
- contentDir: z.string().optional().describe('Directory containing blog MDX files (required for local/both output modes)'),
37
- assetsDir: z.string().optional().describe('Directory for generated images (required for local/both output modes)'),
38
- publicAssetPath: z.string().optional().describe('Public URL path for images (required for local/both output modes)'),
39
27
  topic: z.string().describe('Global topic constraint for content generation'),
40
28
  tone: z.string().describe('Writing tone (e.g., "Professional yet witty")'),
41
- framework: z.enum(['remix', 'next', 'astro', 'custom']).optional().describe('Blog framework type (uses preset configuration, or custom for manual configuration)'),
42
29
  schedule: z
43
30
  .string()
44
31
  .optional()
45
32
  .describe('Cron expression for GitHub Actions (e.g. "0 9 * * *" for daily at 9 UTC)'),
46
- // File structure options
47
- fileExtension: z.enum(['mdx', 'md']).optional().describe('File extension for posts'),
48
33
  imageFormat: z.enum(['png', 'jpg', 'svg']).optional().describe('Image format for generated images'),
49
- fileNameTemplate: z.string().optional().describe('Template for file naming (e.g., "{{slug}}", "{{date}}-{{slug}}")'),
50
- nestedDirectories: z.boolean().optional().describe('Use date-based nested directories (e.g., 2024/01/)'),
51
- // Frontmatter customization
52
- frontmatter: FrontmatterConfigSchema.optional().describe('Custom frontmatter configuration'),
53
- // Content generation options
54
34
  generation: GenerationConfigSchema.optional().describe('Content generation options'),
55
- // Output mode and Sanity CMS integration
56
- outputMode: z.enum(['local', 'sanity']).optional().describe('Output mode: local files or Sanity CMS (default: local)'),
57
- sanity: SanityConfigSchema.optional().describe('Sanity CMS configuration (required when outputMode is "sanity")'),
58
- }).refine((data) => {
59
- const mode = data.outputMode || 'local';
60
- // If using local mode, contentDir, assetsDir, and publicAssetPath are required
61
- if (mode === 'local') {
62
- return !!(data.contentDir && data.assetsDir && data.publicAssetPath);
63
- }
64
- return true;
65
- }, {
66
- message: 'contentDir, assetsDir, and publicAssetPath are required when outputMode is "local"',
35
+ sanity: SanityConfigSchema.describe('Sanity CMS configuration (required)'),
67
36
  });
68
37
  /**
69
- * Framework preset configurations
70
- * Note: 'custom' framework type has no preset and allows manual configuration
71
- */
72
- export const FRAMEWORK_PRESETS = {
73
- remix: {
74
- fileExtension: 'mdx',
75
- frontmatter: {
76
- dateField: 'date',
77
- dateFormat: 'iso',
78
- imageField: 'image',
79
- taxonomyField: 'tag',
80
- },
81
- },
82
- next: {
83
- fileExtension: 'mdx',
84
- frontmatter: {
85
- dateField: 'date',
86
- dateFormat: 'iso',
87
- imageField: 'coverImage',
88
- taxonomyField: 'tag',
89
- },
90
- },
91
- astro: {
92
- fileExtension: 'mdx',
93
- frontmatter: {
94
- dateField: 'pubDate',
95
- dateFormat: 'iso',
96
- imageField: 'heroImage',
97
- taxonomyField: 'tag',
98
- },
99
- },
100
- };
101
- /**
102
- * Default configuration values (for local output mode)
103
- */
104
- export const DEFAULT_CONFIG = {
105
- contentDir: 'app/routes/blog',
106
- assetsDir: 'public/images/generated',
107
- publicAssetPath: '/images/generated',
108
- topic: 'Software Engineering and Technology',
109
- tone: 'Professional yet witty',
110
- framework: 'remix',
111
- fileExtension: 'mdx',
112
- imageFormat: 'png',
113
- fileNameTemplate: '{{slug}}',
114
- nestedDirectories: false,
115
- outputMode: 'local',
116
- };
117
- /**
118
- * Resolve configuration with framework presets and defaults
38
+ * Default image format
119
39
  */
120
- export function resolveConfig(config) {
121
- // If framework is specified and not 'custom', merge with preset
122
- let resolved = { ...config };
123
- if (config.framework && config.framework !== 'custom' && FRAMEWORK_PRESETS[config.framework]) {
124
- const preset = FRAMEWORK_PRESETS[config.framework];
125
- // Apply preset values only if not explicitly set
126
- if (!config.fileExtension)
127
- resolved.fileExtension = preset.fileExtension;
128
- if (!config.frontmatter)
129
- resolved.frontmatter = preset.frontmatter;
130
- }
131
- // Apply remaining defaults
132
- resolved.fileExtension = resolved.fileExtension || DEFAULT_CONFIG.fileExtension;
133
- resolved.imageFormat = resolved.imageFormat || DEFAULT_CONFIG.imageFormat;
134
- resolved.fileNameTemplate = resolved.fileNameTemplate || DEFAULT_CONFIG.fileNameTemplate;
135
- resolved.nestedDirectories = resolved.nestedDirectories ?? DEFAULT_CONFIG.nestedDirectories;
136
- resolved.outputMode = resolved.outputMode ?? 'local';
137
- // Default frontmatter config if none provided
138
- if (!resolved.frontmatter) {
139
- resolved.frontmatter = {
140
- dateField: 'date',
141
- dateFormat: 'iso',
142
- imageField: 'image',
143
- taxonomyField: 'tag',
144
- };
145
- }
146
- return resolved;
147
- }
40
+ export const DEFAULT_IMAGE_FORMAT = 'png';
148
41
  /**
149
42
  * Load and validate configuration from file
43
+ * @deprecated Use loadTopicFromSanity instead for Sanity-native configuration
150
44
  */
151
45
  export async function loadConfig(configPath) {
152
46
  const fs = await import('fs/promises');
153
47
  const raw = await fs.readFile(configPath, 'utf-8');
154
48
  const json = JSON.parse(raw);
155
49
  const config = SeshatConfigSchema.parse(json);
156
- return resolveConfig(config);
50
+ // Apply default for imageFormat if not provided
51
+ if (!config.imageFormat) {
52
+ config.imageFormat = DEFAULT_IMAGE_FORMAT;
53
+ }
54
+ return config;
55
+ }
56
+ /**
57
+ * Load configuration from a Sanity contentTopic document
58
+ * This is the primary configuration method for Seshat
59
+ *
60
+ * @param sanityConfig - Sanity connection configuration
61
+ * @param topicId - Content topic document ID
62
+ * @returns SeshatConfig transformed from the topic document
63
+ */
64
+ export async function loadTopicFromSanity(sanityConfig, topicId) {
65
+ // Create read-only client
66
+ const client = createSanityClientFromConfig(sanityConfig, { readOnly: true });
67
+ // Fetch the topic document
68
+ const topic = await fetchContentTopic(client, topicId);
69
+ // Check if topic is active
70
+ if (!topic.active) {
71
+ throw new Error(`Content topic "${topic.name}" (${topicId}) is not active`);
72
+ }
73
+ // Transform ContentTopicDocument to SeshatConfig
74
+ const config = {
75
+ topic: topic.topic,
76
+ tone: topic.tone,
77
+ schedule: topic.cronSchedule,
78
+ imageFormat: topic.sanityOverride?.imageFormat || DEFAULT_IMAGE_FORMAT,
79
+ generation: topic.generation,
80
+ sanity: {
81
+ projectId: sanityConfig.projectId,
82
+ dataset: sanityConfig.dataset,
83
+ apiVersion: sanityConfig.apiVersion || '2024-01-01',
84
+ documentType: topic.sanityOverride?.documentType || 'post',
85
+ },
86
+ };
87
+ return config;
157
88
  }
158
89
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8DAA8D,CAAC;IACzG,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6DAA6D,CAAC;IACzG,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iEAAiE,CA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MAAM,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE7E,2BAA2B;IAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,CAAC,IAAI,MAAM,OAAO,iBAAiB,CAAC,CAAC;IAC9E,CAAC;IAED,iDAAiD;IACjD,MAAM,MAAM,GAAiB;QAC3B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,YAAY;QAC5B,WAAW,EAAE,KAAK,CAAC,cAAc,EAAE,WAAW,IAAI,oBAAoB;QACtE,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,MAAM,EAAE;YACN,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,UAAU,EAAE,YAAY,CAAC,UAAU,IAAI,YAAY;YACnD,YAAY,EAAE,KAAK,CAAC,cAAc,EAAE,YAAY,IAAI,MAAM;SAC3D;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -18,7 +18,7 @@ export interface RepositoryContext {
18
18
  recentTopics: string[];
19
19
  }
20
20
  /**
21
- * Scan repository - chooses between local files or Sanity based on outputMode
21
+ * Scan repository - fetches existing posts from Sanity CMS
22
22
  */
23
23
  export declare function scanRepository(config: SeshatConfig): Promise<RepositoryContext>;
24
24
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../src/core/analyzer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AA+JD;;GAEG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAUrF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAQnE"}
1
+ {"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../src/core/analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0CrF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAQnE"}
@@ -1,11 +1,8 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import matter from 'gray-matter';
4
1
  import { getSanityClient } from './sanity.js';
5
2
  /**
6
- * Fetch existing posts from Sanity CMS
3
+ * Scan repository - fetches existing posts from Sanity CMS
7
4
  */
8
- async function scanSanityPosts(config) {
5
+ export async function scanRepository(config) {
9
6
  const client = getSanityClient(config, { readOnly: true });
10
7
  const documentType = config.sanity?.documentType || 'post';
11
8
  // Query all posts from Sanity
@@ -44,116 +41,6 @@ async function scanSanityPosts(config) {
44
41
  };
45
42
  }
46
43
  }
47
- /**
48
- * Scan the content directory and extract metadata from all MDX files
49
- */
50
- async function scanLocalPosts(config) {
51
- // Get frontmatter field names from config
52
- const dateField = config.frontmatter?.dateField || 'date';
53
- const taxonomyField = config.frontmatter?.taxonomyField || 'tag';
54
- if (!config.contentDir) {
55
- // If no contentDir, return empty context
56
- return {
57
- totalPosts: 0,
58
- posts: [],
59
- recentTopics: [],
60
- };
61
- }
62
- const contentPath = path.resolve(process.cwd(), config.contentDir);
63
- try {
64
- await fs.access(contentPath);
65
- }
66
- catch {
67
- // Directory doesn't exist yet, return empty context
68
- return {
69
- totalPosts: 0,
70
- posts: [],
71
- recentTopics: [],
72
- };
73
- }
74
- const posts = [];
75
- // Recursively scan for MD/MDX files (to support nested directories)
76
- async function* findMarkdownFiles(dir) {
77
- const entries = await fs.readdir(dir, { withFileTypes: true });
78
- for (const entry of entries) {
79
- const fullPath = path.join(dir, entry.name);
80
- if (entry.isDirectory()) {
81
- yield* findMarkdownFiles(fullPath);
82
- }
83
- else if (/\.(md|mdx)$/i.test(entry.name)) {
84
- yield fullPath;
85
- }
86
- }
87
- }
88
- for await (const filePath of findMarkdownFiles(contentPath)) {
89
- const fileName = path.basename(filePath);
90
- const slug = fileName.replace(/\.(md|mdx)$/i, '');
91
- try {
92
- const content = await fs.readFile(filePath, 'utf-8');
93
- // Try gray-matter first
94
- let data;
95
- try {
96
- const parsed = matter(content);
97
- data = parsed.data;
98
- }
99
- catch (yamlError) {
100
- // Fallback: manual YAML parsing for problematic frontmatter
101
- const frontmatterMatch = content.match(/^---\n([\s\S]+?)\n---/);
102
- if (!frontmatterMatch)
103
- throw yamlError;
104
- const fm = frontmatterMatch[1];
105
- // Extract fields manually using configured field names
106
- const titleMatch = fm.match(/^title:\s*['"](.+?)['"]?\s*$/m);
107
- const descMatch = fm.match(/^description:\s*>-?\s*\n((?:\s+.+\n?)+)/m);
108
- const tagMatch = fm.match(new RegExp(`^${taxonomyField}s?:\\s*(.+?)\\s*$`, 'm'));
109
- const dateMatch = fm.match(new RegExp(`^${dateField}:\\s*(.+?)\\s*$`, 'm'));
110
- data = {
111
- title: titleMatch ? titleMatch[1] : slug,
112
- description: descMatch ? descMatch[1].replace(/\n\s+/g, ' ').trim() : undefined,
113
- tag: tagMatch ? tagMatch[1].trim() : undefined,
114
- tags: undefined,
115
- date: dateMatch ? dateMatch[1].trim() : undefined,
116
- };
117
- }
118
- // Handle configured taxonomy field (singular or plural)
119
- const taxonomyValue = data[taxonomyField] || data[`${taxonomyField}s`] || data.tags || data.tag;
120
- const tags = Array.isArray(taxonomyValue) ? taxonomyValue : (taxonomyValue ? [taxonomyValue] : undefined);
121
- // Get date from configured field
122
- const dateValue = data[dateField] || data.date || data.pubDate;
123
- posts.push({
124
- title: data.title || slug,
125
- description: data.description,
126
- tags,
127
- date: dateValue,
128
- slug,
129
- });
130
- }
131
- catch (err) {
132
- // Skip files that can't be read or parsed
133
- continue;
134
- }
135
- }
136
- // Extract unique topics from tags
137
- const allTags = posts.flatMap((p) => p.tags || []);
138
- const uniqueTags = [...new Set(allTags)];
139
- return {
140
- totalPosts: posts.length,
141
- posts,
142
- recentTopics: uniqueTags.slice(0, 20), // Limit to most recent topics
143
- };
144
- }
145
- /**
146
- * Scan repository - chooses between local files or Sanity based on outputMode
147
- */
148
- export async function scanRepository(config) {
149
- const outputMode = config.outputMode || 'local';
150
- // If using Sanity, fetch from Sanity
151
- if (outputMode === 'sanity') {
152
- return await scanSanityPosts(config);
153
- }
154
- // Otherwise, scan local files
155
- return await scanLocalPosts(config);
156
- }
157
44
  /**
158
45
  * Create a compact JSON summary for Gemini (minimize token usage)
159
46
  */
@@ -1 +1 @@
1
- {"version":3,"file":"analyzer.js","sourceRoot":"","sources":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AAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QAEzC,OAAO;YACL,UAAU,EAAE,KAAK,CAAC,MAAM;YACxB,KAAK;YACL,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;SACtC,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,8CAA8C;QAC9C,OAAO,CAAC,IAAI,CAAC,oCAAoC,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QACzG,OAAO;YACL,UAAU,EAAE,CAAC;YACb,KAAK,EAAE,EAAE;YACT,YAAY,EAAE,EAAE;SACjB,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA0B;IACzD,MAAM,OAAO,GAAG;QACd,KAAK,EAAE,OAAO,CAAC,UAAU;QACzB,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACzC,MAAM,EAAE,OAAO,CAAC,YAAY;KAC7B,CAAC;IAEF,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1C,CAAC"}
@@ -1,6 +1,5 @@
1
- import type { SeshatConfig } from '../config.js';
2
1
  /**
3
2
  * Generate an image using Gemini's Imagen 4.0 model
4
3
  */
5
- export declare function generateImage(config: SeshatConfig, imagePrompt: string, slug: string): Promise<string>;
4
+ export declare function generateImage(imagePrompt: string, slug: string, assetsDir: string): Promise<string>;
6
5
  //# sourceMappingURL=artist.d.ts.map