22 * CLI argument parsing and program setup
33 */
44
5+ import { resolve } from "node:path"
56import { Command } from "commander"
67import { loadConfig } from "./config.ts"
8+ import { initializePaths } from "./fs.ts"
79import { runLoop } from "./loop.ts"
10+ import { formatMetricsSummary , loadMetrics } from "./metrics.ts"
811import type { CliOptions } from "./types.ts"
912
1013const VERSION = "1.0.0"
@@ -39,6 +42,7 @@ function createProgram(): Command {
3942 . option ( "--no-auto-commit" , "Disable automatic commits after tasks" )
4043 . option ( "--no-auto-push" , "Disable automatic push after cycles" )
4144 . option ( "-s, --signoff" , "Add Signed-off-by line to commits" )
45+ . option ( "--status" , "Display metrics summary and exit" )
4246
4347 // Add examples to help
4448 program . addHelpText (
@@ -63,6 +67,12 @@ Examples:
6367 $ opencoder -m anthropic/claude-sonnet-4 -s
6468 Run with commit signoff enabled
6569
70+ $ opencoder --status
71+ Display metrics summary without starting the loop
72+
73+ $ opencoder --status -p ./myproject
74+ Display metrics for a specific project
75+
6676Options:
6777 -p, --project <dir> Project directory (default: current directory)
6878 -m, --model <model> Model for both plan and build
@@ -72,6 +82,7 @@ Options:
7282 --no-auto-commit Disable automatic commits after tasks
7383 --no-auto-push Disable automatic push after cycles
7484 -s, --signoff Add Signed-off-by line to commits
85+ --status Display metrics summary and exit
7586
7687Environment variables:
7788 OPENCODER_PLAN_MODEL Default plan model
@@ -133,6 +144,7 @@ export function parseCli(argv: string[] = process.argv): ParsedCli {
133144 autoCommit : opts . autoCommit as boolean | undefined ,
134145 autoPush : opts . autoPush as boolean | undefined ,
135146 commitSignoff : opts . signoff as boolean | undefined ,
147+ status : opts . status as boolean | undefined ,
136148 } ,
137149 hint : args [ 0 ] ,
138150 }
@@ -169,6 +181,21 @@ export async function run(): Promise<void> {
169181 autoCommit : opts . autoCommit as boolean | undefined ,
170182 autoPush : opts . autoPush as boolean | undefined ,
171183 commitSignoff : opts . signoff as boolean | undefined ,
184+ status : opts . status as boolean | undefined ,
185+ }
186+
187+ // Handle --status flag: display metrics and exit
188+ if ( cliOptions . status ) {
189+ const projectDir = cliOptions . project ? resolve ( cliOptions . project ) : process . cwd ( )
190+ const paths = initializePaths ( projectDir )
191+ const metrics = await loadMetrics ( paths . metricsFile )
192+
193+ console . log ( "\nOpenCoder Metrics" )
194+ console . log ( "=================\n" )
195+ console . log ( formatMetricsSummary ( metrics ) )
196+ console . log ( `\nLast activity: ${ metrics . lastActivityTime } ` )
197+ console . log ( "" )
198+ return
172199 }
173200
174201 const config = await loadConfig ( cliOptions , hint )
0 commit comments