feat(shell): add parallel bash shell subsystem auto-started per workspace

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
tao.chen
2026-07-03 16:36:35 +08:00
co-authored by Claude
parent 75e807c154
commit 0ec3efa812
14 changed files with 730 additions and 12 deletions
+18
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strconv"
"strings"
"time"
"gopkg.in/yaml.v3"
@@ -14,6 +15,7 @@ type Config struct {
Server ServerConfig `yaml:"server"`
Workspace WorkspaceConfig `yaml:"workspace"`
Process ProcessConfig `yaml:"process"`
Shell ShellConfig `yaml:"shell"`
File FileConfig `yaml:"file"`
Gin GinConfig `yaml:"gin"`
Log LogConfig `yaml:"log"`
@@ -38,6 +40,12 @@ type ProcessConfig struct {
OpenCodeCommand string `yaml:"opencodeCommand"`
}
// ShellConfig holds interactive shell settings.
type ShellConfig struct {
Command string `yaml:"command"`
Args []string `yaml:"args"`
}
// FileConfig holds file operation limits.
type FileConfig struct {
MaxWriteBytes int64 `yaml:"maxWriteBytes"`
@@ -60,6 +68,7 @@ type rawConfig struct {
Server rawServerConfig `yaml:"server"`
Workspace WorkspaceConfig `yaml:"workspace"`
Process ProcessConfig `yaml:"process"`
Shell ShellConfig `yaml:"shell"`
File FileConfig `yaml:"file"`
Gin GinConfig `yaml:"gin"`
Log LogConfig `yaml:"log"`
@@ -85,6 +94,7 @@ func Default() Config {
},
Workspace: WorkspaceConfig{Root: "./workspaces"},
Process: ProcessConfig{OpenCodeCommand: "opencode"},
Shell: ShellConfig{Command: "bash", Args: []string{"-i"}},
File: FileConfig{MaxWriteBytes: 1 << 20},
Gin: GinConfig{Mode: "release"},
Log: LogConfig{Level: "info", Format: "json"},
@@ -140,6 +150,8 @@ func applyRaw(cfg *Config, raw rawConfig) error {
if raw.Process.OpenCodeCommand != "" {
cfg.Process.OpenCodeCommand = raw.Process.OpenCodeCommand
}
cfg.Shell.Command = raw.Shell.Command
cfg.Shell.Args = raw.Shell.Args
if raw.File.MaxWriteBytes != 0 {
cfg.File.MaxWriteBytes = raw.File.MaxWriteBytes
}
@@ -199,6 +211,12 @@ func applyEnv(cfg *Config) error {
if v := os.Getenv("CODESPACE_OPENCODE_COMMAND"); v != "" {
cfg.Process.OpenCodeCommand = v
}
if v := os.Getenv("CODESPACE_SHELL_COMMAND"); v != "" {
cfg.Shell.Command = v
}
if v := os.Getenv("CODESPACE_SHELL_ARGS"); v != "" {
cfg.Shell.Args = strings.Split(v, ",")
}
if v := os.Getenv("CODESPACE_FILE_MAX_WRITE_BYTES"); v != "" {
n, err := strconv.ParseInt(v, 10, 64)
if err != nil {