Repository navigation
feat: read the last Claude turn and add the voice prompts - #410
Conversation
ClaudeSpeakable gets the rest of its text work. It reads the turn that just ended from a session transcript, with the turn before it. It holds the rewrite, explain and reminder prompts and builds their inputs. It parses the model's JSON, caps a long answer to whole sentences, and scores how well a rewrite sticks to its source. The test runner checks turns, parse, capped, grounded and summary cases. The naming cases wait for ClaudeVoice. Signed-off-by: Nathan Zylbersztejn <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Automatic reviews are disabled for this repository. Configure in Code Review Settings. |
|
@coderabbitai review |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Action not completed
|
rewriteInput redacted the earlier turn but not the reply or recap. reminderInput's latest summary and explainInput's context also went out unredacted. All of it is transcript text that can hold a secret, and the model may be remote. Each field now goes through redacted(). Three inline checks cover it. Signed-off-by: Nathan Zylbersztejn <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the local CodeRabbit review: - Each input field is redacted before its prefix or suffix cut. A suffix cut could drop "token=" and leave the secret bare. - contentWords trims a trailing period or quote, so "main." matches "main" and grounded no longer scores a faithful answer low. - A transcript tail that starts inside a multi-byte character is decoded with replacement characters instead of failing the whole read. One grounded case and two inline checks cover them. All three fail on the previous commit. Signed-off-by: Nathan Zylbersztejn <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Remote CodeRabbit hit its review limit on the request above, so this PR relies on the local CodeRabbit CLI. It found 3 issues on 15b2e76..5f29b72: redact before the length cut, a trailing period in |
PR 2 of the Claude voice train.
ClaudeSpeakablecan now read the turn that just ended from a session transcript. It also holds the prompts that turn that turn into speech. Nothing calls this code yet. PR 6 (ClaudeVoice) and PR 7 (the CLI) wire it in.Checks.
scripts/check-claude-voice.shpasses 104/104. PR 1 had 60, and this PR adds 44.Changes from the target. Review found four problems in the target code. They are fixed here, and each has a check:
rewriteInputsentreplyandrecapto the model unredacted. So didreminderInput(latest) andexplainInput(the assistant's text). These are transcript text, and the model may be remote. All of them now go throughredacted(). This came from a security review.token=and leave the secret bare. Now each field is redacted first, then cut. This came from local CodeRabbit.contentWordskept a trailing period, so "main." never matched "main". Sogroundedscored faithful answers too low. The period and quotes at a word's edges are now trimmed. This came from local CodeRabbit.What this PR adds
Sources/ParrotFlow/ClaudeSpeakable.swift, taken fromclaude-voice-target:TurnEnd,Earlier,lastTurn,turn(endingAt:in:),isPrompt,latestSummary. The answer is the text after the last tool call. A wrap-up recap is kept. Background task notices and meta reminder lines do not start a new turn.rewritePrompt/rewriteInput,explainPrompt/explainInput,reminderPrompt/reminderInput.parseSpokenreads the model's JSON, or plain text.cappedkeeps at most 3 whole sentences, about 300 characters.capitalizedSentences,spokenOpener,fluent,instructions.groundedgives the share of the output's content words that the source also has.groundedFlooris 0.4.keptis for keep mode.Sources/ParrotFlow/ClaudeHooksCommand.swift:Casesdecodesturns,parse,capped,groundedandsummary.test(cases:)checks them. It also runs six inline checks: the capital after a period, three redaction checks, redact before the cut, and a tail cut inside a character.tests/claude-voice-cases.yaml: 21 new cases in those five sections.Compared with the target,
ClaudeSpeakable.swiftdiffers in PR 1's two review fixes and in the fixes above. PR 1's fixes are the folder path rule andword.last ?? " ". Both are kept.Left for later PRs
namingcases, the introduction checks and the naming loop needClaudeVoice. They come in PR 6.spoken(transcript:),explain,sayand their flags come in PR 7. They are the callers oflastTurn(transcript:),rewriteInputandexplainInput.How it was checked
swift build -c releaseis green.scripts/check-claude-voice.shgives 104/104. The 44 new checks: turns 12, parse 15, capped 4, grounded 5, summary 2, inline 6.ClaudeSpeakable.swift(5f29b72), the new checks fail as they should, 101/104. The three failures are "a word before a period matches the same word", "a secret is redacted before the cut" and "a tail that starts inside a character still reads".swiftlint linton both Swift files gives 0 warnings and 0 errors. The two lossyString(decoding:)calls have a targetedswiftlint:disable:next, because the lossy decode is the fix.🤖 Generated with Claude Code