Skip to content

ktms CLI: a named context wins over the environment - #109

Merged
coyl merged 1 commit into
mainfrom
fix/ktms-cli-contexts
Oct 24, 2026
Merged

coyl merged 1 commit into
mainfrom
fix/ktms-cli-contexts

Conversation

@coyl

@coyl coyl commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #108, from the review of the same code in light-tokenmeter (ai-process/light-tokenmeter#23):

  • A context named with --context or KTMS_CONTEXT wins over KTMS_ADDR, KTMS_TLS, KTMS_HTTP, KTMS_ADMIN_KEY and KTMS_API_KEY, so its keys never go to an address left in the shell (and the shell's key never goes to its address). Flags still win.
  • writePrivate goes through os.CreateTemp + Chmod 0600 + rename: a leftover or planted .tmp file can no longer set the mode.
  • security -i exits 0 when its command fails (checked), so a keychain write is read back.
  • KTMS_TLS is parsed with strconv.ParseBool; anything else is a usage error instead of silent plaintext.
  • Docs (#140) follow in docs.

A context named with --context or KTMS_CONTEXT no longer mixes with
KTMS_ADDR or KTMS_ADMIN_KEY from the shell. Private files are written
through a fresh temporary file, keychain writes are read back since
security -i exits 0 on failure, and KTMS_TLS must be a boolean.
@github-actions

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedOct 24, 2026, 12:27 AM

@coyl
coyl merged commit 80551a2 into main Oct 24, 2026
10 checks passed
@coyl
coyl deleted the fix/ktms-cli-contexts branch October 24, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant