@hienlh/ppm 0.13.64 → 0.13.66

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 (72) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/assets/skills/ppm/SKILL.md +1 -1
  3. package/assets/skills/ppm/references/cli-reference.md +4 -4
  4. package/assets/skills/ppm/references/http-api.md +2 -1
  5. package/dist/web/assets/architecture-PBZL5I3N-CS5Rvu_a.js +1 -0
  6. package/dist/web/assets/{audio-preview-Bog1sIoF.js → audio-preview-B8XiU4Bw.js} +1 -1
  7. package/dist/web/assets/{chat-tab-B-uVAh4d.js → chat-tab-B1m7T_2n.js} +3 -3
  8. package/dist/web/assets/{code-editor-cDv3opsJ.js → code-editor-CQSDgP7X.js} +2 -2
  9. package/dist/web/assets/{conflict-editor-D5sEfbcX.js → conflict-editor-BPjmtXlC.js} +1 -1
  10. package/dist/web/assets/{database-viewer-BGBVsG5J.js → database-viewer-Cl31pR9W.js} +1 -1
  11. package/dist/web/assets/{diff-viewer-B-O1mvHO.js → diff-viewer-sbO35hMr.js} +1 -1
  12. package/dist/web/assets/{docx-preview-ByzSlSgn.js → docx-preview-D_P_e_0O.js} +1 -1
  13. package/dist/web/assets/{extension-webview-0qfU1r7z.js → extension-webview-B2Q7T_NQ.js} +1 -1
  14. package/dist/web/assets/{git-log-panel-C1T8bav0.js → git-log-panel-CAa4j8NA.js} +1 -1
  15. package/dist/web/assets/gitGraph-HDMCJU4V-BjUgCE-3.js +1 -0
  16. package/dist/web/assets/{glide-data-grid-DV8ht1BP.js → glide-data-grid-DbtdLkFk.js} +1 -1
  17. package/dist/web/assets/{image-preview-Dbo7SAVb.js → image-preview-DjWCljN-.js} +1 -1
  18. package/dist/web/assets/{index-DU_JZ5MY.js → index-PZd81rhr.js} +4 -4
  19. package/dist/web/assets/info-3K5VOQVL-Bu3VpM9a.js +1 -0
  20. package/dist/web/assets/keybindings-store-DZjJtyij.js +1 -0
  21. package/dist/web/assets/{markdown-renderer-D-QbsfIC.js → markdown-renderer-BojoStRy.js} +3 -3
  22. package/dist/web/assets/notification-store-CgsqI4c0.js +1 -0
  23. package/dist/web/assets/packet-RMMSAZCW-C83Lg2yy.js +1 -0
  24. package/dist/web/assets/{pdf-preview-DV96VPTb.js → pdf-preview-19LY16zS.js} +1 -1
  25. package/dist/web/assets/pie-UPGHQEXC-DoT-QQxi.js +1 -0
  26. package/dist/web/assets/{port-forwarding-tab-C4OYC71C.js → port-forwarding-tab-DIqVwGrL.js} +1 -1
  27. package/dist/web/assets/{postgres-viewer-hb-_twEU.js → postgres-viewer-DOTykgcg.js} +1 -1
  28. package/dist/web/assets/radar-KQ55EAFF-B6r4mqYF.js +1 -0
  29. package/dist/web/assets/{settings-store-CSDOihqv.js → settings-store-BFlBSwKg.js} +1 -1
  30. package/dist/web/assets/{settings-tab-BUCIqVAl.js → settings-tab-C5S_iYSH.js} +1 -1
  31. package/dist/web/assets/{sql-query-editor-C7YgtDR3.js → sql-query-editor-BsxW0lTw.js} +1 -1
  32. package/dist/web/assets/{sqlite-viewer-z3pGFSje.js → sqlite-viewer-Fq4NnQg6.js} +1 -1
  33. package/dist/web/assets/{system-monitor-tab-Bj6pcRmV.js → system-monitor-tab-C51mwQcv.js} +1 -1
  34. package/dist/web/assets/{terminal-tab-DbxLHofN.js → terminal-tab-Lu2U4vpg.js} +1 -1
  35. package/dist/web/assets/treemap-KZPCXAKY-3t3gW0fB.js +1 -0
  36. package/dist/web/assets/{use-monaco-theme-qx6SfVRk.js → use-monaco-theme-6AirEH08.js} +1 -1
  37. package/dist/web/assets/{vendor-mermaid-DCie7hiR.js → vendor-mermaid-DU911Xa9.js} +2 -2
  38. package/dist/web/assets/{video-preview-DylSBAzo.js → video-preview-8Vrdwy25.js} +1 -1
  39. package/dist/web/index.html +3 -3
  40. package/dist/web/sw.js +1 -1
  41. package/package.json +1 -1
  42. package/src/server/middleware/auth.ts +1 -1
  43. package/src/server/routes/files.ts +2 -2
  44. package/src/server/routes/fs-browse.ts +20 -6
  45. package/src/services/download-token.service.ts +1 -2
  46. package/src/services/resource-monitor-utils.ts +10 -1
  47. package/src/services/resource-monitor.service.ts +1 -1
  48. package/src/web/lib/file-download.ts +8 -0
  49. package/.opencode/.env.example +0 -98
  50. package/.opencode/skills/ads-management/scripts/.env.example +0 -13
  51. package/.opencode/skills/ai-multimodal/.env.example +0 -230
  52. package/.opencode/skills/cip-design/.env.example +0 -6
  53. package/.opencode/skills/devops/.env.example +0 -76
  54. package/.opencode/skills/docs-seeker/.env.example +0 -15
  55. package/.opencode/skills/elevenlabs/.env.example +0 -3
  56. package/.opencode/skills/marketing-dashboard/.env.example +0 -15
  57. package/.opencode/skills/marketing-dashboard/app/.env.example +0 -2
  58. package/.opencode/skills/marketing-dashboard/server/.env.example +0 -2
  59. package/.opencode/skills/mcp-management/scripts/dist/analyze-tools.js +0 -70
  60. package/.opencode/skills/mcp-management/scripts/dist/cli.js +0 -160
  61. package/.opencode/skills/mcp-management/scripts/dist/mcp-client.js +0 -183
  62. package/.opencode/skills/payment-integration/scripts/.env.example +0 -20
  63. package/.opencode/skills/sequential-thinking/.env.example +0 -8
  64. package/dist/web/assets/architecture-PBZL5I3N-DLKD1Xjj.js +0 -1
  65. package/dist/web/assets/gitGraph-HDMCJU4V-2a0r4GHr.js +0 -1
  66. package/dist/web/assets/info-3K5VOQVL-CWKw4e0V.js +0 -1
  67. package/dist/web/assets/keybindings-store-0FUOwc9I.js +0 -1
  68. package/dist/web/assets/notification-store-bwd1UKbs.js +0 -1
  69. package/dist/web/assets/packet-RMMSAZCW-Ar00Wbhd.js +0 -1
  70. package/dist/web/assets/pie-UPGHQEXC-Q4ssDdib.js +0 -1
  71. package/dist/web/assets/radar-KQ55EAFF-kq5v4OKX.js +0 -1
  72. package/dist/web/assets/treemap-KZPCXAKY-DChODgHt.js +0 -1
@@ -1,13 +0,0 @@
1
- # Google Ads API credentials
2
- GOOGLE_ADS_DEVELOPER_TOKEN=your_developer_token
3
- GOOGLE_ADS_CLIENT_ID=your_client_id.apps.googleusercontent.com
4
- GOOGLE_ADS_CLIENT_SECRET=your_client_secret
5
- GOOGLE_ADS_REFRESH_TOKEN=1//your_refresh_token
6
- GOOGLE_ADS_CUSTOMER_ID=1234567890
7
- GOOGLE_ADS_LOGIN_CUSTOMER_ID=your_mcc_id
8
-
9
- # Meta/Facebook Ads API credentials
10
- META_APP_ID=your_app_id
11
- META_APP_SECRET=your_app_secret
12
- META_ACCESS_TOKEN=your_system_user_token
13
- META_AD_ACCOUNT_ID=act_123456789
@@ -1,230 +0,0 @@
1
- # Google Gemini API Configuration
2
-
3
- # ============================================================================
4
- # OPTION 1: Google AI Studio (Default - Recommended for most users)
5
- # ============================================================================
6
- # Get your API key: https://aistudio.google.com/apikey
7
- GEMINI_API_KEY=your_api_key_here
8
-
9
- # ============================================================================
10
- # API Key Rotation (Optional - For high-volume usage)
11
- # ============================================================================
12
- # Add multiple API keys for automatic rotation on rate limit errors.
13
- # Free tier accounts are heavily rate-limited; rotation helps distribute load.
14
- #
15
- # Format: GEMINI_API_KEY_N where N is 2, 3, 4, etc.
16
- # The primary GEMINI_API_KEY is always used first.
17
- #
18
- # GEMINI_API_KEY_2=your_second_api_key
19
- # GEMINI_API_KEY_3=your_third_api_key
20
- # GEMINI_API_KEY_4=your_fourth_api_key
21
- #
22
- # Features:
23
- # - Auto-rotates on RESOURCE_EXHAUSTED / 429 errors
24
- # - 60-second cooldown per key after rate limit
25
- # - Logs rotation events with --verbose flag
26
- # - Backward compatible: single key still works
27
-
28
- # ============================================================================
29
- # OPTION 2: Vertex AI (Google Cloud Platform)
30
- # ============================================================================
31
- # Uncomment these lines to use Vertex AI instead of Google AI Studio
32
- # GEMINI_USE_VERTEX=true
33
- # VERTEX_PROJECT_ID=your-gcp-project-id
34
- # VERTEX_LOCATION=us-central1
35
-
36
- # ============================================================================
37
- # Model Selection (Optional)
38
- # ============================================================================
39
- # Override default models for specific capabilities
40
- # If not set, intelligent defaults are used based on task type
41
-
42
- # --- Image Generation ---
43
- # Used by: --task generate (image)
44
- # Default: gemini-2.5-flash-image (Nano Banana Flash - fast, cost-effective)
45
- # Alternative: imagen-4.0-generate-001 (production quality)
46
- # NOTE: All image generation requires billing - no free tier available (limit: 0)
47
- # Options:
48
- # gemini-2.5-flash-image - Nano Banana Flash: fast, ~$1/1M tokens (DEFAULT)
49
- # gemini-3-pro-image-preview - Nano Banana Pro: 4K text, reasoning (requires billing)
50
- # imagen-4.0-generate-001 - Imagen 4 Standard: production quality (~$0.02/image)
51
- # imagen-4.0-ultra-generate-001 - Imagen 4 Ultra: maximum quality (~$0.04/image)
52
- # imagen-4.0-fast-generate-001 - Imagen 4 Fast: speed-optimized (~$0.01/image)
53
- # IMAGE_GEN_MODEL=gemini-2.5-flash-image
54
-
55
- # --- Video Generation ---
56
- # Used by: --task generate-video (new capability)
57
- # Default: veo-3.1-generate-preview
58
- # NOTE: Video generation requires billing - no free tier fallback available
59
- # Options:
60
- # veo-3.1-generate-preview - Latest, native audio, frame control (requires billing)
61
- # veo-3.1-fast-generate-preview - Speed-optimized for business (requires billing)
62
- # veo-3.0-generate-001 - Stable, native audio, 8s videos (requires billing)
63
- # veo-3.0-fast-generate-001 - Stable fast variant (requires billing)
64
- # VIDEO_GEN_MODEL=veo-3.1-generate-preview
65
-
66
- # --- Multimodal Analysis ---
67
- # Used by: --task analyze, transcribe, extract
68
- # Default: gemini-2.5-flash
69
- # Options:
70
- # gemini-3-pro-preview - Latest, agentic workflows, 1M context
71
- # gemini-2.5-flash - Best price/performance (recommended)
72
- # gemini-2.5-pro - Highest quality
73
- # MULTIMODAL_MODEL=gemini-2.5-flash
74
-
75
- # --- Legacy Compatibility ---
76
- # Generic model override (use specific variables above instead)
77
- # GEMINI_MODEL=gemini-2.5-flash
78
- # GEMINI_IMAGE_GEN_MODEL=gemini-2.5-flash-image
79
-
80
- # ============================================================================
81
- # MiniMax API Configuration (Optional - for image/video/speech/music generation)
82
- # ============================================================================
83
- # Get your API key: https://platform.minimax.io/user-center/basic-information/interface-key
84
- # MINIMAX_API_KEY=your_minimax_api_key_here
85
-
86
- # --- MiniMax Image Generation ---
87
- # Models: image-01 (standard), image-01-live (enhanced)
88
- # Cost: ~$0.03/image | Rate: 10 RPM
89
- # MINIMAX_IMAGE_MODEL=image-01
90
-
91
- # --- MiniMax Video Generation (Hailuo) ---
92
- # Models: MiniMax-Hailuo-2.3, MiniMax-Hailuo-2.3-Fast, MiniMax-Hailuo-02, S2V-01
93
- # Cost: $0.25-0.52/video | Rate: 5 RPM
94
- # MINIMAX_VIDEO_MODEL=MiniMax-Hailuo-2.3
95
-
96
- # --- MiniMax Speech/TTS ---
97
- # Models: speech-2.8-hd (best), speech-2.8-turbo (fast)
98
- # Cost: $30-50/1M chars | Rate: 60 RPM | 300+ voices, 40+ languages
99
- # MINIMAX_SPEECH_MODEL=speech-2.8-hd
100
-
101
- # --- MiniMax Music Generation ---
102
- # Models: music-2.5 (4-minute songs with vocals)
103
- # Cost: $0.03-0.075/gen | Rate: 120 RPM
104
- # MINIMAX_MUSIC_MODEL=music-2.5
105
-
106
- # ============================================================================
107
- # Rate Limiting Configuration (Optional)
108
- # ============================================================================
109
- # Requests per minute limit (adjust based on your tier)
110
- # GEMINI_RPM_LIMIT=15
111
-
112
- # Tokens per minute limit
113
- # GEMINI_TPM_LIMIT=4000000
114
-
115
- # Requests per day limit
116
- # GEMINI_RPD_LIMIT=1500
117
-
118
- # ============================================================================
119
- # Video Generation Options (Optional)
120
- # ============================================================================
121
- # Video duration in seconds (8s only for now)
122
- # VEO_DURATION=8
123
-
124
- # Video resolution: 720p or 1080p
125
- # VEO_RESOLUTION=1080p
126
-
127
- # Aspect ratio: 16:9, 9:16, 1:1 (16:9 is default)
128
- # VEO_ASPECT_RATIO=16:9
129
-
130
- # Frame rate: 24fps (fixed for now)
131
- # VEO_FPS=24
132
-
133
- # Enable native audio generation
134
- # VEO_AUDIO=true
135
-
136
- # ============================================================================
137
- # Image Generation Options (Optional)
138
- # ============================================================================
139
- # Number of images to generate (1-4)
140
- # IMAGEN_NUM_IMAGES=1
141
-
142
- # Image size: 1K or 2K (Ultra/Standard only)
143
- # IMAGEN_SIZE=1K
144
-
145
- # Aspect ratio: 1:1, 16:9, 9:16, 4:3, 3:4
146
- # IMAGEN_ASPECT_RATIO=1:1
147
-
148
- # Enable person generation (restricted in EEA, CH, UK)
149
- # IMAGEN_PERSON_GENERATION=true
150
-
151
- # Add SynthID watermark (always enabled by default)
152
- # IMAGEN_WATERMARK=true
153
-
154
- # ============================================================================
155
- # Processing Options (Optional)
156
- # ============================================================================
157
- # Video resolution mode: default or low-res
158
- # low-res uses ~100 tokens/second vs ~300 for default
159
- # GEMINI_VIDEO_RESOLUTION=default
160
-
161
- # Audio quality: default (16 Kbps mono, auto-downsampled)
162
- # GEMINI_AUDIO_QUALITY=default
163
-
164
- # PDF processing mode: inline (<20MB) or file-api (>20MB, automatic)
165
- # GEMINI_PDF_MODE=auto
166
-
167
- # ============================================================================
168
- # Retry Configuration (Optional)
169
- # ============================================================================
170
- # Maximum retry attempts for failed requests
171
- # GEMINI_MAX_RETRIES=3
172
-
173
- # Initial retry delay in seconds (uses exponential backoff)
174
- # GEMINI_RETRY_DELAY=1
175
-
176
- # ============================================================================
177
- # Output Configuration (Optional)
178
- # ============================================================================
179
- # Default output directory for generated images
180
- # OUTPUT_DIR=./output
181
-
182
- # Image output format (png or jpeg)
183
- # IMAGE_FORMAT=png
184
-
185
- # Image quality for JPEG (1-100)
186
- # IMAGE_QUALITY=95
187
-
188
- # ============================================================================
189
- # Context Caching (Optional)
190
- # ============================================================================
191
- # Enable context caching for repeated queries on same file
192
- # GEMINI_ENABLE_CACHING=true
193
-
194
- # Cache TTL in seconds (default: 1800 = 30 minutes)
195
- # GEMINI_CACHE_TTL=1800
196
-
197
- # ============================================================================
198
- # Logging (Optional)
199
- # ============================================================================
200
- # Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL
201
- # LOG_LEVEL=INFO
202
-
203
- # Log file path
204
- # LOG_FILE=./logs/gemini.log
205
-
206
- # ============================================================================
207
- # Pricing Reference (as of 2025-11)
208
- # ============================================================================
209
- # Gemini 2.5 Flash: $1.00/1M input, $0.10/1M output
210
- # Gemini 2.5 Pro: $3.00/1M input, $12.00/1M output
211
- # Gemini 3 Pro: $2.00/1M input (<200k), $4.00 (>200k), $12/$18 output
212
- # Imagen 4: ~$0.01-$0.04 per image (varies by variant)
213
- # Veo 3: TBD (preview pricing)
214
- # Monitor: https://ai.google.dev/pricing
215
-
216
- # ============================================================================
217
- # Notes
218
- # ============================================================================
219
- # 1. Never commit API keys to version control
220
- # 2. Add .env to .gitignore
221
- # 3. API keys can be restricted in Google Cloud Console
222
- # 4. Monitor usage at: https://aistudio.google.com/apikey
223
- # 5. Free tier limits: 15 RPM, 1M-4M TPM, 1,500 RPD
224
- # 6. Vertex AI requires GCP authentication via gcloud CLI
225
- # 7. Model defaults (Dec 2025):
226
- # - Image gen: gemini-2.5-flash-image (Nano Banana Flash - default)
227
- # - Image gen: imagen-4.0-generate-001 (alternative for production)
228
- # - Video gen: veo-3.1-generate-preview
229
- # - Analysis: gemini-2.5-flash
230
- # 8. Preview models (veo-3.1, gemini-3) may have API changes
@@ -1,6 +0,0 @@
1
- # CIP Design Skill Environment Variables
2
- # Copy this file to .env and fill in your API key
3
-
4
- # Gemini API Key (required for image generation)
5
- # Get from: https://aistudio.google.com/apikey
6
- GEMINI_API_KEY=your-gemini-api-key-here
@@ -1,76 +0,0 @@
1
- # DevOps Skill - Environment Variables
2
-
3
- # =============================================================================
4
- # Cloudflare Configuration
5
- # =============================================================================
6
- # Get these from: https://dash.cloudflare.com
7
- # API Token: Profile -> API Tokens -> Create Token
8
- # Account ID: Overview -> Account ID (right sidebar)
9
-
10
- CLOUDFLARE_API_TOKEN=your_cloudflare_api_token_here
11
- CLOUDFLARE_ACCOUNT_ID=your_cloudflare_account_id_here
12
-
13
- # Optional: Specific zone configuration
14
- # CLOUDFLARE_ZONE_ID=your_zone_id_here
15
-
16
- # =============================================================================
17
- # Google Cloud Configuration
18
- # =============================================================================
19
- # Authentication via service account key file or gcloud CLI
20
- # Download from: IAM & Admin -> Service Accounts -> Create Key
21
-
22
- # Option 1: Service account key file path
23
- GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
24
-
25
- # Option 2: Project configuration
26
- # GCP_PROJECT_ID=your-project-id
27
- # GCP_REGION=us-central1
28
- # GCP_ZONE=us-central1-a
29
-
30
- # =============================================================================
31
- # Docker Configuration
32
- # =============================================================================
33
- # Optional: Docker registry authentication
34
-
35
- # Docker Hub
36
- # DOCKER_USERNAME=your_docker_username
37
- # DOCKER_PASSWORD=your_docker_password
38
-
39
- # Google Container Registry (GCR)
40
- # GCR_HOSTNAME=gcr.io
41
- # GCR_PROJECT_ID=your-project-id
42
-
43
- # AWS ECR
44
- # AWS_ACCOUNT_ID=123456789012
45
- # AWS_REGION=us-east-1
46
-
47
- # =============================================================================
48
- # CI/CD Configuration
49
- # =============================================================================
50
- # Optional: For automated deployments
51
-
52
- # GitHub Actions
53
- # GITHUB_TOKEN=your_github_token
54
-
55
- # GitLab CI
56
- # GITLAB_TOKEN=your_gitlab_token
57
-
58
- # =============================================================================
59
- # Monitoring & Logging
60
- # =============================================================================
61
- # Optional: For observability
62
-
63
- # Sentry
64
- # SENTRY_DSN=your_sentry_dsn
65
-
66
- # Datadog
67
- # DD_API_KEY=your_datadog_api_key
68
-
69
- # =============================================================================
70
- # Notes
71
- # =============================================================================
72
- # 1. Copy this file to .env and fill in your actual values
73
- # 2. Never commit .env file to version control
74
- # 3. Use different credentials for dev/staging/production
75
- # 4. Rotate credentials regularly
76
- # 5. Use least-privilege principle for API tokens
@@ -1,15 +0,0 @@
1
- # Context7 API Configuration (optional)
2
- # Get your API key from https://context7.com/dashboard/api-keys
3
- CONTEXT7_API_KEY=
4
-
5
- # Gemini API Configuration (optional, for ai-multimodal integration)
6
- # Get your API key from https://aistudio.google.com/app/apikey
7
- GEMINI_API_KEY=
8
-
9
- # GitHub Token (optional, for higher rate limits on repository analysis)
10
- # Create at https://github.com/settings/tokens
11
- GITHUB_TOKEN=
12
-
13
- # Output settings
14
- OUTPUT_FORMAT=json
15
- DEBUG=false
@@ -1,3 +0,0 @@
1
- # ElevenLabs API Key
2
- # Get your key at: https://elevenlabs.io/app/settings/api-keys
3
- ELEVENLABS_API_KEY=your_api_key_here
@@ -1,15 +0,0 @@
1
- # Marketing Dashboard Environment Variables
2
-
3
- # Server Configuration
4
- PORT=3457
5
- NODE_ENV=development
6
- ALLOWED_ORIGINS=http://localhost:5173,http://localhost:3457
7
-
8
- # Security
9
- # API Key for authentication (required in production)
10
- # Generate a secure key: openssl rand -hex 32
11
- API_KEY=your-secure-api-key-here
12
-
13
- # Skip authentication in development (set to 'true' only for local dev)
14
- # WARNING: Never set to 'true' in production
15
- SKIP_AUTH=true
@@ -1,2 +0,0 @@
1
- # API Base URL for the marketing dashboard backend
2
- VITE_API_BASE_URL=http://localhost:3457/api
@@ -1,2 +0,0 @@
1
- # API Base URL for static assets and external URLs
2
- API_BASE_URL=http://localhost:3457
@@ -1,70 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Tool Analyzer - Intelligently selects relevant MCP tools for tasks
4
- */
5
- /**
6
- * Analyze tools and return those relevant to the task
7
- */
8
- export function analyzeToolsForTask(tools, taskDescription) {
9
- const keywords = extractKeywords(taskDescription);
10
- const scoredTools = tools.map(tool => ({
11
- tool,
12
- score: calculateRelevanceScore(tool, keywords, taskDescription),
13
- reasons: explainScore(tool, keywords, taskDescription)
14
- }));
15
- // Sort by score descending
16
- scoredTools.sort((a, b) => b.score - a.score);
17
- // Filter tools with score above threshold
18
- const threshold = 0.3;
19
- const relevant = scoredTools.filter(st => st.score > threshold);
20
- return {
21
- relevantTools: relevant.map(st => st.tool),
22
- reasoning: relevant.map(st => `${st.tool.name} (${st.tool.serverName}): ${st.reasons.join('; ')}`),
23
- confidence: relevant.length > 0
24
- ? relevant[0].score
25
- : 0
26
- };
27
- }
28
- function extractKeywords(text) {
29
- const stopWords = new Set([
30
- 'the', 'a', 'an', 'and', 'or', 'but', 'in', 'on', 'at',
31
- 'to', 'for', 'of', 'with', 'by', 'from', 'as', 'is', 'was', 'are'
32
- ]);
33
- return text
34
- .toLowerCase()
35
- .split(/\W+/)
36
- .filter(word => word.length > 2 && !stopWords.has(word));
37
- }
38
- function calculateRelevanceScore(tool, keywords, taskDescription) {
39
- let score = 0;
40
- const toolText = `${tool.name} ${tool.description}`.toLowerCase();
41
- // Keyword matching
42
- for (const keyword of keywords) {
43
- if (toolText.includes(keyword)) {
44
- score += 0.2;
45
- }
46
- }
47
- // Exact phrase matching
48
- const taskLower = taskDescription.toLowerCase();
49
- if (toolText.includes(taskLower) || taskLower.includes(tool.name.toLowerCase())) {
50
- score += 0.5;
51
- }
52
- // Schema complexity bonus (more params = more specialized)
53
- if (tool.inputSchema?.properties) {
54
- const paramCount = Object.keys(tool.inputSchema.properties).length;
55
- score += Math.min(paramCount * 0.05, 0.3);
56
- }
57
- return Math.min(score, 1.0);
58
- }
59
- function explainScore(tool, keywords, taskDescription) {
60
- const reasons = [];
61
- const toolText = `${tool.name} ${tool.description}`.toLowerCase();
62
- const matchedKeywords = keywords.filter(k => toolText.includes(k));
63
- if (matchedKeywords.length > 0) {
64
- reasons.push(`matches keywords: ${matchedKeywords.join(', ')}`);
65
- }
66
- if (tool.description) {
67
- reasons.push(`description: ${tool.description.slice(0, 100)}`);
68
- }
69
- return reasons;
70
- }
@@ -1,160 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * MCP Management CLI - Command-line interface for MCP operations
4
- */
5
- import { MCPClientManager } from './mcp-client.js';
6
- import { writeFileSync, mkdirSync } from 'fs';
7
- import { dirname, join } from 'path';
8
- import { fileURLToPath } from 'url';
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = dirname(__filename);
11
- const GLOBAL_TIMEOUT_MS = parseInt(process.env.MCP_TIMEOUT || '120000', 10);
12
- let globalManager = null;
13
- function setupShutdownHandlers() {
14
- const shutdown = async (signal) => {
15
- console.log(`\nReceived ${signal}, cleaning up...`);
16
- if (globalManager) {
17
- await globalManager.cleanup();
18
- }
19
- process.exit(0);
20
- };
21
- process.on('SIGINT', () => shutdown('SIGINT'));
22
- process.on('SIGTERM', () => shutdown('SIGTERM'));
23
- process.on('SIGHUP', () => shutdown('SIGHUP'));
24
- process.on('unhandledRejection', (reason) => {
25
- console.error('Unhandled rejection:', reason);
26
- process.exit(1);
27
- });
28
- }
29
- async function main() {
30
- const args = process.argv.slice(2);
31
- const command = args[0];
32
- // Setup shutdown handlers
33
- setupShutdownHandlers();
34
- // Check for help flags BEFORE connecting to servers
35
- if (!command || command === '--help' || command === 'help') {
36
- printUsage();
37
- process.exit(0);
38
- }
39
- // Global timeout
40
- const timeoutHandle = setTimeout(() => {
41
- console.error('Global timeout exceeded, forcing exit');
42
- process.exit(1);
43
- }, GLOBAL_TIMEOUT_MS);
44
- timeoutHandle.unref();
45
- const manager = new MCPClientManager();
46
- globalManager = manager;
47
- try {
48
- // Load config
49
- await manager.loadConfig();
50
- console.log('✓ Config loaded');
51
- // Connect to all servers
52
- await manager.connectAll();
53
- console.log('✓ Connected to all MCP servers\n');
54
- switch (command) {
55
- case 'list-tools':
56
- await listTools(manager);
57
- break;
58
- case 'list-prompts':
59
- await listPrompts(manager);
60
- break;
61
- case 'list-resources':
62
- await listResources(manager);
63
- break;
64
- case 'call-tool':
65
- await callTool(manager, args[1], args[2], args[3]);
66
- break;
67
- default:
68
- printUsage();
69
- }
70
- await manager.cleanup();
71
- process.exit(0);
72
- }
73
- catch (error) {
74
- console.error('Error:', error);
75
- process.exit(1);
76
- }
77
- }
78
- async function listTools(manager) {
79
- const tools = await manager.getAllTools();
80
- console.log(`Found ${tools.length} tools:\n`);
81
- for (const tool of tools) {
82
- console.log(`📦 ${tool.serverName} / ${tool.name}`);
83
- console.log(` ${tool.description}`);
84
- if (tool.inputSchema?.properties) {
85
- console.log(` Parameters: ${Object.keys(tool.inputSchema.properties).join(', ')}`);
86
- }
87
- console.log('');
88
- }
89
- // Save tools to JSON file
90
- const assetsDir = join(__dirname, '..', 'assets');
91
- const toolsPath = join(assetsDir, 'tools.json');
92
- try {
93
- mkdirSync(assetsDir, { recursive: true });
94
- writeFileSync(toolsPath, JSON.stringify(tools, null, 2));
95
- console.log(`\n✓ Tools saved to ${toolsPath}`);
96
- }
97
- catch (error) {
98
- console.error(`\n✗ Failed to save tools: ${error}`);
99
- }
100
- }
101
- async function listPrompts(manager) {
102
- const prompts = await manager.getAllPrompts();
103
- console.log(`Found ${prompts.length} prompts:\n`);
104
- for (const prompt of prompts) {
105
- console.log(`💬 ${prompt.serverName} / ${prompt.name}`);
106
- console.log(` ${prompt.description}`);
107
- if (prompt.arguments && prompt.arguments.length > 0) {
108
- console.log(` Arguments: ${prompt.arguments.map((a) => a.name).join(', ')}`);
109
- }
110
- console.log('');
111
- }
112
- }
113
- async function listResources(manager) {
114
- const resources = await manager.getAllResources();
115
- console.log(`Found ${resources.length} resources:\n`);
116
- for (const resource of resources) {
117
- console.log(`📄 ${resource.serverName} / ${resource.name}`);
118
- console.log(` URI: ${resource.uri}`);
119
- if (resource.description) {
120
- console.log(` ${resource.description}`);
121
- }
122
- if (resource.mimeType) {
123
- console.log(` Type: ${resource.mimeType}`);
124
- }
125
- console.log('');
126
- }
127
- }
128
- async function callTool(manager, serverName, toolName, argsJson) {
129
- if (!serverName || !toolName || !argsJson) {
130
- console.error('Usage: cli.ts call-tool <server> <tool> <json-args>');
131
- process.exit(1);
132
- }
133
- const args = JSON.parse(argsJson);
134
- console.log(`Calling ${serverName}/${toolName}...`);
135
- const result = await manager.callTool(serverName, toolName, args);
136
- console.log('\nResult:');
137
- console.log(JSON.stringify(result, null, 2));
138
- }
139
- function printUsage() {
140
- console.log(`
141
- MCP Management CLI
142
-
143
- Usage:
144
- cli.ts <command> [options]
145
-
146
- Commands:
147
- list-tools List all tools and save to assets/tools.json
148
- list-prompts List all prompts from all MCP servers
149
- list-resources List all resources from all MCP servers
150
- call-tool <server> <tool> <json> Call a specific tool
151
-
152
- Examples:
153
- cli.ts list-tools
154
- cli.ts call-tool memory create_entities '{"entities":[{"name":"Alice","entityType":"person"}]}'
155
- cli.ts call-tool human-mcp playwright_screenshot_fullpage '{"url":"https://example.com"}'
156
-
157
- Note: Tool analysis is done by the LLM reading assets/tools.json directly.
158
- `);
159
- }
160
- main();