Remove opencode package + vm acp command (dead code)
The `internal/opencode` package and the `opencodeCapability` that
consumed it were hard-wired to wait for opencode on guest port 4096
when an image shipped an initrd. After the prune commits (void /
alpine / customize.sh / image build all removed), nothing banger
produces today carries an initrd, so the capability's wait path was
unreachable: every startup short-circuited to the "direct-boot, skip
opencode" branch.
Same logic for `banger vm acp`: it SSHes to `opencode acp --cwd
<path>`, a binary the golden image no longer ships. Users who run
their own image with opencode can still invoke
`ssh vm -- opencode acp --cwd /root/repo` directly — no banger
scaffolding required.
Removed:
- internal/opencode/ (whole package, 255 LOC incl. tests)
- internal/daemon/opencode.go (opencodeCapability)
- cli `vm acp` command + its helpers (runVMACP, sshACPCommandArgs,
vmACPRemoteCommand) + their tests
- The opencodeCapability{} entry in registeredCapabilities() plus
the test that pinned its presence
- `wait_opencode` progress-stage label from the vm-create renderer
- Stale mentions in daemon/doc.go, README, and webui test fixtures
~480 lines gone, 12 added. `banger/internal` is now 25 packages
instead of 26.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0933deaeb1
commit
b5c13e3938
10 changed files with 12 additions and 482 deletions
|
|
@ -736,7 +736,6 @@ func newVMCommand() *cobra.Command {
|
|||
newVMActionCommand("delete", "Delete a VM", "vm.delete"),
|
||||
newVMSetCommand(),
|
||||
newVMSSHCommand(),
|
||||
newVMACPCommand(),
|
||||
newVMWorkspaceCommand(),
|
||||
newVMSessionCommand(),
|
||||
newVMLogsCommand(),
|
||||
|
|
@ -1140,27 +1139,6 @@ func newVMSSHCommand() *cobra.Command {
|
|||
}
|
||||
}
|
||||
|
||||
func newVMACPCommand() *cobra.Command {
|
||||
var cwd string
|
||||
cmd := &cobra.Command{
|
||||
Use: "acp <id-or-name>",
|
||||
Short: "Bridge local stdio to guest opencode acp over SSH",
|
||||
Args: exactArgsUsage(1, "usage: banger vm acp [--cwd PATH] <id-or-name>"),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
layout, cfg, err := ensureDaemon(cmd.Context())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateSSHPrereqs(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
return runVMACP(cmd.Context(), layout.SocketPath, cfg, cmd.InOrStdin(), cmd.OutOrStdout(), cmd.ErrOrStderr(), args[0], cwd)
|
||||
},
|
||||
}
|
||||
cmd.Flags().StringVar(&cwd, "cwd", "", "guest working directory for opencode acp")
|
||||
return cmd
|
||||
}
|
||||
|
||||
func newVMWorkspaceCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "workspace",
|
||||
|
|
@ -2497,18 +2475,6 @@ func runSSHSession(ctx context.Context, socketPath, vmRef string, stdin io.Reade
|
|||
return sshErr
|
||||
}
|
||||
|
||||
func runVMACP(ctx context.Context, socketPath string, cfg model.DaemonConfig, stdin io.Reader, stdout, stderr io.Writer, idOrName, cwd string) error {
|
||||
result, err := vmSSHFunc(ctx, socketPath, idOrName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sshArgs, err := sshACPCommandArgs(cfg, result.GuestIP, vmACPRemoteCommand(cwd))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return sshExecFunc(ctx, stdin, stdout, stderr, sshArgs)
|
||||
}
|
||||
|
||||
func shouldCheckSSHReminder(err error) bool {
|
||||
if err == nil {
|
||||
return true
|
||||
|
|
@ -2544,30 +2510,6 @@ func sshCommandArgs(cfg model.DaemonConfig, guestIP string, extra []string) ([]s
|
|||
return args, nil
|
||||
}
|
||||
|
||||
func sshACPCommandArgs(cfg model.DaemonConfig, guestIP, remoteCommand string) ([]string, error) {
|
||||
if guestIP == "" {
|
||||
return nil, errors.New("vm has no guest IP")
|
||||
}
|
||||
args := []string{"-T", "-F", "/dev/null"}
|
||||
if cfg.SSHKeyPath != "" {
|
||||
args = append(args, "-i", cfg.SSHKeyPath)
|
||||
}
|
||||
args = append(
|
||||
args,
|
||||
"-o", "IdentitiesOnly=yes",
|
||||
"-o", "BatchMode=yes",
|
||||
"-o", "PreferredAuthentications=publickey",
|
||||
"-o", "PasswordAuthentication=no",
|
||||
"-o", "KbdInteractiveAuthentication=no",
|
||||
"-o", "StrictHostKeyChecking=no",
|
||||
"-o", "UserKnownHostsFile=/dev/null",
|
||||
"-o", "LogLevel=ERROR",
|
||||
"root@"+guestIP,
|
||||
"bash", "-lc", remoteCommand,
|
||||
)
|
||||
return args, nil
|
||||
}
|
||||
|
||||
func validateSSHPrereqs(cfg model.DaemonConfig) error {
|
||||
checks := system.NewPreflight()
|
||||
checks.RequireCommand("ssh", "install openssh-client")
|
||||
|
|
@ -3175,24 +3117,6 @@ func printVMRunWarning(out io.Writer, detail string) {
|
|||
_, _ = fmt.Fprintln(out, "[vm run] warning: "+detail)
|
||||
}
|
||||
|
||||
func vmACPRemoteCommand(cwd string) string {
|
||||
var script strings.Builder
|
||||
script.WriteString("set -euo pipefail\n")
|
||||
if strings.TrimSpace(cwd) != "" {
|
||||
fmt.Fprintf(&script, "DIR=%s\n", shellQuote(cwd))
|
||||
} else {
|
||||
fmt.Fprintf(&script, "REPO_DIR=%s\n", shellQuote(vmRunGuestDir()))
|
||||
fmt.Fprintf(&script, "DEFAULT_DIR=%s\n", shellQuote("/root"))
|
||||
script.WriteString(`if [ -d "$REPO_DIR" ]; then DIR="$REPO_DIR"; else DIR="$DEFAULT_DIR"; fi
|
||||
`)
|
||||
}
|
||||
script.WriteString(`cd "$DIR"
|
||||
`)
|
||||
script.WriteString(`exec opencode acp --cwd "$DIR"
|
||||
`)
|
||||
return script.String()
|
||||
}
|
||||
|
||||
func shellQuote(value string) string {
|
||||
return "'" + strings.ReplaceAll(value, "'", `'"'"'`) + "'"
|
||||
}
|
||||
|
|
@ -3530,8 +3454,6 @@ func vmCreateStageLabel(stage string) string {
|
|||
return "waiting for vsock agent"
|
||||
case "wait_guest_ready":
|
||||
return "waiting for guest services"
|
||||
case "wait_opencode":
|
||||
return "waiting for opencode"
|
||||
case "apply_dns":
|
||||
return "publishing dns"
|
||||
case "apply_nat":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue