shellway 0.4.1 → 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.
Files changed (3) hide show
  1. package/README.md +3 -1
  2. package/package.json +24 -7
  3. package/shellway.js +52 -9
package/README.md CHANGED
@@ -27,8 +27,10 @@ Optional: `--name "Home laptop"` on `pair` sets the computer's name. `--server U
27
27
  | `edit_block` | Replace exact text in a file; changes nothing if the text is missing or ambiguous | yes |
28
28
  | `search_files` | Find files by name, or text inside files (skips node_modules, .git, binary files) | no |
29
29
  | `start_search`, `get_more_search_results`, `stop_search` | Advanced search in the background: by name or text, optional regular expression, file-type filter (`*.js,*.ts`), lines of context, results in pages | no |
30
- | `list_directory`, `get_file_info` | List a folder; show size, dates and permissions | no |
30
+ | `list_directory`, `get_file_info` | List a folder; show size, dates and permissions. Pass `recursive:true` to walk subdirectories (default depth 3, max 2000 entries) | no |
31
31
  | `move_file` | Move or rename; never overwrites an existing file | yes |
32
+ | `download_file` | Download a file from a URL and save it to the computer (max 500 MB) | yes |
33
+ | `open_file` | Open a file or URL with the default application (like double-clicking it) | no |
32
34
  | `create_directory` | Create a folder | yes |
33
35
  | `start_process`, `interact_with_process` | Start a program that keeps running (dev server, Python or Node shell, `ssh`) and type into it | yes |
34
36
  | `read_process_output`, `list_sessions` | See what a background program printed; list the ones Shellway started | no |
package/package.json CHANGED
@@ -1,14 +1,31 @@
1
1
  {
2
2
  "name": "shellway",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Shellway agent: lets ChatGPT, Claude and Cursor work on this computer through the Shellway relay.",
5
5
  "type": "module",
6
- "bin": { "shellway": "./shellway.js" },
7
- "files": ["shellway.js", "README.md"],
8
- "engines": { "node": ">=22" },
9
- "keywords": ["mcp", "remote-mcp", "chatgpt", "claude", "cursor", "ai-agent", "shellway"],
6
+ "bin": {
7
+ "shellway": "./shellway.js"
8
+ },
9
+ "files": [
10
+ "shellway.js",
11
+ "README.md"
12
+ ],
13
+ "engines": {
14
+ "node": ">=22"
15
+ },
16
+ "keywords": [
17
+ "mcp",
18
+ "remote-mcp",
19
+ "chatgpt",
20
+ "claude",
21
+ "cursor",
22
+ "ai-agent",
23
+ "shellway"
24
+ ],
10
25
  "homepage": "https://getshellway.com",
11
- "bugs": { "email": "support@getshellway.com" },
26
+ "bugs": {
27
+ "email": "support@getshellway.com"
28
+ },
12
29
  "author": "Sandeep Kumar Saini",
13
30
  "license": "UNLICENSED"
14
- }
31
+ }
package/shellway.js CHANGED
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url';
7
7
  import { execFileSync } from 'node:child_process';
8
8
  import { readFile, writeFile, appendFile, readdir, stat, lstat, mkdir, rename, cp, rm } from 'node:fs/promises';
9
9
 
10
- const AGENT_VERSION = '0.4.1'; // keep equal to agent/package.json
10
+ const AGENT_VERSION = '0.5.0'; // keep equal to agent/package.json
11
11
  if (Number(process.versions.node.split('.')[0]) < 22) {
12
12
  console.error(`Shellway needs Node.js 22 or newer (you have ${process.versions.node}). Get it at https://nodejs.org`);
13
13
  process.exit(1);
@@ -452,18 +452,61 @@ const handlers = {
452
452
  if (!s.done) { s.stop = true; s.stopped = true; }
453
453
  return `Search ${s.id}: ${s.done && !s.stopped ? 'was already ' + searchStatus(s) : 'stopped'}, ${s.results.length} results found, ${s.results.length - s.cursor} unread.`;
454
454
  },
455
- async list_directory({ path }) {
455
+ async download_file({ url, path }) {
456
+ if (!url || !/^https?:\/\//.test(url)) throw new Error('url must start with http:// or https://');
457
+ const dest = resolve(path);
458
+ const { createWriteStream } = await import('node:fs');
459
+ const res = await fetch(url);
460
+ if (!res.ok) throw new Error(`HTTP ${res.status} from ${url}`);
461
+ const { dirname } = await import('node:path');
462
+ await mkdir(dirname(dest), { recursive: true });
463
+ const stream = createWriteStream(dest);
464
+ const reader = res.body.getReader();
465
+ let bytes = 0;
466
+ const MAX_DL = 500_000_000;
467
+ while (true) {
468
+ const { done, value } = await reader.read();
469
+ if (done) break;
470
+ if (bytes + value.length > MAX_DL) throw new Error('File exceeds 500 MB limit');
471
+ stream.write(Buffer.from(value));
472
+ bytes += value.length;
473
+ }
474
+ await new Promise((res, rej) => stream.end((e) => e ? rej(e) : res()));
475
+ return `Downloaded ${bytes.toLocaleString()} bytes → ${dest}`;
476
+ },
477
+ async open_file({ path: p }) {
478
+ const target = p.startsWith('http') ? p : resolve(p);
479
+ const pl = platform();
480
+ const cmd = pl === 'darwin' ? 'open' : pl === 'win32' ? 'start' : 'xdg-open';
481
+ const c = spawn(cmd, pl === 'win32' ? ['""', target] : [target], { shell: pl === 'win32', detached: true, stdio: 'ignore' });
482
+ c.unref();
483
+ await new Promise((res, rej) => { c.on('error', rej); setTimeout(res, 500); });
484
+ return `Opened: ${target}`;
485
+ },
486
+ async list_directory({ path, recursive, max_depth }) {
456
487
  const p = resolve(path);
457
- const names = await readdir(p);
488
+ const depth = Math.min(Math.max(Number(max_depth) || (recursive ? 3 : 0), 0), 10);
458
489
  const out = [];
459
- for (const n of names.slice(0, 1000)) {
460
- try { const s = await stat(join(p, n)); out.push(`${s.isDirectory() ? 'd' : '-'} ${String(s.size).padStart(10)} ${n}`); }
461
- catch { out.push(`? ${n}`); }
462
- }
463
- return out.join('\n') + (names.length > 1000 ? `\n…[${names.length - 1000} more]` : '');
490
+ let total = 0;
491
+ const walk = async (dir, rel, d) => {
492
+ let names; try { names = await readdir(dir); } catch { return; }
493
+ for (const n of names) {
494
+ if (total >= 2000) { out.push('…[limit 2000 reached]'); return; }
495
+ const full = join(dir, n);
496
+ const r = rel ? rel + '/' + n : n;
497
+ try {
498
+ const s = await stat(full);
499
+ out.push(`${s.isDirectory() ? 'd' : '-'} ${String(s.size).padStart(10)} ${r}`);
500
+ total++;
501
+ if (s.isDirectory() && d > 0 && !SKIP_DIRS.has(n)) await walk(full, r, d - 1);
502
+ } catch { out.push(`? ${r}`); total++; }
503
+ }
504
+ };
505
+ await walk(p, '', depth);
506
+ return out.join('\n') || '(empty)';
464
507
  },
465
508
  };
466
- const writeMethods = new Set(['run_command', 'write_file', 'edit_block', 'move_file', 'create_directory', 'start_process', 'interact_with_process', 'force_terminate']);
509
+ const writeMethods = new Set(['run_command', 'write_file', 'edit_block', 'move_file', 'create_directory', 'start_process', 'interact_with_process', 'force_terminate', 'download_file']);
467
510
 
468
511
  // One entry point for every request from the relay, so it can be tested without a network.
469
512
  async function dispatch(method, params) {