Initial TrueGrowth source import
This commit is contained in:
37
openspec/changes/add-video-prompt-pdf-context/design.md
Normal file
37
openspec/changes/add-video-prompt-pdf-context/design.md
Normal file
@@ -0,0 +1,37 @@
|
||||
## Context
|
||||
The multi-image tool already supports PDF context by caching the uploaded PDF and passing `pdfCacheUrl`, `pdfMimeType`, and `pdfName` into a `TaskType.CHAT` task. `TaskQueueService.buildChatInlineDataParts()` converts that cached PDF to Gemini `inline_data`, so the new popular-video flow should reuse this path instead of introducing a PDF extraction service.
|
||||
|
||||
The popular video tool stores workflow records as `AnalysisRecord` and downstream pages expect `analysis: VideoAnalysisData`. A prompt-based start can therefore create the same analysis shape without a source video.
|
||||
|
||||
## Goals
|
||||
- Add a first tab/input mode named `提示词生成` before `上传视频`.
|
||||
- Let users enter a creative prompt and optionally upload a PDF as Gemini context.
|
||||
- Submit prompt generation through the unified task queue.
|
||||
- Store the result as a normal popular-video record so Script and Generate pages keep working.
|
||||
- Avoid persisting PDF base64 or full provider responses in history.
|
||||
|
||||
## Non-Goals
|
||||
- No new PDF parser or backend endpoint.
|
||||
- No new storage table/entity.
|
||||
- No changes to video generation semantics after the script is created.
|
||||
|
||||
## Design
|
||||
Extend the video analyzer task action from `analyze | rewrite` to include a prompt-generation action, for example `prompt-generate`. The task params carry:
|
||||
- `prompt`: short task label for queue display
|
||||
- `videoAnalyzerPrompt`: full Gemini instruction
|
||||
- `videoAnalyzerAction: 'prompt-generate'`
|
||||
- `videoAnalyzerSource: 'prompt'`
|
||||
- optional `pdfCacheUrl`, `pdfMimeType`, `pdfName`
|
||||
|
||||
The task queue routes this action through the normal text generation path with `buildChatInlineDataParts()`, then finalizes the task with both markdown preview and structured `VideoAnalysisData`. Task sync creates an `AnalysisRecord` with `source: 'prompt'`, a prompt source label, and a lightweight source snapshot containing prompt text plus optional PDF metadata/cache reference.
|
||||
|
||||
Prompt generation should instruct Gemini to return the same JSON contract as video analysis: total duration, aspect ratio, style, BGM mood, characters, and ordered shots with first/last frame prompts, narration/dialogue, camera movement, and transitions. This keeps existing script editing, versioning, and video generation surfaces compatible.
|
||||
|
||||
## Error Handling
|
||||
- Reject non-PDF uploads and PDFs above the existing multi-image limit.
|
||||
- If a PDF is attached but no Gemini text model is available, show the same style of warning as the multi-image tool.
|
||||
- If a cached PDF cannot be read while the task runs, fail the queue task with a clear message.
|
||||
- If Gemini returns invalid JSON, mark the task failed and keep the current form state.
|
||||
|
||||
## Performance
|
||||
The PDF remains a cached Blob reference until the task executes. Conversion to base64 happens only during Gemini submission, matching current multi-image behavior. No new long-lived large strings should be stored in workflow history.
|
||||
14
openspec/changes/add-video-prompt-pdf-context/proposal.md
Normal file
14
openspec/changes/add-video-prompt-pdf-context/proposal.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# Change: Add PDF-backed prompt start for popular video
|
||||
|
||||
## Why
|
||||
The popular video tool currently starts from an uploaded video or YouTube URL. Users also need to start from a creative prompt and optional PDF context, then continue through the same script editing and video generation workflow.
|
||||
|
||||
## What Changes
|
||||
- Add a prompt-generation input mode before the existing upload video mode in the popular video analysis step.
|
||||
- Reuse the existing Gemini `TaskType.CHAT` PDF inline-data path from the multi-image tool, avoiding a separate PDF parser or storage entity.
|
||||
- Generate a `VideoAnalysisData`-compatible script plan from user prompt plus optional PDF context so the existing Script and Generate pages can continue unchanged.
|
||||
- Persist only lightweight prompt/PDF source metadata and cache references needed for pending or repeatable tasks.
|
||||
|
||||
## Impact
|
||||
- Affected specs: `video-analyzer`
|
||||
- Affected code: `video-analyzer` Analyze page/types/utils/task sync, `task-queue-service` chat action routing, focused tests
|
||||
@@ -0,0 +1,35 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Popular Video Prompt Start
|
||||
The popular video tool SHALL allow users to start the workflow from a creative prompt before uploading a source video.
|
||||
|
||||
#### Scenario: Generate script plan from prompt
|
||||
- **WHEN** the user selects the prompt-generation input mode and submits a creative prompt
|
||||
- **THEN** the system SHALL create a queued text task
|
||||
- **AND** the completed task SHALL create a popular-video record with `VideoAnalysisData`-compatible shots
|
||||
- **AND** the user SHALL be able to continue to script editing and video generation without uploading a source video
|
||||
|
||||
#### Scenario: Preserve existing source-video starts
|
||||
- **WHEN** the user selects upload video or YouTube URL
|
||||
- **THEN** the existing video analysis behavior SHALL remain available
|
||||
- **AND** the prompt-generation mode SHALL NOT change uploaded-video or YouTube task semantics
|
||||
|
||||
### Requirement: Popular Video Prompt Start SHALL Support PDF Context
|
||||
The prompt-generation input mode SHALL accept an optional PDF context and send it to Gemini with the prompt.
|
||||
|
||||
#### Scenario: Submit prompt with PDF context
|
||||
- **GIVEN** the user uploads a valid PDF in prompt-generation mode
|
||||
- **WHEN** the user submits prompt generation
|
||||
- **THEN** the task SHALL include the cached PDF reference and MIME metadata
|
||||
- **AND** Gemini SHALL receive the PDF as inline context together with the prompt-generation instruction
|
||||
|
||||
#### Scenario: Reject invalid PDF context
|
||||
- **WHEN** the user uploads a non-PDF file or a PDF above the allowed size
|
||||
- **THEN** the system SHALL reject the file before task submission
|
||||
- **AND** it SHALL keep the current prompt text intact
|
||||
|
||||
#### Scenario: Missing cached PDF during execution
|
||||
- **GIVEN** a prompt-generation task references a cached PDF
|
||||
- **WHEN** the cached PDF cannot be read during execution
|
||||
- **THEN** the task SHALL fail with a clear PDF-read error
|
||||
- **AND** no partial popular-video record SHALL be created
|
||||
11
openspec/changes/add-video-prompt-pdf-context/tasks.md
Normal file
11
openspec/changes/add-video-prompt-pdf-context/tasks.md
Normal file
@@ -0,0 +1,11 @@
|
||||
## 1. Implementation
|
||||
- [x] 1.1 Extend popular-video source/task types to support prompt-based source records and prompt-generation tasks.
|
||||
- [x] 1.2 Add a video prompt-generation prompt builder that returns `VideoAnalysisData` JSON compatible with the existing workflow.
|
||||
- [x] 1.3 Add `提示词生成` input mode before `上传视频`, with prompt text, optional PDF upload/removal, model selection, and queue submission.
|
||||
- [x] 1.4 Route prompt-generation tasks through the existing Gemini chat + PDF inline-data path and finalize structured results.
|
||||
- [x] 1.5 Sync completed prompt-generation tasks into `AnalysisRecord` history without storing PDF base64.
|
||||
- [x] 1.6 Add focused tests for prompt builder/parsing, task sync, and PDF task params.
|
||||
|
||||
## 2. Verification
|
||||
- [x] 2.1 Run targeted unit tests for video analyzer utilities/task sync.
|
||||
- [ ] 2.2 Manually verify prompt-only generation, prompt + PDF generation, invalid PDF, oversized PDF, and history reopen behavior.
|
||||
Reference in New Issue
Block a user