feat(vault): vault config + vault purge (PRD §7.1)#6
Merged
Conversation
Add a persistent typed config file and the two remaining settings / maintenance verbs, then wire the config into the CLI's agent auto-spawn so a saved interval actually takes effect. CLI-only: no protocol, agent, or TUI changes — the agent still receives knobs as the launch flags it already accepted. Config: $XDG_CONFIG_HOME/vault/config.toml, modeled as a known-key registry. `vault config set <key> <value>` validates the key and parses the value to its type (typos and non-numeric values are rejected, not silently kept); `unset` clears; `get` with no key lists every known key with its effective value (--json on all three). Atomic writes (tempfile + rename, mirroring vault-store::write_atomic). Recognised keys this release: clipboard.clear_secs and agent.idle_lock_secs (both u64, 0 disables); the registry is shaped to grow into the rest of §7.1. Auto-spawn: spawn_and_connect sources those two knobs from config and appends them as agent launch flags, so config wins over the agent's env/default on this path; a manually launched agent is unaffected. A malformed config is reported and skipped rather than blocking the spawn (verified live). Purge: vault purge drops a running agent's in-memory keys (best-effort Lock via a direct, hint-free connect; never auto-spawns) and removes the on-disk item cache (vault_store::default_data_dir()). Confirmation-gated like remove (--force to skip; required when stdin isn't a TTY); an absent cache is success. New toml dependency (MIT/Apache, within deny.toml's allow-list); vault-cli gains dirs/serde/tempfile/vault-store as normal deps. Tests: config registry units (round-trips, unknown-key + bad-value rejection, 0 accepted, KNOWN_KEYS reachable by all three ops, TOML serde round-trip) and a pure agent_args test for the config→launch-flags mapping. Verified live: get/set/unset, JSON output, rejection paths, auto-spawn flag pass-through, malformed-config degradation, and purge (lock + cache removal + no-TTY refusal). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a persistent typed config file and the two remaining PRD §7.1 verbs (
config get/set/unset,purge), then wires the config into the CLI's agent auto-spawn so a saved clipboard/idle-lock interval actually takes effect. CLI-only — no protocol, agent-code, or TUI changes; the agent still receives knobs as the launch flags it already accepted.Config — known-key registry
$XDG_CONFIG_HOME/vault/config.toml.vault config set <key> <value>validates the key and parses the value to its type — a typo or non-numeric value is rejected at write time, not silently kept.unsetclears;getwith no key lists every known key + effective value.--jsonon all three.vault-store::write_atomic).clipboard.clear_secsandagent.idle_lock_secs(bothu64,0disables). The registry is structured to grow into the rest of §7.1 (clipboard.backend,set vim, …).Wired into auto-spawn
spawn_and_connectsources those two knobs from config and appends them as agent launch flags — so a savedclipboard.clear_secsfinally has a persistent home instead of being flag/env-only. On this path config wins over$VAULT_CLIPBOARD_CLEAR_SECS; a manually launched agent is unaffected. A malformed config is reported and skipped rather than blocking the spawn.Purge
vault purgedrops a running agent's in-memory keys (best-effortLockvia a direct, hint-free connect — never auto-spawns) and removes the on-disk item cache ($XDG_DATA_HOME/vault). Confirmation-gated likeremove(--forceto skip; required when stdin isn't a TTY); an absent cache is success.Dependencies
New
toml(MIT/Apache, withindeny.toml's allow-list);vault-cligainsdirs/serde/tempfile/vault-storeas normal deps.Tests
Config registry units (set/get/unset round-trips, unknown-key + bad-value rejection,
0accepted,KNOWN_KEYSreachable by all three ops, TOML serde round-trip) and a pureagent_argstest for the config→launch-flags mapping. Workspace: 123 tests green,clippy -D warningsclean,cargo denyclean, headless build green. Verified live: get/set/unset + JSON, rejection paths, auto-spawn flag pass-through (--clipboard-clear-secs 45 --idle-lock-secs 600), malformed-config degradation, and purge (agent lock + cache removal + no-TTY refusal).🤖 Generated with Claude Code