Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157/** File path conventions for spawn result coordination. Both the spawn-claude CLI and the hook handler use these paths to coordinate parent-child session relationships and result forwarding. Directory layout under `~/.claude/spawn-results/`: - `.by-pid/{claude_pid}`: maps Claude process PID to session identity - `spawns/{spawnId}.json`: spawn state for each child session - `spawns/{spawnId}.reported`: renamed after result injection @module */
import { join, } from 'node:path';
/** Environment lookup object accepted by path helpers. */type Environment = Readonly<NodeJS.ProcessEnv>;
/** Resolves root directory for all spawn coordination files. @param env - environment values to inspect @returns spawn coordination root directory @example ```ts spawnResultsDir({ HOME: '/home/me' }); ``` */function spawnResultsDir(env: Environment = process.env,): string { return join( env.HOME ?? '/tmp', '.claude', 'spawn-results', );}
/** Resolves directory for PID-to-session-identity mapping files. @param env - environment values to inspect @returns PID mapping directory path @example ```ts byPidDir({ HOME: '/home/me' }); ``` */function byPidDir(env: Environment = process.env,): string { return join( spawnResultsDir(env,), '.by-pid', );}
/** Resolves directory for spawn state files. @param env - environment values to inspect @returns spawn state directory path @example ```ts spawnsDir({ HOME: '/home/me' }); ``` */function spawnsDir(env: Environment = process.env,): string { return join( spawnResultsDir(env,), 'spawns', );}
/** Root directory for all spawn coordination files. */const SPAWN_RESULTS_DIR: string = spawnResultsDir();
/** Directory for PID-to-session-identity mapping files. Written by SessionStart hook, read by CLI tool. */const BY_PID_DIR: string = byPidDir();
/** Directory for spawn state files. Created by SessionStart hook, updated by Stop and SessionEnd hooks, read and renamed by the inject check. */const SPAWNS_DIR: string = spawnsDir();
/** JSON structure for PID-to-session mapping files in `.by-pid/`. */type PidMapping = { /** Claude Code session identifier from hook event data. */ readonly sessionId: string; /** Absolute path to the session transcript JSONL file. */ readonly transcriptPath: string;};
/** JSON structure for spawn state files in `spawns/`. */type SpawnState = { /** UUID generated by the CLI tool at spawn time. */ readonly spawnId: string; /** Child session's Claude Code session identifier. */ readonly sessionId: string; /** Absolute path to the child's transcript JSONL file. */ readonly transcriptPath: string; /** Parent session's Claude Code session identifier. */ readonly parentSessionId: string; /** Current lifecycle state of the spawned session. */ readonly status: 'running' | 'stopped'; /** Text of the child's most recent assistant response. */ readonly lastMessage: string;};
export { byPidDir, BY_PID_DIR, spawnResultsDir, SPAWN_RESULTS_DIR, spawnsDir, SPAWNS_DIR,};
export type { Environment, PidMapping, SpawnState,};