qs-ask: answer via Claude Code on the subscription, not an API key
No API key and no separate billing: qs-ask now shells out to `claude -p`, which draws on the existing subscription already authenticated on this host. The trade is latency — Claude Code boots a Node process per question, ~6s measured against the raw API's ~1s — so the launcher now races Wikipedia and Claude instead of chaining them. Wikipedia fills the card in under a second and Claude supersedes it on arrival; chaining would have left the card blank for six seconds on every question. Isolation, verified: --safe-mode drops CLAUDE.md, skills, hooks, plugins and MCP while leaving auth working, which matters for correctness and not just speed — the global CLAUDE.md here asks for caveman-mode replies and that would have leaked into answers. --no-session-persistence writes no transcript, and a dedicated empty cwd keeps launcher questions out of any project's history or auto-memory. Confirmed no project namespace, no transcript and no memory write after a run. Not --bare, which looks right and is a trap: its auth is strictly ANTHROPIC_API_KEY, so it cannot use the subscription at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
dbed82bab4
commit
309c54d31b
2 changed files with 72 additions and 64 deletions
|
|
@ -1709,6 +1709,9 @@ in
|
|||
property string answerSource: ""
|
||||
property bool answerDropNext: false
|
||||
property bool askDropNext: false
|
||||
// Claude answered the current query, so the slower-arriving
|
||||
// Wikipedia result must not overwrite it.
|
||||
property bool askWon: false
|
||||
property var answerCache: ({})
|
||||
|
||||
readonly property var answerStop: [
|
||||
|
|
@ -1798,6 +1801,7 @@ in
|
|||
answerTimer.stop();
|
||||
killAnswer();
|
||||
killAsk();
|
||||
askWon = false;
|
||||
answerFact = "";
|
||||
answerLead = "";
|
||||
answerTitle = "";
|
||||
|
|
@ -1817,12 +1821,16 @@ in
|
|||
showAnswer(hit);
|
||||
return;
|
||||
}
|
||||
// Claude first — it answers the questions Wikipedia
|
||||
// can't. Silence from it means "no key, unreachable, or
|
||||
// doesn't know", and Wikipedia takes over.
|
||||
// Both at once. Wikipedia fills the card in well under a
|
||||
// second; Claude takes ~6s through Claude Code and
|
||||
// supersedes it on arrival. Racing them beats chaining:
|
||||
// Claude-then-fallback would leave the card blank for
|
||||
// six seconds on every question.
|
||||
askWon = false;
|
||||
killAsk();
|
||||
askProc.command = [Commands.askFetch, q];
|
||||
askProc.running = true;
|
||||
startWiki();
|
||||
}
|
||||
|
||||
function startWiki() {
|
||||
|
|
@ -1834,10 +1842,8 @@ in
|
|||
function takeAsk(raw) {
|
||||
if (askDropNext) { askDropNext = false; return; }
|
||||
const text = raw.trim();
|
||||
if (text === "") {
|
||||
startWiki();
|
||||
return;
|
||||
}
|
||||
// Nothing to add — whatever Wikipedia found stands.
|
||||
if (text === "") return;
|
||||
const res = {
|
||||
title: "", // no article behind it
|
||||
fact: text.slice(0, 400),
|
||||
|
|
@ -1848,6 +1854,7 @@ in
|
|||
cacheAnswer(res);
|
||||
// Typing may have moved on while the call was out.
|
||||
if (answerQuery !== answerKey(searchInput.text)) return;
|
||||
askWon = true;
|
||||
showAnswer(res);
|
||||
}
|
||||
|
||||
|
|
@ -1972,6 +1979,9 @@ in
|
|||
: "https://en.wikipedia.org/wiki/" + encodeURIComponent(title.replace(/ /g, "_")),
|
||||
source: "Wikipedia"
|
||||
};
|
||||
// Claude already answered this query — don't overwrite
|
||||
// the better answer in the cache or on screen.
|
||||
if (askWon) return;
|
||||
cacheAnswer(res);
|
||||
// Typing may have moved on while curl was out.
|
||||
if (answerQuery !== answerKey(searchInput.text)) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue