sdd-mcp-server 1.6.2 → 1.8.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.
@@ -8,6 +8,9 @@
8
8
  * - Development mode (src/utils/)
9
9
  * - Alternative paths (parent directory)
10
10
  *
11
+ * The loader supports both TypeScript (.ts) and JavaScript (.js, .mjs, .cjs) extensions
12
+ * for cross-context compatibility.
13
+ *
11
14
  * @module moduleLoader
12
15
  */
13
16
  /**
@@ -51,26 +54,20 @@ export interface ProjectAnalysis {
51
54
  packageManager: string;
52
55
  }
53
56
  /**
54
- * Load the documentGenerator module using fallback path resolution
57
+ * Load the documentGenerator module using cross-context path resolution
55
58
  *
56
- * Attempts to load the module from multiple paths in priority order:
57
- * 1. ./utils/documentGenerator.js - Compiled TypeScript in dist/utils/
58
- * 2. ../utils/documentGenerator.js - From subdirectory (e.g., dist/tools/)
59
- * 3. ./documentGenerator.js - Root-level published package
60
- * 4. ../documentGenerator.js - Alternative root-level
59
+ * Attempts to load the module from multiple paths with multiple extensions.
60
+ * Supports both TypeScript (.ts) and JavaScript (.js, .mjs, .cjs) files.
61
61
  *
62
62
  * @returns The documentGenerator module with all export functions
63
63
  * @throws Error if all import paths fail, with details of all attempts
64
64
  */
65
65
  export declare function loadDocumentGenerator(): Promise<DocumentGeneratorModule>;
66
66
  /**
67
- * Load the specGenerator module using fallback path resolution
67
+ * Load the specGenerator module using cross-context path resolution
68
68
  *
69
- * Attempts to load the module from multiple paths in priority order:
70
- * 1. ./utils/specGenerator.js - Compiled TypeScript in dist/utils/
71
- * 2. ../utils/specGenerator.js - From subdirectory
72
- * 3. ./specGenerator.js - Root-level published package
73
- * 4. ../specGenerator.js - Alternative root-level
69
+ * Attempts to load the module from multiple paths with multiple extensions.
70
+ * Supports both TypeScript (.ts) and JavaScript (.js, .mjs, .cjs) files.
74
71
  *
75
72
  * @returns The specGenerator module with all export functions
76
73
  * @throws Error if all import paths fail, with details of all attempts
@@ -8,74 +8,77 @@
8
8
  * - Development mode (src/utils/)
9
9
  * - Alternative paths (parent directory)
10
10
  *
11
+ * The loader supports both TypeScript (.ts) and JavaScript (.js, .mjs, .cjs) extensions
12
+ * for cross-context compatibility.
13
+ *
11
14
  * @module moduleLoader
12
15
  */
13
16
  /**
14
- * Load the documentGenerator module using fallback path resolution
15
- *
16
- * Attempts to load the module from multiple paths in priority order:
17
- * 1. ./utils/documentGenerator.js - Compiled TypeScript in dist/utils/
18
- * 2. ../utils/documentGenerator.js - From subdirectory (e.g., dist/tools/)
19
- * 3. ./documentGenerator.js - Root-level published package
20
- * 4. ../documentGenerator.js - Alternative root-level
21
- *
22
- * @returns The documentGenerator module with all export functions
23
- * @throws Error if all import paths fail, with details of all attempts
17
+ * File extensions to try when loading modules
18
+ * Order matters: .js first for production builds, .ts for development
24
19
  */
25
- export async function loadDocumentGenerator() {
26
- const paths = [
27
- './utils/documentGenerator.js', // Priority 1: Compiled TS in dist/utils/
28
- '../utils/documentGenerator.js', // Priority 2: From subdirectory
29
- './documentGenerator.js', // Priority 3: Root-level package
30
- '../documentGenerator.js' // Priority 4: Alternative root
20
+ const EXTENSIONS = [".js", ".ts", ".mjs", ".cjs"];
21
+ /**
22
+ * Compute base paths for module resolution
23
+ * Returns relative paths that work in both dev (tsx) and prod (node) contexts
24
+ */
25
+ function computeBasePaths(target) {
26
+ return [
27
+ `./utils/${target}`, // Same directory utils/ subfolder
28
+ `./${target}`, // Same directory
29
+ `../${target}`, // Parent directory (for root-level modules)
30
+ `../utils/${target}`, // Parent utils/ (typical case from dist/X to dist/utils/)
31
+ `../../${target}`, // Two levels up (for root-level modules from dist/utils/)
32
+ `../../utils/${target}`, // Two levels up utils/
31
33
  ];
34
+ }
35
+ /**
36
+ * Generic module loader with cross-context support
37
+ * Tries multiple paths with multiple extensions
38
+ */
39
+ async function loadModule(target) {
40
+ const basePaths = computeBasePaths(target);
32
41
  const errors = [];
33
- for (const path of paths) {
34
- try {
35
- const module = await import(path);
36
- console.error(`[SDD-DEBUG] ✅ Loaded documentGenerator from: ${path}`);
37
- return module;
38
- }
39
- catch (error) {
40
- const errorMessage = error instanceof Error ? error.message : String(error);
41
- errors.push(`${path}: ${errorMessage}`);
42
+ for (const basePath of basePaths) {
43
+ for (const ext of EXTENSIONS) {
44
+ const fullPath = `${basePath}${ext}`;
45
+ try {
46
+ console.error(`[SDD-DEBUG] ModuleLoader attempting: ${fullPath}`);
47
+ const module = await import(fullPath);
48
+ console.error(`[SDD-DEBUG] ✅ Loaded ${target} from: ${fullPath}`);
49
+ return module;
50
+ }
51
+ catch (error) {
52
+ const errorMessage = error instanceof Error ? error.message : String(error);
53
+ errors.push(`${fullPath}: ${errorMessage}`);
54
+ }
42
55
  }
43
56
  }
44
57
  // All paths failed
45
- throw new Error(`Failed to load documentGenerator. Attempted paths:\n${errors.map(e => ` - ${e}`).join('\n')}`);
58
+ throw new Error(`Failed to load ${target}. Attempted paths:\n${errors.map((e) => ` - ${e}`).join("\n")}`);
59
+ }
60
+ /**
61
+ * Load the documentGenerator module using cross-context path resolution
62
+ *
63
+ * Attempts to load the module from multiple paths with multiple extensions.
64
+ * Supports both TypeScript (.ts) and JavaScript (.js, .mjs, .cjs) files.
65
+ *
66
+ * @returns The documentGenerator module with all export functions
67
+ * @throws Error if all import paths fail, with details of all attempts
68
+ */
69
+ export async function loadDocumentGenerator() {
70
+ return loadModule("documentGenerator");
46
71
  }
47
72
  /**
48
- * Load the specGenerator module using fallback path resolution
73
+ * Load the specGenerator module using cross-context path resolution
49
74
  *
50
- * Attempts to load the module from multiple paths in priority order:
51
- * 1. ./utils/specGenerator.js - Compiled TypeScript in dist/utils/
52
- * 2. ../utils/specGenerator.js - From subdirectory
53
- * 3. ./specGenerator.js - Root-level published package
54
- * 4. ../specGenerator.js - Alternative root-level
75
+ * Attempts to load the module from multiple paths with multiple extensions.
76
+ * Supports both TypeScript (.ts) and JavaScript (.js, .mjs, .cjs) files.
55
77
  *
56
78
  * @returns The specGenerator module with all export functions
57
79
  * @throws Error if all import paths fail, with details of all attempts
58
80
  */
59
81
  export async function loadSpecGenerator() {
60
- const paths = [
61
- './utils/specGenerator.js', // Priority 1: Compiled TS in dist/utils/
62
- '../utils/specGenerator.js', // Priority 2: From subdirectory
63
- './specGenerator.js', // Priority 3: Root-level package
64
- '../specGenerator.js' // Priority 4: Alternative root
65
- ];
66
- const errors = [];
67
- for (const path of paths) {
68
- try {
69
- const module = await import(path);
70
- console.error(`[SDD-DEBUG] ✅ Loaded specGenerator from: ${path}`);
71
- return module;
72
- }
73
- catch (error) {
74
- const errorMessage = error instanceof Error ? error.message : String(error);
75
- errors.push(`${path}: ${errorMessage}`);
76
- }
77
- }
78
- // All paths failed
79
- throw new Error(`Failed to load specGenerator. Attempted paths:\n${errors.map(e => ` - ${e}`).join('\n')}`);
82
+ return loadModule("specGenerator");
80
83
  }
81
84
  //# sourceMappingURL=moduleLoader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"moduleLoader.js","sourceRoot":"","sources":["../../src/utils/moduleLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA6CH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,KAAK,GAAG;QACZ,8BAA8B,EAAK,yCAAyC;QAC5E,+BAA+B,EAAI,gCAAgC;QACnE,wBAAwB,EAAW,iCAAiC;QACpE,yBAAyB,CAAU,+BAA+B;KACnE,CAAC;IAEF,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,gDAAgD,IAAI,EAAE,CAAC,CAAC;YACtE,OAAO,MAAiC,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CA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