polydev-ai 1.4.4 → 1.5.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.
package/README.md CHANGED
@@ -1,160 +1,219 @@
1
- # Polydev AI MCP Server
1
+ # Polydev AI
2
2
 
3
- Get diverse AI perspectives from multiple LLMs via Model Context Protocol (MCP). Supports Cline, Claude Code, and other MCP clients with local CLI detection and remote AI perspectives.
3
+ **Advanced Model Context Protocol Platform with Multi-LLM Integrations**
4
+
5
+ <!-- Last updated: 2024-12-12 -->
6
+
7
+ [polydev.ai](https://polydev.ai) | Live Platform
8
+
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ Polydev AI is an advanced Model Context Protocol (MCP) platform providing comprehensive multi-LLM integrations, subscription-based CLI access, OAuth bridges, and advanced tooling for AI development.
4
14
 
5
15
  ## Features
6
16
 
7
- - 🤖 **Multi-Model AI Perspectives**: Get responses from GPT-4, Claude, Gemini, and more
8
- - 🔧 **Local CLI Detection**: Automatically detect and use Claude Code, Codex CLI, Gemini CLI
9
- - ⚡ **Smart Caching**: Intelligent refresh intervals based on CLI status
10
- - 🔄 **Fallback Support**: Local CLI + remote perspectives for comprehensive responses
11
- - 🔐 **Secure**: Token-based authentication with your Polydev account
17
+ ### 🤖 Comprehensive LLM Integration
12
18
 
13
- ## Installation
19
+ - **API-Based Providers**: Direct integration with 8+ providers (Anthropic, OpenAI, Google, etc.)
20
+ - **Subscription-Based CLI Access**: Use your existing ChatGPT Plus, Claude Pro, GitHub Copilot subscriptions
21
+ - **Unified Interface**: Single API for all providers with consistent streaming responses
22
+ - **Auto-Detection**: Automatic CLI tool discovery and path configuration
14
23
 
15
- ### For Claude Code Users
24
+ ### 🔧 CLI Provider Support
16
25
 
17
- ```bash
18
- # Install globally
19
- npm install -g polydev-ai
26
+ | Provider | Integration | Authentication |
27
+ |----------|-------------|----------------|
28
+ | **Codex CLI** | Access GPT-5 with high reasoning | ChatGPT Plus subscription |
29
+ | **Claude Code CLI** | Claude via Anthropic | Anthropic Pro subscription |
30
+ | **Gemini CLI** | Google Cloud | Google Cloud authentication |
31
+ | **GitHub Copilot** | VS Code Language Model API | GitHub Copilot subscription |
20
32
 
21
- # Or use directly with npx
22
- npx polydev-ai
23
- ```
33
+ ### 🛠 Advanced Tooling
24
34
 
25
- ### For Cline Users
26
-
27
- Add to your MCP settings (`.cline/mcp_servers.json`):
28
-
29
- ```json
30
- {
31
- "mcpServers": {
32
- "polydev": {
33
- "command": "npx",
34
- "args": ["polydev-ai"],
35
- "env": {
36
- "POLYDEV_USER_TOKEN": "your_token_here"
37
- }
38
- }
39
- }
40
- }
41
- ```
35
+ - **Model Context Protocol (MCP)**: Hosted MCP server with OAuth authentication
36
+ - **Multi-Authentication**: Both OAuth and API token support for maximum flexibility
37
+ - **Process Execution**: Cross-platform CLI management with timeout handling
38
+ - **Path Auto-Discovery**: Smart detection of CLI installations across Windows, macOS, Linux
39
+ - **Real-time Status**: Live CLI availability and authentication checking
42
40
 
43
- ## Configuration
41
+ ### 🔒 Security & Authentication
44
42
 
45
- ### Get Your Token
43
+ - **Encrypted Storage**: Browser-based API key encryption using SubtleCrypto API
44
+ - **OAuth Bridges**: Secure authentication flows
45
+ - **Subscription Auth**: No API costs - use existing subscriptions
46
+ - **Local Storage**: Keys never leave your device
46
47
 
47
- 1. Sign up at [polydev.ai](https://polydev.ai)
48
- 2. Go to your dashboard and copy your MCP token
49
- 3. Set the environment variable:
48
+ ### 📊 Monitoring & Analytics
50
49
 
51
- ```bash
52
- export POLYDEV_USER_TOKEN="pd_your_token_here"
53
- ```
50
+ - **PostHog Integration**: Advanced user analytics and feature tracking
51
+ - **BetterStack Monitoring**: System health and performance monitoring
52
+ - **Upstash Redis**: High-performance caching layer
53
+ - **Supabase Auth**: Robust authentication system
54
54
 
55
- ### Claude Code Integration
55
+ ## Tech Stack
56
56
 
57
- Add to your Claude Code MCP configuration:
57
+ | Layer | Technology |
58
+ |-------|------------|
59
+ | **Frontend** | Next.js 15 (App Router), React 18, TypeScript, Tailwind CSS, shadcn/ui |
60
+ | **Backend** | Supabase (PostgreSQL + Auth), Upstash Redis |
61
+ | **AI Integration** | Custom TypeScript handlers for 8+ LLM providers |
62
+ | **CLI Integration** | Cross-platform process execution utilities |
63
+ | **Streaming** | Server-Sent Events for real-time responses |
64
+ | **Monitoring** | PostHog Analytics, BetterStack |
58
65
 
59
- ```json
60
- "polydev": {
61
- "disabled": false,
62
- "timeout": 120,
63
- "type": "http",
64
- "url": "https://www.polydev.ai/api/mcp"
65
- },
66
- ```
66
+ ## Supported LLM Providers
67
67
 
68
- ## Available Tools
68
+ | Provider | Models | Context Window | Features |
69
+ |----------|--------|----------------|----------|
70
+ | **Anthropic** | Claude 3.5 Sonnet, Haiku, Opus | 200K tokens | Best for reasoning and code |
71
+ | **OpenAI** | GPT-4o, GPT-4 Turbo, GPT-3.5 | 128K tokens | Versatile, widely adopted |
72
+ | **Google Gemini** | Gemini 1.5 Pro, Flash | 1M+ tokens | Large context window |
73
+ | **OpenRouter** | 100+ models | Varies | Access to multiple providers |
74
+ | **Groq** | Open-source models | Varies | Ultra-fast inference |
75
+ | **Perplexity** | Search-optimized models | Varies | AI search and reasoning |
76
+ | **DeepSeek** | Reasoning models | Varies | Advanced reasoning capabilities |
77
+ | **Mistral AI** | European AI models | Varies | Strong performance, EU-based |
69
78
 
70
- - `get_perspectives` - Get AI responses from multiple models
71
- - `force_cli_detection` - Force detection of local CLI tools
72
- - `get_cli_status` - Check status of CLI tools (Claude Code, Codex, Gemini)
73
- - `send_cli_prompt` - Send prompts to local CLI with perspectives fallback
79
+ ## MCP Tools Available
74
80
 
75
- ## Usage Examples
81
+ - **Research**: Exa (web search), DeepWiki, Context7
82
+ - **Storage**: Supabase, Upstash Redis, Memory (knowledge graph)
83
+ - **Development**: GitHub, Git, Filesystem
84
+ - **Infrastructure**: Vercel, Stripe
85
+ - **AI**: Polydev (multi-model consultation)
86
+ - **Communication**: Resend (email)
76
87
 
77
- ### Get Multi-Model Perspectives
88
+ ## Architecture
78
89
 
79
- ```typescript
80
- // Use the get_perspectives tool
81
- {
82
- "prompt": "How do I optimize React performance?",
83
- "models": ["gpt-4", "claude-3-sonnet", "gemini-pro"]
84
- }
90
+ ```
91
+ ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
92
+ │ Frontend UI │────│ Process Utils │────│ CLI Tools │
93
+ │ (React/TS) │ │ (Node.js) │ │ (External) │
94
+ └─────────────────┘ └──────────────────┘ └─────────────────┘
95
+ │ │ │
96
+ │ │ │
97
+ ▼ ▼ ▼
98
+ ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
99
+ │ LLM Service │ │ CLI Handlers │ │ Subscriptions │
100
+ │ (Unified API) │ │ (Per Provider) │ │ (ChatGPT+, etc) │
101
+ └─────────────────┘ └──────────────────┘ └─────────────────┘
102
+ │ │
103
+ │ │
104
+ ▼ ▼
105
+ ┌─────────────────┐ ┌──────────────────┐
106
+ │ Supabase │ │ MCP Platform │
107
+ │ (Auth + DB) │ │ (16+ Tools) │
108
+ └─────────────────┘ └──────────────────┘
85
109
  ```
86
110
 
87
- ### Check CLI Status
111
+ ## Quick Start
88
112
 
89
- ```typescript
90
- // Check all CLI tools
91
- await get_cli_status({})
113
+ ### Prerequisites
92
114
 
93
- // Check specific tool
94
- await get_cli_status({ provider_id: "claude_code" })
95
- ```
115
+ - Node.js 18+
116
+ - npm or yarn package manager
117
+ - (Optional) CLI tools for subscription-based access:
118
+ - Codex CLI for ChatGPT Plus integration
119
+ - Claude Code CLI for Anthropic Pro integration
120
+ - Gemini CLI for Google Cloud integration
121
+ - VS Code with GitHub Copilot for Copilot integration
96
122
 
97
- ### Send CLI Prompt with Fallback
123
+ ### Installation
98
124
 
99
- ```typescript
100
- await send_cli_prompt({
101
- provider_id: "claude_code",
102
- prompt: "Write a Python function to parse JSON",
103
- mode: "args"
104
- })
105
- ```
125
+ ```bash
126
+ # Clone the repository
127
+ git clone https://github.com/backspacevenkat/polydev-ai.git
128
+ cd polydev-ai
106
129
 
107
- ## Supported CLI Tools
130
+ # Install dependencies
131
+ npm install
108
132
 
109
- - **Claude Code** (`claude`) - Anthropic's official CLI
110
- - **Codex CLI** (`codex`) - OpenAI's code CLI
111
- - **Gemini CLI** (`gemini`) - Google's Gemini CLI
133
+ # Configure environment variables
134
+ cp .env.example .env.local
112
135
 
113
- ## Smart Refresh System
136
+ # Start development server
137
+ npm run dev
138
+ ```
139
+
140
+ Open the application at http://localhost:3000
114
141
 
115
- The MCP server automatically detects CLI status changes:
142
+ ### Quick Configuration
116
143
 
117
- - **Unavailable CLIs**: Check every 2 minutes
118
- - **Unauthenticated CLIs**: Check every 3 minutes
119
- - **Working CLIs**: Check every 10 minutes
120
- - **Fallback detection**: Check every 5 minutes
144
+ 1. **API Key Setup**: Go to Settings → API Keys tab to configure traditional API access
145
+ 2. **CLI Setup**: Go to Settings → CLI Subscriptions tab to set up subscription-based access
146
+ 3. **Provider Selection**: Choose your preferred LLM provider from the dropdown
147
+ 4. **Test Integration**: Use the chat interface to test your configuration
121
148
 
122
149
  ## Environment Variables
123
150
 
124
- - `POLYDEV_USER_TOKEN` - Your Polydev authentication token (required)
125
- - `POLYDEV_CLI_DEBUG` - Enable CLI debugging output
126
- - `CLAUDE_CODE_PATH` - Custom path to Claude Code CLI
127
- - `CODEX_CLI_PATH` - Custom path to Codex CLI
128
- - `GEMINI_CLI_PATH` - Custom path to Gemini CLI
151
+ ```env
152
+ # Supabase
153
+ NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
154
+ NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
155
+ SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
129
156
 
130
- ## Troubleshooting
157
+ # PostHog Analytics
158
+ NEXT_PUBLIC_POSTHOG_KEY=your_posthog_key
159
+ NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
131
160
 
132
- ### CLI Not Detected
161
+ # Upstash Redis
162
+ UPSTASH_REDIS_REST_URL=your_upstash_redis_url
163
+ UPSTASH_REDIS_REST_TOKEN=your_upstash_redis_token
164
+
165
+ # BetterStack Logging
166
+ BETTERSTACK_LOGS_TOKEN=your_betterstack_token
167
+ ```
133
168
 
134
- 1. Ensure the CLI is installed and in your PATH
135
- 2. Check authentication: `claude auth status` / `codex login status`
136
- 3. Enable debugging: `export POLYDEV_CLI_DEBUG=1`
169
+ ## CLI Provider Setup
137
170
 
138
- ### Token Issues
171
+ ### Codex CLI (ChatGPT Plus Integration)
139
172
 
140
- 1. Verify your token at [polydev.ai/dashboard](https://polydev.ai/dashboard)
141
- 2. Ensure the token starts with `pd_`
142
- 3. Check environment variable is set correctly
173
+ ```bash
174
+ # Install and authenticate
175
+ codex auth
176
+ codex --version
177
+ ```
143
178
 
144
- ### Permission Errors
179
+ ### Claude Code CLI (Anthropic Pro Integration)
145
180
 
146
181
  ```bash
147
- # Fix npm permissions
148
- npm config set prefix '~/.npm-global'
149
- export PATH=~/.npm-global/bin:$PATH
182
+ # Install and authenticate
183
+ claude login
184
+ claude --version
150
185
  ```
151
186
 
152
- ## Support
187
+ ### Gemini CLI (Google Cloud Integration)
153
188
 
154
- - 📧 Email: [support@polydev.ai](mailto:support@polydev.ai)
155
- - 📖 Docs: [polydev.ai/docs](https://polydev.ai/docs)
156
- - 🐛 Issues: [GitHub Issues](https://github.com/backspacevenkat/polydev-website/issues)
189
+ ```bash
190
+ # Install Google Cloud SDK and authenticate
191
+ gcloud auth login
192
+ gcloud auth application-default login
193
+ ```
194
+
195
+ ### GitHub Copilot Integration
196
+
197
+ 1. Install VS Code with GitHub Copilot extension
198
+ 2. Sign in with your GitHub account that has Copilot access
199
+ 3. The application will detect VS Code and Copilot availability automatically
200
+
201
+ ## Development Status
202
+
203
+ **Current Status**: Active Development
204
+
205
+ The platform is fully functional for:
206
+ - Multi-LLM chat interface with streaming
207
+ - API key management with client-side encryption
208
+ - CLI subscription integration
209
+ - MCP server with 16+ tools
210
+ - Real-time streaming responses
157
211
 
158
212
  ## License
159
213
 
160
- MIT License - see LICENSE file for details.
214
+ MIT
215
+
216
+ ## Links
217
+
218
+ - **Website**: [polydev.ai](https://polydev.ai)
219
+ - **Repository**: [github.com/backspacevenkat/polydev-ai](https://github.com/backspacevenkat/polydev-ai)
@@ -5,13 +5,34 @@ const fs = require('fs');
5
5
  const os = require('os');
6
6
  const which = require('which');
7
7
 
8
+ // Status reporter for sending CLI status to polydev.ai server
9
+ let StatusReporter;
10
+ try {
11
+ StatusReporter = require('./statusReporter').StatusReporter;
12
+ } catch (e) {
13
+ // StatusReporter not available, continue without it
14
+ StatusReporter = null;
15
+ }
16
+
8
17
  const execAsync = promisify(exec);
9
18
 
10
19
  class CLIManager {
11
- constructor() {
20
+ constructor(options = {}) {
12
21
  this.providers = new Map();
13
22
  this.statusCache = new Map();
14
23
  this.CACHE_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
24
+
25
+ // Initialize status reporter if available
26
+ this.statusReporter = null;
27
+ if (StatusReporter && options.enableStatusReporting !== false) {
28
+ this.statusReporter = new StatusReporter({
29
+ userToken: options.userToken || process.env.POLYDEV_USER_TOKEN,
30
+ reportingEnabled: options.reportingEnabled !== false,
31
+ heartbeatIntervalMs: options.heartbeatIntervalMs,
32
+ debug: options.debug || process.env.POLYDEV_CLI_DEBUG === 'true'
33
+ });
34
+ }
35
+
15
36
  this.initializeProviders();
16
37
  }
17
38
 
@@ -96,6 +117,13 @@ class CLIManager {
96
117
  }
97
118
  }
98
119
 
120
+ // Report status to polydev.ai server (non-blocking)
121
+ if (this.statusReporter && this.statusReporter.isConfigured()) {
122
+ this.statusReporter.reportAllStatuses(results).catch(err => {
123
+ console.warn(`[Polydev CLI] Status reporting failed:`, err.message);
124
+ });
125
+ }
126
+
99
127
  return results;
100
128
  }
101
129
 
@@ -710,6 +738,115 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
710
738
  getProvider(providerId) {
711
739
  return this.providers.get(providerId);
712
740
  }
741
+
742
+ // ============================================
743
+ // Status Reporting Methods
744
+ // ============================================
745
+
746
+ /**
747
+ * Enable status reporting to polydev.ai server
748
+ * @param {string} userToken - User's MCP token (pd_xxx or polydev_xxx)
749
+ * @param {object} options - Additional configuration options
750
+ */
751
+ enableStatusReporting(userToken, options = {}) {
752
+ if (!StatusReporter) {
753
+ console.warn('[Polydev CLI] StatusReporter not available');
754
+ return false;
755
+ }
756
+
757
+ if (!this.statusReporter) {
758
+ this.statusReporter = new StatusReporter({
759
+ userToken,
760
+ reportingEnabled: true,
761
+ ...options
762
+ });
763
+ } else {
764
+ this.statusReporter.configure({
765
+ userToken,
766
+ reportingEnabled: true,
767
+ ...options
768
+ });
769
+ }
770
+
771
+ console.log('[Polydev CLI] Status reporting enabled');
772
+ return true;
773
+ }
774
+
775
+ /**
776
+ * Disable status reporting
777
+ */
778
+ disableStatusReporting() {
779
+ if (this.statusReporter) {
780
+ this.statusReporter.configure({ reportingEnabled: false });
781
+ this.statusReporter.stopHeartbeat();
782
+ console.log('[Polydev CLI] Status reporting disabled');
783
+ }
784
+ }
785
+
786
+ /**
787
+ * Start automatic heartbeat for periodic status updates
788
+ * @param {number} intervalMs - Interval in milliseconds (default: 15 minutes)
789
+ */
790
+ startStatusHeartbeat(intervalMs) {
791
+ if (this.statusReporter) {
792
+ if (intervalMs) {
793
+ this.statusReporter.configure({ heartbeatIntervalMs: intervalMs });
794
+ }
795
+ this.statusReporter.startHeartbeat(this);
796
+ console.log('[Polydev CLI] Status heartbeat started');
797
+ return true;
798
+ }
799
+ return false;
800
+ }
801
+
802
+ /**
803
+ * Stop automatic heartbeat
804
+ */
805
+ stopStatusHeartbeat() {
806
+ if (this.statusReporter) {
807
+ this.statusReporter.stopHeartbeat();
808
+ console.log('[Polydev CLI] Status heartbeat stopped');
809
+ }
810
+ }
811
+
812
+ /**
813
+ * Get status reporting configuration and history
814
+ */
815
+ getStatusReportingInfo() {
816
+ if (!this.statusReporter) {
817
+ return {
818
+ available: false,
819
+ reason: 'StatusReporter not initialized'
820
+ };
821
+ }
822
+
823
+ return {
824
+ available: true,
825
+ config: this.statusReporter.getConfig(),
826
+ history: this.statusReporter.getHistory()
827
+ };
828
+ }
829
+
830
+ /**
831
+ * Manually trigger a status report
832
+ * @returns {Promise<object>} - Report results
833
+ */
834
+ async reportStatusNow() {
835
+ if (!this.statusReporter || !this.statusReporter.isConfigured()) {
836
+ return {
837
+ success: false,
838
+ reason: 'Status reporting not configured'
839
+ };
840
+ }
841
+
842
+ const statuses = await this.forceCliDetection();
843
+ // forceCliDetection already reports, but we return the result
844
+ return {
845
+ success: true,
846
+ statuses,
847
+ reported: true
848
+ };
849
+ }
713
850
  }
714
851
 
715
852
  module.exports = { CLIManager, default: CLIManager };