Skip to content

Add the SQLX CLI integration to the settings page - #2959

Merged
openai0229 merged 4 commits into
mainfrom
feature/sqlx-cli-integration
Sep 28, 2026
Merged

openai0229 merged 4 commits into
mainfrom
feature/sqlx-cli-integration

Conversation

@openai0229

Copy link
Copy Markdown
Contributor

What this adds

A CLI 集成 section in 设置 that installs, updates and locates the OtterMind SQLX command line,
imports the datasources Chat2DB already holds, and shows the Skill command an agent needs.

SQLX is a separate product from the chat2db CLI (/api/cli/v1), so it gets its own module and its own
page section instead of extending the existing CLI entry.

Backend

  • chat2db-community-sqlx (new module): platform/asset mapping for the official release, version
    parsing from sqlx --version, a process runner, the release installer (download → SHA-256 → extract →
    atomic move, with a managed fallback directory when the official directory is not writable), settings
    storage, and the status service the page polls.
  • Credentials never leave the JVM in the clear: the import reads them with
    queryDisplayDataSourceById(id, true) — the decrypted view the connection path itself uses — and sends
    them to the SQLX child process on stdin. They do not appear in argv, on disk, in the renderer, or in
    logs. The status endpoint never returns a credential.
  • chat2db-community-tools: the SqlxBridge contract plus SqlxStatus and SqlxDatasourceState, so
    the JCEF shell reaches the bridge without depending on a domain or storage module.
  • chat2db-community-jcef: eight handlers (get-sqlx-status, install-sqlx, update-sqlx,
    check-sqlx-update, cancel-sqlx-operation, set-sqlx-binary, import-sqlx-datasources,
    get-sqlx-datasource-states) and a boundary test that fails if a handler imports an implementation
    package.
  • chat2db-community-start: registers the bridge before Spring starts and attaches the datasource
    reader after app.run, so the page never sees a missing bridge.
  • SqlxConnectionMapping reaches the eight engines added for the next SQLX release — Presto, Hive,
    Kylin, XuguDB, Db2, Informix (which Chat2DB spells INFOMIX), SUNDB and GBase 8s — instead of skipping
    them as unsupported. Snowflake, Oscar, Elasticsearch, BigQuery and Redshift stay unsupported and keep
    reporting their reason.

Page

Version line with the update check, one adaptive action button (install / update / check), a redetect that
stays visible long enough to be seen, the executable path, a datasource table with a status column
(已导入 / 未导入 / 暂不支持 / 信息不完整) where only importable rows can be selected, the import result as an
alert, and the Skill commands with hover copy buttons.

Verification

  • mvn -pl :chat2db-community-sqlx -am test — 41 tests, including the engine mapping for the new types,
    the datasource reader that must use the decrypted view, and the release installer.
  • yarn test:sqlx-setting, yarn test:settings-layout, yarn test:i18n, yarn test:community-boundary,
    eslint on the changed files, and yarn build:web:community.
  • Exercised by hand in the desktop app against a real installation, a self-update, and an import of a
    MySQL datasource that then answered a query through sqlx.

The page installs, updates and locates the OtterMind SQLX command line, imports the datasources
Chat2DB already holds, and shows the Skill commands an agent needs. SQLX is a separate product
from the chat2db CLI, so it gets its own module and its own page section instead of extending the
existing CLI entry.

* chat2db-community-sqlx: platform and asset mapping for the official release, version parsing,
  a process runner, the release installer with SHA-256 verification and an atomic move, settings
  storage, and the status service. Credentials are read through queryDisplayDataSourceById(id,
  true) -- the decrypted view the connection path uses -- and travel to the SQLX child process on
  stdin, never through argv, files, the renderer or the logs.
* chat2db-community-tools: the SqlxBridge contract, SqlxStatus and SqlxDatasourceState so the JCEF
  shell can reach the bridge without depending on a domain or storage module.
* chat2db-community-jcef: eight handlers (status, install, update, check, cancel, choose binary,
  import, datasource states) plus a boundary test that fails if any handler imports an
  implementation package.
* chat2db-community-start: registers the bridge before Spring starts and attaches the datasource
  reader after app.run, so the page never sees a missing bridge.
* chat2db-community-client: the CLI 集成 settings section with the version line, one adaptive
  action button, a redetect that stays visible long enough to be seen, a datasource table with a
  status column (已导入 / 未导入 / 暂不支持 / 信息不完整) that only lets importable rows be
  selected, an import result reported as an alert, and the Skill commands with hover copy buttons.

SqlxConnectionMapping now reaches the eight engines added for the next SQLX release (Presto, Hive,
Kylin, XuguDB, Db2, Informix -- which Chat2DB spells INFOMIX -- SUNDB and GBase 8s), so they import
once that release ships instead of being skipped as unsupported. Snowflake, Oscar, Elasticsearch,
BigQuery and Redshift stay unsupported and keep reporting their reason.

Verified: chat2db-community-sqlx tests (41, including the new engine mapping and the datasource
reader that must use the decrypted view), test:sqlx-setting, test:settings-layout, test:i18n,
eslint on the changed files, and build:web:community. The desktop app was exercised by hand
against a real installation, an update and an import of a MySQL datasource.
@openai0229
openai0229 requested a review from a team as a code owner September 24, 2026 04:35
@openai0229 openai0229 moved this to In Review in Chat2DB Community Sep 24, 2026
The Skill page section only showed `sqlx skill install --target <agent>`, which
installs the Skill into an agent whose plugin the user still has to add. Each row
now carries the command the SQLX README documents for that agent, so the plugin,
the CLI and the Skill arrive together:

* Codex and Claude Code: marketplace plus plugin install.
* dsh: both documented profiles, browser UI and terminal UI.
* pi: the npm package.

The section description says the plugin brings the CLI and the Skill, and the
settings search indexes plugin and marketplace. Verified with test:sqlx-setting,
test:i18n, eslint and build:web:community.
The mapping filled `service` for Oracle only, so an imported Informix or GBase 8s
connection stored an empty server instance. SQLX does not require it for those two
engines, so the import reported success and the failure appeared later, when the
driver refused the URL with "GBASEDBTSERVER has to be specified" or an
INFORMIXSERVER error.

Chat2DB keeps that instance in the form's service field (`InformixDBManager`
appends `INFORMIXSERVER=`, `GBase8sDBManager` appends `GBASEDBTSERVER=`) and in the
saved URL parameter block. The mapping now sends it as `--service`, and the
database name it derives drops the `:KEY=value` block, which used to end up inside
`database` (`app:INFORMIXSERVER=informix`). 42 module tests pass.
`useBinary` recorded the path, version and source of the adopted executable but
left the note and digest of the download this page made. The page renders that
note when the probe has no message of its own, so an adopted binary could still
show "could not install into ..." from an earlier, unrelated install.
@openai0229
openai0229 merged commit ca6f864 into main Sep 28, 2026
17 of 19 checks passed
@openai0229
openai0229 deleted the feature/sqlx-cli-integration branch September 28, 2026 04:55
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant