diff --git a/src/commands/app/context.ts b/src/commands/app/context.ts index 1586d83..5b09bd7 100644 --- a/src/commands/app/context.ts +++ b/src/commands/app/context.ts @@ -43,14 +43,17 @@ interface ContextOpts { summary?: boolean // v0.23+ (webapi hardening): AI 友好摘要模式, 剔除重字段 } -/** 从 src/cli.ts 源码中提取 const VERSION = '...' */ +/** 从 src/program.ts 源码中提取 export const VERSION = '...' (BS-新152 修) */ function readCliVersion(): string { try { const here = dirname(fileURLToPath(import.meta.url)) - // src/commands/app/context.ts → src/cli.ts - const cliPath = resolve(here, '../../cli.ts') - const src = readFileSync(cliPath, 'utf-8') - const m = src.match(/const\s+VERSION\s*=\s*['"]([^'"]+)['"]/) + // src/commands/app/context.ts → src/program.ts + // 历史 bug: 原路径 '../../cli.ts' 是错的 (VERSION 在 program.ts 声明, 不在 cli.ts), + // 导致 readCliVersion() 永远 fallback 'unknown'. + // 修复: 读 program.ts (跟 commander .version(VERSION) 同源). + const progPath = resolve(here, '../../program.ts') + const src = readFileSync(progPath, 'utf-8') + const m = src.match(/export\s+const\s+VERSION\s*=\s*['"]([^'"]+)['"]/) return m?.[1] || 'unknown' } catch { return 'unknown'