MCPcopy Index your code
hub / github.com/anomalyco/opencode / prompt

Function prompt

packages/opencode/src/cli/cmd/run/demo.ts:1141–1193  ·  view source on GitHub ↗
(line: RunPrompt, signal?: AbortSignal)

Source from the content-addressed store, hash-verified

1139 }
1140
1141 const prompt = async (line: RunPrompt, signal?: AbortSignal): Promise<boolean> => {
1142 const text = line.text.trim()
1143 const list = text.split(/\s+/)
1144 const cmd = list[0] || ""
1145
1146 clearSubagent(state.footer)
1147
1148 if (cmd === "/help") {
1149 intro(state)
1150 return true
1151 }
1152
1153 if (cmd === "/permission") {
1154 const kind = permissionKind(list[1])
1155 if (!kind) {
1156 note(state.footer, `Pick a permission kind: ${PERMISSIONS.join(", ")}`)
1157 return true
1158 }
1159
1160 emitPermission(state, kind)
1161 return true
1162 }
1163
1164 if (cmd === "/question") {
1165 const kind = questionKind(list[1])
1166 if (!kind) {
1167 note(state.footer, `Pick a question kind: ${QUESTIONS.join(", ")}`)
1168 return true
1169 }
1170
1171 emitQuestion(state, kind)
1172 return true
1173 }
1174
1175 if (cmd === "/fmt") {
1176 const kind = (list[1] || "").toLowerCase()
1177 const body = list.slice(2).join(" ")
1178 if (!kind) {
1179 note(state.footer, `Pick a kind: ${KINDS.join(", ")}`)
1180 return true
1181 }
1182
1183 const ok = await emitFmt(state, kind, body, signal)
1184 if (ok) {
1185 return true
1186 }
1187
1188 note(state.footer, `Unknown kind "${kind}". Use: ${KINDS.join(", ")}`)
1189 return true
1190 }
1191
1192 return false
1193 }
1194
1195 const permission = (input: PermissionReply): boolean => {
1196 const item = state.perms.get(input.requestID)

Callers 3

RunFooterViewFunction · 0.70
prompt.tsFile · 0.50
SessionContextTabFunction · 0.50

Calls 8

clearSubagentFunction · 0.85
permissionKindFunction · 0.85
emitPermissionFunction · 0.85
questionKindFunction · 0.85
emitQuestionFunction · 0.85
emitFmtFunction · 0.85
introFunction · 0.70
noteFunction · 0.70

Tested by

no test coverage detected