[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled

This commit is contained in:
2026-09-13 18:24:01 +08:00
commit 3c72efcb7f
3255 changed files with 907009 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
"use strict";
const test = require("node:test");
const assert = require("node:assert/strict");
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
const { prepareCommandForSpawn } = require("../ai/shellUtils.cjs");
const {
expandWindowsShimPath,
parseCursorAgentCmdLaunch,
resolveCursorAgentNativeLaunch,
resolveCursorAgentVersionsLaunch,
resolveCursorCliSpawnSpec,
} = require("./cursorCliSpawn.cjs");
function writeCursorAgentInstall(root, version = "2026.06.01-abc") {
const versionDir = path.join(root, "versions", version);
fs.mkdirSync(versionDir, { recursive: true });
const nodeExe = path.join(versionDir, "node.exe");
const script = path.join(versionDir, "index.js");
fs.writeFileSync(nodeExe, "", "utf8");
fs.writeFileSync(script, "", "utf8");
const shimPath = path.join(root, "cursor-agent.cmd");
fs.writeFileSync(
shimPath,
`@ECHO off\r\n"%~dp0\\versions\\${version}\\node.exe" "%~dp0\\versions\\${version}\\index.js" %*\r\n`,
"utf8",
);
return { shimPath, nodeExe, script, versionDir };
}
test("expandWindowsShimPath expands %~dp0 relative to the shim directory", () => {
const shimDir = path.join("C:", "Users", "me", "AppData", "Local", "cursor-agent");
const resolved = expandWindowsShimPath("%~dp0\\versions\\2026.06.01-abc\\node.exe", shimDir);
assert.equal(
path.normalize(resolved),
path.normalize(path.join(shimDir, "versions", "2026.06.01-abc", "node.exe")),
);
});
test("parseCursorAgentCmdLaunch reads node.exe + index.js from the installer shim", () => {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-cursor-shim-"));
try {
const { shimPath, nodeExe, script } = writeCursorAgentInstall(tmp);
const launch = parseCursorAgentCmdLaunch(shimPath);
assert.deepEqual(launch, { nodeExe, script });
} finally {
fs.rmSync(tmp, { recursive: true, force: true });
}
});
test("resolveCursorAgentVersionsLaunch picks the newest version directory", () => {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-cursor-versions-"));
try {
const older = writeCursorAgentInstall(tmp, "2026.01.01-old");
const newer = writeCursorAgentInstall(tmp, "2026.08.01-new");
const olderTime = new Date("2026-01-01T00:00:00Z");
const newerTime = new Date("2026-08-01T00:00:00Z");
fs.utimesSync(older.versionDir, olderTime, olderTime);
fs.utimesSync(newer.versionDir, newerTime, newerTime);
const launch = resolveCursorAgentVersionsLaunch(tmp);
assert.deepEqual(launch, { nodeExe: newer.nodeExe, script: newer.script });
} finally {
fs.rmSync(tmp, { recursive: true, force: true });
}
});
test("resolveCursorAgentNativeLaunch prefers the shim's node+script over a lone exe unwrap", () => {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-cursor-native-"));
try {
const { shimPath, nodeExe, script } = writeCursorAgentInstall(tmp);
const launch = resolveCursorAgentNativeLaunch(shimPath);
assert.deepEqual(launch, { nodeExe, script });
} finally {
fs.rmSync(tmp, { recursive: true, force: true });
}
});
test("resolveCursorCliSpawnSpec puts the prompt on argv, not a cmd.exe line", () => {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-cursor-spawn-"));
try {
const { shimPath, nodeExe, script } = writeCursorAgentInstall(tmp);
const prompt = 'do "%USERPROFILE%" and `whoami` then say hello';
const spec = resolveCursorCliSpawnSpec(shimPath, ["--print", "--trust", prompt]);
assert.deepEqual(spec, {
command: nodeExe,
args: [script, "--print", "--trust", prompt],
shell: false,
});
assert.equal(spec.command.includes("cmd.exe"), false);
assert.equal(spec.args.includes(prompt), true);
} finally {
fs.rmSync(tmp, { recursive: true, force: true });
}
});
test("resolveCursorCliSpawnSpec falls back to the cmd shim when versions/ is missing", () => {
const shim = "C:\\Users\\me\\AppData\\Local\\cursor-agent\\cursor-agent.cmd";
const args = ["status", "--format", "json"];
const spec = resolveCursorCliSpawnSpec(shim, args, {
exists: () => false,
readFile: () => { throw new Error("missing"); },
});
assert.deepEqual(spec, prepareCommandForSpawn(shim, args, { unwrapNativeExe: false }));
});