refactor(utils): extracted process management utilities into dedicated procmgr module

- Extracted process management utilities from coding-agent shell module into dedicated procmgr module in utils package.
- Migrated shell configuration retrieval to SettingsManager class with new getGlobalShellConfig() static method.
- Replaced custom killProcessTree() implementation with new terminate() function supporting graceful shutdown with timeout and AbortSignal.
- Updated ptree.ChildProcess to use generic type parameter for input stream masking and delegated process termination to procmgr.terminate().
- Centralized process management across coding-agent modules to use SettingsManager and procmgr utilities instead of standalone shell functions.
This commit is contained in:
can1357
2026-01-29 15:07:06 +01:00
parent 37d5b69250
commit 48b6bb0986
14 changed files with 262 additions and 218 deletions
@@ -4,8 +4,8 @@
* Provides unified bash execution for AgentSession.executeBash() and direct calls.
*/
import { Exception, ptree } from "@oh-my-pi/pi-utils";
import { SettingsManager } from "../config/settings-manager";
import { OutputSink } from "../session/streaming-output";
import { getShellConfig } from "../utils/shell";
import { getOrCreateSnapshot, getSnapshotSourceCommand } from "../utils/shell-snapshot";
export interface BashExecutorOptions {
@@ -33,7 +33,7 @@ export interface BashResult {
}
export async function executeBash(command: string, options?: BashExecutorOptions): Promise<BashResult> {
const { shell, args, env, prefix } = await getShellConfig();
const { shell, args, env, prefix } = await SettingsManager.getGlobalShellConfig();
// Merge additional env vars if provided
const finalEnv = options?.env ? { ...env, ...options.env } : env;