revert: Switch back to tsc for compiling.

This commit is contained in:
cpojer
2026-01-31 18:31:49 +09:00
parent e25fedf932
commit 76361ae3ab
36 changed files with 527 additions and 843 deletions

View File

@@ -24,7 +24,7 @@ describe("ensureSkillsWatcher", () => {
expect(ignored.some((re) => re.test("/tmp/workspace/skills/node_modules/pkg/index.js"))).toBe(
true,
);
expect(ignored.some((re) => re.test("/tmp/workspace/skills/dist/index.mjs"))).toBe(true);
expect(ignored.some((re) => re.test("/tmp/workspace/skills/dist/index.js"))).toBe(true);
expect(ignored.some((re) => re.test("/tmp/workspace/skills/.git/config"))).toBe(true);
expect(ignored.some((re) => re.test("/tmp/.hidden/skills/index.md"))).toBe(false);
});

View File

@@ -43,7 +43,7 @@ describe("browser CLI --browser-profile flag", () => {
});
it("does not conflict with global --profile flag", () => {
// The global --profile flag is handled by entry.mjs before Commander
// The global --profile flag is handled by /entry.js before Commander
// This test verifies --browser-profile is a separate option
const program = new Command();
program.name("test");

View File

@@ -4,22 +4,22 @@ import { rewriteUpdateFlagArgv } from "./run-main.js";
describe("rewriteUpdateFlagArgv", () => {
it("leaves argv unchanged when --update is absent", () => {
const argv = ["node", "entry.mjs", "status"];
const argv = ["node", "entry.js", "status"];
expect(rewriteUpdateFlagArgv(argv)).toBe(argv);
});
it("rewrites --update into the update command", () => {
expect(rewriteUpdateFlagArgv(["node", "entry.mjs", "--update"])).toEqual([
expect(rewriteUpdateFlagArgv(["node", "entry.js", "--update"])).toEqual([
"node",
"entry.mjs",
"entry.js",
"update",
]);
});
it("preserves global flags that appear before --update", () => {
expect(rewriteUpdateFlagArgv(["node", "entry.mjs", "--profile", "p", "--update"])).toEqual([
expect(rewriteUpdateFlagArgv(["node", "entry.js", "--profile", "p", "--update"])).toEqual([
"node",
"entry.mjs",
"entry.js",
"--profile",
"p",
"update",
@@ -27,9 +27,9 @@ describe("rewriteUpdateFlagArgv", () => {
});
it("keeps update options after the rewritten command", () => {
expect(rewriteUpdateFlagArgv(["node", "entry.mjs", "--update", "--json"])).toEqual([
expect(rewriteUpdateFlagArgv(["node", "entry.js", "--update", "--json"])).toEqual([
"node",
"entry.mjs",
"entry.js",
"update",
"--json",
]);

View File

@@ -747,7 +747,7 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
let afterVersion = beforeVersion;
if (pkgRoot) {
afterVersion = await readPackageVersion(pkgRoot);
const entryPath = path.join(pkgRoot, "dist", "entry.mjs");
const entryPath = path.join(pkgRoot, "dist", "entry.js");
if (await pathExists(entryPath)) {
const doctorStep = await runUpdateStep({
name: `${CLI_NAME} doctor`,
@@ -969,7 +969,9 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
try {
const { doctorCommand } = await import("../commands/doctor.js");
const interactiveDoctor = Boolean(process.stdin.isTTY) && !opts.json && opts.yes !== true;
await doctorCommand(defaultRuntime, { nonInteractive: !interactiveDoctor });
await doctorCommand(defaultRuntime, {
nonInteractive: !interactiveDoctor,
});
} catch (err) {
defaultRuntime.log(theme.warn(`Doctor failed: ${String(err)}`));
} finally {
@@ -1220,7 +1222,9 @@ ${theme.muted("Docs:")} ${formatDocsLink("/cli/update", "docs.openclaw.ai/cli/up
)
.action(async (opts) => {
try {
await updateWizardCommand({ timeout: opts.timeout as string | undefined });
await updateWizardCommand({
timeout: opts.timeout as string | undefined,
});
} catch (err) {
defaultRuntime.error(String(err));
defaultRuntime.exit(1);

View File

@@ -103,7 +103,12 @@ vi.mock("../memory/manager.js", () => ({
sourceCounts: [{ source: "memory", files: 2, chunks: 3 }],
cache: { enabled: true, entries: 10, maxEntries: 500 },
fts: { enabled: true, available: true },
vector: { enabled: true, available: true, extensionPath: "/opt/vec0.dylib", dims: 1024 },
vector: {
enabled: true,
available: true,
extensionPath: "/opt/vec0.dylib",
dims: 1024,
},
}),
close: vi.fn(async () => {}),
__agentId: agentId,
@@ -254,7 +259,7 @@ vi.mock("../daemon/service.js", () => ({
isLoaded: async () => true,
readRuntime: async () => ({ status: "running", pid: 1234 }),
readCommand: async () => ({
programArguments: ["node", "dist/entry.mjs", "gateway"],
programArguments: ["node", "dist/entry.js", "gateway"],
sourcePath: "/tmp/Library/LaunchAgents/bot.molt.gateway.plist",
}),
}),
@@ -267,7 +272,7 @@ vi.mock("../daemon/node-service.js", () => ({
isLoaded: async () => true,
readRuntime: async () => ({ status: "running", pid: 4321 }),
readCommand: async () => ({
programArguments: ["node", "dist/entry.mjs", "node-host"],
programArguments: ["node", "dist/entry.js", "node-host"],
sourcePath: "/tmp/Library/LaunchAgents/bot.molt.node.plist",
}),
}),

View File

@@ -24,7 +24,7 @@ afterEach(() => {
describe("resolveGatewayProgramArguments", () => {
it("uses realpath-resolved dist entry when running via npx shim", async () => {
const argv1 = path.resolve("/tmp/.npm/_npx/63c3/node_modules/.bin/openclaw");
const entryPath = path.resolve("/tmp/.npm/_npx/63c3/node_modules/openclaw/dist/entry.mjs");
const entryPath = path.resolve("/tmp/.npm/_npx/63c3/node_modules/openclaw/dist/entry.js");
process.argv = ["node", argv1];
fsMocks.realpath.mockResolvedValue(entryPath);
fsMocks.access.mockImplementation(async (target: string) => {
@@ -49,10 +49,10 @@ describe("resolveGatewayProgramArguments", () => {
// Simulates pnpm global install where node_modules/openclaw is a symlink
// to .pnpm/openclaw@X.Y.Z/node_modules/openclaw
const symlinkPath = path.resolve(
"/Users/test/Library/pnpm/global/5/node_modules/openclaw/dist/entry.mjs",
"/Users/test/Library/pnpm/global/5/node_modules/openclaw/dist/entry.js",
);
const realpathResolved = path.resolve(
"/Users/test/Library/pnpm/global/5/node_modules/.pnpm/openclaw@2026.1.21-2/node_modules/openclaw/dist/entry.mjs",
"/Users/test/Library/pnpm/global/5/node_modules/.pnpm/openclaw@2026.1.21-2/node_modules/openclaw/dist/entry.js",
);
process.argv = ["node", symlinkPath];
fsMocks.realpath.mockResolvedValue(realpathResolved);
@@ -67,7 +67,7 @@ describe("resolveGatewayProgramArguments", () => {
it("falls back to node_modules package dist when .bin path is not resolved", async () => {
const argv1 = path.resolve("/tmp/.npm/_npx/63c3/node_modules/.bin/openclaw");
const indexPath = path.resolve("/tmp/.npm/_npx/63c3/node_modules/openclaw/dist/index.mjs");
const indexPath = path.resolve("/tmp/.npm/_npx/63c3/node_modules/openclaw/dist/index.js");
process.argv = ["node", argv1];
fsMocks.realpath.mockRejectedValue(new Error("no realpath"));
fsMocks.access.mockImplementation(async (target: string) => {

View File

@@ -47,7 +47,7 @@ export async function resolveControlUiDistIndexPath(
}
const normalized = path.resolve(argv1);
// Case 1: entrypoint is directly inside dist/ (e.g., dist/entry.mjs)
// Case 1: entrypoint is directly inside dist/ (e.g., dist/entry.js)
const distDir = path.dirname(normalized);
if (path.basename(distDir) === "dist") {
return path.join(distDir, "control-ui", "index.html");

View File

@@ -73,8 +73,8 @@ function isGatewayArgv(args: string[]): boolean {
}
const entryCandidates = [
"dist/index.mjs",
"dist/entry.mjs",
"dist/index.js",
"dist/entry.js",
"openclaw.mjs",
"scripts/run-node.mjs",
"src/index.ts",

View File

@@ -6,8 +6,8 @@ describe("isMainModule", () => {
it("returns true when argv[1] matches current file", () => {
expect(
isMainModule({
currentFile: "/repo/dist/index.mjs",
argv: ["node", "/repo/dist/index.mjs"],
currentFile: "/repo/dist/index.js",
argv: ["node", "/repo/dist/index.js"],
cwd: "/repo",
env: {},
}),
@@ -17,10 +17,10 @@ describe("isMainModule", () => {
it("returns true under PM2 when pm_exec_path matches current file", () => {
expect(
isMainModule({
currentFile: "/repo/dist/index.mjs",
currentFile: "/repo/dist/index.js",
argv: ["node", "/pm2/lib/ProcessContainerFork.js"],
cwd: "/repo",
env: { pm_exec_path: "/repo/dist/index.mjs", pm_id: "0" },
env: { pm_exec_path: "/repo/dist/index.js", pm_id: "0" },
}),
).toBe(true);
});
@@ -28,7 +28,7 @@ describe("isMainModule", () => {
it("returns false when running under PM2 but this module is imported", () => {
expect(
isMainModule({
currentFile: "/repo/node_modules/openclaw/dist/index.mjs",
currentFile: "/repo/node_modules/openclaw/dist/index.js",
argv: ["node", "/repo/app.js"],
cwd: "/repo",
env: { pm_exec_path: "/repo/app.js", pm_id: "0" },

View File

@@ -37,7 +37,7 @@ describe("ports helpers", () => {
expect(
classifyPortListener(
{
commandLine: "node /Users/me/Projects/openclaw/dist/entry.mjs gateway",
commandLine: "node /Users/me/Projects/openclaw/dist/entry.js gateway",
},
18789,
),

View File

@@ -102,11 +102,11 @@ describe("installPluginFromArchive", () => {
JSON.stringify({
name: "@openclaw/voice-call",
version: "0.0.1",
openclaw: { extensions: ["./dist/index.mjs"] },
openclaw: { extensions: ["./dist/index.js"] },
}),
"utf-8",
);
fs.writeFileSync(path.join(pkgDir, "dist", "index.mjs"), "export {};", "utf-8");
fs.writeFileSync(path.join(pkgDir, "dist", "index.js"), "export {};", "utf-8");
const archivePath = packToArchive({
pkgDir,
@@ -127,7 +127,7 @@ describe("installPluginFromArchive", () => {
expect(result.pluginId).toBe("voice-call");
expect(result.targetDir).toBe(path.join(stateDir, "extensions", "voice-call"));
expect(fs.existsSync(path.join(result.targetDir, "package.json"))).toBe(true);
expect(fs.existsSync(path.join(result.targetDir, "dist", "index.mjs"))).toBe(true);
expect(fs.existsSync(path.join(result.targetDir, "dist", "index.js"))).toBe(true);
});
it("rejects installing when plugin already exists", async () => {
@@ -140,7 +140,7 @@ describe("installPluginFromArchive", () => {
JSON.stringify({
name: "@openclaw/voice-call",
version: "0.0.1",
openclaw: { extensions: ["./dist/index.mjs"] },
openclaw: { extensions: ["./dist/index.js"] },
}),
"utf-8",
);
@@ -182,10 +182,10 @@ describe("installPluginFromArchive", () => {
JSON.stringify({
name: "@openclaw/zipper",
version: "0.0.1",
openclaw: { extensions: ["./dist/index.mjs"] },
openclaw: { extensions: ["./dist/index.js"] },
}),
);
zip.file("package/dist/index.mjs", "export {};");
zip.file("package/dist/index.js", "export {};");
const buffer = await zip.generateAsync({ type: "nodebuffer" });
fs.writeFileSync(archivePath, buffer);
@@ -203,7 +203,7 @@ describe("installPluginFromArchive", () => {
expect(result.pluginId).toBe("zipper");
expect(result.targetDir).toBe(path.join(stateDir, "extensions", "zipper"));
expect(fs.existsSync(path.join(result.targetDir, "package.json"))).toBe(true);
expect(fs.existsSync(path.join(result.targetDir, "dist", "index.mjs"))).toBe(true);
expect(fs.existsSync(path.join(result.targetDir, "dist", "index.js"))).toBe(true);
});
it("allows updates when mode is update", async () => {
@@ -216,7 +216,7 @@ describe("installPluginFromArchive", () => {
JSON.stringify({
name: "@openclaw/voice-call",
version: "0.0.1",
openclaw: { extensions: ["./dist/index.mjs"] },
openclaw: { extensions: ["./dist/index.js"] },
}),
"utf-8",
);
@@ -234,7 +234,7 @@ describe("installPluginFromArchive", () => {
JSON.stringify({
name: "@openclaw/voice-call",
version: "0.0.2",
openclaw: { extensions: ["./dist/index.mjs"] },
openclaw: { extensions: ["./dist/index.js"] },
}),
"utf-8",
);