feat: project-level config loading + default safety LIMIT - #1
Merged
Conversation
Brainstormed design for mysql-cli default safe LIMIT (cap=1000, cap+1 probe, meta.truncated) + JSON envelope slimming (drop rows_affected on SELECT, add --format jsonl). Driven by scripts/token-shootout.py findings: bare SELECT returns 6.8M (MCP) / 9.1M (CLI) tokens, both overflow any agent session.
Add ReadJSON for read queries (SELECT): omits rows_affected and reports meta.truncated + meta.limit, consuming result.Result.Truncated from Task 1. Add jsonl format branch to Format: one JSON object per line via formatJSONL, with NULL rendered as native JSON null. SuccessJSON unchanged; existing TestJSONEnvelope still passes.
- 项目级 config:从 cwd 向上找 .config/mysql-cli/config.toml(与全局同构) - 覆盖式合并 + 信任清单机制(防恶意仓库/ENV 套取) - MYSQL_CLI_CONFIG env + config 子命令族(path/show/trust/init) - 优先级链:--config > env > 项目级(已信任) > 全局 - 分阶段实现建议(Phase 1-3)
12 TDD tasks across 3 phases: - Phase 1: loader.go core (DiscoverProject/MergeConfigs/Load) + Globals.resolve wiring (compat) - Phase 2: trust store + MYSQL_CLI_CONFIG env + 'config trust' - Phase 3: config path/show/init + Masked + skill docs - Task 12: full coverage gate (>=80%)
… drop stray roadmap.md Finding 1 (loader.go): swap the loop order in DiscoverProject so the home/root boundary check runs BEFORE the candidate stat. Because project and global configs share the same relConfigPath (.config/mysql-cli/config.toml), the prior order would walk up to home, find the global config there, and wrongly return home as the project root. Now home is never searched as a project root. Finding 2 (loader_test.go): add TestDiscoverProject_HomeGlobalConfigIsNotProject which installs the global config at home/.config/mysql-cli/config.toml and asserts DiscoverProject from a home subdir returns found=false. The prior TestDiscoverProject_StopsAtHome never installed a config at home, so it passed regardless of boundary order. Finding 3 (docs/roadmap.md): the file was newly added in 93d207c and unrelated to Task 1; removed from the branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two features —
feat/project-configbuilds onfeat/default-limit(default-limit has not yet merged to main, so this PR carries both).1. Project-level config loading (this branch's main feature)
.config/mysql-cli/config.toml(same relative path as global~/.config/mysql-cli/config.toml; only the root differs).default/default_limitproject overrides global (0/empty = unset).~/.config/mysql-cli/trusted, plaintext,EvalSymlinks-normalized,0600): untrusted project config is silently skipped (exit 0);${ENV}password placeholders expand only in trusted configs — prevents malicious repos from hijacking connections or siphoning env-var passwords.MYSQL_CLI_CONFIGenv var to specify a config path.configsubcommand group:path/show/trust/init(passwords masked inshow: plaintext→***,${ENV}as-is).--config>MYSQL_CLI_CONFIG> project (trusted) > global >MYSQL_*field overrides > default.--configbehaves exactly as before;--configsingle-file semantics unchanged.2. Default safety LIMIT (default-limit, base of this branch)
--no-limitdisables;--limit Nexplicit.default_limitconfig /MYSQL_CLI_DEFAULT_LIMITenv tune the cap.meta.truncatedmarker (cap+1 probe, zero extra queries);--format jsonlslim envelope.Design & Plan
docs/superpowers/specs/2026-07-24-project-level-config-design.md(+ default-limit spec)docs/superpowers/plans/2026-07-24-project-level-config.md(+ default-limit plan)Test plan
go test ./...— all packages greengo vet ./...clean,go build ./...clean, gofmt clean-dsingle + unknown datasource)Notes
AddTrustswallowsReadTrustederr (plan-mandated, benign), inline mode literals.skills/mysql-shared/SKILL.md(version 1.1.0 → 1.2.0).