The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
// Generate the AppxManifest.xml that MsixTarget.writeManifest produces on
// the win32 CI lane, using the REAL app-builder-lib helpers and the real
// builder config, so the manifest can be inspected off-Windows — makeappx
// reports every manifest problem as a bare 0x80080204, and this is the
// XML it is rejecting.
//
// Usage (from apps/desktop):
// node scripts/gen-msix-manifest.mjs [bundled|light] [x64|arm64]
//
// The output is the substituted manifest on stdout. Imports reach into
// app-builder-lib's dist because the exports map hides the internals; the
// paths are the same ones MsixTarget itself uses, so a bump that moves
// them fails here loudly.
import { readFile, readdir } from "node:fs/promises"
import { createRequire } from "node:module"
import path from "node:path"
import { fileURLToPath } from "node:url"
import {
buildCapabilitiesXml,
buildExtensionsXml,
defaultTileTag,
lockScreenTag,
resolvePackageApplicationId,
resolvePackageIdentityName,
resourceLanguageTag,
splashScreenTag,
substituteManifestMacros,
} from "../../../node_modules/app-builder-lib/dist/targets/win/winAppUtil.js"
import { appIdentity } from "../../../scripts/msix-shared.mjs"
const desktop = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
const repoRoot = path.resolve(desktop, "..", "..")
const variant = process.argv[2] || "bundled"
const arch = process.argv[3] || "x64"
if (!["bundled", "light", "store"].includes(variant)) {
console.error(`variant must be 'bundled', 'light', or 'store', got '${variant}'`)
process.exit(1)
}
process.env.HERMES_DESKTOP_VARIANT = variant
const require = createRequire(import.meta.url)
const config = require(path.join(desktop, "electron-builder.config.cjs"))
const pkg = require(path.join(desktop, "package.json"))
const options = config.msix
// The main application launches Electron. CLI aliases have separate payload
// entrypoints; use the same AppInfo derivation as MsixTarget and signing hooks.
const { AppInfo } = require('../../../node_modules/app-builder-lib/dist/appInfo.js')
const appInfo = new AppInfo({ config, metadata: { ...pkg, ...config.extraMetadata } }, null, config.win)
const executable = `app\\${appInfo.productFilename}.exe`
const displayName = options.displayName || config.productName
// appInfo.name honours extraMetadata.name the way packager merging does.
const appInfoName = config.extraMetadata?.name || pkg.name
// Same asset discovery as computeUserAssets: requiring the config staged
// assets/appx/ into build/appx/ (the buildResources "appx" dir MsixTarget
// reads), so listing it here sees exactly what the win32 lane packs.
const userAssets = (await readdir(path.join(desktop, "build", "appx")))
.filter((it) => !it.startsWith(".") && !it.endsWith(".db") && it.includes("."))
const extensions = await buildExtensionsXml({
protocols: config.protocols,
fileAssociations: [],
addAutoLaunchExtension: options.addAutoLaunchExtension,
customExtensionsPath: options.customExtensionsPath,
appDir: desktop,
executable,
displayName,
dependencyNames: {},
})
// Same precedence as MsixTarget.writeManifest: the config's custom
// template when set (resolved relative to the app dir, as getResource
// does), else the stock template.
const template = await readFile(
options.customManifestPath
? path.resolve(desktop, options.customManifestPath)
: path.join(repoRoot, "node_modules", "app-builder-lib", "templates", "msix", "appxmanifest.xml"),
"utf8"
)
const manifest = substituteManifestMacros(template, (m) => {
switch (m) {
case "publisher": return options.publisher
case "publisherDisplayName": return options.publisherDisplayName
// Same quad the real build stamps (msix-shared::nativeQuad) — the build
// time, so this inspection tool never disagrees with what shipped.
case "version": return appIdentity(desktop, process.env.HERMES_PAYLOAD_TAG).version
case "applicationId": return resolvePackageApplicationId(options.applicationId, options.identityName, appInfoName, "MSIX")
case "identityName": return resolvePackageIdentityName(options.identityName, appInfoName, "MSIX")
case "executable": return executable
case "displayName": return displayName
case "description": return pkg.description || config.productName
case "backgroundColor": return options.backgroundColor || "#464646"
case "logo": return "assets\\StoreLogo.png"
case "square150x150Logo": return "assets\\Square150x150Logo.png"
case "square44x44Logo": return "assets\\Square44x44Logo.png"
case "lockScreen": return lockScreenTag(userAssets)
case "defaultTile": return defaultTileTag(userAssets, options.showNameOnTiles || false)
case "splashScreen": return splashScreenTag(userAssets)
case "arch": return arch
case "resourceLanguages": return resourceLanguageTag(options.languages)
case "capabilities": return `<Capabilities>\n${buildCapabilitiesXml(options.capabilities)}\n</Capabilities>`
case "extensions": return extensions
// Win10 1903 (build 18362) floor, settled 2026-09-03. (An earlier
// desktop6:Service fragment rode this floor; the service feature was
// removed — the Scheduled Task supervises the gateway instead — but the
// shipped floor stays put rather than churning the release minimum.)
// 1809 is a 2018 OS; the bump rides the release notes.
case "minVersion": return options.minVersion || "10.0.18362.0"
case "maxVersionTested": return options.maxVersionTested || options.minVersion || "10.0.18362.0"
case "packageIntegrity": return ""
default: throw new Error(`Macro ${m} is not defined`)
}
})
console.log(manifest)