@respeak/recap 0.3.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 (94) hide show
  1. package/dist/src/ai/gemini.d.ts +10 -0
  2. package/dist/src/ai/gemini.js +76 -0
  3. package/dist/src/ai/gemini.js.map +1 -0
  4. package/dist/src/ai/pipeline.d.ts +26 -0
  5. package/dist/src/ai/pipeline.js +37 -0
  6. package/dist/src/ai/pipeline.js.map +1 -0
  7. package/dist/src/ai/prompts.d.ts +9 -0
  8. package/dist/src/ai/prompts.js +129 -0
  9. package/dist/src/ai/prompts.js.map +1 -0
  10. package/dist/src/analyze/index.d.ts +11 -0
  11. package/dist/src/analyze/index.js +55 -0
  12. package/dist/src/analyze/index.js.map +1 -0
  13. package/dist/src/analyze/plan-schema.d.ts +180 -0
  14. package/dist/src/analyze/plan-schema.js +91 -0
  15. package/dist/src/analyze/plan-schema.js.map +1 -0
  16. package/dist/src/analyze/scanners/generic.d.ts +2 -0
  17. package/dist/src/analyze/scanners/generic.js +44 -0
  18. package/dist/src/analyze/scanners/generic.js.map +1 -0
  19. package/dist/src/analyze/scanners/nextjs.d.ts +11 -0
  20. package/dist/src/analyze/scanners/nextjs.js +84 -0
  21. package/dist/src/analyze/scanners/nextjs.js.map +1 -0
  22. package/dist/src/download.d.ts +2 -0
  23. package/dist/src/download.js +36 -0
  24. package/dist/src/download.js.map +1 -0
  25. package/dist/src/index.d.ts +2 -0
  26. package/dist/src/index.js +330 -0
  27. package/dist/src/index.js.map +1 -0
  28. package/dist/src/output/markdown.d.ts +2 -0
  29. package/dist/src/output/markdown.js +25 -0
  30. package/dist/src/output/markdown.js.map +1 -0
  31. package/dist/src/output/mdx.d.ts +2 -0
  32. package/dist/src/output/mdx.js +31 -0
  33. package/dist/src/output/mdx.js.map +1 -0
  34. package/dist/src/produce/docs-generator.d.ts +11 -0
  35. package/dist/src/produce/docs-generator.js +63 -0
  36. package/dist/src/produce/docs-generator.js.map +1 -0
  37. package/dist/src/produce/index.d.ts +7 -0
  38. package/dist/src/produce/index.js +76 -0
  39. package/dist/src/produce/index.js.map +1 -0
  40. package/dist/src/produce/merge.d.ts +16 -0
  41. package/dist/src/produce/merge.js +66 -0
  42. package/dist/src/produce/merge.js.map +1 -0
  43. package/dist/src/produce/translate.d.ts +2 -0
  44. package/dist/src/produce/translate.js +23 -0
  45. package/dist/src/produce/translate.js.map +1 -0
  46. package/dist/src/produce/tts/elevenlabs.d.ts +4 -0
  47. package/dist/src/produce/tts/elevenlabs.js +34 -0
  48. package/dist/src/produce/tts/elevenlabs.js.map +1 -0
  49. package/dist/src/produce/tts/google.d.ts +4 -0
  50. package/dist/src/produce/tts/google.js +30 -0
  51. package/dist/src/produce/tts/google.js.map +1 -0
  52. package/dist/src/produce/tts/interface.d.ts +9 -0
  53. package/dist/src/produce/tts/interface.js +2 -0
  54. package/dist/src/produce/tts/interface.js.map +1 -0
  55. package/dist/src/produce/tts/openai.d.ts +4 -0
  56. package/dist/src/produce/tts/openai.js +29 -0
  57. package/dist/src/produce/tts/openai.js.map +1 -0
  58. package/dist/src/produce/tts/registry.d.ts +2 -0
  59. package/dist/src/produce/tts/registry.js +16 -0
  60. package/dist/src/produce/tts/registry.js.map +1 -0
  61. package/dist/src/record/action-translator.d.ts +28 -0
  62. package/dist/src/record/action-translator.js +100 -0
  63. package/dist/src/record/action-translator.js.map +1 -0
  64. package/dist/src/record/browser-session.d.ts +12 -0
  65. package/dist/src/record/browser-session.js +129 -0
  66. package/dist/src/record/browser-session.js.map +1 -0
  67. package/dist/src/record/index.d.ts +9 -0
  68. package/dist/src/record/index.js +88 -0
  69. package/dist/src/record/index.js.map +1 -0
  70. package/dist/src/sync/client.d.ts +95 -0
  71. package/dist/src/sync/client.js +90 -0
  72. package/dist/src/sync/client.js.map +1 -0
  73. package/dist/src/sync/diff.d.ts +31 -0
  74. package/dist/src/sync/diff.js +236 -0
  75. package/dist/src/sync/diff.js.map +1 -0
  76. package/dist/src/sync/image-dimensions.d.ts +9 -0
  77. package/dist/src/sync/image-dimensions.js +48 -0
  78. package/dist/src/sync/image-dimensions.js.map +1 -0
  79. package/dist/src/sync/index.d.ts +21 -0
  80. package/dist/src/sync/index.js +141 -0
  81. package/dist/src/sync/index.js.map +1 -0
  82. package/dist/src/sync/links.d.ts +25 -0
  83. package/dist/src/sync/links.js +61 -0
  84. package/dist/src/sync/links.js.map +1 -0
  85. package/dist/src/sync/manifest.d.ts +97 -0
  86. package/dist/src/sync/manifest.js +156 -0
  87. package/dist/src/sync/manifest.js.map +1 -0
  88. package/dist/src/sync/markdown.d.ts +29 -0
  89. package/dist/src/sync/markdown.js +73 -0
  90. package/dist/src/sync/markdown.js.map +1 -0
  91. package/dist/src/sync/payload.d.ts +44 -0
  92. package/dist/src/sync/payload.js +74 -0
  93. package/dist/src/sync/payload.js.map +1 -0
  94. package/package.json +68 -0
@@ -0,0 +1,10 @@
1
+ import { GoogleGenAI } from "@google/genai";
2
+ export declare function initAI(apiKey: string): void;
3
+ export declare function getAI(): GoogleGenAI;
4
+ export declare function uploadVideo(source: string): Promise<{
5
+ uri: string;
6
+ mimeType: string;
7
+ }>;
8
+ export declare function extractVideoContent(fileUri: string, fileMimeType: string, model?: string): Promise<any>;
9
+ export declare function generateText(prompt: string, model?: string): Promise<string>;
10
+ export declare function generateJson<T = unknown>(prompt: string, model?: string): Promise<T>;
@@ -0,0 +1,76 @@
1
+ import { GoogleGenAI, createUserContent, createPartFromUri } from "@google/genai";
2
+ import { readFile } from "node:fs/promises";
3
+ let _ai = null;
4
+ export function initAI(apiKey) {
5
+ _ai = new GoogleGenAI({ apiKey });
6
+ }
7
+ export function getAI() {
8
+ if (!_ai)
9
+ throw new Error("Call initAI(apiKey) first");
10
+ return _ai;
11
+ }
12
+ export async function uploadVideo(source) {
13
+ const ai = getAI();
14
+ let blob;
15
+ if (source.startsWith("http://") || source.startsWith("https://")) {
16
+ const res = await fetch(source);
17
+ if (!res.ok)
18
+ throw new Error(`Failed to download video: ${res.status}`);
19
+ blob = await res.blob();
20
+ }
21
+ else {
22
+ const buffer = await readFile(source);
23
+ blob = new Blob([buffer], { type: "video/mp4" });
24
+ }
25
+ const upload = await ai.files.upload({
26
+ file: blob,
27
+ config: { mimeType: "video/mp4" },
28
+ });
29
+ let info = await ai.files.get({ name: upload.name });
30
+ while (info.state === "PROCESSING") {
31
+ await new Promise((r) => setTimeout(r, 5000));
32
+ info = await ai.files.get({ name: upload.name });
33
+ }
34
+ if (info.state === "FAILED")
35
+ throw new Error("Gemini video processing failed");
36
+ return { uri: info.uri, mimeType: info.mimeType };
37
+ }
38
+ export async function extractVideoContent(fileUri, fileMimeType, model = "gemini-2.5-flash") {
39
+ const ai = getAI();
40
+ const response = await ai.models.generateContent({
41
+ model,
42
+ contents: createUserContent([
43
+ createPartFromUri(fileUri, fileMimeType),
44
+ `Analyze this video and return a JSON array of segments. Each segment should cover a logical section of the video (30-120 seconds each).
45
+
46
+ For each segment provide:
47
+ - "start_time": start in seconds (number)
48
+ - "end_time": end in seconds (number)
49
+ - "spoken_content": what is being said (transcription)
50
+ - "visual_context": what is visually happening on screen (UI elements, code, clicks, navigation)
51
+ - "topic": a short title for this segment
52
+
53
+ Return ONLY valid JSON, no markdown fences.`,
54
+ ]),
55
+ config: { responseMimeType: "application/json" },
56
+ });
57
+ return JSON.parse(response.text);
58
+ }
59
+ export async function generateText(prompt, model = "gemini-2.5-flash") {
60
+ const ai = getAI();
61
+ const response = await ai.models.generateContent({
62
+ model,
63
+ contents: [{ role: "user", parts: [{ text: prompt }] }],
64
+ });
65
+ return response.text ?? "";
66
+ }
67
+ export async function generateJson(prompt, model = "gemini-2.5-flash") {
68
+ const ai = getAI();
69
+ const response = await ai.models.generateContent({
70
+ model,
71
+ contents: [{ role: "user", parts: [{ text: prompt }] }],
72
+ config: { responseMimeType: "application/json" },
73
+ });
74
+ return JSON.parse(response.text);
75
+ }
76
+ //# sourceMappingURL=gemini.js.map
@@ -0,0 +1 @@
1
+ {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,CAAC;IACnB,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC;QAC/C,KAAK;QACL,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;KACxD,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAc,MAAc,EAAE,QAAgB,kBAAkB;IAChG,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC;QAC/C,KAAK;QACL,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QACvD,MAAM,EAAE,EAAE,gBAAgB,EAAE,kBAAkB,EAAE;KACjD,CAAC,CAAC;IACH,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAK,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,26 @@
1
+ export interface Segment {
2
+ start_time: number;
3
+ end_time: number;
4
+ spoken_content: string;
5
+ visual_context: string;
6
+ topic: string;
7
+ }
8
+ export interface Section {
9
+ heading: string;
10
+ content: string;
11
+ timestamp_ref?: string;
12
+ }
13
+ export interface Chapter {
14
+ title: string;
15
+ sections: Section[];
16
+ }
17
+ export interface GeneratedDoc {
18
+ title: string;
19
+ chapters: Chapter[];
20
+ segments: Segment[];
21
+ }
22
+ export interface PipelineOptions {
23
+ model?: string;
24
+ onProgress?: (step: string, message: string) => void;
25
+ }
26
+ export declare function processVideo(source: string, apiKey: string, options?: PipelineOptions): Promise<GeneratedDoc>;
@@ -0,0 +1,37 @@
1
+ import { initAI, uploadVideo, extractVideoContent, getAI } from "./gemini.js";
2
+ import { getDocGenerationPrompt } from "./prompts.js";
3
+ import { isYouTubeUrl, downloadYouTube } from "../download.js";
4
+ import { unlink } from "node:fs/promises";
5
+ export async function processVideo(source, apiKey, options) {
6
+ const model = options?.model ?? "gemini-2.5-flash";
7
+ const log = options?.onProgress ?? (() => { });
8
+ initAI(apiKey);
9
+ let videoPath = source;
10
+ let tempFile = null;
11
+ if (isYouTubeUrl(source)) {
12
+ log("download", "Downloading video from YouTube...");
13
+ videoPath = await downloadYouTube(source);
14
+ tempFile = videoPath;
15
+ }
16
+ try {
17
+ log("upload", "Uploading video to Gemini...");
18
+ const { uri, mimeType } = await uploadVideo(videoPath);
19
+ log("extract", "Extracting content from video...");
20
+ const segments = await extractVideoContent(uri, mimeType, model);
21
+ log("generate", "Generating documentation...");
22
+ const prompt = getDocGenerationPrompt(segments);
23
+ const response = await getAI().models.generateContent({
24
+ model,
25
+ contents: [{ role: "user", parts: [{ text: prompt }] }],
26
+ config: { responseMimeType: "application/json" },
27
+ });
28
+ const doc = JSON.parse(response.text);
29
+ return { title: doc.title, chapters: doc.chapters, segments };
30
+ }
31
+ finally {
32
+ if (tempFile) {
33
+ await unlink(tempFile).catch(() => { });
34
+ }
35
+ }
36
+ }
37
+ //# sourceMappingURL=pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../src/ai/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAgC1C,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,MAAc,EACd,OAAyB;IAEzB,MAAM,KAAK,GAAG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,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAChE,CAAC;YAAS,CAAC;QACT,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare function getDocGenerationPrompt(segments: Record<string, unknown>[]): string;
2
+ import type { CodebaseSummary } from "../analyze/scanners/nextjs.js";
3
+ export declare function getFeatureDiscoveryPrompt(summary: CodebaseSummary, hints?: string): string;
4
+ export declare function getActionTranslationPrompt(action: string, ariaSnapshot: string): string;
5
+ export declare function getNarrationTranslationPrompt(narration: string, targetLanguage: string): string;
6
+ export declare function getDocsPolishPrompt(featureTitle: string, steps: {
7
+ action: string;
8
+ narration: string;
9
+ }[]): string;
@@ -0,0 +1,129 @@
1
+ export function getDocGenerationPrompt(segments) {
2
+ return `You are a technical writer creating documentation from a product video.
3
+
4
+ Write clear documentation based strictly on the video content below. You may rephrase for clarity and describe what is visually shown on screen, but NEVER add information that is not present in the spoken content or visible on screen. If code, APIs, or UI elements appear in the video, document them faithfully. Do NOT invent code snippets, API endpoints, JSON examples, or technical details that are not explicitly shown or spoken in the video.
5
+
6
+ Video segments (with timestamps and visual context):
7
+ ${JSON.stringify(segments, null, 2)}
8
+
9
+ Generate a structured documentation article in JSON format:
10
+ {
11
+ "title": "Article title",
12
+ "chapters": [
13
+ {
14
+ "title": "Chapter title",
15
+ "sections": [
16
+ {
17
+ "heading": "Section heading",
18
+ "content": "Markdown content with video timestamp references like [video:MM:SS]",
19
+ "timestamp_ref": "MM:SS"
20
+ }
21
+ ]
22
+ }
23
+ ]
24
+ }
25
+
26
+ Rules:
27
+ - Reference specific video timestamps using [video:MM:SS] format
28
+ - Each section should be self-contained and readable
29
+ - Group related content into chapters
30
+ - Only include code snippets if they are visible on screen or explicitly dictated in the video
31
+ - NEVER fabricate API endpoints, JSON schemas, or developer integration guides unless they appear in the video
32
+ - When uncertain whether something was in the video, leave it out — omission is better than hallucination
33
+ - Return ONLY valid JSON, no markdown fences.`;
34
+ }
35
+ export function getFeatureDiscoveryPrompt(summary, hints) {
36
+ const routeDescriptions = summary.routes
37
+ .map((r) => `Route: ${r.path}${r.isDynamic ? " (dynamic)" : ""}\nSource:\n${r.componentSource}\n`)
38
+ .join("\n---\n");
39
+ return `You are analyzing a ${summary.framework} web application to identify user-facing features for documentation.
40
+
41
+ Here are the discovered routes and their page components:
42
+
43
+ ${routeDescriptions}
44
+
45
+ ${hints ? `The user has specifically requested focus on: ${hints}\n` : ""}
46
+
47
+ For each user-facing feature you identify, generate a walkthrough script. Each feature should have:
48
+ - "id": a URL-safe slug (e.g., "create-project")
49
+ - "title": a human-readable title (e.g., "Creating a New Project")
50
+ - "category": a documentation category (e.g., "Getting Started", "Projects", "Settings")
51
+ - "steps": an array of walkthrough steps, each with:
52
+ - "action": a human-readable browser action (e.g., "navigate to /dashboard", "click button 'New Project'", "fill input[name='email'] with 'user@example.com'")
53
+ - "narration": what a voiceover would say during this step
54
+ - "pause": milliseconds to pause after the action (default 1500 for navigation, 1000 for clicks, 500 for typing)
55
+
56
+ Action format guidelines:
57
+ - "navigate to /path" — go to a URL
58
+ - "click button 'Label'" — click a button by visible text
59
+ - "click link 'Label'" — click a link by visible text
60
+ - "click 'Label'" — click any element by visible text
61
+ - "fill input[name='x'] with 'value'" — type into a form field
62
+ - "select 'Option' from 'Label'" — select from a dropdown
63
+ - "wait 2000" — explicit wait
64
+
65
+ Rules:
66
+ - Only include features that are accessible to end users (skip admin, API routes, auth internals)
67
+ - Group related features logically into categories
68
+ - Each feature should demonstrate a complete workflow (not just one click)
69
+ - The narration should explain what the user is doing and why, in a friendly tutorial tone
70
+ - Skip features behind dynamic routes that require specific data unless you can infer reasonable demo data
71
+ - Return ONLY valid JSON matching this structure, no markdown fences.
72
+
73
+ Return format:
74
+ {
75
+ "features": [
76
+ {
77
+ "id": "...",
78
+ "title": "...",
79
+ "category": "...",
80
+ "steps": [{ "action": "...", "narration": "...", "pause": 1500 }]
81
+ }
82
+ ]
83
+ }`;
84
+ }
85
+ export function getActionTranslationPrompt(action, ariaSnapshot) {
86
+ return `You are translating a human-readable browser action into a Playwright API call.
87
+
88
+ Current page structure (ARIA snapshot):
89
+ ${ariaSnapshot}
90
+
91
+ Action to translate: "${action}"
92
+
93
+ Return a single Playwright statement that performs this action. Use the most resilient selector strategy:
94
+ - Prefer getByRole() with name for buttons, links, headings
95
+ - Prefer getByLabel() for form inputs
96
+ - Prefer getByText() for generic text elements
97
+ - Use locator() with CSS only as a fallback
98
+
99
+ Return ONLY the Playwright code (e.g., "page.getByRole('button', { name: 'Submit' }).click()"), no explanation.`;
100
+ }
101
+ export function getNarrationTranslationPrompt(narration, targetLanguage) {
102
+ return `Translate the following narration text to ${targetLanguage}.
103
+ Keep it natural and conversational — this will be spoken aloud by a text-to-speech system.
104
+ Preserve any technical terms, product names, or UI element names that should stay in English.
105
+ Return ONLY the translated text, no preamble.
106
+
107
+ ${narration}`;
108
+ }
109
+ export function getDocsPolishPrompt(featureTitle, steps) {
110
+ const stepText = steps
111
+ .map((s, i) => `Step ${i + 1}: [Action: ${s.action}] ${s.narration}`)
112
+ .join("\n");
113
+ return `You are a technical writer creating documentation from a product walkthrough script.
114
+
115
+ Feature: ${featureTitle}
116
+
117
+ Walkthrough steps:
118
+ ${stepText}
119
+
120
+ Write clear, structured documentation for this feature. The output should be:
121
+ - Written in second person ("you can", "click the button")
122
+ - Organized with a brief introduction, then step-by-step instructions
123
+ - Include the step actions as context but rewrite narration into polished prose
124
+ - Use Markdown formatting (headings, bold for UI elements, numbered lists for steps)
125
+ - Keep it concise — aim for documentation, not a transcript
126
+
127
+ Return ONLY the Markdown content, no preamble.`;
128
+ }
129
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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AC;SACpE,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;WAEE,YAAY;;;EAGrB,QAAQ;;;;;;;;;+CASqC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type Plan } from "./plan-schema.js";
2
+ export interface AnalyzeOptions {
3
+ codebaseDir: string;
4
+ appUrl: string;
5
+ apiKey: string;
6
+ model?: string;
7
+ hints?: string;
8
+ outputPath?: string;
9
+ onProgress?: (message: string) => void;
10
+ }
11
+ export declare function analyzeCodebase(options: AnalyzeOptions): Promise<Plan>;
@@ -0,0 +1,55 @@
1
+ import { writeFile, mkdir } from "node:fs/promises";
2
+ import { dirname } from "node:path";
3
+ import yaml from "js-yaml";
4
+ import { initAI, generateJson } from "../ai/gemini.js";
5
+ import { getFeatureDiscoveryPrompt } from "../ai/prompts.js";
6
+ import { scanNextjs } from "./scanners/nextjs.js";
7
+ import { scanGeneric } from "./scanners/generic.js";
8
+ import { PlanSchema } from "./plan-schema.js";
9
+ export async function analyzeCodebase(options) {
10
+ const { codebaseDir, appUrl, apiKey, model = "gemini-2.5-flash", hints, outputPath = "./plan.yaml", onProgress = () => { }, } = options;
11
+ initAI(apiKey);
12
+ // Step 1: Scan the codebase
13
+ onProgress("Scanning codebase...");
14
+ let summary = await scanNextjs(codebaseDir);
15
+ if (!summary) {
16
+ onProgress("No Next.js structure found, falling back to generic scan...");
17
+ summary = await scanGeneric(codebaseDir);
18
+ }
19
+ if (summary.routes.length === 0) {
20
+ throw new Error("No routes or pages found in the codebase. Check the --codebase path.");
21
+ }
22
+ onProgress(`Found ${summary.routes.length} routes (${summary.framework}). Asking AI to identify features...`);
23
+ // Step 2: Send to Gemini for feature discovery
24
+ const prompt = getFeatureDiscoveryPrompt(summary, hints);
25
+ const aiResponse = await generateJson(prompt, model);
26
+ // Step 3: Assemble and validate the plan
27
+ const rawPlan = {
28
+ version: 1,
29
+ app: {
30
+ url: appUrl,
31
+ auth: {
32
+ strategy: "credentials",
33
+ credentials: { email: "", password: "" },
34
+ },
35
+ viewport: { width: 1280, height: 720 },
36
+ },
37
+ recording: { max_concurrent: 3 },
38
+ features: aiResponse.features,
39
+ output: {
40
+ video_dir: "./generated/videos",
41
+ docs_dir: "./generated/docs",
42
+ languages: ["en"],
43
+ tts: { provider: "google", voice: "en-US-Studio-O", speed: 1.0 },
44
+ screenshots: true,
45
+ },
46
+ };
47
+ const plan = PlanSchema.parse(rawPlan);
48
+ // Step 4: Write YAML
49
+ const yamlContent = yaml.dump(plan, { lineWidth: 120, noRefs: true });
50
+ await mkdir(dirname(outputPath), { recursive: true });
51
+ await writeFile(outputPath, yamlContent, "utf-8");
52
+ onProgress(`Plan written to ${outputPath}`);
53
+ return plan;
54
+ }
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/analyze/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AAazD,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAuB;IAC3D,MAAM,EACJ,WAAW,EACX,MAAM,EACN,MAAM,EACN,KAAK,GAAG,kBAAkB,EAC1B,KAAK,EACL,UAAU,GAAG,aAAa,EAC1B,UAAU,GAAG,GAAG,EAAE,GAAE,CAAC,GACtB,GAAG,OAAO,CAAC;IAEZ,MAAM,CAAC,MAAM,CA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KAAK,EAAE,GAAG,EAAE;YACzE,WAAW,EAAE,IAAI;SAClB;KACF,CAAC;IAEF,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAEvC,qBAAqB;IACrB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACtE,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,MAAM,SAAS,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IAElD,UAAU,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,180 @@
1
+ import { z } from "zod/v4";
2
+ export declare const StepSchema: z.ZodObject<{
3
+ action: z.ZodString;
4
+ narration: z.ZodString;
5
+ pause: z.ZodDefault<z.ZodNumber>;
6
+ timeout: z.ZodDefault<z.ZodNumber>;
7
+ }, z.core.$strip>;
8
+ export type Step = z.infer<typeof StepSchema>;
9
+ export declare const FeatureSchema: z.ZodObject<{
10
+ id: z.ZodString;
11
+ title: z.ZodString;
12
+ category: z.ZodString;
13
+ steps: z.ZodArray<z.ZodObject<{
14
+ action: z.ZodString;
15
+ narration: z.ZodString;
16
+ pause: z.ZodDefault<z.ZodNumber>;
17
+ timeout: z.ZodDefault<z.ZodNumber>;
18
+ }, z.core.$strip>>;
19
+ }, z.core.$strip>;
20
+ export type Feature = z.infer<typeof FeatureSchema>;
21
+ export declare const AuthSchema: z.ZodObject<{
22
+ strategy: z.ZodEnum<{
23
+ script: "script";
24
+ cookie: "cookie";
25
+ credentials: "credentials";
26
+ }>;
27
+ credentials: z.ZodOptional<z.ZodObject<{
28
+ email: z.ZodString;
29
+ password: z.ZodString;
30
+ }, z.core.$strip>>;
31
+ setup_script: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>;
33
+ export type Auth = z.infer<typeof AuthSchema>;
34
+ export declare const ViewportSchema: z.ZodObject<{
35
+ width: z.ZodDefault<z.ZodNumber>;
36
+ height: z.ZodDefault<z.ZodNumber>;
37
+ }, z.core.$strip>;
38
+ export declare const AppSchema: z.ZodObject<{
39
+ url: z.ZodURL;
40
+ auth: z.ZodObject<{
41
+ strategy: z.ZodEnum<{
42
+ script: "script";
43
+ cookie: "cookie";
44
+ credentials: "credentials";
45
+ }>;
46
+ credentials: z.ZodOptional<z.ZodObject<{
47
+ email: z.ZodString;
48
+ password: z.ZodString;
49
+ }, z.core.$strip>>;
50
+ setup_script: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$strip>;
52
+ viewport: z.ZodDefault<z.ZodOptional<z.ZodObject<{
53
+ width: z.ZodDefault<z.ZodNumber>;
54
+ height: z.ZodDefault<z.ZodNumber>;
55
+ }, z.core.$strip>>>;
56
+ }, z.core.$strip>;
57
+ export declare const RecordingConfigSchema: z.ZodObject<{
58
+ max_concurrent: z.ZodDefault<z.ZodNumber>;
59
+ }, z.core.$strip>;
60
+ export declare const TTSConfigSchema: z.ZodObject<{
61
+ provider: z.ZodDefault<z.ZodEnum<{
62
+ google: "google";
63
+ openai: "openai";
64
+ elevenlabs: "elevenlabs";
65
+ }>>;
66
+ voice: z.ZodDefault<z.ZodString>;
67
+ speed: z.ZodDefault<z.ZodNumber>;
68
+ }, z.core.$strip>;
69
+ export declare const OutputSchema: z.ZodObject<{
70
+ video_dir: z.ZodDefault<z.ZodString>;
71
+ docs_dir: z.ZodDefault<z.ZodString>;
72
+ languages: z.ZodDefault<z.ZodArray<z.ZodString>>;
73
+ tts: z.ZodDefault<z.ZodOptional<z.ZodObject<{
74
+ provider: z.ZodDefault<z.ZodEnum<{
75
+ google: "google";
76
+ openai: "openai";
77
+ elevenlabs: "elevenlabs";
78
+ }>>;
79
+ voice: z.ZodDefault<z.ZodString>;
80
+ speed: z.ZodDefault<z.ZodNumber>;
81
+ }, z.core.$strip>>>;
82
+ screenshots: z.ZodDefault<z.ZodBoolean>;
83
+ }, z.core.$strip>;
84
+ export declare const PlanSchema: z.ZodObject<{
85
+ version: z.ZodLiteral<1>;
86
+ app: z.ZodObject<{
87
+ url: z.ZodURL;
88
+ auth: z.ZodObject<{
89
+ strategy: z.ZodEnum<{
90
+ script: "script";
91
+ cookie: "cookie";
92
+ credentials: "credentials";
93
+ }>;
94
+ credentials: z.ZodOptional<z.ZodObject<{
95
+ email: z.ZodString;
96
+ password: z.ZodString;
97
+ }, z.core.$strip>>;
98
+ setup_script: z.ZodOptional<z.ZodString>;
99
+ }, z.core.$strip>;
100
+ viewport: z.ZodDefault<z.ZodOptional<z.ZodObject<{
101
+ width: z.ZodDefault<z.ZodNumber>;
102
+ height: z.ZodDefault<z.ZodNumber>;
103
+ }, z.core.$strip>>>;
104
+ }, z.core.$strip>;
105
+ recording: z.ZodDefault<z.ZodOptional<z.ZodObject<{
106
+ max_concurrent: z.ZodDefault<z.ZodNumber>;
107
+ }, z.core.$strip>>>;
108
+ features: z.ZodArray<z.ZodObject<{
109
+ id: z.ZodString;
110
+ title: z.ZodString;
111
+ category: z.ZodString;
112
+ steps: z.ZodArray<z.ZodObject<{
113
+ action: z.ZodString;
114
+ narration: z.ZodString;
115
+ pause: z.ZodDefault<z.ZodNumber>;
116
+ timeout: z.ZodDefault<z.ZodNumber>;
117
+ }, z.core.$strip>>;
118
+ }, z.core.$strip>>;
119
+ output: z.ZodDefault<z.ZodOptional<z.ZodObject<{
120
+ video_dir: z.ZodDefault<z.ZodString>;
121
+ docs_dir: z.ZodDefault<z.ZodString>;
122
+ languages: z.ZodDefault<z.ZodArray<z.ZodString>>;
123
+ tts: z.ZodDefault<z.ZodOptional<z.ZodObject<{
124
+ provider: z.ZodDefault<z.ZodEnum<{
125
+ google: "google";
126
+ openai: "openai";
127
+ elevenlabs: "elevenlabs";
128
+ }>>;
129
+ voice: z.ZodDefault<z.ZodString>;
130
+ speed: z.ZodDefault<z.ZodNumber>;
131
+ }, z.core.$strip>>>;
132
+ screenshots: z.ZodDefault<z.ZodBoolean>;
133
+ }, z.core.$strip>>>;
134
+ }, z.core.$strip>;
135
+ export type Plan = z.infer<typeof PlanSchema>;
136
+ export declare const ManifestStepSchema: z.ZodObject<{
137
+ stepIndex: z.ZodNumber;
138
+ startedAt: z.ZodNumber;
139
+ completedAt: z.ZodNumber;
140
+ screenshot: z.ZodOptional<z.ZodString>;
141
+ }, z.core.$strip>;
142
+ export type ManifestStep = z.infer<typeof ManifestStepSchema>;
143
+ export declare const ManifestFeatureSchema: z.ZodObject<{
144
+ video_path: z.ZodString;
145
+ status: z.ZodEnum<{
146
+ failed: "failed";
147
+ success: "success";
148
+ }>;
149
+ steps: z.ZodArray<z.ZodObject<{
150
+ stepIndex: z.ZodNumber;
151
+ startedAt: z.ZodNumber;
152
+ completedAt: z.ZodNumber;
153
+ screenshot: z.ZodOptional<z.ZodString>;
154
+ }, z.core.$strip>>;
155
+ duration_ms: z.ZodNumber;
156
+ error: z.ZodOptional<z.ZodString>;
157
+ error_screenshot: z.ZodOptional<z.ZodString>;
158
+ }, z.core.$strip>;
159
+ export type ManifestFeature = z.infer<typeof ManifestFeatureSchema>;
160
+ export declare const RecordingManifestSchema: z.ZodObject<{
161
+ version: z.ZodLiteral<1>;
162
+ recorded_at: z.ZodString;
163
+ features: z.ZodRecord<z.ZodString, z.ZodObject<{
164
+ video_path: z.ZodString;
165
+ status: z.ZodEnum<{
166
+ failed: "failed";
167
+ success: "success";
168
+ }>;
169
+ steps: z.ZodArray<z.ZodObject<{
170
+ stepIndex: z.ZodNumber;
171
+ startedAt: z.ZodNumber;
172
+ completedAt: z.ZodNumber;
173
+ screenshot: z.ZodOptional<z.ZodString>;
174
+ }, z.core.$strip>>;
175
+ duration_ms: z.ZodNumber;
176
+ error: z.ZodOptional<z.ZodString>;
177
+ error_screenshot: z.ZodOptional<z.ZodString>;
178
+ }, z.core.$strip>>;
179
+ }, z.core.$strip>;
180
+ export type RecordingManifest = z.infer<typeof RecordingManifestSchema>;
@@ -0,0 +1,91 @@
1
+ import { z } from "zod/v4";
2
+ // --- Step schema ---
3
+ export const StepSchema = z.object({
4
+ action: z.string().min(1),
5
+ narration: z.string().min(1),
6
+ pause: z.number().int().nonnegative().default(0),
7
+ timeout: z.number().int().positive().default(10000),
8
+ });
9
+ // --- Feature schema ---
10
+ export const FeatureSchema = z.object({
11
+ id: z.string().min(1),
12
+ title: z.string().min(1),
13
+ category: z.string().min(1),
14
+ steps: z.array(StepSchema).min(1),
15
+ });
16
+ // --- Auth schema ---
17
+ export const AuthSchema = z.object({
18
+ strategy: z.enum(["credentials", "cookie", "script"]),
19
+ credentials: z
20
+ .object({ email: z.string(), password: z.string() })
21
+ .optional(),
22
+ setup_script: z.string().optional(),
23
+ });
24
+ // --- Viewport schema ---
25
+ export const ViewportSchema = z.object({
26
+ width: z.number().int().positive().default(1280),
27
+ height: z.number().int().positive().default(720),
28
+ });
29
+ // --- App schema ---
30
+ export const AppSchema = z.object({
31
+ url: z.url(),
32
+ auth: AuthSchema,
33
+ viewport: ViewportSchema.optional().default({ width: 1280, height: 720 }),
34
+ });
35
+ // --- Recording schema ---
36
+ export const RecordingConfigSchema = z.object({
37
+ max_concurrent: z.number().int().positive().default(3),
38
+ });
39
+ // --- TTS schema ---
40
+ export const TTSConfigSchema = z.object({
41
+ provider: z.enum(["google", "openai", "elevenlabs"]).default("google"),
42
+ voice: z.string().default("en-US-Studio-O"),
43
+ speed: z.number().positive().default(1.0),
44
+ });
45
+ // --- Output schema ---
46
+ export const OutputSchema = z.object({
47
+ video_dir: z.string().default("./generated/videos"),
48
+ docs_dir: z.string().default("./generated/docs"),
49
+ languages: z.array(z.string()).min(1).default(["en"]),
50
+ tts: TTSConfigSchema.optional().default({
51
+ provider: "google",
52
+ voice: "en-US-Studio-O",
53
+ speed: 1.0,
54
+ }),
55
+ screenshots: z.boolean().default(true),
56
+ });
57
+ // --- Plan schema (top-level) ---
58
+ export const PlanSchema = z.object({
59
+ version: z.literal(1),
60
+ app: AppSchema,
61
+ recording: RecordingConfigSchema.optional().default({ max_concurrent: 3 }),
62
+ features: z.array(FeatureSchema).min(1),
63
+ output: OutputSchema.optional().default({
64
+ video_dir: "./generated/videos",
65
+ docs_dir: "./generated/docs",
66
+ languages: ["en"],
67
+ tts: { provider: "google", voice: "en-US-Studio-O", speed: 1.0 },
68
+ screenshots: true,
69
+ }),
70
+ });
71
+ // --- Recording manifest schemas ---
72
+ export const ManifestStepSchema = z.object({
73
+ stepIndex: z.number().int().nonnegative(),
74
+ startedAt: z.number().nonnegative(),
75
+ completedAt: z.number().nonnegative(),
76
+ screenshot: z.string().optional(),
77
+ });
78
+ export const ManifestFeatureSchema = z.object({
79
+ video_path: z.string(),
80
+ status: z.enum(["success", "failed"]),
81
+ steps: z.array(ManifestStepSchema),
82
+ duration_ms: z.number().nonnegative(),
83
+ error: z.string().optional(),
84
+ error_screenshot: z.string().optional(),
85
+ });
86
+ export const RecordingManifestSchema = z.object({
87
+ version: z.literal(1),
88
+ recorded_at: z.string(),
89
+ features: z.record(z.string(), ManifestFeatureSchema),
90
+ });
91
+ //# sourceMappingURL=plan-schema.js.map