merge: integrate package-name setup wizard

This commit is contained in:
morluto
2026-07-18 06:15:36 +00:00
16 changed files with 331 additions and 166 deletions
+4 -1
View File
@@ -25,6 +25,9 @@ export async function verifyPackageInstall({
{ env: environment },
);
const cli = join(prefix, "bin", "rea");
const packageRunnerCli = join(prefix, "bin", "rea-agents");
if (!(await run(packageRunnerCli, ["--help"], environment)).includes("setup"))
throw new Error("packaged rea-agents alias did not expose setup");
const processCaptureCapabilityUrl = pathToFileURL(
join(
prefix,
@@ -97,5 +100,5 @@ export async function verifyPackageInstall({
throw new Error(
`packaged CLI did not degrade without the optional PTY binary: ${JSON.stringify(noOptionalCapability)}`,
);
return { cli };
return { cli, packageRunnerCli };
}
+5
View File
@@ -21,6 +21,11 @@ export async function verifyPackagePack({ root, workspace }) {
packedManifest.dependencies?.["@lydell/node-pty"] !== "1.1.0"
)
throw new Error("package retained a lifecycle-dependent PTY installation");
if (
packedManifest.bin?.rea !== "scripts/rea.mjs" ||
packedManifest.bin?.["rea-agents"] !== "scripts/rea.mjs"
)
throw new Error("package did not expose both rea command entry points");
if (
packedFiles.some(
(path) => path.includes("__pycache__") || path.endsWith(".pyc"),
+54
View File
@@ -8,6 +8,8 @@ import {
} from "node:fs/promises";
import { join } from "node:path";
import { spawn } from "@lydell/node-pty";
import { TOOL_CONTRACTS } from "../dist/contracts/toolContracts.js";
import {
json,
@@ -25,6 +27,52 @@ const verifyMcpAdd = async ({ cli, environment, npxLog }) => {
throw new Error("Incur mcp add did not register the latest npx command");
};
const verifyInteractiveSetup = async ({ command, environment, root }) =>
new Promise((resolvePromise, reject) => {
let output = "";
let cancelled = false;
let settled = false;
const terminal = spawn(command, ["setup"], {
cwd: root,
env: { ...environment, NO_COLOR: "1", TERM: "xterm-256color" },
name: "xterm-256color",
cols: 120,
rows: 40,
});
const finish = (error) => {
if (settled) return;
settled = true;
clearTimeout(timeout);
if (error === undefined) resolvePromise();
else reject(error);
};
const timeout = setTimeout(() => {
terminal.kill();
finish(
new Error(`packaged setup wizard timed out after output: ${output}`),
);
}, 20_000);
terminal.onData((data) => {
output += data;
if (!cancelled && output.includes("What should REA set up?")) {
cancelled = true;
terminal.write("\u0003");
}
});
terminal.onExit(() => {
if (!cancelled || !output.includes("No changes were made.")) {
finish(
new Error(
`packaged rea-agents setup did not open and cancel the wizard: ${output}`,
),
);
return;
}
finish();
});
});
const verifySetupPlan = async ({
cli,
environment,
@@ -308,6 +356,7 @@ const verifyUninstall = async ({
/** Verify setup transactions, skill installation, and uninstall for supported hosts. */
export async function verifyPackageSetup({
cli,
packageRunnerCli,
environment,
home,
npxLog,
@@ -319,6 +368,11 @@ export async function verifyPackageSetup({
supportedSetupHost,
root,
}) {
await verifyInteractiveSetup({
command: packageRunnerCli,
environment,
root,
});
await verifyMcpAdd({ cli, environment, npxLog });
const skillPath = join(
home,
+2 -1
View File
@@ -32,7 +32,7 @@ try {
evidenceRoot,
referenceRoot,
});
const { cli } = await verifyPackageInstall({
const { cli, packageRunnerCli } = await verifyPackageInstall({
root,
tarball,
prefix: environmentData.prefix,
@@ -80,6 +80,7 @@ try {
});
await verifyPackageSetup({
cli,
packageRunnerCli,
environment: environmentData.environment,
home: environmentData.home,
npxLog: environmentData.npxLog,