From 9353effde7dc5066e62524572adbc106a6d4476a Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:23:04 +0500 Subject: [PATCH 1/3] feat(cli): scaffold CLI argument parser and options handling --- src/cli.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/cli.ts diff --git a/src/cli.ts b/src/cli.ts new file mode 100644 index 0000000..8207022 --- /dev/null +++ b/src/cli.ts @@ -0,0 +1,35 @@ +import * as fs from 'node:fs'; +import * as path from 'node:path'; +import { ProofCodeEngine } from './engine/proofCodeEngine'; +import { ReportFormatter } from './engine/reportFormatter'; +import { ProjectRulesEngine } from './rules/projectRulesEngine'; + +async function runCli(): Promise { + const args = process.argv.slice(2); + const cwd = process.cwd(); + + const isHelp = args.includes('--help') || args.includes('-h'); + const isJson = args.includes('--json'); + const isMarkdown = args.includes('--markdown') || args.includes('-m'); + const isStaged = args.includes('--staged'); + const isLive = args.includes('--live'); + const command = args[0] && !args[0].startsWith('-') ? args[0] : 'verify'; + + if (isHelp) { + console.log(` +ProofCode CLI - Code Change Verification +AI writes code. ProofCode proves the change. + +Usage: + proofcode [command] [options] + +Commands: + verify Verify working tree or git diff (default) + init Initialize default .proofcode/rules.md in project + rules List and check configured project rules + +Options: + --staged Verify only staged git changes + --live Run full live test and build checks (npm test, tsc, etc.) + --json Output report as structured JSON + --markdown Output report as formatted GitHub Markdown From ad6cd6961e3f72e6bc7c439d2746493dd9b209f3 Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:23:04 +0500 Subject: [PATCH 2/3] feat(cli): integrate ProofCodeEngine and report formatters --- src/cli.ts | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/cli.ts b/src/cli.ts index 8207022..09c7b50 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -33,3 +33,44 @@ Options: --live Run full live test and build checks (npm test, tsc, etc.) --json Output report as structured JSON --markdown Output report as formatted GitHub Markdown + --help, -h Show this help message +`); + process.exit(0); + } + + if (command === 'init') { + const rulesEngine = new ProjectRulesEngine(cwd); + const created = await rulesEngine.initDefaultRulesFile(); + console.log(`Initialized ProofCode rules at: ${created}`); + process.exit(0); + } + + if (command === 'rules') { + const rulesEngine = new ProjectRulesEngine(cwd); + const rules = rulesEngine.parseRules(); + console.log(`\nConfigured Rules (${rules.length}):`); + rules.forEach((r, idx) => { + console.log(` ${idx + 1}. [${r.severity}] ${r.title}: ${r.description}`); + }); + console.log(''); + process.exit(0); + } + + // Default: Verify + try { + const engine = new ProofCodeEngine(cwd); + const report = await engine.verify({ + staged: isStaged, + runLiveTests: isLive + }); + + if (isJson) { + console.log(ReportFormatter.toJson(report)); + } else if (isMarkdown) { + console.log(ReportFormatter.toMarkdown(report)); + } else { + console.log(ReportFormatter.toTerminal(report)); + } + + // Write artifact report if .proofcode dir exists + const proofcodeDir = path.join(cwd, '.proofcode'); From a428757efbbf3f47b4483905f6ca3e4e4b9fbd5b Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:23:04 +0500 Subject: [PATCH 3/3] feat(cli): implement CI exit codes and report export flag --- src/cli.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/cli.ts b/src/cli.ts index 09c7b50..e3f8a8d 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -74,3 +74,29 @@ Options: // Write artifact report if .proofcode dir exists const proofcodeDir = path.join(cwd, '.proofcode'); + if (fs.existsSync(proofcodeDir)) { + fs.writeFileSync( + path.join(proofcodeDir, 'report.md'), + ReportFormatter.toMarkdown(report), + 'utf8' + ); + fs.writeFileSync( + path.join(proofcodeDir, 'report.json'), + ReportFormatter.toJson(report), + 'utf8' + ); + } + + // Exit code: 0 if ready or needs review, 1 if blocked + if (report.verdict === 'BLOCKED') { + process.exit(1); + } else { + process.exit(0); + } + } catch (err: unknown) { + console.error(`Verification failed: ${(err as Error).message}`); + process.exit(1); + } +} + +runCli();