Skip to content

Commit 4bae99b

Browse files
authored
Merge pull request #102 from drivecore/fix/cli-profiling-double-yargs
Fix double yargs initialization in CLI profiling feature
2 parents f7302c1 + 790fe11 commit 4bae99b

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

packages/cli/src/index.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@ sourceMapSupport.install();
2626
mark('After sourceMapSupport install');
2727

2828
const main = async () => {
29-
// Parse argv early to check for profiling flag
30-
const parsedArgv = await yargs(hideBin(process.argv))
31-
.options(sharedOptions)
32-
.parse();
33-
34-
// Get config to check for profile setting
35-
const config = getConfig();
36-
37-
// Enable profiling if --profile flag is set or if enabled in config
38-
enableProfiling(Boolean(parsedArgv.profile) || Boolean(config.profile));
39-
4029
mark('Main function start');
4130

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

48+
console.log('packageInfo', packageInfo);
49+
5950
// Set up yargs with the new CLI interface
6051
mark('Before yargs setup');
61-
await yargs(hideBin(process.argv))
52+
const argv = await yargs(hideBin(process.argv))
6253
.scriptName(packageInfo.name!)
6354
.version(packageInfo.version!)
6455
.options(sharedOptions)
@@ -74,6 +65,13 @@ const main = async () => {
7465
.strict()
7566
.showHelpOnFail(true)
7667
.help().argv;
68+
69+
// Get config to check for profile setting
70+
const config = getConfig();
71+
72+
// Enable profiling if --profile flag is set or if enabled in config
73+
enableProfiling(Boolean(argv.profile) || Boolean(config.profile));
74+
mark('After yargs setup');
7775
};
7876

7977
await main()

packages/cli/src/utils/performance.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ export function enableProfiling(enabled: boolean): void {
1414

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

packages/cli/tests/settings/config.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ describe('Config', () => {
4444
modelProvider: 'anthropic',
4545
modelName: 'claude-3-7-sonnet-20250219',
4646
ollamaBaseUrl: 'http://localhost:11434/api',
47+
profile: false,
4748
customPrompt: '',
4849
});
4950
expect(fs.existsSync).toHaveBeenCalledWith(mockConfigFile);
@@ -77,6 +78,7 @@ describe('Config', () => {
7778
modelProvider: 'anthropic',
7879
modelName: 'claude-3-7-sonnet-20250219',
7980
ollamaBaseUrl: 'http://localhost:11434/api',
81+
profile: false,
8082
customPrompt: '',
8183
});
8284
});

0 commit comments

Comments
 (0)