mulmocast-preprocessor 0.5.2 → 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.
@@ -1,6 +1,6 @@
1
1
  import { readFileSync, writeFileSync } from "fs";
2
2
  import { GraphAILogger } from "graphai";
3
- import { processScript } from "../../core/preprocessing/process.js";
3
+ import { processScript } from "@mulmocast/script-utils";
4
4
  /**
5
5
  * Process script with profile and output result
6
6
  */
@@ -1,6 +1,6 @@
1
1
  import { readFileSync } from "fs";
2
2
  import { GraphAILogger } from "graphai";
3
- import { listProfiles } from "../../core/preprocessing/profiles.js";
3
+ import { listProfiles } from "@mulmocast/script-utils";
4
4
  /**
5
5
  * List available profiles in script
6
6
  */
@@ -4,5 +4,3 @@ import type { QueryOptions, QueryResult } from "../../../../types/query.js";
4
4
  * Main query function - answers a question based on script content
5
5
  */
6
6
  export declare const queryScript: (script: ExtendedMulmoScript, question: string, options?: Partial<QueryOptions>) => Promise<QueryResult>;
7
- export type { QueryOptions, QueryResult } from "../../../../types/query.js";
8
- export { queryOptionsSchema } from "../../../../types/query.js";
@@ -1,6 +1,6 @@
1
1
  import { queryOptionsSchema } from "../../../../types/query.js";
2
- import { executeLLM, filterScript } from "../../llm.js";
3
- import { buildUserPrompt, getSystemPrompt } from "./prompts.js";
2
+ import { executeLLM } from "../../llm.js";
3
+ import { filterScript, buildQueryPrompt, buildSystemPrompt, DEFAULT_QUERY_SYSTEM_PROMPT } from "@mulmocast/script-utils";
4
4
  /**
5
5
  * Main query function - answers a question based on script content
6
6
  */
@@ -19,8 +19,8 @@ export const queryScript = async (script, question, options = {}) => {
19
19
  };
20
20
  }
21
21
  // Build prompts
22
- const systemPrompt = getSystemPrompt(validatedOptions);
23
- const userPrompt = buildUserPrompt(filteredScript, question);
22
+ const systemPrompt = buildSystemPrompt(DEFAULT_QUERY_SYSTEM_PROMPT, validatedOptions);
23
+ const userPrompt = buildQueryPrompt(filteredScript, question);
24
24
  // Execute LLM
25
25
  const answer = await executeLLM(systemPrompt, userPrompt, validatedOptions, `Querying script "${script.title}" with ${validatedOptions.provider}... Beats: ${filteredScript.beats.length}, Question: ${question}`);
26
26
  return {
@@ -30,4 +30,3 @@ export const queryScript = async (script, question, options = {}) => {
30
30
  beatCount: filteredScript.beats.length,
31
31
  };
32
32
  };
33
- export { queryOptionsSchema } from "../../../../types/query.js";
@@ -1,6 +1,6 @@
1
1
  import { queryOptionsSchema } from "../../../../types/query.js";
2
- import { executeLLM, filterScript, getLanguageName } from "../../llm.js";
3
- import { buildInteractiveUserPrompt, getInteractiveSystemPrompt, DEFAULT_INTERACTIVE_SYSTEM_PROMPT_WITH_FETCH } from "./prompts.js";
2
+ import { executeLLM } from "../../llm.js";
3
+ import { filterScript, buildInteractiveQueryPrompt, buildSystemPrompt, DEFAULT_INTERACTIVE_SYSTEM_PROMPT, DEFAULT_INTERACTIVE_SYSTEM_PROMPT_WITH_FETCH, } from "@mulmocast/script-utils";
4
4
  import { fetchUrlContent, findMatchingReference } from "../../utils/fetcher.js";
5
5
  /**
6
6
  * Create an interactive query session
@@ -23,8 +23,8 @@ export const sendInteractiveQuery = async (filteredScript, question, session, op
23
23
  if (filteredScript.beats.length === 0) {
24
24
  return "No content available to answer the question.";
25
25
  }
26
- const systemPrompt = getInteractiveSystemPrompt(options);
27
- const userPrompt = buildInteractiveUserPrompt(filteredScript, question, session.history);
26
+ const systemPrompt = buildSystemPrompt(DEFAULT_INTERACTIVE_SYSTEM_PROMPT, options);
27
+ const userPrompt = buildInteractiveQueryPrompt(filteredScript, question, session.history);
28
28
  const answer = await executeLLM(systemPrompt, userPrompt, options, options.verbose ? `Interactive query: ${question}` : undefined);
29
29
  // Add to history
30
30
  session.history.push({ role: "user", content: question });
@@ -88,13 +88,9 @@ export const sendInteractiveQueryWithFetch = async (filteredScript, question, fe
88
88
  return "No content available to answer the question.";
89
89
  }
90
90
  // Build system prompt for fetched content mode
91
- let systemPrompt = DEFAULT_INTERACTIVE_SYSTEM_PROMPT_WITH_FETCH;
92
- if (options.lang) {
93
- const langName = getLanguageName(options.lang);
94
- systemPrompt = `${systemPrompt}\n- IMPORTANT: Write the answer in ${langName}`;
95
- }
91
+ const systemPrompt = buildSystemPrompt(DEFAULT_INTERACTIVE_SYSTEM_PROMPT_WITH_FETCH, options);
96
92
  // Build user prompt with fetched content
97
- const baseUserPrompt = buildInteractiveUserPrompt(filteredScript, question, session.history);
93
+ const baseUserPrompt = buildInteractiveQueryPrompt(filteredScript, question, session.history);
98
94
  // Insert fetched content before the question
99
95
  const fetchedSection = [
100
96
  "",
@@ -4,5 +4,3 @@ import type { SummarizeOptions, SummarizeResult } from "../../../../types/summar
4
4
  * Main summarize function - generates a summary of the entire script
5
5
  */
6
6
  export declare const summarizeScript: (script: ExtendedMulmoScript, options?: Partial<SummarizeOptions>) => Promise<SummarizeResult>;
7
- export type { SummarizeOptions, SummarizeResult, LLMProvider, SummarizeFormat } from "../../../../types/summarize.js";
8
- export { summarizeOptionsSchema, llmProviderSchema, summarizeFormatSchema } from "../../../../types/summarize.js";
@@ -1,6 +1,6 @@
1
1
  import { summarizeOptionsSchema } from "../../../../types/summarize.js";
2
- import { executeLLM, filterScript } from "../../llm.js";
3
- import { buildUserPrompt, getSystemPrompt } from "./prompts.js";
2
+ import { executeLLM } from "../../llm.js";
3
+ import { filterScript, buildSummarizePrompt, buildSystemPrompt, DEFAULT_SUMMARIZE_TEXT_SYSTEM_PROMPT, DEFAULT_SUMMARIZE_MARKDOWN_SYSTEM_PROMPT, } from "@mulmocast/script-utils";
4
4
  /**
5
5
  * Main summarize function - generates a summary of the entire script
6
6
  */
@@ -19,8 +19,9 @@ export const summarizeScript = async (script, options = {}) => {
19
19
  };
20
20
  }
21
21
  // Build prompts
22
- const systemPrompt = getSystemPrompt(validatedOptions);
23
- const userPrompt = buildUserPrompt(filteredScript, validatedOptions);
22
+ const basePrompt = validatedOptions.format === "markdown" ? DEFAULT_SUMMARIZE_MARKDOWN_SYSTEM_PROMPT : DEFAULT_SUMMARIZE_TEXT_SYSTEM_PROMPT;
23
+ const systemPrompt = buildSystemPrompt(basePrompt, validatedOptions);
24
+ const userPrompt = buildSummarizePrompt(filteredScript, validatedOptions);
24
25
  // Execute LLM
25
26
  const summary = await executeLLM(systemPrompt, userPrompt, validatedOptions, `Summarizing script "${script.title}" with ${validatedOptions.provider}... Beats: ${filteredScript.beats.length}, Format: ${validatedOptions.format}`);
26
27
  return {
@@ -30,4 +31,3 @@ export const summarizeScript = async (script, options = {}) => {
30
31
  beatCount: filteredScript.beats.length,
31
32
  };
32
33
  };
33
- export { summarizeOptionsSchema, llmProviderSchema, summarizeFormatSchema } from "../../../../types/summarize.js";
@@ -1,4 +1,3 @@
1
- import type { ExtendedMulmoScript } from "@mulmocast/extended-types";
2
1
  import type { LLMProvider } from "../../types/summarize.js";
3
2
  /**
4
3
  * Base options for LLM operations
@@ -31,30 +30,6 @@ export declare const getProviderConfig: (provider: LLMProvider) => ProviderConfi
31
30
  * Get API key for provider
32
31
  */
33
32
  export declare const getProviderApiKey: (provider: LLMProvider) => string | undefined;
34
- /**
35
- * Filter script based on options (section, tags)
36
- */
37
- export declare const filterScript: (script: ExtendedMulmoScript, options: BaseLLMOptions) => ExtendedMulmoScript;
38
- /**
39
- * Get language name from code
40
- */
41
- export declare const getLanguageName: (langCode: string) => string;
42
- /**
43
- * Build script content for user prompt (common part)
44
- */
45
- export declare const buildScriptContent: (script: ExtendedMulmoScript) => string;
46
- /**
47
- * Command execution result
48
- */
49
- export interface CommandResult {
50
- text: string;
51
- scriptTitle: string;
52
- beatCount: number;
53
- }
54
- /**
55
- * Execute a command (summarize, query, etc.) with common logic
56
- */
57
- export declare const executeCommand: <T extends BaseLLMOptions>(script: ExtendedMulmoScript, options: T, getSystemPrompt: (opts: T) => string, buildUserPrompt: (script: ExtendedMulmoScript) => string, verboseMessage: string) => Promise<CommandResult | null>;
58
33
  /**
59
34
  * Execute LLM call with GraphAI
60
35
  */
@@ -5,7 +5,6 @@ import { openAIAgent } from "@graphai/openai_agent";
5
5
  import { anthropicAgent } from "@graphai/anthropic_agent";
6
6
  import { groqAgent } from "@graphai/groq_agent";
7
7
  import { geminiAgent } from "@graphai/gemini_agent";
8
- import { filterBySection, filterByTags } from "../preprocessing/filter.js";
9
8
  dotenv.config({ quiet: true });
10
9
  const agents = vanillaAgents.default ?? vanillaAgents;
11
10
  const provider2Agent = {
@@ -77,168 +76,6 @@ const createLLMGraph = (agentName) => ({
77
76
  },
78
77
  },
79
78
  });
80
- /**
81
- * Filter script based on options (section, tags)
82
- */
83
- export const filterScript = (script, options) => {
84
- const afterSection = options.section ? filterBySection(script, options.section) : script;
85
- const afterTags = options.tags && options.tags.length > 0 ? filterByTags(afterSection, options.tags) : afterSection;
86
- return afterTags;
87
- };
88
- /**
89
- * Get language name from code
90
- */
91
- export const getLanguageName = (langCode) => {
92
- const langMap = {
93
- ja: "Japanese",
94
- en: "English",
95
- zh: "Chinese",
96
- ko: "Korean",
97
- fr: "French",
98
- de: "German",
99
- es: "Spanish",
100
- it: "Italian",
101
- pt: "Portuguese",
102
- ru: "Russian",
103
- };
104
- return langMap[langCode] || langCode;
105
- };
106
- /**
107
- * Build beat content including metadata
108
- */
109
- const buildBeatContent = (beat, index) => {
110
- const lines = [];
111
- // Main text
112
- const text = beat.text || "";
113
- if (!text.trim())
114
- return "";
115
- lines.push(`[${index}] ${text}`);
116
- // Add metadata if available
117
- const meta = beat.meta;
118
- if (meta) {
119
- // Tags for categorization
120
- if (meta.tags && meta.tags.length > 0) {
121
- lines.push(` Tags: ${meta.tags.join(", ")}`);
122
- }
123
- // Context provides additional information not in the text
124
- if (meta.context) {
125
- lines.push(` Context: ${meta.context}`);
126
- }
127
- // Keywords highlight important terms
128
- if (meta.keywords && meta.keywords.length > 0) {
129
- lines.push(` Keywords: ${meta.keywords.join(", ")}`);
130
- }
131
- // Expected questions this beat can answer
132
- if (meta.expectedQuestions && meta.expectedQuestions.length > 0) {
133
- lines.push(` Can answer: ${meta.expectedQuestions.join("; ")}`);
134
- }
135
- }
136
- return lines.join("\n");
137
- };
138
- /**
139
- * Build script-level metadata section
140
- */
141
- const buildScriptMetaContent = (script) => {
142
- const meta = script.scriptMeta;
143
- if (!meta)
144
- return "";
145
- const lines = [];
146
- // Background info
147
- if (meta.background) {
148
- lines.push(`Background: ${meta.background}`);
149
- }
150
- // Audience and prerequisites
151
- if (meta.audience) {
152
- lines.push(`Target audience: ${meta.audience}`);
153
- }
154
- if (meta.prerequisites && meta.prerequisites.length > 0) {
155
- lines.push(`Prerequisites: ${meta.prerequisites.join(", ")}`);
156
- }
157
- // Goals
158
- if (meta.goals && meta.goals.length > 0) {
159
- lines.push(`Goals: ${meta.goals.join("; ")}`);
160
- }
161
- // Keywords
162
- if (meta.keywords && meta.keywords.length > 0) {
163
- lines.push(`Keywords: ${meta.keywords.join(", ")}`);
164
- }
165
- // References
166
- if (meta.references && meta.references.length > 0) {
167
- lines.push("References:");
168
- meta.references.forEach((ref) => {
169
- const title = ref.title || ref.url;
170
- const desc = ref.description ? ` - ${ref.description}` : "";
171
- lines.push(` - [${ref.type || "web"}] ${title}: ${ref.url}${desc}`);
172
- });
173
- }
174
- // FAQ
175
- if (meta.faq && meta.faq.length > 0) {
176
- lines.push("FAQ:");
177
- meta.faq.forEach((faq) => {
178
- lines.push(` Q: ${faq.question}`);
179
- lines.push(` A: ${faq.answer}`);
180
- });
181
- }
182
- // Author info
183
- if (meta.author) {
184
- lines.push(`Author: ${meta.author}`);
185
- }
186
- return lines.length > 0 ? lines.join("\n") : "";
187
- };
188
- /**
189
- * Build script content for user prompt (common part)
190
- */
191
- export const buildScriptContent = (script) => {
192
- const parts = [];
193
- // Add script title and language
194
- parts.push(`# Script: ${script.title}`);
195
- parts.push(`Language: ${script.lang}`);
196
- parts.push("");
197
- // Add script-level metadata
198
- const scriptMetaContent = buildScriptMetaContent(script);
199
- if (scriptMetaContent) {
200
- parts.push("## About this content");
201
- parts.push(scriptMetaContent);
202
- parts.push("");
203
- }
204
- // Collect all content from beats grouped by section
205
- const sections = new Map();
206
- script.beats.forEach((beat, index) => {
207
- const content = buildBeatContent(beat, index);
208
- if (!content)
209
- return;
210
- const section = beat.meta?.section || "main";
211
- if (!sections.has(section)) {
212
- sections.set(section, []);
213
- }
214
- sections.get(section).push(content);
215
- });
216
- // Output by section
217
- sections.forEach((contents, section) => {
218
- parts.push(`## Section: ${section}`);
219
- contents.forEach((c) => parts.push(c));
220
- parts.push("");
221
- });
222
- return parts.join("\n");
223
- };
224
- /**
225
- * Execute a command (summarize, query, etc.) with common logic
226
- */
227
- export const executeCommand = async (script, options, getSystemPrompt, buildUserPrompt, verboseMessage) => {
228
- const filteredScript = filterScript(script, options);
229
- const scriptTitle = script.title || "Untitled";
230
- if (filteredScript.beats.length === 0) {
231
- return null;
232
- }
233
- const systemPrompt = getSystemPrompt(options);
234
- const userPrompt = buildUserPrompt(filteredScript);
235
- const text = await executeLLM(systemPrompt, userPrompt, options, verboseMessage);
236
- return {
237
- text,
238
- scriptTitle,
239
- beatCount: filteredScript.beats.length,
240
- };
241
- };
242
79
  /**
243
80
  * Execute LLM call with GraphAI
244
81
  */
package/lib/index.d.ts CHANGED
@@ -1,13 +1,8 @@
1
- export { processScript } from "./core/preprocessing/process.js";
2
- export { applyProfile } from "./core/preprocessing/variant.js";
3
- export { filterBySection, filterByTags, stripExtendedFields } from "./core/preprocessing/filter.js";
4
- export { listProfiles } from "./core/preprocessing/profiles.js";
5
1
  export { summarizeScript } from "./core/ai/command/summarize/index.js";
6
2
  export { queryScript } from "./core/ai/command/query/index.js";
7
3
  export { createInteractiveSession, sendInteractiveQuery, sendInteractiveQueryWithFetch, clearHistory, getHistory, getReferences, findReference, fetchReference, parseSuggestedFetch, removeSuggestFetchMarkers, } from "./core/ai/command/query/interactive.js";
8
4
  export { fetchUrlContent, stripHtml, extractTitle } from "./core/ai/utils/fetcher.js";
9
5
  export type { FetchedContent } from "./core/ai/utils/fetcher.js";
10
- export type { ProcessOptions, ProfileInfo } from "./types/index.js";
11
6
  export type { SummarizeOptions, SummarizeResult, LLMProvider, SummarizeFormat, ProviderConfig } from "./types/summarize.js";
12
7
  export type { QueryOptions, QueryResult, ConversationMessage, InteractiveQuerySession } from "./types/query.js";
13
8
  export { summarizeOptionsSchema, llmProviderSchema, summarizeFormatSchema } from "./types/summarize.js";
package/lib/index.js CHANGED
@@ -1,8 +1,3 @@
1
- // Preprocessing API
2
- export { processScript } from "./core/preprocessing/process.js";
3
- export { applyProfile } from "./core/preprocessing/variant.js";
4
- export { filterBySection, filterByTags, stripExtendedFields } from "./core/preprocessing/filter.js";
5
- export { listProfiles } from "./core/preprocessing/profiles.js";
6
1
  // AI API
7
2
  export { summarizeScript } from "./core/ai/command/summarize/index.js";
8
3
  export { queryScript } from "./core/ai/command/query/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mulmocast-preprocessor",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "Preprocessor for MulmoScript",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -40,6 +40,7 @@
40
40
  "@graphai/openai_agent": "^2.0.9",
41
41
  "@graphai/vanilla": "^2.0.12",
42
42
  "@mulmocast/extended-types": "^0.3.0",
43
+ "@mulmocast/script-utils": "^0.1.0",
43
44
  "@mulmocast/types": "^2.1.38",
44
45
  "dotenv": "^17.3.1",
45
46
  "graphai": "^2.0.16",
@@ -1,30 +0,0 @@
1
- import type { QueryOptions, ConversationMessage } from "../../../../types/query.js";
2
- import type { ExtendedMulmoScript } from "@mulmocast/extended-types";
3
- /**
4
- * Default system prompt for query
5
- */
6
- export declare const DEFAULT_SYSTEM_PROMPT = "You are answering questions based on the content provided.\n- Answer based ONLY on the information in the provided content\n- If the answer cannot be found in the content, say so clearly\n- Be concise and direct in your answers\n- Do not make up information that is not in the content";
7
- /**
8
- * Get system prompt based on options
9
- */
10
- export declare const getSystemPrompt: (options: QueryOptions) => string;
11
- /**
12
- * Build user prompt from script and question
13
- */
14
- export declare const buildUserPrompt: (script: ExtendedMulmoScript, question: string) => string;
15
- /**
16
- * Default system prompt for interactive query
17
- */
18
- export declare const DEFAULT_INTERACTIVE_SYSTEM_PROMPT = "You are answering questions based on the content provided.\n- Answer based ONLY on the information in the provided content\n- If the answer cannot be found in the content, say so clearly\n- Be concise and direct in your answers\n- Do not make up information that is not in the content\n- You may reference previous conversation when answering follow-up questions\n- If references are available and the user asks for more details, mention which reference could provide more information\n- When you suggest fetching a reference for more details, include [SUGGEST_FETCH: <url>] in your response";
19
- /**
20
- * Default system prompt for interactive query with fetched content
21
- */
22
- export declare const DEFAULT_INTERACTIVE_SYSTEM_PROMPT_WITH_FETCH = "You are answering questions based on the content provided, including fetched reference content.\n- Answer based on both the main content and any fetched reference content\n- If the answer cannot be found, say so clearly\n- Be concise and direct in your answers\n- Do not make up information\n- You may reference previous conversation when answering follow-up questions\n- Prioritize information from fetched content when it's more detailed and relevant";
23
- /**
24
- * Get system prompt for interactive mode
25
- */
26
- export declare const getInteractiveSystemPrompt: (options: QueryOptions) => string;
27
- /**
28
- * Build user prompt with conversation history for interactive mode
29
- */
30
- export declare const buildInteractiveUserPrompt: (script: ExtendedMulmoScript, question: string, history: ConversationMessage[]) => string;
@@ -1,100 +0,0 @@
1
- import { getLanguageName, buildScriptContent } from "../../llm.js";
2
- /**
3
- * Default system prompt for query
4
- */
5
- export const DEFAULT_SYSTEM_PROMPT = `You are answering questions based on the content provided.
6
- - Answer based ONLY on the information in the provided content
7
- - If the answer cannot be found in the content, say so clearly
8
- - Be concise and direct in your answers
9
- - Do not make up information that is not in the content`;
10
- /**
11
- * Get system prompt based on options
12
- */
13
- export const getSystemPrompt = (options) => {
14
- if (options.systemPrompt) {
15
- return options.systemPrompt;
16
- }
17
- const basePrompt = DEFAULT_SYSTEM_PROMPT;
18
- // Add language instruction if specified
19
- if (options.lang) {
20
- const langName = getLanguageName(options.lang);
21
- return `${basePrompt}\n- IMPORTANT: Write the answer in ${langName}`;
22
- }
23
- return basePrompt;
24
- };
25
- /**
26
- * Build user prompt from script and question
27
- */
28
- export const buildUserPrompt = (script, question) => {
29
- const parts = [];
30
- // Add common script content (title, language, sections with beats)
31
- parts.push(buildScriptContent(script));
32
- parts.push("---");
33
- parts.push("");
34
- parts.push(`Question: ${question}`);
35
- parts.push("");
36
- parts.push("Answer:");
37
- return parts.join("\n");
38
- };
39
- /**
40
- * Default system prompt for interactive query
41
- */
42
- export const DEFAULT_INTERACTIVE_SYSTEM_PROMPT = `You are answering questions based on the content provided.
43
- - Answer based ONLY on the information in the provided content
44
- - If the answer cannot be found in the content, say so clearly
45
- - Be concise and direct in your answers
46
- - Do not make up information that is not in the content
47
- - You may reference previous conversation when answering follow-up questions
48
- - If references are available and the user asks for more details, mention which reference could provide more information
49
- - When you suggest fetching a reference for more details, include [SUGGEST_FETCH: <url>] in your response`;
50
- /**
51
- * Default system prompt for interactive query with fetched content
52
- */
53
- export const DEFAULT_INTERACTIVE_SYSTEM_PROMPT_WITH_FETCH = `You are answering questions based on the content provided, including fetched reference content.
54
- - Answer based on both the main content and any fetched reference content
55
- - If the answer cannot be found, say so clearly
56
- - Be concise and direct in your answers
57
- - Do not make up information
58
- - You may reference previous conversation when answering follow-up questions
59
- - Prioritize information from fetched content when it's more detailed and relevant`;
60
- /**
61
- * Get system prompt for interactive mode
62
- */
63
- export const getInteractiveSystemPrompt = (options) => {
64
- if (options.systemPrompt) {
65
- return options.systemPrompt;
66
- }
67
- const basePrompt = DEFAULT_INTERACTIVE_SYSTEM_PROMPT;
68
- if (options.lang) {
69
- const langName = getLanguageName(options.lang);
70
- return `${basePrompt}\n- IMPORTANT: Write the answer in ${langName}`;
71
- }
72
- return basePrompt;
73
- };
74
- /**
75
- * Build user prompt with conversation history for interactive mode
76
- */
77
- export const buildInteractiveUserPrompt = (script, question, history) => {
78
- const parts = [];
79
- // Add common script content (title, language, sections with beats)
80
- parts.push(buildScriptContent(script));
81
- parts.push("---");
82
- parts.push("");
83
- // Add conversation history if exists
84
- if (history.length > 0) {
85
- parts.push("Previous conversation:");
86
- history.forEach((msg) => {
87
- if (msg.role === "user") {
88
- parts.push(`Q: ${msg.content}`);
89
- }
90
- else {
91
- parts.push(`A: ${msg.content}`);
92
- }
93
- });
94
- parts.push("");
95
- }
96
- parts.push(`Current question: ${question}`);
97
- parts.push("");
98
- parts.push("Answer:");
99
- return parts.join("\n");
100
- };
@@ -1,18 +0,0 @@
1
- import type { SummarizeOptions } from "../../../../types/summarize.js";
2
- import type { ExtendedMulmoScript } from "@mulmocast/extended-types";
3
- /**
4
- * Default system prompt for text summary
5
- */
6
- export declare const DEFAULT_SYSTEM_PROMPT_TEXT = "You are creating a summary based on the content provided.\n- Extract and explain the actual information and knowledge from the content\n- Do NOT describe what the presentation/script is about (avoid phrases like \"this presentation explains...\" or \"the script describes...\")\n- Write as if you are directly explaining the topic to the reader\n- Be concise and informative\n- Output plain text only";
7
- /**
8
- * Default system prompt for markdown summary
9
- */
10
- export declare const DEFAULT_SYSTEM_PROMPT_MARKDOWN = "You are creating a summary based on the content provided.\n- Extract and explain the actual information and knowledge from the content\n- Do NOT describe what the presentation/script is about (avoid phrases like \"this presentation explains...\" or \"the script describes...\")\n- Write as if you are directly explaining the topic to the reader\n- Use markdown formatting (headers, bullet points, etc.)\n- Include a title, key points, and conclusion\n- Output well-formatted markdown";
11
- /**
12
- * Build user prompt from entire script
13
- */
14
- export declare const buildUserPrompt: (script: ExtendedMulmoScript, options: SummarizeOptions) => string;
15
- /**
16
- * Get system prompt based on format and language
17
- */
18
- export declare const getSystemPrompt: (options: SummarizeOptions) => string;
@@ -1,50 +0,0 @@
1
- import { getLanguageName, buildScriptContent } from "../../llm.js";
2
- /**
3
- * Default system prompt for text summary
4
- */
5
- export const DEFAULT_SYSTEM_PROMPT_TEXT = `You are creating a summary based on the content provided.
6
- - Extract and explain the actual information and knowledge from the content
7
- - Do NOT describe what the presentation/script is about (avoid phrases like "this presentation explains..." or "the script describes...")
8
- - Write as if you are directly explaining the topic to the reader
9
- - Be concise and informative
10
- - Output plain text only`;
11
- /**
12
- * Default system prompt for markdown summary
13
- */
14
- export const DEFAULT_SYSTEM_PROMPT_MARKDOWN = `You are creating a summary based on the content provided.
15
- - Extract and explain the actual information and knowledge from the content
16
- - Do NOT describe what the presentation/script is about (avoid phrases like "this presentation explains..." or "the script describes...")
17
- - Write as if you are directly explaining the topic to the reader
18
- - Use markdown formatting (headers, bullet points, etc.)
19
- - Include a title, key points, and conclusion
20
- - Output well-formatted markdown`;
21
- /**
22
- * Build user prompt from entire script
23
- */
24
- export const buildUserPrompt = (script, options) => {
25
- const parts = [];
26
- // Add common script content (title, language, sections with beats)
27
- parts.push(buildScriptContent(script));
28
- // Add target length if specified
29
- if (options.targetLengthChars) {
30
- parts.push(`Target summary length: approximately ${options.targetLengthChars} characters`);
31
- }
32
- parts.push("");
33
- parts.push("Based on the above content, explain the topic directly to the reader:");
34
- return parts.join("\n");
35
- };
36
- /**
37
- * Get system prompt based on format and language
38
- */
39
- export const getSystemPrompt = (options) => {
40
- if (options.systemPrompt) {
41
- return options.systemPrompt;
42
- }
43
- const basePrompt = options.format === "markdown" ? DEFAULT_SYSTEM_PROMPT_MARKDOWN : DEFAULT_SYSTEM_PROMPT_TEXT;
44
- // Add language instruction if specified
45
- if (options.lang) {
46
- const langName = getLanguageName(options.lang);
47
- return `${basePrompt}\n- IMPORTANT: Write the output in ${langName}`;
48
- }
49
- return basePrompt;
50
- };
@@ -1,14 +0,0 @@
1
- import type { MulmoScript } from "@mulmocast/types";
2
- import type { ExtendedMulmoScript } from "@mulmocast/extended-types";
3
- /**
4
- * Filter beats by section (preserves meta for chaining)
5
- */
6
- export declare const filterBySection: (script: ExtendedMulmoScript, section: string) => ExtendedMulmoScript;
7
- /**
8
- * Filter beats by tags (preserves meta for chaining)
9
- */
10
- export declare const filterByTags: (script: ExtendedMulmoScript, tags: string[]) => ExtendedMulmoScript;
11
- /**
12
- * Strip variants and meta fields, converting to standard MulmoScript
13
- */
14
- export declare const stripExtendedFields: (script: ExtendedMulmoScript) => MulmoScript;
@@ -1,30 +0,0 @@
1
- const stripBeatExtendedFields = (beat) => {
2
- const { variants: __variants, meta: __meta, ...baseBeat } = beat;
3
- return baseBeat;
4
- };
5
- const filterBeatsToMulmoScript = (script, predicate) => {
6
- const { outputProfiles: __outputProfiles, scriptMeta: __scriptMeta, ...baseScript } = script;
7
- return {
8
- ...baseScript,
9
- beats: script.beats.filter(predicate).map(stripBeatExtendedFields),
10
- };
11
- };
12
- const filterBeatsPreservingMeta = (script, predicate) => ({
13
- ...script,
14
- beats: script.beats.filter(predicate),
15
- });
16
- /**
17
- * Filter beats by section (preserves meta for chaining)
18
- */
19
- export const filterBySection = (script, section) => filterBeatsPreservingMeta(script, (beat) => beat.meta?.section === section);
20
- /**
21
- * Filter beats by tags (preserves meta for chaining)
22
- */
23
- export const filterByTags = (script, tags) => {
24
- const tagSet = new Set(tags);
25
- return filterBeatsPreservingMeta(script, (beat) => (beat.meta?.tags ?? []).some((tag) => tagSet.has(tag)));
26
- };
27
- /**
28
- * Strip variants and meta fields, converting to standard MulmoScript
29
- */
30
- export const stripExtendedFields = (script) => filterBeatsToMulmoScript(script, () => true);
@@ -1,8 +0,0 @@
1
- import type { MulmoScript } from "@mulmocast/types";
2
- import type { ExtendedMulmoScript } from "@mulmocast/extended-types";
3
- import type { ProcessOptions } from "../../types/index.js";
4
- /**
5
- * Main processing function
6
- * Applies filters first (while meta exists), then profile
7
- */
8
- export declare const processScript: (script: ExtendedMulmoScript, options?: ProcessOptions) => MulmoScript;
@@ -1,12 +0,0 @@
1
- import { applyProfile } from "./variant.js";
2
- import { filterBySection, filterByTags, stripExtendedFields } from "./filter.js";
3
- /**
4
- * Main processing function
5
- * Applies filters first (while meta exists), then profile
6
- */
7
- export const processScript = (script, options = {}) => {
8
- const afterSection = options.section ? filterBySection(script, options.section) : script;
9
- const afterTags = options.tags && options.tags.length > 0 ? filterByTags(afterSection, options.tags) : afterSection;
10
- const afterProfile = options.profile && options.profile !== "default" ? applyProfile(afterTags, options.profile) : stripExtendedFields(afterTags);
11
- return afterProfile;
12
- };
@@ -1,6 +0,0 @@
1
- import type { ExtendedMulmoScript } from "@mulmocast/extended-types";
2
- import type { ProfileInfo } from "../../types/index.js";
3
- /**
4
- * Get list of available profiles from script
5
- */
6
- export declare const listProfiles: (script: ExtendedMulmoScript) => ProfileInfo[];
@@ -1,38 +0,0 @@
1
- /**
2
- * Get list of available profiles from script
3
- */
4
- export const listProfiles = (script) => {
5
- const profileNames = new Set(["default"]);
6
- script.beats
7
- .filter((beat) => beat.variants)
8
- .flatMap((beat) => Object.keys(beat.variants))
9
- .forEach((name) => profileNames.add(name));
10
- const buildProfileInfo = (profileName) => {
11
- const outputProfile = script.outputProfiles?.[profileName];
12
- const { beatCount, skippedCount } = profileName === "default"
13
- ? { beatCount: script.beats.length, skippedCount: 0 }
14
- : script.beats.reduce((acc, beat) => {
15
- const isSkipped = beat.variants?.[profileName]?.skip === true;
16
- return {
17
- beatCount: acc.beatCount + (isSkipped ? 0 : 1),
18
- skippedCount: acc.skippedCount + (isSkipped ? 1 : 0),
19
- };
20
- }, { beatCount: 0, skippedCount: 0 });
21
- return {
22
- name: profileName,
23
- displayName: outputProfile?.name,
24
- description: outputProfile?.description,
25
- beatCount,
26
- skippedCount,
27
- };
28
- };
29
- return Array.from(profileNames)
30
- .map(buildProfileInfo)
31
- .sort((a, b) => {
32
- if (a.name === "default")
33
- return -1;
34
- if (b.name === "default")
35
- return 1;
36
- return a.name.localeCompare(b.name);
37
- });
38
- };
@@ -1,6 +0,0 @@
1
- import type { MulmoScript } from "@mulmocast/types";
2
- import type { ExtendedMulmoScript } from "@mulmocast/extended-types";
3
- /**
4
- * Apply profile to script and return standard MulmoScript
5
- */
6
- export declare const applyProfile: (script: ExtendedMulmoScript, profileName: string) => MulmoScript;
@@ -1,26 +0,0 @@
1
- /**
2
- * Apply profile variant to a single beat
3
- * @returns Processed beat, or null if skip is set
4
- */
5
- const applyVariantToBeat = (beat, profileName) => {
6
- const variant = beat.variants?.[profileName];
7
- if (variant?.skip) {
8
- return null;
9
- }
10
- const { variants: __variants, meta: __meta, ...baseBeat } = beat;
11
- if (!variant) {
12
- return baseBeat;
13
- }
14
- const { skip: __skip, ...overrides } = variant;
15
- return { ...baseBeat, ...overrides };
16
- };
17
- /**
18
- * Apply profile to script and return standard MulmoScript
19
- */
20
- export const applyProfile = (script, profileName) => {
21
- const { outputProfiles: __outputProfiles, scriptMeta: __scriptMeta, ...baseScript } = script;
22
- return {
23
- ...baseScript,
24
- beats: script.beats.map((beat) => applyVariantToBeat(beat, profileName)).filter((beat) => beat !== null),
25
- };
26
- };
@@ -1,18 +0,0 @@
1
- /**
2
- * Process Options - options for processScript
3
- */
4
- export interface ProcessOptions {
5
- profile?: string;
6
- section?: string;
7
- tags?: string[];
8
- }
9
- /**
10
- * Profile Info - profile metadata with beat counts
11
- */
12
- export interface ProfileInfo {
13
- name: string;
14
- displayName?: string;
15
- description?: string;
16
- beatCount: number;
17
- skippedCount: number;
18
- }
@@ -1 +0,0 @@
1
- export {};