@adrifer/winix 0.2.4-preview.2 → 0.3.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,154 @@
1
+ import { readFile, mkdir, writeFile, lstat } from "node:fs/promises";
2
+ import { join, dirname } from "node:path";
3
+ import { createInterface } from "node:readline/promises";
4
+ import { stdin, stdout } from "node:process";
5
+ import { fileURLToPath } from "node:url";
6
+ import { execFileSync } from "node:child_process";
7
+ import { standaloneRuntime } from "../../runtime.js";
8
+ import { resolveWinixVersionRange } from "./init.js";
9
+ import { runCommand } from "../run.js";
10
+ export function pinnedWinixVersion(spec) {
11
+ if (typeof spec !== "string")
12
+ throw new Error("package.json must declare an exact @adrifer/winix dependency");
13
+ if (/^\d+\.\d+\.\d+(?:-preview\.\d+)?$/.test(spec))
14
+ return spec;
15
+ const match = /^https:\/\/github\.com\/adrifer\/winix\/releases\/download\/v(\d+\.\d+\.\d+(?:-preview\.\d+)?)\/adrifer-winix-\1\.tgz$/.exec(spec);
16
+ if (!match)
17
+ throw new Error("Winix bootstrap requires an exact version or matching official GitHub release SDK URL; floating versions are not supported");
18
+ return match[1];
19
+ }
20
+ export async function checkoutWinixVersion(directory) {
21
+ const pkg = JSON.parse(await readFile(join(directory, "package.json"), "utf8"));
22
+ return pinnedWinixVersion(pkg.dependencies?.["@adrifer/winix"] ?? pkg.devDependencies?.["@adrifer/winix"]);
23
+ }
24
+ export async function localWinixCommand(directory, expected, runtimeVersion, executable) {
25
+ const packagePath = join(directory, "node_modules", "@adrifer", "winix", "package.json");
26
+ let local;
27
+ let installed = false;
28
+ try {
29
+ local = JSON.parse(await readFile(packagePath, "utf8"));
30
+ installed = true;
31
+ }
32
+ catch (error) {
33
+ if (error.code !== "ENOENT")
34
+ throw error;
35
+ try {
36
+ await lstat(dirname(packagePath));
37
+ throw new Error("Local node_modules Winix is incomplete (missing package.json). Run npm ci or remove the optional SDK explicitly.");
38
+ }
39
+ catch (directoryError) {
40
+ if (directoryError.code !== "ENOENT")
41
+ throw directoryError;
42
+ }
43
+ }
44
+ if (installed) {
45
+ if (!local || typeof local !== "object" || !("version" in local))
46
+ throw new Error("Local node_modules Winix has invalid package metadata. Run npm ci.");
47
+ if (local.version !== expected) {
48
+ throw new Error(`Local node_modules Winix is ${local.version}, expected ${expected}. Run npm ci using your approved repository; bootstrap will not install dependencies automatically.`);
49
+ }
50
+ return {
51
+ command: standaloneRuntime() ? "node" : process.execPath,
52
+ args: ["--no-warnings", join(dirname(packagePath), "dist", "cli", "index.js")],
53
+ };
54
+ }
55
+ if (runtimeVersion !== expected) {
56
+ throw new Error(`Checkout requires Winix ${expected}, but this executable is ${runtimeVersion}. Rerun the repository bootstrap to download the matching release.`);
57
+ }
58
+ return { command: executable, args: [] };
59
+ }
60
+ export async function runCheckout(directory, args, run = runCommand) {
61
+ if (!args.length || ["run", "bootstrap"].includes(args[0])) {
62
+ throw new Error("Usage: winix run <check|apply|switch|update|inspect|...> [options]; run/bootstrap cannot be nested");
63
+ }
64
+ const version = (await resolveWinixVersionRange()).replace(/^\^/, "");
65
+ const executable = process.env.WINIX_STANDALONE_EXECUTABLE ?? process.execPath;
66
+ let command = await localWinixCommand(directory, await checkoutWinixVersion(directory), version, executable);
67
+ if (command.args.length) {
68
+ const nodeVersion = execFileSync(command.command, ["--version"], { encoding: "utf8" }).trim();
69
+ command.args.unshift(...nodeTypeArguments(nodeVersion));
70
+ }
71
+ if (!standaloneRuntime() && command.command === process.execPath && command.args.length === 0) {
72
+ command = {
73
+ command: process.execPath,
74
+ args: [...nodeTypeArguments(process.version), "--no-warnings",
75
+ fileURLToPath(new URL(`../index.${import.meta.url.endsWith(".ts") ? "ts" : "js"}`, import.meta.url))],
76
+ };
77
+ }
78
+ await run(command.command, [...command.args, ...args], { cwd: directory });
79
+ }
80
+ export function nodeTypeArguments(version) {
81
+ const parsed = /^v?(\d+)\.(\d+)\.\d+$/.exec(version);
82
+ if (!parsed || Number(parsed[1]) < 22 || Number(parsed[1]) === 22 && Number(parsed[2]) < 13) {
83
+ throw new Error(`Local SDK requires stable Node >=22.13, found ${version}. Install it explicitly or remove the optional node_modules SDK to retain standalone mode.`);
84
+ }
85
+ return Number(parsed[1]) >= 26 ? [] : ["--experimental-transform-types"];
86
+ }
87
+ async function confirm(message, yes) {
88
+ if (yes)
89
+ return;
90
+ if (!stdin.isTTY)
91
+ throw new Error(`${message} Noninteractive bootstrap requires --yes.`);
92
+ const reader = createInterface({ input: stdin, output: stdout });
93
+ try {
94
+ if (!/^(y|yes)$/i.test((await reader.question(`${message} [y/N] `)).trim())) {
95
+ throw new Error("Bootstrap cancelled.");
96
+ }
97
+ }
98
+ finally {
99
+ reader.close();
100
+ }
101
+ }
102
+ export async function bootstrapCheckout(directory, opts, run = runCheckout) {
103
+ if (!opts.host || opts.host.startsWith("-") || /[\0\r\n]/.test(opts.host))
104
+ throw new Error("bootstrap requires --host <declared-host>");
105
+ const expected = await checkoutWinixVersion(directory);
106
+ const version = (await resolveWinixVersionRange()).replace(/^\^/, "");
107
+ if (expected !== version)
108
+ throw new Error(`Checkout requires Winix ${expected}; run its matching bootstrap executable, not ${version}.`);
109
+ if (opts.dry) {
110
+ console.log(`Would prepare checkout ${directory} with Winix ${expected}, validate host "${opts.host}", preview, and ${opts.prepareOnly ? "stop before activation" : "ask before activation"}. No config was evaluated.`);
111
+ return;
112
+ }
113
+ await confirm("Evaluate trusted TypeScript from this checkout? Config code can execute commands.", opts.yes);
114
+ const bin = join(directory, ".winix", "bin");
115
+ for (const path of [join(directory, ".winix"), bin]) {
116
+ try {
117
+ if (!(await lstat(path)).isDirectory())
118
+ throw new Error(`Refusing a linked/non-directory bootstrap path: ${path}`);
119
+ }
120
+ catch (error) {
121
+ if (error.code !== "ENOENT")
122
+ throw error;
123
+ }
124
+ }
125
+ await run(directory, ["check"]);
126
+ await run(directory, ["switch", "--dry", "--host", opts.host]);
127
+ if (standaloneRuntime()) {
128
+ const executable = process.env.WINIX_STANDALONE_EXECUTABLE ?? process.execPath;
129
+ await mkdir(bin, { recursive: true });
130
+ const windows = process.platform === "win32";
131
+ const launcher = join(bin, windows ? "winix.ps1" : "winix");
132
+ const content = windows
133
+ ? `# Generated by Winix bootstrap\n$ErrorActionPreference = 'Stop'\nSet-Location -LiteralPath (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent)\n& '${executable.replaceAll("'", "''")}' run @args\nexit $LASTEXITCODE\n`
134
+ : `#!/usr/bin/env bash\n# Generated by Winix bootstrap\nset -euo pipefail\ncd -- "$(dirname -- "\${BASH_SOURCE[0]}")/../.."\nexec '${executable.replaceAll("'", "'\\''")}' run "$@"\n`;
135
+ try {
136
+ const stat = await lstat(launcher);
137
+ if (!stat.isFile() || !(await readFile(launcher, "utf8")).includes("# Generated by Winix bootstrap")) {
138
+ throw new Error(`Refusing to overwrite an unrecognized launcher: ${launcher}`);
139
+ }
140
+ }
141
+ catch (error) {
142
+ if (error.code !== "ENOENT")
143
+ throw error;
144
+ }
145
+ await writeFile(launcher, content, { mode: 0o755 });
146
+ console.log(`Checkout launcher: ${launcher}. It prefers a matching node_modules SDK, never installs npm packages, and rejects stale versions.`);
147
+ }
148
+ if (opts.prepareOnly) {
149
+ console.log("Prepared and validated. No host activation performed.");
150
+ return;
151
+ }
152
+ await confirm(`Activate host "${opts.host}"? Reboot and WSL shutdown are never automatic.`, opts.yes);
153
+ await run(directory, ["switch", "--host", opts.host, ...(opts.yes ? ["--yes"] : [])]);
154
+ }
@@ -7,7 +7,7 @@ import { standaloneRuntime } from "../../runtime.js";
7
7
  export async function init(cwd, opts) {
8
8
  await mkdir(cwd, { recursive: true });
9
9
  const versionRange = await resolveWinixVersionRange();
10
- const packageJson = renderPackageJson(versionRange);
10
+ const packageJson = renderPackageJson(versionRange.replace(/^\^/, ""));
11
11
  await writeIfAllowed(join(cwd, "winix.config.ts"), CONFIG, opts.force);
12
12
  await writeIfAllowed(join(cwd, "tsconfig.json"), TSCONFIG, opts.force);
13
13
  await writeIfAllowed(join(cwd, "package.json"), packageJson, opts.force);
@@ -78,7 +78,8 @@ async function updateWindowsLock(cwd, opts) {
78
78
  const wslImages = hasWindowsWslDistros(windowsHosts);
79
79
  const wslSetup = windowsHosts.some((host) => host.windows.dsc?.some((resource) => resource.winix?.kind === "wsl-distro" && resource.winix.distro.setup));
80
80
  for (const id of opts.inputs) {
81
- if (!floating.has(id) && !pinned.has(id) && !modules.has(id.toLowerCase()) &&
81
+ if (!floating.has(id) && !pinned.has(id) &&
82
+ ![...modules.values()].some((module) => module.name.toLowerCase() === id.toLowerCase()) &&
82
83
  !(id === "nixos-wsl" && wslImages) && !(id === "wsl-setup" && wslSetup)) {
83
84
  throw new Error(`Windows package, PowerShell module, WSL image or setup repository "${id}" is not declared in this workspace.`);
84
85
  }
package/dist/cli/index.js CHANGED
@@ -9,7 +9,18 @@ import { inspect } from "./commands/inspect.js";
9
9
  import { switchCommand } from "./commands/switch.js";
10
10
  import { update } from "./commands/update.js";
11
11
  import { renderSkill } from "../skill.js";
12
+ import { bootstrapCheckout, runCheckout } from "./commands/bootstrap.js";
12
13
  import { forgetWindowsResource, windowsStatePath } from "./windows-state.js";
14
+ if (process.argv[2] === "run") {
15
+ try {
16
+ await runCheckout(process.cwd(), process.argv.slice(3));
17
+ }
18
+ catch (error) {
19
+ console.error(`Error: ${error.message}`);
20
+ process.exit(1);
21
+ }
22
+ process.exit(0);
23
+ }
13
24
  const { positionals, values } = parseArgs({
14
25
  allowPositionals: true,
15
26
  options: {
@@ -24,6 +35,7 @@ const { positionals, values } = parseArgs({
24
35
  "escape-report": { type: "boolean", default: false },
25
36
  help: { type: "boolean", short: "h", default: false },
26
37
  version: { type: "boolean", short: "v", default: false },
38
+ "prepare-only": { type: "boolean", default: false },
27
39
  },
28
40
  });
29
41
  const command = positionals[0];
@@ -44,6 +56,8 @@ if (values.help || !command) {
44
56
  winix - TypeScript-first system configuration
45
57
 
46
58
  Commands:
59
+ bootstrap Validate/preview a trusted checkout, then confirm activation
60
+ run <args> Prefer checkout-local SDK, enforcing the checkout's exact Winix pin
47
61
  init Scaffold a Winix project
48
62
  install skill Install the agent skill wrapper
49
63
  apply Generate backend output in .winix/out/
@@ -55,6 +69,7 @@ Commands:
55
69
 
56
70
  Options:
57
71
  --host <name> Target a specific host
72
+ --prepare-only Stop bootstrap after validation/preview; no activation
58
73
  --dry Preview generation (apply) or activation and managed cleanup (switch)
59
74
  -y, --yes Confirm managed Windows removals without prompting (switch)
60
75
  --diff Show diff against current output (apply)
@@ -81,11 +96,26 @@ Examples:
81
96
  process.exit(0);
82
97
  }
83
98
  const cwd = process.cwd();
84
- if (values.yes && command !== "switch") {
85
- console.error("--yes is only supported by winix switch.");
99
+ if (values["prepare-only"] && command !== "bootstrap") {
100
+ console.error("--prepare-only is only supported by winix bootstrap.");
101
+ process.exit(2);
102
+ }
103
+ if (values.yes && command !== "switch" && command !== "bootstrap") {
104
+ console.error("--yes is only supported by winix switch or bootstrap.");
86
105
  process.exit(2);
87
106
  }
88
107
  switch (command) {
108
+ case "bootstrap":
109
+ try {
110
+ await bootstrapCheckout(cwd, {
111
+ host: values.host ?? "", yes: values.yes, prepareOnly: values["prepare-only"], dry: values.dry,
112
+ });
113
+ }
114
+ catch (error) {
115
+ console.error(`Error: ${error.message}`);
116
+ process.exit(1);
117
+ }
118
+ break;
89
119
  case "init":
90
120
  try {
91
121
  await init(cwd, { force: values.force });
@@ -1,5 +1,6 @@
1
1
  // Evaluator: takes a workspace config, evaluates fragments per host, produces merged IR
2
2
  import { setEvalContext, restoreEvalContext } from "../sdk/index.js";
3
+ import { powerShellRepositoryPolicyIdentity, validateWindowsPowerShellPolicy } from "../helpers/windows-repositories.js";
3
4
  /**
4
5
  * Evaluate a workspace: process each host's fragments and merge them.
5
6
  */
@@ -50,12 +51,22 @@ function evaluateHost(host) {
50
51
  result.windows = mergeWindowsOptions(result.windows, fragment.windows);
51
52
  }
52
53
  }
54
+ validateWindowsPowerShellPolicy(result.windows);
53
55
  return result;
54
56
  }
55
57
  function mergeWindowsOptions(target, source) {
58
+ const targetPolicy = target.powershell?.repositories;
59
+ const sourcePolicy = source.powershell?.repositories;
60
+ if (targetPolicy && sourcePolicy &&
61
+ powerShellRepositoryPolicyIdentity(targetPolicy) !== powerShellRepositoryPolicyIdentity(sourcePolicy)) {
62
+ throw new Error("Conflicting PowerShell repository policies in one host; declare one policy in the selected profile");
63
+ }
56
64
  const targetCommands = Array.isArray(target.commands) ? target.commands : [];
57
65
  const sourceCommands = Array.isArray(source.commands) ? source.commands : [];
58
66
  const result = deepMerge(target, source);
67
+ if (targetPolicy && sourcePolicy) {
68
+ result.powershell = { ...result.powershell, repositories: targetPolicy };
69
+ }
59
70
  if (targetCommands.length > 0 || sourceCommands.length > 0) {
60
71
  result.commands = [...targetCommands, ...sourceCommands];
61
72
  }
@@ -0,0 +1,11 @@
1
+ import type { WinPowerShellModule, WinPowerShellRepositoryPolicy, WindowsOptions } from "../types/windows.js";
2
+ export interface ResolvedPowerShellModule extends WinPowerShellModule {
3
+ repository: string;
4
+ repositoryUri?: string;
5
+ }
6
+ export declare const powerShellRepositoryName: RegExp;
7
+ export declare function powerShellRepositoryUri(value: string): string;
8
+ export declare function validatePowerShellRepositoryPolicy(policy: WinPowerShellRepositoryPolicy): void;
9
+ export declare function powerShellRepositoryPolicyIdentity(policy: WinPowerShellRepositoryPolicy): string;
10
+ export declare function resolvePowerShellModule(win: WindowsOptions, module: WinPowerShellModule): ResolvedPowerShellModule;
11
+ export declare function validateWindowsPowerShellPolicy(win: WindowsOptions): void;
@@ -0,0 +1,77 @@
1
+ export const powerShellRepositoryName = /^[a-z0-9][a-z0-9._-]*$/i;
2
+ export function powerShellRepositoryUri(value) {
3
+ let url;
4
+ try {
5
+ url = new URL(value);
6
+ }
7
+ catch {
8
+ throw new Error("PowerShell repository URI must be an HTTPS URL");
9
+ }
10
+ if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash) {
11
+ throw new Error("PowerShell repository URI must be HTTPS without credentials, query, or fragment");
12
+ }
13
+ return url.href.replace(/\/+$/, "");
14
+ }
15
+ export function validatePowerShellRepositoryPolicy(policy) {
16
+ if (!policy || typeof policy !== "object" || Array.isArray(policy) ||
17
+ !policy.repositories || typeof policy.repositories !== "object" || Array.isArray(policy.repositories) ||
18
+ typeof policy.default !== "string" || !powerShellRepositoryName.test(policy.default)) {
19
+ throw new Error("PowerShell repository policy requires repositories and a default repository name");
20
+ }
21
+ const names = new Set(["psgallery"]);
22
+ for (const [name, feed] of Object.entries(policy.repositories)) {
23
+ if (!powerShellRepositoryName.test(name) || names.has(name.toLowerCase())) {
24
+ throw new Error(`Duplicate or reserved PowerShell repository name: ${name}`);
25
+ }
26
+ if (!feed || typeof feed.uri !== "string")
27
+ throw new Error(`PowerShell repository "${name}" requires a URI`);
28
+ powerShellRepositoryUri(feed.uri);
29
+ names.add(name.toLowerCase());
30
+ }
31
+ if (!names.has(policy.default.toLowerCase())) {
32
+ throw new Error(`Default PowerShell repository "${policy.default}" is not declared`);
33
+ }
34
+ if (policy.allowed !== undefined &&
35
+ (!Array.isArray(policy.allowed) || policy.allowed.length === 0 ||
36
+ policy.allowed.some((name) => typeof name !== "string" || !names.has(name.toLowerCase())))) {
37
+ throw new Error("PowerShell allowed repositories must be a nonempty list of declared names or PSGallery");
38
+ }
39
+ if (policy.allowed && !policy.allowed.some((name) => name.toLowerCase() === policy.default.toLowerCase())) {
40
+ throw new Error("Default PowerShell repository must be allowed");
41
+ }
42
+ }
43
+ export function powerShellRepositoryPolicyIdentity(policy) {
44
+ validatePowerShellRepositoryPolicy(policy);
45
+ return JSON.stringify({
46
+ repositories: Object.entries(policy.repositories)
47
+ .map(([name, feed]) => [name.toLowerCase(), powerShellRepositoryUri(feed.uri)])
48
+ .sort(([left], [right]) => left.localeCompare(right)),
49
+ default: policy.default.toLowerCase(),
50
+ allowed: policy.allowed ? [...new Set(policy.allowed.map((name) => name.toLowerCase()))].sort() : null,
51
+ });
52
+ }
53
+ export function resolvePowerShellModule(win, module) {
54
+ const policy = win.powershell?.repositories;
55
+ if (policy)
56
+ validatePowerShellRepositoryPolicy(policy);
57
+ const requested = module.repository ?? policy?.default ?? "PSGallery";
58
+ if (policy?.allowed && !policy.allowed.some((name) => name.toLowerCase() === requested.toLowerCase())) {
59
+ throw new Error(`PowerShell module "${module.name}" requests disallowed repository "${requested}"`);
60
+ }
61
+ const entry = Object.entries(policy?.repositories ?? {}).find(([name]) => name.toLowerCase() === requested.toLowerCase());
62
+ return {
63
+ ...module,
64
+ repository: entry?.[0] ?? requested,
65
+ ...(entry ? { repositoryUri: powerShellRepositoryUri(entry[1].uri) } : {}),
66
+ };
67
+ }
68
+ export function validateWindowsPowerShellPolicy(win) {
69
+ if (win.powershell?.repositories)
70
+ validatePowerShellRepositoryPolicy(win.powershell.repositories);
71
+ for (const resource of win.dsc ?? []) {
72
+ if (resource.winix?.kind === "powershell-module")
73
+ resolvePowerShellModule(win, resource.winix.module);
74
+ if (resource.winix?.kind === "setting")
75
+ resolvePowerShellModule(win, { name: "Microsoft.Windows.Settings" });
76
+ }
77
+ }
@@ -1,5 +1,5 @@
1
- import type { ResourceHandle } from "../core/types.js";
2
- import type { WinDscProperties, WinDscResource, WinPackageSource, WinSettings, WinFilePath, WinKnownFolder, WinKnownFolderName, WinStartupCommand, WinWslConfig, WinWslDistro, WinWslSetup } from "../types/index.js";
1
+ import type { Fragment, ResourceHandle } from "../core/types.js";
2
+ import type { WinDscProperties, WinDscResource, WinPackageSource, WinSettings, WinFilePath, WinKnownFolder, WinKnownFolderName, WinStartupCommand, WinWslConfig, WinWslDistro, WinWslSetup, WinPowerShellRepositoryPolicy } from "../types/index.js";
3
3
  /**
4
4
  * Accepted call shapes for `windows.package(...)`.
5
5
  *
@@ -48,7 +48,7 @@ export interface WinSettingOpts {
48
48
  dependsOn?: ResourceHandle | ResourceHandle[];
49
49
  }
50
50
  export interface WinPowerShellModuleOpts {
51
- /** Registered PowerShell repository on the target. Defaults to PSGallery. */
51
+ /** Registered repository; inherits the host policy, otherwise PSGallery. */
52
52
  repository?: string;
53
53
  dependsOn?: ResourceHandle | ResourceHandle[];
54
54
  }
@@ -120,6 +120,8 @@ export interface WindowsHelper {
120
120
  [Folder in WinKnownFolderName]: (path?: string) => WinKnownFolder;
121
121
  };
122
122
  powershell: {
123
+ /** Select and optionally restrict feeds for Winix-managed modules on this host. */
124
+ repositories(policy: WinPowerShellRepositoryPolicy): Fragment;
123
125
  /** Install a current-user PowerShell 7 module using winix-windows.lock. */
124
126
  module(name: string, opts?: WinPowerShellModuleOpts): ResourceHandle;
125
127
  };
@@ -6,6 +6,7 @@
6
6
  import { resolve, win32, posix } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { powerShellLiteral as psSingleQuoted } from "./utils.js";
9
+ import { validatePowerShellRepositoryPolicy } from "./windows-repositories.js";
9
10
  const KNOWN_FOLDERS = {
10
11
  documents: "MyDocuments",
11
12
  desktop: "Desktop",
@@ -1009,6 +1010,10 @@ export const windows = {
1009
1010
  userProfile: (path) => knownFolder("userProfile", path),
1010
1011
  },
1011
1012
  powershell: {
1013
+ repositories: (policy) => {
1014
+ validatePowerShellRepositoryPolicy(policy);
1015
+ return { windows: { powershell: { repositories: policy } } };
1016
+ },
1012
1017
  module: (name, opts = {}) => {
1013
1018
  if (typeof name !== "string" || !/^[a-z0-9][a-z0-9._-]*$/i.test(name)) {
1014
1019
  throw new Error("windows.powershell.module requires a module name without wildcards or paths");
@@ -1016,8 +1021,8 @@ export const windows = {
1016
1021
  if (!opts || typeof opts !== "object" || Array.isArray(opts)) {
1017
1022
  throw new Error("windows.powershell.module options must be an object");
1018
1023
  }
1019
- const repository = opts.repository ?? "PSGallery";
1020
- if (typeof repository !== "string" || !/^[a-z0-9][a-z0-9._-]*$/i.test(repository)) {
1024
+ const repository = opts.repository;
1025
+ if (repository !== undefined && (typeof repository !== "string" || !/^[a-z0-9][a-z0-9._-]*$/i.test(repository))) {
1021
1026
  throw new Error("windows.powershell.module repository must be a registered repository name");
1022
1027
  }
1023
1028
  const resource = withDscMetadata(withDscToken({
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { Fragment, ResourceHandle, FragmentFactory, PlatformFactory, ProfileFactory, LazyFragment, PlatformLazyFragment, FragmentEntry, FragmentResult, NixExpr, RawModuleRef, ImportRef, InputDef, InputWithOptions, WorkspaceDef, HostDef, EvalContext } from "./core/types.js";
2
- export type { Attrs, BootOptions, DarwinNetworking, DarwinOptions, DarwinSecurity, DarwinDefaults, DarwinSystem, EnvironmentOptions, FirewallOptions, FontsOptions, FzfOptions, GitInclude, GitOptions, HomeActivation, HomebrewOptions, HomeConfig, HomeFile, HomeOptions, I18nOptions, LaunchdAgentOptions, LaunchdOptions, NeovimOptions, NetworkingOptions, NixConfig, NixGcOptions, NixHomebrewOptions, NixOptions, NixpkgsOptions, NixosSecurityOptions, NixosSystemOptions, NixPrimitive, NixSettings, NixValue, NixosOptions, OciContainerOptions, PackageRef, Script, ServicesOptions, StarshipOptions, SystemdOptions, SystemdService, SystemdTimer, TimeOptions, TmuxOptions, UserOptions, UsersOptions, VirtualisationOptions, WslOptions, XdgFile, XdgOptions, ZoxideOptions, ZshOptions, WindowsOptions, WinPackage, WinPackageSource, WinRawCommand, WinSettings, WinColorMode, WinStartFolder, WinTaskbarAlignment, WinTaskbarGroupingMode, WinTaskbarMultiMonMode, WinKnownFolder, WinKnownFolderName, WinFilePath, WinPowerShellModule, WinStartupCommand, WinStartupWindowStyle, } from "./types/index.js";
2
+ export type { Attrs, BootOptions, DarwinNetworking, DarwinOptions, DarwinSecurity, DarwinDefaults, DarwinSystem, EnvironmentOptions, FirewallOptions, FontsOptions, FzfOptions, GitInclude, GitOptions, HomeActivation, HomebrewOptions, HomeConfig, HomeFile, HomeOptions, I18nOptions, LaunchdAgentOptions, LaunchdOptions, NeovimOptions, NetworkingOptions, NixConfig, NixGcOptions, NixHomebrewOptions, NixOptions, NixpkgsOptions, NixosSecurityOptions, NixosSystemOptions, NixPrimitive, NixSettings, NixValue, NixosOptions, OciContainerOptions, PackageRef, Script, ServicesOptions, StarshipOptions, SystemdOptions, SystemdService, SystemdTimer, TimeOptions, TmuxOptions, UserOptions, UsersOptions, VirtualisationOptions, WslOptions, XdgFile, XdgOptions, ZoxideOptions, ZshOptions, WindowsOptions, WinPackage, WinPackageSource, WinRawCommand, WinSettings, WinColorMode, WinStartFolder, WinTaskbarAlignment, WinTaskbarGroupingMode, WinTaskbarMultiMonMode, WinKnownFolder, WinKnownFolderName, WinFilePath, WinPowerShellModule, WinPowerShellRepositoryPolicy, WinStartupCommand, WinStartupWindowStyle, } from "./types/index.js";
3
3
  export { platform, feature, profile, host, workspace, input, defineInputs, rawModule, withContext } from "./sdk/index.js";
4
4
  export type { WinixContext } from "./sdk/context.js";
5
5
  export { evaluate } from "./evaluator/index.js";
package/dist/skill.js CHANGED
@@ -285,7 +285,14 @@ Resources return handles that can be passed through \`dependsOn\`.
285
285
  sources resolve relative to the directory containing winix.config.ts;
286
286
  absolute paths, environment-variable paths, and file URLs are also supported.
287
287
  - \`windows.powershell.module()\` declares a current-user PowerShell 7 module
288
- by name, with optional repository (default PSGallery) and dependsOn.
288
+ by name, with optional repository (host default, otherwise PSGallery) and dependsOn.
289
+ windows.powershell.repositories({ repositories: { approved: { uri: "https://packages.example.com/powershell/v3/index.json" } }, default: "approved", allowed: ["approved"] })
290
+ declares a host-scoped feed policy. Compose it in work profiles; shared modules
291
+ and the automatic Settings installer inherit it after merging. Explicit
292
+ disallowed repositories fail without fallback. Named HTTPS feeds are registered
293
+ for the current user for resolution/activation, without changing global priority
294
+ or trust. Existing registrations with different URLs fail explicitly. Module
295
+ pins include source identity; personal hosts retain their own repositories.
289
296
  Versions are recorded in the modules section of winix-windows.lock, not
290
297
  handwritten declarations. PowerShell 7 with PSResourceGet is required for
291
298
  resolution and installation.
@@ -329,6 +336,9 @@ Resources return handles that can be passed through \`dependsOn\`.
329
336
  or occupied checkouts/changed settings are refused, never reset or adopted.
330
337
  State lives at /var/lib/winix/wsl-setup. Inspect stale run.lock and its PID
331
338
  before manual recovery; never remove a live coordinator's lock.
339
+ Fresh branch-based clones retain full history and an upstream-tracking branch
340
+ at the locked commit, even if upstream is newer. Tags/commits stay detached.
341
+ Completed checkouts are never switched or migrated automatically.
332
342
  No shutdown/reboot is automatic. Fresh-image activation remains unverified.
333
343
  Omit setup to retain separate manual Linux activation.
334
344
  - \`windows.raw()\` runs a command on every apply. It is not idempotent, so use
@@ -379,10 +389,34 @@ hashes; custom single-target builds cannot provision WSL. Linux assets use glibc
379
389
  automatic WSL setup prepares NixOS's linker explicitly. No ARM64 execution or
380
390
  fresh-image activation is claimed.
381
391
  \`-UseNvm\` chooses NVM for Windows instead of standalone Node; \`-Yes\` accepts
382
- bootstrap changes. It never installs Winix globally, activates a host, provisions
392
+ bootstrap changes. Prerequisite-only mode never installs Winix globally, activates a host, provisions
383
393
  WSL, reboots, or changes execution policy persistently. Prepare the config and
384
394
  compatible SDK separately, then review \`switch --dry\` before activation.
385
395
 
396
+ Repository mode adds \`-Repository HTTPS_URL -Ref main -Destination PATH
397
+ -ConfigDirectory winix -HostName HOST\`. Linux's \`bootstrap-linux.sh\` uses
398
+ \`--repository\`, \`--ref\`, \`--destination\`, \`--config-directory\`, \`--host\`.
399
+ It uses existing Nix for temporary Git/Python tools, or requires installed
400
+ Git/Python; it never installs Nix or converts other Linux distributions.
401
+ Both clone or validate a clean existing checkout without pulling/resetting,
402
+ read its exact SDK dependency (version or official release SDK tarball URL),
403
+ and verify matching release executables before running them. Windows additionally
404
+ verifies that release's prerequisite-only script. Review scripts and release
405
+ checksums first; hashes are not signatures. No Node/npm installation is automatic.
406
+ \`-DryRun\`/\`--dry-run\` performs no changes/evaluation; \`-PrepareOnly\`/
407
+ \`--prepare-only\` allows setup plus check/switch preview but no activation.
408
+ Trust confirmation occurs before config evaluation. Omit prepare-only to
409
+ confirm activation separately; \`-Yes\`/\`--yes\` accepts trust/activation/removals.
410
+ Do not run real bootstrap/activation as a development check on a shared machine.
411
+
412
+ \`winix bootstrap --host HOST\` performs the checkout validation/preview/confirmation
413
+ phase. Its generated \`.winix/bin/winix.ps1\` or \`.winix/bin/winix\` launcher invokes
414
+ \`winix run <args>\`, rereading the exact pin on every invocation. A matching
415
+ optional node_modules SDK uses its own CLI under Node >=22.13; stale/corrupt
416
+ local packages fail, never silently fall back. Otherwise the standalone must
417
+ match the manifest; rerun bootstrap after changing the pin. The user may run
418
+ \`npm ci\` explicitly using an approved source, then use normal local npm scripts.
419
+
386
420
  On existing NixOS/NixOS-WSL, \`bash bootstrap-nixos.sh\` (from
387
421
  \`scripts/bootstrap-nixos.sh\` or a reviewed release asset) opens a temporary
388
422
  Git/Node.js 24/npm/Bash environment using pinned nixpkgs. Nix must already be
@@ -18,7 +18,17 @@ export interface WinStartupCommand {
18
18
  }
19
19
  export interface WinPowerShellModule {
20
20
  name: string;
21
- repository: string;
21
+ /** Omitted repositories inherit the host policy after all fragments merge. */
22
+ repository?: string;
23
+ }
24
+ export interface WinPowerShellRepositoryPolicy {
25
+ /** Named HTTPS feeds to register for the current Windows user. No credentials in URLs. */
26
+ repositories: Record<string, {
27
+ uri: string;
28
+ }>;
29
+ default: string;
30
+ /** When specified, reject other repositories instead of falling back. */
31
+ allowed?: string[];
22
32
  }
23
33
  export interface WinWslDistro {
24
34
  name: string;
@@ -258,6 +268,9 @@ export type WinDscProperties = {
258
268
  * order controls apply order.
259
269
  */
260
270
  export interface WindowsOptions extends Record<string, unknown> {
271
+ powershell?: {
272
+ repositories?: WinPowerShellRepositoryPolicy;
273
+ };
261
274
  /** Declared packages, keyed by package id. */
262
275
  packages?: Record<string, WinPackage>;
263
276
  /** Raw commands to run on apply, in declaration order. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adrifer/winix",
3
- "version": "0.2.4-preview.2",
3
+ "version": "0.3.0-preview.1",
4
4
  "description": "TypeScript-first system configuration for NixOS, nix-darwin, and Home Manager",
5
5
  "license": "MIT",
6
6
  "author": "Adrian Fernandez",
@@ -45,6 +45,7 @@
45
45
  "files": [
46
46
  "scripts/bootstrap-windows.ps1",
47
47
  "scripts/bootstrap-nixos.sh",
48
+ "scripts/bootstrap-linux.sh",
48
49
  "dist",
49
50
  "types",
50
51
  "index.d.ts",