v1.0.1
prompt-scrub v1.0.1
What's changed
Refactor to a stateless API and hardening for TUI/agent consumers (e.g. nanocoder). Highlights:
- Stateless map-passing API —
scrub()andrehydrate()now accept an optionalsessionMap, andscrub()returns the placeholder→value map. Callers can drive the whole scrub/rehydrate lifecycle from an in-memory map with no hidden global disk state and no session-id lifecycle. The existing session-id/on-disk mode still works. The providedsessionMapis mutated in place (and returned asresult.sessionMap, the same reference), so callers may rely on either. - New placeholder format — placeholders are now delimited as
«Email_1»instead ofEmail_1, to avoid collisions with genuine code identifiers a model might emit and to survive model reproduction more reliably. Note: session maps written by 1.0.0 (bareEmail_1) will not rehydrate against 1.0.1-scrubbed content; callers using the stateless map API are unaffected. - No more library logging — removed all
console.warn/console.errorfrom session storage and rule-pack loading. A library writing to stdout/stderr corrupts Ink/TUI rendering in consumers; failures are now handled silently (best-effort) or surfaced via return values. - Removed
cwd-based config —loadConfig()no longer readsprocess.cwd()/package.jsonfor aprompt-scrubkey. Reading config from an arbitrary working directory was surprising and risky; global config (PROMPT_SCRUB_CONFIG_DIR) is unchanged. - Faster placeholder reuse — reverse (value→placeholder) lookup is now O(1) instead of a linear scan per finding.
- Packaging — added a
preparescript sofile:/git installs always build a freshdist(prevents consumers from linking a stale build). - Tests — session-storage tests are now hermetic on every platform (use
PROMPT_SCRUB_CONFIG_DIRrather thanXDG_CONFIG_HOME, which only isolates on Linux), so they no longer read or write the user's real config directory.
Installation
npm install -g @nanocollective/prompt-scrubCLI usage
# Inspect a prompt before sending (recommended first step)
echo "My email is alice@example.com" | prompt-scrub inspect
# Scrub a prompt
echo "My email is alice@example.com" | prompt-scrub scrub
# Rehydrate a response
echo "Contact Email_1 for details." | prompt-scrub rehydrate --session-id <id>Library usage
import { scrub, rehydrate } from "@nanocollective/prompt-scrub";
const { scrubbedContent, sessionId } = scrub({ content: prompt });
// send scrubbedContent to LLM...
const { content } = rehydrate({ content: response, sessionId });