Skip to content

Kickstart enhancements#2144

Open
bosesuneha wants to merge 4 commits into
Azure:kickstartfrom
bosesuneha:kickstart-enhancements
Open

Kickstart enhancements#2144
bosesuneha wants to merge 4 commits into
Azure:kickstartfrom
bosesuneha:kickstart-enhancements

Conversation

@bosesuneha
Copy link
Copy Markdown
Member

fix(kickstart): correct run_in_terminal tool invocation — was calling "runInTerminal" with {command, cwd}; the real tool is "run_in_terminal" with {command, explanation, goal, mode} (no cwd). Probe vscode.lm.tools first and prepend cd && to the command.

feat(kickstart): clone sample repos into existing workspace folder — in vscode.dev / Cloud Shell, samples must land on the Cloud-Shell-backed folder, not os.tmpdir(). useSample() now takes an optional parentPath and the command passes the open workspace folder when one exists.

feat(kickstart): support monorepos with per-module Dockerfile and k8s manifests

Stage per-module at /Dockerfile and /k8s/ via a new moduleStagePrefix() helper; single-module projects keep the flat layout.
ExistingFilesCheckResult.dockerfilePaths: string[] (was a single path); AnalysisData carries existing Dockerfile / manifest paths.
Build phase: one target per Dockerfile with sanitized image names, workspace as build context, --file for staged Dockerfiles, --subscription on az acr calls.
Deploy phase: collects every /k8s/ dir and applies them all with multiple -f flags in one kubectl apply.
Generic buildNestedFileTree() for chat file-tree rendering of nested paths.
Resolve modulePath to absolute before SDK calls. Tests updated.
feat(kickstart): enhance existing Dockerfiles and k8s manifests instead of overwriting

prepare.ts reads existing files into Map<modulePath, …> via longest-prefix match (pickModuleForRelDir) so each module only sees its own.
Streams a "🔄 Enhancing N existing …" message when applicable.
System prompts gain an ENHANCEMENT MODE section: preserve base image family, custom RUN/COPY/ENV, metadata, env vars, volumes, probes; improve only missing best practices (multi-stage, non-root, HEALTHCHECK, securityContext, resources, image refs); return the COMPLETE artifact, not a diff.
buildDockerfileUserPrompt / buildK8sManifestUserPrompt accept the existing artifacts and append them as guidance.

The kickstart terminal helper was invoking the language model tool as
"runInTerminal" with a {command, cwd} payload, but the actual tool
registered by the Copilot extension is "run_in_terminal" and accepts
{command, explanation, goal, mode} (no cwd parameter).

- Use the correct tool name.
- Probe vscode.lm.tools first and surface a clear message when the tool
  is unavailable (e.g. when Kickstart is run outside agent mode).
- Prepend a `cd <cwd> && ...` to the command since the tool runs in the
  current shell cwd.
When Kickstart runs in vscode.dev / Azure Portal Cloud Shell, the
workspace already has a Cloud-Shell-backed folder (azure-XXX). Cloning
samples into the OS temp dir was placing them on the wrong filesystem,
so subsequent operations couldn't see the cloned files.

- useSample() now accepts an optional parentPath, defaulting to the
  previous temp root for backward compatibility.
- registerKickstartCommands.useSample passes the first open workspace
  folder as the clone parent when one exists. Falls back to the temp
  root and adds the clone as a workspace folder so the chat handler
  can still pick up pendingSamplePath.
… manifests

Previously Kickstart assumed a single root `Dockerfile` and a single
`k8s/` folder, so monorepos with multiple modules would have each
module overwrite the previous one's staged files, and only the last
module's image would be built.

Staging:
- Add `moduleStagePrefix(module, projectPath)` helper.
- Stage per-module artifacts at `<moduleRel>/Dockerfile` and
  `<moduleRel>/k8s/<file>` (forward-slash, workspace-relative).
- Single-module / root-module projects keep the previous flat layout.

File detection:
- ExistingFilesCheckResult exposes `dockerfilePaths: string[]` (was a
  single `dockerfilePath`); analyze surfaces all detected Dockerfiles.
- AnalysisData carries `existingDockerfilePaths` /
  `existingK8sManifestPaths` for downstream phases.
- prepare.ts adds `isDockerfileFilename`, `isManifestFilename`,
  `manifestBaseFilename` to handle both flat and prefixed names.

Build phase:
- Iterates one build target per Dockerfile, sanitizing image names with
  a module-derived suffix.
- Always uses the workspace as build context so Dockerfiles can
  reference source files there; passes `--file` for staged Dockerfiles.
- Adds `--subscription` to az acr commands for correctness when the
  CLI is logged into a different default subscription.

Deploy phase:
- Collects every `<module>/k8s/` directory from staged files and
  applies them all with multiple `-f` flags in a single kubectl call.

Chat rendering:
- Replace the hardcoded flat/k8s file tree with a generic
  `buildNestedFileTree()` (used in orchestrator and prepare) so nested
  module paths render correctly.

SDK call:
- Resolve `modulePath` to an absolute path before passing to the
  containerization SDK to avoid path-resolution ambiguity.

Tests updated for the renamed `dockerfilePaths` field.
…ad of overwriting

When a workspace already contains a Dockerfile or Kubernetes manifests,
Kickstart now reads them and asks the language model to preserve the
user's existing structure (base image family, build stages, custom
RUN/COPY/ENV, metadata, env vars, volumes, probes, etc.) while only
improving missing best-practice bits (multi-stage builds, non-root user,
HEALTHCHECK, securityContext, resources, image references, etc.).

Plumbing:
- New `DockerfileEnhancementInput` and `ExistingManifestInput` types
  carried from prepare.ts into the dockerfile/manifests steps.
- prepare.ts reads existing files via Map<modulePath, …> using a longest-
  prefix module match (`pickModuleForRelDir`) so each module's
  enhancement only sees its own existing files in monorepos.
- A user-visible "Enhancing N existing Dockerfile(s) / manifest(s)"
  message is streamed when applicable.

Prompts:
- DOCKERFILE_SYSTEM_PROMPT and K8S_MANIFEST_SYSTEM_PROMPT each gain an
  ENHANCEMENT MODE section telling the model what to preserve vs.
  improve, and to return the COMPLETE updated artifact (not a diff).
- `buildDockerfileUserPrompt` accepts an optional override and
  `buildK8sManifestUserPrompt` accepts an optional list of existing
  manifests, each appended as guidance to the user prompt.
@bosesuneha bosesuneha changed the base branch from kickstart to main May 14, 2026 00:11
@bosesuneha bosesuneha changed the base branch from main to kickstart May 14, 2026 00:11
@Tatsinnit Tatsinnit requested review from Copilot and davidgamero May 14, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant