Skip to content

Keep collector credentials out of the agent context - #202

Merged
titanwings merged 1 commit into
dot-skillfrom
credentials-out-of-context
Oct 12, 2026
Merged

titanwings merged 1 commit into
dot-skillfrom
credentials-out-of-context

Conversation

@titanwings

Copy link
Copy Markdown
Owner

Requested by Tianyi · project thread

Summary

Before: the Lark/Feishu, DingTalk and Slack collectors asked for App Secrets, user_access_token and Bot Tokens through echoed input(), --user-token / --exchange-code CLI flags, and SKILL.md told the agent to collect app_id / app_secret / OAuth codes from the user in chat. Secrets ended up in the model context, shell history and transcripts.

After: credentials are read from environment variables → OS keychain (optional keyring) → ~/.distilly/*_config.json (0600). Setup and OAuth happen only in the user's own terminal with hidden input, and the agent can only see whether a credential is configured, never its value.

Changes

  • New tools/credentials.py: shared resolve / describe / require / save helpers. Env var names (FEISHU_APP_ID, FEISHU_APP_SECRET, FEISHU_USER_ACCESS_TOKEN, FEISHU_REFRESH_TOKEN, DINGTALK_APP_KEY, DINGTALK_APP_SECRET, SLACK_BOT_TOKEN) double as keychain entry names, so the Feishu collector and the Feishu MCP client share one set.
  • All four collectors (feishu_auto_collector, feishu_mcp_client, dingtalk_auto_collector, slack_auto_collector):
    • --setup uses getpass for secrets and refuses to run when stdin is not a TTY, so an agent cannot pipe secrets through it.
    • New --check: prints each field's source (env / keychain / config file / missing), never the value.
    • Config file is optional; missing credentials fail with a pointer to --setup or the env var.
  • Feishu: new --login (prints authorize URL, hidden input for the callback URL/code, saves the token directly) and --refresh (renews from stored refresh_token, no input). --user-token and --exchange-code are removed with an explanatory error; the token prefix is no longer printed; error output no longer dumps raw API responses.
  • Runtime env/keychain values are never written back to the config file (save_secrets works on the raw file dict).
  • SKILL.md (中文 + English): new credential rules block; Option A/B/C now say "run --check, ask the user to run --setup / --login in their own terminal", the private-chat command no longer passes --user-token, ad-hoc scripts must load via credentials.resolve or env vars, and a pasted secret should be rotated rather than used.
  • INSTALL.md / INSTALL_EN.md document env vars, keychain and --check; keyring added to requirements.txt as optional.

Motivation

Personal-agent tools like Dots and Muse explicitly keep credentials out of the model context; distilly's collectors did the opposite (tools/feishu_auto_collector.py:112, tools/dingtalk_auto_collector.py:85).

Testing

  • python -m unittest discover -s tests -p 'test_*.py' passed (81 tests, incl. new tests/test_credentials.py: env override, keychain path, --check never prints values, keychain save keeps secrets out of the file, refresh doesn't persist env secrets, non-TTY --setup refused, --user-token rejected without echoing the value)
  • python -m compileall tools/ passed
  • node bin/distilly.mjs --check-package passed
  • Manually tested against live Feishu/DingTalk/Slack tenants (not done: no credentials in this environment)

Checklist

  • Docs updated if behavior or usage changed (README / SKILL.md / INSTALL.md)
  • No secrets, tokens, or personal data committed
  • New dependencies added to requirements.txt (optional keyring)
  • Tests added/updated for new functionality

Breaking: --user-token and --exchange-code on feishu_auto_collector.py now exit with an error pointing to --login / FEISHU_USER_ACCESS_TOKEN. Existing ~/.distilly/*_config.json files keep working unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_017ZQBLAJV6q9FP7domp6FKf


Generated by Claude Code

Lark/Feishu, DingTalk and Slack collectors now read secrets from
environment variables, then the OS keychain (optional keyring), then the
0600 config file. --setup and the new Feishu --login use hidden input and
refuse to run without a TTY, so an agent cannot pipe secrets through
them. --check reports where each credential comes from without printing
values, and Feishu --refresh renews the user token from the stored
refresh_token. --user-token / --exchange-code are removed, and SKILL.md
no longer asks users to paste App Secrets, tokens or OAuth codes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ZQBLAJV6q9FP7domp6FKf
@titanwings titanwings self-assigned this Oct 12, 2026
@titanwings
titanwings marked this pull request as ready for review October 12, 2026 08:03
@titanwings
titanwings merged commit c978219 into dot-skill Oct 12, 2026
3 checks passed
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.

2 participants