Skip to content

feat(cli): Create CLI manager with process lifecycle and output buffering #41

@coderooz

Description

@coderooz

Summary

Create the core CLI command execution manager with process lifecycle management, output buffering, and blocked command safety.

Acceptance Criteria

  • Create \src/domains/cli/cli-manager.js\ with \CLIManager\ class
  • Process registry: Map of processId → ProcessInfo
  • Async command execution via \child_process.spawn\
  • Output buffering (stdout/stderr) capped at 1MB per process
  • Background mode: return immediately, poll output later
  • Foreground mode: wait up to timeout (default 30s)
  • Process signals: SIGTERM, SIGKILL for cleanup
  • Zombie process detection (no output for 60s = failed)
  • Max concurrent processes: configurable (default 10)
  • Blocked command patterns (security):

    • m -rf /,
      m -rf ~, \ ormat, \del /s /q\
    • \shutdown,
      eboot, \halt\
    • Destructive pipe patterns
  • Command confirmation: dangerous commands return { requiresConfirmation: true }\

Class Interface

\\js
class CLIManager {
constructor(config = {}) {}
async runCommand({ command, args, cwd, timeout, background, agent }) {}
getOutput(processId, offset) {}
listProcesses(statusFilter) {}
async killProcess(processId, signal) {}
async cleanup() {}
isCommandBlocked(command, args) {}
}
\\

Related

  • Milestone: v2.7.0 — CLI Command Execution

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions