@iservu-inc/adf-cli 0.14.2 → 0.14.4

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 (37) hide show
  1. package/README.md +13 -13
  2. package/bin/adf.js +43 -26
  3. package/conductor/product-guidelines.md +1 -1
  4. package/conductor/product.md +2 -3
  5. package/conductor/tracks/bootstrap_agents_20260111/plan.md +5 -0
  6. package/lib/ai/ai-client.js +80 -35
  7. package/lib/ai/ai-config.js +225 -107
  8. package/lib/commands/config.js +15 -5
  9. package/lib/commands/deploy.js +5 -2
  10. package/lib/commands/init.js +14 -4
  11. package/lib/frameworks/interviewer.js +3 -3
  12. package/lib/frameworks/output-generators.js +7 -7
  13. package/lib/frameworks/questions.js +3 -3
  14. package/lib/generators/agents-md-generator.js +3 -3
  15. package/lib/generators/antigravity-generator.js +3 -3
  16. package/lib/generators/cursor-generator.js +3 -3
  17. package/lib/generators/deepagent-generator.js +5 -5
  18. package/lib/generators/gemini-cli-generator.js +5 -5
  19. package/lib/generators/index.js +15 -0
  20. package/lib/generators/vscode-generator.js +3 -3
  21. package/lib/generators/windsurf-generator.js +3 -3
  22. package/lib/templates/scripts/analyze-docs.js +14 -13
  23. package/lib/templates/scripts/config-helpers.js +1 -1
  24. package/lib/templates/shared/agents/analyst.md +1 -1
  25. package/lib/templates/shared/agents/architect.md +1 -1
  26. package/lib/templates/shared/agents/dev.md +1 -1
  27. package/lib/templates/shared/agents/pm.md +2 -2
  28. package/lib/templates/shared/agents/qa.md +1 -1
  29. package/lib/templates/shared/agents/sm.md +3 -3
  30. package/lib/templates/shared/memory/constitution.md +2 -2
  31. package/lib/templates/shared/templates/README.md +14 -14
  32. package/lib/templates/shared/templates/prd-template.md +1 -1
  33. package/lib/templates/shared/templates/spec-template.md +1 -1
  34. package/lib/utils/context-manager.js +11 -10
  35. package/lib/utils/framework-detector.js +5 -5
  36. package/lib/utils/project-detector.js +7 -7
  37. package/package.json +5 -5
package/README.md CHANGED
@@ -41,13 +41,13 @@ The interactive init process will:
41
41
  Skip interactive questions and specify workflow directly:
42
42
 
43
43
  ```bash
44
- # Level 1: Rapid Development (PRP)
44
+ # Level 1: Rapid (Agent-Native)
45
45
  adf init --rapid
46
46
 
47
- # Level 2: Specification-Driven (Balanced)
47
+ # Level 2: Balanced (OpenSpec)
48
48
  adf init --balanced
49
49
 
50
- # Level 3: BMAD Comprehensive
50
+ # Level 3: Comprehensive (Agent-Native)
51
51
  adf init --comprehensive
52
52
  ```
53
53
 
@@ -375,7 +375,7 @@ your-project/
375
375
  │ ├── scripts/ # Helper scripts
376
376
  │ └── shared/ # Templates, agents, and resources
377
377
  │ ├── agents/ # Agent definition files
378
- │ ├── templates/ # PRP, BMAD, Spec-Kit templates
378
+ │ ├── templates/ # Agent-Native and OpenSpec templates
379
379
  │ ├── mcp/ # MCP configurations
380
380
  │ └── memory/ # Framework memory/constitution
381
381
  ├── .framework/ # Deployment directory
@@ -415,23 +415,23 @@ The `.adf/context.json` file contains your workflow configuration:
415
415
 
416
416
  ## Workflow Levels
417
417
 
418
- ### Level 1: Rapid Development (PRP)
418
+ ### Level 1: Rapid (Agent-Native)
419
419
  - **Time:** 5-15 minutes planning
420
420
  - **Agents:** dev, qa
421
421
  - **Best for:** Solo developers, simple projects, prototyping
422
- - **Templates:** PRP story, PRP task
422
+ - **Templates:** Rapid story, Rapid task
423
423
 
424
- ### Level 2: Specification-Driven (Balanced)
424
+ ### Level 2: Balanced (OpenSpec)
425
425
  - **Time:** 30-60 minutes planning
426
426
  - **Agents:** analyst, pm, dev, qa
427
- - **Best for:** Small teams, moderate complexity
428
- - **Templates:** Full PRP suite, spec templates
427
+ - **Best for:** Small teams, moderate complexity, iterative requirements
428
+ - **Templates:** OpenSpec proposal, Spec deltas
429
429
 
430
- ### Level 3: BMAD Comprehensive
430
+ ### Level 3: Comprehensive (Agent-Native)
431
431
  - **Time:** 1-2+ hours planning
432
432
  - **Agents:** analyst, pm, architect, sm, dev, qa
433
- - **Best for:** Large teams, complex systems, strategic planning
434
- - **Templates:** Complete BMAD framework, governance tools
433
+ - **Best for:** Large teams, complex systems, strategic orchestration
434
+ - **Templates:** Complete agent-native suite, governance tools
435
435
 
436
436
  ## Examples
437
437
 
@@ -503,7 +503,7 @@ See [CHANGELOG.md](./CHANGELOG.md) for detailed version history.
503
503
 
504
504
  **Latest:** v0.14.0 (2026-01-12)
505
505
  - **Project Context Synthesis & Extended Tool Support (v0.14.0)** - Minor release
506
- - ✨ **Adaptive Project Augmentation** - Synthesizes existing .adf, BMAD, OpenSpec, and Spec-Kit project files into unified context.
506
+ - ✨ **Adaptive Project Augmentation** - Synthesizes existing .adf, Agent-Native (BMAD), and OpenSpec project files into unified context.
507
507
  - ✨ **AI-Driven Gap Analysis** - Automatically identifies knowledge gaps and generates targeted questionnaire to fill them.
508
508
  - ✨ **Extended Tool Support** - Native generators for Kiro, Trae, and Codex CLI.
509
509
  - ✨ **Tool Audit Registry** - New `adf tools audit` command to monitor integration features across all 12+ supported tools.
package/bin/adf.js CHANGED
@@ -50,17 +50,17 @@ ${chalk.cyan.bold('What is ADF?')}
50
50
  AgentDevFramework (ADF) is an AI-assisted development framework that helps
51
51
  you gather requirements through intelligent AI-guided interviews. It supports
52
52
  multiple AI providers and workflow levels, from rapid prototyping to
53
- comprehensive enterprise documentation.
53
+ comprehensive agent-native documentation.
54
54
 
55
55
  ${chalk.cyan.bold('Key Features:')}
56
56
  • ${chalk.yellow('Multi-Provider AI')} - Anthropic, OpenAI, Google, OpenRouter
57
- • ${chalk.yellow('3 Workflow Levels')} - Rapid (PRP), Balanced (Spec-Kit), Comprehensive (BMAD)
57
+ • ${chalk.yellow('3 Workflow Levels')} - Rapid (Agent-Native), Balanced (OpenSpec), Comprehensive (Agent-Native)
58
58
  • ${chalk.yellow('Smart Filtering')} - AI-powered question filtering based on context
59
59
  • ${chalk.yellow('Learning System')} - Adapts to your preferences over time
60
60
  • ${chalk.yellow('Session Resume')} - Pause and resume interviews anytime
61
- • ${chalk.yellow('Multi-Tool Deploy')} - 10+ IDEs and CLI tools supported
62
- ${chalk.gray('IDEs:')} Windsurf, Cursor, VS Code, Zed, Antigravity
63
- ${chalk.gray('CLI:')} Claude Code, OpenCode, Gemini CLI, DeepAgent
61
+ • ${chalk.yellow('Multi-Tool Deploy')} - 12+ IDEs and CLI tools supported
62
+ ${chalk.gray('IDEs:')} Windsurf, Cursor, VS Code, Zed, Antigravity, Kiro, Trae
63
+ ${chalk.gray('CLI:')} Claude Code, OpenCode, Gemini CLI, DeepAgent, Codex CLI
64
64
 
65
65
  ${chalk.cyan.bold('Getting Help:')}
66
66
  ${chalk.gray('# Detailed help for specific commands')}
@@ -69,6 +69,7 @@ ${chalk.cyan.bold('Getting Help:')}
69
69
  $ adf guide --help
70
70
  $ adf config --help
71
71
  $ adf update --help
72
+ $ adf tools audit --help
72
73
 
73
74
  ${chalk.gray('# Get tool-specific setup guides')}
74
75
  $ adf guide windsurf
@@ -83,12 +84,12 @@ ${chalk.cyan.bold('Common Workflows:')}
83
84
 
84
85
  ${chalk.yellow('Standard Project:')}
85
86
  $ adf config ${chalk.gray('# Configure AI provider once')}
86
- $ adf init --balanced ${chalk.gray('# Run interview')}
87
+ $ adf init --balanced ${chalk.gray('# Run OpenSpec interview')}
87
88
  $ adf deploy cursor ${chalk.gray('# Deploy to Cursor')}
88
89
 
89
90
  ${chalk.yellow('Enterprise Project:')}
90
91
  $ adf config ${chalk.gray('# Configure with comprehensive mode')}
91
- $ adf init --comprehensive
92
+ $ adf init --comprehensive ${chalk.gray('# Run Agent-Native interview')}
92
93
  $ adf deploy vscode ${chalk.gray('# Deploy to multiple tools')}
93
94
  $ adf deploy claude-code
94
95
 
@@ -106,9 +107,9 @@ ${chalk.cyan.bold('Learn More:')}
106
107
  program
107
108
  .command('init')
108
109
  .description('Initialize AgentDevFramework in current project')
109
- .option('--rapid', 'Skip questions, use Level 1 (Rapid Development)')
110
- .option('--balanced', 'Skip questions, use Level 2 (Balanced)')
111
- .option('--comprehensive', 'Skip questions, use Level 3 (Comprehensive)')
110
+ .option('--rapid', 'Skip questions, use Level 1 (Rapid (Agent-Native))')
111
+ .option('--balanced', 'Skip questions, use Level 2 (Balanced (OpenSpec))')
112
+ .option('--comprehensive', 'Skip questions, use Level 3 (Comprehensive (Agent-Native))')
112
113
  .option('--tool <tool>', 'Specify deployment tool (windsurf, cursor, etc.)')
113
114
  .addHelpText('after', `
114
115
  ${chalk.cyan.bold('Description:')}
@@ -117,20 +118,20 @@ ${chalk.cyan.bold('Description:')}
117
118
  documentation based on your chosen workflow level.
118
119
 
119
120
  ${chalk.cyan.bold('Workflow Levels:')}
120
- ${chalk.yellow('Rapid (PRP)')} - 20 core questions, fast setup
121
+ ${chalk.yellow('Rapid (Agent-Native)')} - 20 core questions, fast setup
121
122
  Agents: dev, qa
122
123
  Output: prp.md
123
124
  Best for: Quick prototypes, MVPs
124
125
 
125
- ${chalk.yellow('Balanced (Spec-Kit)')} - 30+ questions, detailed specs
126
+ ${chalk.yellow('Balanced (OpenSpec)')} - 30+ questions, iterative spec deltas
126
127
  Agents: analyst, pm, dev, qa
127
128
  Output: constitution.md, specification.md, plan.md, tasks.md
128
- Best for: Standard projects with clear requirements
129
+ Best for: Standard projects with iterative requirements
129
130
 
130
- ${chalk.yellow('Comprehensive (BMAD)')} - 40+ questions, full documentation
131
+ ${chalk.yellow('Comprehensive (Agent-Native)')} - 40+ questions, full agent orchestration
131
132
  Agents: analyst, pm, architect, sm, dev, qa
132
133
  Output: prd.md, architecture.md, stories.md
133
- Best for: Enterprise projects, complex systems
134
+ Best for: Enterprise projects, complex agent-native systems
134
135
 
135
136
  ${chalk.cyan.bold('Examples:')}
136
137
  ${chalk.gray('# Interactive mode - choose workflow interactively')}
@@ -172,26 +173,33 @@ ${chalk.cyan.bold('Command Syntax:')}
172
173
  ${chalk.white('adf deploy [tool]')}
173
174
 
174
175
  ${chalk.yellow('[tool]')} - (Optional) Target tool name
175
- If omitted, you'll be prompted to select interactively
176
- Supported: windsurf, cursor, vscode, claude-code, zed, generic
176
+ If omitted, you\'ll be prompted to select interactively
177
+ Supported: windsurf, cursor, vscode, zed, antigravity, kiro, trae,
178
+ claude-code, opencode, gemini-cli, deepagent, codex-cli, generic
177
179
 
178
180
  ${chalk.cyan.bold('Supported Tools:')}
179
181
  ${chalk.white.bold('IDEs:')}
180
182
  ${chalk.yellow('windsurf')} - Codeium Windsurf IDE
181
- Output: .windsurfrules
183
+ Output: .windsurfrules, .windsurf/rules/
182
184
 
183
185
  ${chalk.yellow('cursor')} - Cursor AI IDE
184
- Output: .cursorrules
186
+ Output: .cursorrules, .cursor/rules/
185
187
 
186
188
  ${chalk.yellow('vscode')} - Visual Studio Code
187
189
  Output: .vscode/settings.json, .github/copilot-instructions.md
188
190
 
189
191
  ${chalk.yellow('zed')} - Zed Editor
190
- Output: .zed/settings.json, .zed/rules (symlink to AGENTS.md)
192
+ Output: .zed/settings.json, .zed/keymap.json
191
193
 
192
194
  ${chalk.yellow('antigravity')} - Google Antigravity IDE
193
195
  Output: .antigravity/agents.yaml
194
196
 
197
+ ${chalk.yellow('kiro')} - Kiro AI Code Editor
198
+ Output: .kiro/product.md, .kiro/technical.md
199
+
200
+ ${chalk.yellow('trae')} - Trae AI IDE
201
+ Output: .trae/config.json
202
+
195
203
  ${chalk.white.bold('CLI Tools:')}
196
204
  ${chalk.yellow('claude-code')} - Anthropic Claude Code CLI
197
205
  Output: .framework/agents/*.md
@@ -205,6 +213,9 @@ ${chalk.cyan.bold('Supported Tools:')}
205
213
  ${chalk.yellow('deepagent')} - Abacus.ai DeepAgent CLI
206
214
  Output: .deepagent/agents/*.md, .deepagent/README.md
207
215
 
216
+ ${chalk.yellow('codex-cli')} - Codex CLI
217
+ Output: .codex/config.toml, .codex/instructions.md
218
+
208
219
  ${chalk.white.bold('Generic:')}
209
220
  ${chalk.yellow('generic')} - Generic AI tools (agent markdown files)
210
221
  Output: .framework/agents/*.md
@@ -237,17 +248,20 @@ ${chalk.cyan.bold('Requirements:')}
237
248
 
238
249
  ${chalk.cyan.bold('Output Files by Tool:')}
239
250
  ${chalk.white.bold('IDEs:')}
240
- Windsurf: ${chalk.white('.windsurfrules')}
241
- Cursor: ${chalk.white('.cursorrules')}
251
+ Windsurf: ${chalk.white('.windsurfrules + .windsurf/rules/')}
252
+ Cursor: ${chalk.white('.cursorrules + .cursor/rules/')}
242
253
  VS Code: ${chalk.white('.vscode/settings.json + .github/copilot-instructions.md')}
243
- Zed: ${chalk.white('.zed/settings.json + .zed/rules')}
254
+ Zed: ${chalk.white('.zed/settings.json + .zed/keymap.json')}
244
255
  Antigravity: ${chalk.white('.antigravity/agents.yaml')}
256
+ Kiro: ${chalk.white('.kiro/product.md + .kiro/technical.md')}
257
+ Trae: ${chalk.white('.trae/config.json')}
245
258
 
246
259
  ${chalk.white.bold('CLI Tools:')}
247
260
  Claude Code: ${chalk.white('.framework/agents/*.md')}
248
261
  OpenCode: ${chalk.white('.opencode.json')}
249
262
  Gemini CLI: ${chalk.white('GEMINI.md')}
250
263
  DeepAgent: ${chalk.white('.deepagent/agents/*.md + .deepagent/README.md')}
264
+ Codex CLI: ${chalk.white('.codex/config.toml + .codex/instructions.md')}
251
265
 
252
266
  ${chalk.white.bold('Generic:')}
253
267
  Generic: ${chalk.white('.framework/agents/*.md')}
@@ -335,10 +349,13 @@ ${chalk.cyan.bold('Available Tools:')}
335
349
  ${chalk.yellow('vscode')} - Visual Studio Code with GitHub Copilot
336
350
  ${chalk.yellow('zed')} - Zed Editor
337
351
  ${chalk.yellow('antigravity')} - Google Antigravity
352
+ ${chalk.yellow('kiro')} - Kiro AI Code Editor
353
+ ${chalk.yellow('trae')} - Trae AI IDE
338
354
  ${chalk.yellow('claude-code')} - Claude Code CLI
339
355
  ${chalk.yellow('opencode')} - OpenCode CLI
340
356
  ${chalk.yellow('gemini-cli')} - Google Gemini CLI
341
357
  ${chalk.yellow('deepagent')} - Abacus.ai DeepAgent
358
+ ${chalk.yellow('codex-cli')} - Codex CLI
342
359
 
343
360
  ${chalk.cyan.bold('What You\'ll Learn:')}
344
361
  • Which files were generated and what they do
@@ -443,18 +460,18 @@ ${chalk.cyan.bold('Performance Modes:')}
443
460
  ${chalk.yellow('Fast')} - Minimal AI calls (~0.5s per answer)
444
461
  Answer quality: OFF
445
462
  Smart filtering: OFF
446
- Best for: Quick interviews, testing
463
+ Best for: Level 1 Rapid (Agent-Native)
447
464
 
448
465
  ${chalk.yellow('Balanced')} - Moderate AI usage (~2-3s per answer)
449
466
  Answer quality: ON
450
467
  Smart filtering: ON
451
- Best for: Most projects (recommended)
468
+ Best for: Level 2 Balanced (OpenSpec) - Recommended
452
469
 
453
470
  ${chalk.yellow('Comprehensive')} - Full AI analysis (~4-6s per answer)
454
471
  All features: ON
455
472
  Context extraction: ON
456
473
  Question reordering: ON
457
- Best for: Critical projects, detailed requirements
474
+ Best for: Level 3 Comprehensive (Agent-Native)
458
475
 
459
476
  ${chalk.cyan.bold('Storage Locations:')}
460
477
  API Keys: ${chalk.white('.adf/.env')} ${chalk.gray('(gitignored)')}
@@ -5,7 +5,7 @@
5
5
  * **Context-Aware:** The CLI's tone must dynamically adjust to the specific scenario, project parameters, and user intent.
6
6
  * **Scenario-Based Adaptation:**
7
7
  * *Quick/Rapid Projects:* Adopt a **Professional & Concise** tone. fast, direct, and efficient.
8
- * *Complex/BMAD Projects:* Shift to a **Technical & Analytical** tone, focusing on precision, data, and architectural depth.
8
+ * *Complex Agent-Native Projects:* Shift to a **Technical & Analytical** tone, focusing on precision, data, and architectural depth.
9
9
  * *Learning/New Users:* Utilize a **Collaborative & Supportive** tone to guide them through the framework.
10
10
  * **Goal:** Maximize the "return on time investment" by matching the communication style to the user's immediate cognitive load and task requirements.
11
11
 
@@ -16,9 +16,8 @@ Create the definitive AI-driven requirements gathering tool that transforms vagu
16
16
 
17
17
  **Key Features:**
18
18
  * **Dynamic Questionnaire:** AI-driven interview system that adapts questions based on answer quality, project context, and identified knowledge gaps.
19
- * **Project Context Synthesis:** Adaptive project augmentation that intelligently detects existing framework indicators (.adf, BMAD, OpenSpec, Spec-Kit) and merges them into a unified context.
20
- * **Learning System:** Tracks user behavior (skips, answers) to detect patterns and generate learned rules that streamline future sessions.
21
- * **Artifact Generation:** Automated creation of structured documents (PRP, BMAD, Spec-Kit) and IDE configurations.
19
+ * **Project Context Synthesis:** Adaptive project augmentation that intelligently detects existing framework indicators (.adf, Agent-Native, OpenSpec) and merges them into a unified context.
20
+ * **Artifact Generation:** Automated creation of structured documents (Rapid, OpenSpec, Agent-Native) and IDE configurations.
22
21
  * **Multi-Provider AI Support:** Integrates with Anthropic, OpenAI, Google Gemini, and OpenRouter.
23
22
  * **Tool Integration:** Deploys directly to 12+ AI-native tools including Windsurf, Cursor, VS Code, Zed, Antigravity, Kiro, Trae, Codex CLI, and more.
24
23
  * **Tool Audit Registry:** Built-in capability to audit supported tool features and integration status.
@@ -14,4 +14,9 @@
14
14
  - [x] Task: Verify Agent Access.
15
15
  - [x] Subtask: Simulate an agent reading `AGENTS.md` and following the references.
16
16
  - [x] Subtask: Ensure all paths in `AGENTS.md` are valid.
17
+ - [x] Task: Verify AI Provider Integration (Dynamic Discovery & Perplexity)
18
+ - [x] Subtask: Upgrade Google Gemini to `@google/genai` and dynamic validation.
19
+ - [x] Subtask: Implement dynamic model fetching for Anthropic, OpenAI, OpenRouter.
20
+ - [x] Subtask: Add Perplexity provider with "connectivity check" validation.
21
+ - [x] Subtask: Ensure tests pass and code is committed.
17
22
  - [x] Task: Conductor - User Manual Verification 'Verification' (Protocol in workflow.md)
@@ -35,8 +35,10 @@ class AIClient {
35
35
  break;
36
36
 
37
37
  case 'google':
38
- const { GoogleGenerativeAI } = require('@google/generative-ai');
39
- this.client = new GoogleGenerativeAI(this.apiKey);
38
+ const { GoogleGenAI } = require('@google/genai');
39
+ this.client = new GoogleGenAI({
40
+ apiKey: this.apiKey
41
+ });
40
42
  break;
41
43
 
42
44
  case 'openrouter':
@@ -47,6 +49,14 @@ class AIClient {
47
49
  });
48
50
  break;
49
51
 
52
+ case 'perplexity':
53
+ const OpenAIForPerplexity = require('openai');
54
+ this.client = new OpenAIForPerplexity({
55
+ apiKey: this.apiKey,
56
+ baseURL: 'https://api.perplexity.ai'
57
+ });
58
+ break;
59
+
50
60
  default:
51
61
  throw new Error(`Unsupported provider: ${this.provider}`);
52
62
  }
@@ -70,11 +80,13 @@ class AIClient {
70
80
  case 'google':
71
81
  return await this.googleRequest(prompt, maxTokens, temperature);
72
82
 
73
- case 'openrouter':
74
- return await this.openrouterRequest(prompt, maxTokens, temperature);
75
-
76
- default:
77
- throw new Error(`Provider ${this.provider} not implemented`);
83
+ case 'openrouter':
84
+ return await this.openrouterRequest(prompt, maxTokens, temperature);
85
+
86
+ case 'perplexity':
87
+ return await this.perplexityRequest(prompt, maxTokens, temperature);
88
+
89
+ default: throw new Error(`Provider ${this.provider} not implemented`);
78
90
  }
79
91
  } catch (error) {
80
92
  throw new Error(`AI request failed: ${error.message}`);
@@ -194,39 +206,35 @@ class AIClient {
194
206
  * Google Gemini request
195
207
  */
196
208
  async googleRequest(prompt, maxTokens, temperature) {
197
- const model = this.client.getGenerativeModel({
198
- model: this.model,
199
- generationConfig: {
200
- maxOutputTokens: maxTokens,
201
- temperature
202
- }
203
- });
209
+ try {
210
+ const response = await this.client.models.generateContent({
211
+ model: this.model,
212
+ contents: [{ parts: [{ text: prompt }] }],
213
+ config: {
214
+ maxOutputTokens: maxTokens,
215
+ temperature
216
+ }
217
+ });
204
218
 
205
- const result = await model.generateContent(prompt);
206
- const response = result.response;
219
+ const content = response.text;
207
220
 
208
- // Validate response
209
- let content;
210
- try {
211
- content = response.text();
221
+ if (!content || content.trim().length === 0) {
222
+ throw new Error(`Google Gemini model '${this.model}' returned empty content.`);
223
+ }
224
+
225
+ return {
226
+ content,
227
+ model: this.model,
228
+ provider: 'google',
229
+ usage: {
230
+ promptTokens: response.usageMetadata?.promptTokenCount || 0,
231
+ completionTokens: response.usageMetadata?.candidatesTokenCount || 0,
232
+ totalTokens: response.usageMetadata?.totalTokenCount || 0
233
+ }
234
+ };
212
235
  } catch (error) {
213
236
  throw new Error(`Google Gemini model '${this.model}' failed to generate text: ${error.message}`);
214
237
  }
215
-
216
- if (!content || content.trim().length === 0) {
217
- throw new Error(`Google Gemini model '${this.model}' returned empty content.`);
218
- }
219
-
220
- return {
221
- content,
222
- model: this.model,
223
- provider: 'google',
224
- usage: {
225
- promptTokens: response.usageMetadata?.promptTokenCount || 0,
226
- completionTokens: response.usageMetadata?.candidatesTokenCount || 0,
227
- totalTokens: response.usageMetadata?.totalTokenCount || 0
228
- }
229
- };
230
238
  }
231
239
 
232
240
  /**
@@ -314,6 +322,43 @@ class AIClient {
314
322
  }
315
323
  }
316
324
 
325
+ /**
326
+ * Perplexity AI request (via OpenAI-compatible API)
327
+ */
328
+ async perplexityRequest(prompt, maxTokens, temperature) {
329
+ try {
330
+ // Perplexity supports standard OpenAI chat completions
331
+ // but has some specific recommended parameters
332
+ const response = await this.client.chat.completions.create({
333
+ model: this.model,
334
+ messages: [
335
+ {
336
+ role: 'user',
337
+ content: prompt
338
+ }
339
+ ],
340
+ max_tokens: maxTokens,
341
+ temperature: temperature,
342
+ // Optional: Perplexity specific headers can be passed if needed via client config
343
+ });
344
+
345
+ return {
346
+ content: response.choices[0].message.content,
347
+ model: this.model,
348
+ provider: 'perplexity',
349
+ usage: {
350
+ promptTokens: response.usage?.prompt_tokens || 0,
351
+ completionTokens: response.usage?.completion_tokens || 0,
352
+ totalTokens: response.usage?.total_tokens || 0
353
+ },
354
+ // Include search citations if available (Perplexity feature)
355
+ citations: response.citations || []
356
+ };
357
+ } catch (error) {
358
+ throw new Error(`Perplexity request failed: ${error.message}`);
359
+ }
360
+ }
361
+
317
362
  /**
318
363
  * Test connection with a simple prompt
319
364
  */