VoiceWake: route forwarding via agent rpc
This commit is contained in:
@@ -16,54 +16,6 @@ import Testing
|
||||
#expect(parsed?.port == defaultVoiceWakeForwardPort)
|
||||
}
|
||||
|
||||
@Test func renderedCommandReplacesPlaceholderAndEscapes() {
|
||||
let template = "clawdis-mac agent --message \"${text}\""
|
||||
let command = VoiceWakeForwarder.renderedCommand(template: template, transcript: "hi i'm here")
|
||||
#expect(command.contains("clawdis-mac agent"))
|
||||
#expect(command.contains("'hi i'\\''m here'"))
|
||||
#expect(!command.contains("${text}"))
|
||||
}
|
||||
|
||||
@Test func renderedCommandPassthroughWhenNoPlaceholder() {
|
||||
let template = "echo noop"
|
||||
let command = VoiceWakeForwarder.renderedCommand(template: template, transcript: "ignored")
|
||||
#expect(command == template)
|
||||
}
|
||||
|
||||
@Test func commandPrefersCliInstallPaths() {
|
||||
let command = VoiceWakeForwarder.commandWithCliPath("clawdis-mac status", target: "user@host")
|
||||
#expect(command.contains("PATH=\(cliHelperSearchPaths.joined(separator: ":"))"))
|
||||
#expect(command.contains("for c in clawdis-mac /usr/local/bin/clawdis-mac /opt/homebrew/bin/clawdis-mac"))
|
||||
#expect(command.contains("\"$CLI\" status"))
|
||||
}
|
||||
|
||||
@Test func commandUsesCachedCliForSameTarget() {
|
||||
VoiceWakeForwarder.clearCliCache(); defer { VoiceWakeForwarder.clearCliCache() }
|
||||
VoiceWakeForwarder._testSetCliCache(target: "t1", path: "/tmp/custom-cli")
|
||||
|
||||
let command = VoiceWakeForwarder.commandWithCliPath("clawdis-mac status", target: "t1")
|
||||
|
||||
#expect(command.contains("CLI=\"/tmp/custom-cli\""))
|
||||
}
|
||||
|
||||
@Test func commandIgnoresCacheForDifferentTarget() {
|
||||
VoiceWakeForwarder.clearCliCache(); defer { VoiceWakeForwarder.clearCliCache() }
|
||||
VoiceWakeForwarder._testSetCliCache(target: "t1", path: "/tmp/custom-cli")
|
||||
|
||||
let command = VoiceWakeForwarder.commandWithCliPath("clawdis-mac status", target: "t2")
|
||||
|
||||
#expect(!command.contains("/tmp/custom-cli"))
|
||||
}
|
||||
|
||||
@Test func clearCliCacheRemovesCachedCli() {
|
||||
VoiceWakeForwarder._testSetCliCache(target: "t1", path: "/tmp/custom-cli")
|
||||
VoiceWakeForwarder.clearCliCache(); defer { VoiceWakeForwarder.clearCliCache() }
|
||||
|
||||
let command = VoiceWakeForwarder.commandWithCliPath("clawdis-mac status", target: "t1")
|
||||
|
||||
#expect(!command.contains("/tmp/custom-cli"))
|
||||
}
|
||||
|
||||
@Test func shellEscapeHandlesQuotesAndParens() {
|
||||
let text = "Debug test works (and a funny pun)"
|
||||
let escaped = VoiceWakeForwarder.shellEscape(text)
|
||||
@@ -82,4 +34,13 @@ import Testing
|
||||
#expect(prefixed.contains("My-Mac"))
|
||||
#expect(prefixed.hasSuffix("\n\nhello world"))
|
||||
}
|
||||
|
||||
@Test func parsesCommandTemplateOverrides() {
|
||||
let opts = VoiceWakeForwarder._testParseCommandTemplate(
|
||||
"clawdis-mac agent --session alt --thinking high --no-deliver --to +123 --message \"${text}\"")
|
||||
#expect(opts.session == "alt")
|
||||
#expect(opts.thinking == "high")
|
||||
#expect(opts.deliver == false)
|
||||
#expect(opts.to == "+123")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user