@elliotding/ai-agent-mcp 0.1.24 → 0.1.26

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.
Files changed (233) hide show
  1. package/README.md +27 -0
  2. package/package.json +4 -1
  3. package/.prompt-cache/cmd-cmd-client-sdk-ai-hub-generate-testcase.md +0 -101
  4. package/.prompt-cache/cmd-cmd-client-sdk-ai-hub-submit_zct_job.md +0 -158
  5. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-conf-status.md +0 -311
  6. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-sdk-log.md +0 -64
  7. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-zmb-log-errors.md +0 -84
  8. package/ai-resource-telemetry.json +0 -40
  9. package/dist/api/cached-client.d.ts +0 -48
  10. package/dist/api/cached-client.d.ts.map +0 -1
  11. package/dist/api/cached-client.js +0 -126
  12. package/dist/api/cached-client.js.map +0 -1
  13. package/dist/api/client.d.ts +0 -281
  14. package/dist/api/client.d.ts.map +0 -1
  15. package/dist/api/client.js +0 -371
  16. package/dist/api/client.js.map +0 -1
  17. package/dist/auth/index.d.ts +0 -8
  18. package/dist/auth/index.d.ts.map +0 -1
  19. package/dist/auth/index.js +0 -26
  20. package/dist/auth/index.js.map +0 -1
  21. package/dist/auth/middleware.d.ts +0 -36
  22. package/dist/auth/middleware.d.ts.map +0 -1
  23. package/dist/auth/middleware.js +0 -194
  24. package/dist/auth/middleware.js.map +0 -1
  25. package/dist/auth/permissions.d.ts +0 -60
  26. package/dist/auth/permissions.d.ts.map +0 -1
  27. package/dist/auth/permissions.js +0 -262
  28. package/dist/auth/permissions.js.map +0 -1
  29. package/dist/auth/token-validator.d.ts +0 -52
  30. package/dist/auth/token-validator.d.ts.map +0 -1
  31. package/dist/auth/token-validator.js +0 -215
  32. package/dist/auth/token-validator.js.map +0 -1
  33. package/dist/cache/cache-manager.d.ts +0 -49
  34. package/dist/cache/cache-manager.d.ts.map +0 -1
  35. package/dist/cache/cache-manager.js +0 -191
  36. package/dist/cache/cache-manager.js.map +0 -1
  37. package/dist/cache/index.d.ts +0 -6
  38. package/dist/cache/index.d.ts.map +0 -1
  39. package/dist/cache/index.js +0 -12
  40. package/dist/cache/index.js.map +0 -1
  41. package/dist/cache/redis-client.d.ts +0 -45
  42. package/dist/cache/redis-client.d.ts.map +0 -1
  43. package/dist/cache/redis-client.js +0 -210
  44. package/dist/cache/redis-client.js.map +0 -1
  45. package/dist/config/constants.d.ts +0 -28
  46. package/dist/config/constants.d.ts.map +0 -1
  47. package/dist/config/constants.js +0 -31
  48. package/dist/config/constants.js.map +0 -1
  49. package/dist/config/index.d.ts +0 -71
  50. package/dist/config/index.d.ts.map +0 -1
  51. package/dist/config/index.js +0 -190
  52. package/dist/config/index.js.map +0 -1
  53. package/dist/filesystem/manager.d.ts +0 -45
  54. package/dist/filesystem/manager.d.ts.map +0 -1
  55. package/dist/filesystem/manager.js +0 -246
  56. package/dist/filesystem/manager.js.map +0 -1
  57. package/dist/git/multi-source-manager.d.ts +0 -78
  58. package/dist/git/multi-source-manager.d.ts.map +0 -1
  59. package/dist/git/multi-source-manager.js +0 -577
  60. package/dist/git/multi-source-manager.js.map +0 -1
  61. package/dist/git/operations.d.ts +0 -27
  62. package/dist/git/operations.d.ts.map +0 -1
  63. package/dist/git/operations.js +0 -83
  64. package/dist/git/operations.js.map +0 -1
  65. package/dist/index.d.ts +0 -6
  66. package/dist/index.d.ts.map +0 -1
  67. package/dist/index.js +0 -122
  68. package/dist/index.js.map +0 -1
  69. package/dist/monitoring/health.d.ts +0 -35
  70. package/dist/monitoring/health.d.ts.map +0 -1
  71. package/dist/monitoring/health.js +0 -105
  72. package/dist/monitoring/health.js.map +0 -1
  73. package/dist/prompts/cache.d.ts +0 -69
  74. package/dist/prompts/cache.d.ts.map +0 -1
  75. package/dist/prompts/cache.js +0 -163
  76. package/dist/prompts/cache.js.map +0 -1
  77. package/dist/prompts/generator.d.ts +0 -49
  78. package/dist/prompts/generator.d.ts.map +0 -1
  79. package/dist/prompts/generator.js +0 -160
  80. package/dist/prompts/generator.js.map +0 -1
  81. package/dist/prompts/index.d.ts +0 -13
  82. package/dist/prompts/index.d.ts.map +0 -1
  83. package/dist/prompts/index.js +0 -24
  84. package/dist/prompts/index.js.map +0 -1
  85. package/dist/prompts/manager.d.ts +0 -169
  86. package/dist/prompts/manager.d.ts.map +0 -1
  87. package/dist/prompts/manager.js +0 -488
  88. package/dist/prompts/manager.js.map +0 -1
  89. package/dist/resources/index.d.ts +0 -6
  90. package/dist/resources/index.d.ts.map +0 -1
  91. package/dist/resources/index.js +0 -10
  92. package/dist/resources/index.js.map +0 -1
  93. package/dist/resources/loader.d.ts +0 -88
  94. package/dist/resources/loader.d.ts.map +0 -1
  95. package/dist/resources/loader.js +0 -492
  96. package/dist/resources/loader.js.map +0 -1
  97. package/dist/server/http.d.ts +0 -57
  98. package/dist/server/http.d.ts.map +0 -1
  99. package/dist/server/http.js +0 -435
  100. package/dist/server/http.js.map +0 -1
  101. package/dist/server.d.ts +0 -13
  102. package/dist/server.d.ts.map +0 -1
  103. package/dist/server.js +0 -200
  104. package/dist/server.js.map +0 -1
  105. package/dist/session/manager.d.ts +0 -91
  106. package/dist/session/manager.d.ts.map +0 -1
  107. package/dist/session/manager.js +0 -251
  108. package/dist/session/manager.js.map +0 -1
  109. package/dist/telemetry/index.d.ts +0 -3
  110. package/dist/telemetry/index.d.ts.map +0 -1
  111. package/dist/telemetry/index.js +0 -7
  112. package/dist/telemetry/index.js.map +0 -1
  113. package/dist/telemetry/manager.d.ts +0 -151
  114. package/dist/telemetry/manager.d.ts.map +0 -1
  115. package/dist/telemetry/manager.js +0 -367
  116. package/dist/telemetry/manager.js.map +0 -1
  117. package/dist/tools/index.d.ts +0 -12
  118. package/dist/tools/index.d.ts.map +0 -1
  119. package/dist/tools/index.js +0 -28
  120. package/dist/tools/index.js.map +0 -1
  121. package/dist/tools/manage-subscription.d.ts +0 -47
  122. package/dist/tools/manage-subscription.d.ts.map +0 -1
  123. package/dist/tools/manage-subscription.js +0 -314
  124. package/dist/tools/manage-subscription.js.map +0 -1
  125. package/dist/tools/registry.d.ts +0 -40
  126. package/dist/tools/registry.d.ts.map +0 -1
  127. package/dist/tools/registry.js +0 -85
  128. package/dist/tools/registry.js.map +0 -1
  129. package/dist/tools/search-resources.d.ts +0 -35
  130. package/dist/tools/search-resources.d.ts.map +0 -1
  131. package/dist/tools/search-resources.js +0 -159
  132. package/dist/tools/search-resources.js.map +0 -1
  133. package/dist/tools/sync-resources.d.ts +0 -54
  134. package/dist/tools/sync-resources.d.ts.map +0 -1
  135. package/dist/tools/sync-resources.js +0 -733
  136. package/dist/tools/sync-resources.js.map +0 -1
  137. package/dist/tools/track-usage.d.ts +0 -63
  138. package/dist/tools/track-usage.d.ts.map +0 -1
  139. package/dist/tools/track-usage.js +0 -90
  140. package/dist/tools/track-usage.js.map +0 -1
  141. package/dist/tools/uninstall-resource.d.ts +0 -30
  142. package/dist/tools/uninstall-resource.d.ts.map +0 -1
  143. package/dist/tools/uninstall-resource.js +0 -174
  144. package/dist/tools/uninstall-resource.js.map +0 -1
  145. package/dist/tools/upload-resource.d.ts +0 -81
  146. package/dist/tools/upload-resource.d.ts.map +0 -1
  147. package/dist/tools/upload-resource.js +0 -393
  148. package/dist/tools/upload-resource.js.map +0 -1
  149. package/dist/transport/sse.d.ts +0 -29
  150. package/dist/transport/sse.d.ts.map +0 -1
  151. package/dist/transport/sse.js +0 -271
  152. package/dist/transport/sse.js.map +0 -1
  153. package/dist/types/errors.d.ts +0 -60
  154. package/dist/types/errors.d.ts.map +0 -1
  155. package/dist/types/errors.js +0 -112
  156. package/dist/types/errors.js.map +0 -1
  157. package/dist/types/index.d.ts +0 -7
  158. package/dist/types/index.d.ts.map +0 -1
  159. package/dist/types/index.js +0 -23
  160. package/dist/types/index.js.map +0 -1
  161. package/dist/types/mcp.d.ts +0 -50
  162. package/dist/types/mcp.d.ts.map +0 -1
  163. package/dist/types/mcp.js +0 -6
  164. package/dist/types/mcp.js.map +0 -1
  165. package/dist/types/resources.d.ts +0 -109
  166. package/dist/types/resources.d.ts.map +0 -1
  167. package/dist/types/resources.js +0 -7
  168. package/dist/types/resources.js.map +0 -1
  169. package/dist/types/tools.d.ts +0 -235
  170. package/dist/types/tools.d.ts.map +0 -1
  171. package/dist/types/tools.js +0 -6
  172. package/dist/types/tools.js.map +0 -1
  173. package/dist/utils/cursor-paths.d.ts +0 -84
  174. package/dist/utils/cursor-paths.d.ts.map +0 -1
  175. package/dist/utils/cursor-paths.js +0 -166
  176. package/dist/utils/cursor-paths.js.map +0 -1
  177. package/dist/utils/log-cleaner.d.ts +0 -18
  178. package/dist/utils/log-cleaner.d.ts.map +0 -1
  179. package/dist/utils/log-cleaner.js +0 -112
  180. package/dist/utils/log-cleaner.js.map +0 -1
  181. package/dist/utils/logger.d.ts +0 -59
  182. package/dist/utils/logger.d.ts.map +0 -1
  183. package/dist/utils/logger.js +0 -292
  184. package/dist/utils/logger.js.map +0 -1
  185. package/dist/utils/validation.d.ts +0 -58
  186. package/dist/utils/validation.d.ts.map +0 -1
  187. package/dist/utils/validation.js +0 -214
  188. package/dist/utils/validation.js.map +0 -1
  189. package/src/api/cached-client.ts +0 -144
  190. package/src/api/client.ts +0 -697
  191. package/src/auth/index.ts +0 -11
  192. package/src/auth/middleware.ts +0 -244
  193. package/src/auth/permissions.ts +0 -323
  194. package/src/auth/token-validator.ts +0 -292
  195. package/src/cache/cache-manager.ts +0 -243
  196. package/src/cache/index.ts +0 -6
  197. package/src/cache/redis-client.ts +0 -249
  198. package/src/config/constants.ts +0 -33
  199. package/src/config/index.ts +0 -269
  200. package/src/filesystem/manager.ts +0 -235
  201. package/src/git/multi-source-manager.ts +0 -654
  202. package/src/git/operations.ts +0 -93
  203. package/src/index.ts +0 -157
  204. package/src/monitoring/health.ts +0 -132
  205. package/src/prompts/cache.ts +0 -140
  206. package/src/prompts/generator.ts +0 -143
  207. package/src/prompts/index.ts +0 -20
  208. package/src/prompts/manager.ts +0 -613
  209. package/src/resources/index.ts +0 -13
  210. package/src/resources/loader.ts +0 -563
  211. package/src/server/http.ts +0 -549
  212. package/src/server.ts +0 -204
  213. package/src/session/manager.ts +0 -296
  214. package/src/telemetry/index.ts +0 -10
  215. package/src/telemetry/manager.ts +0 -419
  216. package/src/tools/index.ts +0 -12
  217. package/src/tools/manage-subscription.ts +0 -385
  218. package/src/tools/registry.ts +0 -97
  219. package/src/tools/search-resources.ts +0 -185
  220. package/src/tools/sync-resources.ts +0 -827
  221. package/src/tools/track-usage.ts +0 -113
  222. package/src/tools/uninstall-resource.ts +0 -199
  223. package/src/tools/upload-resource.ts +0 -431
  224. package/src/transport/sse.ts +0 -308
  225. package/src/types/errors.ts +0 -146
  226. package/src/types/index.ts +0 -7
  227. package/src/types/mcp.ts +0 -61
  228. package/src/types/resources.ts +0 -141
  229. package/src/types/tools.ts +0 -284
  230. package/src/utils/cursor-paths.ts +0 -135
  231. package/src/utils/log-cleaner.ts +0 -92
  232. package/src/utils/logger.ts +0 -333
  233. package/src/utils/validation.ts +0 -262
@@ -1,49 +0,0 @@
1
- /**
2
- * PromptGenerator: converts raw Command/Skill Markdown assets into MCP Prompt content.
3
- *
4
- * Two-step pipeline:
5
- * 1. parseMarkdownWithImports — recursively inline `import 'path'` directives.
6
- * 2. replaceMDVariables — substitute ${VAR} placeholders with runtime values.
7
- *
8
- * The resulting string is returned to the caller who can pass it directly as
9
- * the MCP Prompt message text, or write it to the .prompt-cache/ directory.
10
- */
11
- /**
12
- * Recursively resolve and inline all `import 'path'` statements in a Markdown
13
- * file. Each imported file's content replaces its import statement in the
14
- * parent document.
15
- *
16
- * @param filePath Absolute path to the root Markdown file.
17
- * @param depth Current recursion depth (used for cycle detection).
18
- * @returns Fully expanded Markdown string.
19
- */
20
- export declare function parseMarkdownWithImports(filePath: string, depth?: number): Promise<string>;
21
- /**
22
- * Replace ${VARIABLE_NAME} placeholders in content with values from the
23
- * provided variable map. Variables not found in the map are left unchanged so
24
- * they remain visible in the output for debugging.
25
- *
26
- * @param content Markdown string (after import expansion).
27
- * @param variables Key-value map of variable names to their replacement strings.
28
- * @returns Content with placeholders substituted.
29
- */
30
- export declare function replaceMDVariables(content: string, variables: Record<string, string>): string;
31
- /**
32
- * High-level entry point: expand imports then substitute variables.
33
- *
34
- * @param filePath Absolute path to the root Markdown file.
35
- * @param variables Optional variable substitution map (defaults to empty).
36
- * @returns Final Prompt content ready for MCP registration.
37
- */
38
- export declare function generatePromptContent(filePath: string, variables?: Record<string, string>): Promise<string>;
39
- /**
40
- * Generate Prompt content from a raw Markdown string (no file I/O).
41
- * Used when the resource content has already been downloaded from the API.
42
- *
43
- * @param rawContent Raw Markdown string.
44
- * @param basePath Absolute directory used to resolve relative `import` paths.
45
- * @param variables Optional variable substitution map.
46
- * @returns Final Prompt content.
47
- */
48
- export declare function generatePromptContentFromString(rawContent: string | undefined | null, basePath: string, variables?: Record<string, string>): Promise<string>;
49
- //# sourceMappingURL=generator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/prompts/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,MAAM,EAChB,KAAK,SAAI,GACR,OAAO,CAAC,MAAM,CAAC,CA6CjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,MAAM,CAOR;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACrC,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,+BAA+B,CACnD,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EACrC,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACrC,OAAO,CAAC,MAAM,CAAC,CAajB"}
@@ -1,160 +0,0 @@
1
- "use strict";
2
- /**
3
- * PromptGenerator: converts raw Command/Skill Markdown assets into MCP Prompt content.
4
- *
5
- * Two-step pipeline:
6
- * 1. parseMarkdownWithImports — recursively inline `import 'path'` directives.
7
- * 2. replaceMDVariables — substitute ${VAR} placeholders with runtime values.
8
- *
9
- * The resulting string is returned to the caller who can pass it directly as
10
- * the MCP Prompt message text, or write it to the .prompt-cache/ directory.
11
- */
12
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- var desc = Object.getOwnPropertyDescriptor(m, k);
15
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
- desc = { enumerable: true, get: function() { return m[k]; } };
17
- }
18
- Object.defineProperty(o, k2, desc);
19
- }) : (function(o, m, k, k2) {
20
- if (k2 === undefined) k2 = k;
21
- o[k2] = m[k];
22
- }));
23
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
- Object.defineProperty(o, "default", { enumerable: true, value: v });
25
- }) : function(o, v) {
26
- o["default"] = v;
27
- });
28
- var __importStar = (this && this.__importStar) || (function () {
29
- var ownKeys = function(o) {
30
- ownKeys = Object.getOwnPropertyNames || function (o) {
31
- var ar = [];
32
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
- return ar;
34
- };
35
- return ownKeys(o);
36
- };
37
- return function (mod) {
38
- if (mod && mod.__esModule) return mod;
39
- var result = {};
40
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
- __setModuleDefault(result, mod);
42
- return result;
43
- };
44
- })();
45
- Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.parseMarkdownWithImports = parseMarkdownWithImports;
47
- exports.replaceMDVariables = replaceMDVariables;
48
- exports.generatePromptContent = generatePromptContent;
49
- exports.generatePromptContentFromString = generatePromptContentFromString;
50
- const fs = __importStar(require("fs"));
51
- const path = __importStar(require("path"));
52
- const logger_js_1 = require("../utils/logger.js");
53
- // Maximum import recursion depth to guard against circular imports.
54
- const MAX_IMPORT_DEPTH = 20;
55
- // Matches lines like: import 'relative/path/to/file.md'
56
- const IMPORT_REGEX = /^import\s+['"]([^'"]+)['"]\s*$/gm;
57
- /**
58
- * Recursively resolve and inline all `import 'path'` statements in a Markdown
59
- * file. Each imported file's content replaces its import statement in the
60
- * parent document.
61
- *
62
- * @param filePath Absolute path to the root Markdown file.
63
- * @param depth Current recursion depth (used for cycle detection).
64
- * @returns Fully expanded Markdown string.
65
- */
66
- async function parseMarkdownWithImports(filePath, depth = 0) {
67
- if (depth > MAX_IMPORT_DEPTH) {
68
- throw new Error(`Import depth exceeded ${MAX_IMPORT_DEPTH} levels at ${filePath}. ` +
69
- 'Check for circular imports.');
70
- }
71
- let content;
72
- try {
73
- content = fs.readFileSync(filePath, 'utf8');
74
- }
75
- catch (err) {
76
- throw new Error(`Cannot read Markdown file: ${filePath} — ${err.message}`);
77
- }
78
- const fileDir = path.dirname(filePath);
79
- const matches = [];
80
- let match;
81
- // Reset lastIndex before each exec loop (regex is stateful with 'g' flag).
82
- IMPORT_REGEX.lastIndex = 0;
83
- while ((match = IMPORT_REGEX.exec(content)) !== null) {
84
- const importPath = match[1];
85
- if (importPath) {
86
- matches.push({
87
- statement: match[0],
88
- resolvedPath: path.resolve(fileDir, importPath),
89
- });
90
- }
91
- }
92
- // Process imports sequentially to preserve insertion order.
93
- for (const { statement, resolvedPath } of matches) {
94
- try {
95
- const importedContent = await parseMarkdownWithImports(resolvedPath, depth + 1);
96
- content = content.replace(statement, importedContent);
97
- }
98
- catch (err) {
99
- logger_js_1.logger.warn({ importPath: resolvedPath, parentFile: filePath, error: err.message }, 'Failed to resolve import — leaving placeholder in place');
100
- }
101
- }
102
- return content;
103
- }
104
- /**
105
- * Replace ${VARIABLE_NAME} placeholders in content with values from the
106
- * provided variable map. Variables not found in the map are left unchanged so
107
- * they remain visible in the output for debugging.
108
- *
109
- * @param content Markdown string (after import expansion).
110
- * @param variables Key-value map of variable names to their replacement strings.
111
- * @returns Content with placeholders substituted.
112
- */
113
- function replaceMDVariables(content, variables) {
114
- let result = content;
115
- for (const [key, value] of Object.entries(variables)) {
116
- const regex = new RegExp(`\\$\\{${key}\\}`, 'g');
117
- result = result.replace(regex, value);
118
- }
119
- return result;
120
- }
121
- /**
122
- * High-level entry point: expand imports then substitute variables.
123
- *
124
- * @param filePath Absolute path to the root Markdown file.
125
- * @param variables Optional variable substitution map (defaults to empty).
126
- * @returns Final Prompt content ready for MCP registration.
127
- */
128
- async function generatePromptContent(filePath, variables = {}) {
129
- const expanded = await parseMarkdownWithImports(filePath);
130
- return replaceMDVariables(expanded, variables);
131
- }
132
- /**
133
- * Generate Prompt content from a raw Markdown string (no file I/O).
134
- * Used when the resource content has already been downloaded from the API.
135
- *
136
- * @param rawContent Raw Markdown string.
137
- * @param basePath Absolute directory used to resolve relative `import` paths.
138
- * @param variables Optional variable substitution map.
139
- * @returns Final Prompt content.
140
- */
141
- async function generatePromptContentFromString(rawContent, basePath, variables = {}) {
142
- if (!rawContent)
143
- return '';
144
- // Write to a temp file so parseMarkdownWithImports can resolve relative imports.
145
- const tmpPath = path.join(basePath, `.tmp-prompt-${Date.now()}-${process.pid}.md`);
146
- let result;
147
- try {
148
- fs.mkdirSync(basePath, { recursive: true });
149
- fs.writeFileSync(tmpPath, rawContent, 'utf8');
150
- result = await parseMarkdownWithImports(tmpPath);
151
- }
152
- finally {
153
- try {
154
- fs.unlinkSync(tmpPath);
155
- }
156
- catch { /* best-effort cleanup */ }
157
- }
158
- return replaceMDVariables(result, variables);
159
- }
160
- //# sourceMappingURL=generator.js.map
@@ -1 +0,0 @@
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Q,EAAE,SAAS,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,+BAA+B,CACnD,UAAqC,EACrC,QAAgB,EAChB,YAAoC,EAAE;IAEtC,IAAI,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAC3B,iFAAiF;IACjF,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,IAAI,CAAC,GAAG,EAAE,IAAI,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IACnF,IAAI,MAAc,CAAC;IACnB,IAAI,CAAC;QACH,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;QAC9C,MAAM,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACnD,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,yBAAyB,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,kBAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC/C,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * prompts module — public API
3
- *
4
- * Exports:
5
- * - PromptGenerator utilities (parseMarkdownWithImports, replaceMDVariables,
6
- * generatePromptContent, generatePromptContentFromString)
7
- * - PromptCache class and the shared singleton `promptCache`
8
- * - PromptManager class and the shared singleton `promptManager`
9
- */
10
- export { parseMarkdownWithImports, replaceMDVariables, generatePromptContent, generatePromptContentFromString, } from './generator.js';
11
- export { PromptCache, promptCache } from './cache.js';
12
- export { PromptManager, promptManager } from './manager.js';
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,+BAA+B,GAChC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /**
3
- * prompts module — public API
4
- *
5
- * Exports:
6
- * - PromptGenerator utilities (parseMarkdownWithImports, replaceMDVariables,
7
- * generatePromptContent, generatePromptContentFromString)
8
- * - PromptCache class and the shared singleton `promptCache`
9
- * - PromptManager class and the shared singleton `promptManager`
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.promptManager = exports.PromptManager = exports.promptCache = exports.PromptCache = exports.generatePromptContentFromString = exports.generatePromptContent = exports.replaceMDVariables = exports.parseMarkdownWithImports = void 0;
13
- var generator_js_1 = require("./generator.js");
14
- Object.defineProperty(exports, "parseMarkdownWithImports", { enumerable: true, get: function () { return generator_js_1.parseMarkdownWithImports; } });
15
- Object.defineProperty(exports, "replaceMDVariables", { enumerable: true, get: function () { return generator_js_1.replaceMDVariables; } });
16
- Object.defineProperty(exports, "generatePromptContent", { enumerable: true, get: function () { return generator_js_1.generatePromptContent; } });
17
- Object.defineProperty(exports, "generatePromptContentFromString", { enumerable: true, get: function () { return generator_js_1.generatePromptContentFromString; } });
18
- var cache_js_1 = require("./cache.js");
19
- Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function () { return cache_js_1.PromptCache; } });
20
- Object.defineProperty(exports, "promptCache", { enumerable: true, get: function () { return cache_js_1.promptCache; } });
21
- var manager_js_1 = require("./manager.js");
22
- Object.defineProperty(exports, "PromptManager", { enumerable: true, get: function () { return manager_js_1.PromptManager; } });
23
- Object.defineProperty(exports, "promptManager", { enumerable: true, get: function () { return manager_js_1.promptManager; } });
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,+CAKwB;AAJtB,wHAAA,wBAAwB,OAAA;AACxB,kHAAA,kBAAkB,OAAA;AAClB,qHAAA,qBAAqB,OAAA;AACrB,+HAAA,+BAA+B,OAAA;AAGjC,uCAAsD;AAA7C,uGAAA,WAAW,OAAA;AAAE,uGAAA,WAAW,OAAA;AAEjC,2CAA4D;AAAnD,2GAAA,aAAa,OAAA;AAAE,2GAAA,aAAa,OAAA"}
@@ -1,169 +0,0 @@
1
- /**
2
- * PromptManager: manages the lifecycle of MCP Prompts for Command and Skill resources.
3
- *
4
- * Design decisions:
5
- * - Uses the low-level MCP SDK `Server` class (same as the rest of this project)
6
- * via `setRequestHandler` for `ListPromptsRequestSchema` and `GetPromptRequestSchema`.
7
- * - Maintains an in-memory registry of registered prompts so list/get handlers
8
- * can be served without touching the disk on every request.
9
- * - Prompt content is read from the `.prompt-cache/` directory written by
10
- * PromptGenerator. If the cache file is missing, a fallback message is returned.
11
- * - `jira_id` is an optional Prompt argument; when provided it is forwarded to
12
- * TelemetryManager so usage can be correlated with a Jira issue.
13
- *
14
- * Prompt naming convention: `{type}/{team}/{resource-name}`
15
- * e.g. command/client-sdk/generate-testcase
16
- * skill/client-sdk/analyze-sdk-log
17
- */
18
- import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
19
- import type { LocalAction } from '../types/tools.js';
20
- export interface PromptResourceMeta {
21
- /** Canonical resource ID from the CSP platform (e.g. "cmd-client-sdk-001"). */
22
- resource_id: string;
23
- /** 'command' | 'skill' */
24
- resource_type: 'command' | 'skill';
25
- /** Human-readable resource name. */
26
- resource_name: string;
27
- /** Team that owns the resource. */
28
- team: string;
29
- /** Description shown in the Cursor slash command menu. */
30
- description: string;
31
- /** Raw Markdown content of the resource (from API download). */
32
- rawContent: string;
33
- }
34
- interface RegisteredPrompt {
35
- name: string;
36
- description: string;
37
- meta: PromptResourceMeta;
38
- }
39
- export declare class PromptManager {
40
- /**
41
- * Per-user prompt store: userToken → (promptName → RegisteredPrompt).
42
- *
43
- * Keeping prompts scoped to each user's token ensures that a ListPrompts
44
- * request for user A never leaks user B's resources and vice-versa.
45
- * The anonymous fallback key '' is used for non-authenticated connections.
46
- */
47
- private readonly userPrompts;
48
- /**
49
- * Per-user cache of the most recent local_actions_required from sync_resources.
50
- *
51
- * Populated by storeSyncActions() after each background sync on connect.
52
- * Consumed by GetPrompt(csp-ai-agent-setup) so the AI receives the actions
53
- * directly in the prompt content without needing to call sync_resources again.
54
- * Cleared after being served to avoid replaying stale actions on subsequent
55
- * GetPrompt calls.
56
- */
57
- private readonly userSyncActions;
58
- /**
59
- * Tracks which Server instances already have handlers installed.
60
- * Each SSE connection creates a new Server instance, so we track per-instance
61
- * rather than using a global boolean flag (which would skip registration on
62
- * subsequent connections and cause "Method not found" errors).
63
- */
64
- private readonly installedServers;
65
- /** Return (or lazily create) the prompt Map for a given user token. */
66
- private promptsFor;
67
- /**
68
- * Cache the local_actions_required result from the most recent background
69
- * sync for a user. Called by http.ts after oninitialized sync completes.
70
- *
71
- * @param userToken The authenticated token identifying the user.
72
- * @param actions The list of local file-system actions to execute.
73
- */
74
- storeSyncActions(userToken: string, actions: LocalAction[]): void;
75
- /**
76
- * Consume and return the cached sync actions for a user.
77
- * Returns undefined if no actions are cached (nothing to do).
78
- * The cache is cleared after retrieval to prevent stale replays.
79
- */
80
- consumeSyncActions(userToken: string): LocalAction[] | undefined;
81
- /**
82
- * Build the MCP Prompt name for a resource.
83
- * Format: `{type}/{resource-name}`
84
- *
85
- * We deliberately omit the team segment: Cursor prepends the MCP server name
86
- * already (e.g. "user-csp-ai-agent/"), so adding team would create an
87
- * unnecessarily deep slash path in the UI. type + name is sufficient to be
88
- * unique across commands and skills on this server.
89
- */
90
- buildPromptName(meta: Pick<PromptResourceMeta, 'resource_type' | 'resource_name'>): string;
91
- /**
92
- * Install `ListPrompts` and `GetPrompt` request handlers on the given MCP
93
- * `Server` instance. Must be called once after the server is created, before
94
- * `server.connect()`.
95
- *
96
- * @param server The MCP Server instance for this SSE connection.
97
- * @param userToken The authenticated token for this connection's user.
98
- * Used to attribute telemetry invocations to the correct user.
99
- *
100
- * Calling this a second time with the same server is a no-op.
101
- */
102
- installHandlers(server: Server, userToken?: string): void;
103
- /**
104
- * Register (or refresh) a single resource as an MCP Prompt.
105
- * Generates the intermediate cache file and adds the prompt to the registry.
106
- * Safe to call for an already-registered prompt — it will update the entry.
107
- */
108
- /**
109
- * Build the telemetry header that is prepended to every Command/Skill prompt.
110
- *
111
- * When the AI receives this prompt it must call `track_usage` first so that
112
- * the server records the invocation even though Cursor's slash command menu
113
- * does not trigger `prompts/get`. The header is deliberately short and
114
- * authoritative so the AI does not skip it.
115
- */
116
- private buildTrackingHeader;
117
- /**
118
- * Register (or refresh) a single resource as an MCP Prompt for a specific user.
119
- * Generates the intermediate cache file and adds the prompt to the user's registry.
120
- * Safe to call for an already-registered prompt — it will update the entry.
121
- *
122
- * @param meta Resource metadata including content.
123
- * @param userToken The token of the user subscribing this prompt.
124
- */
125
- registerPrompt(meta: PromptResourceMeta, userToken: string): Promise<void>;
126
- /**
127
- * Unregister a prompt for a specific user.
128
- * @param resourceId The canonical resource ID.
129
- * @param resourceType 'command' | 'skill'
130
- * @param resourceName Resource name (used to reconstruct the prompt name).
131
- * @param userToken The token of the user to remove the prompt from.
132
- */
133
- unregisterPrompt(resourceId: string, resourceType: 'command' | 'skill', resourceName: string, userToken: string): void;
134
- /**
135
- * Refresh a prompt's cached content and description for a specific user.
136
- * Equivalent to calling registerPrompt() again.
137
- */
138
- refreshPrompt(meta: PromptResourceMeta, userToken: string): Promise<void>;
139
- /**
140
- * Re-register all provided resources as MCP Prompts for a specific user.
141
- * Existing prompts NOT in the list are NOT removed (use pruneStalePrompts for that).
142
- */
143
- refreshAllPrompts(resources: PromptResourceMeta[], userToken: string): Promise<void>;
144
- /** Return the number of currently registered prompts for a given user. */
145
- sizeFor(userToken: string): number;
146
- /** Return the total number of registered prompts across all users. */
147
- get size(): number;
148
- /** Check if a prompt with the given name is currently registered for a user. */
149
- has(promptName: string, userToken: string): boolean;
150
- /** Return the registered prompt metadata for a given prompt name and user, or undefined. */
151
- getByPromptName(promptName: string, userToken: string): RegisteredPrompt | undefined;
152
- /** Return a snapshot of all registered prompt names for a given user. */
153
- promptNames(userToken: string): string[];
154
- /**
155
- * Remove any prompts for a specific user whose names are NOT in the provided
156
- * set of expected prompt names built from the current subscription list.
157
- *
158
- * Call this after every sync_resources run to prevent stale prompts from
159
- * accumulating across subscription changes.
160
- *
161
- * @param expectedNames Set of prompt names that SHOULD exist for this user.
162
- * @param userToken The token identifying the user's prompt namespace.
163
- */
164
- pruneStalePrompts(expectedNames: Set<string>, userToken: string): void;
165
- }
166
- /** Singleton PromptManager shared across the server process. */
167
- export declare const promptManager: PromptManager;
168
- export {};
169
- //# sourceMappingURL=manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/prompts/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,+EAA+E;IAC/E,WAAW,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,aAAa,EAAE,SAAS,GAAG,OAAO,CAAC;IACnC,oCAAoC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IAC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