refactor(subagent): split extension into modules

This commit is contained in:
2026-05-12 14:15:11 -04:00
parent 4d5584aa8c
commit 4f80b590da
9 changed files with 669 additions and 604 deletions

21
src/session.ts Normal file
View File

@@ -0,0 +1,21 @@
import { createHash } from "node:crypto";
import * as os from "node:os";
import * as path from "node:path";
// Session Path - Persist child sessions as <agent>_<uuid>.jsonl under a cwd hash.
export function getSubagentSessionPath(
cwd: string,
agentName: string,
sessionId: string,
): string {
const cwdHash = createHash("sha256").update(cwd).digest("hex").slice(0, 16);
const safeAgent = agentName.replace(/[^\w.-]+/g, "_");
const safeSessionId = sessionId.replace(/[^\w.-]+/g, "_");
return path.join(
os.homedir(),
".pi",
"subagent-sessions",
cwdHash,
`${safeAgent}_${safeSessionId}.jsonl`,
);
}