mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 22:48:16 +00:00
core: simplify question tool output formatting
This commit is contained in:
@@ -15,18 +15,12 @@ export const QuestionTool = Tool.define("question", {
|
||||
tool: ctx.callID ? { messageID: ctx.messageID, callID: ctx.callID } : undefined,
|
||||
})
|
||||
|
||||
function format(q: Question.Info, answer: Question.Answer | undefined) {
|
||||
function format(answer: Question.Answer | undefined) {
|
||||
if (!answer?.length) return "Unanswered"
|
||||
return answer
|
||||
.map((label) => {
|
||||
const opt = q.options.find((x) => x.label === label)
|
||||
if (!opt) return label
|
||||
return `${opt.label} - ${opt.description}`
|
||||
})
|
||||
.join(", ")
|
||||
return answer.join(", ")
|
||||
}
|
||||
|
||||
const formatted = params.questions.map((q, i) => `"${q.question}"="${format(q, answers[i])}"`).join(", ")
|
||||
const formatted = params.questions.map((q, i) => `"${q.question}"="${format(answers[i])}"`).join(", ")
|
||||
|
||||
return {
|
||||
title: `Asked ${params.questions.length} question${params.questions.length > 1 ? "s" : ""}`,
|
||||
|
||||
Reference in New Issue
Block a user