refactor(tools): narrow optional values

Avoid non-null assertions in tool and doctor code by preserving narrowed locals through each use site.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-05-15 16:31:13 +09:00
parent d92e78c956
commit 0a3d1875f7
5 changed files with 27 additions and 15 deletions
+6 -2
View File
@@ -6,7 +6,11 @@ import type { DependencyInfo } from "../types"
import { spawnWithTimeout } from "../spawn-with-timeout"
import { getCachedBinaryPath } from "../../../hooks/comment-checker/downloader"
async function checkBinaryExists(binary: string): Promise<{ exists: boolean; path: string | null }> {
type BinaryCheck =
| { exists: true; path: string }
| { exists: false; path: null }
async function checkBinaryExists(binary: string): Promise<BinaryCheck> {
try {
const path = Bun.which(binary)
if (path) {
@@ -44,7 +48,7 @@ export async function checkAstGrepCli(): Promise<DependencyInfo> {
}
}
const version = await getBinaryVersion(binary.path!)
const version = await getBinaryVersion(binary.path)
return {
name: "AST-Grep CLI",