Loading...
Loading...
Compare original and translation side by side
https://raw.githubusercontent.com/Canner/WrenAI/main/skills/versions.jsonwren-usageA newer version of the wren-usage skill is available. Update with:npx skills add Canner/WrenAI --skill wren-usageThe CLI auto-detects your installed agent. To target a specific one, add(e.g.,--agent <name>,claude-code,cursor,windsurf).cline
https://raw.githubusercontent.com/Canner/WrenAI/main/skills/versions.jsonwren-usagewren-usage技能的新版本已可用。 执行以下命令更新:npx skills add Canner/WrenAI --skill wren-usageCLI会自动检测已安装的Agent。若要指定特定Agent,添加参数(例如:--agent <name>,claude-code,cursor,windsurf)。cline
wrenwrenpython -c "import sys; print(sys.prefix)"python -m venv .venv && source .venv/bin/activatepython -c "import sys; print(sys.prefix)"python -m venv .venv && source .venv/bin/activatewren-enginewren-enginewren --versionwrenwren_project.ymlcat ~/.wren/profiles.ymlpostgresmysqlbigquerysnowflakeclickhousetrinomssqldatabricksredshiftsparkathenaoracle# DuckDB (no extra needed)
pip install "wren-engine"
# Other datasources
pip install "wren-engine[<datasource>]"pip install "wren-engine[<datasource>,main]"
# or for DuckDB:
pip install "wren-engine[main]"wren --versionwren --versionwrenwren profile~/.wren/profiles.ymltarget/mdl.jsonwren context buildwren profile listwren profile switch <name>dry-plan--datasource-dwren --versionwrenwren_project.ymlcat ~/.wren/profiles.ymlpostgresmysqlbigquerysnowflakeclickhousetrinomssqldatabricksredshiftsparkathenaoracle# DuckDB(无需扩展)
pip install "wren-engine"
# 其他数据源
pip install "wren-engine[<datasource>]"pip install "wren-engine[<datasource>,main]"
# 针对DuckDB的命令:
pip install "wren-engine[main]"wren --versionwren --versionwrenwren profile~/.wren/profiles.ymlwren context buildtarget/mdl.jsonwren profile listwren profile switch <name>dry-plan--datasource-d| Situation | Command |
|---|---|
| Default | |
| Need specific model's columns | |
| Memory not installed | Read |
wren context instructions| 场景 | 命令 |
|---|---|
| 默认情况 | |
| 需要特定模型的列 | |
| 未安装记忆功能 | 读取项目目录下的 |
wren context instructionswren memory recall -q "<question>" --limit 3wren memory recall -q "<question>" --limit 3wren memory recall -q "<sub-question>"memory recallwren memory recall -q "<sub-question>"memory recallwren --sql 'SELECT c_name, SUM(o_totalprice) FROM orders
JOIN customer ON orders.o_custkey = customer.c_custkey
GROUP BY 1 ORDER BY 2 DESC LIMIT 5'wren dry-plan --sql 'SELECT ...'wren --sql 'SELECT ...'wren --sql 'SELECT c_name, SUM(o_totalprice) FROM orders
JOIN customer ON orders.o_custkey = customer.c_custkey
GROUP BY 1 ORDER BY 2 DESC LIMIT 5'wren dry-plan --sql 'SELECT ...'wren --sql 'SELECT ...'wren memory store --nl "<user's original question>" --sql "<the SQL>"SELECT * ... LIMIT N| Outcome | Action |
|---|---|
| User confirms correct | Store |
| User continues with follow-up | Store, then handle follow-up |
| User says nothing (but question had clear NL description) | Store |
| User says wrong | Do NOT store — fix the SQL |
| Query error | See Error recovery below |
wren memory store --nl "<user's original question>" --sql "<the SQL>"SELECT * ... LIMIT N| 结果 | 操作 |
|---|---|
| 用户确认结果正确 | 存储 |
| 用户提出后续问题 | 存储,然后处理后续问题 |
| 用户未反馈(但问题有明确的自然语言描述) | 存储 |
| 用户表示结果错误 | 不存储——修复SQL |
| 查询出错 | 查看下方的错误恢复流程 |
wren memory fetch -q "<name>" --type model --threshold 0ls target/mdl.jsonwren context showwren memory fetch -q "<column>" --model <name> --threshold 0wren memory fetch -q "<name>" --type model --threshold 0ls target/mdl.jsonwren context showwren memory fetch -q "<column>" --model <name> --threshold 0wren profile debugwren --sql "SELECT 1"postgresmysqlbigquerysnowflakeclickhousetrinomssqldatabricksredshiftsparkathenaoracleduckdbwren profile add --ui--interactive--from-filewren profile debugwren --sql "SELECT 1"postgresmysqlbigquerysnowflakeclickhousetrinomssqldatabricksredshiftsparkathenaoracleduckdbwren profile add --ui--interactive--from-filewren dry-plan --sql "<failed SQL>"| dry-plan result | Failure layer | Next step |
|---|---|---|
| dry-plan fails | MDL / semantic | → Layer 2A |
| dry-plan succeeds, execution fails | DB / dialect | → Layer 2B |
wren dry-plan --sql "<failed SQL>"| dry-plan结果 | 失败层级 | 下一步操作 |
|---|---|---|
| dry-plan失败 | MDL/语义层 | → 第二层A |
| dry-plan成功,但执行失败 | 数据库/方言层 | → 第二层B |
| Error pattern | Diagnosis | Fix |
|---|---|---|
| Wrong column name | |
| Wrong model name | |
| Column exists in multiple models | Qualify with model name: |
| Planning error with JOIN | Relationship not defined in MDL | Check available relationships in context |
| 错误模式 | 诊断 | 修复方案 |
|---|---|---|
| 列名错误 | 运行 |
| 模型名称错误 | 运行 |
| 列存在于多个模型中 | 使用模型名限定列: |
| JOIN相关的规划错误 | MDL中未定义该关系 | 查看上下文中可用的关系 |
| Error pattern | Diagnosis | Fix |
|---|---|---|
| Type mismatch | Column type differs from assumed | Check column type in context, add explicit CAST |
| Function not supported | Dialect-specific function | Use dialect-neutral alternative |
| Permission denied | Table/schema access | Check connection credentials |
| Timeout | Query too expensive | Simplify: reduce JOINs, add filters, LIMIT |
| 错误模式 | 诊断 | 修复方案 |
|---|---|---|
| 类型不匹配 | 列类型与预期不符 | 查看上下文中的列类型,添加显式CAST转换 |
| 函数不支持 | 使用了方言特定函数 | 使用与方言无关的替代函数 |
| 权限不足 | 无表/ schema访问权限 | 检查连接凭证 |
| 超时 | 查询开销过大 | 简化查询:减少JOIN、添加过滤条件、使用LIMIT |
wren profile add --ui--interactive--from-filewren profile debugwren --sql "SELECT 1"wren context initwren context buildwren memory indexwren --sql "SELECT * FROM <model> LIMIT 5"wren profile add --ui--interactive--from-filewren profile debugwren --sql "SELECT 1"wren context initwren context buildwren memory indexwren --sql "SELECT * FROM <model> LIMIT 5"undefinedundefined
---
---Get data back → wren --sql "..."
Aggregation across dims → wren cube query --cube <name> --measures <m> (if cube defined)
See translated SQL only → wren dry-plan --sql "..." (accepts -d <datasource> if no active profile)
Validate against DB → wren dry-run --sql "..."
Schema context → wren memory fetch -q "..."
Filter by type/model → wren memory fetch -q "..." --type T --model M --threshold 0
Store confirmed query → wren memory store --nl "..." --sql "..."
Few-shot examples → wren memory recall -q "..."
Index stats → wren memory status
Re-index after MDL change → wren memory index
Show project context → wren context show
Rebuild manifest → wren context build
Check profile → wren profile debug
Switch profile → wren profile switch <name>获取数据结果 → wren --sql "..."
跨维度聚合 → wren cube query --cube <name> --measures <m>(如果已定义cube)
仅查看转换后的SQL → wren dry-plan --sql "..."(如果无活跃配置文件,可使用-d <datasource>参数)
针对数据库验证 → wren dry-run --sql "..."
Schema上下文 → wren memory fetch -q "..."
按类型/模型过滤 → wren memory fetch -q "..." --type T --model M --threshold 0
存储已确认的查询 → wren memory store --nl "..." --sql "..."
少样本示例 → wren memory recall -q "..."
索引状态 → wren memory status
MDL变更后重新索引 → wren memory index
查看项目上下文 → wren context show
重建清单 → wren context build
检查配置文件 → wren profile debug
切换配置文件 → wren profile switch <name>wren cube listwren cube listwren cube describe <cube_name>wren cube describe <cube_name>| User phrase | Maps to |
|---|---|
| "total revenue" | |
| "by month" | |
| "in 2024" | |
| "for completed orders" | |
| "top N customers" | |
| 用户表述 | 对应参数 |
|---|---|
| “总收入” | |
| “按月” | |
| “2024年” | |
| “针对已完成订单” | |
| “前N个客户” | |
wren cube query \
--cube order_metrics \
--measures revenue,order_count \
--time-dimension "created_at:month:2024-01-01,2025-01-01" \
--filter "status:eq:completed" \
--limit 100echo '{"cube":"order_metrics","measures":["revenue"]}' | wren cube query --from ---sql-onlywren cube query \
--cube order_metrics \
--measures revenue,order_count \
--time-dimension "created_at:month:2024-01-01,2025-01-01" \
--filter "status:eq:completed" \
--limit 100echo '{"cube":"order_metrics","measures":["revenue"]}' | wren cube query --from ---sql-only| Error | Action |
|---|---|
| |
| |
| |
| Derived measure references itself — inspect the cube YAML |
| 错误 | 操作 |
|---|---|
| 运行 |
| 运行 |
| 运行 |
| 派生度量引用了自身——检查cube的YAML文件 |
wren --sqlwren --sqlUser question → Is it an aggregation question?
(SUM, COUNT, AVG, GROUP BY, "by month", "per customer", ...)
├── Yes → Are cubes defined? (`wren cube list` once at start of session)
│ ├── Yes → Does a cube cover the question? (`wren cube describe`)
│ │ ├── Yes → Use `wren cube query` (preferred — lower error rate)
│ │ └── No → Write raw SQL with `wren --sql`
│ └── No → Write raw SQL with `wren --sql`
└── No → Write raw SQL with `wren --sql` (look for memory recall first)用户问题 → 是否为聚合类问题?
(SUM、COUNT、AVG、GROUP BY、“按月”“按客户”等)
├── 是 → 是否已定义cube?(会话开始时运行一次`wren cube list`)
│ ├── 是 → 是否有cube覆盖该问题?(运行`wren cube describe`)
│ │ ├── 是 → 使用`wren cube query`(优先选择——错误率更低)
│ │ └── 否 → 使用`wren --sql`编写原始SQL
│ └── 否 → 使用`wren --sql`编写原始SQL
└── 否 → 使用`wren --sql`编写原始SQL(先查看memory recall结果)--connection-infowren profile add--connection-file--connection-infowren profile add--connection-file