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>
126 lines
3.2 KiB
TypeScript
126 lines
3.2 KiB
TypeScript
import fsSync from "node:fs";
|
|
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const CORE_PACKAGE_NAMES = new Set(["openclaw", "ironclaw"]);
|
|
|
|
async function readPackageName(dir: string): Promise<string | null> {
|
|
try {
|
|
const raw = await fs.readFile(path.join(dir, "package.json"), "utf-8");
|
|
const parsed = JSON.parse(raw) as { name?: unknown };
|
|
return typeof parsed.name === "string" ? parsed.name : null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function readPackageNameSync(dir: string): string | null {
|
|
try {
|
|
const raw = fsSync.readFileSync(path.join(dir, "package.json"), "utf-8");
|
|
const parsed = JSON.parse(raw) as { name?: unknown };
|
|
return typeof parsed.name === "string" ? parsed.name : null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
async function findPackageRoot(startDir: string, maxDepth = 12): Promise<string | null> {
|
|
let current = path.resolve(startDir);
|
|
for (let i = 0; i < maxDepth; i += 1) {
|
|
const name = await readPackageName(current);
|
|
if (name && CORE_PACKAGE_NAMES.has(name)) {
|
|
return current;
|
|
}
|
|
const parent = path.dirname(current);
|
|
if (parent === current) {
|
|
break;
|
|
}
|
|
current = parent;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function findPackageRootSync(startDir: string, maxDepth = 12): string | null {
|
|
let current = path.resolve(startDir);
|
|
for (let i = 0; i < maxDepth; i += 1) {
|
|
const name = readPackageNameSync(current);
|
|
if (name && CORE_PACKAGE_NAMES.has(name)) {
|
|
return current;
|
|
}
|
|
const parent = path.dirname(current);
|
|
if (parent === current) {
|
|
break;
|
|
}
|
|
current = parent;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function candidateDirsFromArgv1(argv1: string): string[] {
|
|
const normalized = path.resolve(argv1);
|
|
const candidates = [path.dirname(normalized)];
|
|
const parts = normalized.split(path.sep);
|
|
const binIndex = parts.lastIndexOf(".bin");
|
|
if (binIndex > 0 && parts[binIndex - 1] === "node_modules") {
|
|
const binName = path.basename(normalized);
|
|
const nodeModulesDir = parts.slice(0, binIndex).join(path.sep);
|
|
candidates.push(path.join(nodeModulesDir, binName));
|
|
}
|
|
return candidates;
|
|
}
|
|
|
|
export async function resolveOpenClawPackageRoot(opts: {
|
|
cwd?: string;
|
|
argv1?: string;
|
|
moduleUrl?: string;
|
|
}): Promise<string | null> {
|
|
const candidates: string[] = [];
|
|
|
|
if (opts.moduleUrl) {
|
|
candidates.push(path.dirname(fileURLToPath(opts.moduleUrl)));
|
|
}
|
|
if (opts.argv1) {
|
|
candidates.push(...candidateDirsFromArgv1(opts.argv1));
|
|
}
|
|
if (opts.cwd) {
|
|
candidates.push(opts.cwd);
|
|
}
|
|
|
|
for (const candidate of candidates) {
|
|
const found = await findPackageRoot(candidate);
|
|
if (found) {
|
|
return found;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
export function resolveOpenClawPackageRootSync(opts: {
|
|
cwd?: string;
|
|
argv1?: string;
|
|
moduleUrl?: string;
|
|
}): string | null {
|
|
const candidates: string[] = [];
|
|
|
|
if (opts.moduleUrl) {
|
|
candidates.push(path.dirname(fileURLToPath(opts.moduleUrl)));
|
|
}
|
|
if (opts.argv1) {
|
|
candidates.push(...candidateDirsFromArgv1(opts.argv1));
|
|
}
|
|
if (opts.cwd) {
|
|
candidates.push(opts.cwd);
|
|
}
|
|
|
|
for (const candidate of candidates) {
|
|
const found = findPackageRootSync(candidate);
|
|
if (found) {
|
|
return found;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|