allem 1.0.0

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/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # allem (npm wrapper)
2
+
3
+ Run **[Allem](https://github.com/walkowicz19/allem)** — polyglot codebase & dependency intelligence —
4
+ with no install and no Rust toolchain:
5
+
6
+ ```sh
7
+ npx allem analyze .
8
+ ```
9
+
10
+ On first run this downloads a small prebuilt binary for your platform from Allem's GitHub
11
+ Releases and caches it; subsequent runs are instant. The native CLI does all the work — this
12
+ package is just a thin launcher.
13
+
14
+ Supported platforms: Linux x64, macOS x64/arm64, Windows x64. On other platforms, build from
15
+ source: `cargo install --git https://github.com/walkowicz19/allem allem-cli`.
16
+
17
+ See the [main README](https://github.com/walkowicz19/allem) for full usage and the MCP server.
18
+
19
+ ## License
20
+
21
+ MIT OR Apache-2.0
package/bin/allem.js ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ // Thin launcher: ensure the platform binary is present (download on first run), then exec it
3
+ // with the user's arguments and stdio inherited (so `allem mcp` works over stdio).
4
+
5
+ "use strict";
6
+
7
+ const { spawnSync } = require("child_process");
8
+ const { ensureBinary } = require("../scripts/download.js");
9
+
10
+ (async () => {
11
+ let binary;
12
+ try {
13
+ binary = await ensureBinary();
14
+ } catch (err) {
15
+ console.error(`allem: failed to obtain the binary: ${err.message}`);
16
+ process.exit(1);
17
+ }
18
+
19
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
20
+ if (result.error) {
21
+ console.error(`allem: ${result.error.message}`);
22
+ process.exit(1);
23
+ }
24
+ process.exit(result.status === null ? 1 : result.status);
25
+ })();
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "allem",
3
+ "version": "1.0.0",
4
+ "description": "Polyglot codebase & dependency intelligence — run with `npx allem`. Downloads a small prebuilt binary for your platform.",
5
+ "bin": {
6
+ "allem": "bin/allem.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node scripts/download.js"
10
+ },
11
+ "files": [
12
+ "bin/",
13
+ "scripts/"
14
+ ],
15
+ "engines": {
16
+ "node": ">=16"
17
+ },
18
+ "keywords": [
19
+ "static-analysis",
20
+ "dependencies",
21
+ "security",
22
+ "polyglot",
23
+ "mcp",
24
+ "cli"
25
+ ],
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/walkowicz19/allem"
30
+ }
31
+ }
@@ -0,0 +1,116 @@
1
+ // Resolves the Allem binary for the current platform, downloading a prebuilt release asset
2
+ // from GitHub Releases on first use and caching it under the package's vendor/ dir.
3
+ //
4
+ // Used two ways:
5
+ // - as a best-effort `postinstall` (pre-warms the cache; never fails the install)
6
+ // - lazily from bin/allem.js on first run (so `npx allem` works even with --ignore-scripts)
7
+ //
8
+ // No third-party dependencies — Node built-ins only. Release assets are single binaries
9
+ // gzip-compressed (decompressed here with zlib), so no tar/unzip is required.
10
+
11
+ "use strict";
12
+
13
+ const fs = require("fs");
14
+ const path = require("path");
15
+ const https = require("https");
16
+ const zlib = require("zlib");
17
+
18
+ const pkg = require("../package.json");
19
+
20
+ const TAG = process.env.ALLEM_RELEASE_TAG || `v${pkg.version}`;
21
+ const BASE =
22
+ process.env.ALLEM_DOWNLOAD_BASE ||
23
+ `https://github.com/walkowicz19/allem/releases/download/${TAG}`;
24
+
25
+ // Maps Node platform-arch → the release asset name produced by .github/workflows/release.yml.
26
+ const ASSETS = {
27
+ "linux-x64": "allem-linux-x64.gz",
28
+ "darwin-x64": "allem-darwin-x64.gz",
29
+ "darwin-arm64": "allem-darwin-arm64.gz",
30
+ "win32-x64": "allem-win32-x64.exe.gz",
31
+ };
32
+
33
+ function assetName() {
34
+ const key = `${process.platform}-${process.arch}`;
35
+ const asset = ASSETS[key];
36
+ if (!asset) {
37
+ throw new Error(
38
+ `unsupported platform '${key}'. Build from source instead: ` +
39
+ `cargo install --git https://github.com/walkowicz19/allem allem-cli`
40
+ );
41
+ }
42
+ return asset;
43
+ }
44
+
45
+ function binName() {
46
+ return process.platform === "win32" ? "allem.exe" : "allem";
47
+ }
48
+
49
+ function vendorDir() {
50
+ return path.join(__dirname, "..", "vendor");
51
+ }
52
+
53
+ function binPath() {
54
+ return path.join(vendorDir(), binName());
55
+ }
56
+
57
+ // GET with redirect following (GitHub release downloads redirect to object storage).
58
+ function get(url) {
59
+ return new Promise((resolve, reject) => {
60
+ https
61
+ .get(url, { headers: { "User-Agent": "allem-npm" } }, (res) => {
62
+ const { statusCode, headers } = res;
63
+ if (statusCode >= 300 && statusCode < 400 && headers.location) {
64
+ res.resume();
65
+ resolve(get(headers.location));
66
+ return;
67
+ }
68
+ if (statusCode !== 200) {
69
+ res.resume();
70
+ reject(new Error(`HTTP ${statusCode} for ${url}`));
71
+ return;
72
+ }
73
+ resolve(res);
74
+ })
75
+ .on("error", reject);
76
+ });
77
+ }
78
+
79
+ // Returns the path to a ready-to-run binary, downloading + decompressing it if absent.
80
+ async function ensureBinary() {
81
+ const target = binPath();
82
+ if (fs.existsSync(target)) {
83
+ return target;
84
+ }
85
+ fs.mkdirSync(vendorDir(), { recursive: true });
86
+
87
+ const url = `${BASE}/${assetName()}`;
88
+ const res = await get(url);
89
+ const tmp = `${target}.tmp`;
90
+
91
+ await new Promise((resolve, reject) => {
92
+ const out = fs.createWriteStream(tmp);
93
+ res.on("error", reject);
94
+ out.on("error", reject);
95
+ out.on("finish", resolve);
96
+ res.pipe(zlib.createGunzip()).on("error", reject).pipe(out);
97
+ });
98
+
99
+ fs.renameSync(tmp, target);
100
+ if (process.platform !== "win32") {
101
+ fs.chmodSync(target, 0o755);
102
+ }
103
+ return target;
104
+ }
105
+
106
+ module.exports = { ensureBinary, binPath, assetName };
107
+
108
+ // postinstall: best-effort pre-download. Never fail `npm install` over it.
109
+ if (require.main === module) {
110
+ ensureBinary().catch((err) => {
111
+ console.warn(
112
+ `allem: could not pre-download the binary (${err.message}). ` +
113
+ `It will be fetched on first run.`
114
+ );
115
+ });
116
+ }