Skip to content

Commit 39a8403

Browse files
Merge pull request #6 from Spacecraft-Software/config-purge
feat(vault): vault config + vault purge (PRD §7.1)
2 parents d0ad250 + f1ca11a commit 39a8403

8 files changed

Lines changed: 600 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,35 @@ range may break in any release.
1010

1111
### Added
1212

13+
- **`vault config` + `vault purge` (PRD §7.1).** A persistent, typed config
14+
file and the two remaining settings/maintenance verbs.
15+
- **Config file** at `$XDG_CONFIG_HOME/vault/config.toml`, modeled as a
16+
*known-key registry*: `vault config set <key> <value>` validates the key
17+
and parses the value to its type (a typo or non-numeric value is rejected,
18+
not silently kept), `vault config unset <key>` clears it, and
19+
`vault config get` with no key lists every known key with its effective
20+
value (`--json` on all three). Writes are atomic (tempfile + rename).
21+
Recognised keys this release: `clipboard.clear_secs` and
22+
`agent.idle_lock_secs` (both `u64`, `0` disables).
23+
- **Wired into auto-spawn.** When the CLI starts the agent, it sources those
24+
two knobs from the config and passes them as launch flags — so a saved
25+
`clipboard.clear_secs` finally has a persistent home instead of being
26+
flag/env-only. On the auto-spawn path the config value populates the agent
27+
flag (winning over `$VAULT_CLIPBOARD_CLEAR_SECS`); a manually launched
28+
agent is unaffected, and a malformed config is reported and skipped rather
29+
than blocking the spawn.
30+
- **`vault purge`** drops a running agent's in-memory keys (best-effort
31+
`Lock`, never auto-spawning) and removes the on-disk item cache
32+
(`$XDG_DATA_HOME/vault`). Confirmation-gated like `remove` (`--force` to
33+
skip; required when stdin isn't a TTY); an absent cache is success.
34+
- CLI-only slice — no protocol, agent, or TUI changes; the agent still
35+
receives knobs as the launch flags it already accepted. New `toml`
36+
dependency (MIT/Apache, within the `deny.toml` allow-list).
37+
- Tests: config registry units (set/get/unset round-trips, unknown-key and
38+
bad-value rejection, `0` accepted, `KNOWN_KEYS` reachable by all three
39+
ops, TOML serde round-trip) and a pure `agent_args` test for the
40+
config→launch-flags mapping (both set / one set / none).
41+
1342
- **Clipboard hardening — clear-on-lock sweep, backend trait, OSC52 fallback,
1443
configurable interval.** Closes the secret-can-outlive-the-agent limitation
1544
tracked since the M5 copy slice, and delivers PRD §7.5 in its

Cargo.lock

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ thiserror = "2"
4747
clap = { version = "4", features = ["derive", "wrap_help"] }
4848
serde = { version = "1", features = ["derive"] }
4949
serde_json = "1"
50+
toml = "0.8"
5051
tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "io-util", "signal", "sync", "time", "fs"] }
5152
tokio-test = "0.4"
5253
zeroize = { version = "1", features = ["zeroize_derive"] }

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ sibling of the `vault` binary, then `$PATH` (override with
4444
`$VAULT_AGENT_BIN`; opt out per-call with `--no-auto-spawn`). A spawned
4545
agent logs to `agent.log` beside the socket.
4646

47+
## Configuration
48+
49+
Persistent settings live at `$XDG_CONFIG_HOME/vault/config.toml`, managed with
50+
`vault config`:
51+
52+
```sh
53+
vault config get # list every known key + value
54+
vault config set clipboard.clear_secs 45 # validated; writes config.toml
55+
vault config set agent.idle_lock_secs 600
56+
vault config unset clipboard.clear_secs
57+
```
58+
59+
Recognised keys: `clipboard.clear_secs` (auto-clear window, `0` disables) and
60+
`agent.idle_lock_secs` (idle-lock timeout, `0` disables). When the CLI
61+
auto-starts the agent, these populate its launch flags. Wipe the on-disk item
62+
cache (and drop a running agent's keys) with `vault purge`.
63+
4764
## Repository layout
4865

4966
```

crates/vault-cli/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ workspace = true
2828
default = ["cli"]
2929
cli = []
3030

31-
[dev-dependencies]
32-
tempfile = { workspace = true }
33-
3431
[dependencies]
3532
anyhow = { workspace = true }
3633
clap = { workspace = true }
34+
dirs = { workspace = true }
35+
serde = { workspace = true }
3736
serde_json = { workspace = true }
37+
tempfile = { workspace = true }
3838
tokio = { workspace = true }
39+
toml = { workspace = true }
3940
zeroize = { workspace = true }
4041
vault-core = { path = "../vault-core" }
4142
vault-ipc = { path = "../vault-ipc" }
43+
vault-store = { path = "../vault-store" }

0 commit comments

Comments
 (0)