Skip to content

wip: prebaked platform VM#2251

Draft
JanPokorny wants to merge 5 commits intomainfrom
janpokorny/feat-agentstack-cli-prebaked-platform-vm
Draft

wip: prebaked platform VM#2251
JanPokorny wants to merge 5 commits intomainfrom
janpokorny/feat-agentstack-cli-prebaked-platform-vm

Conversation

@JanPokorny
Copy link
Collaborator

@JanPokorny JanPokorny commented Feb 27, 2026

Summary

Linked Issues

Documentation

  • No Docs Needed:

If this PR adds new feature or changes existing. Make sure documentation is adjusted accordingly. If the docs is not needed, please explain why.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to the Agent Stack platform by enabling the use of prebaked VM images for both Lima and WSL environments. This change aims to drastically reduce the initial setup and startup time of the platform by providing images with Microshift, Helm, and other essential components already installed. The agentstack-cli has been updated to leverage these new images, offering options for specifying custom image paths. A new dedicated project has been added to manage the building process of these prebaked VM images.

Highlights

  • Prebaked VM Images Introduced: This pull request introduces the concept of prebaked VM images for Lima (macOS/Linux) and WSL (Windows), aiming to significantly reduce platform startup times by pre-installing essential components like Microshift and Helm.
  • CLI Integration for Custom Images: The agentstack-cli has been updated to support specifying custom prebaked Lima (--lima-image) and WSL (--wsl-image) images via command-line arguments or environment variables, allowing users to leverage their own optimized images.
  • VM Provisioning Logic Refactored: The internal VM provisioning logic in platform.py was refactored to remove the sync_vm_files function and adapt to the use of prebaked images, including new logic for importing WSL images and detecting existing Kubernetes platforms.
  • New Image Building Project: A new project, apps/agentstack-platform-vm, has been added to the repository. This project contains the necessary scripts and configuration to build the prebaked Lima (.qcow2) and WSL (.tar.gz) VM images.
  • Dependency Updates: Several Python dependencies in uv.lock have been updated to their latest versions, including certifi, faker, fastapi, openai, opentelemetry-instrumentation-openai, and pyrefly.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • apps/agentstack-cli/src/agentstack_cli/commands/platform.py
    • Removed the sync_vm_files function.
    • Added lima_image and wsl_image options to the start_cmd function.
    • Modified VM provisioning logic to use specified Lima/WSL images or default cloud images, and to import WSL images if provided.
    • Updated Kubernetes platform detection and initialization to expect a prebaked image.
    • Removed dynamic Helm installation, assuming it is pre-installed.
  • apps/agentstack-cli/uv.lock
    • Updated certifi from 2026.1.4 to 2026.2.25.
    • Updated faker from 40.4.0 to 40.5.1.
    • Updated fastapi from 0.131.0 to 0.133.1.
    • Updated openai from 2.21.0 to 2.24.0.
    • Updated opentelemetry-instrumentation-openai from 0.52.4 to 0.52.5.
    • Updated pyrefly from 0.53.0 to 0.54.0.
  • apps/agentstack-platform-vm/README.md
    • Added a new README file describing the Agent Stack Platform VM Image Builder project.
  • apps/agentstack-platform-vm/build.sh
    • Added a new shell script to build prebaked Lima (.qcow2) and WSL (.tar.gz) VM images.
  • apps/agentstack-platform-vm/common/etc/apt/sources.list.d/cri-o.list
    • Renamed from apps/agentstack-cli/src/agentstack_cli/data/vm/common/etc/apt/sources.list.d/cri-o.list.
  • apps/agentstack-platform-vm/common/etc/apt/sources.list.d/kubernetes.list
    • Renamed from apps/agentstack-cli/src/agentstack_cli/data/vm/common/etc/apt/sources.list.d/kubernetes.list.
  • apps/agentstack-platform-vm/common/etc/containers/registries.conf.d/200-microshift-local.conf
    • Renamed from apps/agentstack-cli/src/agentstack_cli/data/vm/common/etc/containers/registries.conf.d/200-microshift-local.conf.
  • apps/agentstack-platform-vm/common/etc/crio/crio.conf.d/14-microshift-cni.conf
    • Renamed from apps/agentstack-cli/src/agentstack_cli/data/vm/common/etc/crio/crio.conf.d/14-microshift-cni.conf.
  • apps/agentstack-platform-vm/common/etc/microshift/config.yaml
    • Renamed from apps/agentstack-cli/src/agentstack_cli/data/vm/common/etc/microshift/config.yaml.
  • apps/agentstack-platform-vm/common/etc/resolv.conf-override
    • Renamed from apps/agentstack-cli/src/agentstack_cli/data/vm/wsl/etc/resolv.conf-override.
  • apps/agentstack-platform-vm/common/etc/systemd/system/kubectl-port-forward@.service
    • Renamed from apps/agentstack-cli/src/agentstack_cli/data/vm/common/etc/systemd/system/kubectl-port-forward@.service.
  • apps/agentstack-platform-vm/common/etc/wsl.conf
    • Renamed from apps/agentstack-cli/src/agentstack_cli/data/vm/wsl/etc/wsl.conf.
  • apps/agentstack-platform-vm/provision.sh
    • Added a new shell script for provisioning the VM with MicroShift, Helm, and pre-pulling container images.
  • apps/agentstack-platform-vm/tasks.toml
    • Added a new tasks.toml file defining the agentstack-platform-vm:build task.
  • mise.toml
    • Included the new apps/agentstack-platform-vm/tasks.toml in the project configuration.
  • tasks.toml
    • Added agentstack-platform-vm:build as a dependency.
    • Modified the platform start command to pass IMAGE_ARGS for Lima/WSL images.
Activity
  • The pull request is currently marked as a work in progress (wip).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant improvement by adding support for pre-baked platform VM images, aiming to drastically reduce startup times through a new build process and updates to the platform start command. However, it also introduces several critical security vulnerabilities in the platform.py command, including a command injection vulnerability when importing images, multiple path traversal vulnerabilities via the vm_name parameter that could allow overwriting arbitrary files on the host, and the hardcoding of several default credentials and an encryption key. Additionally, there are functional issues such as a potential bug in platform.py where the service enabling logic for k3s incorrectly assumes crio is present, an inconsistency in provision.sh with a hardcoded Helm version instead of using the variable defined in build.sh, and a fragile architecture detection mechanism in tasks.toml. Addressing these security and functional concerns is crucial before merging.

@JanPokorny JanPokorny force-pushed the janpokorny/feat-agentstack-cli-prebaked-platform-vm branch 3 times, most recently from 4dda19f to a759978 Compare March 4, 2026 07:48
@i-am-bee i-am-bee deleted a comment from claude bot Mar 4, 2026
@JanPokorny JanPokorny force-pushed the janpokorny/feat-agentstack-cli-prebaked-platform-vm branch from 6a4fe58 to 38c8088 Compare March 4, 2026 18:44
Signed-off-by: Jan Pokorný <JenomPokorny@gmail.com>
@JanPokorny JanPokorny force-pushed the janpokorny/feat-agentstack-cli-prebaked-platform-vm branch from 98b2961 to c509961 Compare March 5, 2026 13:05
Signed-off-by: Jan Pokorný <JenomPokorny@gmail.com>
Signed-off-by: Jan Pokorný <JenomPokorny@gmail.com>
Comment on lines +8 to +37
name: Build WSL image
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup
with:
install_vm_deps: 'build'
maximize_space: 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install libguestfs-tools
run: |
sudo apt-get update
sudo apt-get install -y libguestfs-tools
sudo chmod +r /boot/vmlinuz-*

- name: Build WSL image
run: mise run microshift-vm:build:wsl
env:
LIBGUESTFS_BACKEND: direct

- name: Upload WSL artifact
uses: actions/upload-artifact@v4
with:
name: microshift-vm-wsl
path: apps/microshift-vm/dist/x86_64/*.wsl
if-no-files-found: error

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 17 hours ago

In general, the fix is to explicitly set permissions at the workflow or job level so that the GITHUB_TOKEN has only the minimal scopes required. When in doubt, start with contents: read at the job (or workflow) level and add more granular write permissions only if the job needs them.

For this specific workflow, the build-wsl job checks out the repository, installs packages, builds a WSL image, and uploads an artifact. None of these steps require write access to repository contents, PRs, or issues. Therefore, adding permissions: contents: read to the build-wsl job is sufficient and should not change existing functionality. Concretely, in .github/workflows/microshift-vm-wsl.yml, add a permissions block under build-wsl: (same indentation as name: and runs-on:) so that the job’s token is restricted to read-only access to repository contents.

Suggested changeset 1
.github/workflows/microshift-vm-wsl.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/microshift-vm-wsl.yml b/.github/workflows/microshift-vm-wsl.yml
--- a/.github/workflows/microshift-vm-wsl.yml
+++ b/.github/workflows/microshift-vm-wsl.yml
@@ -7,6 +7,8 @@
   build-wsl:
     name: Build WSL image
     runs-on: ubuntu-latest
+    permissions:
+      contents: read
     timeout-minutes: 30
     steps:
       - uses: actions/checkout@v4
EOF
@@ -7,6 +7,8 @@
build-wsl:
name: Build WSL image
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
Copilot is powered by AI and may make mistakes. Always verify output.
Signed-off-by: Jan Pokorný <JenomPokorny@gmail.com>
Signed-off-by: Jan Pokorný <JenomPokorny@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant