Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(ai): broaden agent execution intent

t8y2c3bc9d5d074c
diff --git a/src/lib/aiSqlExecutionPolicy.ts b/src/lib/aiSqlExecutionPolicy.ts
index 1f11a0575b..22d176b1c7 100644
--- a/src/lib/aiSqlExecutionPolicy.ts
+++ b/src/lib/aiSqlExecutionPolicy.ts
@@ -24,9 +24,9 @@ const NON_PRODUCTION_RE =
/\b(local|localhost|dev|develop|development|test|testing|stage|staging|sandbox|demo)\b|本地|开发|测试|预发/i;
const LOCAL_HOST_RE = /^(localhost|127(?:\.\d{1,3}){3}|0\.0\.0\.0|::1)$/i;
const NEGATIVE_EXECUTION_RE =
- /(不要|别|不用|禁止|只生成|仅生成|只写|仅写).{0,12}(执行|运行)|do\s+not\s+execute|don't\s+execute|dont\s+execute|without\s+executing|only\s+(generate|write|return)/i;
+ /(不要|别|不用|禁止|只生成|仅生成|只写|仅写).{0,12}(执行|运行|跑)|do\s+not\s+execute|don't\s+execute|dont\s+execute|without\s+executing|only\s+(generate|write|return)/i;
const ACTION_INTENT_RE =
- /(查一下|查询|查看|看一下|统计|列出|执行|运行|跑一下|show|list|query|find|count|get|fetch|execute|run)/i;
+ /(帮我查|帮忙查|请查|查一下|查询|查看|看一下|看下|统计|计算|算|求|平均|最大|最小|总数|数量|列出|显示|获取|执行|运行|跑一下|show|list|query|find|count|get|fetch|execute|run)/i;
export function stripAiSqlComments(sql: string): string {
return sql
diff --git a/tests/aiSqlExecutionPolicy.test.ts b/tests/aiSqlExecutionPolicy.test.ts
index 4d30c340b0..3f67836936 100644
--- a/tests/aiSqlExecutionPolicy.test.ts
+++ b/tests/aiSqlExecutionPolicy.test.ts
@@ -61,7 +61,14 @@ test("comments and multi-statement writes do not bypass policy", () => {
test("AI auto-execution only attempts action-oriented generate requests", () => {
assert.equal(shouldAttemptAiAutoExecute("查一下用户数量", "generate"), true);
+ assert.equal(shouldAttemptAiAutoExecute("帮我查ihli的平均值", "generate"), true);
+ assert.equal(shouldAttemptAiAutoExecute("看下 ihli 平均是多少", "generate"), true);
+ assert.equal(shouldAttemptAiAutoExecute("求 ihli 的最大值", "generate"), true);
+ assert.equal(shouldAttemptAiAutoExecute("计算 ihli 总数", "generate"), true);
+ assert.equal(shouldAttemptAiAutoExecute("显示最近 10 条订单", "generate"), true);
+ assert.equal(shouldAttemptAiAutoExecute("获取用户数量", "generate"), true);
assert.equal(shouldAttemptAiAutoExecute("show me recent orders", "generate"), true);
assert.equal(shouldAttemptAiAutoExecute("只生成 SQL,不要执行", "generate"), false);
+ assert.equal(shouldAttemptAiAutoExecute("先别跑,帮我查一下用户数量", "generate"), false);
assert.equal(shouldAttemptAiAutoExecute("优化这条 SQL", "optimize"), false);
});