mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
devvm takes no IMAGE word any more than any other: in a terminal a new VM's toolchains, coding agents and layers are checked in one picker, under three headings, before the network-policy question; --tools, --agents and --layers (each an exact list, or none) skip it, and a part left out takes its default: the detected toolchains, devvm setup's agents, no layers (a devcontainer.json's features still count). Without a terminal, or with --no-input, the VM gets the defaults and new_vm_gets says so in one line. devvm setup --agents (and its first-run question) chooses new VMs' agents. devvm tools in a terminal opens the same picker for the VM, its layers fixed, and turns the changes into tools add and rm. An image is base and layers only: tools are the VM's tool_names state key. build, rebuild and images rm refuse a shared tool (tool_not_layer), and devvm build builds no tool images. devvm ls gains a TOOLS column and --json tools. gc's --tools is --tool-images, so --tools has one meaning. Gone: image.Reserved, checkWord's image half (devvm WORD is no_command or no_command_like, did-you-mean over commands, msg.Closest), the lacks path in internal/vm/existing.go, and the messages vm_lacks_tools, vm_lacks_layer, layer_is_command, layer_name_command, no_image_for, no_command_or_image*, tools_not_images, tools_not_images_rm, detected, vm_is_now (vm_tools_now), secret_with_image (secret_with_claude). New: ui.Pick takes headed sections with fixed rows, ui.CanPick, vm.PickPart/PickRow/AgentsChoice/CheckPart (internal/vm/parts.go), state.KeyToolNames, state.ReadAgents/WriteAgents, paths.Dirs.Agents, project.DetectFiles. Image keys are unchanged in form: images never held tools; docker.sh's and nix.sh's comments changed, so those layers rebuild. Docs: the home page's quick start steps, diagram (sandbox.svg), cards and FAQ; README; getting started; using (images' What a new VM gets, coding agents' Running an agent, settings' agents); internals; contributing; the cli skill; AGENTS.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
52 lines
1.8 KiB
Go
52 lines
1.8 KiB
Go
package cli
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/w3cj/devvm/internal/build"
|
|
"github.com/w3cj/devvm/internal/msg"
|
|
"github.com/w3cj/devvm/internal/paths"
|
|
"github.com/w3cj/devvm/internal/ui"
|
|
)
|
|
|
|
// newLayerCmd is devvm layer new NAME.
|
|
func newLayerCmd(u *ui.UI) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "layer",
|
|
Short: "Make image layers of your own",
|
|
Long: "Make image layers of your own, which are scripts in ~/.config/devvm/layers that an image runs on top of base. " +
|
|
"An image names them as it names devvm's built-in layers, bottom first, such as docker+NAME, and a new VM gets them with --layers.",
|
|
Example: examples(
|
|
"devvm layer new mailpit", "start a layer named mailpit",
|
|
),
|
|
Args: noArgs,
|
|
RunE: func(cmd *cobra.Command, _ []string) error { return cmd.Help() },
|
|
}
|
|
cmd.AddCommand(&cobra.Command{
|
|
Use: "new NAME",
|
|
Short: "Start a layer of your own",
|
|
Long: "Start a layer of your own, ~/.config/devvm/layers/NAME.sh, a script to edit, and NAME.policy next to it, " +
|
|
"the hosts that VMs with the layer can reach with network policy. " +
|
|
"NAME is lowercase letters, digits and dashes, and not base or a built-in layer's or shared tool's name.",
|
|
Example: examples(
|
|
"devvm layer new mailpit", "start the mailpit layer, then edit its script",
|
|
"devvm build mailpit", "build its image",
|
|
"devvm --layers mailpit", "create a VM with the layer",
|
|
),
|
|
Args: cobra.MatchAll(exactArgs(1), func(_ *cobra.Command, args []string) error {
|
|
return build.CheckLayerName(args[0])
|
|
}),
|
|
RunE: func(_ *cobra.Command, args []string) error {
|
|
dirs, err := paths.FromEnv()
|
|
var script, policy string
|
|
if err == nil {
|
|
script, policy, err = build.NewLayer(dirs, args[0])
|
|
}
|
|
fail(u, err, msg.LayerNewFailed)
|
|
u.Info(msg.LayerCreated(args[0], policy, script))
|
|
return nil
|
|
},
|
|
})
|
|
return cmd
|
|
}
|