Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
4b7a4a2
refactor(cli): extract sandbox live state helpers
cv May 2, 2026
2ce87dd
refactor(cli): extract sandbox skill install action
cv May 2, 2026
4cd3cf3
refactor(cli): extract sandbox connect action
cv May 3, 2026
e9dd46e
refactor(cli): extract sandbox status action
cv May 3, 2026
aab6c86
refactor(cli): extract sandbox doctor action
cv May 3, 2026
8908521
refactor(cli): extract sandbox destroy action
cv May 3, 2026
56e4f05
refactor(cli): extract sandbox rebuild action
cv May 3, 2026
8bf1958
refactor(cli): extract upgrade sandboxes action
cv May 3, 2026
38eb84d
refactor(cli): remove runtime bridge
cv May 3, 2026
b2ad5da
refactor(cli): remove legacy dispatch fallbacks
cv May 3, 2026
edd2650
refactor(cli): expose explicit main entrypoint
cv May 3, 2026
a15da95
refactor(cli): add oclif examples for utility commands
cv May 3, 2026
4f57ebb
refactor(cli): validate logs flags with oclif
cv May 3, 2026
8b2d077
refactor(cli): improve sandbox diagnostic command metadata
cv May 3, 2026
a09cc51
refactor(cli): tighten policy and channel parser validation
cv May 3, 2026
75857dc
refactor(cli): improve snapshot command metadata
cv May 3, 2026
11c0676
refactor(cli): require skill install path in oclif
cv May 3, 2026
05f9eca
refactor(cli): add lifecycle confirmation flag aliases
cv May 3, 2026
4ebeae4
refactor(cli): split share into oclif subcommands
cv May 3, 2026
7d72437
Revert "refactor(cli): split share into oclif subcommands"
cv May 3, 2026
0ee5ca5
refactor(cli): split share into oclif subcommands
cv May 3, 2026
928219c
refactor(cli): model debug flags with oclif
cv May 3, 2026
36cce5e
refactor(cli): model onboard flags with oclif
cv May 3, 2026
702afb1
docs: sync oclif UX command reference
cv May 3, 2026
3224350
refactor(cli): extract public argv normalizer
cv May 3, 2026
cd4cdb8
refactor(cli): rename oclif dispatch module
cv May 3, 2026
9499ca6
refactor(cli): normalize policy command ids
cv May 3, 2026
42028ef
test(cli): require oclif command metadata
cv May 3, 2026
a05c6b3
refactor(cli): return typed debug parse results
cv May 3, 2026
1875fe9
refactor(cli): add public command display ids
cv May 3, 2026
36f1dbe
refactor(cli): use oclif summaries in root help
cv May 3, 2026
78bfd5a
refactor(cli): table-drive sandbox dispatch
cv May 3, 2026
96ce61f
refactor(cli): normalize gateway token command id
cv May 3, 2026
266ebc9
refactor(cli): render public oclif help
cv May 3, 2026
dc98994
refactor(cli): add shared oclif command base
cv May 3, 2026
d0d2a70
refactor(cli): use oclif flag relationships
cv May 3, 2026
8396c06
refactor(cli): pass lifecycle typed options
cv May 3, 2026
1532b19
refactor(cli): parse durations with oclif flags
cv May 3, 2026
7c0445a
refactor(cli): project public help through oclif
cv May 3, 2026
3978c32
test(cli): cover oclif metadata routing helpers
cv May 3, 2026
591eabb
test(cli): cover global oclif command adapters
cv May 3, 2026
8a6ecbc
test(cli): cover sandbox oclif command adapters
cv May 3, 2026
e5aa22f
refactor(cli): split share oclif commands
cv May 3, 2026
e179336
test(cli): narrow sandbox logs coverage ignores
cv May 3, 2026
a629813
test(cli): cover remaining global oclif adapters
cv May 3, 2026
c5954e7
test(cli): cover credentials oclif adapter
cv May 3, 2026
3380de9
test(cli): cover runtime utility helpers
cv May 3, 2026
f60a190
test(cli): improve global adapter coverage
cv May 3, 2026
78a16d1
merge: sync simple global adapter coverage
cv May 3, 2026
a58dc90
merge: sync credentials adapter coverage
cv May 3, 2026
034454f
merge: include credentials adapter coverage
cv May 3, 2026
28bc497
merge: sync combined global adapter coverage
cv May 3, 2026
e9ed6ba
test(cli): cover global action facade
cv May 3, 2026
00b288c
merge: sync global action facade coverage
cv May 3, 2026
7bd5f32
test(cli): stabilize coverage dist sourcemaps
cv May 4, 2026
d4b55d9
test(cli): rebaseline clean-dist function coverage
cv May 4, 2026
b872474
refactor(cli): extract maintenance image helpers
cv May 4, 2026
4965762
refactor(cli): extract upgrade sandbox helpers
cv May 4, 2026
9acd660
refactor(cli): extract sandbox destroy helpers
cv May 4, 2026
cc0eaa1
refactor(cli): extract sandbox logs helpers
cv May 4, 2026
847e115
refactor(cli): extract policy channel helpers
cv May 4, 2026
b6c0f5a
test(cli): allow clean coverage variance
cv May 4, 2026
5c98bd1
merge: sync coverage stabilization
cv May 4, 2026
4754f3e
merge: sync maintenance helper extraction
cv May 4, 2026
96f0758
merge: sync upgrade helper extraction
cv May 4, 2026
b6bd105
merge: sync destroy helper extraction
cv May 4, 2026
98fb75d
merge: sync logs helper extraction
cv May 4, 2026
5920d5b
test(cli): keep destroy helpers outside coverage ratchet
cv May 4, 2026
64d1646
merge: sync destroy helper coverage boundary
cv May 4, 2026
717c482
test(cli): keep logs helpers outside coverage ratchet
cv May 4, 2026
688074f
merge: sync logs helper coverage boundary
cv May 4, 2026
1314270
test(cli): keep policy channel helpers outside coverage ratchet
cv May 4, 2026
79d81c2
refactor(cli): group oclif core modules
cv May 4, 2026
5453a89
refactor(cli): split oclif commands by command tree
cv May 4, 2026
bbc297f
test(cli): reset credential command helper cache
cv May 4, 2026
25224c1
test(cli): avoid generic warning assertion in debug output
cv May 4, 2026
1ed9256
refactor(cli): group pure domain helpers
cv May 4, 2026
51799e4
refactor(cli): group openshell adapters
cv May 4, 2026
0b1e877
test(cli): enforce initial layer import boundaries
cv May 4, 2026
91d750b
refactor(cli): group sandbox actions
cv May 4, 2026
4321d63
refactor(cli): group global actions
cv May 4, 2026
5bc2242
test(cli): format layer boundary checker
cv May 4, 2026
073225e
ci(prek): tolerate unmatched biome format chunks
cv May 4, 2026
29a26ae
refactor(cli): group state modules
cv May 4, 2026
523e2d9
refactor(cli): group docker adapters
cv May 4, 2026
f25fcce
Merge branch 'test/layer-import-boundaries' into refactor/layer-sandb…
cv May 4, 2026
301b0a7
Merge branch 'refactor/layer-sandbox-actions' into refactor/layer-glo…
cv May 4, 2026
668235a
Merge branch 'refactor/layer-global-actions' into refactor/layer-stat…
cv May 4, 2026
392bebb
Merge branch 'refactor/layer-state-modules' into refactor/layer-docke…
cv May 4, 2026
e25e0a3
refactor(cli): discover oclif commands by pattern
cv May 6, 2026
bb7ebc3
refactor(cli): move coredns patcher behind internal command
cv May 6, 2026
489198d
refactor(cli): move dns proxy setup behind internal command
cv May 6, 2026
b5cdf50
refactor(uninstall): extract plan domain helpers
cv May 6, 2026
cc93aae
fix(uninstall): allow optional host env fields in plan tests
cv May 6, 2026
aa0f853
refactor(uninstall): run uninstall through internal command
cv May 6, 2026
cf416a4
fix(cli): locate node for uninstall wrapper
cv May 6, 2026
359fefd
test(cli): exclude source-tested uninstall helpers from coverage ratchet
cv May 6, 2026
f729544
refactor(cli): wrap debug script with TypeScript command
cv May 6, 2026
ab60b4c
refactor(cli): move dev shim install behind internal command
cv May 6, 2026
7f39bd5
ci(cli): typecheck cli sources during pre-push
cv May 6, 2026
9f8c6a3
refactor(cli): read metadata from oclif discovery
cv May 6, 2026
7e9d3c0
refactor(cli): colocate display metadata with commands
cv May 6, 2026
ca4388c
refactor(cli): derive legacy sandbox dispatch from metadata
cv May 6, 2026
70c78ec
refactor(cli): remove compatibility command index
cv May 6, 2026
9af5206
test(cli): cover oclif-native sandbox commands
cv May 6, 2026
28daa3e
refactor(installer): extract pure domain helpers
cv May 6, 2026
3489904
refactor(installer): add internal plan commands
cv May 6, 2026
ddfc25c
fix(installer): derive provider alias help text
cv May 6, 2026
dbf7088
merge(main): reconcile installer domain helpers
cv May 6, 2026
651c49a
Merge branch 'refactor/installer-domain-helpers' into refactor/intern…
prekshivyas May 6, 2026
1e0e33e
Merge branch 'main' into refactor/internal-installer-plan
prekshivyas May 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/commands/internal/installer/normalize-env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { Command, Flags } from "@oclif/core";

import { normalizeInstallerEnv } from "../../../lib/actions/installer-plan";

export default class InternalInstallerNormalizeEnvCommand extends Command {
static hidden = true;
static strict = true;
static summary = "Internal: normalize installer environment values";
static description = "Normalize installer ref and provider environment values without applying installation changes.";
static usage = ["internal installer normalize-env [--json]"];
static examples = ["<%= config.bin %> internal installer normalize-env --provider cloud --json"];
static flags = {
help: Flags.help({ char: "h" }),
json: Flags.boolean({ description: "Print normalized values as JSON" }),
"install-ref": Flags.string({ description: "NEMOCLAW_INSTALL_REF value" }),
"install-tag": Flags.string({ description: "NEMOCLAW_INSTALL_TAG value" }),
provider: Flags.string({ description: "NEMOCLAW_PROVIDER value" }),
};

public async run(): Promise<void> {
const { flags } = await this.parse(InternalInstallerNormalizeEnvCommand);
const normalized = normalizeInstallerEnv({
NEMOCLAW_INSTALL_REF: flags["install-ref"] ?? process.env.NEMOCLAW_INSTALL_REF,
NEMOCLAW_INSTALL_TAG: flags["install-tag"] ?? process.env.NEMOCLAW_INSTALL_TAG,
NEMOCLAW_PROVIDER: flags.provider ?? process.env.NEMOCLAW_PROVIDER,
});

if (flags.json) console.log(JSON.stringify(normalized, null, 2));
else console.log(`ref=${normalized.installRef} provider=${normalized.provider.normalized ?? ""}`);
}
}
49 changes: 49 additions & 0 deletions src/commands/internal/installer/plan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { Command, Flags } from "@oclif/core";

import { buildInstallerPlan } from "../../../lib/actions/installer-plan";

export default class InternalInstallerPlanCommand extends Command {
static hidden = true;
static strict = true;
static summary = "Internal: build the NemoClaw installer plan";
static description = "Build a deterministic installer plan from environment and probe inputs without applying it.";
static usage = ["internal installer plan [--json]"];
static examples = ["<%= config.bin %> internal installer plan --json --provider nim --install-ref v0.1.0"];
static flags = {
help: Flags.help({ char: "h" }),
json: Flags.boolean({ description: "Print the installer plan as JSON" }),
"install-ref": Flags.string({ description: "Install ref override" }),
"install-tag": Flags.string({ description: "Install tag fallback" }),
"git-describe-version": Flags.string({ description: "git describe version fallback", hidden: true }),
"node-version": Flags.string({ description: "Detected Node.js version" }),
"npm-prefix": Flags.string({ description: "Detected npm prefix" }),
"npm-version": Flags.string({ description: "Detected npm version" }),
"package-json-version": Flags.string({ description: "package.json version fallback", hidden: true }),
provider: Flags.string({ description: "Installer provider value" }),
"stamped-version": Flags.string({ description: "Stamped .version fallback", hidden: true }),
};

public async run(): Promise<void> {
const { flags } = await this.parse(InternalInstallerPlanCommand);
const plan = buildInstallerPlan({
env: {
...process.env,
NEMOCLAW_INSTALL_REF: flags["install-ref"] ?? process.env.NEMOCLAW_INSTALL_REF,
NEMOCLAW_INSTALL_TAG: flags["install-tag"] ?? process.env.NEMOCLAW_INSTALL_TAG,
NEMOCLAW_PROVIDER: flags.provider ?? process.env.NEMOCLAW_PROVIDER,
},
gitDescribeVersion: flags["git-describe-version"],
nodeVersion: flags["node-version"],
npmPrefix: flags["npm-prefix"],
npmVersion: flags["npm-version"],
packageJsonVersion: flags["package-json-version"],
stampedVersion: flags["stamped-version"],
});

if (flags.json) console.log(JSON.stringify(plan, null, 2));
else console.log(`Installer plan: ref '${plan.installRef}', version '${plan.installerVersion}'`);
}
}
32 changes: 32 additions & 0 deletions src/commands/internal/installer/resolve-release-tag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { Command, Flags } from "@oclif/core";

import { resolveInstallRef } from "../../../lib/domain/installer/ref";

export default class InternalInstallerResolveReleaseTagCommand extends Command {
static hidden = true;
static strict = true;
static summary = "Internal: resolve the installer release ref";
static description = "Resolve the installer ref using the same precedence as install.sh.";
static usage = ["internal installer resolve-release-tag [--json]"];
static examples = ["<%= config.bin %> internal installer resolve-release-tag --install-ref v0.1.0"];
static flags = {
help: Flags.help({ char: "h" }),
json: Flags.boolean({ description: "Print the resolved ref as JSON" }),
"install-ref": Flags.string({ description: "NEMOCLAW_INSTALL_REF value" }),
"install-tag": Flags.string({ description: "NEMOCLAW_INSTALL_TAG value" }),
};

public async run(): Promise<void> {
const { flags } = await this.parse(InternalInstallerResolveReleaseTagCommand);
const installRef = resolveInstallRef({
NEMOCLAW_INSTALL_REF: flags["install-ref"] ?? process.env.NEMOCLAW_INSTALL_REF,
NEMOCLAW_INSTALL_TAG: flags["install-tag"] ?? process.env.NEMOCLAW_INSTALL_TAG,
});

if (flags.json) console.log(JSON.stringify({ installRef }, null, 2));
else console.log(installRef);
}
}
55 changes: 55 additions & 0 deletions src/lib/actions/installer-plan.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import path from "node:path";

import { describe, expect, it } from "vitest";

import { buildInstallerPlan, normalizeInstallerEnv } from "./installer-plan";

const writableState = {
exists: (targetPath: string) => targetPath !== "/missing",
isWritable: () => true,
};

describe("installer plan actions", () => {
it("builds a deterministic installer plan from env, versions, and npm prefix", () => {
const plan = buildInstallerPlan({
defaultVersion: "0.1.0",
env: {
NEMOCLAW_INSTALL_REF: "feature/refactor",
NEMOCLAW_INSTALL_TAG: "v9.9.9",
NEMOCLAW_PROVIDER: "cloud",
PATH: "/usr/bin",
},
nodeVersion: "v22.16.0",
npmPrefix: "/tmp/npm-prefix",
npmTargetState: writableState,
npmVersion: "10.1.0",
});

expect(plan.installRef).toBe("feature/refactor");
expect(plan.installerVersion).toBe("feature/refactor");
expect(plan.provider).toMatchObject({ normalized: "build", raw: "cloud", valid: true });
expect(plan.runtime).toEqual({ ok: true, nodeVersion: "v22.16.0", npmVersion: "10.1.0" });
expect(plan.npm?.globalBin).toBe(path.join("/tmp/npm-prefix", "bin"));
expect(plan.npm?.pathWithGlobalBin).toBe(`${path.join("/tmp/npm-prefix", "bin")}${path.delimiter}/usr/bin`);
expect(plan.npm?.linkTargetsWritable?.ok).toBe(true);
});

it("marks unsupported providers and missing optional probes without failing plan construction", () => {
const plan = buildInstallerPlan({ env: { NEMOCLAW_PROVIDER: "bad-provider" } });

expect(plan.installRef).toBe("latest");
expect(plan.provider).toMatchObject({ normalized: null, raw: "bad-provider", valid: false });
expect(plan.runtime).toBeNull();
expect(plan.npm).toBeNull();
});

it("normalizes installer env for shell-compatible helper output", () => {
expect(normalizeInstallerEnv({ NEMOCLAW_INSTALL_TAG: "v1.2.3", NEMOCLAW_PROVIDER: "nim" })).toEqual({
installRef: "v1.2.3",
provider: expect.objectContaining({ normalized: "nim-local", raw: "nim", valid: true }),
});
});
});
105 changes: 105 additions & 0 deletions src/lib/actions/installer-plan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import {
npmGlobalBin,
npmLinkTargetsWritable,
pathWithPrependedEntries,
type NpmLinkTargetState,
type NpmLinkTargetWritableResult,
} from "../domain/installer/npm";
import {
installerProviderHelpValues,
normalizeInstallerProvider,
type InstallerProvider,
} from "../domain/installer/provider";
import { resolveInstallerVersion, resolveInstallRef, type InstallerRefEnv } from "../domain/installer/ref";
import { checkInstallerRuntime, type RuntimeCheckResult } from "../domain/installer/version";

export interface InstallerPlanEnv extends InstallerRefEnv {
NEMOCLAW_PROVIDER?: string | undefined;
PATH?: string | undefined;
}

export interface BuildInstallerPlanOptions {
defaultVersion?: string;
env?: InstallerPlanEnv;
gitDescribeVersion?: string | null;
nodeVersion?: string | null;
npmPrefix?: string | null;
npmTargetState?: NpmLinkTargetState;
npmVersion?: string | null;
packageJsonVersion?: string | null;
stampedVersion?: string | null;
}

export interface InstallerProviderPlan {
helpValues: string;
normalized: InstallerProvider | null;
raw: string | null;
valid: boolean;
}

export interface InstallerNpmPlan {
globalBin: string | null;
linkTargetsWritable: NpmLinkTargetWritableResult | null;
pathWithGlobalBin: string | null;
prefix: string;
}

export interface InstallerPlan {
installRef: string;
installerVersion: string;
npm: InstallerNpmPlan | null;
provider: InstallerProviderPlan;
runtime: RuntimeCheckResult | null;
}

function nonEmpty(value: string | null | undefined): string | null {
const trimmed = value?.trim();
return trimmed ? trimmed : null;
}

export function buildInstallerPlan(options: BuildInstallerPlanOptions = {}): InstallerPlan {
const env = options.env ?? {};
const installRef = resolveInstallRef(env);
const providerRaw = nonEmpty(env.NEMOCLAW_PROVIDER);
const normalizedProvider = normalizeInstallerProvider(providerRaw);
const globalBin = options.npmPrefix ? npmGlobalBin(options.npmPrefix) : null;

return {
installRef,
installerVersion: resolveInstallerVersion({
defaultVersion: options.defaultVersion ?? "0.1.0",
env,
gitDescribeVersion: options.gitDescribeVersion,
packageJsonVersion: options.packageJsonVersion,
stampedVersion: options.stampedVersion,
}),
npm: options.npmPrefix
? {
globalBin,
linkTargetsWritable: options.npmTargetState
? npmLinkTargetsWritable(options.npmPrefix, options.npmTargetState)
: null,
pathWithGlobalBin: globalBin ? pathWithPrependedEntries(env.PATH ?? "", [globalBin]) : null,
prefix: options.npmPrefix.trim(),
}
: null,
provider: {
helpValues: installerProviderHelpValues(),
normalized: normalizedProvider,
raw: providerRaw,
valid: providerRaw === null || normalizedProvider !== null,
},
runtime:
options.nodeVersion && options.npmVersion
? checkInstallerRuntime({ nodeVersion: options.nodeVersion, npmVersion: options.npmVersion })
: null,
};
}

export function normalizeInstallerEnv(env: InstallerPlanEnv): Pick<InstallerPlan, "installRef" | "provider"> {
const plan = buildInstallerPlan({ env });
return { installRef: plan.installRef, provider: plan.provider };
}
58 changes: 58 additions & 0 deletions test/internal-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,62 @@ describe("internal oclif namespace", () => {
expect(result.stdout).toContain("Internal: link the checkout CLI or create a dev shim");
expect(result.stdout).toContain("nemoclaw internal dev npm-link-or-shim");
});

it("exposes installer plan commands through oclif routing", () => {
const help = spawnSync(process.execPath, [CLI, "internal", "installer", "plan", "--help"], {
encoding: "utf-8",
});

expect(help.status).toBe(0);
expect(help.stdout).toContain("Internal: build the NemoClaw installer plan");
expect(help.stdout).toContain("nemoclaw internal installer plan [--json]");

const result = spawnSync(
process.execPath,
[
CLI,
"internal",
"installer",
"plan",
"--json",
"--install-ref",
"v1.2.3",
"--provider",
"cloud",
"--node-version",
"v22.16.0",
"--npm-version",
"10.0.0",
],
{ encoding: "utf-8" },
);

expect(result.status).toBe(0);
expect(JSON.parse(result.stdout)).toMatchObject({
installRef: "v1.2.3",
provider: { normalized: "build", raw: "cloud", valid: true },
runtime: { ok: true },
});
});

it("exposes installer ref and env normalization helpers through oclif routing", () => {
const ref = spawnSync(
process.execPath,
[CLI, "internal", "installer", "resolve-release-tag", "--json", "--install-tag", "v2.0.0"],
{ encoding: "utf-8" },
);
const env = spawnSync(
process.execPath,
[CLI, "internal", "installer", "normalize-env", "--json", "--provider", "nim"],
{ encoding: "utf-8" },
);

expect(ref.status).toBe(0);
expect(JSON.parse(ref.stdout)).toEqual({ installRef: "v2.0.0" });
expect(env.status).toBe(0);
expect(JSON.parse(env.stdout)).toMatchObject({
installRef: "latest",
provider: { normalized: "nim-local", raw: "nim", valid: true },
});
});
});
Loading