Skip to content

feat: implement Phase 4 (Filters) and Phase 5 (AI Auth & Provider System)#128

Merged
utkarsh232005 merged 3 commits into
KDM-cli:mainfrom
utkarsh232005:phase4-5
Jun 7, 2026
Merged

feat: implement Phase 4 (Filters) and Phase 5 (AI Auth & Provider System)#128
utkarsh232005 merged 3 commits into
KDM-cli:mainfrom
utkarsh232005:phase4-5

Conversation

@utkarsh232005
Copy link
Copy Markdown
Member

@utkarsh232005 utkarsh232005 commented Jun 7, 2026

This PR implements K8sGPT-style filter management (Phase 4) and AI provider management (Phase 5) along with unit tests. Fully compliant with coding_style.md guidelines.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added auth command to manage AI providers: add, update, list, set default, and remove providers
    • Support for multiple AI backends: OpenAI, Anthropic, Ollama, and custom REST endpoints
    • Added filters command to manage analyzer filters: list, add, and remove
    • Custom headers and configurable parameters for AI providers
  • Tests

    • Comprehensive test coverage for auth and filters commands and AI client implementations

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 7, 2026

Review Change Stack

Warning

Review limit reached

@utkarsh232005, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 51 minutes and 12 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c28c3cfc-f56c-4d86-8108-4a64fab5a909

📥 Commits

Reviewing files that changed from the base of the PR and between b644c82 and cd64242.

📒 Files selected for processing (4)
  • src/__tests__/auth.test.ts
  • src/ai/anthropic.ts
  • src/ai/openai.ts
  • src/commands/auth.ts

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key: "pre_merge_checks"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

This PR introduces a pluggable AI client system with four production backends (OpenAI, Anthropic, Ollama, CustomRest), a test stub (Noop), and CLI commands to manage provider credentials and analyzer filters. The factory pattern enables runtime backend selection from stored configuration.

Changes

AI Provider Management and Filter CLI Commands

Layer / File(s) Summary
AI Client Interface
src/ai/types.ts
Standardized AIClient interface with configure, getCompletion, and optional close methods.
AI Client Implementations
src/ai/noop.ts, src/ai/anthropic.ts, src/ai/custom-rest.ts, src/ai/ollama.ts, src/ai/openai.ts
Five AI client implementations with backend-specific request formatting, header handling, and response parsing. AnthropicAIClient validates API key presence; CustomRestAIClient supports arbitrary endpoints; OpenAI and Ollama apply URL normalization and default model/base-url values.
AI Client Factory
src/ai/factory.ts
createAIClient(backendName) maps backend names to client classes, loads provider config, instantiates and configures the client, and returns a ready-to-use instance.
Auth Command
src/commands/auth.ts
CLI subcommands for provider management: auth add (with defaults for model and numeric fields), auth update (per-field modification), auth list (with secret masking), auth default, auth remove (with default provider reassignment).
Filters Command
src/commands/filters.ts
CLI subcommands for analyzer filters: filters list (shows active and available-but-inactive), filters add (with duplicate detection), filters remove (handles explicit and default-set removals).
Root CLI Integration
src/commands/root.ts
Registers auth and filters commands alongside existing show/health/watch/logs/config/analyze commands.
Auth and AI Client Tests
src/__tests__/auth.test.ts
Mocks config store and fetch; tests provider add/update/list/default/remove, parameterized client request wiring across four backends with URL/header/body assertions, error handling for missing required fields and unsupported backends, and HTTP error responses.
Filters Command Tests
src/__tests__/filters.test.ts
Mocks filter store; tests list (empty and populated), add (valid/duplicate/invalid), remove (active/inactive/from-defaults/invalid), with exit-code and console-output assertions.

Sequence Diagram(s)

sequenceDiagram
  participant User as User
  participant CLI as Auth CLI
  participant Store as Config Store
  participant Factory as Factory
  participant Client as AIClient
  participant HTTP as HTTP Endpoint
  
  User->>CLI: auth add openai
  CLI->>Store: getAIConfig()
  Store-->>CLI: current config
  CLI->>CLI: validate backend
  CLI->>Store: setAIConfig(provider added)
  Store-->>CLI: persisted
  CLI-->>User: "Added openai provider"
  
  User->>CLI: some-command-that-needs-ai
  CLI->>Factory: createAIClient('openai')
  Factory->>Store: getAIConfig()
  Factory->>Client: new OpenAIAIClient()
  Factory->>Client: configure(providerConfig)
  Client-->>Factory: configured
  Factory-->>CLI: AIClient instance
  CLI->>Client: getCompletion(prompt)
  Client->>HTTP: POST /chat/completions
  HTTP-->>Client: response with choices
  Client-->>CLI: "completion text"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

version2

Poem

🤖 Four backends now dance in harmony,
Ollama, OpenAI, Anthropic, REST—
A pluggable symphony of completion,
Masking secrets while users request,
CLI commands filter and configure with grace. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: implementing filter management (Phase 4) and AI provider/auth system (Phase 5), matching the substantial additions across test files, commands, and AI client implementations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 7, 2026

Codecov Report

❌ Patch coverage is 92.41877% with 21 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/commands/auth.ts 88.18% 0 Missing and 15 partials ⚠️
src/ai/anthropic.ts 92.00% 0 Missing and 2 partials ⚠️
src/ai/openai.ts 92.30% 0 Missing and 2 partials ⚠️
src/ai/custom-rest.ts 94.44% 0 Missing and 1 partial ⚠️
src/ai/ollama.ts 94.11% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 7, 2026
codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@utkarsh232005 utkarsh232005 merged commit 81697e8 into KDM-cli:main Jun 7, 2026
11 of 13 checks passed
@utkarsh232005 utkarsh232005 added this to the v2.0.0 milestone Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant