@@ -15,6 +15,7 @@ function showHelp(): void {
1515 --provider <name> AI provider: claude | openai | ollama (default: claude)
1616 --yes Skip confirmation prompt
1717 --dry-run Show plan without executing
18+ --debug Show system prompt and raw AI response
1819 --help Show this help message` ,
1920 ) ;
2021 p . log . message (
@@ -25,7 +26,9 @@ function showHelp(): void {
2526 json-cli "git add, commit with message 'fix: bug', push"
2627 json-cli "clone https://github.com/user/repo, install deps, run dev"
2728 json-cli "run tests and publish" --provider openai
28- json-cli "run tests" --dry-run` ,
29+ json-cli "run tests" --dry-run
30+ json-cli "run tests" --debug
31+ json-cli "run tests" --debug --dry-run` ,
2932 ) ;
3033 p . outro ( "Docs: https://github.com/ekaone/json-cli" ) ;
3134}
@@ -39,6 +42,7 @@ function parseArgs(): {
3942 provider : ProviderName ;
4043 yes : boolean ;
4144 dryRun : boolean ;
45+ debug : boolean ;
4246} {
4347 const args = process . argv . slice ( 2 ) ;
4448
@@ -54,6 +58,7 @@ function parseArgs(): {
5458
5559 const yes = args . includes ( "--yes" ) ;
5660 const dryRun = args . includes ( "--dry-run" ) ;
61+ const debug = args . includes ( "--debug" ) ;
5762
5863 const prompt = args
5964 . filter (
@@ -67,7 +72,7 @@ function parseArgs(): {
6772 process . exit ( 0 ) ;
6873 }
6974
70- return { prompt, provider, yes, dryRun } ;
75+ return { prompt, provider, yes, dryRun, debug } ;
7176}
7277
7378// ---------------------------------------------------------------------------
@@ -86,10 +91,10 @@ function formatStep(step: Step): string {
8691// Main
8792// ---------------------------------------------------------------------------
8893async function main ( ) {
89- const { prompt, provider : providerName , yes, dryRun } = parseArgs ( ) ;
94+ const { prompt, provider : providerName , yes, dryRun, debug } = parseArgs ( ) ;
9095
9196 p . intro (
92- `json-cli — powered by ${ providerName } ${ dryRun ? " (dry run)" : "" } ` ,
97+ `json-cli — powered by ${ providerName } ${ dryRun ? " (dry run)" : "" } ${ debug ? " (debug)" : "" } ` ,
9398 ) ;
9499
95100 // Step 1: Generate plan
@@ -99,7 +104,7 @@ async function main() {
99104 let plan ;
100105 try {
101106 const provider = resolveProvider ( providerName ) ;
102- plan = await generatePlan ( prompt , provider ) ;
107+ plan = await generatePlan ( prompt , provider , debug ) ;
103108 spinner . stop ( "Plan ready" ) ;
104109 } catch ( err ) {
105110 spinner . stop ( "Failed to generate plan" ) ;
@@ -128,6 +133,7 @@ async function main() {
128133 if ( dryRun ) {
129134 p . outro ( "Dry run complete — no commands were executed." ) ;
130135 setTimeout ( ( ) => process . exit ( 0 ) , 50 ) ;
136+ return ;
131137 }
132138
133139 // Step 5: Confirm — skip if --yes
@@ -136,6 +142,7 @@ async function main() {
136142 if ( p . isCancel ( confirmed ) || ! confirmed ) {
137143 p . cancel ( "Aborted." ) ;
138144 setTimeout ( ( ) => process . exit ( 0 ) , 50 ) ;
145+ return ;
139146 }
140147 } else {
141148 p . log . info ( "Skipping confirmation (--yes)" ) ;
@@ -155,6 +162,7 @@ async function main() {
155162 `❌ Failed at step ${ result . failedStep ?. id } : ${ result . failedStep ?. description } \n${ result . error ?? "" } ` ,
156163 ) ;
157164 setTimeout ( ( ) => process . exit ( 1 ) , 50 ) ;
165+ return ;
158166 }
159167}
160168
0 commit comments