Skip to content

foryourhealth111-pixel/Vibe-Skills

Vibe Code Orchestrator (VCO) is a governed runtime entry that freezes requirements, bounds execution, and enforces verification and phase cleanup.

FileKindSize
SKILL.mdskill md17.2 KB
agents/templates/debugger.mdmarkdown323 B
agents/templates/planner.mdmarkdown313 B
agents/templates/reviewer.mdmarkdown331 B
agents/templates/security-reviewer.mdmarkdown341 B
references/change-proof-matrix.mdmarkdown2.6 KB
references/contributor-zone-decision-table.mdmarkdown2.2 KB
references/developer-entry-contract.mdmarkdown2.7 KB
references/fixtures/external-corpus/external-corpus-gate.jsonconfig8.6 KB
references/fixtures/external-corpus/prompt-signals.jsonconfig412.4 KB
references/fixtures/external-corpus/skill-keyword-index.backup.jsonconfig30.6 KB
references/fixtures/external-corpus/skill-keyword-index.candidate.jsonconfig26.5 KB
references/fixtures/external-corpus/vco-suggestions.jsonconfig16.6 KB
references/fixtures/migration-map.jsonconfig7.8 KB
references/fixtures/retro-compare/safety-gate/baseline-cer.jsonconfig294 B
references/fixtures/retro-compare/safety-gate/current-cer.jsonconfig1.1 KB
references/fixtures/retro-compare/safety-gate/delta.jsonconfig1.0 KB
references/fixtures/retro-compare/sample-run/baseline-cer.jsonconfig324 B
references/fixtures/retro-compare/sample-run/current-cer.jsonconfig1.2 KB
references/fixtures/retro-compare/sample-run/delta.jsonconfig1.0 KB
references/fixtures/retro-compare/smoke/baseline-smoke.jsonconfig266 B
references/fixtures/retro-compare/smoke/current-smoke.jsonconfig1.0 KB
references/fixtures/retro-compare/smoke/delta-smoke.jsonconfig1.0 KB
references/fixtures/runtime/vibe-sessions/20260413T131910Z-pr153-rabbit-review-fix/cleanup-receipt.jsonconfig1.3 KB
references/fixtures/runtime/vibe-sessions/20260413T131910Z-pr153-rabbit-review-fix/governance-capsule.jsonconfig408 B
references/fixtures/runtime/vibe-sessions/20260413T131910Z-pr153-rabbit-review-fix/intent-contract.jsonconfig2.2 KB
references/fixtures/runtime/vibe-sessions/20260413T131910Z-pr153-rabbit-review-fix/phase-plan-execute.jsonconfig2.4 KB
references/fixtures/runtime/vibe-sessions/20260413T131910Z-pr153-rabbit-review-fix/skeleton-receipt.jsonconfig722 B
references/fixtures/runtime/vibe-sessions/20260413T131910Z-pr153-rabbit-review-fix/stage-lineage.jsonconfig1.3 KB
references/fixtures/skills-audit/bio-science-problem/bio-science-problem-map.csvother9.2 KB
references/fixtures/skills-audit/bio-science-problem/bio-science-problem-map.jsonconfig18.1 KB
references/fixtures/verify/routing-stability/vibe-routing-stability-gate.jsonconfig24.4 KB
references/index.mdmarkdown1.3 KB
references/proof-bundles/claude-code-managed-closure-candidate/linux-managed-run-01-local-host/installed-runtime-outputs/runtime-freshness-receipt.jsonconfig262 B
references/proof-bundles/claude-code-managed-closure-candidate/manifest.jsonconfig2.6 KB
references/proof-bundles/linux-full-authoritative-candidate/linux-pwsh-run-01-wsl/installed-runtime-outputs/runtime-freshness-receipt.jsonconfig298 B
references/proof-bundles/linux-full-authoritative-candidate/linux-pwsh-run-02-docker/installed-runtime-outputs/runtime-freshness-receipt.jsonconfig298 B
references/proof-bundles/linux-full-authoritative-candidate/manifest.jsonconfig3.3 KB
references/proof-bundles/openclaw-runtime-core-preview-candidate/manifest.jsonconfig1.9 KB
references/release-ledger.jsonlother5.1 KB
scripts/README.mdmarkdown1.7 KB
scripts/bootstrap/one-shot-setup.ps1script797 B
scripts/bootstrap/one-shot-setup.shscript482 B
scripts/bootstrap/scaffold-claude-preview.ps1script875 B
scripts/bootstrap/scaffold-claude-preview.shexecutablescript866 B
scripts/bootstrap/sync-local-compat.ps1script2.6 KB
scripts/common/AntiProxyGoalDrift.ps1script15.1 KB
scripts/common/NodeLaunchWrapper.ps1script13.1 KB
scripts/common/ProcessLedger.ps1script27.1 KB
scripts/common/ProtectedDocumentCleanup.ps1script6.9 KB
scripts/common/README.mdmarkdown1.9 KB
scripts/common/Resolve-VgoAdapter.ps1script4.3 KB
scripts/common/adapter_registry_query.pyexecutablescript3.8 KB
scripts/common/python_helpers.shscript2.8 KB
scripts/common/resolve_vgo_adapter.pyexecutablescript2.4 KB
scripts/common/runtime_contracts.pyscript3.7 KB
scripts/common/vibe-governance-helpers.ps1script75.6 KB
scripts/common/vibe-wave-gate-runner.ps1script28.3 KB
scripts/governance/Invoke-NodeProcessAudit.ps1script3.6 KB
scripts/governance/Invoke-NodeZombieCleanup.ps1script3.7 KB
scripts/governance/README.mdmarkdown5.1 KB
scripts/governance/audit-upstream.ps1script22.7 KB
scripts/governance/export-repo-cleanliness-inventory.ps1script8.6 KB
scripts/governance/install-local-worktree-excludes.ps1script2.0 KB
scripts/governance/invoke-mem0-policy.ps1script1.0 KB
scripts/governance/invoke-openspec-governance.ps1script8.6 KB
scripts/governance/new-origin-record.ps1script3.3 KB
scripts/governance/phase-end-cleanup.ps1script10.7 KB
scripts/governance/publish-absorption-soft-rollout.ps1script3.2 KB
scripts/governance/publish-openspec-soft-rollout.ps1script9.3 KB
scripts/governance/release-cut.ps1script25.1 KB
scripts/governance/set-gsd-overlay-rollout.ps1script3.9 KB
scripts/governance/set-openspec-rollout.ps1script3.1 KB
scripts/governance/sync-bundled-vibe.ps1script20.3 KB
scripts/install/Install-VgoAdapter.ps1script2.0 KB
scripts/install/install_vgo_adapter.pyexecutablescript524 B
scripts/overlay/README.mdmarkdown885 B
scripts/overlay/suggest-browserops-provider.ps1script9.3 KB
scripts/overlay/suggest-overlays.ps1script17.3 KB
scripts/release/build_release_bundle.pyscript6.5 KB
scripts/research/README.mdmarkdown1.1 KB
scripts/research/build-eval-slicing-catalog.ps1script2.6 KB
scripts/research/build-watch-portfolio-review.ps1script3.5 KB
scripts/research/build-xl-operator-checklist.ps1script2.3 KB
scripts/research/extract-prompt-signals.ps1script6.7 KB
scripts/research/generate-vco-suggestions.ps1script9.7 KB
scripts/research/sync-mcp-catalog.ps1script3.5 KB
scripts/research/vibe-adaptive-train.ps1script10.1 KB
scripts/router/README.mdmarkdown1.8 KB
scripts/router/invoke-pack-route.pyscript428 B
scripts/router/modules/00-core-utils.ps1script14.6 KB
scripts/router/modules/01-openai-responses.ps1script17.9 KB
scripts/router/modules/10-observability.ps1script11.7 KB
scripts/router/modules/11-route-probe.ps1script20.7 KB
scripts/router/modules/12-heartbeat.ps1script19.9 KB
scripts/router/modules/19-custom-admission.ps1script16.3 KB
scripts/router/modules/20-routing-rules.ps1script1.7 KB
scripts/router/modules/21-capability-interview.ps1script11.8 KB
scripts/router/modules/22-intent-contract.ps1script18.2 KB
scripts/router/modules/30-openspec.ps1script8.3 KB
scripts/router/modules/31-gsd-overlay.ps1script5.5 KB
scripts/router/modules/32-prompt-overlay.ps1script8.0 KB
scripts/router/modules/33-memory-governance.ps1script5.5 KB
scripts/router/modules/34-data-scale-overlay.ps1script25.8 KB
scripts/router/modules/35-quality-debt-overlay.ps1script13.4 KB
scripts/router/modules/36-framework-interop-overlay.ps1script16.9 KB
scripts/router/modules/37-ml-lifecycle-overlay.ps1script22.4 KB
scripts/router/modules/38-python-clean-code-overlay.ps1script16.2 KB
scripts/router/modules/39-system-design-overlay.ps1script15.5 KB
scripts/router/modules/40-cuda-kernel-overlay.ps1script17.7 KB
scripts/router/modules/42-ai-rerank-overlay.ps1script14.0 KB
scripts/router/modules/43-retrieval-overlay.ps1script22.4 KB
scripts/router/modules/44-dialectic-team-gate.ps1script7.5 KB
scripts/router/modules/44-exploration-overlay.ps1script17.7 KB
scripts/router/modules/45-daily-dialectic-guard.ps1script6.6 KB
scripts/router/modules/47-closure-overlay.ps1script9.2 KB
scripts/router/modules/48-llm-acceleration-overlay.ps1script104.6 KB
scripts/router/modules/49-prompt-asset-boost.ps1script28.3 KB
scripts/router/resolve-pack-route.ps1script4.1 KB
scripts/router/runtime_neutral/custom_admission.pyscript349 B
scripts/router/runtime_neutral/router_contract.pyscript356 B
scripts/ruc-nlpir/preflight.ps1script5.3 KB
scripts/runtime/Freeze-RuntimeInputPacket.ps1script33.0 KB
scripts/runtime/Invoke-AntiProxyGoalDriftCompaction.ps1script551 B
scripts/runtime/Invoke-DeepInterview.ps1script1.1 KB
scripts/runtime/Invoke-PhaseCleanup.ps1script11.1 KB
scripts/runtime/Invoke-PlanExecute.ps1script13.7 KB
scripts/runtime/Invoke-SkeletonCheck.ps1script3.1 KB
scripts/runtime/Invoke-VibeCanonicalEntry.ps1script12.9 KB
scripts/runtime/VibeMemoryActivation.Common.ps1script41.3 KB
scripts/runtime/VibeMemoryBackends.Common.ps1script12.4 KB
scripts/runtime/VibeRuntime.Common.ps1script298.6 KB
scripts/runtime/VibeSkillRouting.Common.ps1script19.0 KB
scripts/runtime/VibeWorkspaceMemory.Common.ps1script6.9 KB
scripts/runtime/Write-RequirementDoc.ps1script23.7 KB
scripts/runtime/Write-XlPlan.ps1script32.3 KB
scripts/runtime/invoke-vibe-runtime.ps1script69.7 KB
scripts/runtime/memory_backend_driver.pyscript14.2 KB
scripts/runtime/skill_authority_driver.pyscript375 B
scripts/runtime/workspace_memory_driver.pyscript24.8 KB
scripts/setup/check-kvm-host-readiness.shscript3.4 KB
scripts/setup/check-windows-eval-iso-readiness.shexecutablescript2.2 KB
scripts/setup/check-windows-proof-vm-state.shexecutablescript2.0 KB
scripts/setup/export-codex-settings-sanitized.ps1script2.6 KB
scripts/setup/fetch-windows11-eval-iso.shexecutablescript4.1 KB
scripts/setup/install-local-vm-host.shexecutablescript1.6 KB
scripts/setup/persist-codex-openai-env.ps1script2.4 KB
scripts/setup/run-windows-proof-vm.shexecutablescript11.4 KB
scripts/setup/send-qmp-boot-keys.pyexecutablescript3.0 KB
scripts/setup/send-qmp-text.pyexecutablescript3.0 KB
scripts/setup/show-windows-proof-media-options.shexecutablescript1.6 KB
scripts/setup/stop-windows-proof-vm.shexecutablescript1.6 KB
scripts/setup/sync-codex-settings-to-user-env.ps1script2.6 KB
scripts/uninstall/Uninstall-VgoAdapter.ps1script1.4 KB
scripts/uninstall/uninstall_vgo_adapter.pyscript526 B
scripts/verify/README.mdmarkdown3.8 KB
scripts/verify/cer-compare.ps1script8.5 KB
scripts/verify/fixtures/README.mdmarkdown1.1 KB
scripts/verify/fixtures/document-cleanup-safety/README.mdmarkdown527 B
scripts/verify/fixtures/document-cleanup-safety/ambiguous-cn-set/metadata.jsonconfig101 B
scripts/verify/fixtures/document-cleanup-safety/ambiguous-cn-set/source/.tmp/docs/重庆市永川区技术预见与制度创新项目申报书1-修订版.docxbinary56 B
scripts/verify/fixtures/document-cleanup-safety/ambiguous-cn-set/source/.tmp/docs/重庆市永川区技术预见与制度创新项目申报书1-补充材料.pdfbinary56 B
scripts/verify/fixtures/document-cleanup-safety/ambiguous-cn-set/source/docs/重庆市永川区技术预见与制度创新项目申报书1-正式版.docxbinary36 B
scripts/verify/fixtures/document-cleanup-safety/mixed-office-assets/metadata.jsonconfig101 B
scripts/verify/fixtures/document-cleanup-safety/mixed-office-assets/source/.tmp/staging/budget-review.xlsxbinary59 B
scripts/verify/fixtures/document-cleanup-safety/mixed-office-assets/source/.tmp/staging/quarterly-review-deck.pptxbinary60 B
scripts/verify/fixtures/document-cleanup-safety/mixed-office-assets/source/docs/reference-manual.pdfbinary21 B
scripts/verify/fixtures/document-cleanup-safety/non-protected-control/metadata.jsonconfig101 B
scripts/verify/fixtures/document-cleanup-safety/non-protected-control/source/.tmp/control.txtmarkdown54 B
scripts/verify/fixtures/llm-acceleration.mock.jsonconfig1.0 KB
scripts/verify/fixtures/pilot-browserops.jsonconfig541 B
scripts/verify/fixtures/pilot-deep-extraction.jsonconfig731 B
scripts/verify/fixtures/pilot-desktopops.jsonconfig587 B
scripts/verify/fixtures/pilot-memory.jsonconfig575 B
scripts/verify/fixtures/pilot-prompt.jsonconfig525 B
scripts/verify/fixtures/process-health/external-node-protected-fixture.jsonconfig345 B
scripts/verify/fixtures/process-health/healthy-managed-fixture.jsonconfig1.1 KB
scripts/verify/fixtures/process-health/managed-completed-alive-fixture.jsonconfig1.2 KB
scripts/verify/fixtures/process-health/managed-stale-fixture.jsonconfig1.1 KB
scripts/verify/fixtures/process-health/no-node-processes-fixture.jsonconfig131 B
scripts/verify/fixtures/prompt-asset-boost.mock.jsonconfig1.2 KB
scripts/verify/gate-family-index.mdmarkdown2.5 KB
scripts/verify/lib/VibeOfflineSkillsAudit.Suites.ps1script11.8 KB
scripts/verify/lib/VibeOfflineSkillsAudit.ps1script12.2 KB
scripts/verify/lib/VibeRouteAudit.Suites.ps1script7.9 KB
scripts/verify/lib/VibeRouteAudit.ps1script5.2 KB
scripts/verify/live-document-gate.pyscript7.6 KB
scripts/verify/probe-scientific-packs.ps1script55.1 KB
scripts/verify/publish-proof.pyscript409 B
scripts/verify/runtime_neutral/README.mdmarkdown2.5 KB
scripts/verify/runtime_neutral/_bootstrap.pyscript321 B
scripts/verify/runtime_neutral/bio_science_pack_consolidation_audit.pyscript421 B
scripts/verify/runtime_neutral/bootstrap_doctor.pyscript494 B
scripts/verify/runtime_neutral/code_quality_pack_consolidation_audit.pyscript717 B
scripts/verify/runtime_neutral/coherence_gate.pyscript529 B
scripts/verify/runtime_neutral/freshness_gate.pyscript494 B
scripts/verify/runtime_neutral/global_pack_consolidation_audit.pyscript635 B
scripts/verify/runtime_neutral/ml_skills_pruning_audit.pyscript574 B
scripts/verify/runtime_neutral/opencode_preview_smoke.pyscript674 B
scripts/verify/runtime_neutral/release_notes_quality.pyscript701 B

scripts/setup/run-windows-proof-vm.sh

View on GitHub
#!/usr/bin/env bash
set -euo pipefail

DEFAULT_VM_ROOT="${HOME}/.cache/vibeskills-vm/windows-proof"
VM_ROOT="${DEFAULT_VM_ROOT}"
ISO_PATH=""
DISK_IMAGE_PATH=""
VM_NAME="vibeskills-windows-proof"
DISK_GB="80"
MEMORY_MB="8192"
CPUS="4"
CPU_MODEL="max"
MACHINE_TYPE="q35"
FIRMWARE_MODE="uefi"
VNC_DISPLAY="5"
RUN_IN_FOREGROUND="0"
WITH_TPM="0"
DRY_RUN="0"
REQUIRE_KVM="0"
BOOT_KEY=""
BOOT_KEY_ROUNDS="0"
BOOT_KEY_INTERVAL_MS="1000"
USE_LEGACY_IDE="0"

usage() {
  cat <<'EOF'
Usage: bash ./scripts/setup/run-windows-proof-vm.sh --iso /absolute/path/Windows.iso [options]

Options:
  --iso PATH           Absolute path to a Windows installation ISO
  --disk-image PATH    Existing Windows disk image (.qcow2, .img, .raw, .vhdx, .vmdk)
  --vm-root PATH       VM state directory (default: ~/.cache/vibeskills-vm/windows-proof)
  --name NAME          VM name
  --disk-gb N          qcow2 system disk size in GB (default: 80)
  --memory-mb N        guest memory in MB (default: 8192)
  --cpus N             guest vCPU count (default: 4)
  --cpu-model NAME     QEMU CPU model (default: max)
  --machine-type NAME  QEMU machine type (default: q35)
  --firmware MODE      Guest firmware mode: uefi or bios (default: uefi)
  --bios               Shortcut for --firmware bios
  --vnc-display N      QEMU VNC display number (default: 5 -> tcp 5905)
  --boot-key KEY[,KEY] Repeatedly inject one or more QMP qcode keys after cold boot
                       (examples: ret, spc, ret,spc)
  --boot-key-rounds N  Number of repeated key injection rounds (default: 0; disabled)
  --boot-key-interval-ms N
                       Delay between key injection rounds in milliseconds (default: 1000)
  --legacy-ide         Use legacy IDE drive wiring instead of q35 AHCI
  --with-tpm           Start a local swtpm instance and attach TPM 2.0
  --require-kvm        Fail instead of silently falling back to TCG when /dev/kvm is unavailable
  --foreground         Keep QEMU attached to the current terminal
  --dry-run            Print the resolved launch command and exit
  --help               Show this help
EOF
}

while [[ $# -gt 0 ]]; do
  case "$1" in
    --iso)
      ISO_PATH="${2:-}"
      shift 2
      ;;
    --disk-image)
      DISK_IMAGE_PATH="${2:-}"
      shift 2
      ;;
    --vm-root)
      VM_ROOT="${2:-}"
      shift 2
      ;;
    --name)
      VM_NAME="${2:-}"
      shift 2
      ;;
    --disk-gb)
      DISK_GB="${2:-}"
      shift 2
      ;;
    --memory-mb)
      MEMORY_MB="${2:-}"
      shift 2
      ;;
    --cpus)
      CPUS="${2:-}"
      shift 2
      ;;
    --cpu-model)
      CPU_MODEL="${2:-}"
      shift 2
      ;;
    --machine-type)
      MACHINE_TYPE="${2:-}"
      shift 2
      ;;
    --firmware)
      FIRMWARE_MODE="${2:-}"
      shift 2
      ;;
    --bios)
      FIRMWARE_MODE="bios"
      shift
      ;;
    --vnc-display)
      VNC_DISPLAY="${2:-}"
      shift 2
      ;;
    --boot-key)
      BOOT_KEY="${2:-}"
      shift 2
      ;;
    --boot-key-rounds)
      BOOT_KEY_ROUNDS="${2:-}"
      shift 2
      ;;
    --boot-key-interval-ms)
      BOOT_KEY_INTERVAL_MS="${2:-}"
      shift 2
      ;;
    --legacy-ide)
      USE_LEGACY_IDE="1"
      shift
      ;;
    --with-tpm)
      WITH_TPM="1"
      shift
      ;;
    --require-kvm)
      REQUIRE_KVM="1"
      shift
      ;;
    --foreground)
      RUN_IN_FOREGROUND="1"
      shift
      ;;
    --dry-run)
      DRY_RUN="1"
      shift
      ;;
    --help)
      usage
      exit 0
      ;;
    *)
      echo "[ERROR] Unknown argument: $1" >&2
      usage >&2
      exit 1
      ;;
  esac
done

if [[ -z "${ISO_PATH}" && -z "${DISK_IMAGE_PATH}" ]]; then
  echo "[ERROR] Either --iso or --disk-image is required." >&2
  echo "[INFO] Official Windows ISO entry: https://www.microsoft.com/en-us/software-download/windows10iso" >&2
  exit 1
fi

if [[ -n "${ISO_PATH}" && ! -f "${ISO_PATH}" ]]; then
  echo "[ERROR] ISO not found: ${ISO_PATH}" >&2
  exit 1
fi

if [[ -n "${ISO_PATH}" ]]; then
  if [[ -f "${ISO_PATH}.part" ]]; then
    echo "[ERROR] ISO partial download detected: ${ISO_PATH}.part" >&2
    echo "[INFO] Wait for the download to complete before launching the VM." >&2
    exit 1
  fi

  if command -v lsof >/dev/null 2>&1; then
    if lsof "${ISO_PATH}" 2>/dev/null | awk 'NR > 1 && $4 ~ /w/ { found=1 } END { exit(found ? 0 : 1) }'; then
      echo "[ERROR] ISO is currently open for writing: ${ISO_PATH}" >&2
      echo "[INFO] Wait for the writer to finish before launching the VM." >&2
      exit 1
    fi
  fi
fi

if [[ -n "${DISK_IMAGE_PATH}" && ! -f "${DISK_IMAGE_PATH}" ]]; then
  echo "[ERROR] Disk image not found: ${DISK_IMAGE_PATH}" >&2
  exit 1
fi

if ! command -v qemu-system-x86_64 >/dev/null 2>&1; then
  echo "[ERROR] qemu-system-x86_64 is missing. Run install-local-vm-host.sh first." >&2
  exit 1
fi

if [[ "${FIRMWARE_MODE}" != "uefi" && "${FIRMWARE_MODE}" != "bios" ]]; then
  echo "[ERROR] Unsupported firmware mode: ${FIRMWARE_MODE}" >&2
  exit 1
fi

OVMF_CODE=""
OVMF_VARS_TEMPLATE=""
SEABIOS_BIN=""

if [[ "${FIRMWARE_MODE}" == "uefi" ]]; then
  for candidate in \
    /usr/share/OVMF/OVMF_CODE_4M.fd \
    /usr/share/OVMF/OVMF_CODE.fd \
    /usr/share/OVMF/OVMF_CODE_4M.ms.fd \
    /usr/share/OVMF/OVMF_CODE.ms.fd
  do
    if [[ -f "${candidate}" ]]; then
      OVMF_CODE="${candidate}"
      break
    fi
  done

  if [[ -z "${OVMF_CODE}" ]]; then
    echo "[ERROR] Unable to locate OVMF code firmware." >&2
    exit 1
  fi

  for candidate in \
    /usr/share/OVMF/OVMF_VARS_4M.fd \
    /usr/share/OVMF/OVMF_VARS.fd \
    /usr/share/OVMF/OVMF_VARS_4M.ms.fd \
    /usr/share/OVMF/OVMF_VARS.ms.fd
  do
    if [[ -f "${candidate}" ]]; then
      OVMF_VARS_TEMPLATE="${candidate}"
      break
    fi
  done

  if [[ -z "${OVMF_VARS_TEMPLATE}" ]]; then
    echo "[ERROR] Unable to locate OVMF vars firmware." >&2
    exit 1
  fi
else
  for candidate in \
    /usr/share/seabios/bios.bin \
    /usr/share/seabios/bios-256k.bin \
    /usr/share/qemu/bios.bin
  do
    if [[ -f "${candidate}" ]]; then
      SEABIOS_BIN="${candidate}"
      break
    fi
  done

  if [[ -z "${SEABIOS_BIN}" ]]; then
    echo "[ERROR] Unable to locate SeaBIOS firmware." >&2
    exit 1
  fi
fi

mkdir -p "${VM_ROOT}"
OVMF_VARS="${VM_ROOT}/OVMF_VARS.fd"
PIDFILE="${VM_ROOT}/qemu.pid"
MONITOR_SOCKET="${VM_ROOT}/monitor.sock"
QMP_SOCKET="${VM_ROOT}/qmp.sock"
SERIAL_LOG="${VM_ROOT}/serial.log"
TPM_DIR="${VM_ROOT}/tpm"
TPM_SOCKET="${VM_ROOT}/swtpm.sock"
TPM_PIDFILE="${VM_ROOT}/swtpm.pid"
BOOT_KEY_LOG="${VM_ROOT}/boot-key-sender.log"
BOOT_KEY_SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/send-qmp-boot-keys.py"

SYSTEM_DRIVE_PATH=""
SYSTEM_DRIVE_FORMAT=""

if [[ -n "${DISK_IMAGE_PATH}" ]]; then
  DISK_INFO="$(qemu-img info --output=json "${DISK_IMAGE_PATH}")"
  SYSTEM_DRIVE_FORMAT="$(python3 -c 'import json,sys; print(json.loads(sys.stdin.read()).get("format",""))' <<< "${DISK_INFO}")"
  if [[ -z "${SYSTEM_DRIVE_FORMAT}" ]]; then
    echo "[ERROR] Unable to determine disk image format for ${DISK_IMAGE_PATH}" >&2
    exit 1
  fi
  SYSTEM_DRIVE_PATH="${DISK_IMAGE_PATH}"
else
  SYSTEM_DRIVE_PATH="${VM_ROOT}/windows-system.qcow2"
  SYSTEM_DRIVE_FORMAT="qcow2"
  if [[ ! -f "${SYSTEM_DRIVE_PATH}" ]]; then
    qemu-img create -f qcow2 "${SYSTEM_DRIVE_PATH}" "${DISK_GB}G" >/dev/null
  fi
fi

if [[ "${FIRMWARE_MODE}" == "uefi" && ! -f "${OVMF_VARS}" ]]; then
  cp "${OVMF_VARS_TEMPLATE}" "${OVMF_VARS}"
fi

ACCEL="tcg"
if [[ -e /dev/kvm && -r /dev/kvm && -w /dev/kvm ]]; then
  ACCEL="kvm"
fi

if [[ "${REQUIRE_KVM}" == "1" && "${ACCEL}" != "kvm" ]]; then
  echo "[ERROR] --require-kvm was set, but /dev/kvm is not available for read/write access on this host." >&2
  echo "[INFO] Re-run on a real KVM-capable host or guest with nested KVM passthrough enabled." >&2
  exit 1
fi

TPM_ARGS=()
if [[ "${WITH_TPM}" == "1" ]]; then
  if ! command -v swtpm >/dev/null 2>&1; then
    echo "[ERROR] swtpm is missing. Run install-local-vm-host.sh first." >&2
    exit 1
  fi
  mkdir -p "${TPM_DIR}"
  rm -f "${TPM_SOCKET}" "${TPM_PIDFILE}"
  swtpm socket \
    --tpm2 \
    --tpmstate "dir=${TPM_DIR}" \
    --ctrl "type=unixio,path=${TPM_SOCKET}" \
    --daemon \
    --pid "file=${TPM_PIDFILE}"
  TPM_ARGS=(
    -chardev "socket,id=chrtpm,path=${TPM_SOCKET}"
    -tpmdev "emulator,id=tpm0,chardev=chrtpm"
    -device "tpm-tis,tpmdev=tpm0"
  )
fi

rm -f "${PIDFILE}" "${MONITOR_SOCKET}" "${QMP_SOCKET}"

QEMU_ARGS=(
  -name "${VM_NAME}"
  -machine "${MACHINE_TYPE},accel=${ACCEL}"
  -cpu "${CPU_MODEL}"
  -smp "${CPUS}"
  -m "${MEMORY_MB}"
  -rtc base=localtime,clock=host
  -boot "order=dc,menu=on"
  -netdev "user,id=net0,hostfwd=tcp:127.0.0.1:33890-:3389,hostfwd=tcp:127.0.0.1:22220-:22"
  -device "e1000,netdev=net0"
  -monitor "unix:${MONITOR_SOCKET},server,nowait"
  -qmp "unix:${QMP_SOCKET},server,nowait"
  -serial "file:${SERIAL_LOG}"
  -display none
  -vnc "127.0.0.1:${VNC_DISPLAY}"
)

if [[ "${FIRMWARE_MODE}" == "uefi" ]]; then
  QEMU_ARGS+=(
    -drive "if=pflash,format=raw,readonly=on,file=${OVMF_CODE}"
    -drive "if=pflash,format=raw,file=${OVMF_VARS}"
  )
else
  QEMU_ARGS+=(
    -bios "${SEABIOS_BIN}"
  )
fi

if [[ "${USE_LEGACY_IDE}" == "1" ]]; then
  QEMU_ARGS+=(
    -drive "file=${SYSTEM_DRIVE_PATH},format=${SYSTEM_DRIVE_FORMAT},if=ide,index=0"
  )
  if [[ -n "${ISO_PATH}" ]]; then
    QEMU_ARGS+=(
      -drive "file=${ISO_PATH},media=cdrom,if=ide,index=1"
    )
  fi
else
  QEMU_ARGS+=(
    -device ich9-ahci,id=ahci
    -drive "id=system,if=none,file=${SYSTEM_DRIVE_PATH},format=${SYSTEM_DRIVE_FORMAT}"
    -device "ide-hd,drive=system,bus=ahci.0"
  )
fi

if [[ -n "${ISO_PATH}" && "${USE_LEGACY_IDE}" != "1" ]]; then
  QEMU_ARGS+=(
    -drive "id=installer,if=none,media=cdrom,file=${ISO_PATH}"
    -device "ide-cd,drive=installer,bus=ahci.1"
  )
fi

if [[ "${RUN_IN_FOREGROUND}" == "0" ]]; then
  QEMU_ARGS+=(-daemonize -pidfile "${PIDFILE}")
fi

if [[ "${#TPM_ARGS[@]}" -gt 0 ]]; then
  QEMU_ARGS+=("${TPM_ARGS[@]}")
fi

run_boot_key_sender() {
  if [[ -z "${BOOT_KEY}" ]]; then
    return 0
  fi

  if ! [[ "${BOOT_KEY_ROUNDS}" =~ ^[0-9]+$ ]] || [[ "${BOOT_KEY_ROUNDS}" == "0" ]]; then
    echo "[WARN] --boot-key was set but --boot-key-rounds is 0; skipping key injection." >&2
    return 0
  fi

  rm -f "${BOOT_KEY_LOG}"
  nohup python3 "${BOOT_KEY_SCRIPT}" "${QMP_SOCKET}" "${BOOT_KEY}" "${BOOT_KEY_ROUNDS}" "${BOOT_KEY_INTERVAL_MS}" >"${BOOT_KEY_LOG}" 2>&1 &
}

echo "[INFO] VM root: ${VM_ROOT}"
echo "[INFO] Acceleration: ${ACCEL}"
echo "[INFO] Firmware mode: ${FIRMWARE_MODE}"
echo "[INFO] CPU model: ${CPU_MODEL}"
echo "[INFO] Machine type: ${MACHINE_TYPE}"
echo "[INFO] Require KVM: ${REQUIRE_KVM}"
echo "[INFO] Storage path: $( [[ "${USE_LEGACY_IDE}" == "1" ]] && echo legacy-ide || echo ahci )"
echo "[INFO] System drive: ${SYSTEM_DRIVE_PATH} (${SYSTEM_DRIVE_FORMAT})"
if [[ -n "${ISO_PATH}" ]]; then
  echo "[INFO] Installer ISO: ${ISO_PATH}"
fi
if [[ -n "${BOOT_KEY}" ]]; then
  echo "[INFO] Boot key injection: key=${BOOT_KEY} rounds=${BOOT_KEY_ROUNDS} interval_ms=${BOOT_KEY_INTERVAL_MS}"
  echo "[INFO] Boot key sender log: ${BOOT_KEY_LOG}"
fi
echo "[INFO] VNC endpoint: 127.0.0.1:$((5900 + VNC_DISPLAY))"
echo "[INFO] RDP forward (after guest setup): 127.0.0.1:33890"
echo "[INFO] SSH forward (after guest setup): 127.0.0.1:22220"

if [[ "${DRY_RUN}" == "1" ]]; then
  printf '[DRY-RUN] qemu-system-x86_64'
  printf ' %q' "${QEMU_ARGS[@]}"
  printf '\n'
  exit 0
fi

run_boot_key_sender
qemu-system-x86_64 "${QEMU_ARGS[@]}"

if [[ "${RUN_IN_FOREGROUND}" == "0" ]]; then
  echo "[OK] Windows VM started in the background."
  if [[ -f "${PIDFILE}" ]]; then
    echo "[OK] QEMU pid: $(cat "${PIDFILE}")"
  fi
fi
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall