auto(14b5ea1b9bd9): session end @ 2026-07-29T10:38:01 (+1f)
This commit is contained in:
1 parent
295c3c6a67
commit
af34011680
1 file changed
+8
-5
@@ -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'
|
||||
|
||||
Reference in new issue
Block a user