@spuentesp/lain-mcp 0.4.2 → 0.5.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/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@spuentesp/lain-mcp",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "mcpName": "io.github.spuentesp/lain",
5
- "description": "Lain - Architectural code intelligence for AI coding agents",
5
+ "description": "Wird - Architectural code intelligence for AI coding agents",
6
6
  "keywords": ["mcp", "code-intelligence", "architectural-analysis", "lain"],
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/spuentesp/lain",
@@ -14,7 +14,8 @@
14
14
  "lain": "./bin/lain.js"
15
15
  },
16
16
  "files": [
17
- "bin/"
17
+ "bin/",
18
+ "scripts/"
18
19
  ],
19
20
  "os": [
20
21
  "darwin",
@@ -0,0 +1,264 @@
1
+ #!/usr/bin/env node
2
+ // postinstall script — downloads the Lain binary and creates ~/.lain/ structure
3
+
4
+ const { execSync, spawnSync } = require('child_process');
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ const LAIN_DIR = path.join(process.env.HOME, '.lain');
9
+ const BIN_DIR = path.join(LAIN_DIR, 'bin');
10
+ const MODELS_DIR = path.join(LAIN_DIR, 'models');
11
+ const TOOLCHAINS_DIR = path.join(LAIN_DIR, 'toolchains');
12
+ const TUNING_FILE = path.join(LAIN_DIR, 'tuning.toml');
13
+
14
+ // Skip postinstall in CI unless explicitly requested
15
+ if (process.env.CI && !process.env.LAIN_FORCE_INSTALL) {
16
+ console.log('Skipping Lain install in CI environment (set LAIN_FORCE_INSTALL=1 to override)');
17
+ return;
18
+ }
19
+
20
+ // Respect npm's --ignore-scripts flag
21
+ if (process.env.npm_config_ignore_scripts === 'true') {
22
+ console.log('Skipping Lain install (npm --ignore-scripts detected)');
23
+ return;
24
+ }
25
+
26
+ // Detect platform
27
+ function getPlatform() {
28
+ const platform = process.platform;
29
+ const arch = process.arch;
30
+ if (platform === 'darwin' && arch === 'arm64') return 'aarch64-apple-darwin';
31
+ if (platform === 'darwin' && arch === 'x64') return 'x86_64-apple-darwin';
32
+ if (platform === 'linux' && arch === 'x64') return 'x86_64-unknown-linux-gnu';
33
+ if (platform === 'win32' && arch === 'x64') return 'x86_64-pc-windows-msvc.exe';
34
+ throw new Error(`Unsupported platform: ${platform}-${arch}`);
35
+ }
36
+
37
+ function getAssetName(platform, version) {
38
+ const versionSlug = version.replace(/^v/, '');
39
+ const map = {
40
+ 'aarch64-apple-darwin': `lain-${versionSlug}-aarch64-apple-darwin`,
41
+ 'x86_64-apple-darwin': `lain-${versionSlug}-x86_64-apple-darwin`,
42
+ 'x86_64-unknown-linux-gnu': `lain-${versionSlug}-x86_64-unknown-linux-gnu`,
43
+ 'x86_64-pc-windows-msvc.exe': `lain-${versionSlug}-x86_64-pc-windows-msvc.exe`,
44
+ };
45
+ const asset = map[platform];
46
+ if (!asset) throw new Error(`Unsupported platform for binary download: ${platform}`);
47
+ return asset;
48
+ }
49
+
50
+ // Ensure directory exists
51
+ function ensureDir(dir) {
52
+ if (!fs.existsSync(dir)) {
53
+ fs.mkdirSync(dir, { recursive: true });
54
+ }
55
+ }
56
+
57
+ // Download file with curl, fallback to PowerShell on Windows
58
+ function download(url, dest) {
59
+ console.log(` Downloading ${path.basename(dest)}...`);
60
+ try {
61
+ execSync(`curl -L "${url}" -o "${dest}" --progress-bar`, { stdio: 'inherit' });
62
+ } catch (e) {
63
+ if (process.platform === 'win32') {
64
+ console.log(' curl not found, using PowerShell...');
65
+ execSync(
66
+ `powershell -Command "Invoke-WebRequest -Uri \\"${url}\\" -OutFile \\"${dest}\\""`,
67
+ { stdio: 'inherit' }
68
+ );
69
+ } else {
70
+ throw new Error(`curl not found and no fallback available for ${process.platform}`);
71
+ }
72
+ }
73
+ }
74
+
75
+ // Create default tuning.toml
76
+ function createTuningConfig() {
77
+ const content = `# Lain tuning configuration — loaded from ~/.lain/tuning.toml
78
+ # All values are optional; omit a field to use the built-in default.
79
+
80
+ [semantic]
81
+ threshold = 0.1 # Semantic search cosine similarity floor
82
+ anchor_weight = 0.3 # Weight for anchor_score in hybrid ranking
83
+
84
+ [ingestion]
85
+ max_pattern_edges = 200
86
+ lsp_pool_size = 4
87
+ files_per_batch = 50
88
+ max_files_per_scan = 5000
89
+ cochange_commit_window = 100
90
+ cochange_min_pair_count = 2
91
+ cochange_max_commit_files = 100
92
+
93
+ [execution]
94
+ default_command_timeout_secs = 60
95
+ default_test_timeout_secs = 300
96
+ lsp_symbol_poll_timeout_secs = 2
97
+ lsp_symbol_poll_interval_ms = 50
98
+ `;
99
+ fs.writeFileSync(TUNING_FILE, content);
100
+ console.log(` Created ${TUNING_FILE}`);
101
+ }
102
+
103
+ // Create toolchains/ README
104
+ function createToolchainsDir() {
105
+ ensureDir(TOOLCHAINS_DIR);
106
+ const readme = `# User toolchain overrides
107
+ # Drop .toml files here to override built-in toolchain profiles.
108
+ # See the built-in profiles in the Lain source at toolchains/
109
+ `;
110
+ fs.writeFileSync(path.join(TOOLCHAINS_DIR, 'README.md'), readme);
111
+ console.log(` Created ${TOOLCHAINS_DIR}/`);
112
+ }
113
+
114
+ // Create models/ README
115
+ function createModelsDir() {
116
+ ensureDir(MODELS_DIR);
117
+ const readme = `# ONNX embedding models
118
+ # Place .onnx model files here for semantic search.
119
+ # Required files:
120
+ # model.onnx — the ONNX model
121
+ # tokenizer.json — the tokenizer
122
+ #
123
+ # Download the default model:
124
+ # ./scripts/install.sh --fast # if using Lain's install script
125
+ # or from https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2
126
+ `;
127
+ fs.writeFileSync(path.join(MODELS_DIR, 'README.md'), readme);
128
+ console.log(` Created ${MODELS_DIR}/`);
129
+ }
130
+
131
+ // Create the launcher script (shell for unix, batch for windows)
132
+ function createLauncher(binaryPath) {
133
+ const isWin = process.platform === 'win32';
134
+ const launcherName = isWin ? 'lain-launcher.cmd' : 'lain-launcher';
135
+ const launcherPath = path.join(BIN_DIR, launcherName);
136
+ const content = isWin
137
+ ? `@echo off\n"${binaryPath}" %*`
138
+ : `#!/bin/sh\nexec "${binaryPath}" "$@"\n`;
139
+ fs.writeFileSync(launcherPath, content);
140
+ if (!isWin) fs.chmodSync(launcherPath, 0o755);
141
+ console.log(` Created ${launcherPath}`);
142
+ }
143
+
144
+ // Create symlink in node_modules/.bin for npm-installed binaries
145
+ function createSymlink() {
146
+ const isWin = process.platform === 'win32';
147
+ const launcherName = isWin ? 'lain-launcher.cmd' : 'lain-launcher';
148
+ // node_modules/.bin is inside the package, not a sibling of node_modules
149
+ const nodeBin = path.join(__dirname, '..', 'node_modules', '.bin', launcherName);
150
+ try {
151
+ const binDir = path.dirname(nodeBin);
152
+ if (!fs.existsSync(binDir)) {
153
+ fs.mkdirSync(binDir, { recursive: true });
154
+ }
155
+ if (isWin) {
156
+ // nodeBin already ends in .cmd via launcherName, don't append again
157
+ fs.writeFileSync(nodeBin, `@echo off\n"${path.join(BIN_DIR, launcherName)}" %*`);
158
+ } else {
159
+ if (fs.existsSync(nodeBin)) fs.unlinkSync(nodeBin);
160
+ fs.symlinkSync(path.join(BIN_DIR, launcherName), nodeBin);
161
+ }
162
+ console.log(` Linked to node_modules/.bin/${launcherName}`);
163
+ } catch (e) {
164
+ if (e.code !== 'ENOENT' && e.code !== 'EEXIST') {
165
+ console.warn(` Warning: could not create .bin symlink: ${e.message}`);
166
+ }
167
+ }
168
+ }
169
+
170
+ // Main install
171
+ async function install() {
172
+ console.log('\n=== Lain installer ===\n');
173
+
174
+ // Ensure directories
175
+ ensureDir(BIN_DIR);
176
+ ensureDir(LAIN_DIR);
177
+
178
+ const platform = getPlatform();
179
+ const version = `v${require('../package.json').version}`;
180
+ const assetName = getAssetName(platform, version);
181
+ // On unix the asset IS the binary; on windows it's .exe
182
+ const binaryName = process.platform === 'win32' ? 'lain.exe' : 'lain';
183
+ // Download to a staging name first, then rename to avoid overwriting launcher
184
+ const stagingPath = path.join(BIN_DIR, binaryName + '.new');
185
+ const binaryPath = path.join(BIN_DIR, binaryName);
186
+ const githubRepo = 'spuentesp/lain';
187
+ const url = `https://github.com/${githubRepo}/releases/download/${version}/${assetName}`;
188
+
189
+ console.log(` Platform: ${platform}`);
190
+ console.log(` Binary: ${binaryPath}`);
191
+
192
+ // Download binary
193
+ if (fs.existsSync(binaryPath)) {
194
+ console.log(' Binary already exists — skipping download');
195
+ } else {
196
+ console.log(` Downloading from GitHub releases...`);
197
+ download(url, stagingPath);
198
+ fs.renameSync(stagingPath, binaryPath);
199
+ if (!process.platform.startsWith('win')) {
200
+ fs.chmodSync(binaryPath, 0o755);
201
+ }
202
+ console.log(` Installed ${binaryPath}`);
203
+ }
204
+
205
+ // Create config directories
206
+ if (!fs.existsSync(TUNING_FILE)) {
207
+ createTuningConfig();
208
+ } else {
209
+ console.log(` tuning.toml already exists — skipping`);
210
+ }
211
+
212
+ if (!fs.existsSync(TOOLCHAINS_DIR)) {
213
+ createToolchainsDir();
214
+ } else {
215
+ console.log(` toolchains/ already exists — skipping`);
216
+ }
217
+
218
+ if (!fs.existsSync(MODELS_DIR)) {
219
+ createModelsDir();
220
+ } else {
221
+ console.log(` models/ already exists — skipping`);
222
+ }
223
+
224
+ // Create launcher
225
+ createLauncher(binaryPath);
226
+
227
+ // Symlink for npm
228
+ createSymlink();
229
+
230
+ // Post-install: if a known agent config dir is present, run
231
+ // `lain init --agent auto -y` so the user lands on a working MCP
232
+ // configuration. Skip with LAIN_SKIP_INIT=1 for CI/scripted installs.
233
+ const agentDirs = [
234
+ path.join(process.env.HOME, '.claude'),
235
+ path.join(process.env.HOME, '.gemini'),
236
+ path.join(process.env.HOME, '.cursor'),
237
+ path.join(process.env.HOME, '.codeium', 'windsurf'),
238
+ path.join(process.env.HOME, '.cline'),
239
+ path.join(process.env.HOME, '.kimi-code'),
240
+ ];
241
+ const hasAgentConfig = agentDirs.some(d => fs.existsSync(d));
242
+
243
+ if (hasAgentConfig && !process.env.LAIN_SKIP_INIT) {
244
+ console.log('\nDetected an agent config directory. Running `lain init --agent auto -y`...');
245
+ const result = spawnSync(launcherPath, ['init', '--agent', 'auto', '-y'], { stdio: 'inherit' });
246
+ if (result.status !== 0) {
247
+ console.warn(' init failed; run manually: lain init --agent <name>');
248
+ }
249
+ } else {
250
+ console.log('\nNo agent config detected. To configure lain for your agent, run:');
251
+ console.log(` ${launcherPath} init --agent <claude|gemini|cursor|windsurf|cline|kimi>`);
252
+ }
253
+
254
+ console.log('\n=== Installation complete ===\n');
255
+ console.log(' To use Lain:');
256
+ console.log(` ${binaryPath} --workspace /path/to/project`);
257
+ console.log('\n Or add to your PATH:');
258
+ console.log(` export PATH="$HOME/.lain/bin:$PATH"\n`);
259
+ }
260
+
261
+ install().catch((err) => {
262
+ console.error('Installation failed:', err.message);
263
+ process.exit(1);
264
+ });
@@ -0,0 +1,280 @@
1
+ #!/usr/bin/env node
2
+ // Tests for npm-shim install.js logic
3
+
4
+ const assert = require('assert');
5
+ const path = require('path');
6
+ const os = require('os');
7
+ const fs = require('fs');
8
+
9
+ // ─────────────────────────────────────────────
10
+ // Helpers — reimplement the core logic under test
11
+ // so tests run against the same code paths.
12
+ // ─────────────────────────────────────────────
13
+
14
+ function getPlatform(platform = process.platform, arch = process.arch) {
15
+ if (platform === 'darwin' && arch === 'arm64') return 'aarch64-apple-darwin';
16
+ if (platform === 'darwin' && arch === 'x64') return 'x86_64-apple-darwin';
17
+ if (platform === 'linux' && arch === 'x64') return 'x86_64-unknown-linux-gnu';
18
+ if (platform === 'win32' && arch === 'x64') return 'x86_64-pc-windows-msvc.exe';
19
+ throw new Error(`Unsupported platform: ${platform}-${arch}`);
20
+ }
21
+
22
+ function getAssetName(platform, version) {
23
+ const versionSlug = version.replace(/^v/, '');
24
+ const map = {
25
+ 'aarch64-apple-darwin': `lain-${versionSlug}-aarch64-apple-darwin`,
26
+ 'x86_64-apple-darwin': `lain-${versionSlug}-x86_64-apple-darwin`,
27
+ 'x86_64-unknown-linux-gnu': `lain-${versionSlug}-x86_64-unknown-linux-gnu`,
28
+ 'x86_64-pc-windows-msvc.exe': `lain-${versionSlug}-x86_64-pc-windows-msvc.exe`,
29
+ };
30
+ const asset = map[platform];
31
+ if (!asset) throw new Error(`Unsupported platform for binary download: ${platform}`);
32
+ return asset;
33
+ }
34
+
35
+ function getBinaryName(isWin) {
36
+ return isWin ? 'lain.exe' : 'lain';
37
+ }
38
+
39
+ function buildUrl(platform, version = 'v0.1.0', repo = 'spuentesp/lain') {
40
+ const assetName = getAssetName(platform, version);
41
+ return `https://github.com/${repo}/releases/download/${version}/${assetName}`;
42
+ }
43
+
44
+ // ─────────────────────────────────────────────
45
+ // Tests
46
+ // ─────────────────────────────────────────────
47
+
48
+ let passed = 0;
49
+ let failed = 0;
50
+
51
+ function test(name, fn) {
52
+ try {
53
+ fn();
54
+ console.log(` ✓ ${name}`);
55
+ passed++;
56
+ } catch (e) {
57
+ console.log(` ✗ ${name}`);
58
+ console.log(` ${e.message}`);
59
+ failed++;
60
+ }
61
+ }
62
+
63
+ // ── Platform detection ─────────────────────
64
+
65
+ console.log('\n[ getPlatform ]');
66
+
67
+ test('darwin arm64 → aarch64-apple-darwin', () => {
68
+ assert.strictEqual(getPlatform('darwin', 'arm64'), 'aarch64-apple-darwin');
69
+ });
70
+
71
+ test('darwin x64 → x86_64-apple-darwin', () => {
72
+ assert.strictEqual(getPlatform('darwin', 'x64'), 'x86_64-apple-darwin');
73
+ });
74
+
75
+ test('linux x64 → x86_64-unknown-linux-gnu', () => {
76
+ assert.strictEqual(getPlatform('linux', 'x64'), 'x86_64-unknown-linux-gnu');
77
+ });
78
+
79
+ test('win32 x64 → x86_64-pc-windows-msvc.exe', () => {
80
+ assert.strictEqual(getPlatform('win32', 'x64'), 'x86_64-pc-windows-msvc.exe');
81
+ });
82
+
83
+ test('unknown platform throws', () => {
84
+ let threw = false;
85
+ try { getPlatform('freebsd', 'x64'); } catch (e) { threw = true; }
86
+ assert(threw, 'should throw on freebsd');
87
+ });
88
+
89
+ // ── Asset name construction ─────────────────
90
+
91
+ console.log('\n[ getAssetName ]');
92
+
93
+ test('v0.1.0 → "0.1.0" slug (no leading v in asset name)', () => {
94
+ const name = getAssetName('x86_64-unknown-linux-gnu', 'v0.1.0');
95
+ assert.strictEqual(name, 'lain-0.1.0-x86_64-unknown-linux-gnu');
96
+ });
97
+
98
+ test('0.1.0 (no v) also works', () => {
99
+ const name = getAssetName('x86_64-apple-darwin', '0.1.0');
100
+ assert.strictEqual(name, 'lain-0.1.0-x86_64-apple-darwin');
101
+ });
102
+
103
+ test('macOS ARM asset name is correct', () => {
104
+ const name = getAssetName('aarch64-apple-darwin', 'v0.1.0');
105
+ assert.strictEqual(name, 'lain-0.1.0-aarch64-apple-darwin');
106
+ });
107
+
108
+ test('Windows asset name ends in .exe', () => {
109
+ const name = getAssetName('x86_64-pc-windows-msvc.exe', 'v0.1.0');
110
+ assert.strictEqual(name, 'lain-0.1.0-x86_64-pc-windows-msvc.exe');
111
+ });
112
+
113
+ test('unknown platform in getAssetName throws', () => {
114
+ let threw = false;
115
+ try { getAssetName('freebsd-x64', 'v0.1.0'); } catch (e) { threw = true; }
116
+ assert(threw, 'should throw on unknown platform');
117
+ });
118
+
119
+ // ── URL construction ────────────────────────
120
+
121
+ console.log('\n[ buildUrl ]');
122
+
123
+ test('GitHub release URL is correctly formed', () => {
124
+ const url = buildUrl('x86_64-unknown-linux-gnu', 'v0.1.0');
125
+ assert.strictEqual(
126
+ url,
127
+ 'https://github.com/spuentesp/lain/releases/download/v0.1.0/lain-0.1.0-x86_64-unknown-linux-gnu'
128
+ );
129
+ });
130
+
131
+ test('custom repo works', () => {
132
+ const url = buildUrl('x86_64-apple-darwin', 'v0.1.0', 'myorg/mylain');
133
+ assert.strictEqual(
134
+ url,
135
+ 'https://github.com/myorg/mylain/releases/download/v0.1.0/lain-0.1.0-x86_64-apple-darwin'
136
+ );
137
+ });
138
+
139
+ test('different version in URL', () => {
140
+ const url = buildUrl('x86_64-apple-darwin', 'v1.2.3');
141
+ assert.ok(url.includes('/v1.2.3/'));
142
+ assert.ok(url.includes('lain-1.2.3-x86_64-apple-darwin'));
143
+ });
144
+
145
+ // ── Binary name ─────────────────────────────
146
+
147
+ console.log('\n[ getBinaryName ]');
148
+
149
+ test('win32 → lain.exe', () => {
150
+ assert.strictEqual(getBinaryName(true), 'lain.exe');
151
+ });
152
+
153
+ test('unix → lain (no extension)', () => {
154
+ assert.strictEqual(getBinaryName(false), 'lain');
155
+ });
156
+
157
+ // ── Symlink path construction ──────────────
158
+
159
+ console.log('\n[ createSymlink path ]');
160
+
161
+ test('node_modules/.bin path on unix', () => {
162
+ // Simulate: __dirname = /pkg/scripts → package root = /pkg
163
+ const __dirname = '/pkg/scripts';
164
+ const launcherName = 'lain-launcher';
165
+ const nodeBin = path.join(__dirname, '..', 'node_modules', '.bin', launcherName);
166
+ assert.strictEqual(nodeBin, '/pkg/node_modules/.bin/lain-launcher');
167
+ });
168
+
169
+ test('node_modules/.bin path on windows', () => {
170
+ // path.join normalizes separators for the current platform
171
+ // on darwin it uses /, on win32 it uses \
172
+ const nodeBin = path.join('C:\\pkg', 'scripts', '..', 'node_modules', '.bin', 'lain-launcher.cmd');
173
+ const expected = path.join('C:\\pkg', 'node_modules', '.bin', 'lain-launcher.cmd');
174
+ assert.strictEqual(nodeBin, expected);
175
+ });
176
+
177
+ // ── LAIN_DIR path ───────────────────────────
178
+
179
+ console.log('\n[ LAIN_DIR paths ]');
180
+
181
+ test('LAIN_DIR is ~/.lain', () => {
182
+ const lainDir = path.join(process.env.HOME, '.lain');
183
+ assert.strictEqual(lainDir, path.join(os.homedir(), '.lain'));
184
+ });
185
+
186
+ test('BIN_DIR is ~/.lain/bin', () => {
187
+ const lainDir = path.join(process.env.HOME, '.lain');
188
+ const binDir = path.join(lainDir, 'bin');
189
+ assert.strictEqual(binDir, path.join(os.homedir(), '.lain', 'bin'));
190
+ });
191
+
192
+ // ── CI guard logic ──────────────────────────
193
+
194
+ console.log('\n[ CI guard ]');
195
+
196
+ test('CI=true skips install', () => {
197
+ const env = { CI: 'true' };
198
+ const shouldSkip = env.CI && !env.LAIN_FORCE_INSTALL;
199
+ assert.strictEqual(shouldSkip, true);
200
+ });
201
+
202
+ test('CI=true + LAIN_FORCE_INSTALL=1 does NOT skip', () => {
203
+ const env = { CI: 'true', LAIN_FORCE_INSTALL: '1' };
204
+ const shouldSkip = env.CI && !env.LAIN_FORCE_INSTALL;
205
+ assert.strictEqual(shouldSkip, false);
206
+ });
207
+
208
+ test('CI unset does not skip', () => {
209
+ const env = {};
210
+ const shouldSkip = !!(env.CI && !env.LAIN_FORCE_INSTALL);
211
+ assert.strictEqual(shouldSkip, false);
212
+ });
213
+
214
+ // ── ignore-scripts guard ────────────────────
215
+
216
+ console.log('\n[ --ignore-scripts guard ]');
217
+
218
+ test('npm_config_ignore_scripts=true skips install', () => {
219
+ const env = { npm_config_ignore_scripts: 'true' };
220
+ const shouldSkip = env.npm_config_ignore_scripts === 'true';
221
+ assert.strictEqual(shouldSkip, true);
222
+ });
223
+
224
+ test('npm_config_ignore_scripts unset does not skip', () => {
225
+ const env = {};
226
+ const shouldSkip = env.npm_config_ignore_scripts === 'true';
227
+ assert.strictEqual(shouldSkip, false);
228
+ });
229
+
230
+ // ── Launcher content ───────────────────────
231
+
232
+ console.log('\n[ createLauncher content ]');
233
+
234
+ test('Unix launcher uses exec with quoted binary path', () => {
235
+ const isWin = false;
236
+ const binaryPath = '/Users/user/.lain/bin/lain';
237
+ const content = isWin
238
+ ? `@echo off\n"${binaryPath}" %*`
239
+ : `#!/bin/sh\nexec "${binaryPath}" "$@"\n`;
240
+ assert.strictEqual(content, '#!/bin/sh\nexec "/Users/user/.lain/bin/lain" "$@"\n');
241
+ });
242
+
243
+ test('Windows launcher uses @echo off with quoted binary path', () => {
244
+ const isWin = true;
245
+ const binaryPath = 'C:\\Users\\user\\.lain\\bin\\lain.exe';
246
+ const content = isWin
247
+ ? `@echo off\n"${binaryPath}" %*`
248
+ : `#!/bin/sh\nexec "${binaryPath}" "$@"\n`;
249
+ assert.strictEqual(content, '@echo off\n"C:\\Users\\user\\.lain\\bin\\lain.exe" %*');
250
+ });
251
+
252
+ // ── Download URL round-trip ────────────────
253
+
254
+ console.log('\n[ Full URL round-trip for all platforms ]');
255
+
256
+ const platforms = [
257
+ { p: 'darwin', a: 'arm64', expected: 'aarch64-apple-darwin' },
258
+ { p: 'darwin', a: 'x64', expected: 'x86_64-apple-darwin' },
259
+ { p: 'linux', a: 'x64', expected: 'x86_64-unknown-linux-gnu' },
260
+ { p: 'win32', a: 'x64', expected: 'x86_64-pc-windows-msvc.exe' },
261
+ ];
262
+
263
+ for (const { p, a, expected } of platforms) {
264
+ test(`${p}-${a} round-trip`, () => {
265
+ const plat = getPlatform(p, a);
266
+ assert.strictEqual(plat, expected);
267
+ const asset = getAssetName(plat, 'v0.1.0');
268
+ assert.ok(asset.startsWith('lain-'));
269
+ assert.ok(asset.endsWith(plat));
270
+ const url = buildUrl(plat, 'v0.1.0');
271
+ assert.ok(url.startsWith('https://github.com/spuentesp/lain/releases/download/v0.1.0/lain-'));
272
+ });
273
+ }
274
+
275
+ // ── Summary ────────────────────────────────
276
+
277
+ console.log(`\n${'─'.repeat(40)}`);
278
+ console.log(` Results: ${passed} passed, ${failed} failed`);
279
+ if (failed > 0) process.exit(1);
280
+ console.log(' All tests passed.\n');