plumb-lang 0.0.0-stage → 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Szymon Prajs and Plumb contributors
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,3 +1,23 @@
1
- # Temporary Holding Version
1
+ # plumb-lang
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ CLI installer and runner for **[Plumb](https://plumb-lang.sh)** — a strict referee for empirical and theoretical physics.
4
+
5
+ ## Install & Run
6
+
7
+ ```sh
8
+ npm install -g plumb-lang
9
+ plumb --version
10
+ ```
11
+
12
+ Or run directly with `npx`:
13
+
14
+ ```sh
15
+ npx plumb-lang --version
16
+ npx plumb-lang doc quickstart
17
+ ```
18
+
19
+ On install (or first run), this package downloads the prebuilt native `plumb` binary for your platform from [GitHub Releases](https://github.com/sprajs/plumb/releases), verifies its SHA-256 checksum, and runs it natively.
20
+
21
+ - Website & Docs: https://plumb-lang.sh
22
+ - Repository: https://github.com/sprajs/plumb
23
+ - License: BSD-3-Clause
package/bin/plumb.js ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { spawnSync } = require('node:child_process');
5
+ const { ensureBinary } = require('../lib/install.js');
6
+
7
+ (async () => {
8
+ try {
9
+ const bin = await ensureBinary();
10
+ const res = spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' });
11
+ if (res.error) throw res.error;
12
+ process.exit(res.status ?? 1);
13
+ } catch (err) {
14
+ console.error(`[plumb-lang] ${err.message}`);
15
+ process.exit(1);
16
+ }
17
+ })();
package/lib/install.js ADDED
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const crypto = require('node:crypto');
5
+ const fs = require('node:fs');
6
+ const https = require('node:https');
7
+ const os = require('node:os');
8
+ const path = require('node:path');
9
+ const { execFileSync } = require('node:child_process');
10
+
11
+ const VERSION = '0.0.1';
12
+ const BASE_URL = `https://github.com/sprajs/plumb/releases/download/v${VERSION}`;
13
+
14
+ const ARTIFACTS = {
15
+ 'darwin-arm64': {
16
+ file: 'plumb-aarch64-apple-darwin.tar.xz',
17
+ sha256: '90a18f25954300d717006e73b0c6c7f54bfbf42ddbb2b1256395bcae622191ac',
18
+ ext: 'tar.xz',
19
+ },
20
+ 'darwin-x64': {
21
+ file: 'plumb-x86_64-apple-darwin.tar.xz',
22
+ sha256: 'cd48204a45c94ba173467119ffb869c4f6b06eca29c89bc78aec10e08c3231a3',
23
+ ext: 'tar.xz',
24
+ },
25
+ 'linux-x64': {
26
+ file: 'plumb-x86_64-unknown-linux-musl.tar.xz',
27
+ sha256: '6b22720960d9abaabb4eae9096003ba19488c6190117174f59d8bea5981e1168',
28
+ ext: 'tar.xz',
29
+ },
30
+ 'linux-arm64': {
31
+ file: 'plumb-aarch64-unknown-linux-musl.tar.xz',
32
+ sha256: 'ad6dffc2de6d0a2eece38b07260f77e9a5941240bf9876a0cdc9991ae7d0e2a6',
33
+ ext: 'tar.xz',
34
+ },
35
+ 'win32-x64': {
36
+ file: 'plumb-x86_64-pc-windows-msvc.zip',
37
+ sha256: 'aa3743f595f03fa7b08aac05984aa922888225a4bd767901221a356caa15839d',
38
+ ext: 'zip',
39
+ },
40
+ 'win32-arm64': {
41
+ file: 'plumb-aarch64-pc-windows-msvc.zip',
42
+ sha256: 'a2f4dc8024983d86c3204d7edc535a77c68145647b349c581c0184e41f29aabf',
43
+ ext: 'zip',
44
+ },
45
+ };
46
+
47
+ function binaryPath() {
48
+ const binName = process.platform === 'win32' ? 'plumb.exe' : 'plumb';
49
+ return path.join(__dirname, '..', 'vendor', binName);
50
+ }
51
+
52
+ function download(url, dest, redirects = 0) {
53
+ if (redirects > 5) return Promise.reject(new Error('Too many redirects'));
54
+ return new Promise((resolve, reject) => {
55
+ https
56
+ .get(url, { headers: { 'User-Agent': `plumb-lang-npm/${VERSION}` } }, (res) => {
57
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
58
+ res.resume();
59
+ resolve(download(res.headers.location, dest, redirects + 1));
60
+ return;
61
+ }
62
+ if (res.statusCode !== 200) {
63
+ res.resume();
64
+ reject(new Error(`Failed to download ${url}: HTTP ${res.statusCode}`));
65
+ return;
66
+ }
67
+ const out = fs.createWriteStream(dest);
68
+ res.pipe(out);
69
+ out.on('finish', () => out.close(resolve));
70
+ out.on('error', reject);
71
+ })
72
+ .on('error', reject);
73
+ });
74
+ }
75
+
76
+ function sha256File(filePath) {
77
+ return crypto.createHash('sha256').update(fs.readFileSync(filePath)).digest('hex');
78
+ }
79
+
80
+ function findFile(dir, targetName) {
81
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
82
+ const full = path.join(dir, entry.name);
83
+ if (entry.isDirectory()) {
84
+ const hit = findFile(full, targetName);
85
+ if (hit) return hit;
86
+ } else if (entry.name === targetName) {
87
+ return full;
88
+ }
89
+ }
90
+ return null;
91
+ }
92
+
93
+ async function ensureBinary() {
94
+ const destBin = binaryPath();
95
+ if (fs.existsSync(destBin)) return destBin;
96
+
97
+ const key = `${process.platform}-${process.arch}`;
98
+ const spec = ARTIFACTS[key];
99
+ if (!spec) {
100
+ throw new Error(
101
+ `Unsupported platform ${key}. Download a release archive from https://github.com/sprajs/plumb/releases/tag/v${VERSION}`,
102
+ );
103
+ }
104
+
105
+ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'plumb-lang-'));
106
+ const archivePath = path.join(tmpDir, spec.file);
107
+ const extractDir = path.join(tmpDir, 'out');
108
+ fs.mkdirSync(extractDir);
109
+
110
+ try {
111
+ await download(`${BASE_URL}/${spec.file}`, archivePath);
112
+ const actual = sha256File(archivePath);
113
+ if (actual !== spec.sha256) {
114
+ throw new Error(`SHA-256 mismatch for ${spec.file}: expected ${spec.sha256}, got ${actual}`);
115
+ }
116
+
117
+ if (spec.ext === 'zip') {
118
+ execFileSync(
119
+ 'powershell',
120
+ ['-NoProfile', '-Command', `Expand-Archive -Path '${archivePath}' -DestinationPath '${extractDir}' -Force`],
121
+ { stdio: 'inherit' },
122
+ );
123
+ } else {
124
+ execFileSync('tar', ['-xJf', archivePath, '-C', extractDir], { stdio: 'inherit' });
125
+ }
126
+
127
+ const binName = process.platform === 'win32' ? 'plumb.exe' : 'plumb';
128
+ const extracted = findFile(extractDir, binName);
129
+ if (!extracted) throw new Error(`Could not find ${binName} in ${spec.file}`);
130
+
131
+ fs.mkdirSync(path.dirname(destBin), { recursive: true });
132
+ fs.copyFileSync(extracted, destBin);
133
+ if (process.platform !== 'win32') fs.chmodSync(destBin, 0o755);
134
+ return destBin;
135
+ } finally {
136
+ fs.rmSync(tmpDir, { recursive: true, force: true });
137
+ }
138
+ }
139
+
140
+ module.exports = { ensureBinary, binaryPath };
141
+
142
+ if (require.main === module) {
143
+ ensureBinary().catch((err) => {
144
+ console.error(`[plumb-lang] ${err.message}`);
145
+ process.exit(1);
146
+ });
147
+ }
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "plumb-lang",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "A strict referee for empirical and theoretical physics — native CLI wrapper for Plumb",
5
+ "homepage": "https://plumb-lang.sh",
6
+ "license": "BSD-3-Clause",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/sprajs/plumb.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/sprajs/plumb/issues"
13
+ },
14
+ "keywords": [
15
+ "plumb",
16
+ "physics",
17
+ "formal-verification",
18
+ "lean4",
19
+ "cosmology",
20
+ "science",
21
+ "statistics",
22
+ "cli"
23
+ ],
24
+ "bin": {
25
+ "plumb": "bin/plumb.js",
26
+ "plumb-lang": "bin/plumb.js"
27
+ },
28
+ "scripts": {
29
+ "postinstall": "node lib/install.js"
30
+ },
31
+ "files": [
32
+ "bin/plumb.js",
33
+ "lib/install.js",
34
+ "README.md",
35
+ "LICENSE"
36
+ ],
37
+ "engines": {
38
+ "node": ">=18"
39
+ }
40
+ }