mulmocast-preprocessor 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/commands/process.js +1 -1
- package/lib/cli/commands/profiles.js +1 -1
- package/lib/core/ai/command/query/index.d.ts +0 -2
- package/lib/core/ai/command/query/index.js +4 -5
- package/lib/core/ai/command/query/interactive.js +6 -10
- package/lib/core/ai/command/summarize/index.d.ts +0 -2
- package/lib/core/ai/command/summarize/index.js +5 -5
- package/lib/core/ai/llm.d.ts +0 -22
- package/lib/core/ai/llm.js +0 -47
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -5
- package/package.json +2 -5
- package/lib/context.d.ts +0 -1
- package/lib/context.js +0 -2
- package/lib/core/ai/command/query/prompts.d.ts +0 -28
- package/lib/core/ai/command/query/prompts.js +0 -91
- package/lib/core/ai/command/summarize/prompts.d.ts +0 -18
- package/lib/core/ai/command/summarize/prompts.js +0 -50
- package/lib/core/ai/context-builder.d.ts +0 -21
- package/lib/core/ai/context-builder.js +0 -146
- package/lib/core/preprocessing/filter.d.ts +0 -14
- package/lib/core/preprocessing/filter.js +0 -30
- package/lib/core/preprocessing/process.d.ts +0 -8
- package/lib/core/preprocessing/process.js +0 -12
- package/lib/core/preprocessing/profiles.d.ts +0 -6
- package/lib/core/preprocessing/profiles.js +0 -38
- package/lib/core/preprocessing/variant.d.ts +0 -6
- package/lib/core/preprocessing/variant.js +0 -26
- package/lib/types/index.d.ts +0 -18
- package/lib/types/index.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from "fs";
|
|
2
2
|
import { GraphAILogger } from "graphai";
|
|
3
|
-
import { processScript } from "
|
|
3
|
+
import { processScript } from "@mulmocast/script-utils";
|
|
4
4
|
/**
|
|
5
5
|
* Process script with profile and output result
|
|
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
|
|
3
|
-
import {
|
|
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 =
|
|
23
|
-
const userPrompt =
|
|
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
|
|
3
|
-
import {
|
|
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 =
|
|
27
|
-
const userPrompt =
|
|
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
|
-
|
|
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 =
|
|
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
|
|
3
|
-
import {
|
|
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
|
|
23
|
-
const
|
|
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";
|
package/lib/core/ai/llm.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { ExtendedMulmoScript } from "@mulmocast/extended-types";
|
|
2
1
|
import type { LLMProvider } from "../../types/summarize.js";
|
|
3
|
-
export { buildBeatContent, buildScriptMetaContent, buildScriptContent, scriptToViewerData } from "./context-builder.js";
|
|
4
2
|
/**
|
|
5
3
|
* Base options for LLM operations
|
|
6
4
|
*/
|
|
@@ -32,26 +30,6 @@ export declare const getProviderConfig: (provider: LLMProvider) => ProviderConfi
|
|
|
32
30
|
* Get API key for provider
|
|
33
31
|
*/
|
|
34
32
|
export declare const getProviderApiKey: (provider: LLMProvider) => string | undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Filter script based on options (section, tags)
|
|
37
|
-
*/
|
|
38
|
-
export declare const filterScript: (script: ExtendedMulmoScript, options: BaseLLMOptions) => ExtendedMulmoScript;
|
|
39
|
-
/**
|
|
40
|
-
* Get language name from code
|
|
41
|
-
*/
|
|
42
|
-
export declare const getLanguageName: (langCode: string) => string;
|
|
43
|
-
/**
|
|
44
|
-
* Command execution result
|
|
45
|
-
*/
|
|
46
|
-
export interface CommandResult {
|
|
47
|
-
text: string;
|
|
48
|
-
scriptTitle: string;
|
|
49
|
-
beatCount: number;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Execute a command (summarize, query, etc.) with common logic
|
|
53
|
-
*/
|
|
54
|
-
export declare const executeCommand: <T extends BaseLLMOptions>(script: ExtendedMulmoScript, options: T, getSystemPrompt: (opts: T) => string, buildUserPrompt: (script: ExtendedMulmoScript) => string, verboseMessage: string) => Promise<CommandResult | null>;
|
|
55
33
|
/**
|
|
56
34
|
* Execute LLM call with GraphAI
|
|
57
35
|
*/
|
package/lib/core/ai/llm.js
CHANGED
|
@@ -5,9 +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
|
-
// Re-export pure context-building functions (no GraphAI dependency)
|
|
10
|
-
export { buildBeatContent, buildScriptMetaContent, buildScriptContent, scriptToViewerData } from "./context-builder.js";
|
|
11
8
|
dotenv.config({ quiet: true });
|
|
12
9
|
const agents = vanillaAgents.default ?? vanillaAgents;
|
|
13
10
|
const provider2Agent = {
|
|
@@ -79,50 +76,6 @@ const createLLMGraph = (agentName) => ({
|
|
|
79
76
|
},
|
|
80
77
|
},
|
|
81
78
|
});
|
|
82
|
-
/**
|
|
83
|
-
* Filter script based on options (section, tags)
|
|
84
|
-
*/
|
|
85
|
-
export const filterScript = (script, options) => {
|
|
86
|
-
const afterSection = options.section ? filterBySection(script, options.section) : script;
|
|
87
|
-
const afterTags = options.tags && options.tags.length > 0 ? filterByTags(afterSection, options.tags) : afterSection;
|
|
88
|
-
return afterTags;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Get language name from code
|
|
92
|
-
*/
|
|
93
|
-
export const getLanguageName = (langCode) => {
|
|
94
|
-
const langMap = {
|
|
95
|
-
ja: "Japanese",
|
|
96
|
-
en: "English",
|
|
97
|
-
zh: "Chinese",
|
|
98
|
-
ko: "Korean",
|
|
99
|
-
fr: "French",
|
|
100
|
-
de: "German",
|
|
101
|
-
es: "Spanish",
|
|
102
|
-
it: "Italian",
|
|
103
|
-
pt: "Portuguese",
|
|
104
|
-
ru: "Russian",
|
|
105
|
-
};
|
|
106
|
-
return langMap[langCode] || langCode;
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Execute a command (summarize, query, etc.) with common logic
|
|
110
|
-
*/
|
|
111
|
-
export const executeCommand = async (script, options, getSystemPrompt, buildUserPrompt, verboseMessage) => {
|
|
112
|
-
const filteredScript = filterScript(script, options);
|
|
113
|
-
const scriptTitle = script.title || "Untitled";
|
|
114
|
-
if (filteredScript.beats.length === 0) {
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
const systemPrompt = getSystemPrompt(options);
|
|
118
|
-
const userPrompt = buildUserPrompt(filteredScript);
|
|
119
|
-
const text = await executeLLM(systemPrompt, userPrompt, options, verboseMessage);
|
|
120
|
-
return {
|
|
121
|
-
text,
|
|
122
|
-
scriptTitle,
|
|
123
|
-
beatCount: filteredScript.beats.length,
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
79
|
/**
|
|
127
80
|
* Execute LLM call with GraphAI
|
|
128
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.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Preprocessor for MulmoScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./lib/index.d.ts",
|
|
14
14
|
"default": "./lib/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./context": {
|
|
17
|
-
"types": "./lib/context.d.ts",
|
|
18
|
-
"default": "./lib/context.js"
|
|
19
15
|
}
|
|
20
16
|
},
|
|
21
17
|
"files": [
|
|
@@ -44,6 +40,7 @@
|
|
|
44
40
|
"@graphai/openai_agent": "^2.0.9",
|
|
45
41
|
"@graphai/vanilla": "^2.0.12",
|
|
46
42
|
"@mulmocast/extended-types": "^0.3.0",
|
|
43
|
+
"@mulmocast/script-utils": "^0.1.0",
|
|
47
44
|
"@mulmocast/types": "^2.1.38",
|
|
48
45
|
"dotenv": "^17.3.1",
|
|
49
46
|
"graphai": "^2.0.16",
|
package/lib/context.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { buildScriptContent, buildBeatContent, buildScriptMetaContent, scriptToViewerData, DEFAULT_INTERACTIVE_SYSTEM_PROMPT, } from "./core/ai/context-builder.js";
|
package/lib/context.js
DELETED
|
@@ -1,28 +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
|
-
import { DEFAULT_INTERACTIVE_SYSTEM_PROMPT } from "../../context-builder.js";
|
|
16
|
-
export { DEFAULT_INTERACTIVE_SYSTEM_PROMPT };
|
|
17
|
-
/**
|
|
18
|
-
* Default system prompt for interactive query with fetched content
|
|
19
|
-
*/
|
|
20
|
-
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";
|
|
21
|
-
/**
|
|
22
|
-
* Get system prompt for interactive mode
|
|
23
|
-
*/
|
|
24
|
-
export declare const getInteractiveSystemPrompt: (options: QueryOptions) => string;
|
|
25
|
-
/**
|
|
26
|
-
* Build user prompt with conversation history for interactive mode
|
|
27
|
-
*/
|
|
28
|
-
export declare const buildInteractiveUserPrompt: (script: ExtendedMulmoScript, question: string, history: ConversationMessage[]) => string;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { getLanguageName, buildScriptContent, scriptToViewerData } 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(scriptToViewerData(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
|
-
import { DEFAULT_INTERACTIVE_SYSTEM_PROMPT } from "../../context-builder.js";
|
|
40
|
-
export { DEFAULT_INTERACTIVE_SYSTEM_PROMPT };
|
|
41
|
-
/**
|
|
42
|
-
* Default system prompt for interactive query with fetched content
|
|
43
|
-
*/
|
|
44
|
-
export const DEFAULT_INTERACTIVE_SYSTEM_PROMPT_WITH_FETCH = `You are answering questions based on the content provided, including fetched reference content.
|
|
45
|
-
- Answer based on both the main content and any fetched reference content
|
|
46
|
-
- If the answer cannot be found, say so clearly
|
|
47
|
-
- Be concise and direct in your answers
|
|
48
|
-
- Do not make up information
|
|
49
|
-
- You may reference previous conversation when answering follow-up questions
|
|
50
|
-
- Prioritize information from fetched content when it's more detailed and relevant`;
|
|
51
|
-
/**
|
|
52
|
-
* Get system prompt for interactive mode
|
|
53
|
-
*/
|
|
54
|
-
export const getInteractiveSystemPrompt = (options) => {
|
|
55
|
-
if (options.systemPrompt) {
|
|
56
|
-
return options.systemPrompt;
|
|
57
|
-
}
|
|
58
|
-
const basePrompt = DEFAULT_INTERACTIVE_SYSTEM_PROMPT;
|
|
59
|
-
if (options.lang) {
|
|
60
|
-
const langName = getLanguageName(options.lang);
|
|
61
|
-
return `${basePrompt}\n- IMPORTANT: Write the answer in ${langName}`;
|
|
62
|
-
}
|
|
63
|
-
return basePrompt;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Build user prompt with conversation history for interactive mode
|
|
67
|
-
*/
|
|
68
|
-
export const buildInteractiveUserPrompt = (script, question, history) => {
|
|
69
|
-
const parts = [];
|
|
70
|
-
// Add common script content (title, language, sections with beats)
|
|
71
|
-
parts.push(buildScriptContent(scriptToViewerData(script)));
|
|
72
|
-
parts.push("---");
|
|
73
|
-
parts.push("");
|
|
74
|
-
// Add conversation history if exists
|
|
75
|
-
if (history.length > 0) {
|
|
76
|
-
parts.push("Previous conversation:");
|
|
77
|
-
history.forEach((msg) => {
|
|
78
|
-
if (msg.role === "user") {
|
|
79
|
-
parts.push(`Q: ${msg.content}`);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
parts.push(`A: ${msg.content}`);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
parts.push("");
|
|
86
|
-
}
|
|
87
|
-
parts.push(`Current question: ${question}`);
|
|
88
|
-
parts.push("");
|
|
89
|
-
parts.push("Answer:");
|
|
90
|
-
return parts.join("\n");
|
|
91
|
-
};
|
|
@@ -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, scriptToViewerData } 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(scriptToViewerData(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,21 +0,0 @@
|
|
|
1
|
-
import type { ExtendedMulmoScript, ExtendedMulmoViewerData, ExtendedMulmoViewerBeat } from "@mulmocast/extended-types";
|
|
2
|
-
/**
|
|
3
|
-
* Default system prompt for interactive query
|
|
4
|
-
*/
|
|
5
|
-
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";
|
|
6
|
-
/**
|
|
7
|
-
* Build beat content including metadata
|
|
8
|
-
*/
|
|
9
|
-
export declare const buildBeatContent: (beat: ExtendedMulmoViewerBeat, index: number) => string;
|
|
10
|
-
/**
|
|
11
|
-
* Build script-level metadata section
|
|
12
|
-
*/
|
|
13
|
-
export declare const buildScriptMetaContent: (data: ExtendedMulmoViewerData) => string;
|
|
14
|
-
/**
|
|
15
|
-
* Convert ExtendedMulmoScript to ExtendedMulmoViewerData (extract only needed fields)
|
|
16
|
-
*/
|
|
17
|
-
export declare const scriptToViewerData: (script: ExtendedMulmoScript) => ExtendedMulmoViewerData;
|
|
18
|
-
/**
|
|
19
|
-
* Build script content for user prompt (common part)
|
|
20
|
-
*/
|
|
21
|
-
export declare const buildScriptContent: (data: ExtendedMulmoViewerData) => string;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default system prompt for interactive query
|
|
3
|
-
*/
|
|
4
|
-
export const DEFAULT_INTERACTIVE_SYSTEM_PROMPT = `You are answering questions based on the content provided.
|
|
5
|
-
- Answer based ONLY on the information in the provided content
|
|
6
|
-
- If the answer cannot be found in the content, say so clearly
|
|
7
|
-
- Be concise and direct in your answers
|
|
8
|
-
- Do not make up information that is not in the content
|
|
9
|
-
- You may reference previous conversation when answering follow-up questions
|
|
10
|
-
- If references are available and the user asks for more details, mention which reference could provide more information
|
|
11
|
-
- When you suggest fetching a reference for more details, include [SUGGEST_FETCH: <url>] in your response`;
|
|
12
|
-
/**
|
|
13
|
-
* Build beat content including metadata
|
|
14
|
-
*/
|
|
15
|
-
export const buildBeatContent = (beat, index) => {
|
|
16
|
-
const lines = [];
|
|
17
|
-
// Main text
|
|
18
|
-
const text = beat.text || "";
|
|
19
|
-
if (!text.trim())
|
|
20
|
-
return "";
|
|
21
|
-
lines.push(`[${index}] ${text}`);
|
|
22
|
-
// Add metadata if available
|
|
23
|
-
const meta = beat.meta;
|
|
24
|
-
if (meta) {
|
|
25
|
-
// Tags for categorization
|
|
26
|
-
if (meta.tags && meta.tags.length > 0) {
|
|
27
|
-
lines.push(` Tags: ${meta.tags.join(", ")}`);
|
|
28
|
-
}
|
|
29
|
-
// Context provides additional information not in the text
|
|
30
|
-
if (meta.context) {
|
|
31
|
-
lines.push(` Context: ${meta.context}`);
|
|
32
|
-
}
|
|
33
|
-
// Keywords highlight important terms
|
|
34
|
-
if (meta.keywords && meta.keywords.length > 0) {
|
|
35
|
-
lines.push(` Keywords: ${meta.keywords.join(", ")}`);
|
|
36
|
-
}
|
|
37
|
-
// Expected questions this beat can answer
|
|
38
|
-
if (meta.expectedQuestions && meta.expectedQuestions.length > 0) {
|
|
39
|
-
lines.push(` Can answer: ${meta.expectedQuestions.join("; ")}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return lines.join("\n");
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Build script-level metadata section
|
|
46
|
-
*/
|
|
47
|
-
export const buildScriptMetaContent = (data) => {
|
|
48
|
-
const meta = data.scriptMeta;
|
|
49
|
-
if (!meta)
|
|
50
|
-
return "";
|
|
51
|
-
const lines = [];
|
|
52
|
-
// Background info
|
|
53
|
-
if (meta.background) {
|
|
54
|
-
lines.push(`Background: ${meta.background}`);
|
|
55
|
-
}
|
|
56
|
-
// Audience and prerequisites
|
|
57
|
-
if (meta.audience) {
|
|
58
|
-
lines.push(`Target audience: ${meta.audience}`);
|
|
59
|
-
}
|
|
60
|
-
if (meta.prerequisites && meta.prerequisites.length > 0) {
|
|
61
|
-
lines.push(`Prerequisites: ${meta.prerequisites.join(", ")}`);
|
|
62
|
-
}
|
|
63
|
-
// Goals
|
|
64
|
-
if (meta.goals && meta.goals.length > 0) {
|
|
65
|
-
lines.push(`Goals: ${meta.goals.join("; ")}`);
|
|
66
|
-
}
|
|
67
|
-
// Keywords
|
|
68
|
-
if (meta.keywords && meta.keywords.length > 0) {
|
|
69
|
-
lines.push(`Keywords: ${meta.keywords.join(", ")}`);
|
|
70
|
-
}
|
|
71
|
-
// References
|
|
72
|
-
if (meta.references && meta.references.length > 0) {
|
|
73
|
-
lines.push("References:");
|
|
74
|
-
meta.references.forEach((ref) => {
|
|
75
|
-
const title = ref.title || ref.url;
|
|
76
|
-
const desc = ref.description ? ` - ${ref.description}` : "";
|
|
77
|
-
lines.push(` - [${ref.type || "web"}] ${title}: ${ref.url}${desc}`);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
// FAQ
|
|
81
|
-
if (meta.faq && meta.faq.length > 0) {
|
|
82
|
-
lines.push("FAQ:");
|
|
83
|
-
meta.faq.forEach((faq) => {
|
|
84
|
-
lines.push(` Q: ${faq.question}`);
|
|
85
|
-
lines.push(` A: ${faq.answer}`);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
// Author info
|
|
89
|
-
if (meta.author) {
|
|
90
|
-
lines.push(`Author: ${meta.author}`);
|
|
91
|
-
}
|
|
92
|
-
return lines.length > 0 ? lines.join("\n") : "";
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* Convert ExtendedMulmoScript to ExtendedMulmoViewerData (extract only needed fields)
|
|
96
|
-
*/
|
|
97
|
-
export const scriptToViewerData = (script) => {
|
|
98
|
-
return {
|
|
99
|
-
beats: script.beats.map((b) => ({
|
|
100
|
-
text: b.text,
|
|
101
|
-
meta: b.meta,
|
|
102
|
-
variants: b.variants,
|
|
103
|
-
id: b.id,
|
|
104
|
-
})),
|
|
105
|
-
title: script.title,
|
|
106
|
-
lang: script.lang,
|
|
107
|
-
scriptMeta: script.scriptMeta,
|
|
108
|
-
outputProfiles: script.outputProfiles,
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Build script content for user prompt (common part)
|
|
113
|
-
*/
|
|
114
|
-
export const buildScriptContent = (data) => {
|
|
115
|
-
const parts = [];
|
|
116
|
-
// Add script title and language
|
|
117
|
-
parts.push(`# Script: ${data.title}`);
|
|
118
|
-
parts.push(`Language: ${data.lang}`);
|
|
119
|
-
parts.push("");
|
|
120
|
-
// Add script-level metadata
|
|
121
|
-
const scriptMetaContent = buildScriptMetaContent(data);
|
|
122
|
-
if (scriptMetaContent) {
|
|
123
|
-
parts.push("## About this content");
|
|
124
|
-
parts.push(scriptMetaContent);
|
|
125
|
-
parts.push("");
|
|
126
|
-
}
|
|
127
|
-
// Collect all content from beats grouped by section
|
|
128
|
-
const sections = new Map();
|
|
129
|
-
data.beats.forEach((beat, index) => {
|
|
130
|
-
const content = buildBeatContent(beat, index);
|
|
131
|
-
if (!content)
|
|
132
|
-
return;
|
|
133
|
-
const section = beat.meta?.section || "main";
|
|
134
|
-
if (!sections.has(section)) {
|
|
135
|
-
sections.set(section, []);
|
|
136
|
-
}
|
|
137
|
-
sections.get(section).push(content);
|
|
138
|
-
});
|
|
139
|
-
// Output by section
|
|
140
|
-
sections.forEach((contents, section) => {
|
|
141
|
-
parts.push(`## Section: ${section}`);
|
|
142
|
-
contents.forEach((c) => parts.push(c));
|
|
143
|
-
parts.push("");
|
|
144
|
-
});
|
|
145
|
-
return parts.join("\n");
|
|
146
|
-
};
|
|
@@ -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
|
-
};
|
package/lib/types/index.d.ts
DELETED
|
@@ -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
|
-
}
|
package/lib/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|