Skip to content

Add bin/fill-keys.nu — fill API-key placeholders into a gitignored dist/#4

Merged
UnbreakableMJ merged 2 commits into
mainfrom
add-fill-keys-script
Jun 16, 2026
Merged

Add bin/fill-keys.nu — fill API-key placeholders into a gitignored dist/#4
UnbreakableMJ merged 2 commits into
mainfrom
add-fill-keys-script

Conversation

@UnbreakableMJ

Copy link
Copy Markdown
Collaborator

A small Nushell tool that takes your API keys once and writes ready-to-use,
key-filled copies of the host configs — without ever touching the tracked templates.

What it does

Substitutes the four template placeholders with real values:

Env var Fills Server
CONTEXT7_API_KEY YOUR_CONTEXT7_API_KEY context7
BRAVE_API_KEY YOUR_BRAVE_API_KEY brave-search
GITHUB_PAT YOUR_GITHUB_PAT github
WORKSPACE_PATH /path/to/your/workspace filesystem

Values come from env vars; any unset ones are prompted for (hidden input) when
interactive
, or left as placeholders when not (CI/agent-safe — never hangs).
Filled copies are written to a gitignored dist/ mirror; the tracked templates are
never modified, so no secret is committed. The script prints each file's intended
install destination.

CONTEXT7_API_KEY=ctx7sk-... BRAVE_API_KEY=... nu bin/fill-keys.nu
nu bin/fill-keys.nu --help

Notes

  • VS Code is left alone — it has no literal tokens (uses ${input:} + ${workspaceFolder}); copied verbatim. The Markdown docs are excluded too.
  • Partial fills keep the placeholder for any omitted key, so that server stays inert rather than getting a broken empty value.
  • Adds .gitignore (/dist/), a README "Filling in your keys" section, and a CLAUDE.md tooling note.
  • Compliance: Nushell-native (no bashisms), two-tag SPDX header → reuse lint clean (script is GPL-3.0-or-later); the lone executable (755). CI validator is unaffected (skips .nu; dist/ is ignored).

Verified locally: full fill (4/4), partial fill (only context7), no-vars non-interactive (0/4, exit 0, no prompt hang), dist/ parses via the existing validator, sentinels gone from dist/ but retained in templates.

🤖 Generated with Claude Code

UnbreakableMJ and others added 2 commits June 16, 2026 19:20
Nushell script that substitutes the four template placeholders
(YOUR_CONTEXT7_API_KEY, YOUR_BRAVE_API_KEY, YOUR_GITHUB_PAT,
/path/to/your/workspace) with values from env vars — prompting (hidden
input) for any unset ones when interactive, leaving them as placeholders
when not (CI/agent-safe). Filled copies are written to a gitignored dist/
mirror; the tracked templates are never modified, so no secret is committed.

VS Code (uses ${input:}/${workspaceFolder}) and the docs are excluded from
substitution. Adds .gitignore (/dist/), a README "Filling in your keys"
section, and a CLAUDE.md tooling note. reuse lint clean (script is GPL,
two-tag SPDX header); CI validator unaffected (skips .nu, dist/ ignored).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
bin/fill-keys.sh (POSIX sh — Bash/Brush/dash/ash) and bin/fill-keys.ion (Ion)
mirror bin/fill-keys.nu exactly: same four placeholders → env vars, hidden-input
prompt fallback, gitignored dist/ mirror, partial-fill and non-interactive/agent
safety. The shell ports use `sd -s` (literal) for substitution; the Nushell port
uses native string ops.

Notable shell quirks handled: Ion's `test -t` is unreliable (uses `tty -s`),
Ion eats -h/--help, and Ion's `test` needs the POSIX x-prefix guard for
--leading operands; POSIX prompts read from /dev/tty so the here-doc data on
stdin isn't consumed. README + CLAUDE.md updated; both scripts carry SPDX
headers (reuse lint clean, 23/23).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@UnbreakableMJ
UnbreakableMJ merged commit d5de413 into main Jun 16, 2026
1 check passed
@UnbreakableMJ
UnbreakableMJ deleted the add-fill-keys-script branch June 16, 2026 16:43
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