@serviceme/devtools-core 0.1.4 → 0.1.5

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/dist/index.d.mts CHANGED
@@ -19,7 +19,8 @@ declare class EnvironmentInspector {
19
19
  private getToolVersion;
20
20
  private checkNvm;
21
21
  private checkNuget;
22
- private getVersionCommand;
22
+ private getVersionInvocation;
23
+ private getToolTimeout;
23
24
  private parseVersion;
24
25
  private handleToolCheckError;
25
26
  }
package/dist/index.d.ts CHANGED
@@ -19,7 +19,8 @@ declare class EnvironmentInspector {
19
19
  private getToolVersion;
20
20
  private checkNvm;
21
21
  private checkNuget;
22
- private getVersionCommand;
22
+ private getVersionInvocation;
23
+ private getToolTimeout;
23
24
  private parseVersion;
24
25
  private handleToolCheckError;
25
26
  }
package/dist/index.js CHANGED
@@ -293,8 +293,14 @@ async function copilotPrompt(options) {
293
293
 
294
294
  // src/env/environmentInspector.ts
295
295
  var import_devtools_protocol3 = require("@serviceme/devtools-protocol");
296
- var TOOL_CHECK_TIMEOUT_MS = 5e3;
296
+ var DEFAULT_TOOL_CHECK_TIMEOUT_MS = 5e3;
297
+ var TOOL_CHECK_TIMEOUT_MS = {
298
+ nuget: 12e3,
299
+ nvm: 8e3,
300
+ dotnet: 8e3
301
+ };
297
302
  var ERROR_CODE_NOT_FOUND = 127;
303
+ var ERROR_CODE_TIMEOUT = "ETIMEDOUT";
298
304
  var EnvironmentInspector = class {
299
305
  async checkEnvironment() {
300
306
  const results = await Promise.all(
@@ -331,19 +337,18 @@ var EnvironmentInspector = class {
331
337
  const isWindows = process.platform === "win32";
332
338
  const result = await runCommand(isWindows ? "where" : "which", {
333
339
  args: [toolName],
334
- timeoutMs: TOOL_CHECK_TIMEOUT_MS
340
+ timeoutMs: this.getToolTimeout(toolName)
335
341
  });
336
- return result.stdout.trim().split("\n")[0];
342
+ return result.stdout.split(/\r?\n/).map((line) => line.trim()).find((line) => line.length > 0);
337
343
  } catch {
338
344
  return void 0;
339
345
  }
340
346
  }
341
347
  async getToolVersion(toolName) {
342
- const command = this.getVersionCommand(toolName);
343
- const isWindows = process.platform === "win32";
344
- const result = await runCommand(isWindows ? "cmd.exe" : "/bin/bash", {
345
- args: isWindows ? ["/c", command] : ["-lc", command],
346
- timeoutMs: TOOL_CHECK_TIMEOUT_MS
348
+ const invocation = this.getVersionInvocation(toolName);
349
+ const result = await runCommand(invocation.command, {
350
+ args: invocation.args,
351
+ timeoutMs: this.getToolTimeout(toolName)
347
352
  });
348
353
  return this.parseVersion(toolName, result.stdout || result.stderr);
349
354
  }
@@ -352,7 +357,7 @@ var EnvironmentInspector = class {
352
357
  try {
353
358
  const result = await runCommand("cmd.exe", {
354
359
  args: ["/c", "nvm version"],
355
- timeoutMs: TOOL_CHECK_TIMEOUT_MS
360
+ timeoutMs: this.getToolTimeout("nvm")
356
361
  });
357
362
  return {
358
363
  installed: true,
@@ -372,7 +377,7 @@ var EnvironmentInspector = class {
372
377
  "-lc",
373
378
  'export NVM_DIR="$HOME/.nvm"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"; nvm --version'
374
379
  ],
375
- timeoutMs: TOOL_CHECK_TIMEOUT_MS
380
+ timeoutMs: this.getToolTimeout("nvm")
376
381
  });
377
382
  return {
378
383
  installed: true,
@@ -397,7 +402,7 @@ var EnvironmentInspector = class {
397
402
  try {
398
403
  const result = await runCommand("dotnet", {
399
404
  args: ["nuget", "list", "source"],
400
- timeoutMs: TOOL_CHECK_TIMEOUT_MS
405
+ timeoutMs: this.getToolTimeout("nuget")
401
406
  });
402
407
  const privateSourceUrl = "http://192.168.20.209:10010/nuget";
403
408
  if (result.stdout.includes(privateSourceUrl)) {
@@ -415,17 +420,28 @@ var EnvironmentInspector = class {
415
420
  return this.handleToolCheckError(error);
416
421
  }
417
422
  }
418
- getVersionCommand(toolName) {
423
+ getVersionInvocation(toolName) {
424
+ const isWindows = process.platform === "win32";
425
+ if (isWindows && ["npm", "pnpm", "nrm"].includes(toolName)) {
426
+ return {
427
+ command: "cmd.exe",
428
+ args: ["/d", "/s", "/c", `${toolName} --version`]
429
+ };
430
+ }
419
431
  const commands = {
420
- git: "git --version",
421
- node: "node --version",
422
- npm: "npm --version",
423
- pnpm: "pnpm --version",
424
- nvm: "nvm --version",
425
- nrm: "nrm --version",
426
- dotnet: "dotnet --version"
432
+ git: { command: "git", args: ["--version"] },
433
+ node: { command: "node", args: ["--version"] },
434
+ npm: { command: "npm", args: ["--version"] },
435
+ pnpm: { command: "pnpm", args: ["--version"] },
436
+ nvm: { command: "nvm", args: ["--version"] },
437
+ nrm: { command: "nrm", args: ["--version"] },
438
+ rtk: { command: "rtk", args: ["--version"] },
439
+ dotnet: { command: "dotnet", args: ["--version"] }
427
440
  };
428
- return commands[toolName] || `${toolName} --version`;
441
+ return commands[toolName] || { command: toolName, args: ["--version"] };
442
+ }
443
+ getToolTimeout(toolName) {
444
+ return TOOL_CHECK_TIMEOUT_MS[toolName] ?? DEFAULT_TOOL_CHECK_TIMEOUT_MS;
429
445
  }
430
446
  parseVersion(toolName, output) {
431
447
  const cleaned = output.trim();
@@ -452,10 +468,11 @@ var EnvironmentInspector = class {
452
468
  const execError = error;
453
469
  const message = execError.message || String(error);
454
470
  const code = execError.code;
455
- const isNotFound = message.includes("command not found") || message.includes("not recognized") || code === ERROR_CODE_NOT_FOUND;
471
+ const isNotFound = message.includes("command not found") || message.includes("not recognized") || message.includes("ENOENT") || code === "ENOENT" || code === ERROR_CODE_NOT_FOUND;
472
+ const isTimeout = code === ERROR_CODE_TIMEOUT || message.toLowerCase().includes("timed out");
456
473
  return {
457
474
  installed: false,
458
- error: isNotFound ? "Not installed" : message
475
+ error: isNotFound ? "Not installed" : isTimeout ? "Check timed out" : message
459
476
  };
460
477
  }
461
478
  };
@@ -1161,6 +1178,30 @@ function writeDiagnostic(message) {
1161
1178
  }
1162
1179
  process.stderr.write(message);
1163
1180
  }
1181
+ function resolveGithubCopilotCliExecution(payload) {
1182
+ const args = ["copilot", "prompt", "--prompt", payload.prompt];
1183
+ if (payload.autopilot) {
1184
+ args.push("--autopilot");
1185
+ }
1186
+ if (payload.allowTools && payload.allowTools.length > 0) {
1187
+ args.push("--allow-tools", payload.allowTools.join(","));
1188
+ }
1189
+ if (payload.model) {
1190
+ args.push("--model", payload.model);
1191
+ }
1192
+ if (payload.agent) {
1193
+ args.push("--agent", payload.agent);
1194
+ }
1195
+ args.push("--timeout", String(payload.timeout ?? 0));
1196
+ return {
1197
+ command: "serviceme",
1198
+ args,
1199
+ cwd: payload.workspace,
1200
+ timeoutMs: resolveConfiguredTimeoutMs(payload.timeout, DEFAULT_TIMEOUT_MS2),
1201
+ diagnosticArgs: redactArgs(args),
1202
+ promptLen: payload.prompt.length
1203
+ };
1204
+ }
1164
1205
  var GithubCopilotCliExecutor = class {
1165
1206
  async execute(payload, abortSignal) {
1166
1207
  const authenticated = await isCopilotAuthenticated();
@@ -1183,7 +1224,7 @@ var GithubCopilotCliExecutor = class {
1183
1224
  }
1184
1225
  executeStreaming(payload, onOutput, abortSignal) {
1185
1226
  const p = payload;
1186
- const timeoutMs = resolveConfiguredTimeoutMs(p.timeout, DEFAULT_TIMEOUT_MS2);
1227
+ const execution = resolveGithubCopilotCliExecution(p);
1187
1228
  let resolve;
1188
1229
  const resultPromise = new Promise((r) => {
1189
1230
  resolve = r;
@@ -1205,26 +1246,12 @@ var GithubCopilotCliExecutor = class {
1205
1246
  }
1206
1247
  };
1207
1248
  }
1208
- const args = ["copilot", "prompt", "--prompt", p.prompt];
1209
- if (p.autopilot) {
1210
- args.push("--autopilot");
1211
- }
1212
- if (p.allowTools && p.allowTools.length > 0) {
1213
- args.push("--allow-tools", p.allowTools.join(","));
1214
- }
1215
- if (p.model) {
1216
- args.push("--model", p.model);
1217
- }
1218
- if (p.agent) {
1219
- args.push("--agent", p.agent);
1220
- }
1221
- args.push("--timeout", String(p.timeout ?? 0));
1222
1249
  writeDiagnostic(
1223
- `[GithubCopilotCliExecutor] spawn: command=serviceme, args=${JSON.stringify(redactArgs(args))}, promptLen=${p.prompt.length}, cwd=${p.workspace ?? "(default)"}, platform=${process.platform}, windowsHide=true, pid=${process.pid}
1250
+ `[GithubCopilotCliExecutor] spawn: command=${execution.command}, args=${JSON.stringify(execution.diagnosticArgs)}, promptLen=${execution.promptLen}, cwd=${execution.cwd ?? "(default)"}, platform=${process.platform}, windowsHide=true, pid=${process.pid}
1224
1251
  `
1225
1252
  );
1226
- const child = (0, import_node_child_process2.spawn)("serviceme", args, {
1227
- cwd: p.workspace,
1253
+ const child = (0, import_node_child_process2.spawn)(execution.command, execution.args, {
1254
+ cwd: execution.cwd,
1228
1255
  stdio: ["ignore", "pipe", "pipe"],
1229
1256
  windowsHide: true
1230
1257
  });
@@ -1234,6 +1261,7 @@ var GithubCopilotCliExecutor = class {
1234
1261
  `
1235
1262
  );
1236
1263
  }
1264
+ const timeoutMs = execution.timeoutMs;
1237
1265
  const timer = timeoutMs != null ? setTimeout(() => {
1238
1266
  child.kill("SIGTERM");
1239
1267
  setTimeout(() => {
package/dist/index.mjs CHANGED
@@ -244,8 +244,14 @@ import {
244
244
  createServicemeError as createServicemeError3,
245
245
  KNOWN_ENVIRONMENT_TOOLS
246
246
  } from "@serviceme/devtools-protocol";
247
- var TOOL_CHECK_TIMEOUT_MS = 5e3;
247
+ var DEFAULT_TOOL_CHECK_TIMEOUT_MS = 5e3;
248
+ var TOOL_CHECK_TIMEOUT_MS = {
249
+ nuget: 12e3,
250
+ nvm: 8e3,
251
+ dotnet: 8e3
252
+ };
248
253
  var ERROR_CODE_NOT_FOUND = 127;
254
+ var ERROR_CODE_TIMEOUT = "ETIMEDOUT";
249
255
  var EnvironmentInspector = class {
250
256
  async checkEnvironment() {
251
257
  const results = await Promise.all(
@@ -282,19 +288,18 @@ var EnvironmentInspector = class {
282
288
  const isWindows = process.platform === "win32";
283
289
  const result = await runCommand(isWindows ? "where" : "which", {
284
290
  args: [toolName],
285
- timeoutMs: TOOL_CHECK_TIMEOUT_MS
291
+ timeoutMs: this.getToolTimeout(toolName)
286
292
  });
287
- return result.stdout.trim().split("\n")[0];
293
+ return result.stdout.split(/\r?\n/).map((line) => line.trim()).find((line) => line.length > 0);
288
294
  } catch {
289
295
  return void 0;
290
296
  }
291
297
  }
292
298
  async getToolVersion(toolName) {
293
- const command = this.getVersionCommand(toolName);
294
- const isWindows = process.platform === "win32";
295
- const result = await runCommand(isWindows ? "cmd.exe" : "/bin/bash", {
296
- args: isWindows ? ["/c", command] : ["-lc", command],
297
- timeoutMs: TOOL_CHECK_TIMEOUT_MS
299
+ const invocation = this.getVersionInvocation(toolName);
300
+ const result = await runCommand(invocation.command, {
301
+ args: invocation.args,
302
+ timeoutMs: this.getToolTimeout(toolName)
298
303
  });
299
304
  return this.parseVersion(toolName, result.stdout || result.stderr);
300
305
  }
@@ -303,7 +308,7 @@ var EnvironmentInspector = class {
303
308
  try {
304
309
  const result = await runCommand("cmd.exe", {
305
310
  args: ["/c", "nvm version"],
306
- timeoutMs: TOOL_CHECK_TIMEOUT_MS
311
+ timeoutMs: this.getToolTimeout("nvm")
307
312
  });
308
313
  return {
309
314
  installed: true,
@@ -323,7 +328,7 @@ var EnvironmentInspector = class {
323
328
  "-lc",
324
329
  'export NVM_DIR="$HOME/.nvm"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"; nvm --version'
325
330
  ],
326
- timeoutMs: TOOL_CHECK_TIMEOUT_MS
331
+ timeoutMs: this.getToolTimeout("nvm")
327
332
  });
328
333
  return {
329
334
  installed: true,
@@ -348,7 +353,7 @@ var EnvironmentInspector = class {
348
353
  try {
349
354
  const result = await runCommand("dotnet", {
350
355
  args: ["nuget", "list", "source"],
351
- timeoutMs: TOOL_CHECK_TIMEOUT_MS
356
+ timeoutMs: this.getToolTimeout("nuget")
352
357
  });
353
358
  const privateSourceUrl = "http://192.168.20.209:10010/nuget";
354
359
  if (result.stdout.includes(privateSourceUrl)) {
@@ -366,17 +371,28 @@ var EnvironmentInspector = class {
366
371
  return this.handleToolCheckError(error);
367
372
  }
368
373
  }
369
- getVersionCommand(toolName) {
374
+ getVersionInvocation(toolName) {
375
+ const isWindows = process.platform === "win32";
376
+ if (isWindows && ["npm", "pnpm", "nrm"].includes(toolName)) {
377
+ return {
378
+ command: "cmd.exe",
379
+ args: ["/d", "/s", "/c", `${toolName} --version`]
380
+ };
381
+ }
370
382
  const commands = {
371
- git: "git --version",
372
- node: "node --version",
373
- npm: "npm --version",
374
- pnpm: "pnpm --version",
375
- nvm: "nvm --version",
376
- nrm: "nrm --version",
377
- dotnet: "dotnet --version"
383
+ git: { command: "git", args: ["--version"] },
384
+ node: { command: "node", args: ["--version"] },
385
+ npm: { command: "npm", args: ["--version"] },
386
+ pnpm: { command: "pnpm", args: ["--version"] },
387
+ nvm: { command: "nvm", args: ["--version"] },
388
+ nrm: { command: "nrm", args: ["--version"] },
389
+ rtk: { command: "rtk", args: ["--version"] },
390
+ dotnet: { command: "dotnet", args: ["--version"] }
378
391
  };
379
- return commands[toolName] || `${toolName} --version`;
392
+ return commands[toolName] || { command: toolName, args: ["--version"] };
393
+ }
394
+ getToolTimeout(toolName) {
395
+ return TOOL_CHECK_TIMEOUT_MS[toolName] ?? DEFAULT_TOOL_CHECK_TIMEOUT_MS;
380
396
  }
381
397
  parseVersion(toolName, output) {
382
398
  const cleaned = output.trim();
@@ -403,10 +419,11 @@ var EnvironmentInspector = class {
403
419
  const execError = error;
404
420
  const message = execError.message || String(error);
405
421
  const code = execError.code;
406
- const isNotFound = message.includes("command not found") || message.includes("not recognized") || code === ERROR_CODE_NOT_FOUND;
422
+ const isNotFound = message.includes("command not found") || message.includes("not recognized") || message.includes("ENOENT") || code === "ENOENT" || code === ERROR_CODE_NOT_FOUND;
423
+ const isTimeout = code === ERROR_CODE_TIMEOUT || message.toLowerCase().includes("timed out");
407
424
  return {
408
425
  installed: false,
409
- error: isNotFound ? "Not installed" : message
426
+ error: isNotFound ? "Not installed" : isTimeout ? "Check timed out" : message
410
427
  };
411
428
  }
412
429
  };
@@ -1127,6 +1144,30 @@ function writeDiagnostic(message) {
1127
1144
  }
1128
1145
  process.stderr.write(message);
1129
1146
  }
1147
+ function resolveGithubCopilotCliExecution(payload) {
1148
+ const args = ["copilot", "prompt", "--prompt", payload.prompt];
1149
+ if (payload.autopilot) {
1150
+ args.push("--autopilot");
1151
+ }
1152
+ if (payload.allowTools && payload.allowTools.length > 0) {
1153
+ args.push("--allow-tools", payload.allowTools.join(","));
1154
+ }
1155
+ if (payload.model) {
1156
+ args.push("--model", payload.model);
1157
+ }
1158
+ if (payload.agent) {
1159
+ args.push("--agent", payload.agent);
1160
+ }
1161
+ args.push("--timeout", String(payload.timeout ?? 0));
1162
+ return {
1163
+ command: "serviceme",
1164
+ args,
1165
+ cwd: payload.workspace,
1166
+ timeoutMs: resolveConfiguredTimeoutMs(payload.timeout, DEFAULT_TIMEOUT_MS2),
1167
+ diagnosticArgs: redactArgs(args),
1168
+ promptLen: payload.prompt.length
1169
+ };
1170
+ }
1130
1171
  var GithubCopilotCliExecutor = class {
1131
1172
  async execute(payload, abortSignal) {
1132
1173
  const authenticated = await isCopilotAuthenticated();
@@ -1149,7 +1190,7 @@ var GithubCopilotCliExecutor = class {
1149
1190
  }
1150
1191
  executeStreaming(payload, onOutput, abortSignal) {
1151
1192
  const p = payload;
1152
- const timeoutMs = resolveConfiguredTimeoutMs(p.timeout, DEFAULT_TIMEOUT_MS2);
1193
+ const execution = resolveGithubCopilotCliExecution(p);
1153
1194
  let resolve;
1154
1195
  const resultPromise = new Promise((r) => {
1155
1196
  resolve = r;
@@ -1171,26 +1212,12 @@ var GithubCopilotCliExecutor = class {
1171
1212
  }
1172
1213
  };
1173
1214
  }
1174
- const args = ["copilot", "prompt", "--prompt", p.prompt];
1175
- if (p.autopilot) {
1176
- args.push("--autopilot");
1177
- }
1178
- if (p.allowTools && p.allowTools.length > 0) {
1179
- args.push("--allow-tools", p.allowTools.join(","));
1180
- }
1181
- if (p.model) {
1182
- args.push("--model", p.model);
1183
- }
1184
- if (p.agent) {
1185
- args.push("--agent", p.agent);
1186
- }
1187
- args.push("--timeout", String(p.timeout ?? 0));
1188
1215
  writeDiagnostic(
1189
- `[GithubCopilotCliExecutor] spawn: command=serviceme, args=${JSON.stringify(redactArgs(args))}, promptLen=${p.prompt.length}, cwd=${p.workspace ?? "(default)"}, platform=${process.platform}, windowsHide=true, pid=${process.pid}
1216
+ `[GithubCopilotCliExecutor] spawn: command=${execution.command}, args=${JSON.stringify(execution.diagnosticArgs)}, promptLen=${execution.promptLen}, cwd=${execution.cwd ?? "(default)"}, platform=${process.platform}, windowsHide=true, pid=${process.pid}
1190
1217
  `
1191
1218
  );
1192
- const child = spawn2("serviceme", args, {
1193
- cwd: p.workspace,
1219
+ const child = spawn2(execution.command, execution.args, {
1220
+ cwd: execution.cwd,
1194
1221
  stdio: ["ignore", "pipe", "pipe"],
1195
1222
  windowsHide: true
1196
1223
  });
@@ -1200,6 +1227,7 @@ var GithubCopilotCliExecutor = class {
1200
1227
  `
1201
1228
  );
1202
1229
  }
1230
+ const timeoutMs = execution.timeoutMs;
1203
1231
  const timer = timeoutMs != null ? setTimeout(() => {
1204
1232
  child.kill("SIGTERM");
1205
1233
  setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serviceme/devtools-core",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Reusable Node.js core capabilities powering the SERVICEME CLI and integrations.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "comment-json": "^4.5.1",
37
37
  "json5": "^2.2.3",
38
38
  "yauzl": "^3.2.0",
39
- "@serviceme/devtools-protocol": "0.1.4"
39
+ "@serviceme/devtools-protocol": "0.1.5"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "^24",