pinescript-ai  by arturoabreuhd

Self-hosted PineScript code generator with RAG and multi-LLM support

Created 1 month ago
369 stars

Top 76.6% on SourcePulse

GitHubView on GitHub
Project Summary

A self-hosted AI code generator for TradingView's PineScript, pinescript-ai addresses the need for efficient, customizable, and secure script development. It targets PineScript developers by leveraging Retrieval-Augmented Generation (RAG) and multi-provider Large Language Model (LLM) support, offering a private, on-device solution that respects user API keys. The primary benefit is empowering developers with AI assistance without compromising data privacy or relying on external services for key management.

How It Works

The project employs a RAG architecture centered around a local BM25 search index, eliminating the need for vector databases or external embedding APIs. This index is built from PineScript v6 documentation and 285 example scripts, allowing users to customize the AI's knowledge base by adding their own Markdown docs or .pine scripts. At runtime, relevant retrieved information (function signatures, documentation chunks, example scripts) is injected into LLM prompts, grounding the AI's responses. A multi-stage validation pipeline, including static rules, an optional AST transpiler, and AI code review with auto-correction, ensures generated code quality.

Quick Start & Requirements

  • Primary install/run command:
    git clone https://github.com/arturoabreuhd/pinescript-ai.git
    cd pinescript-ai
    npm install
    npm run dev
    
    The application will be accessible at http://localhost:3000.
  • Non-default prerequisites: Node.js, LLM provider API keys (Anthropic, OpenAI, Google, or Ollama for local models). API keys are stored locally in the browser's localStorage. An optional AST transpiler (pine-transpiler) can be installed via npm install github:Opus-Aether-AI/pine-transpiler for enhanced validation.
  • Estimated setup time: Minimal, primarily involving cloning, dependency installation, and API key configuration.
  • Relevant pages: GitHub Repository

Highlighted Details

  • Multi-Provider LLM Support: Integrates with Anthropic (Claude), OpenAI (GPT-4.1, o3), Google (Gemini via OpenAI-compatible API), and local Ollama models.
  • Customizable RAG: Utilizes a local BM25 index for retrieval, allowing users to easily extend or replace the knowledge base with their own documentation and scripts.
  • 3-Layer Validation Pipeline: Includes static regex rules, an optional AST transpiler check, and AI-driven code review with auto-correction capabilities.
  • BYOK (Bring Your Own Key): API keys are securely stored in the browser's localStorage, ensuring they never leave the user's machine.
  • Live Code Editor: Features CodeMirror 6 with PineScript syntax highlighting and inline display of validation results.
  • Streaming Output: Real-time Server-Sent Events (SSE) streaming from all supported LLM providers.

Maintenance & Community

No specific details regarding maintainers, community channels (like Discord/Slack), sponsorships, or roadmaps were present in the provided README.

Licensing & Compatibility

  • License: MIT.
  • Compatibility: The MIT license is permissive and generally compatible with commercial use and closed-source projects. However, the optional pine-transpiler dependency is AGPL-3.0 licensed, which carries strong copyleft obligations if integrated into proprietary software.

Limitations & Caveats

The optional AST transpiler validation is licensed under AGPL-3.0, which may impose significant restrictions on its use within closed-source or commercial applications. Rebuilding the RAG index (npm run build-rag) is a full regeneration process and does not support incremental updates.

Health Check
Last Commit

1 month ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
6
Star History
20 stars in the last 30 days

Explore Similar Projects

Starred by Jared Palmer Jared Palmer(SVP at GitHub; Founder of Turborepo; Author of Formik, TSDX), Vincent Weisser Vincent Weisser(Cofounder of Prime Intellect), and
8 more.

llm-vscode by huggingface

0%
1k
VSCode extension for LLM-powered code development
Created 3 years ago
Updated 4 days ago
Feedback? Help us improve.