refactor: wave 1 - extract leaf modules, rename catch-all files, split index.ts hooks
- Split 25+ index.ts files into hook.ts + extracted modules - Rename all catch-all utils.ts/helpers.ts to domain-specific names - Split src/tools/lsp/ into ~15 focused modules - Split src/tools/delegate-task/ into ~18 focused modules - Separate shared types from implementation - 155 files changed, 60+ new files created - All typecheck clean, 61 tests pass
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import type { OpencodeClient } from "./types"
|
||||
|
||||
export async function createSyncSession(
|
||||
client: OpencodeClient,
|
||||
input: { parentSessionID: string; agentToUse: string; description: string; defaultDirectory: string }
|
||||
): Promise<{ ok: true; sessionID: string; parentDirectory: string } | { ok: false; error: string }> {
|
||||
const parentSession = client.session.get
|
||||
? await client.session.get({ path: { id: input.parentSessionID } }).catch(() => null)
|
||||
: null
|
||||
const parentDirectory = parentSession?.data?.directory ?? input.defaultDirectory
|
||||
|
||||
const createResult = await client.session.create({
|
||||
body: {
|
||||
parentID: input.parentSessionID,
|
||||
title: `${input.description} (@${input.agentToUse} subagent)`,
|
||||
permission: [
|
||||
{ permission: "question", action: "deny" as const, pattern: "*" },
|
||||
],
|
||||
} as any,
|
||||
query: {
|
||||
directory: parentDirectory,
|
||||
},
|
||||
})
|
||||
|
||||
if (createResult.error) {
|
||||
return { ok: false, error: `Failed to create session: ${createResult.error}` }
|
||||
}
|
||||
|
||||
return { ok: true, sessionID: createResult.data.id, parentDirectory }
|
||||
}
|
||||
Reference in New Issue
Block a user