@spuentesp/lain-mcp 0.5.0 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spuentesp/lain-mcp",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "mcpName": "io.github.spuentesp/lain",
5
5
  "description": "Wird - Architectural code intelligence for AI coding agents",
6
6
  "keywords": ["mcp", "code-intelligence", "architectural-analysis", "lain"],
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  // postinstall script — downloads the Lain binary and creates ~/.lain/ structure
3
3
 
4
- const { execSync, spawnSync } = require('child_process');
4
+ const { execSync } = require('child_process');
5
5
  const fs = require('fs');
6
6
  const path = require('path');
7
7
 
@@ -28,19 +28,19 @@ function getPlatform() {
28
28
  const platform = process.platform;
29
29
  const arch = process.arch;
30
30
  if (platform === 'darwin' && arch === 'arm64') return 'aarch64-apple-darwin';
31
- if (platform === 'darwin' && arch === 'x64') return 'x86_64-apple-darwin';
32
31
  if (platform === 'linux' && arch === 'x64') return 'x86_64-unknown-linux-gnu';
33
- if (platform === 'win32' && arch === 'x64') return 'x86_64-pc-windows-msvc.exe';
32
+ if (platform === 'linux' && arch === 'arm64') return 'aarch64-unknown-linux-gnu';
33
+ if (platform === 'win32' && arch === 'x64') return 'x86_64-pc-windows-msvc';
34
34
  throw new Error(`Unsupported platform: ${platform}-${arch}`);
35
35
  }
36
36
 
37
37
  function getAssetName(platform, version) {
38
38
  const versionSlug = version.replace(/^v/, '');
39
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`,
40
+ 'aarch64-apple-darwin': `lain-${versionSlug}-aarch64-apple-darwin.tar.gz`,
41
+ 'x86_64-unknown-linux-gnu': `lain-${versionSlug}-x86_64-unknown-linux-gnu.tar.gz`,
42
+ 'aarch64-unknown-linux-gnu': `lain-${versionSlug}-aarch64-unknown-linux-gnu.tar.gz`,
43
+ 'x86_64-pc-windows-msvc': `lain-${versionSlug}-x86_64-pc-windows-msvc.tar.gz`,
44
44
  };
45
45
  const asset = map[platform];
46
46
  if (!asset) throw new Error(`Unsupported platform for binary download: ${platform}`);
@@ -54,11 +54,12 @@ function ensureDir(dir) {
54
54
  }
55
55
  }
56
56
 
57
- // Download file with curl, fallback to PowerShell on Windows
57
+ // Download file with curl (-f: fail on HTTP errors instead of saving
58
+ // the 404 page as the binary), fallback to PowerShell on Windows
58
59
  function download(url, dest) {
59
60
  console.log(` Downloading ${path.basename(dest)}...`);
60
61
  try {
61
- execSync(`curl -L "${url}" -o "${dest}" --progress-bar`, { stdio: 'inherit' });
62
+ execSync(`curl -fsSL "${url}" -o "${dest}" --progress-bar`, { stdio: 'inherit' });
62
63
  } catch (e) {
63
64
  if (process.platform === 'win32') {
64
65
  console.log(' curl not found, using PowerShell...');
@@ -178,24 +179,27 @@ async function install() {
178
179
  const platform = getPlatform();
179
180
  const version = `v${require('../package.json').version}`;
180
181
  const assetName = getAssetName(platform, version);
181
- // On unix the asset IS the binary; on windows it's .exe
182
+ // Assets are tarballs containing the binary (`lain` / `lain.exe`).
182
183
  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
184
  const binaryPath = path.join(BIN_DIR, binaryName);
185
+ const archivePath = path.join(BIN_DIR, assetName);
186
186
  const githubRepo = 'spuentesp/lain';
187
187
  const url = `https://github.com/${githubRepo}/releases/download/${version}/${assetName}`;
188
188
 
189
189
  console.log(` Platform: ${platform}`);
190
190
  console.log(` Binary: ${binaryPath}`);
191
191
 
192
- // Download binary
192
+ // Download + extract binary
193
193
  if (fs.existsSync(binaryPath)) {
194
194
  console.log(' Binary already exists — skipping download');
195
195
  } else {
196
196
  console.log(` Downloading from GitHub releases...`);
197
- download(url, stagingPath);
198
- fs.renameSync(stagingPath, binaryPath);
197
+ download(url, archivePath);
198
+ execSync(`tar xzf "${archivePath}" -C "${BIN_DIR}"`, { stdio: 'inherit' });
199
+ fs.unlinkSync(archivePath);
200
+ if (!fs.existsSync(binaryPath)) {
201
+ throw new Error(`Archive ${assetName} did not contain ${binaryName}`);
202
+ }
199
203
  if (!process.platform.startsWith('win')) {
200
204
  fs.chmodSync(binaryPath, 0o755);
201
205
  }
@@ -227,34 +231,18 @@ async function install() {
227
231
  // Symlink for npm
228
232
  createSymlink();
229
233
 
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
- }
234
+ // Post-install: nothing more to do. The user configures their
235
+ // agent's MCP wiring themselves, pointing it at the zero-config
236
+ // `lain mcp` entry (walks up for .git, no repos.yaml needed).
253
237
 
254
238
  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:');
239
+ console.log(' The zero-config MCP entry point (run from any git repo):');
240
+ console.log(` ${binaryPath} mcp`);
241
+ console.log('\n Add it to your agent\'s MCP config as:');
242
+ console.log(' { "mcpServers": { "lain": { "command": "lain", "args": ["mcp"] } } }');
243
+ console.log('\n See `lain --help` for the full subcommand surface');
244
+ console.log(' (server, mcp, workspaces, repos, query, hooks, doctor).');
245
+ console.log('\n Or add lain to your PATH:');
258
246
  console.log(` export PATH="$HOME/.lain/bin:$PATH"\n`);
259
247
  }
260
248
 
@@ -13,19 +13,19 @@ const fs = require('fs');
13
13
 
14
14
  function getPlatform(platform = process.platform, arch = process.arch) {
15
15
  if (platform === 'darwin' && arch === 'arm64') return 'aarch64-apple-darwin';
16
- if (platform === 'darwin' && arch === 'x64') return 'x86_64-apple-darwin';
17
16
  if (platform === 'linux' && arch === 'x64') return 'x86_64-unknown-linux-gnu';
18
- if (platform === 'win32' && arch === 'x64') return 'x86_64-pc-windows-msvc.exe';
17
+ if (platform === 'linux' && arch === 'arm64') return 'aarch64-unknown-linux-gnu';
18
+ if (platform === 'win32' && arch === 'x64') return 'x86_64-pc-windows-msvc';
19
19
  throw new Error(`Unsupported platform: ${platform}-${arch}`);
20
20
  }
21
21
 
22
22
  function getAssetName(platform, version) {
23
23
  const versionSlug = version.replace(/^v/, '');
24
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`,
25
+ 'aarch64-apple-darwin': `lain-${versionSlug}-aarch64-apple-darwin.tar.gz`,
26
+ 'x86_64-unknown-linux-gnu': `lain-${versionSlug}-x86_64-unknown-linux-gnu.tar.gz`,
27
+ 'aarch64-unknown-linux-gnu': `lain-${versionSlug}-aarch64-unknown-linux-gnu.tar.gz`,
28
+ 'x86_64-pc-windows-msvc': `lain-${versionSlug}-x86_64-pc-windows-msvc.tar.gz`,
29
29
  };
30
30
  const asset = map[platform];
31
31
  if (!asset) throw new Error(`Unsupported platform for binary download: ${platform}`);
@@ -68,16 +68,22 @@ test('darwin arm64 → aarch64-apple-darwin', () => {
68
68
  assert.strictEqual(getPlatform('darwin', 'arm64'), 'aarch64-apple-darwin');
69
69
  });
70
70
 
71
- test('darwin x64 → x86_64-apple-darwin', () => {
72
- assert.strictEqual(getPlatform('darwin', 'x64'), 'x86_64-apple-darwin');
71
+ test('darwin x64 throws (no published asset)', () => {
72
+ let threw = false;
73
+ try { getPlatform('darwin', 'x64'); } catch (e) { threw = true; }
74
+ assert(threw, 'should throw on darwin x64');
73
75
  });
74
76
 
75
77
  test('linux x64 → x86_64-unknown-linux-gnu', () => {
76
78
  assert.strictEqual(getPlatform('linux', 'x64'), 'x86_64-unknown-linux-gnu');
77
79
  });
78
80
 
79
- test('win32 x64 → x86_64-pc-windows-msvc.exe', () => {
80
- assert.strictEqual(getPlatform('win32', 'x64'), 'x86_64-pc-windows-msvc.exe');
81
+ test('linux arm64 → aarch64-unknown-linux-gnu', () => {
82
+ assert.strictEqual(getPlatform('linux', 'arm64'), 'aarch64-unknown-linux-gnu');
83
+ });
84
+
85
+ test('win32 x64 → x86_64-pc-windows-msvc', () => {
86
+ assert.strictEqual(getPlatform('win32', 'x64'), 'x86_64-pc-windows-msvc');
81
87
  });
82
88
 
83
89
  test('unknown platform throws', () => {
@@ -92,22 +98,22 @@ console.log('\n[ getAssetName ]');
92
98
 
93
99
  test('v0.1.0 → "0.1.0" slug (no leading v in asset name)', () => {
94
100
  const name = getAssetName('x86_64-unknown-linux-gnu', 'v0.1.0');
95
- assert.strictEqual(name, 'lain-0.1.0-x86_64-unknown-linux-gnu');
101
+ assert.strictEqual(name, 'lain-0.1.0-x86_64-unknown-linux-gnu.tar.gz');
96
102
  });
97
103
 
98
104
  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');
105
+ const name = getAssetName('aarch64-unknown-linux-gnu', '0.1.0');
106
+ assert.strictEqual(name, 'lain-0.1.0-aarch64-unknown-linux-gnu.tar.gz');
101
107
  });
102
108
 
103
109
  test('macOS ARM asset name is correct', () => {
104
110
  const name = getAssetName('aarch64-apple-darwin', 'v0.1.0');
105
- assert.strictEqual(name, 'lain-0.1.0-aarch64-apple-darwin');
111
+ assert.strictEqual(name, 'lain-0.1.0-aarch64-apple-darwin.tar.gz');
106
112
  });
107
113
 
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');
114
+ test('Windows asset name ends in .tar.gz', () => {
115
+ const name = getAssetName('x86_64-pc-windows-msvc', 'v0.1.0');
116
+ assert.strictEqual(name, 'lain-0.1.0-x86_64-pc-windows-msvc.tar.gz');
111
117
  });
112
118
 
113
119
  test('unknown platform in getAssetName throws', () => {
@@ -124,22 +130,22 @@ test('GitHub release URL is correctly formed', () => {
124
130
  const url = buildUrl('x86_64-unknown-linux-gnu', 'v0.1.0');
125
131
  assert.strictEqual(
126
132
  url,
127
- 'https://github.com/spuentesp/lain/releases/download/v0.1.0/lain-0.1.0-x86_64-unknown-linux-gnu'
133
+ 'https://github.com/spuentesp/lain/releases/download/v0.1.0/lain-0.1.0-x86_64-unknown-linux-gnu.tar.gz'
128
134
  );
129
135
  });
130
136
 
131
137
  test('custom repo works', () => {
132
- const url = buildUrl('x86_64-apple-darwin', 'v0.1.0', 'myorg/mylain');
138
+ const url = buildUrl('aarch64-apple-darwin', 'v0.1.0', 'myorg/mylain');
133
139
  assert.strictEqual(
134
140
  url,
135
- 'https://github.com/myorg/mylain/releases/download/v0.1.0/lain-0.1.0-x86_64-apple-darwin'
141
+ 'https://github.com/myorg/mylain/releases/download/v0.1.0/lain-0.1.0-aarch64-apple-darwin.tar.gz'
136
142
  );
137
143
  });
138
144
 
139
145
  test('different version in URL', () => {
140
- const url = buildUrl('x86_64-apple-darwin', 'v1.2.3');
146
+ const url = buildUrl('aarch64-apple-darwin', 'v1.2.3');
141
147
  assert.ok(url.includes('/v1.2.3/'));
142
- assert.ok(url.includes('lain-1.2.3-x86_64-apple-darwin'));
148
+ assert.ok(url.includes('lain-1.2.3-aarch64-apple-darwin'));
143
149
  });
144
150
 
145
151
  // ── Binary name ─────────────────────────────
@@ -255,9 +261,9 @@ console.log('\n[ Full URL round-trip for all platforms ]');
255
261
 
256
262
  const platforms = [
257
263
  { p: 'darwin', a: 'arm64', expected: 'aarch64-apple-darwin' },
258
- { p: 'darwin', a: 'x64', expected: 'x86_64-apple-darwin' },
259
264
  { p: 'linux', a: 'x64', expected: 'x86_64-unknown-linux-gnu' },
260
- { p: 'win32', a: 'x64', expected: 'x86_64-pc-windows-msvc.exe' },
265
+ { p: 'linux', a: 'arm64', expected: 'aarch64-unknown-linux-gnu' },
266
+ { p: 'win32', a: 'x64', expected: 'x86_64-pc-windows-msvc' },
261
267
  ];
262
268
 
263
269
  for (const { p, a, expected } of platforms) {
@@ -266,7 +272,7 @@ for (const { p, a, expected } of platforms) {
266
272
  assert.strictEqual(plat, expected);
267
273
  const asset = getAssetName(plat, 'v0.1.0');
268
274
  assert.ok(asset.startsWith('lain-'));
269
- assert.ok(asset.endsWith(plat));
275
+ assert.ok(asset.endsWith(`${plat}.tar.gz`));
270
276
  const url = buildUrl(plat, 'v0.1.0');
271
277
  assert.ok(url.startsWith('https://github.com/spuentesp/lain/releases/download/v0.1.0/lain-'));
272
278
  });