-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(media): image/video/audio project kinds via od media generate #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pftom
wants to merge
14
commits into
main
Choose a base branch
from
cursor/289994c1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
af3f963
Refactor project name from "Open Claude Design" to "Open Design"
pftom 9852384
Add contributing guidelines in English and Chinese
pftom 243e611
Update README and documentation for deck framework directives
pftom 0eef347
Update README and documentation for deck framework directives
pftom 490bbe2
Merge branch 'feat/optimize-naming' of github.com:nexu-io/open-design…
pftom 1337907
Merge branch 'main' of github.com:nexu-io/open-design
pftom 19b5272
Merge branch 'main' into feat/optimize-naming
pftom 5a63d09
Enhance README and add star promotion assets
pftom bc7c057
Merge remote-tracking branch 'origin/main' into cursor/47ca13ab
pftom 0b61be5
Merge remote-tracking branch 'origin/main' into cursor/289994c1
pftom ac70719
feat(media): add image / video / audio surfaces with unified od media…
pftom 976a6ea
feat(media): add image/video/audio project kinds via od media generate
pftom 8719c08
Merge PR #12 (cursor/47ca13ab) into cursor/289994c1
pftom 68069c5
fix(media): address PR #11 review (validation, drift, security, promp…
pftom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Daemon-side wrapper around the shared media model registry. The | ||
| // authoritative data lives in src/media/models.data.json so the | ||
| // frontend (NewProjectPanel pickers, MEDIA_GENERATION_CONTRACT prompt) | ||
| // and the daemon dispatcher read the exact same arrays — no hand-mirror, | ||
| // no drift. We keep this file in plain JS so the daemon never needs a | ||
| // TS toolchain at runtime; it just JSON.parses one file at module load. | ||
|
|
||
| import { readFileSync } from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const DATA_PATH = path.join(__dirname, '..', 'src', 'media', 'models.data.json'); | ||
|
|
||
| const data = JSON.parse(readFileSync(DATA_PATH, 'utf8')); | ||
|
|
||
| export const IMAGE_MODELS = data.image; | ||
| export const VIDEO_MODELS = data.video; | ||
| export const AUDIO_MODELS_BY_KIND = data.audio; | ||
| export const MEDIA_ASPECTS = data.aspects; | ||
| export const VIDEO_LENGTHS_SEC = data.videoLengthsSec; | ||
| export const AUDIO_DURATIONS_SEC = data.audioDurationsSec; | ||
|
|
||
| export function findMediaModel(id) { | ||
| const all = [ | ||
| ...IMAGE_MODELS, | ||
| ...VIDEO_MODELS, | ||
| ...AUDIO_MODELS_BY_KIND.music, | ||
| ...AUDIO_MODELS_BY_KIND.speech, | ||
| ...AUDIO_MODELS_BY_KIND.sfx, | ||
| ]; | ||
| return all.find((m) => m.id === id) || null; | ||
| } | ||
|
|
||
| export function modelsForSurface(surface, audioKind) { | ||
| if (surface === 'image') return IMAGE_MODELS; | ||
| if (surface === 'video') return VIDEO_MODELS; | ||
| if (surface === 'audio') { | ||
| const k = audioKind || 'music'; | ||
| return AUDIO_MODELS_BY_KIND[k] || AUDIO_MODELS_BY_KIND.music; | ||
| } | ||
| return []; | ||
| } | ||
|
|
||
| // Surface-aware lookup. Returns the model record only when it is registered | ||
| // for the given (surface, audioKind) pair. The dispatcher uses this to | ||
| // reject mismatches like `surface=image, model=suno-v5` BEFORE writing | ||
| // bytes — without it, an audio model would silently produce an image-named | ||
| // stub and routing to a real provider later would land in the wrong place. | ||
| export function findMediaModelForSurface(id, surface, audioKind) { | ||
| const list = modelsForSurface(surface, audioKind); | ||
| return list.find((m) => m.id === id) || null; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3 Missing validation: the CLI parses
--lengthand--durationasNumber(flags.length)but doesn't validate they're positive integers. A malicious/confused agent could pass--length=-5or--length=banana, silently gettingNaNin the POST body. The dispatcher checkstypeofbutNumber('banana')isnumber(albeitNaN). Suggest:const len = Number(flags.length); if (!Number.isFinite(len) || len <= 0) { console.error('--length must be a positive number'); process.exit(2); }