feat: add ci test runner, session routing, bash parser, and test fixtures

- script/run-ci-tests.ts: CI test sharding and isolation logic
- script/run-ci-tests.test.ts: tests for CI test target selection
- src/features/background-agent/session-route.ts: session prompt routing for background agents
- src/hooks/interactive-bash-session/parser.ts: interactive bash output parser
- src/hooks/ralph-loop/completion-promise-detector-test-input.ts: test fixture for completion promise detection
This commit is contained in:
YeonGyu-Kim
2026-05-16 23:51:43 +09:00
parent 166e5de06c
commit 4f9813848a
5 changed files with 511 additions and 0 deletions
@@ -0,0 +1,72 @@
import type { PluginInput } from "@opencode-ai/plugin"
import { promptWithModelSuggestionRetry } from "../../shared"
import { promptAsyncAfterSessionIdle } from "../../shared/prompt-async-gate"
type OpencodeClient = PluginInput["client"]
type PromptAsyncArgs = Parameters<OpencodeClient["session"]["promptAsync"]>[0]
type PromptRetryClient = Parameters<typeof promptWithModelSuggestionRetry>[0]
type PromptRetryArgs = Parameters<typeof promptWithModelSuggestionRetry>[1]
type SessionMessagesArgs = Parameters<OpencodeClient["session"]["messages"]>[0]
export function routeSessionPrompt(args: PromptAsyncArgs, directory: string): PromptAsyncArgs {
return {
...args,
query: { directory },
}
}
function routePromptRetry(args: PromptRetryArgs, directory: string): PromptRetryArgs {
return {
...args,
query: { directory },
}
}
export function promptAsyncInDirectory(
client: OpencodeClient,
args: PromptAsyncArgs,
directory: string,
): Promise<unknown> {
const routedArgs = routeSessionPrompt(args, directory)
const sessionID = routedArgs.path?.id
if (!sessionID) {
return Promise.reject(new Error("session id is required for routed promptAsync"))
}
return promptAsyncAfterSessionIdle({
client,
sessionID,
input: routedArgs,
source: "background-agent-session-route",
settleMs: 0,
}).then((result) => {
if (result.status === "failed") {
throw result.error
}
if (result.status !== "dispatched") {
throw new Error(`promptAsync skipped by gate: ${result.status}`)
}
return result.response
})
}
export function promptWithRetryInDirectory(
client: PromptRetryClient,
args: PromptRetryArgs,
directory: string,
): Promise<void> {
return promptWithModelSuggestionRetry(client, routePromptRetry(args, directory))
}
export function messagesInDirectory(
client: OpencodeClient,
args: SessionMessagesArgs,
directory: string,
): Promise<unknown> {
return client.session.messages({
...args,
query: { directory },
})
}