diff --git a/.github/workflows/gemini-extension-release.yml b/.github/workflows/gemini-extension-release.yml new file mode 100644 index 000000000000..28e3b4daf8da --- /dev/null +++ b/.github/workflows/gemini-extension-release.yml @@ -0,0 +1,69 @@ +name: Release Gemini Extension + +on: + workflow_dispatch: + inputs: + tag: + description: 'Tag to release (e.g., gemini-v1.0.0)' + required: true + type: string + +env: + EXTENSION_VERSION: ${{ github.event.inputs.tag || github.ref_name }} + +jobs: + release-gemini-extension: + name: Release Gemini Extension + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + + - name: Build Gemini Extension + run: | + cd integrations/gemini + npm ci + npm run build + npm run package + env: + HUSKY: 0 + + - name: Create Gemini Extension Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.EXTENSION_VERSION }} + name: "Gemini Extension ${{ env.EXTENSION_VERSION }}" + files: integrations/gemini/release/** + body: | + ## Rill Gemini Extension Release + + This release contains the Rill integration for Google Gemini. + + ### Installation + ```bash + gemini extensions install https://github.com/rilldata/rill --ref=${{ env.EXTENSION_VERSION }} + ``` + + See the [README](https://github.com/rilldata/rill/blob/main/integrations/gemini/README.md) for setup instructions. + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Notify Slack + uses: ravsamhq/notify-slack-action@v2 + if: always() + with: + status: ${{ job.status }} + notification_title: "Gemini Extension Release - ${{ env.EXTENSION_VERSION }}" + message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>" + footer: "Linked Repo <{repo_url}|{repo}>" + notify_when: "failure" + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ANNOUNCE_DD }} diff --git a/.prettierignore b/.prettierignore index 93696b4ac490..80fd4b5fee42 100644 --- a/.prettierignore +++ b/.prettierignore @@ -20,6 +20,7 @@ web-common/tests/projects web-local/tests/data .env +.example.env *.sql *.bin *.csv diff --git a/integrations/README.md b/integrations/README.md new file mode 100644 index 000000000000..171709800a33 --- /dev/null +++ b/integrations/README.md @@ -0,0 +1,5 @@ +# Rill Integration + +## Google Gemini Integration + +Enhance your Rill Data experience with the Gemini integration, enabling advanced data analysis. Explore the [Gemini README](gemini/README.md) for detailed information on installation, configuration, and usage. diff --git a/integrations/gemini/GEMINI.md b/integrations/gemini/GEMINI.md new file mode 100644 index 000000000000..981e56b81e53 --- /dev/null +++ b/integrations/gemini/GEMINI.md @@ -0,0 +1,95 @@ +## Rill Gemini Integration + +You are an expert data analyst with access to Rill's metrics views through specialized tools. You can autonomously explore data, generate insights, and create text-based visualizations. When users ask about their data, you should use the available Rill tools to query metrics views and provide comprehensive analysis. + +## Chart Generation + +When users request data visualization, do not build web pages or React apps. Instead, create text-based visualizations using Unicode characters and formatting. Use these techniques: + +Bar Charts using block characters: + +Q1 ████████░░ 411 + +Q2 ██████████ 514 + +Q3 ██████░░░░ 300 + +Q4 ████████░░ 400 + +Horizontal progress bars: Project Progress: + +Frontend ▓▓▓▓▓▓▓▓░░ 80% + +Backend ▓▓▓▓▓▓░░░░ 60% + +Testing ▓▓░░░░░░░░ 20% + +Using different block densities: Trends: + +Jan ▁▂▃▄▅▆▇█ High + +Feb ▁▂▃▄▅░░░ Medium + +Mar ▁▂░░░░░░ Low + +Sparklines with Unicode Basic sparklines: + +Stock prices: ▁▂▃▅▂▇▆▃▅▇ + +Website traffic: ▁▁▂▃▅▄▆▇▆▅▄▂▁ + +CPU usage: ▂▄▆█▇▅▃▂▄▆█▇▄▂ + +Trend indicators: + +AAPL ▲ +2.3% + +GOOG ▼ -1.2% + +MSFT ► +0.5% + +TSLA ▼ -3.1% + +Simple trend arrows: Sales ↗️ (+15%) Costs ↘️ (-8%) Profit ⤴️ (+28%) + +Pivot tables using text formatting: + +| Region | Q1 Sales | Q2 Sales | Q3 Sales | Q4 Sales | +| ------ | -------- | -------- | -------- | -------- | +| North | $120,000 | $130,000 | $125,000 | $140,000 | +| South | $100,000 | $110,000 | $115,000 | $120,000 | +| East | $90,000 | $95,000 | $100,000 | $105,000 | +| West | $110,000 | $115,000 | $120,000 | $130,000 | + +Line Charts characters: + +``` +Value + ^ + | /--------------- (Value) + | / + 3 | / + | / + 2 | / + | / + 1 | / + | / + 0 |______/ + +---+---+---+---+---+---+---+---+---+---+---> Timeseries + 0 1 2 3 4 5 6 7 8 9 10 +``` + +## Analysis Guidelines + +### When Users Encounter Issues + +- **Access denied errors**: Inform users to ensure their Rill access token has appropriate permissions +- **No data found**: Guide users to verify their project contains metrics views with available data +- **Incomplete analysis**: Ask users for more specific context about which metrics to focus on + +### Your Analysis Process + +- **Be thorough**: Use available Rill tools to explore data comprehensively +- **Provide context**: Always explain what the data shows and why it matters +- **Cite your sources**: Reference specific metrics views and time ranges used +- **Offer insights**: Go beyond raw numbers to identify trends, patterns, and actionable findings diff --git a/integrations/gemini/README.md b/integrations/gemini/README.md new file mode 100644 index 000000000000..2f04d2456271 --- /dev/null +++ b/integrations/gemini/README.md @@ -0,0 +1,63 @@ +# Gemini CLI Extension for Rill Data + +Professional data analysis and report generation using Rill's metrics layer. + +## Overview + +Check out [Rill's Docs](https://docs.rilldata.com) for more information about Rill. + +## Installation + +Install the extension via GitHub using a specific release tag: + +```bash +gemini extensions install https://github.com/rilldata/rill --ref=gemini-v1.0.0 +``` + +> **Note**: Since this is a monorepo, you must specify a Gemini-specific release tag (prefixed with `gemini-v`) to ensure Gemini CLI picks up the correct extension files. See [Releases](https://github.com/rilldata/rill/releases) for available versions. + +For the latest version, check the [releases page](https://github.com/rilldata/rill/releases) and use the most recent `gemini-v*` tag. + +Install Rill CLI if you haven't already: + +```bash +curl https://rill.sh | sh +``` + +## Configuration + +After installation, configure the extension with your Rill credentials. The extension will prompt you for the following information during setup: + +- **Organization**: Your Rill organization name +- **Project**: Your Rill project name +- **Access Token**: Your Rill access token + +To generate a Rill authentication token, run: + +```bash +rill token issue --display-name "Gemini Extension" +``` + +> **Tip**: You can find your organization and project names in the Rill Cloud UI URL: `https://ui.rilldata.com/{organization}/{project}` + +The extension configuration is handled automatically through Gemini's settings interface - no manual environment file setup is required. + +## Development + +### Local Development + +To test changes locally: + +1. Make your changes to the extension files +2. Install the extension from your local development branch: + ```bash + npm run -w integrations/gemini link + ``` +3. Test the extension in Gemini: + ```bash + npm run -w integrations/gemini unlink + ``` + +### Releasing + +This extension is distributed through [GitHub Releases](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases) diff --git a/integrations/gemini/gemini-extension.json b/integrations/gemini/gemini-extension.json new file mode 100644 index 000000000000..05dca6213977 --- /dev/null +++ b/integrations/gemini/gemini-extension.json @@ -0,0 +1,39 @@ +{ + "name": "rill", + "description": "Professional data analysis using Rill's metrics layer", + "version": "0.1.0", + "displayName": "Rill Analytics", + "contextFileName": "GEMINI.md", + "mcpServers": { + "rill": { + "httpUrl": "https://api.rilldata.com/v1/orgs/${RILL_ORG}/projects/${RILL_PROJECT}/runtime/mcp", + "headers": { + "Authorization": "Bearer ${RILL_ACCESS_TOKEN}", + "Content-Type": "application/json" + }, + "env": { + "RILL_ORG": "${RILL_ORG}", + "RILL_PROJECT": "${RILL_PROJECT}", + "RILL_ACCESS_TOKEN": "${RILL_ACCESS_TOKEN}" + } + } + }, + "settings": [ + { + "name": "Organization", + "description": "Your Rill organization name", + "envVar": "RILL_ORG" + }, + { + "name": "Project", + "description": "Your Rill project name", + "envVar": "RILL_PROJECT" + }, + { + "name": "Access Token", + "description": "Your Rill access token", + "envVar": "RILL_ACCESS_TOKEN", + "sensitive": true + } + ] +} diff --git a/integrations/gemini/package.json b/integrations/gemini/package.json new file mode 100644 index 000000000000..49d0d971f3b4 --- /dev/null +++ b/integrations/gemini/package.json @@ -0,0 +1,23 @@ +{ + "name": "rill", + "version": "0.1.0", + "description": "Data analysis using Rill's metrics layer", + "license": "Apache-2.0", + "type": "module", + "author": { + "name": "Rill Data", + "email": "support@rilldata.com", + "url": "https://rilldata.com" + }, + "scripts": { + "build": "echo 'No build required'", + "link": "gemini extensions link .", + "unlink": "gemini extensions uninstall rill", + "format": "prettier --write \"**/*.{ts,js,json,md}\"" + }, + "repository": { + "type": "git", + "url": "https://github.com/rilldata/rill", + "directory": "integrations/gemini" + } +} diff --git a/package-lock.json b/package-lock.json index ecc23cb9d261..b58c494c373b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "workspaces": [ "docs", + "integrations/gemini", "web-admin", "web-common", "web-integration", @@ -328,6 +329,11 @@ "node": ">=6" } }, + "integrations/gemini": { + "name": "rill", + "version": "0.1.0", + "license": "Apache-2.0" + }, "node_modules/@adobe/css-tools": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.2.tgz", @@ -37652,6 +37658,10 @@ "dev": true, "license": "MIT" }, + "node_modules/rill": { + "resolved": "integrations/gemini", + "link": true + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", diff --git a/package.json b/package.json index 9a33c5cbd181..b338e8ba6fba 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "type": "module", "workspaces": [ "docs", + "integrations/gemini", "web-admin", "web-common", "web-integration", diff --git a/runtime/ai/analyst_agent.go b/runtime/ai/analyst_agent.go index ada57176249b..5d361b465c37 100644 --- a/runtime/ai/analyst_agent.go +++ b/runtime/ai/analyst_agent.go @@ -72,8 +72,15 @@ func (t *AnalystAgent) CheckAccess(ctx context.Context) bool { return false } - // Only allow for rill user agents since it's not useful in MCP contexts. - if !strings.HasPrefix(s.CatalogSession().UserAgent, "rill") { + // Allow for rill user agents and rill integrations + // Check if the user agent indicates this is a Rill client or integration + agent := s.CatalogSession().UserAgent + isRillClient := strings.HasPrefix(agent, "rill") + + // Allow rill-gemini-extension specifically for Gemini integration + isGeminiIntegration := strings.Contains(agent, "rill-gemini-extension") + + if !isRillClient && !isGeminiIntegration { return false }