mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14:25:51 +00:00
feat: 支持自托管的 remote-control-server (#214)
* feat: 支持自托管的 remote-control-server (#214) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
39
src/bridge/rcDebugLog.ts
Normal file
39
src/bridge/rcDebugLog.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* File-based debug logger for Remote Control bridge diagnostics.
|
||||
* Writes [RC-DEBUG] lines to ~/.claude/rc-debug.log so they survive
|
||||
* Ink's stdout capture in the REPL / bridge UI.
|
||||
*/
|
||||
import { appendFileSync, mkdirSync, existsSync } from 'node:fs'
|
||||
import { homedir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
|
||||
const LOG_PATH = join(homedir(), '.claude', 'rc-debug.log')
|
||||
|
||||
function ensureLogDir() {
|
||||
const dir = join(homedir(), '.claude')
|
||||
if (!existsSync(dir)) mkdirSync(dir, { recursive: true })
|
||||
}
|
||||
|
||||
let headerWritten = false
|
||||
|
||||
export function rcLog(msg: string): void {
|
||||
try {
|
||||
if (!headerWritten) {
|
||||
ensureLogDir()
|
||||
appendFileSync(LOG_PATH, `\n===== RC-DEBUG session ${new Date().toISOString()} =====\n`)
|
||||
headerWritten = true
|
||||
}
|
||||
const ts = new Date().toISOString().slice(11, 23) // HH:mm:ss.SSS
|
||||
appendFileSync(LOG_PATH, `[${ts}] ${msg}\n`)
|
||||
} catch {
|
||||
// best-effort — never crash the bridge
|
||||
}
|
||||
}
|
||||
|
||||
/** Clear the log file at session start. */
|
||||
export function rcLogClear(): void {
|
||||
try {
|
||||
ensureLogDir()
|
||||
appendFileSync(LOG_PATH, '')
|
||||
} catch {}
|
||||
}
|
||||
Reference in New Issue
Block a user