MCPcopy Index your code
hub / github.com/tiann/hapi / opencodeLocal

Function opencodeLocal

cli/src/opencode/opencodeLocal.ts:4–33  ·  view source on GitHub ↗
(opts: {
    path: string;
    abort: AbortSignal;
    env: NodeJS.ProcessEnv;
    sessionId?: string;
})

Source from the content-addressed store, hash-verified

2import { spawnWithTerminalGuard } from '@/utils/spawnWithTerminalGuard';
3
4export async function opencodeLocal(opts: {
5 path: string;
6 abort: AbortSignal;
7 env: NodeJS.ProcessEnv;
8 sessionId?: string;
9}): Promise<void> {
10 const args: string[] = [];
11 if (opts.sessionId) {
12 if (process.platform === 'win32' && /[&|<>^()%!"\r\n]/u.test(opts.sessionId)) {
13 throw new Error('Invalid sessionId');
14 }
15 args.push('--session', opts.sessionId);
16 }
17
18 logger.debug(`[OpencodeLocal] Spawning opencode with args: ${JSON.stringify(args)}`);
19
20 await spawnWithTerminalGuard({
21 command: 'opencode',
22 args,
23 cwd: opts.path,
24 env: opts.env,
25 signal: opts.abort,
26 shell: process.platform === 'win32',
27 logLabel: 'OpencodeLocal',
28 spawnName: 'opencode',
29 installHint: 'OpenCode CLI',
30 includeCause: true,
31 logExit: true
32 });
33}

Callers 1

opencodeLocalLauncherFunction · 0.90

Calls 3

spawnWithTerminalGuardFunction · 0.90
debugMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected