modality-kit 0.16.2 → 0.17.1

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.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __returnValue = (v) => v;
3
4
  function __exportSetter(name, newValue) {
@@ -12,13 +13,7 @@ var __export = (target, all) => {
12
13
  set: __exportSetter.bind(all, name)
13
14
  });
14
15
  };
15
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
16
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
17
- }) : x)(function(x) {
18
- if (typeof require !== "undefined")
19
- return require.apply(this, arguments);
20
- throw Error('Dynamic require of "' + x + '" is not supported');
21
- });
16
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
22
17
 
23
18
  // src/ErrorCode.ts
24
19
  class ErrorCode extends Error {
@@ -15597,8 +15592,51 @@ class SimpleCache {
15597
15592
  }
15598
15593
  // src/isTestEnvironment.ts
15599
15594
  var isTestEnvironment = globalThis.Bun?.main?.includes?.("test");
15595
+ // src/recursiveScanForFiles.ts
15596
+ import { readdirSync, statSync } from "fs";
15597
+ import { join, extname } from "path";
15598
+ function recursiveScanForFiles(baseDir, options) {
15599
+ const files = [];
15600
+ const {
15601
+ targetFolderName,
15602
+ fileExtensions,
15603
+ fileNameFilter = () => true,
15604
+ excludePatterns = [".", "__"],
15605
+ searchInSubfolders = false
15606
+ } = options;
15607
+ const extensionSet = new Set(fileExtensions);
15608
+ function scanDirectory(dir, relativePath = "", isSearchingForTarget = true) {
15609
+ try {
15610
+ const entries = readdirSync(dir);
15611
+ for (const entry of entries) {
15612
+ if (excludePatterns.some((pattern) => entry.startsWith(pattern))) {
15613
+ continue;
15614
+ }
15615
+ const fullPath = join(dir, entry);
15616
+ const relPath = relativePath ? `${relativePath}/${entry}` : entry;
15617
+ const isDirectory = statSync(fullPath).isDirectory();
15618
+ if (isSearchingForTarget) {
15619
+ if (isDirectory) {
15620
+ scanDirectory(fullPath, relPath, entry !== targetFolderName);
15621
+ }
15622
+ } else if (isDirectory) {
15623
+ if (searchInSubfolders) {
15624
+ scanDirectory(fullPath, relPath, false);
15625
+ }
15626
+ } else if ((!fileExtensions || extensionSet.has(extname(entry))) && fileNameFilter(entry)) {
15627
+ files.push({ filename: relPath, fullPath });
15628
+ }
15629
+ }
15630
+ } catch (e) {
15631
+ console.error(e);
15632
+ }
15633
+ }
15634
+ scanDirectory(baseDir, "", true);
15635
+ return files.sort((a, b) => a.filename.localeCompare(b.filename));
15636
+ }
15600
15637
  export {
15601
15638
  withErrorHandling,
15639
+ recursiveScanForFiles,
15602
15640
  mergeResponsesContent,
15603
15641
  loadVersion,
15604
15642
  isTestEnvironment,
@@ -24,3 +24,4 @@ export { SimpleCache } from "./simple-cache";
24
24
  export { isTestEnvironment } from "./isTestEnvironment";
25
25
  export type { SimpleCacheOptions } from "./simple-cache";
26
26
  export type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
27
+ export { recursiveScanForFiles, type ScannedFile } from "./recursiveScanForFiles";
@@ -0,0 +1,23 @@
1
+ interface ScanOptions {
2
+ targetFolderName: string;
3
+ fileExtensions?: string[];
4
+ fileNameFilter?: (name: string) => boolean;
5
+ excludePatterns?: string[];
6
+ searchInSubfolders?: boolean;
7
+ }
8
+ /**
9
+ * Generic recursive file finder that scans directories for files matching criteria
10
+ * Internal utility for scanning templates, protocols, and other resource types
11
+ */
12
+ export interface ScannedFile {
13
+ filename: string;
14
+ fullPath: string;
15
+ }
16
+ /**
17
+ * Recursively scan directory for files in folders matching criteria
18
+ * @param baseDir - Base directory to start scanning from
19
+ * @param options - Scan configuration
20
+ * @returns Array of found files sorted by filename
21
+ */
22
+ export declare function recursiveScanForFiles(baseDir: string, options: ScanOptions): ScannedFile[];
23
+ export {};
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.16.2",
2
+ "version": "0.17.1",
3
3
  "name": "modality-kit",
4
4
  "repository": {
5
5
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "license": "ISC",
15
15
  "devDependencies": {
16
16
  "@modelcontextprotocol/sdk": "^1.29.0",
17
- "modality-bun-kit": "^0.0.3",
17
+ "modality-bun-kit": "^1.3.13",
18
18
  "zod": "^4.3.6"
19
19
  },
20
20
  "exports": {
@@ -28,7 +28,7 @@
28
28
  "scripts": {
29
29
  "build:clean": "find ./dist -name '*.*' | xargs rm -rf",
30
30
  "build:types": "bun tsc -p ./",
31
- "build:src": "bun build src/index.ts --outdir dist",
31
+ "build:src": "bun build src/index.ts --outdir dist --target=node",
32
32
  "build": "bun run build:clean && bun run build:types && bun run build:src",
33
33
  "dev": "bunx concurrently 'bun --watch tsc -p ./' 'bun build:src -- --watch --sourcemap=inline'",
34
34
  "test": "npm run build && bun test",