polydev-ai 1.8.20 → 1.8.22

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/lib/cliManager.js CHANGED
@@ -75,7 +75,8 @@ class CLIManager {
75
75
  subcommands: {
76
76
  chat: ['chat'],
77
77
  version: ['--version'],
78
- auth_status: ['auth-status'] // gemini-mcp auth-status command
78
+ auth_status: ['auth-status'],
79
+ test_prompt: ['-p'] // Gemini CLI uses -p for headless prompts
79
80
  },
80
81
  install_instructions: 'Install Gemini CLI from Google',
81
82
  auth_instructions: 'Authenticate with: gemini (then /auth login)'
@@ -327,7 +328,21 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
327
328
  return false;
328
329
 
329
330
  case 'gemini_cli':
330
- // Check for Gemini CLI auth files (if any)
331
+ // Check for Gemini CLI auth files
332
+ // Gemini CLI stores OAuth credentials in ~/.gemini/oauth_creds.json
333
+ const geminiOauthPath = path.join(os.homedir(), '.gemini', 'oauth_creds.json');
334
+ if (fs.existsSync(geminiOauthPath)) {
335
+ try {
336
+ const oauthContent = fs.readFileSync(geminiOauthPath, 'utf8');
337
+ const oauthData = JSON.parse(oauthContent);
338
+ // Check for valid OAuth tokens
339
+ return !!(oauthData && (oauthData.access_token || oauthData.refresh_token));
340
+ } catch {
341
+ // Has OAuth file but couldn't parse - assume authenticated
342
+ return true;
343
+ }
344
+ }
345
+ // Fallback: check legacy location
331
346
  const geminiConfigPath = path.join(os.homedir(), '.config', 'gemini-cli', 'config.json');
332
347
  if (fs.existsSync(geminiConfigPath)) {
333
348
  const configContent = fs.readFileSync(geminiConfigPath, 'utf8');
@@ -568,14 +583,21 @@ This is a known issue with @google/gemini-cli@0.3.4 and older Node.js versions.`
568
583
  // Claude Code uses --model flag
569
584
  args = ['--model', model, ...args, prompt];
570
585
  } else if (providerId === 'gemini_cli') {
571
- // Gemini CLI uses -m flag
572
- args = ['-m', model, ...args, prompt];
586
+ // Gemini CLI: -m for model, -p for prompt (headless mode)
587
+ // Format: gemini -m gemini-2.0-flash -p "prompt"
588
+ args = ['-m', model, '-p', prompt];
573
589
  } else {
574
590
  // Default: just append prompt
575
591
  args = [...args, prompt];
576
592
  }
577
593
  } else {
578
- args = [...args, prompt];
594
+ // No model specified
595
+ if (providerId === 'gemini_cli') {
596
+ // Gemini CLI still needs -p flag for headless mode
597
+ args = ['-p', prompt];
598
+ } else {
599
+ args = [...args, prompt];
600
+ }
579
601
  }
580
602
 
581
603
  try {
@@ -770,7 +770,8 @@ class StdioMCPWrapper {
770
770
  try {
771
771
  const cliResults = localResults.map(result => ({
772
772
  provider_id: result.provider_id,
773
- model: result.model || this.getDefaultModelForCli(result.provider_id),
773
+ // IMPORTANT: cliManager returns model_used, not model
774
+ model: result.model_used || result.model || this.getModelPreferenceForCli(result.provider_id),
774
775
  content: result.content || '',
775
776
  tokens_used: result.tokens_used || 0,
776
777
  latency_ms: result.latency_ms || 0,
@@ -810,6 +811,37 @@ class StdioMCPWrapper {
810
811
  }
811
812
  }
812
813
 
814
+ /**
815
+ * Get model preference for a CLI provider from cached user preferences
816
+ * Falls back to a descriptive default if not available
817
+ */
818
+ getModelPreferenceForCli(providerId) {
819
+ // Try to get from cached user model preferences first
820
+ if (this.userModelPreferences && this.userModelPreferences[providerId]) {
821
+ return this.userModelPreferences[providerId];
822
+ }
823
+
824
+ // Map CLI provider to API provider for lookup
825
+ const cliToApiProvider = {
826
+ 'claude_code': 'anthropic',
827
+ 'codex_cli': 'openai',
828
+ 'gemini_cli': 'google'
829
+ };
830
+
831
+ const apiProvider = cliToApiProvider[providerId];
832
+ if (apiProvider && this.userModelPreferences && this.userModelPreferences[apiProvider]) {
833
+ return this.userModelPreferences[apiProvider];
834
+ }
835
+
836
+ // Fallback to descriptive defaults based on typical CLI models
837
+ const defaults = {
838
+ 'claude_code': 'claude-sonnet-4',
839
+ 'codex_cli': 'gpt-4.1',
840
+ 'gemini_cli': 'gemini-2.5-pro'
841
+ };
842
+ return defaults[providerId] || 'unknown';
843
+ }
844
+
813
845
  /**
814
846
  * Get default model name for a CLI tool (used when model not specified in result)
815
847
  * These are just display labels - actual model selection is done by:
@@ -817,14 +849,8 @@ class StdioMCPWrapper {
817
849
  * 2. CLI tool's own default if no preference set
818
850
  */
819
851
  getDefaultModelForCli(providerId) {
820
- // Return a display label indicating CLI default was used
821
- // The actual model depends on the CLI tool's configuration
822
- const defaults = {
823
- 'claude_code': 'CLI Default',
824
- 'codex_cli': 'CLI Default',
825
- 'gemini_cli': 'CLI Default'
826
- };
827
- return defaults[providerId] || 'CLI Default';
852
+ // Prefer user's model preference if available
853
+ return this.getModelPreferenceForCli(providerId);
828
854
  }
829
855
 
830
856
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polydev-ai",
3
- "version": "1.8.20",
3
+ "version": "1.8.22",
4
4
  "description": "Agentic workflow assistant with CLI integration - get diverse perspectives from multiple LLMs when stuck or need enhanced reasoning",
5
5
  "keywords": [
6
6
  "mcp",