feat(mcp): add package-backed ast-grep MCP

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-18 21:19:15 +09:00
parent 4ea29e2c94
commit 499aff011a
19 changed files with 1372 additions and 0 deletions
@@ -0,0 +1,28 @@
type SpawnedProcess = {
stdout: ReadableStream | null
stderr: ReadableStream | null
exited: Promise<number>
kill: () => void
}
export async function collectProcessOutputWithTimeout(
process: SpawnedProcess,
timeoutMs: number
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
const timeoutPromise = new Promise<never>((_, reject) => {
const timeoutId = setTimeout(() => {
process.kill()
reject(new Error(`Search timeout after ${timeoutMs}ms`))
}, timeoutMs)
process.exited.then(() => clearTimeout(timeoutId))
})
const stdoutPromise = process.stdout ? new Response(process.stdout).text() : Promise.resolve("")
const stderrPromise = process.stderr ? new Response(process.stderr).text() : Promise.resolve("")
const stdout = await Promise.race([stdoutPromise, timeoutPromise])
const stderr = await stderrPromise
const exitCode = await process.exited
return { stdout, stderr, exitCode }
}