@elliotding/ai-agent-mcp 0.1.25 → 0.1.27

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 (53) hide show
  1. package/package.json +4 -1
  2. package/.prompt-cache/cmd-cmd-client-sdk-ai-hub-generate-testcase.md +0 -101
  3. package/.prompt-cache/cmd-cmd-client-sdk-ai-hub-submit_zct_job.md +0 -158
  4. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-conf-status.md +0 -311
  5. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-sdk-log.md +0 -64
  6. package/.prompt-cache/skill-skill-client-sdk-ai-hub-analyze-zmb-log-errors.md +0 -84
  7. package/ai-resource-telemetry.json +0 -40
  8. package/src/api/cached-client.ts +0 -144
  9. package/src/api/client.ts +0 -697
  10. package/src/auth/index.ts +0 -11
  11. package/src/auth/middleware.ts +0 -244
  12. package/src/auth/permissions.ts +0 -323
  13. package/src/auth/token-validator.ts +0 -292
  14. package/src/cache/cache-manager.ts +0 -243
  15. package/src/cache/index.ts +0 -6
  16. package/src/cache/redis-client.ts +0 -249
  17. package/src/config/constants.ts +0 -33
  18. package/src/config/index.ts +0 -269
  19. package/src/filesystem/manager.ts +0 -235
  20. package/src/git/multi-source-manager.ts +0 -654
  21. package/src/git/operations.ts +0 -93
  22. package/src/index.ts +0 -157
  23. package/src/monitoring/health.ts +0 -132
  24. package/src/prompts/cache.ts +0 -140
  25. package/src/prompts/generator.ts +0 -143
  26. package/src/prompts/index.ts +0 -20
  27. package/src/prompts/manager.ts +0 -718
  28. package/src/resources/index.ts +0 -13
  29. package/src/resources/loader.ts +0 -563
  30. package/src/server/http.ts +0 -549
  31. package/src/server.ts +0 -206
  32. package/src/session/manager.ts +0 -296
  33. package/src/telemetry/index.ts +0 -10
  34. package/src/telemetry/manager.ts +0 -419
  35. package/src/tools/index.ts +0 -13
  36. package/src/tools/manage-subscription.ts +0 -388
  37. package/src/tools/registry.ts +0 -97
  38. package/src/tools/resolve-prompt-content.ts +0 -113
  39. package/src/tools/search-resources.ts +0 -185
  40. package/src/tools/sync-resources.ts +0 -829
  41. package/src/tools/track-usage.ts +0 -113
  42. package/src/tools/uninstall-resource.ts +0 -199
  43. package/src/tools/upload-resource.ts +0 -431
  44. package/src/transport/sse.ts +0 -308
  45. package/src/types/errors.ts +0 -146
  46. package/src/types/index.ts +0 -7
  47. package/src/types/mcp.ts +0 -61
  48. package/src/types/resources.ts +0 -141
  49. package/src/types/tools.ts +0 -305
  50. package/src/utils/cursor-paths.ts +0 -135
  51. package/src/utils/log-cleaner.ts +0 -92
  52. package/src/utils/logger.ts +0 -333
  53. package/src/utils/validation.ts +0 -262
@@ -1,235 +0,0 @@
1
- /**
2
- * Filesystem Manager
3
- * Atomic filesystem operations for resource management
4
- */
5
-
6
- import * as fs from 'fs/promises';
7
- import * as fsSync from 'fs';
8
- import * as path from 'path';
9
- import { logger } from '../utils/logger';
10
- import { createFileSystemError, createValidationError } from '../types/errors';
11
-
12
- class FilesystemManager {
13
- /**
14
- * Write resource file atomically
15
- */
16
- async writeResource(filePath: string, content: string): Promise<void> {
17
- const tempPath = `${filePath}.tmp`;
18
-
19
- try {
20
- // Ensure directory exists
21
- const dir = path.dirname(filePath);
22
- await fs.mkdir(dir, { recursive: true });
23
-
24
- // Write to temporary file
25
- await fs.writeFile(tempPath, content, 'utf-8');
26
-
27
- // Validate content (basic check)
28
- await this.validateResourceContent(tempPath, content);
29
-
30
- // Atomic rename
31
- await fs.rename(tempPath, filePath);
32
-
33
- logger.debug({ filePath }, 'Resource file written successfully');
34
- } catch (error) {
35
- // Cleanup temporary file
36
- try {
37
- await fs.unlink(tempPath);
38
- } catch {
39
- // Ignore cleanup errors
40
- }
41
-
42
- throw createFileSystemError('write', filePath, error as Error & { code?: string });
43
- }
44
- }
45
-
46
- /**
47
- * Read resource file with validation
48
- */
49
- async readResource(filePath: string): Promise<string> {
50
- try {
51
- // Check if file exists
52
- await fs.access(filePath, fsSync.constants.R_OK);
53
-
54
- // Read file
55
- const content = await fs.readFile(filePath, 'utf-8');
56
-
57
- // Validate format
58
- await this.validateResourceContent(filePath, content);
59
-
60
- return content;
61
- } catch (error) {
62
- throw createFileSystemError('read', filePath, error as Error & { code?: string });
63
- }
64
- }
65
-
66
- /**
67
- * Delete resource file with backup
68
- */
69
- async deleteResource(filePath: string): Promise<void> {
70
- const backupPath = `${filePath}.backup`;
71
-
72
- try {
73
- // Create backup
74
- if (fsSync.existsSync(filePath)) {
75
- await fs.copyFile(filePath, backupPath);
76
- }
77
-
78
- // Delete file
79
- await fs.unlink(filePath);
80
-
81
- // Remove backup on success
82
- try {
83
- await fs.unlink(backupPath);
84
- } catch {
85
- // Ignore backup cleanup errors
86
- }
87
-
88
- logger.debug({ filePath }, 'Resource file deleted successfully');
89
- } catch (error) {
90
- // Restore from backup on failure
91
- try {
92
- if (fsSync.existsSync(backupPath)) {
93
- await fs.copyFile(backupPath, filePath);
94
- await fs.unlink(backupPath);
95
- }
96
- } catch {
97
- // Ignore restore errors
98
- }
99
-
100
- throw createFileSystemError('delete', filePath, error as Error & { code?: string });
101
- }
102
- }
103
-
104
- /**
105
- * Validate resource content
106
- */
107
- private async validateResourceContent(filePath: string, content: string): Promise<void> {
108
- const ext = path.extname(filePath);
109
-
110
- // Check if empty
111
- if (!content || content.trim().length === 0) {
112
- throw createValidationError(filePath, ext, 'File content is empty');
113
- }
114
-
115
- // Validate based on file type
116
- if (ext === '.json') {
117
- try {
118
- JSON.parse(content);
119
- } catch (error) {
120
- throw createValidationError(filePath, 'json', 'Invalid JSON format');
121
- }
122
- } else if (ext === '.md') {
123
- // Basic markdown validation (check for minimum content)
124
- if (content.length < 10) {
125
- throw createValidationError(filePath, 'markdown', 'Markdown content too short');
126
- }
127
- }
128
- }
129
-
130
- /**
131
- * Check if file exists
132
- */
133
- async fileExists(filePath: string): Promise<boolean> {
134
- try {
135
- await fs.access(filePath, fsSync.constants.F_OK);
136
- return true;
137
- } catch {
138
- return false;
139
- }
140
- }
141
-
142
- /**
143
- * List files in directory
144
- */
145
- async listFiles(dirPath: string, pattern?: RegExp): Promise<string[]> {
146
- try {
147
- const files = await fs.readdir(dirPath, { recursive: true });
148
-
149
- if (pattern) {
150
- return files.filter((file) => pattern.test(file));
151
- }
152
-
153
- return files;
154
- } catch (error) {
155
- throw createFileSystemError('list', dirPath, error as Error & { code?: string });
156
- }
157
- }
158
-
159
- /**
160
- * Recursively scan a directory and return all text files as FileEntry[]
161
- * Supported extensions: .md, .mdc, .txt, .yaml, .yml, .json
162
- */
163
- async scanDirectory(dirPath: string): Promise<Array<{ path: string; content: string }>> {
164
- const TEXT_EXTENSIONS = new Set(['.md', '.mdc', '.txt', '.yaml', '.yml', '.json']);
165
- const results: Array<{ path: string; content: string }> = [];
166
-
167
- const walk = async (currentPath: string, relBase: string): Promise<void> => {
168
- let entries: fsSync.Dirent[];
169
- try {
170
- entries = await fs.readdir(currentPath, { withFileTypes: true });
171
- } catch (error) {
172
- throw createFileSystemError('list', currentPath, error as Error & { code?: string });
173
- }
174
-
175
- for (const entry of entries) {
176
- const fullPath = path.join(currentPath, entry.name);
177
- const relPath = path.join(relBase, entry.name);
178
-
179
- if (entry.isDirectory()) {
180
- await walk(fullPath, relPath);
181
- } else if (entry.isFile()) {
182
- const ext = path.extname(entry.name).toLowerCase();
183
- if (TEXT_EXTENSIONS.has(ext)) {
184
- try {
185
- const content = await fs.readFile(fullPath, 'utf-8');
186
- if (content.trim().length > 0) {
187
- results.push({ path: relPath, content });
188
- }
189
- } catch {
190
- // Skip unreadable files silently
191
- logger.warn({ filePath: fullPath }, 'Skipped unreadable file during directory scan');
192
- }
193
- }
194
- }
195
- }
196
- };
197
-
198
- await walk(dirPath, '');
199
-
200
- if (results.length === 0) {
201
- throw createValidationError(
202
- dirPath,
203
- 'directory',
204
- `No text files found in directory: ${dirPath}`
205
- );
206
- }
207
-
208
- logger.debug({ dirPath, fileCount: results.length }, 'Directory scan completed');
209
- return results;
210
- }
211
-
212
- /**
213
- * Remove empty directories recursively
214
- */
215
- async removeEmptyDirs(dirPath: string): Promise<void> {
216
- try {
217
- const files = await fs.readdir(dirPath);
218
-
219
- if (files.length === 0) {
220
- await fs.rmdir(dirPath);
221
- logger.debug({ dirPath }, 'Empty directory removed');
222
-
223
- // Check parent directory
224
- const parentDir = path.dirname(dirPath);
225
- if (parentDir !== dirPath) {
226
- await this.removeEmptyDirs(parentDir);
227
- }
228
- }
229
- } catch (error) {
230
- // Ignore errors (directory might not be empty or already deleted)
231
- }
232
- }
233
- }
234
-
235
- export const filesystemManager = new FilesystemManager();