Repository navigation
feat: add source module for prompt edits - #50
Closed
wavekat-eason wants to merge 1 commit into
Closed
wavekat-eason wants to merge 1 commit into
wavekat-eason wants to merge 1 commit into
Conversation
Rust authoring tools need to voice a flow's text prompts and swap
local recordings for uploaded clips without losing the author's
comments and layout. That logic encodes the format (which fields hold
a prompt, what a clip ref is, the shape of a voiced prompt), so it
belongs here rather than in each consumer.
- `source`: find prompts in the YAML text, voice text prompts as
`{ audio, transcript }`, replace `audio:` refs. Every edit is a
splice, re-parsed and compared event by event before it's returned.
- `prompt_fields(kind)` and `PROMPT_FIELDS`, kept in step with
`Node::prompts` by a corpus test.
- `is_generated_clip_ref` (twin of `isGeneratedClipRef`) and
`is_local_audio_ref`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GNFHhzw4ZsqCFnv6ERigjd
Contributor
Author
|
Closing: rather than splicing YAML text, we're making the document the complete source of truth (per-node |
1 of 2 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Rust authoring tools (a CLI that voices and publishes flows, for one) need to edit a flow's YAML text: swap each text prompt for the clip generated from it, and swap a local recording's path for the clip uploaded from it. They have to keep the author's comments and layout, so the typed
Flowround-trip won't do. That code encodes the format: which fields hold a prompt, what a generated clip ref is, and what a voiced prompt looks like. So it should live here, next to the model and checked against the corpus, not be copied into each consumer.sourcemodule (new)prompts(src) -> Prompts { text, audio }lists every prompt in document order, with node, field and kind. Audio prompts carryaudioandtranscript.voice_text_prompts(src, &[(TextPrompt, clip_ref)])writes each text prompt as{ audio: <clip>, transcript: "<text>" }, the shape the web editor writes. It uses block style in block context and flow style inside{…}.local_audio(src)andreplace_audio_refs(src, &[(AudioPrompt, clip_ref)])handleaudio: ./intro.wavstyle prompts.top_level_name(src)andwith_placeholder_fields(src, …)let a draft with noidornameyet still be validated.SourceError::Mismatchinstead of a broken document.SourceError::NotAClipRef).Model helpers
prompt_fields(kind)andPROMPT_FIELDSsay which fields a kind speaks from.sourceuses them, so a field likebook'sconfirm_promptis only voiced on a node of that kind. A node with no kind, or a kind this build doesn't know, keeps every prompt field, so nothing is skipped silently.is_generated_clip_refis the Rust twin ofisGeneratedClipRef(^vprompt_[a-z0-9]+$, case-insensitive).is_local_audio_ref: a path separator or an audio file extension makes a ref a local file. A generated clip ref never counts as one.Dependency
saphyr-parser = "=0.2.2", event parser only, pure Rust. It's needed becauseserde_yaml_ngdoesn't expose value positions. It's pinned exactly because 0.2.2's markers count chars, not bytes as its docs say, and the module relies on that. The non-ASCII tests would catch a change. Lockfile: addssaphyr-parserandarraydeque, and bumpsthiserror2.0.19 → 2.0.21, which saphyr-parser requires.Not in this PR
voice_text_prompts. The platform voices prompts through its own editor code today. Moving that onto a shared op, with corpus cases both languages run, would be a natural follow-up.booksteps can't use uploaded clips. That depends on whether a clip was uploaded or generated, which only the platform knows, so it stays a platform check.Test plan
cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo test -p wavekat-flow: all pass.nodes; per-kind fields; local audio detection and replacement; placeholder fields.tests/source.rsruns over every valid corpus document (includingoutbound/valid):source::promptsmust agree withNode::prompts()node for node. Checked by hand: removingconfirm_promptfrombook's fields makes it fail onv2/valid/clinic.yaml.{ audio, transcript }.cargo package -p wavekat-flowbuilds.🤖 Generated with Claude Code
https://claude.ai/code/session_01GNFHhzw4ZsqCFnv6ERigjd