fix: DSH host node resolution (verified live route) + vscode 0.2.1
Browse files- ext/dsh-plugin/index.js +20 -2
- ext/vscode/agentlens-0.2.1.vsix +0 -0
- ext/vscode/src/extension.ts +8 -1
ext/dsh-plugin/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
| 12 |
*/
|
| 13 |
import { execFile } from "node:child_process";
|
| 14 |
import { promisify } from "node:util";
|
| 15 |
-
import { existsSync,
|
| 16 |
|
| 17 |
const execFileAsync = promisify(execFile);
|
| 18 |
|
|
@@ -20,6 +20,24 @@ export const inject = ["tools", "webServer"];
|
|
| 20 |
|
| 21 |
const DEFAULT_ENTRY = '/Users/apple/Downloads/mimo/agentlens/dist/cli/index.js';
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
function resolveEntry(config) {
|
| 24 |
return config?.entry || process.env.AGENTLENS_ENTRY || DEFAULT_ENTRY;
|
| 25 |
}
|
|
@@ -27,7 +45,7 @@ function resolveEntry(config) {
|
|
| 27 |
/** Run the agentlens CLI and return its combined output. */
|
| 28 |
async function runAgentlens(entry, args, cwd) {
|
| 29 |
try {
|
| 30 |
-
const { stdout, stderr } = await execFileAsync(
|
| 31 |
cwd,
|
| 32 |
timeout: 120_000,
|
| 33 |
maxBuffer: 4 * 1024 * 1024,
|
|
|
|
| 12 |
*/
|
| 13 |
import { execFile } from "node:child_process";
|
| 14 |
import { promisify } from "node:util";
|
| 15 |
+
import { existsSync, accessSync, constants } from "node:fs";
|
| 16 |
|
| 17 |
const execFileAsync = promisify(execFile);
|
| 18 |
|
|
|
|
| 20 |
|
| 21 |
const DEFAULT_ENTRY = '/Users/apple/Downloads/mimo/agentlens/dist/cli/index.js';
|
| 22 |
|
| 23 |
+
/**
|
| 24 |
+
* Resolve a real Node.js binary. Inside the Electron host `process.execPath`
|
| 25 |
+
* points at the app bundle, which cannot run a CLI script — prefer PATH and
|
| 26 |
+
* well-known install locations.
|
| 27 |
+
*/
|
| 28 |
+
function resolveNodeBinary() {
|
| 29 |
+
if (process.env.AGENTLENS_NODE) return process.env.AGENTLENS_NODE;
|
| 30 |
+
for (const candidate of ["/usr/local/bin/node", "/opt/homebrew/bin/node", "/usr/bin/node"]) {
|
| 31 |
+
try {
|
| 32 |
+
accessSync(candidate, constants.X_OK);
|
| 33 |
+
return candidate;
|
| 34 |
+
} catch {
|
| 35 |
+
// try next
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
return "node";
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
function resolveEntry(config) {
|
| 42 |
return config?.entry || process.env.AGENTLENS_ENTRY || DEFAULT_ENTRY;
|
| 43 |
}
|
|
|
|
| 45 |
/** Run the agentlens CLI and return its combined output. */
|
| 46 |
async function runAgentlens(entry, args, cwd) {
|
| 47 |
try {
|
| 48 |
+
const { stdout, stderr } = await execFileAsync(resolveNodeBinary(), [entry, ...args], {
|
| 49 |
cwd,
|
| 50 |
timeout: 120_000,
|
| 51 |
maxBuffer: 4 * 1024 * 1024,
|
ext/vscode/agentlens-0.2.1.vsix
ADDED
|
Binary file (33.4 kB). View file
|
|
|
ext/vscode/src/extension.ts
CHANGED
|
@@ -314,7 +314,14 @@ export function activate(context: vscode.ExtensionContext) {
|
|
| 314 |
return;
|
| 315 |
}
|
| 316 |
try {
|
| 317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
outputChannel.clear();
|
| 319 |
outputChannel.appendLine(stdout || "");
|
| 320 |
if (stderr) outputChannel.appendLine(stderr);
|
|
|
|
| 314 |
return;
|
| 315 |
}
|
| 316 |
try {
|
| 317 |
+
let nodeBin = process.env.AGENTLENS_NODE || "";
|
| 318 |
+
if (!nodeBin) {
|
| 319 |
+
for (const c of ["/usr/local/bin/node", "/opt/homebrew/bin/node", "/usr/bin/node"]) {
|
| 320 |
+
if (existsSync(c)) { nodeBin = c; break; }
|
| 321 |
+
}
|
| 322 |
+
}
|
| 323 |
+
if (!nodeBin) nodeBin = "node";
|
| 324 |
+
const { stdout, stderr } = await execFileAsync(nodeBin, [cli, "install", "--target", "all"], { timeout: 120_000 });
|
| 325 |
outputChannel.clear();
|
| 326 |
outputChannel.appendLine(stdout || "");
|
| 327 |
if (stderr) outputChannel.appendLine(stderr);
|