MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / main

Function main

src/index.tsx:122–204  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

120}
121
122async function main(): Promise<void> {
123 // Override Node's default process title so terminals (iTerm2 "current job
124 // name", VSCode terminal status, etc.) don't append " (node)" next to our
125 // own title. The bundled bin/orbcode.js also does this for the npm case.
126 process.title = "orbcode"
127 const args = process.argv.slice(2)
128
129 if (args.includes("--version") || args.includes("-v")) {
130 console.log(VERSION)
131 return
132 }
133 if (args.includes("--help") || args.includes("-h")) {
134 printHelp()
135 return
136 }
137 if (args[0] === "update") {
138 const force = args.includes("--force") || args.includes("-f")
139 const code = await runUpdate(force)
140 process.exit(code)
141 }
142
143 // `orbcode mcp ...` — manage MCP servers from the command line (add/remove/list).
144 if (args[0] === "mcp") {
145 const code = await runMcpCommand(args.slice(1))
146 process.exit(code)
147 }
148
149 const model = takeFlagValue(args, "model") ?? takeFlagValue(args, "m")
150 if (model) {
151 // loadSettings() treats MATTERAI_MODEL as the highest-precedence override,
152 // so the flag reaches both the TUI and headless mode without plumbing.
153 process.env.MATTERAI_MODEL = model
154 }
155
156 let initialSession: SessionData | undefined
157 const resumeId = takeFlagValue(args, "resume") ?? takeFlagValue(args, "r")
158 if (resumeId) {
159 initialSession = loadSessionById(resumeId)
160 if (!initialSession) {
161 console.error(`Session "${resumeId}" not found.`)
162 process.exit(1)
163 }
164 }
165
166 // `-s` / `--system-prompt` lets the user replace the default prompt
167 // entirely. Accepts values starting with `-` (unlike other flags), so
168 // `orbcode -s '- you are a code reviewer'` works.
169 const systemPromptOverride = takeSystemPrompt(args)
170
171 const printIndex = args.findIndex((a) => a === "-p" || a === "--print")
172 if (printIndex !== -1) {
173 const prompt = args[printIndex + 1]
174 if (!prompt) {
175 console.error("Missing prompt after -p")
176 process.exit(1)
177 }
178 await runHeadless(prompt, args.includes("--yolo"), systemPromptOverride)
179 return

Callers 1

index.tsxFile · 0.70

Calls 9

printHelpFunction · 0.85
runUpdateFunction · 0.85
runMcpCommandFunction · 0.85
takeFlagValueFunction · 0.85
loadSessionByIdFunction · 0.85
takeSystemPromptFunction · 0.85
runHeadlessFunction · 0.85
getUpdateInfoFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected