import "@johnlindquist/kit"
const query = await arg("Enter your query to send to both AI assistants:")
if (!query.trim()) {
await div(md("No query provided. Exiting..."))
exit()
}
await hide()
const sendQueryToApp = async (appName: string, query: string) => {
try {
await applescript(`
tell application "${appName}"
activate
end tell
`)
await wait(1000)
await keyboard.type(query)
await wait(500)
await keyboard.tap(Key.Enter)
return true
} catch (error) {
console.log(`Failed to send query to ${appName}: ${error.message}`)
return false
}
}
const claudeSuccess = await sendQueryToApp("Claude", query)
await wait(2000)
const chatgptSuccess = await sendQueryToApp("ChatGPT", query)
let results = []
if (claudeSuccess) results.push("✅ Claude")
if (chatgptSuccess) results.push("✅ ChatGPT")
if (!claudeSuccess) results.push("❌ Claude (app not found or failed)")
if (!chatgptSuccess) results.push("❌ ChatGPT (app not found or failed)")
await div(md(`
# Query Results
**Query sent:** "${query}"
**Status:**
${results.map(result => `- ${result}`).join('\n')}
${results.filter(r => r.includes('✅')).length === 0 ?
'\n⚠️ Make sure both Claude and ChatGPT desktop apps are installed and accessible.' :
'\n🎉 Query sent successfully! Check the apps for responses.'}
`))