非纯格式的改动: - logger:info 级日志原先走 console.log(no-console 禁止),改为通过 VS Code LogOutputChannel(Output 面板 "Superpowers")输出 info/warn/error,并在 activate 时注册 dispose - esbuild.mjs:顶层 await 收进 async main(),失败时退出码 1;构建脚本打印 进度属正当输出,文件级关闭 no-console 并注明原因 - KanbanPanel 资源路径正则:去掉 `\.\/[^"]+` 分支(已被 `[^"/][^"]*` 完全 覆盖),匹配结果不变 - webhook/server:onError/onListening 互相引用,改为函数声明消除先用后定义 - SettingsModal:删掉针对未启用规则 react-hooks/exhaustive-deps 的失效 disable 注释,effect 依赖 [open] 保持不变(按打开时机重置表单是有意的) - issues.ts 提示词里两处全角空格换成普通空格 - 其余为 node:process / node:buffer 显式导入与 switch 拆行 Claude-Session: https://claude.ai/code/session_01HTMgwaE3woqM5yvsHiuSAa
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { existsSync } from 'node:fs'
|
|
import * as os from 'node:os'
|
|
import * as path from 'node:path'
|
|
import process from 'node:process'
|
|
|
|
/**
|
|
* 解析 claude 可执行文件绝对路径;找不到返回 null。
|
|
*
|
|
* 顺序:env.PATH 各目录下的 claude → 官方/常见绝对路径候选。
|
|
* GUI 启动的 VS Code 常缺 ~/.local/bin,不能只靠 spawn('claude')。
|
|
*/
|
|
export function resolveClaudeBin(
|
|
env: NodeJS.ProcessEnv = process.env,
|
|
homeDir?: string,
|
|
): string | null {
|
|
const home = homeDir ?? env.HOME ?? os.homedir()
|
|
|
|
for (const dir of (env.PATH ?? '').split(path.delimiter)) {
|
|
if (!dir)
|
|
continue
|
|
const candidate = path.join(dir, 'claude')
|
|
if (existsSync(candidate))
|
|
return candidate
|
|
}
|
|
|
|
const fallbacks = [
|
|
path.join(home, '.local', 'bin', 'claude'),
|
|
'/usr/local/bin/claude',
|
|
'/usr/bin/claude',
|
|
path.join(home, '.claude', 'local', 'claude'),
|
|
]
|
|
for (const candidate of fallbacks) {
|
|
if (existsSync(candidate))
|
|
return candidate
|
|
}
|
|
return null
|
|
}
|