STARDUSTLC666 / dsh-sql

Listed

DeepSeek Harness 工程师级数据库插件:sql_list/query/exec/schema 四工具,SQLite/MySQL/PostgreSQL 三引擎、只读白名单、写审批门、行数钳制。· Databases for DeepSeek Harness agents.

masterOther View source

Installation

npx -y @deepseek-ai/dsh plugin --profile web add github:STARDUSTLC666/dsh-sql

This installation command is an unverified starting point generated from the GitHub repository address.

README

Maintainer-authored documentation snapshot.

View on GitHub ↗
Commit 8d636aeSynced Aug 18, 2026

English

dsh-sql

你的 agent 会查库了:SQLite / MySQL / PostgreSQL 三引擎,只读白名单 + 写审批门。

DSH(DeepSeek Harness)工程师级数据库插件:四个工具覆盖连接管理、只读查询、写操作与结构探查。

npm version npm downloads license stars

Awesome DSH Plugin

安装

dsh plugin --profile web add dsh-sql

配置

- id: sql
  name: 'dsh-sql'
  config:
    connections:
      - name: local
        engine: sqlite
        file: E:\data\app.db          # 或 :memory:
      - name: prod
        engine: postgres
        host: db.internal
        database: app
        # password: xxx              # 推荐环境变量 DSH_SQL_PASSWORD_PROD
      - name: legacy
        engine: mysql
        host: 127.0.0.1
        port: 3306
        user: root
        database: legacy
    maxRows: 1000                     # 查询返回行数上限(1-10000)
    queryTimeoutMs: 60000             # 单次查询超时(默认 60 秒,5 秒 - 10 分钟)
    execTimeoutMs: 120000             # 单次写操作超时(默认 120 秒,5 秒 - 10 分钟)
    readOnly: false                   # true 时禁用 sql_exec
    writeApproval: true               # 写操作先弹审批(默认 true)

工具一览

工具作用安全
sql_list列出连接 + 连通性测试
sql_query只读查询(SELECT/PRAGMA/EXPLAIN/SHOW/DESCRIBE/WITH)关键字白名单 + 拒绝多语句
sql_exec写操作/DDL(可多语句脚本)readOnly 禁用 + 审批门
sql_schema表清单 / 表结构标识符白名单校验

示例

sql_list {}
sql_schema {}                                  # 列出所有表
sql_schema { table: users }                    # 看 users 表结构
sql_query { sql: SELECT * FROM orders WHERE status = 'pending' LIMIT 50 }
sql_exec { sql: UPDATE orders SET status = 'paid' WHERE id = 42 }

安全设计

  • 词法级只读保护:sql_query 先剥离字符串/注释再校验,拒绝 data-modifying CTE(WITH…DELETE/UPDATE)、SELECT INTO、FOR UPDATE/FOR SHARE、PRAGMA 赋值与多语句
  • 写审批门:sql_exec 默认弹审批(对齐 dsh-email 的发信审批),headless 环境无审批通道时拒绝执行
  • readOnly 模式:生产库可整体禁用写
  • 流式行数钳制:SQLite 迭代器 / MySQL stream / PostgreSQL portal 都按 maxRows+1 停表,大查询不会全量载入内存,超量标记 truncated
  • 标识符校验:表名只允许字母/数字/下划线,杜绝 schema 注入
  • 密钥不落配置:密码支持 DSH_SQL_PASSWORD_<连接名> 环境变量

引擎

  • SQLite:Node 22.13+ 内置 node:sqlite,零依赖
  • MySQL:mysql2 连接池
  • PostgreSQL:pg 连接池

开发

pnpm install
pnpm test       # 构建 + 35 个测试(含真实 SQLite 集成)

License

MIT

Project files and signals

Shown items are public repository signals detected in the directory snapshot.

TestsDetected

Repository information

Language
TypeScript
License
MIT
Last updated
Aug 18, 2026, 1:04 PM

Install deliberately

Review source code, permissions, lifecycle hooks, dependencies and network access. Test untrusted plugins in an isolated environment.