()
| 115 | } |
| 116 | |
| 117 | async function main(): Promise<void> { |
| 118 | const cliBootstrapStartedAt = Date.now(); |
| 119 | const earlyCommand = findTopLevelCommand(process.argv.slice(2)); |
| 120 | if (earlyCommand === 'mcp') { |
| 121 | await startMcpServer(); |
| 122 | return; |
| 123 | } |
| 124 | if (earlyCommand === 'init') { |
| 125 | await runInitCommand(); |
| 126 | return; |
| 127 | } |
| 128 | if (earlyCommand === 'setup') { |
| 129 | await runSetupCommand(); |
| 130 | return; |
| 131 | } |
| 132 | if (earlyCommand === 'upgrade') { |
| 133 | await runUpgradeCommand(); |
| 134 | return; |
| 135 | } |
| 136 | |
| 137 | await hydrateSentryDisabledEnvFromProjectConfig(); |
| 138 | initSentry({ mode: 'cli' }); |
| 139 | |
| 140 | // CLI mode uses disableSessionDefaults to show all tool parameters as flags |
| 141 | const result = await bootstrapRuntime({ |
| 142 | runtime: 'cli', |
| 143 | configOverrides: { |
| 144 | disableSessionDefaults: true, |
| 145 | }, |
| 146 | }); |
| 147 | |
| 148 | const { workspaceRoot, workspaceKey } = result; |
| 149 | |
| 150 | const socketPath = |
| 151 | findGlobalSocketOverride(process.argv.slice(2)) ?? |
| 152 | getSocketPath({ |
| 153 | cwd: result.runtime.cwd, |
| 154 | projectConfigPath: result.configPath, |
| 155 | }); |
| 156 | |
| 157 | const cliExposedWorkflowIds = await listCliWorkflowIdsFromManifest({ |
| 158 | excludeWorkflows: ['session-management', 'workflow-discovery'], |
| 159 | }); |
| 160 | const topLevelCommand = findTopLevelCommand(process.argv.slice(2)); |
| 161 | const discoveryMode = topLevelCommand === 'xcode-ide' ? 'quick' : 'none'; |
| 162 | |
| 163 | // CLI uses a manifest-resolved catalog plus daemon-backed xcode-ide dynamic tools. |
| 164 | const catalog = await buildCliToolCatalog({ |
| 165 | socketPath, |
| 166 | workspaceRoot, |
| 167 | cliExposedWorkflowIds, |
| 168 | discoveryMode, |
| 169 | }); |
| 170 | |
| 171 | const yargsApp = buildYargsApp({ |
| 172 | catalog, |
| 173 | runtimeConfig: result.runtime.config, |
| 174 | defaultSocketPath: socketPath, |
no test coverage detected