Skip to content

Commit f3c8aa5

Browse files
authored
Merge pull request #26 from tidbcloud/agent/global-preferences
Add global CLI preferences
2 parents 5671e31 + 9984a37 commit f3c8aa5

19 files changed

Lines changed: 1439 additions & 297 deletions

‎AGENTS.md‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Implemented:
2121
- CLI foundation from `docs/spec/done/0001-cli-foundation.md`
2222
- Local config and credentials from
2323
`docs/spec/done/0002-local-config-and-credentials.md`
24+
- Global settings and operation logging configuration from
25+
`docs/spec/done/0021-global-settings.md`
2426
- Output, query, and dry-run contracts from
2527
`docs/spec/done/0003-output-error-query-dry-run.md`
2628
- API client auth, authorization, and region routing from
@@ -286,6 +288,7 @@ internal/output/ structured JSON/text/raw rendering
286288
internal/organization/ organization project command use cases
287289
internal/query/ JMESPath query application
288290
internal/secretinput/ no-echo secret input helper
291+
internal/settings/ global settings parsing and legacy logging migration
289292
internal/telemetrybackend/ telemetry API, batcher, TiDB, and PostHog sinks
290293
internal/update/ GitHub Releases update checks and self-update logic
291294
internal/version/ build version metadata
@@ -617,9 +620,15 @@ specs or demos.
617620

618621
All tdc local state belongs under `~/.tdc/`.
619622

620-
- `~/.tdc/config` stores non-sensitive TOML values.
621-
- `~/.tdc/credentials` stores sensitive TOML values.
623+
- `~/.tdc/config` stores profile-scoped non-sensitive TOML values.
624+
- `~/.tdc/credentials` stores profile-scoped sensitive TOML values.
622625
- Both files use profile sections such as `[default]` and `[stage]`.
626+
- `~/.tdc/.preferences` is optional hidden global TOML configuration and is
627+
never selected by profile. Fresh installs and `tdc configure` do not create
628+
it. Do not create or migrate the unshipped intermediate `~/.tdc/settings`
629+
path.
630+
- The profile name `logging` is reserved so legacy global logging configuration
631+
cannot be confused with a profile.
623632
- The default profile name is `default`.
624633
- The global `--profile` flag selects a profile when explicitly provided.
625634
- The global `--region` flag selects command-scope placement when explicitly
@@ -823,17 +832,25 @@ fixtures.
823832

824833
Local operation logs are enabled by default and live at
825834
`~/.tdc/logs/tdc.jsonl`. They are local audit/debug summaries, not telemetry.
826-
`TDC_LOGGING=off` disables them for the current process, and global config can
827-
disable them with:
835+
`TDC_LOGGING=off` disables them for the current process, and global settings
836+
can disable them with:
828837

829838
```toml
839+
# ~/.tdc/.preferences
840+
schema_version = 1
841+
830842
[logging]
831843
enabled = false
832844
```
833845

834846
Environment values `off`, `false`, `0`, and `no` disable logging; `on`,
835847
`true`, `1`, and `yes` enable it. The environment variable takes precedence
836-
over config. Do not add a `tdc logging status` command. The operation log may
848+
over settings. Do not add a `tdc logging status` command. Invalid settings or
849+
environment values fail closed for logging without failing the requested
850+
command. Legacy `[logging]` in `~/.tdc/config` is migrated atomically into
851+
`~/.tdc/.preferences`; config and credentials remain profile-only afterward.
852+
Every `tdc update` form must bypass settings, migration, profiles, credentials,
853+
operation logs, and all other `~/.tdc/` state. The operation log may
837854
record command paths, flag names, profile names, region codes, duration, exit
838855
code, app error code/category, service name, HTTP method/status, operation, and
839856
request id. It must never record flag values, SQL text, SQL results, file
@@ -939,7 +956,7 @@ boundary writes to stdout/stderr and maps errors to exit codes.
939956

940957
The product-owned telemetry backend is implemented as the independent
941958
`tdc-telemetry-backend` process. The CLI collection and delivery path remains
942-
governed by `docs/spec/0021-telemetry.md`. Telemetry must be opt-aware and
959+
governed by `docs/spec/0022-telemetry.md`. Telemetry must be opt-aware and
943960
privacy-preserving. Allowed fields:
944961

945962
- command and subcommand invoked

‎README.md‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,24 @@ Alternatively, set up a default profile interactively by running the command bel
110110
tdc configure
111111
```
112112

113-
`tdc configure` stores non-sensitive settings in `~/.tdc/config` and API credentials to `~/.tdc/credentials`.
113+
`tdc configure` stores non-sensitive profile configuration in `~/.tdc/config` and API credentials in `~/.tdc/credentials`.
114+
115+
### Global Settings and Operation Logs
116+
117+
Process-wide preferences are separate from profiles. The optional, hidden `~/.tdc/.preferences` file applies to every profile and is not created on fresh installs or by `tdc configure`. Local operation logs are enabled by default at `~/.tdc/logs/tdc.jsonl`; they contain redacted command and API summaries, not command values or user data.
118+
119+
To disable operation logging persistently, create `~/.tdc/.preferences`:
120+
121+
```toml
122+
schema_version = 1
123+
124+
[logging]
125+
enabled = false
126+
max_file_mb = 10
127+
max_files = 5
128+
```
129+
130+
Use `TDC_LOGGING=off` to disable logging for one process. Accepted values are `on`, `true`, `1`, `yes`, `off`, `false`, `0`, and `no`. An existing `[logging]` section in `~/.tdc/config` is migrated automatically to `~/.tdc/.preferences`; profiles and credentials are preserved. `tdc update` does not read or write settings, profiles, credentials, operation logs, or other `~/.tdc/` state.
114131

115132
### TiDB Cloud Filesystem
116133

‎docs/priciples.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,16 @@ Logs must never include flag values, SQL text or results, file contents, remote
242242
Disable local logging for one process with `TDC_LOGGING=off`, or globally:
243243

244244
```toml
245+
# ~/.tdc/.preferences
246+
schema_version = 1
247+
245248
[logging]
246249
enabled = false
247250
```
248251

249-
Telemetry follows the same data-minimization rule and must be explicitly disclosed after installation. It can collect command/subcommand names, flag names, error codes, duration, region, CLI version, and OS type, but never credentials or user content. Telemetry must have a documented opt-out command before collection is enabled.
252+
`~/.tdc/.preferences` is optional, hidden from ordinary directory listings, global across profiles, and separate from the profile-only `~/.tdc/config` and `~/.tdc/credentials` files. Missing settings use in-memory defaults without creating the file. Existing legacy `[logging]` configuration in `~/.tdc/config` is migrated atomically. `tdc update` does not read or write any state under `~/.tdc/`, including settings and operation logs.
253+
254+
Telemetry follows the same data-minimization rule and must be explicitly disclosed after installation. It can collect command/subcommand names, flag names, error codes, duration, region, CLI version, and OS type, but never credentials or user content. Telemetry must have documented settings-file and process-scoped environment opt-outs before collection is enabled.
250255

251256
## Security And Engineering Constraints
252257

0 commit comments

Comments
 (0)