mirror of
https://github.com/Canner/WrenAI.git
synced 2026-08-29 08:18:10 +08:00
feat(skills): detect existing project in wren-generate-mdl skill (#1525)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -81,14 +81,16 @@ wren version
|
||||
|
||||
## Step 3 — Install CLI skills
|
||||
|
||||
Skills are workflow guides that tell Claude Code how to use the Wren CLI effectively. Install both skills:
|
||||
Skills are workflow guides that tell your AI coding agent how to use the Wren CLI effectively. Install both skills:
|
||||
|
||||
```bash
|
||||
npx skills add Canner/wren-engine --skill '*' --agent claude-code
|
||||
npx skills add Canner/wren-engine --skill '*'
|
||||
# or:
|
||||
curl -fsSL https://raw.githubusercontent.com/Canner/wren-engine/main/skills/install.sh | bash
|
||||
```
|
||||
|
||||
The CLI auto-detects your installed agent. To target a specific one, add `--agent <name>` (e.g., `claude-code`, `cursor`, `windsurf`, `cline`).
|
||||
|
||||
This installs two skills:
|
||||
|
||||
| Skill | Purpose |
|
||||
|
||||
+4
-4
@@ -21,12 +21,12 @@ Skills are namespaced as `/wren:<skill>` (e.g., `/wren:wren-generate-mdl`, `/wre
|
||||
|
||||
### Option 2 — npx skills
|
||||
|
||||
Install all skills for Claude Code:
|
||||
Install all skills:
|
||||
```bash
|
||||
npx skills add Canner/wren-engine --skill '*' --agent claude-code
|
||||
npx skills add Canner/wren-engine --skill '*'
|
||||
```
|
||||
|
||||
`npx skills` also supports Cursor, Windsurf, and 30+ other agent tools — replace `--agent claude-code` with your agent of choice.
|
||||
The CLI auto-detects your installed agent. To target a specific one, add `--agent <name>` (e.g., `claude-code`, `cursor`, `windsurf`, `cline`).
|
||||
|
||||
### Option 3 — install script (from a local clone)
|
||||
|
||||
@@ -71,7 +71,7 @@ Each skill automatically checks for updates when invoked. To update manually:
|
||||
|
||||
```bash
|
||||
# Re-add to reinstall the latest version
|
||||
npx skills add Canner/wren-engine --skill '*' --agent claude-code
|
||||
npx skills add Canner/wren-engine --skill '*'
|
||||
|
||||
# Or reinstall from a local clone
|
||||
bash skills/install.sh --force
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@
|
||||
"skills": [
|
||||
{
|
||||
"name": "wren-generate-mdl",
|
||||
"version": "2.0",
|
||||
"version": "2.1",
|
||||
"description": "Generate a Wren MDL project by exploring a database with available tools (SQLAlchemy, database drivers, MCP connectors, or raw SQL). Guides agents through schema discovery, type normalization, and MDL YAML generation using the wren CLI.",
|
||||
"tags": [
|
||||
"wren",
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
{
|
||||
"name": "wren-usage",
|
||||
"version": "2.0",
|
||||
"description": "Wren Engine CLI workflow guide for AI agents. Answer data questions end-to-end using the wren CLI: gather schema context, recall past queries, write SQL through the MDL semantic layer, execute, and learn from confirmed results.",
|
||||
"version": "2.1",
|
||||
"description": "Wren Engine CLI workflow guide for AI agents. Triggers on data questions, reports, metrics, revenue, trends, 'how many', 'show me', 'top N', 'compare', 'breakdown'. Answer data questions end-to-end using the wren CLI.",
|
||||
"tags": [
|
||||
"wren",
|
||||
"usage",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"wren-generate-mdl": "2.0",
|
||||
"wren-usage": "2.0"
|
||||
"wren-generate-mdl": "2.1",
|
||||
"wren-usage": "2.1"
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Generate a Wren MDL project by exploring a database with available
|
||||
license: Apache-2.0
|
||||
metadata:
|
||||
author: wren-engine
|
||||
version: "2.0"
|
||||
version: "2.1"
|
||||
---
|
||||
|
||||
# Generate Wren MDL — CLI Agent Workflow
|
||||
@@ -18,8 +18,9 @@ If the remote version is newer, notify the user before proceeding:
|
||||
> A newer version of the **wren-generate-mdl** skill is available.
|
||||
> Update with:
|
||||
> ```
|
||||
> npx skills add Canner/wren-engine --skill wren-generate-mdl --agent claude-code
|
||||
> npx skills add Canner/wren-engine --skill wren-generate-mdl
|
||||
> ```
|
||||
> The CLI auto-detects your installed agent. To target a specific one, add `--agent <name>` (e.g., `claude-code`, `cursor`, `windsurf`, `cline`).
|
||||
|
||||
Then continue with the workflow below regardless of update status.
|
||||
|
||||
@@ -42,6 +43,27 @@ For memory and query workflows after setup, see the **wren-usage** skill.
|
||||
|
||||
---
|
||||
|
||||
## Phase 0 — Detect existing project
|
||||
|
||||
**Goal:** If the current directory is already inside a wren project, let the user decide how to proceed.
|
||||
|
||||
Check whether `wren_project.yml` exists in the current working directory
|
||||
(or any parent up to the repository root). If found:
|
||||
|
||||
1. Tell the user that an existing wren project was detected and show its path.
|
||||
2. Ask:
|
||||
- **Reset** — wipe the existing project (`models/`, `views/`,
|
||||
`relationships.yml`, `instructions.md`, and rebuild `wren_project.yml`)
|
||||
and regenerate from scratch in the same directory.
|
||||
- **New path** — keep the existing project untouched and choose a
|
||||
different directory for the new project. Ask the user for the new path,
|
||||
then `wren context init --path <new_path>` and continue from Phase 1
|
||||
using that path.
|
||||
|
||||
If no existing project is detected, proceed directly to Phase 1.
|
||||
|
||||
---
|
||||
|
||||
## Phase 1 — Establish connection and scope
|
||||
|
||||
**Goal:** Confirm the agent can reach the database and agree on scope with the user.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
---
|
||||
name: wren-usage
|
||||
description: "Wren Engine CLI workflow guide for AI agents. Answer data questions end-to-end using the wren CLI: gather schema context, recall past queries, write SQL through the MDL semantic layer, execute, and learn from confirmed results. Use when: agent needs to query data, connect a data source, handle errors, or manage MDL changes via the wren CLI."
|
||||
description: "Wren Engine CLI workflow guide for AI agents. Answer data questions end-to-end using the wren CLI: gather schema context, recall past queries, write SQL through the MDL semantic layer, execute, and learn from confirmed results. Use when: user asks a data question, requests a report or analysis, asks about metrics, revenue, customers, orders, trends, or any business data; user says 'how many', 'show me', 'what is the', 'top N', 'compare', 'trend', 'growth', 'breakdown'; user wants to explore, analyze, filter, aggregate, or summarize data from a database; agent needs to query data, connect a data source, handle errors, or manage MDL changes via the wren CLI."
|
||||
license: Apache-2.0
|
||||
metadata:
|
||||
author: wren-engine
|
||||
version: "2.0"
|
||||
version: "2.1"
|
||||
---
|
||||
|
||||
# Wren Engine CLI — Agent Workflow Guide
|
||||
@@ -18,13 +18,68 @@ If the remote version is newer, notify the user before proceeding:
|
||||
> A newer version of the **wren-usage** skill is available.
|
||||
> Update with:
|
||||
> ```
|
||||
> npx skills add Canner/wren-engine --skill wren-usage --agent claude-code
|
||||
> npx skills add Canner/wren-engine --skill wren-usage
|
||||
> ```
|
||||
> The CLI auto-detects your installed agent. To target a specific one, add `--agent <name>` (e.g., `claude-code`, `cursor`, `windsurf`, `cline`).
|
||||
|
||||
Then continue with the workflow below regardless of update status.
|
||||
|
||||
---
|
||||
|
||||
## Preflight — Verify environment and installation
|
||||
|
||||
**Goal:** Ensure the `wren` CLI is available before entering any workflow.
|
||||
|
||||
### Step 1 — Check Python virtual environment
|
||||
|
||||
Run `python -c "import sys; print(sys.prefix)"` (or equivalent) to determine
|
||||
whether a virtual environment is active.
|
||||
|
||||
- If **no venv is active**, warn the user and ask whether to:
|
||||
- Create one (e.g., `python -m venv .venv && source .venv/bin/activate`)
|
||||
- Continue without a venv (not recommended — may pollute global packages)
|
||||
|
||||
### Step 2 — Check if `wren-engine` is installed
|
||||
|
||||
Run `wren --version`. If the command is not found or errors:
|
||||
|
||||
1. Tell the user that the `wren` CLI is not installed.
|
||||
2. Ask if you should help install it.
|
||||
3. If the user agrees, determine the **datasource extra** to install:
|
||||
|
||||
**Auto-detect from project:** Check whether the current directory is inside
|
||||
a wren project (look for `wren_project.yml` up to the repository root).
|
||||
If found, read the active profile with `cat ~/.wren/profiles.yml` or look
|
||||
for a datasource hint in the project's profile configuration. Extract the
|
||||
datasource type from there.
|
||||
|
||||
**Ask the user:** If no project is detected or no datasource can be
|
||||
inferred, ask the user which database they plan to connect to. Valid
|
||||
extras: `postgres`, `mysql`, `bigquery`, `snowflake`, `clickhouse`,
|
||||
`trino`, `mssql`, `databricks`, `redshift`, `spark`, `athena`, `oracle`.
|
||||
DuckDB is included by default — no extra needed.
|
||||
|
||||
4. Install with the detected or chosen extra:
|
||||
```bash
|
||||
# DuckDB (no extra needed)
|
||||
pip install "wren-engine"
|
||||
|
||||
# Other datasources
|
||||
pip install "wren-engine[<datasource>]"
|
||||
```
|
||||
To also enable semantic memory and web UI (recommended):
|
||||
```bash
|
||||
pip install "wren-engine[<datasource>,memory,ui]"
|
||||
# or for DuckDB:
|
||||
pip install "wren-engine[memory,ui]"
|
||||
```
|
||||
|
||||
5. Verify: `wren --version`
|
||||
|
||||
If `wren --version` succeeds, proceed to the relevant workflow below.
|
||||
|
||||
---
|
||||
|
||||
The `wren` CLI queries databases through an MDL (Model Definition Language) semantic layer. You write SQL against model names, not raw tables. The engine translates to the target dialect.
|
||||
|
||||
Two things drive everything:
|
||||
|
||||
Reference in New Issue
Block a user