Skip to content

222 feat enhance ai analyzer providers power user prompt versioning and swapping#225

Open
MatiasOS wants to merge 8 commits intoopenscan-explorer:release/v1.2.1-afrom
MatiasOS:222-feat-enhance-ai-analyzer-providers-power-user-prompt-versioning-and-swapping
Open

222 feat enhance ai analyzer providers power user prompt versioning and swapping#225
MatiasOS wants to merge 8 commits intoopenscan-explorer:release/v1.2.1-afrom
MatiasOS:222-feat-enhance-ai-analyzer-providers-power-user-prompt-versioning-and-swapping

Conversation

@MatiasOS
Copy link
Member

Description

Enhance the AI Analyzer with new provider support (Perplexity and Gemini), a prompt versioning system with power/regular user modes, and improved contract analysis context with smarter ABI summarization.

Related Issue

Closes #222

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Refactoring
  • Performance improvement
  • Other (please describe):

Changes Made

AI Providers

  • Replaced Together AI with Perplexity and Gemini as new AI providers
  • Added Gemini API integration (callGemini) with its native REST API format
  • Updated provider priority order: Groq > Gemini > Perplexity > OpenAI > Anthropic (free-tier providers first)
  • Increased MAX_TOKENS from 1024 to 4096

Prompt Versioning & User Modes

  • Added PromptVersion type ("stable" | "latest") to support prompt experimentation
  • Introduced power vs regular user modes with distinct prompt configs:
    • Power user: Detailed analysis (8-10 sentences), audience = senior blockchain developer, includes security-focused analysis
    • Regular user: Simplified analysis (3-7 sentences), audience = general user, beginner-friendly language
  • Created a PROMPT_REGISTRY for O(1) lookup by version → mode → type
  • Added prompt version selector in Settings UI (Stable/Latest)
  • Cache keys now incorporate prompt version and user mode to avoid stale results

Smarter Contract Context (aiContext.ts)

  • Replaced raw ABI dump with structured contract intelligence:
    • Interface detection: Automatically identifies ERC-20, ERC-721, ERC-1155, Uniswap V4 Hook, Ownable, AccessControl, Pausable, ERC-2612, UUPS/Transparent Proxy
    • Protocol hints: Detects OpenZeppelin, Uniswap, Solady, Chainlink, Aave, Compound, Safe, EigenLayer, LayerZero from source file paths
    • Function categorization: Groups functions into admin, hooks, core, and view categories
    • Function summary: Counts total, view, state-changing, and payable functions
  • Significantly reduces token usage by sending structured summaries instead of full ABI arrays

Transaction Context

  • Event summaries now include up to 4 decoded parameter name/value pairs for richer AI context

i18n

  • Added translations (en/es) for Perplexity, Gemini provider labels, and prompt version settings

Screenshots (if applicable)

image image

Checklist

  • I have run npm run format:fix and npm run lint:fix
  • I have run npm run typecheck with no errors
  • I have run tests with npm run test:run
  • I have tested my changes locally
  • I have updated documentation if needed
  • My code follows the project's architecture patterns

Additional Notes

  • The latest prompt configs are initially clones of stable — they serve as an experimentation sandbox for prompt iteration without risking regression on the stable path.
  • Gemini uses its native REST API (not OpenAI-compatible), so a dedicated callGemini method was added.
  • The contract context refactor should noticeably reduce AI token consumption while providing better analytical signals (detected interfaces, protocol hints, categorized functions).

@MatiasOS MatiasOS requested a review from AugustoL February 16, 2026 22:14
@github-actions
Copy link

github-actions bot commented Feb 16, 2026

🚀 Preview: https://pr-225--openscan.netlify.app
📝 Commit: daf500132efaa5b2bebf39c6e16c0c7a6ec8a409

@MatiasOS MatiasOS marked this pull request as ready for review February 18, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments