refactor: replace console.log/warn/error with file-based log() for silent logging

Replace all console output with shared logger to write to
/tmp/oh-my-opencode.log instead of stdout/stderr.

Files changed:
- index.ts: console.warn → log()
- hook-message-injector/injector.ts: console.warn → log()
- lsp/client.ts: console.error → log()
- ast-grep/downloader.ts: console.log/error → log()
- session-recovery/index.ts: console.error → log()
- comment-checker/downloader.ts: console.log/error → log()

CLI tools (install.ts, doctor, etc.) retain console output for UX.
This commit is contained in:
justsisyphus
2026-01-30 12:45:37 +09:00
parent df9004d6f7
commit 493b20394b
6 changed files with 17 additions and 12 deletions
+5 -4
View File
@@ -3,6 +3,7 @@ import { join } from "path"
import { homedir } from "os"
import { createRequire } from "module"
import { extractZip } from "../../shared"
import { log } from "../../shared/logger"
const REPO = "ast-grep/ast-grep"
@@ -63,7 +64,7 @@ export async function downloadAstGrep(version: string = DEFAULT_VERSION): Promis
const platformInfo = PLATFORM_MAP[platformKey]
if (!platformInfo) {
console.error(`[oh-my-opencode] Unsupported platform for ast-grep: ${platformKey}`)
log(`[oh-my-opencode] Unsupported platform for ast-grep: ${platformKey}`)
return null
}
@@ -79,7 +80,7 @@ export async function downloadAstGrep(version: string = DEFAULT_VERSION): Promis
const assetName = `app-${arch}-${os}.zip`
const downloadUrl = `https://github.com/${REPO}/releases/download/${version}/${assetName}`
console.log(`[oh-my-opencode] Downloading ast-grep binary...`)
log(`[oh-my-opencode] Downloading ast-grep binary...`)
try {
if (!existsSync(cacheDir)) {
@@ -106,11 +107,11 @@ export async function downloadAstGrep(version: string = DEFAULT_VERSION): Promis
chmodSync(binaryPath, 0o755)
}
console.log(`[oh-my-opencode] ast-grep binary ready.`)
log(`[oh-my-opencode] ast-grep binary ready.`)
return binaryPath
} catch (err) {
console.error(
log(
`[oh-my-opencode] Failed to download ast-grep: ${err instanceof Error ? err.message : err}`
)
return null
+2 -1
View File
@@ -11,6 +11,7 @@ import {
} from "vscode-jsonrpc/node"
import { getLanguageId } from "./config"
import type { Diagnostic, ResolvedServer } from "./types"
import { log } from "../../shared/logger"
interface ManagedClient {
client: LSPClient
@@ -306,7 +307,7 @@ export class LSPClient {
})
this.connection.onError((error) => {
console.error("LSP connection error:", error)
log("LSP connection error:", error)
})
this.connection.listen()