Skip to content

feat(publish): read HF token from ~/.config/leadforge/credentials#89

Merged
shaypal5 merged 1 commit into
mainfrom
feat/hf-credentials-fallback
May 29, 2026
Merged

feat(publish): read HF token from ~/.config/leadforge/credentials#89
shaypal5 merged 1 commit into
mainfrom
feat/hf-credentials-fallback

Conversation

@shaypal5

Copy link
Copy Markdown
Contributor

What

Adds a ~/.config/leadforge/credentials file as a fallback token source in scripts/publish_hf.py.

Token resolution order (highest priority first)

  1. --token CLI arg
  2. HF_TOKEN / HUGGING_FACE_HUB_TOKEN env var
  3. ~/.config/leadforge/credentials (new — KEY=VALUE file)
  4. huggingface_hub's own credential cache (huggingface-cli login)

Placeholder values starting with REPLACE_WITH are silently ignored so the unedited template file doesn't accidentally match.

New helpers

  • _read_token_from_credentials_file() — parses the file, skips blanks and comments
  • _resolve_token(cli_token) — runs the four-step priority chain; main() calls this once and threads token through to both _upload() and _go_public()

Context

~/.config/leadforge/credentials was created in the previous session with an HF_TOKEN=REPLACE_WITH_YOUR_HUGGINGFACE_TOKEN placeholder. The user fills in the real token once; every subsequent publish_hf.py invocation picks it up automatically without touching env vars or the keyring.

🤖 Generated with Claude Code

Add _resolve_token() and _read_token_from_credentials_file() helpers
to scripts/publish_hf.py.  Token lookup priority:

  1. --token CLI arg
  2. HF_TOKEN / HUGGING_FACE_HUB_TOKEN env var
  3. ~/.config/leadforge/credentials  (KEY=VALUE file, new fallback)
  4. huggingface_hub stored login cache

Placeholder values (lines starting with 'REPLACE_WITH') are ignored.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 29, 2026 03:16
@shaypal5 shaypal5 added type: feature New capability layer: cli cli/ command-line interface labels May 29, 2026
@shaypal5 shaypal5 merged commit c9848e8 into main May 29, 2026
10 checks passed
@shaypal5 shaypal5 deleted the feat/hf-credentials-fallback branch May 29, 2026 03:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a credentials-file fallback for the Hugging Face token used by scripts/publish_hf.py, so users can avoid setting env vars or relying on the huggingface-cli keyring.

Changes:

  • New _read_token_from_credentials_file() parses ~/.config/leadforge/credentials (KEY=VALUE), skipping blanks/comments and ignoring REPLACE_WITH* placeholders.
  • New _resolve_token() applies the priority chain: CLI arg → env var → credentials file → None.
  • main() resolves the token once and threads it through _upload() and _go_public().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

pr-agent-context report:

No unresolved review comments, failing checks, or actionable patch coverage gaps were found on PR #89 in repository https://github.com/leadforge-dev/leadforge. Treat this PR as all clear unless new signals appear.

Run metadata:

Tool ref: v4
Tool version: 4.0.21
Trigger: pull request opened
Workflow run: 26615792221 attempt 1
Comment timestamp: 2026-05-29T03:16:25.746516+00:00
PR head commit: efbc040a9066707690b062ea2b69f696cbef9b97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

layer: cli cli/ command-line interface type: feature New capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants