2026-01-18 15:56:24 -05:00
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
|
import {
|
|
|
|
|
buildParseArgv,
|
2026-01-18 23:28:09 +00:00
|
|
|
getFlagValue,
|
2026-01-18 15:56:24 -05:00
|
|
|
getCommandPath,
|
|
|
|
|
getPrimaryCommand,
|
2026-01-19 00:52:13 +00:00
|
|
|
getPositiveIntFlagValue,
|
|
|
|
|
getVerboseFlag,
|
2026-01-18 15:56:24 -05:00
|
|
|
hasHelpOrVersion,
|
2026-01-18 23:28:09 +00:00
|
|
|
hasFlag,
|
2026-01-19 00:52:13 +00:00
|
|
|
shouldMigrateState,
|
|
|
|
|
shouldMigrateStateFromPath,
|
2026-01-18 15:56:24 -05:00
|
|
|
} from "./argv.js";
|
|
|
|
|
|
|
|
|
|
describe("argv helpers", () => {
|
|
|
|
|
it("detects help/version flags", () => {
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(hasHelpOrVersion(["node", "openclaw", "--help"])).toBe(true);
|
|
|
|
|
expect(hasHelpOrVersion(["node", "openclaw", "-V"])).toBe(true);
|
|
|
|
|
expect(hasHelpOrVersion(["node", "openclaw", "status"])).toBe(false);
|
2026-01-18 15:56:24 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("extracts command path ignoring flags and terminator", () => {
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(getCommandPath(["node", "openclaw", "status", "--json"], 2)).toEqual(["status"]);
|
|
|
|
|
expect(getCommandPath(["node", "openclaw", "agents", "list"], 2)).toEqual(["agents", "list"]);
|
|
|
|
|
expect(getCommandPath(["node", "openclaw", "status", "--", "ignored"], 2)).toEqual(["status"]);
|
2026-01-18 15:56:24 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("returns primary command", () => {
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(getPrimaryCommand(["node", "openclaw", "agents", "list"])).toBe("agents");
|
|
|
|
|
expect(getPrimaryCommand(["node", "openclaw"])).toBeNull();
|
2026-01-18 15:56:24 -05:00
|
|
|
});
|
|
|
|
|
|
2026-01-18 23:28:09 +00:00
|
|
|
it("parses boolean flags and ignores terminator", () => {
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(hasFlag(["node", "openclaw", "status", "--json"], "--json")).toBe(true);
|
|
|
|
|
expect(hasFlag(["node", "openclaw", "--", "--json"], "--json")).toBe(false);
|
2026-01-18 23:28:09 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("extracts flag values with equals and missing values", () => {
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(getFlagValue(["node", "openclaw", "status", "--timeout", "5000"], "--timeout")).toBe(
|
2026-01-18 23:28:09 +00:00
|
|
|
"5000",
|
|
|
|
|
);
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(getFlagValue(["node", "openclaw", "status", "--timeout=2500"], "--timeout")).toBe(
|
|
|
|
|
"2500",
|
|
|
|
|
);
|
|
|
|
|
expect(getFlagValue(["node", "openclaw", "status", "--timeout"], "--timeout")).toBeNull();
|
|
|
|
|
expect(getFlagValue(["node", "openclaw", "status", "--timeout", "--json"], "--timeout")).toBe(
|
2026-01-18 23:28:09 +00:00
|
|
|
null,
|
|
|
|
|
);
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(getFlagValue(["node", "openclaw", "--", "--timeout=99"], "--timeout")).toBeUndefined();
|
2026-01-18 23:28:09 +00:00
|
|
|
});
|
|
|
|
|
|
2026-01-19 00:52:13 +00:00
|
|
|
it("parses verbose flags", () => {
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(getVerboseFlag(["node", "openclaw", "status", "--verbose"])).toBe(true);
|
|
|
|
|
expect(getVerboseFlag(["node", "openclaw", "status", "--debug"])).toBe(false);
|
|
|
|
|
expect(getVerboseFlag(["node", "openclaw", "status", "--debug"], { includeDebug: true })).toBe(
|
2026-01-19 00:52:13 +00:00
|
|
|
true,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("parses positive integer flag values", () => {
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(getPositiveIntFlagValue(["node", "openclaw", "status"], "--timeout")).toBeUndefined();
|
2026-01-19 00:52:13 +00:00
|
|
|
expect(
|
2026-01-30 03:15:10 +01:00
|
|
|
getPositiveIntFlagValue(["node", "openclaw", "status", "--timeout"], "--timeout"),
|
2026-01-19 00:52:13 +00:00
|
|
|
).toBeNull();
|
|
|
|
|
expect(
|
2026-01-30 03:15:10 +01:00
|
|
|
getPositiveIntFlagValue(["node", "openclaw", "status", "--timeout", "5000"], "--timeout"),
|
2026-01-19 00:52:13 +00:00
|
|
|
).toBe(5000);
|
|
|
|
|
expect(
|
2026-01-30 03:15:10 +01:00
|
|
|
getPositiveIntFlagValue(["node", "openclaw", "status", "--timeout", "nope"], "--timeout"),
|
2026-01-19 00:52:13 +00:00
|
|
|
).toBeUndefined();
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-18 15:56:24 -05:00
|
|
|
it("builds parse argv from raw args", () => {
|
|
|
|
|
const nodeArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
|
|
|
|
rawArgs: ["node", "openclaw", "status"],
|
2026-01-18 15:56:24 -05:00
|
|
|
});
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(nodeArgv).toEqual(["node", "openclaw", "status"]);
|
2026-01-18 15:56:24 -05:00
|
|
|
|
2026-01-26 20:29:15 -05:00
|
|
|
const versionedNodeArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
|
|
|
|
rawArgs: ["node-22", "openclaw", "status"],
|
2026-01-26 20:29:15 -05:00
|
|
|
});
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(versionedNodeArgv).toEqual(["node-22", "openclaw", "status"]);
|
2026-01-26 20:29:15 -05:00
|
|
|
|
|
|
|
|
const versionedNodeWindowsArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
|
|
|
|
rawArgs: ["node-22.2.0.exe", "openclaw", "status"],
|
2026-01-26 20:29:15 -05:00
|
|
|
});
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(versionedNodeWindowsArgv).toEqual(["node-22.2.0.exe", "openclaw", "status"]);
|
2026-01-26 20:29:15 -05:00
|
|
|
|
|
|
|
|
const versionedNodePatchlessArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
|
|
|
|
rawArgs: ["node-22.2", "openclaw", "status"],
|
2026-01-26 20:29:15 -05:00
|
|
|
});
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(versionedNodePatchlessArgv).toEqual(["node-22.2", "openclaw", "status"]);
|
2026-01-26 20:29:15 -05:00
|
|
|
|
|
|
|
|
const versionedNodeWindowsPatchlessArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
|
|
|
|
rawArgs: ["node-22.2.exe", "openclaw", "status"],
|
2026-01-26 20:29:15 -05:00
|
|
|
});
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(versionedNodeWindowsPatchlessArgv).toEqual(["node-22.2.exe", "openclaw", "status"]);
|
2026-01-26 20:29:15 -05:00
|
|
|
|
|
|
|
|
const versionedNodeWithPathArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
|
|
|
|
rawArgs: ["/usr/bin/node-22.2.0", "openclaw", "status"],
|
2026-01-26 20:29:15 -05:00
|
|
|
});
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(versionedNodeWithPathArgv).toEqual(["/usr/bin/node-22.2.0", "openclaw", "status"]);
|
2026-01-26 20:29:15 -05:00
|
|
|
|
|
|
|
|
const nodejsArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
|
|
|
|
rawArgs: ["nodejs", "openclaw", "status"],
|
2026-01-26 20:29:15 -05:00
|
|
|
});
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(nodejsArgv).toEqual(["nodejs", "openclaw", "status"]);
|
2026-01-26 20:29:15 -05:00
|
|
|
|
|
|
|
|
const nonVersionedNodeArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
|
|
|
|
rawArgs: ["node-dev", "openclaw", "status"],
|
2026-01-26 20:29:15 -05:00
|
|
|
});
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(nonVersionedNodeArgv).toEqual(["node", "openclaw", "node-dev", "openclaw", "status"]);
|
2026-01-26 20:29:15 -05:00
|
|
|
|
2026-01-18 15:56:24 -05:00
|
|
|
const directArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
|
|
|
|
rawArgs: ["openclaw", "status"],
|
2026-01-18 15:56:24 -05:00
|
|
|
});
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(directArgv).toEqual(["node", "openclaw", "status"]);
|
2026-01-18 15:56:24 -05:00
|
|
|
|
|
|
|
|
const bunArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
2026-01-18 15:56:24 -05:00
|
|
|
rawArgs: ["bun", "src/entry.ts", "status"],
|
|
|
|
|
});
|
|
|
|
|
expect(bunArgv).toEqual(["bun", "src/entry.ts", "status"]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("builds parse argv from fallback args", () => {
|
|
|
|
|
const fallbackArgv = buildParseArgv({
|
2026-01-30 03:15:10 +01:00
|
|
|
programName: "openclaw",
|
2026-01-18 15:56:24 -05:00
|
|
|
fallbackArgv: ["status"],
|
|
|
|
|
});
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(fallbackArgv).toEqual(["node", "openclaw", "status"]);
|
2026-01-18 15:56:24 -05:00
|
|
|
});
|
2026-01-19 00:52:13 +00:00
|
|
|
|
Ironclaw rename: update CLI binary references, fix Next.js invocation, harden package resolution
Comprehensive update to complete the openclaw → ironclaw CLI rename across the
codebase, fix build/runtime issues, and add test coverage for infra modules.
CLI binary rename (openclaw → ironclaw):
- Update DEFAULT_CLI_NAME and all argv parsing to recognize "ironclaw" binary
- Extend package name sets (CORE_PACKAGE_NAMES, ALL_PACKAGE_NAMES) to include
both "ironclaw" and "openclaw" for backward compatibility
- Update NPM registry URL to fetch from ironclaw package
- Update gateway lock detection, port listener classification, and launchd/systemd
service scanning to recognize ironclaw-prefixed services and binaries
- Update daemon inspect markers and legacy detection for ironclaw
- Update voice-call extension core-bridge to resolve ironclaw package root
- Fix install instructions in embeddings error messages (npm i -g ironclaw@latest)
Web app / Next.js fixes:
- Replace fragile `npx next` invocations with direct `node next-bin` resolution
to avoid broken pnpm virtual-store symlinks in global installs
- Add resolveNextBin() helper that resolves apps/web/node_modules/next directly
Infra hardening:
- Workspace templates: compute both source and dist fallback paths for template
directory resolution (fixes templates not found in bundled builds)
- Control UI assets: recognize both "openclaw" and "ironclaw" package names
- Update-check, update-runner, update-cli: normalize ironclaw@ tag prefixes
New tests:
- Add openclaw-root.test.ts, ports-format.test.ts, update-global.test.ts
- Add workspace-templates.test.ts and control-ui-assets.test.ts coverage
- Add argv.test.ts coverage for ironclaw binary detection
Test fixes (28 failures → 0):
- Update all test assertions expecting "openclaw" CLI command output to "ironclaw"
- Fix version.test.ts package name from "openclaw" to "ironclaw"
- Fix camera/canvas temp path patterns in nodes-camera and program.nodes-media tests
- Fix pairing message, telegram bot, channels, daemon, onboard, gateway tool,
status, and profile test expectations
Version: 2026.2.10-1.2 (published to npm as ironclaw@2026.2.10-1.2)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 12:19:49 -08:00
|
|
|
it("builds parse argv for ironclaw binary name", () => {
|
|
|
|
|
const directArgv = buildParseArgv({
|
|
|
|
|
programName: "ironclaw",
|
|
|
|
|
rawArgs: ["ironclaw", "status"],
|
|
|
|
|
});
|
|
|
|
|
expect(directArgv).toEqual(["node", "ironclaw", "status"]);
|
|
|
|
|
|
|
|
|
|
const nodeArgv = buildParseArgv({
|
|
|
|
|
programName: "ironclaw",
|
|
|
|
|
rawArgs: ["node", "ironclaw", "status"],
|
|
|
|
|
});
|
|
|
|
|
expect(nodeArgv).toEqual(["node", "ironclaw", "status"]);
|
|
|
|
|
});
|
|
|
|
|
|
2026-01-19 00:52:13 +00:00
|
|
|
it("decides when to migrate state", () => {
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(shouldMigrateState(["node", "openclaw", "status"])).toBe(false);
|
|
|
|
|
expect(shouldMigrateState(["node", "openclaw", "health"])).toBe(false);
|
|
|
|
|
expect(shouldMigrateState(["node", "openclaw", "sessions"])).toBe(false);
|
2026-02-14 01:18:20 +00:00
|
|
|
expect(shouldMigrateState(["node", "openclaw", "config", "get", "update"])).toBe(false);
|
|
|
|
|
expect(shouldMigrateState(["node", "openclaw", "config", "unset", "update"])).toBe(false);
|
|
|
|
|
expect(shouldMigrateState(["node", "openclaw", "models", "list"])).toBe(false);
|
|
|
|
|
expect(shouldMigrateState(["node", "openclaw", "models", "status"])).toBe(false);
|
2026-01-30 03:15:10 +01:00
|
|
|
expect(shouldMigrateState(["node", "openclaw", "memory", "status"])).toBe(false);
|
|
|
|
|
expect(shouldMigrateState(["node", "openclaw", "agent", "--message", "hi"])).toBe(false);
|
|
|
|
|
expect(shouldMigrateState(["node", "openclaw", "agents", "list"])).toBe(true);
|
|
|
|
|
expect(shouldMigrateState(["node", "openclaw", "message", "send"])).toBe(true);
|
2026-01-19 00:52:13 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("reuses command path for migrate state decisions", () => {
|
|
|
|
|
expect(shouldMigrateStateFromPath(["status"])).toBe(false);
|
2026-02-14 01:18:20 +00:00
|
|
|
expect(shouldMigrateStateFromPath(["config", "get"])).toBe(false);
|
|
|
|
|
expect(shouldMigrateStateFromPath(["models", "status"])).toBe(false);
|
2026-01-19 00:52:13 +00:00
|
|
|
expect(shouldMigrateStateFromPath(["agents", "list"])).toBe(true);
|
|
|
|
|
});
|
2026-01-18 15:56:24 -05:00
|
|
|
});
|