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

Function createRunDemo

packages/opencode/src/cli/cmd/run/demo.ts:1121–1274  ·  view source on GitHub ↗
(input: Input)

Source from the content-addressed store, hash-verified

1119}
1120
1121export function createRunDemo(input: Input) {
1122 const state: State = {
1123 id: input.sessionID,
1124 thinking: input.thinking,
1125 data: createSessionData(),
1126 footer: input.footer,
1127 limits: input.limits,
1128 msg: 0,
1129 part: 0,
1130 call: 0,
1131 perm: 0,
1132 ask: 0,
1133 perms: new Map(),
1134 asks: new Map(),
1135 }
1136
1137 const start = async (): Promise<void> => {
1138 intro(state)
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) {

Callers 2

runInteractiveRuntimeFunction · 0.90
runQueueFunction · 0.90

Calls 1

createSessionDataFunction · 0.90

Tested by

no test coverage detected