Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ sourceMapSupport.install();
mark('After sourceMapSupport install');

const main = async () => {
// Parse argv early to check for profiling flag
const parsedArgv = await yargs(hideBin(process.argv))
.options(sharedOptions)
.parse();

// Get config to check for profile setting
const config = getConfig();

// Enable profiling if --profile flag is set or if enabled in config
enableProfiling(Boolean(parsedArgv.profile) || Boolean(config.profile));

mark('Main function start');

dotenv.config();
Expand All @@ -56,9 +45,11 @@ const main = async () => {
const packageInfo = require('../package.json') as PackageJson;
mark('After package.json load');

console.log('packageInfo', packageInfo);

// Set up yargs with the new CLI interface
mark('Before yargs setup');
await yargs(hideBin(process.argv))
const argv = await yargs(hideBin(process.argv))
.scriptName(packageInfo.name!)
.version(packageInfo.version!)
.options(sharedOptions)
Expand All @@ -74,6 +65,13 @@ const main = async () => {
.strict()
.showHelpOnFail(true)
.help().argv;

// Get config to check for profile setting
const config = getConfig();

// Enable profiling if --profile flag is set or if enabled in config
enableProfiling(Boolean(argv.profile) || Boolean(config.profile));
mark('After yargs setup');
};

await main()
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/utils/performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export function enableProfiling(enabled: boolean): void {

/**
* Mark a timing point in the application
* Always collect data, but only report if profiling is enabled
*/
export function mark(label: string): void {
if (!isEnabled) return;
// Always collect timing data regardless of whether profiling is enabled
timings[label] = performance.now() - cliStartTime;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/cli/tests/settings/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('Config', () => {
modelProvider: 'anthropic',
modelName: 'claude-3-7-sonnet-20250219',
ollamaBaseUrl: 'http://localhost:11434/api',
profile: false,
customPrompt: '',
});
expect(fs.existsSync).toHaveBeenCalledWith(mockConfigFile);
Expand Down Expand Up @@ -77,6 +78,7 @@ describe('Config', () => {
modelProvider: 'anthropic',
modelName: 'claude-3-7-sonnet-20250219',
ollamaBaseUrl: 'http://localhost:11434/api',
profile: false,
customPrompt: '',
});
});
Expand Down