Class CodingAgentShell
-
- All Implemented Interfaces:
public final class CodingAgentShellEnhanced shell command execution subsystem for AI coding agents.
Extends AgentShell's basic read-only command support to include full development tooling: compilers, build systems, package managers, version control, scripting runtimes, and more. Designed for use in autonomous coding agents that need to write, build, test, and deploy code.
Commands are validated against a tiered allow-list:
safe — read-only commands always permitted (subset of AgentShell whitelist)
dev — development tools permitted when allowDevTools is true (default)
network — network-accessing tools require explicit opt-in (allowNetwork)
destructive — write/delete operations require explicit opt-in (allowDestructive)
Environment variables can be injected per-session or per-command.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classCodingAgentShell.Companion
-
Field Summary
Fields Modifier and Type Field Description public final static LongMAX_TIMEOUT_SECONDSpublic final static IntegerMAX_OUTPUT_CHARSprivate final PathcanonicalWorkspaceDirpublic final static CodingAgentShell.CompanionCompanion
-
Method Summary
Modifier and Type Method Description final PathgetCanonicalWorkspaceDir()Canonical workspace directory used as the default command working directory. final Stringexecute(String command, Long timeoutSeconds, String workingDir, Map<String, String> env)Execute a command with full development tool support. final ShellResultexecuteRaw(String command, Long timeoutSeconds, String workingDir, Map<String, String> env)Execute a command and return the raw ShellResult. final StringreadOutput(String sessionId)final StringgetStatus(String sessionId)final StringlistSessions()final UnitsetEnv(String name, String value)Set a persistent environment variable for all subsequent commands in this session. final UnitunsetEnv(String name)Remove a persistent environment variable. final Map<String, String>getEnv()Get all session environment variables. final UnitallowCommand(String name)Allow a specific command by its base name (e.g. final UnitdenyCommand(String name)Deny a specific command by its base name (e.g. final UnitresetCommand(String name)Remove a command from both the allow and deny lists, reverting to the default category-based policy. final UnitallowPattern(Regex pattern)Allow commands matching a regex pattern. final UnitdenyPattern(Regex pattern)Deny commands matching a regex pattern. final Stringexplain(String command)Show the current effective policy for a command — why it's allowed or denied. final BooleanisAllowed(String command)Check whether a command would be allowed without actually executing it. final Stringgit(String args, Long timeoutSeconds)Execute a git command in the workspace. final BooleanisAvailable(String command)Check if a command/program is available. final Set<String>detectAvailableTools()List available development tools detected on PATH. final StringdetectProjectType()Detect the project type in the workspace by looking for build files. -
-
Method Detail
-
getCanonicalWorkspaceDir
final Path getCanonicalWorkspaceDir()
Canonical workspace directory used as the default command working directory.
-
execute
final String execute(String command, Long timeoutSeconds, String workingDir, Map<String, String> env)
Execute a command with full development tool support.
- Parameters:
command- The command to executetimeoutSeconds- Timeout in seconds (default: 120, max: 600)workingDir- Working directory override (absolute, or relative to baseDir)env- Additional environment variables for this command- Returns:
Formatted execution result string
-
executeRaw
final ShellResult executeRaw(String command, Long timeoutSeconds, String workingDir, Map<String, String> env)
Execute a command and return the raw ShellResult.
-
readOutput
final String readOutput(String sessionId)
-
listSessions
final String listSessions()
-
setEnv
final Unit setEnv(String name, String value)
Set a persistent environment variable for all subsequent commands in this session.
-
allowCommand
final Unit allowCommand(String name)
Allow a specific command by its base name (e.g. "ffmpeg", "pandoc"). This adds the command to a per-instance allow-list that overrides the category check — even if the command is not in any predefined set, it will be permitted.
Example:
shell.allowCommand("ffmpeg") // allow ffmpeg even though it's not in DEV_COMMANDS shell.allowCommand("pandoc") // allow pandoc
-
denyCommand
final Unit denyCommand(String name)
Deny a specific command by its base name (e.g. "git", "curl"). This adds the command to a per-instance deny-list. The deny list takes priority over everything — even SAFE_COMMANDS and explicit allows — so you can lock down a command entirely.
Example:
shell.denyCommand("git") // block git entirely shell.denyCommand("curl") // block curl even if allowNetwork=true
-
resetCommand
final Unit resetCommand(String name)
Remove a command from both the allow and deny lists, reverting to the default category-based policy.
-
allowPattern
final Unit allowPattern(Regex pattern)
Allow commands matching a regex pattern. The full command string (e.g. "pip install requests") is tested against the pattern.
Example:
shell.allowPattern(Regex("pip\\s+install.*")) // allow pip install shell.allowPattern(Regex("npm\\s+run\\s+.*")) // allow npm run <script>
-
denyPattern
final Unit denyPattern(Regex pattern)
Deny commands matching a regex pattern. Deny patterns take priority over allow patterns — if a command matches both, it is denied.
Example:
shell.denyPattern(Regex("git\\s+push.*--force")) // block force push shell.denyPattern(Regex("rm\\s+-rf\\s+/")) // block recursive root delete
-
explain
final String explain(String command)
Show the current effective policy for a command — why it's allowed or denied. Returns a human-readable explanation.
-
isAllowed
final Boolean isAllowed(String command)
Check whether a command would be allowed without actually executing it.
-
isAvailable
final Boolean isAvailable(String command)
Check if a command/program is available.
-
detectAvailableTools
final Set<String> detectAvailableTools()
List available development tools detected on PATH.
-
detectProjectType
final String detectProjectType()
Detect the project type in the workspace by looking for build files.
-
-
-
-