Planck.Headless.Secrets.EnvFile (Planck.Headless v0.1.10)

Copy Markdown View Source

Default Planck.Agent.Secrets implementation that reads and writes API keys and service rules to .planck/.env and ~/.planck/.env.

Credentials are stored as KEY=value lines. Service rules are stored as # planck-service: comment lines, which standard .env parsers (including Skogsra's EnvBinding) ignore:

N8N_API_KEY=secret
# planck-service: api.n8n.com bearer N8N_API_KEY
# planck-service: api.custom.com api-key x-api-key CUSTOM_KEY

Both credential writes and service rule writes preserve the other section, so the two types of data coexist safely in the same file.

Summary

Functions

Write a key=value pair to the given .env file path.

Functions

write_to(path, key, value)

@spec write_to(Path.t(), String.t(), String.t()) :: :ok | {:error, term()}

Write a key=value pair to the given .env file path.

Creates the file and its parent directories if they don't exist. Updates the line in-place if the key already exists. Preserves any existing # planck-service: comment lines.