Secrets in wiki documents
Use secret references to replace a known password or token in the current body
of a memory or knowledge card. The document retains a marker such as
{{secret:API_KEY}}, and an encrypted credential in the same vault holds the
value. Current reads, search and MCP do not expand the marker.
This feature requires an updated CLI/daemon or mobile app. Update every client before synchronizing documents with references: older clients cannot decode the new content field. See security boundaries and validation results.
Replace a secret
Start the daemon and unlock the library. Use the short vault and document IDs returned by list or search. Run sudo in the same terminal before replacement:
memories sudo
memories memory protect-secret VAULT_ID DOCUMENT_ID API_KEY
For a knowledge card, use:
memories card protect-secret VAULT_ID CARD_ID API_KEY
The CLI prompts for the exact secret without echoing it. Do not put the secret in arguments or the reference name. Replacement is case-sensitive and literal; it does not use a regular expression. All non-overlapping matches in the current body are replaced. For example, a body containing the same synthetic token twice becomes:
API_KEY={{secret:API_KEY}}
Authorization: Bearer {{secret:API_KEY}}
Success returns the document id, the new credential ID and the number of
replacements in the normal JSON response. Credential creation and document
replacement commit together; a rejected operation saves neither change.
In the mobile app, open the memory/card menu, choose Protect secret in document, confirm the history warning, enter a reference name and then the secret in the hidden field. Complete password authorization when prompted.
Reference names contain 1-64 ASCII letters, digits, underscores or hyphens and must be unused in that document. A document can hold at most 64 references. Replacement requires local sudo and vault write permission. It is rejected if:
- The secret is empty or does not occur in the current body.
- The name is invalid, already mapped, or its marker already occurs in the body.
- The secret also occurs in metadata, such as the title, tags or source, or would be left in the new marker or alter an existing reference marker.
- The document has unresolved conflicting versions, or the resulting content exceeds its size or reference limits.
Remove exposed values from metadata and resolve conflicts before retrying. Those edits also leave signed historical versions intact.
Copy a current value
Copying requires local sudo. For a document reference, supply its label even when there is only one reference. For a credential or protected card, use its own ID:
memories sudo
memories credential copy VAULT_ID DOCUMENT_ID --label API_KEY
memories credential copy VAULT_ID CREDENTIAL_ID
memories credential copy VAULT_ID PROTECTED_CARD_ID
The CLI writes to the system clipboard and prints only copy status
("copied": true). The authenticated local client receives plaintext to perform
the copy. Generic credential reads and exports remain unavailable, and MCP
cannot perform replacement or copying, including with a write grant.
In the mobile app, choose Copy secret from the document, protected card or credential menu. Select the reference name for a document, confirm the clipboard warning and complete authorization when prompted. The app shows success without displaying the value and discards late responses after backgrounding or locking.
Protected account and token cards copy their stored password or token. An env card copies its stored dotenv text. An OTP card copies its Base32 seed; use the separate OTP action to generate a current one-time code. Clipboard copying accepts UTF-8 text only and rejects credentials containing NUL bytes.
| Platform | Clipboard requirement |
|---|---|
| Windows CLI | Native Windows clipboard access |
| macOS CLI | pbcopy available in the CLI environment |
Linux CLI, with WAYLAND_DISPLAY set |
wl-copy and access to the Wayland session |
| Linux CLI, otherwise | xclip and access to the X11 clipboard |
| Mobile | The platform clipboard through Flutter |
Linux selects the helper from WAYLAND_DISPLAY; it does not automatically fall
back from wl-copy to xclip. A missing helper or inaccessible clipboard causes
the command to fail. The service records a delivery intent before sending the
value to the client, so that audit entry alone does not prove clipboard success.
Editing, synchronization and limits
The document's typed secrets map binds labels to credential IDs. Typing a marker
manually does not create a credential or grant access. Ordinary edits must retain
the existing map; the CLI and mobile editor preserve it. The current MCP
card_write tool does not carry that map, so updating a card with secret references
through it is rejected. Use the CLI or mobile editor for those cards. Removing a
marker from the body does not delete the mapping or the credential.
References resolve the current credential value. To update it, use the returned
credential ID with an authorized credential replacement command, for example
memories credential add VAULT_ID API_KEY --id CREDENTIAL_ID, which prompts for
hidden input. The document marker stays the same. This changes the stored value;
provider-side key rotation must be performed separately.
The document and credential travel with their vault during encrypted sync. Independent backup recovery preserves references for unambiguous assets; device-only vaults remain excluded from sync and backup. Deleting a referenced credential or leaving it conflicted prevents copying through that reference.
Replacement changes only the current body. Previous signed revisions, recovery archives, existing backups, other documents and shared copies can retain the original secret. Revoke or rotate already exposed keys with their issuer.
Clipboard contents can remain after locking and can be read or retained by other apps, clipboard history or OS synchronization. Clear the clipboard after use; the application does not guarantee clipboard erasure.