MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / main

Function main

compatible-shell/src/cli.mjs:19–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17}
18
19async function main() {
20 const options = parseArgs(process.argv.slice(2))
21 if (options.help) {
22 printHelp()
23 return
24 }
25
26 const initialPrompt = await getInitialPrompt(options)
27 if (initialPrompt) {
28 await runPromptOnce({
29 ...options,
30 prompt: initialPrompt,
31 })
32 return
33 }
34
35 const state = createState(options)
36 const rl = createInterface({
37 input: process.stdin,
38 output: process.stdout,
39 })
40
41 console.log('Compatible shell ready.')
42 console.log(`Workspace: ${state.workspaceDir}`)
43 console.log(`Model endpoint: ${state.clientConfig.baseUrl}`)
44 console.log(`Model: ${state.clientConfig.model}`)
45 console.log(`Session file: ${state.sessionStore.sessionPath}`)
46 console.log('Type /help for commands.')
47
48 while (true) {
49 const line = (await rl.question('compat> ')).trim()
50 if (!line) {
51 continue
52 }
53
54 if (line.startsWith('/')) {
55 const shouldExit = await handleSlashCommand(line, state)
56 if (shouldExit) {
57 break
58 }
59 continue
60 }
61
62 await runUserTurn(line, state, rl)
63 }
64
65 await persistSession(state)
66 rl.close()
67}
68
69function createState(options = {}) {
70 const workspaceDir = path.resolve(

Callers 1

cli.mjsFile · 0.70

Calls 8

printHelpFunction · 0.85
getInitialPromptFunction · 0.85
runPromptOnceFunction · 0.85
createStateFunction · 0.85
handleSlashCommandFunction · 0.85
runUserTurnFunction · 0.85
persistSessionFunction · 0.85
parseArgsFunction · 0.70

Tested by

no test coverage detected