@@ -75,7 +75,7 @@ const {
7575 executeTaskPlan
7676} = require ( './lib/task-orchestrator' ) ;
7777const { buildConfigHealthReport : buildConfigHealthReportCore } = require ( './cli/config-health' ) ;
78- const { buildDoctorReport, buildDoctorLegacyPayload } = require ( './cli/doctor-core' ) ;
78+ const { buildDoctorReport, buildDoctorLegacyPayload, renderDoctorMarkdown } = require ( './cli/doctor-core' ) ;
7979const {
8080 createAuthProfileController
8181} = require ( './cli/auth-profiles' ) ;
@@ -6417,23 +6417,42 @@ function cmdStatus() {
64176417
64186418function parseDoctorCommandArgs ( argv = [ ] ) {
64196419 const options = {
6420- json : false ,
6420+ format : 'json' ,
64216421 range : '7d' ,
64226422 targetApp : 'codex' ,
64236423 remote : true ,
64246424 includeInstall : true ,
64256425 includeUsage : true ,
64266426 includeTasks : true ,
6427- includeSkills : true
6427+ includeSkills : true ,
6428+ output : ''
64286429 } ;
64296430 let cursor = 0 ;
64306431 while ( cursor < argv . length ) {
64316432 const token = String ( argv [ cursor ] || '' ) ;
64326433 if ( token === '--json' ) {
6433- options . json = true ;
6434+ options . format = 'json' ;
64346435 cursor += 1 ;
64356436 continue ;
64366437 }
6438+ if ( token === '--format' ) {
6439+ const value = String ( argv [ cursor + 1 ] || '' ) . trim ( ) . toLowerCase ( ) ;
6440+ if ( ! value || value . startsWith ( '--' ) ) {
6441+ throw new Error ( '错误: --format 需要一个值(json/md)' ) ;
6442+ }
6443+ options . format = value === 'md' || value === 'markdown' ? 'md' : 'json' ;
6444+ cursor += 2 ;
6445+ continue ;
6446+ }
6447+ if ( token === '--output' ) {
6448+ const value = String ( argv [ cursor + 1 ] || '' ) . trim ( ) ;
6449+ if ( ! value || value . startsWith ( '--' ) ) {
6450+ throw new Error ( '错误: --output 需要一个值(文件路径)' ) ;
6451+ }
6452+ options . output = value ;
6453+ cursor += 2 ;
6454+ continue ;
6455+ }
64376456 if ( token === '--range' ) {
64386457 const value = String ( argv [ cursor + 1 ] || '' ) . trim ( ) . toLowerCase ( ) ;
64396458 if ( ! value || value . startsWith ( '--' ) ) {
@@ -6478,8 +6497,15 @@ async function cmdDoctor(argv = []) {
64786497 buildTaskOverviewPayload,
64796498 listSkills
64806499 } ) ;
6481- const json = JSON . stringify ( report , null , 2 ) ;
6482- process . stdout . write ( json + '\n' ) ;
6500+ const format = options . format === 'md' ? 'md' : 'json' ;
6501+ const text = format === 'md'
6502+ ? renderDoctorMarkdown ( report )
6503+ : JSON . stringify ( report , null , 2 ) ;
6504+ if ( options . output ) {
6505+ fs . writeFileSync ( options . output , text ) ;
6506+ } else {
6507+ process . stdout . write ( text + '\n' ) ;
6508+ }
64836509 } catch ( e ) {
64846510 console . error ( '错误:' , e && e . message ? e . message : e ) ;
64856511 process . exitCode = 1 ;
@@ -8345,6 +8371,7 @@ function createWebServer({ htmlPath, assetsDir, webDir, host, port, openBrowser
83458371 listSkills
83468372 } ) ;
83478373 result = buildDoctorLegacyPayload ( report ) ;
8374+ result . markdown = renderDoctorMarkdown ( report ) ;
83488375 }
83498376 break ;
83508377 case 'get-agents-file' :
@@ -13134,7 +13161,7 @@ async function main() {
1313413161 console . log ( '\nCodex Mate - Codex 提供商管理工具' ) ;
1313513162 console . log ( '\n用法:' ) ;
1313613163 console . log ( ' codexmate status 显示当前状态' ) ;
13137- console . log ( ' codexmate doctor [--json] 输出诊断报告(JSON) ' ) ;
13164+ console . log ( ' codexmate doctor [--format json|md] [--output <PATH>] 输出诊断报告' ) ;
1313813165 console . log ( ' codexmate setup 交互式配置向导' ) ;
1313913166 console . log ( ' codexmate list 列出所有提供商' ) ;
1314013167 console . log ( ' codexmate models 列出所有模型' ) ;
0 commit comments