@agntn/harnesses 0.1.1 → 0.2.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.
@@ -1,5 +1,6 @@
1
+ import { createRequire } from "node:module";
1
2
  import { addAbortListener } from "node:events";
2
- import { existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, renameSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
3
+ import { existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, realpathSync, renameSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
3
4
  import { execFile, execFileSync, spawn } from "node:child_process";
4
5
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
5
6
  import { basename, dirname, isAbsolute, join, posix, resolve, win32 } from "node:path";
@@ -963,6 +964,18 @@ var Freebuff = class extends Harness {
963
964
  id = "freebuff";
964
965
  name = "Freebuff";
965
966
  binaries = ["freebuff"];
967
+ get version() {
968
+ const configDir = join(homedir(), ".config", "manicode");
969
+ const binaryName = process.platform === "win32" ? "freebuff.exe" : "freebuff";
970
+ if (!existsSync(join(configDir, binaryName))) return null;
971
+ try {
972
+ const metadata = JSON.parse(readFileSync(join(configDir, "freebuff-metadata.json"), "utf8"));
973
+ if (typeof metadata === "object" && metadata !== null && "version" in metadata && typeof metadata.version === "string" && metadata.version !== "") return metadata.version;
974
+ } catch {
975
+ return null;
976
+ }
977
+ return null;
978
+ }
966
979
  capabilities = {
967
980
  mcp: true,
968
981
  vision: true,
@@ -1417,10 +1430,43 @@ var Grok = class extends Harness {
1417
1430
  projectMarkers: [".grok"]
1418
1431
  };
1419
1432
  };
1433
+ function packageVersion(commandPath) {
1434
+ try {
1435
+ const require = createRequire(realpathSync(commandPath));
1436
+ const metadata = JSON.parse(readFileSync(require.resolve("mastracode/package.json"), "utf8"));
1437
+ if (typeof metadata === "object" && metadata !== null && "version" in metadata && typeof metadata.version === "string" && metadata.version !== "") return metadata.version;
1438
+ } catch {
1439
+ return null;
1440
+ }
1441
+ return null;
1442
+ }
1420
1443
  var MastraCode = class extends Harness {
1421
1444
  id = "mastracode";
1422
1445
  name = "Mastra Code";
1423
1446
  binaries = ["mastracode"];
1447
+ get version() {
1448
+ const locator = process.platform === "win32" ? "where" : "which";
1449
+ let output;
1450
+ try {
1451
+ output = execFileSync(locator, [this.binaries[0] ?? "mastracode"], {
1452
+ encoding: "utf8",
1453
+ stdio: [
1454
+ "pipe",
1455
+ "pipe",
1456
+ "pipe"
1457
+ ],
1458
+ timeout: 5e3
1459
+ });
1460
+ } catch {
1461
+ return null;
1462
+ }
1463
+ const paths = output.split(/\r?\n/u).filter((path) => path !== "");
1464
+ for (const path of paths) {
1465
+ const version = packageVersion(path);
1466
+ if (version !== null) return version;
1467
+ }
1468
+ return null;
1469
+ }
1424
1470
  capabilities = {
1425
1471
  mcp: true,
1426
1472
  vision: true,
@@ -2543,9 +2589,6 @@ function writeAtomically(path, content) {
2543
2589
  writeFileSync(temp, content);
2544
2590
  renameSync(temp, path);
2545
2591
  }
2546
- function escapeRegExp(value) {
2547
- return value.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&");
2548
- }
2549
2592
  function tomlValue(value) {
2550
2593
  return JSON.stringify(value);
2551
2594
  }
@@ -2567,8 +2610,8 @@ function tomlSections(key, server) {
2567
2610
  return `${lines.join("\n")}\n`;
2568
2611
  }
2569
2612
  function stripTomlServer(raw, key, name) {
2570
- const prefix = escapeRegExp(key.map(tomlKeyPart).join("."));
2571
- const namePart = `(?:${escapeRegExp(tomlKeyPart(name))}|${escapeRegExp(JSON.stringify(name))})`;
2613
+ const prefix = RegExp.escape(key.map(tomlKeyPart).join("."));
2614
+ const namePart = `(?:${RegExp.escape(tomlKeyPart(name))}|${RegExp.escape(JSON.stringify(name))})`;
2572
2615
  const sectionRe = new RegExp(`^\\s*\\[${prefix}\\.${namePart}(\\.[^\\]]+)?\\]`);
2573
2616
  const bareTableRe = new RegExp(`^\\s*\\[${prefix}\\]\\s*(#.*)?$`);
2574
2617
  const anyHeaderRe = /^\s*\[/;