@zoer7788/mcp-nexus-node 0.1.8 → 0.1.9

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 (2) hide show
  1. package/cli.js +22 -3
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -2,9 +2,9 @@
2
2
  import http from "node:http";
3
3
  import { createHash, randomBytes, randomUUID } from "node:crypto";
4
4
  import { spawn, spawnSync } from "node:child_process";
5
- import { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync, appendFileSync } from "node:fs";
5
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync, appendFileSync, readdirSync, statSync } from "node:fs";
6
6
  import { homedir, hostname } from "node:os";
7
- import { dirname, join } from "node:path";
7
+ import { dirname, join, resolve } from "node:path";
8
8
  import { fileURLToPath } from "node:url";
9
9
  import { createRequire } from "node:module";
10
10
 
@@ -17,7 +17,7 @@ const logDir = join(stateDir, "logs");
17
17
  const binDir = join(stateDir, "bin");
18
18
  const nodeIdPath = join(stateDir, "node-id");
19
19
  const packageDir = dirname(fileURLToPath(import.meta.url));
20
- const NODE_VERSION = "0.1.8";
20
+ const NODE_VERSION = "0.1.9";
21
21
  const require = createRequire(import.meta.url);
22
22
 
23
23
  function ensureState() {
@@ -195,6 +195,21 @@ function findProject(name) {
195
195
  return projects().find((p) => p.name === name);
196
196
  }
197
197
 
198
+ function listDirectories(path) {
199
+ const current = resolve(String(path || home).replace(/^~(?=\/|$)/, home));
200
+ const entries = readdirSync(current, { withFileTypes: true })
201
+ .filter((entry) => entry.isDirectory())
202
+ .slice(0, 300)
203
+ .map((entry) => {
204
+ const fullPath = join(current, entry.name);
205
+ let writable = false;
206
+ try { writable = Boolean(statSync(fullPath).mode & 0o200); } catch {}
207
+ return { name: entry.name, path: fullPath, writable };
208
+ })
209
+ .sort((a, b) => a.name.localeCompare(b.name));
210
+ return { current, parent: dirname(current), entries };
211
+ }
212
+
198
213
  function devspaceCommand() {
199
214
  const explicit = process.env.DEVSPACE_CLI;
200
215
  if (explicit && existsSync(explicit)) return ["node", explicit];
@@ -453,6 +468,10 @@ function serve() {
453
468
  }
454
469
  if (!req.url?.startsWith("/api/")) return json(res, 404, { ok: false, error: "not found" });
455
470
  if (!requireAuth(req)) return json(res, 401, { ok: false, error: "unauthorized" });
471
+ const url = new URL(req.url, "http://localhost");
472
+ if (req.method === "GET" && url.pathname === "/api/fs/list") {
473
+ return json(res, 200, listDirectories(url.searchParams.get("path") || home));
474
+ }
456
475
  if (req.method === "GET" && req.url === "/api/projects") return json(res, 200, { projects: projects().map(projectStatus) });
457
476
  if (req.method === "POST" && req.url === "/api/projects") return json(res, 200, setupProject(await readJson(req)));
458
477
  const match = req.url.match(/^\/api\/projects\/([^/]+)(?:\/([^?]+))?/);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoer7788/mcp-nexus-node",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Remote node for MCP Nexus pairing and DevSpace project control.",
5
5
  "license": "MIT",
6
6
  "type": "module",