Documentation
¶
Overview ¶
Package store manages scratchpad file persistence including encryption and path resolution.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureGitignore ¶
EnsureGitignore adds an entry to .gitignore if not already present.
Parameters:
- contextDir: The .context directory path
- filename: The file to add (joined with contextDir)
Returns:
- error: Non-nil on read/write failure
func EnsureKey ¶
EnsureKey generates a scratchpad key when none exists.
If an encrypted scratchpad already exists without a key, returns an error (a new key would not decrypt the existing data). On first use this lets `ctx pad add` work without requiring `ctx init`.
Parameters:
- cmd: Cobra command for diagnostic output
Returns:
- error: Non-nil on missing key with existing data, or generation failure
func KeyPath ¶
func KeyPath() string
KeyPath returns the full path to the encryption key file.
Triggers legacy key migration on each call, then resolves the effective path via rc.KeyPath().
Returns:
- string: Resolved key file path
func ReadEntries ¶
ReadEntries reads the scratchpad and returns its entries.
If the scratchpad file does not exist, it returns an empty slice (no error). If the encrypted file exists but the key is missing, it returns an error.
Returns:
- []string: The scratchpad entries (may be empty)
- error: Non-nil on key or decryption errors
func ScratchpadPath ¶
func ScratchpadPath() string
ScratchpadPath returns the full path to the scratchpad file.
Returns:
- string: Encrypted or plaintext path based on rc.ScratchpadEncrypt()
func WriteEntries ¶
WriteEntries writes entries to the scratchpad file.
In encrypted mode, the entries are encrypted with AES-256-GCM before writing. In plaintext mode, they are written as a newline-delimited file.
Parameters:
- cmd: Cobra command for diagnostic output
- entries: The scratchpad entries to write
Returns:
- error: Non-nil on key, encryption, or file write errors
Types ¶
This section is empty.