polydev-ai 1.4.2 → 1.4.3

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 (2) hide show
  1. package/package.json +1 -1
  2. package/stdio-wrapper.js +63 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polydev-ai",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Get diverse AI perspectives from multiple LLMs via MCP - supports Cline, Claude Code, and other MCP clients",
5
5
  "main": "stdio-wrapper.js",
6
6
  "bin": {
package/stdio-wrapper.js CHANGED
@@ -6,6 +6,69 @@ const path = require('path');
6
6
  const os = require('os');
7
7
  const { CLIManager } = require('./cliManager');
8
8
 
9
+ // Simple .env file loader (no external dependencies)
10
+ function loadEnvFile(filePath) {
11
+ try {
12
+ if (!fs.existsSync(filePath)) return false;
13
+
14
+ const content = fs.readFileSync(filePath, 'utf8');
15
+ const lines = content.split('\n');
16
+ let loaded = 0;
17
+
18
+ for (const line of lines) {
19
+ const trimmed = line.trim();
20
+ // Skip comments and empty lines
21
+ if (!trimmed || trimmed.startsWith('#')) continue;
22
+
23
+ const eqIndex = trimmed.indexOf('=');
24
+ if (eqIndex === -1) continue;
25
+
26
+ const key = trimmed.substring(0, eqIndex).trim();
27
+ let value = trimmed.substring(eqIndex + 1).trim();
28
+
29
+ // Remove surrounding quotes if present
30
+ if ((value.startsWith('"') && value.endsWith('"')) ||
31
+ (value.startsWith("'") && value.endsWith("'"))) {
32
+ value = value.slice(1, -1);
33
+ }
34
+
35
+ // Only set if not already defined (don't override existing env vars)
36
+ if (!process.env[key]) {
37
+ process.env[key] = value;
38
+ loaded++;
39
+ }
40
+ }
41
+
42
+ return loaded > 0;
43
+ } catch (error) {
44
+ return false;
45
+ }
46
+ }
47
+
48
+ // Load .env files from multiple locations (in priority order)
49
+ function loadEnvironment() {
50
+ const envPaths = [
51
+ path.join(process.cwd(), '.env'), // Current working directory
52
+ path.join(process.cwd(), '.env.local'), // Local overrides
53
+ path.join(os.homedir(), '.polydev.env'), // User home directory
54
+ path.join(os.homedir(), '.env'), // Home directory fallback
55
+ ];
56
+
57
+ const loaded = [];
58
+ for (const envPath of envPaths) {
59
+ if (loadEnvFile(envPath)) {
60
+ loaded.push(envPath);
61
+ }
62
+ }
63
+
64
+ if (loaded.length > 0) {
65
+ console.error(`[Stdio Wrapper] Loaded env from: ${loaded.join(', ')}`);
66
+ }
67
+ }
68
+
69
+ // Load environment variables FIRST, before any checks
70
+ loadEnvironment();
71
+
9
72
  function ensureWritableTmpDir() {
10
73
  const candidates = [
11
74
  process.env.POLYDEV_TMPDIR,