Skip to content

feat: add CrofAI provider#412

Open
msadiks wants to merge 3 commits intorobinebers:mainfrom
msadiks:crofai-provider
Open

feat: add CrofAI provider#412
msadiks wants to merge 3 commits intorobinebers:mainfrom
msadiks:crofai-provider

Conversation

@msadiks
Copy link
Copy Markdown

@msadiks msadiks commented Apr 27, 2026

Description

Adds CrofAI provider as plugin. Bar chart is not used since usage api from provider doesn't have a total/limit response.

Type of Change

  • Bug fix
  • New feature
  • New provider plugin
  • Documentation
  • Performance improvement
  • Other (describe below)

Testing

  • I ran bun run build and it succeeded
  • I ran bun run test and all tests pass
  • I tested the change locally with bun tauri dev

Checklist

  • I read CONTRIBUTING.md
  • My PR targets the main branch
  • I did not introduce new dependencies without justification

Summary by cubic

Adds the crofai provider plugin to show CrofAI credits and daily request counts. No bar chart is shown because the API doesn’t provide total/limit data.

  • New Features

    • Uses GET https://crof.ai/usage_api/ with CROFAI_API_KEY (Bearer).
    • Overview text: Requests first (remaining today); Credits as dollars (shows $0.00); hides fields when absent/invalid.
    • Stricter response validation with clear errors for missing/invalid key, auth, network/HTTP, or bad types.
    • Theme-aware icon; docs at docs/providers/crofai.md; README updated; env var whitelisted.
  • Migration

    • Set CROFAI_API_KEY in your environment and restart the app.

Written for commit 129b2ba. Summary will update on new commits. Review in cubic

@github-actions github-actions Bot added rust Pull requests that update rust code plugin docs labels Apr 27, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 7 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src-tauri/src/plugin_engine/host_api.rs">

<violation number="1" location="src-tauri/src/plugin_engine/host_api.rs:18">
P1: Adding `CROFAI_API_KEY` to the global plugin env allowlist exposes a sensitive credential to any plugin via `host.env.get`, because env access is not scoped per plugin.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

"CODEX_HOME",
"CLAUDE_CONFIG_DIR",
"CLAUDE_CODE_OAUTH_TOKEN",
"CROFAI_API_KEY",
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Apr 27, 2026

Choose a reason for hiding this comment

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

P1: Adding CROFAI_API_KEY to the global plugin env allowlist exposes a sensitive credential to any plugin via host.env.get, because env access is not scoped per plugin.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src-tauri/src/plugin_engine/host_api.rs, line 18:

<comment>Adding `CROFAI_API_KEY` to the global plugin env allowlist exposes a sensitive credential to any plugin via `host.env.get`, because env access is not scoped per plugin.</comment>

<file context>
@@ -11,10 +11,11 @@ use std::path::{Path, PathBuf};
     "CODEX_HOME",
     "CLAUDE_CONFIG_DIR",
     "CLAUDE_CODE_OAUTH_TOKEN",
+    "CROFAI_API_KEY",
     "USER_TYPE",
     "USE_STAGING_OAUTH",
</file context>
Fix with Cubic

Copy link
Copy Markdown
Owner

@robinebers robinebers left a comment

Choose a reason for hiding this comment

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

Hey! 👋 This is Rob's AI reviewer. Thanks for the contribution!

Nice clean provider plugin overall. The API call is scoped, tests are solid, docs are included, and the env var whitelist was updated. Three things to fix before merge:

  1. Icon themingplugins/crofai/icon.svg uses a fixed gradient fill. OpenUsage icons should use currentColor so they work in light/dark themes.

  2. Show zero credits — if CrofAI returns credits: 0, the plugin hides the Credits line. A valid zero balance should show $0.00, not disappear.

  3. Fail clearly on unexpected data — if credits or usable_requests has the wrong type, the plugin currently treats it like 0. Better to show a clear “usage response invalid” error so bad API data does not look like real usage.

Everything else looks good: manifest shape, README/docs, tests, env whitelist, and request URL all match the repo’s patterns.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 5 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/providers/crofai.md">

<violation number="1" location="docs/providers/crofai.md:55">
P3: Malformed Markdown table in Errors section: separator row declares 3 columns while header/data rows have 2.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread docs/providers/crofai.md
## Errors

| Condition | Message |
|---|---|---|
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: Malformed Markdown table in Errors section: separator row declares 3 columns while header/data rows have 2.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/providers/crofai.md, line 55:

<comment>Malformed Markdown table in Errors section: separator row declares 3 columns while header/data rows have 2.</comment>

<file context>
@@ -46,15 +46,15 @@ Response:
 
 | Condition | Message |
-|---|---|
+|---|---|---|
 | Missing `CROFAI_API_KEY` env var | `No CROFAI_API_KEY found. Set up environment variable first.` |
 | HTTP 401/403 | `API key invalid. Check your CrofAI API key.` |
</file context>
Suggested change
|---|---|---|
|---|---|

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs plugin rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants