easyresearch 0.0.1 → 0.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/launcher.mjs +76 -0
- package/package.json +13 -8
- package/bin/easyresearch.exe +0 -4
- package/postinstall.mjs +0 -117
package/launcher.mjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runtime launcher for the `easyresearch` meta package.
|
|
3
|
+
// Resolves the platform-specific binary package (easyresearch-<os>-<arch>)
|
|
4
|
+
// from optionalDependencies and executes it with the given arguments.
|
|
5
|
+
// No install scripts, no postinstall: works on any npm version regardless
|
|
6
|
+
// of allowScripts/--ignore-scripts settings.
|
|
7
|
+
|
|
8
|
+
import { spawnSync } from "node:child_process";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
|
+
import { existsSync } from "node:fs";
|
|
11
|
+
import { dirname, join, resolve } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
const platformMap = {
|
|
18
|
+
darwin: "darwin",
|
|
19
|
+
linux: "linux",
|
|
20
|
+
win32: "windows",
|
|
21
|
+
};
|
|
22
|
+
const supportedArchs = ["x64", "arm64"];
|
|
23
|
+
|
|
24
|
+
export function missingOptionalPackageMessage(name) {
|
|
25
|
+
return `Required optional package ${name} is not installed. Run npm reinstall easyresearch and ensure optional dependencies are enabled.`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function describeSpawnFailure(result, target) {
|
|
29
|
+
if (result.error) {
|
|
30
|
+
const code = result.error.code ? ` (${result.error.code})` : "";
|
|
31
|
+
return `Failed to execute ${target}${code}: ${result.error.message}`;
|
|
32
|
+
}
|
|
33
|
+
if (result.signal) return `${target} was terminated by signal ${result.signal}.`;
|
|
34
|
+
return `${target} exited with code ${result.status ?? 1}.`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function binaryPath(name, platform) {
|
|
38
|
+
const packageJsonPath = require.resolve(`${name}/package.json`);
|
|
39
|
+
const binary = join(dirname(packageJsonPath), "bin", platform === "windows" ? "easyresearch.exe" : "easyresearch");
|
|
40
|
+
if (!existsSync(binary)) throw new Error(`The ${name} package is installed but its executable is missing at ${binary}. Reinstall easyresearch.`);
|
|
41
|
+
return binary;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function runLauncher(argv = process.argv.slice(2)) {
|
|
45
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, "package.json"), "utf8"));
|
|
46
|
+
const platform = platformMap[process.platform];
|
|
47
|
+
const arch = supportedArchs.includes(process.arch) ? process.arch : undefined;
|
|
48
|
+
const name = platform && arch ? `easyresearch-${platform}-${arch}` : undefined;
|
|
49
|
+
if (!name || !packageJson.optionalDependencies?.[name]) {
|
|
50
|
+
console.error(
|
|
51
|
+
`easyresearch does not ship a binary for ${process.platform}-${process.arch}. Supported platforms: linux-x64, darwin-arm64, windows-x64.`,
|
|
52
|
+
);
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let target;
|
|
57
|
+
try {
|
|
58
|
+
target = binaryPath(name, platform);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
const candidate = error;
|
|
61
|
+
if (candidate && typeof candidate === "object" && candidate.code === "MODULE_NOT_FOUND") {
|
|
62
|
+
console.error(missingOptionalPackageMessage(name));
|
|
63
|
+
} else {
|
|
64
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
65
|
+
}
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const result = spawnSync(target, argv, { stdio: "inherit" });
|
|
70
|
+
if (result.error || result.signal || result.status !== 0) console.error(describeSpawnFailure(result, target));
|
|
71
|
+
return result.status ?? 1;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
75
|
+
process.exit(runLauncher());
|
|
76
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easyresearch",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48",
|
|
4
4
|
"description": "Automated academic paper writing CLI built on the Pi agent harness",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,15 +14,20 @@
|
|
|
14
14
|
"ai",
|
|
15
15
|
"latex"
|
|
16
16
|
],
|
|
17
|
+
"files": [
|
|
18
|
+
"launcher.mjs",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
17
22
|
"bin": {
|
|
18
|
-
"easyresearch": "./
|
|
19
|
-
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"postinstall": "node ./postinstall.mjs"
|
|
23
|
+
"easyresearch": "./launcher.mjs"
|
|
22
24
|
},
|
|
23
25
|
"optionalDependencies": {
|
|
24
|
-
"easyresearch-linux-x64": "0.0.
|
|
25
|
-
"easyresearch-darwin-arm64": "0.0.
|
|
26
|
-
"easyresearch-windows-x64": "0.0.
|
|
26
|
+
"easyresearch-linux-x64": "0.0.48",
|
|
27
|
+
"easyresearch-darwin-arm64": "0.0.48",
|
|
28
|
+
"easyresearch-windows-x64": "0.0.48"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
32
|
}
|
|
28
33
|
}
|
package/bin/easyresearch.exe
DELETED
package/postinstall.mjs
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// postinstall for the `easyresearch` meta package.
|
|
3
|
-
// Resolves the platform-specific binary package (easyresearch-<os>-<arch>),
|
|
4
|
-
// copies the executable into ./bin/easyresearch.exe, and verifies it with
|
|
5
|
-
// `--version`.
|
|
6
|
-
//
|
|
7
|
-
// Adapted from opencode-ai (https://github.com/sst/opencode, MIT licensed)
|
|
8
|
-
// which ships a platform meta package in the same way.
|
|
9
|
-
|
|
10
|
-
import childProcess from "child_process";
|
|
11
|
-
import fs from "fs";
|
|
12
|
-
import os from "os";
|
|
13
|
-
import path from "path";
|
|
14
|
-
import { createRequire } from "module";
|
|
15
|
-
import { fileURLToPath } from "url";
|
|
16
|
-
|
|
17
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
18
|
-
const require = createRequire(import.meta.url);
|
|
19
|
-
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8"));
|
|
20
|
-
|
|
21
|
-
const platformMap = {
|
|
22
|
-
darwin: "darwin",
|
|
23
|
-
linux: "linux",
|
|
24
|
-
win32: "windows",
|
|
25
|
-
};
|
|
26
|
-
const archMap = {
|
|
27
|
-
x64: "x64",
|
|
28
|
-
arm64: "arm64",
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const platform = platformMap[os.platform()] ?? os.platform();
|
|
32
|
-
const arch = archMap[os.arch()] ?? os.arch();
|
|
33
|
-
const base = `easyresearch-${platform}-${arch}`;
|
|
34
|
-
const sourceBinary = platform === "windows" ? "easyresearch.exe" : "easyresearch";
|
|
35
|
-
const targetBinary = path.join(__dirname, "bin", "easyresearch.exe");
|
|
36
|
-
|
|
37
|
-
function packageName() {
|
|
38
|
-
// Shipped platforms (see scripts/build.ts TARGETS):
|
|
39
|
-
// linux-x64, darwin-arm64, windows-x64
|
|
40
|
-
return base;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function resolveBinary(name) {
|
|
44
|
-
const packageJsonPath = require.resolve(`${name}/package.json`);
|
|
45
|
-
const binaryPath = path.join(path.dirname(packageJsonPath), "bin", sourceBinary);
|
|
46
|
-
if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found at ${binaryPath}`);
|
|
47
|
-
return binaryPath;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function installPackage(name) {
|
|
51
|
-
const version = packageJson.optionalDependencies?.[name];
|
|
52
|
-
if (!version) return;
|
|
53
|
-
|
|
54
|
-
const temp = fs.mkdtempSync(path.join(os.tmpdir(), "easyresearch-install-"));
|
|
55
|
-
try {
|
|
56
|
-
const result = childProcess.spawnSync(
|
|
57
|
-
"npm",
|
|
58
|
-
["install", "--ignore-scripts", "--no-save", "--loglevel=error", "--prefix", temp, `${name}@${version}`],
|
|
59
|
-
{ stdio: "inherit", windowsHide: true },
|
|
60
|
-
);
|
|
61
|
-
if (result.status !== 0) return;
|
|
62
|
-
const packageDir = path.join(temp, "node_modules", name);
|
|
63
|
-
copyBinary(path.join(packageDir, "bin", sourceBinary), targetBinary);
|
|
64
|
-
return true;
|
|
65
|
-
} finally {
|
|
66
|
-
fs.rmSync(temp, { recursive: true, force: true });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function copyBinary(source, target) {
|
|
71
|
-
if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`);
|
|
72
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
73
|
-
if (fs.existsSync(target)) fs.unlinkSync(target);
|
|
74
|
-
try {
|
|
75
|
-
fs.linkSync(source, target);
|
|
76
|
-
} catch {
|
|
77
|
-
fs.copyFileSync(source, target);
|
|
78
|
-
}
|
|
79
|
-
fs.chmodSync(target, 0o755);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function verifyBinary() {
|
|
83
|
-
const result = childProcess.spawnSync(targetBinary, ["--version"], {
|
|
84
|
-
encoding: "utf8",
|
|
85
|
-
stdio: "ignore",
|
|
86
|
-
windowsHide: true,
|
|
87
|
-
});
|
|
88
|
-
return result.status === 0;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function main() {
|
|
92
|
-
const name = packageName();
|
|
93
|
-
if (!packageJson.optionalDependencies?.[name]) {
|
|
94
|
-
throw new Error(
|
|
95
|
-
`easyresearch does not ship a binary for ${platform}-${arch}. Supported platforms: linux-x64, darwin-arm64, windows-x64.`,
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
copyBinary(resolveBinary(name), targetBinary);
|
|
100
|
-
if (verifyBinary()) return;
|
|
101
|
-
} catch {
|
|
102
|
-
if (installPackage(name) && verifyBinary()) return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
throw new Error(
|
|
106
|
-
`It seems your package manager failed to install the right easyresearch binary package. Try manually installing ${JSON.stringify(
|
|
107
|
-
name,
|
|
108
|
-
)}.`,
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
main();
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.error(error.message);
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|