opentool 0.7.13 → 0.7.14

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.
@@ -18,6 +18,7 @@ interface BuildArtifacts {
18
18
  compiledTools: CompiledToolArtifact[];
19
19
  workflowBundles: WorkflowBundleArtifact | null;
20
20
  cronManifestPath: string | null;
21
+ sharedModules?: SharedModulesInfo | null;
21
22
  }
22
23
  interface CompiledToolArtifact {
23
24
  name: string;
@@ -37,6 +38,10 @@ interface WorkflowBundleArtifact {
37
38
  clientBundlePath?: string;
38
39
  manifestPath?: string;
39
40
  }
41
+ interface SharedModulesInfo {
42
+ count: number;
43
+ outputDir: string;
44
+ }
40
45
  declare function buildCommand(options: BuildOptions): Promise<void>;
41
46
  declare function buildProject(options: BuildOptions): Promise<BuildArtifacts>;
42
47
 
package/dist/cli/index.js CHANGED
@@ -40,7 +40,7 @@ async function transpileWithEsbuild(options) {
40
40
  format: options.format,
41
41
  platform: "node",
42
42
  target: "node20",
43
- logLevel: "warning",
43
+ logLevel: options.logLevel ?? "warning",
44
44
  sourcesContent: false,
45
45
  sourcemap: false,
46
46
  loader: {
@@ -54,13 +54,16 @@ async function transpileWithEsbuild(options) {
54
54
  ".cjs": "js",
55
55
  ".json": "json"
56
56
  },
57
- metafile: false,
57
+ metafile: options.metafile ?? false,
58
58
  allowOverwrite: true,
59
59
  absWorkingDir: projectRoot
60
60
  };
61
61
  if (options.external && options.external.length > 0) {
62
62
  buildOptions.external = options.external;
63
63
  }
64
+ if (options.outBase) {
65
+ buildOptions.outbase = options.outBase;
66
+ }
64
67
  if (!buildOptions.bundle) {
65
68
  buildOptions.packages = "external";
66
69
  }
@@ -1375,6 +1378,10 @@ async function buildProject(options) {
1375
1378
  projectRoot,
1376
1379
  outputDir
1377
1380
  });
1381
+ const sharedModules = await emitSharedModules({
1382
+ projectRoot,
1383
+ outputDir
1384
+ });
1378
1385
  const cronManifestPath = await writeCronManifest({
1379
1386
  tools,
1380
1387
  compiledTools,
@@ -1403,7 +1410,8 @@ async function buildProject(options) {
1403
1410
  tools,
1404
1411
  compiledTools,
1405
1412
  workflowBundles,
1406
- cronManifestPath
1413
+ cronManifestPath,
1414
+ sharedModules
1407
1415
  };
1408
1416
  }
1409
1417
  async function emitTools(tools, config) {
@@ -1447,6 +1455,48 @@ async function emitTools(tools, config) {
1447
1455
  });
1448
1456
  return compiled;
1449
1457
  }
1458
+ async function emitSharedModules(config) {
1459
+ const srcDir = path5.join(config.projectRoot, "src");
1460
+ if (!fs4.existsSync(srcDir)) {
1461
+ return null;
1462
+ }
1463
+ const sharedFiles = collectSourceFiles(srcDir);
1464
+ if (sharedFiles.length === 0) {
1465
+ return null;
1466
+ }
1467
+ const sharedOutDir = path5.join(config.outputDir, "src");
1468
+ await transpileWithEsbuild({
1469
+ entryPoints: sharedFiles,
1470
+ projectRoot: config.projectRoot,
1471
+ outDir: sharedOutDir,
1472
+ outBase: srcDir,
1473
+ format: "cjs",
1474
+ bundle: false,
1475
+ logLevel: "warning"
1476
+ });
1477
+ return { count: sharedFiles.length, outputDir: sharedOutDir };
1478
+ }
1479
+ function collectSourceFiles(dir) {
1480
+ const supported = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"]);
1481
+ const results = [];
1482
+ const ignoreDirs = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", ".opentool-temp"]);
1483
+ const entries = fs4.readdirSync(dir, { withFileTypes: true });
1484
+ for (const entry of entries) {
1485
+ const fullPath = path5.join(dir, entry.name);
1486
+ if (entry.isDirectory()) {
1487
+ if (ignoreDirs.has(entry.name)) {
1488
+ continue;
1489
+ }
1490
+ results.push(...collectSourceFiles(fullPath));
1491
+ continue;
1492
+ }
1493
+ const ext = path5.extname(entry.name);
1494
+ if (supported.has(ext) && !entry.name.endsWith(".d.ts")) {
1495
+ results.push(fullPath);
1496
+ }
1497
+ }
1498
+ return results;
1499
+ }
1450
1500
  function renderMcpServer(options) {
1451
1501
  const toolImports = options.compiledTools.map((tool, index) => `const tool${index} = require('./${tool.modulePath}');`).join("\n");
1452
1502
  const registry = options.compiledTools.map((artifact, index) => {
@@ -1605,6 +1655,11 @@ function logBuildSummary(artifacts, options) {
1605
1655
  console.log(" \u2022 mcp-server.js (stdio server)");
1606
1656
  }
1607
1657
  console.log(` \u2022 tools/ (${artifacts.compiledTools.length} compiled tools)`);
1658
+ if (artifacts.sharedModules) {
1659
+ console.log(
1660
+ ` \u2022 src/ (${artifacts.sharedModules.count} shared module${artifacts.sharedModules.count === 1 ? "" : "s"} compiled)`
1661
+ );
1662
+ }
1608
1663
  artifacts.compiledTools.forEach((tool) => {
1609
1664
  const methods = tool.httpMethods.join(", ");
1610
1665
  const walletBadge = tool.hasWallet ? " [wallet]" : "";