Skip to content

feat: add ask.switch - #3

Merged
pi0 merged 4 commits into
mainfrom
feat/switch
Sep 18, 2026
Merged

pi0 merged 4 commits into
mainfrom
feat/switch

Conversation

@pi0x

@pi0x pi0x commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Adds ask.switch, a companion to ask.if. It takes the same options as ask.choice but resolves straight to the selected label, so you can branch on it directly:

switch (await ask.switch`What kind of issue is ${issue}?`(["bug", "feature", "question"])) {
  case "bug":
    return label(issue, "bug");
  case "feature":
    return triage(issue);
}

Works inside ask(...) and on its own, with tags or plain calls. The request sent is the same as ask.choice; only the answer shape differs. Use ask.choice when you still need confidence or probabilities.

Both ask.choice and ask.switch now also accept an array of labels when no descriptions are needed. ["bug", "other"] is sent as { bug: null, other: null } and the answer keeps the "bug" | "other" type.

Also exported as askSwitch, since switch is a reserved word.

🤖 Generated with AI assistant

@pi0
pi0 marked this pull request as ready for review September 18, 2026 08:54
@pi0
pi0 merged commit d06e23e into main Sep 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants