aristo-cli 0.2.4

Aristo CLI binary (the `aristo` command).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
//! Claude Code hook integration for `aristo install-skills` /
//! `aristo uninstall-skills`.
//!
//! `aristo install-skills --agent claude-code` writes two hook entries to
//! `<scope>/.claude/settings.json` (workspace scope by default; `--user`
//! writes to `~/.claude/settings.json`):
//!
//! 1. A `UserPromptSubmit` hook running `aristo session active
//!    --hook-format` (slice 27.5 Layer 2) — injects the active review
//!    session into every prompt so the agent can't drift while a review
//!    is open.
//! 2. A `SessionStart` hook running `aristo install-skills --hook-format`
//!    — a best-effort staleness check that, when the installed skills lag
//!    the binary, emits a SessionStart `additionalContext` block telling
//!    the agent to offer the user a refresh (`aristo install-skills
//!    --update`). Notify-only: it never rewrites skills itself.
//!
//! Both entries are identified by a marker substring of their command, so
//! install is idempotent and uninstall removes exactly our entries while
//! preserving any other hooks the user configured.

use std::path::Path;

use serde_json::{Map, Value};

use crate::{CliError, CliResult};

/// The `UserPromptSubmit` command. The trailing `|| true` is load-bearing:
/// if the user installs the hook before updating their on-PATH `aristo` to
/// a version that knows `session`, the hook would otherwise exit non-zero
/// and Claude Code would BLOCK every prompt with an "unrecognized
/// subcommand" error. The `|| true` makes the fallback exit 0, so the hook
/// silently injects nothing instead of breaking the user's workflow.
const HOOK_COMMAND: &str = "aristo session active --hook-format 2>/dev/null || true";

/// Marker substring inside [`HOOK_COMMAND`] uniquely identifying the aristo
/// session hook. Kept narrow (just the subcommand triple) so changes to
/// flags or shell wrapping don't break uninstall's matching.
const HOOK_MARKER: &str = "aristo session active --hook-format";

/// The `SessionStart` command: a best-effort skill-staleness check that
/// prints a SessionStart `additionalContext` block when installed skills
/// lag the binary. Same tolerant `2>/dev/null || true` fallback — a stale
/// or absent on-PATH aristo must never break session start.
const SESSION_START_COMMAND: &str = "aristo install-skills --hook-format 2>/dev/null || true";

/// Marker substring identifying the SessionStart staleness hook.
const SESSION_START_MARKER: &str = "aristo install-skills --hook-format";

// ─── nudge surface v2 (Phase 18 #9): the engine's hook surfaces ──────────────
// All emit via `hookSpecificOutput.additionalContext` (the only channel that
// reaches the agent — the S0a spike). Same tolerant `2>/dev/null || true`
// fallback so a stale on-PATH aristo never breaks a session. Behaviour is
// gated at runtime by `[nudges] aggressiveness` (off → silent), so these
// install unconditionally for Claude Code.

/// PostToolUse: the authoring-debt nudge (edit counter → "annotate" reminder).
const POST_TOOL_USE_COMMAND: &str = "aristo nudge --event post-tool-use 2>/dev/null || true";
const POST_TOOL_USE_MARKER: &str = "aristo nudge --event post-tool-use";

/// UserPromptSubmit: the consolidated per-turn review/verify/score nudge (the
/// Stop replacement — Stop's output never reached the agent).
const USER_PROMPT_NUDGE_COMMAND: &str =
    "aristo nudge --event user-prompt-submit 2>/dev/null || true";
const USER_PROMPT_NUDGE_MARKER: &str = "aristo nudge --event user-prompt-submit";

/// SessionStart: compute-only baseline capture (surfaces nothing itself).
const SESSION_START_NUDGE_COMMAND: &str = "aristo nudge --event session-start 2>/dev/null || true";
const SESSION_START_NUDGE_MARKER: &str = "aristo nudge --event session-start";

/// statusLine: the ambient user-facing status segment.
const STATUSLINE_COMMAND: &str = "aristo statusline 2>/dev/null || true";
const STATUSLINE_MARKER: &str = "aristo statusline";

/// Settings file path under `<root>/.claude/`.
fn settings_path(root: &Path) -> std::path::PathBuf {
    root.join(".claude").join("settings.json")
}

/// Read the existing settings.json (or an empty JSON object if missing).
/// Bubbles up parse errors so the user notices a manually-corrupted
/// settings file rather than us silently overwriting it.
fn read_settings(path: &Path) -> CliResult<Value> {
    let text = match std::fs::read_to_string(path) {
        Ok(t) => t,
        Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(Value::Object(Map::new())),
        Err(e) => return Err(e.into()),
    };
    serde_json::from_str(&text).map_err(|e| CliError::Other {
        message: format!("could not parse {}: {e}", path.display()),
        exit_code: 1,
    })
}

fn write_settings(path: &Path, value: &Value) -> CliResult<()> {
    if let Some(parent) = path.parent() {
        std::fs::create_dir_all(parent)?;
    }
    let text = serde_json::to_string_pretty(value).map_err(|e| CliError::Other {
        message: format!("settings serialize: {e}"),
        exit_code: 1,
    })?;
    std::fs::write(path, text)?;
    Ok(())
}

#[aristo::intent(
    "Installing a hook is idempotent — running install twice leaves \
     settings.json with exactly one entry for that hook's marker, not two. \
     Existing entries are found by command substring and left in place. A \
     refactor that appends unconditionally would compound on every \
     reinstall. Applies uniformly to every hook event (UserPromptSubmit, \
     SessionStart).",
    verify = "neural",
    id = "install_claude_hook_is_idempotent"
)]
fn install_hook_into(root: &Path, event: &str, marker: &str, entry: Value) -> CliResult<bool> {
    let path = settings_path(root);
    let mut value = read_settings(&path)?;
    let root_obj = ensure_object(&mut value);

    let hooks = root_obj
        .entry("hooks".to_string())
        .or_insert_with(|| Value::Object(Map::new()))
        .as_object_mut()
        .ok_or_else(|| CliError::Other {
            message: format!(
                "`hooks` key in {} is not a JSON object; refusing to overwrite",
                path.display()
            ),
            exit_code: 1,
        })?;

    let array = hooks
        .entry(event.to_string())
        .or_insert_with(|| Value::Array(Vec::new()))
        .as_array_mut()
        .ok_or_else(|| CliError::Other {
            message: format!(
                "`hooks.{event}` in {} is not a JSON array; refusing to overwrite",
                path.display()
            ),
            exit_code: 1,
        })?;

    let already_present = array.iter().any(|entry| entry_mentions_hook(entry, marker));
    if !already_present {
        array.push(entry);
    }
    write_settings(&path, &value)?;
    Ok(!already_present)
}

#[aristo::intent(
    "Uninstall removes ONLY the aristo entry matching the given marker from \
     its hook-event array; any other hooks the user configured are \
     preserved. After removal an empty array is left in place rather than \
     removed — the user may have intentional structure around the key. \
     Idempotent: uninstalling-when-not-installed is a no-op return.",
    verify = "neural",
    id = "uninstall_claude_hook_preserves_other_hooks"
)]
fn uninstall_hook_from(root: &Path, event: &str, marker: &str) -> CliResult<bool> {
    let path = settings_path(root);
    if !path.exists() {
        return Ok(false);
    }
    let mut value = read_settings(&path)?;
    let Some(root_obj) = value.as_object_mut() else {
        return Ok(false);
    };
    let Some(hooks) = root_obj.get_mut("hooks").and_then(Value::as_object_mut) else {
        return Ok(false);
    };
    let Some(arr) = hooks.get_mut(event).and_then(Value::as_array_mut) else {
        return Ok(false);
    };
    let before = arr.len();
    arr.retain(|entry| !entry_mentions_hook(entry, marker));
    let removed = arr.len() < before;
    if removed {
        write_settings(&path, &value)?;
    }
    Ok(removed)
}

/// Install the `UserPromptSubmit` review-session hook. Returns `true` if a
/// new entry was written, `false` if one was already present.
pub fn install_claude_hook(root: &Path) -> CliResult<bool> {
    install_hook_into(root, "UserPromptSubmit", HOOK_MARKER, session_hook_entry())
}

/// Install the `SessionStart` skill-staleness hook.
pub fn install_session_start_hook(root: &Path) -> CliResult<bool> {
    install_hook_into(
        root,
        "SessionStart",
        SESSION_START_MARKER,
        session_start_hook_entry(),
    )
}

/// Remove the `UserPromptSubmit` review-session hook.
pub fn uninstall_claude_hook(root: &Path) -> CliResult<bool> {
    uninstall_hook_from(root, "UserPromptSubmit", HOOK_MARKER)
}

/// Remove the `SessionStart` skill-staleness hook.
pub fn uninstall_session_start_hook(root: &Path) -> CliResult<bool> {
    uninstall_hook_from(root, "SessionStart", SESSION_START_MARKER)
}

// ─── nudge surface v2 install/uninstall ─────────────────────────────────────

/// Install all nudge-engine surfaces for Claude Code: the PostToolUse,
/// UserPromptSubmit, and SessionStart hooks plus the statusLine. Idempotent.
pub fn install_nudge_surface(root: &Path) -> CliResult<()> {
    install_hook_into(
        root,
        "PostToolUse",
        POST_TOOL_USE_MARKER,
        post_tool_use_entry(),
    )?;
    install_hook_into(
        root,
        "UserPromptSubmit",
        USER_PROMPT_NUDGE_MARKER,
        user_prompt_nudge_entry(),
    )?;
    install_hook_into(
        root,
        "SessionStart",
        SESSION_START_NUDGE_MARKER,
        session_start_nudge_entry(),
    )?;
    install_statusline(root)?;
    Ok(())
}

/// Remove all nudge-engine surfaces. Each removal preserves any non-aristo
/// hooks and only touches a statusLine that is ours.
pub fn uninstall_nudge_surface(root: &Path) -> CliResult<()> {
    uninstall_hook_from(root, "PostToolUse", POST_TOOL_USE_MARKER)?;
    uninstall_hook_from(root, "UserPromptSubmit", USER_PROMPT_NUDGE_MARKER)?;
    uninstall_hook_from(root, "SessionStart", SESSION_START_NUDGE_MARKER)?;
    uninstall_statusline(root)?;
    Ok(())
}

#[aristo::intent(
    "Installing the statusLine NEVER clobbers an existing one: settings.json's \
     `statusLine` is a single value (not an append-safe array), so a user who \
     already configured a status line keeps it — aristo only sets it when the \
     field is absent. Uninstall removes it only when it is aristo's own \
     (its command mentions the aristo statusline marker).",
    verify = "test",
    id = "statusline_install_never_clobbers_user_config"
)]
fn install_statusline(root: &Path) -> CliResult<bool> {
    let path = settings_path(root);
    let mut value = read_settings(&path)?;
    let obj = ensure_object(&mut value);
    if obj.contains_key("statusLine") {
        return Ok(false); // respect the user's existing statusLine
    }
    obj.insert(
        "statusLine".to_string(),
        serde_json::json!({ "type": "command", "command": STATUSLINE_COMMAND }),
    );
    write_settings(&path, &value)?;
    Ok(true)
}

fn uninstall_statusline(root: &Path) -> CliResult<bool> {
    let path = settings_path(root);
    if !path.exists() {
        return Ok(false);
    }
    let mut value = read_settings(&path)?;
    let Some(obj) = value.as_object_mut() else {
        return Ok(false);
    };
    let is_ours = obj
        .get("statusLine")
        .map(|v| entry_mentions_hook(v, STATUSLINE_MARKER))
        .unwrap_or(false);
    if is_ours {
        obj.remove("statusLine");
        write_settings(&path, &value)?;
        return Ok(true);
    }
    Ok(false)
}

/// `PostToolUse` entry: matched to the edit-like tools (the nudge emitter
/// also re-checks the tool name from stdin).
fn post_tool_use_entry() -> Value {
    serde_json::json!({
        "matcher": "Edit|Write|MultiEdit|NotebookEdit",
        "hooks": [ { "type": "command", "command": POST_TOOL_USE_COMMAND } ]
    })
}

fn user_prompt_nudge_entry() -> Value {
    serde_json::json!({
        "matcher": ".*",
        "hooks": [ { "type": "command", "command": USER_PROMPT_NUDGE_COMMAND } ]
    })
}

fn session_start_nudge_entry() -> Value {
    serde_json::json!({
        "hooks": [ { "type": "command", "command": SESSION_START_NUDGE_COMMAND } ]
    })
}

fn ensure_object(value: &mut Value) -> &mut Map<String, Value> {
    if !value.is_object() {
        *value = Value::Object(Map::new());
    }
    value.as_object_mut().expect("just set to object")
}

/// `UserPromptSubmit` entry shape: `{matcher, hooks: [{type, command}]}`.
fn session_hook_entry() -> Value {
    serde_json::json!({
        "matcher": ".*",
        "hooks": [ { "type": "command", "command": HOOK_COMMAND } ]
    })
}

/// `SessionStart` entry shape: `{hooks: [{type, command}]}` (no matcher —
/// SessionStart fires once per session, not per tool/prompt).
fn session_start_hook_entry() -> Value {
    serde_json::json!({
        "hooks": [ { "type": "command", "command": SESSION_START_COMMAND } ]
    })
}

/// True if the given hook entry contains a sub-hook whose command mentions
/// our marker. Tolerant of both flat (`command` at top level) and nested
/// (`hooks: [{command}]`) shapes so Claude Code schema changes don't
/// silently leave stale entries behind.
fn entry_mentions_hook(entry: &Value, marker: &str) -> bool {
    fn has(entry: &Value, marker: &str) -> bool {
        if let Some(s) = entry.get("command").and_then(Value::as_str) {
            if s.contains(marker) {
                return true;
            }
        }
        if let Some(arr) = entry.get("hooks").and_then(Value::as_array) {
            return arr.iter().any(|e| has(e, marker));
        }
        false
    }
    has(entry, marker)
}

#[cfg(test)]
mod tests {
    use super::*;
    use tempfile::TempDir;

    #[test]
    fn install_creates_settings_when_missing() {
        let tmp = TempDir::new().unwrap();
        let inserted = install_claude_hook(tmp.path()).unwrap();
        assert!(inserted);
        let body = std::fs::read_to_string(settings_path(tmp.path())).unwrap();
        assert!(body.contains(HOOK_COMMAND), "body: {body}");
    }

    #[test]
    fn both_hook_commands_use_tolerant_shell_fallback() {
        // Regression guard: both hooks MUST exit 0 even when aristo is
        // missing or doesn't recognize the subcommand — otherwise installing
        // a hook before updating PATH-resident aristo would break sessions.
        for cmd in [HOOK_COMMAND, SESSION_START_COMMAND] {
            assert!(cmd.contains("|| true"), "`{cmd}` must fall back gracefully");
            assert!(cmd.contains("2>/dev/null"), "`{cmd}` must suppress stderr");
        }
        assert!(HOOK_COMMAND.contains(HOOK_MARKER));
        assert!(SESSION_START_COMMAND.contains(SESSION_START_MARKER));
    }

    #[test]
    fn install_twice_remains_idempotent() {
        let tmp = TempDir::new().unwrap();
        assert!(install_claude_hook(tmp.path()).unwrap());
        assert!(
            !install_claude_hook(tmp.path()).unwrap(),
            "second install should be a no-op"
        );
        let body = std::fs::read_to_string(settings_path(tmp.path())).unwrap();
        assert_eq!(body.matches(HOOK_COMMAND).count(), 1);
    }

    #[test]
    fn session_start_hook_installs_idempotently_under_its_own_event() {
        let tmp = TempDir::new().unwrap();
        assert!(install_session_start_hook(tmp.path()).unwrap());
        assert!(!install_session_start_hook(tmp.path()).unwrap());
        let body = std::fs::read_to_string(settings_path(tmp.path())).unwrap();
        assert!(body.contains("SessionStart"));
        assert_eq!(body.matches(SESSION_START_COMMAND).count(), 1);
    }

    #[test]
    fn both_hooks_coexist_in_one_settings_file() {
        let tmp = TempDir::new().unwrap();
        install_claude_hook(tmp.path()).unwrap();
        install_session_start_hook(tmp.path()).unwrap();
        let body = std::fs::read_to_string(settings_path(tmp.path())).unwrap();
        assert!(body.contains("UserPromptSubmit"));
        assert!(body.contains("SessionStart"));
        assert!(body.contains(HOOK_MARKER));
        assert!(body.contains(SESSION_START_MARKER));
    }

    #[test]
    fn install_preserves_other_existing_hooks() {
        let tmp = TempDir::new().unwrap();
        let settings = settings_path(tmp.path());
        std::fs::create_dir_all(settings.parent().unwrap()).unwrap();
        std::fs::write(
            &settings,
            r#"{ "hooks": { "UserPromptSubmit": [{ "matcher": ".*", "hooks": [{"type":"command","command":"someone_elses_tool --hook"}] }] } }"#,
        )
        .unwrap();
        install_claude_hook(tmp.path()).unwrap();
        let body = std::fs::read_to_string(&settings).unwrap();
        assert!(body.contains("someone_elses_tool"));
        assert!(body.contains(HOOK_COMMAND));
    }

    #[test]
    fn uninstall_removes_only_aristo_entry() {
        let tmp = TempDir::new().unwrap();
        let settings = settings_path(tmp.path());
        std::fs::create_dir_all(settings.parent().unwrap()).unwrap();
        std::fs::write(
            &settings,
            r#"{ "hooks": { "UserPromptSubmit": [{ "matcher": ".*", "hooks": [{"type":"command","command":"someone_elses_tool --hook"}] }] } }"#,
        )
        .unwrap();
        install_claude_hook(tmp.path()).unwrap();
        assert!(uninstall_claude_hook(tmp.path()).unwrap());
        let body = std::fs::read_to_string(&settings).unwrap();
        assert!(!body.contains(HOOK_COMMAND));
        assert!(body.contains("someone_elses_tool"));
    }

    #[test]
    fn uninstall_session_start_removes_only_its_entry() {
        let tmp = TempDir::new().unwrap();
        install_claude_hook(tmp.path()).unwrap();
        install_session_start_hook(tmp.path()).unwrap();
        assert!(uninstall_session_start_hook(tmp.path()).unwrap());
        let body = std::fs::read_to_string(settings_path(tmp.path())).unwrap();
        // SessionStart entry gone; UserPromptSubmit one preserved.
        assert!(!body.contains(SESSION_START_COMMAND));
        assert!(body.contains(HOOK_COMMAND));
    }

    #[test]
    fn uninstall_when_not_installed_is_no_op() {
        let tmp = TempDir::new().unwrap();
        assert!(!uninstall_claude_hook(tmp.path()).unwrap());
        assert!(!uninstall_session_start_hook(tmp.path()).unwrap());
    }

    #[test]
    fn install_then_uninstall_idempotent_on_repeat() {
        let tmp = TempDir::new().unwrap();
        install_claude_hook(tmp.path()).unwrap();
        assert!(uninstall_claude_hook(tmp.path()).unwrap());
        assert!(!uninstall_claude_hook(tmp.path()).unwrap());
    }

    #[test]
    fn nudge_surface_installs_all_three_hooks_plus_statusline() {
        let tmp = TempDir::new().unwrap();
        install_nudge_surface(tmp.path()).unwrap();
        let body = std::fs::read_to_string(settings_path(tmp.path())).unwrap();
        assert!(body.contains(POST_TOOL_USE_MARKER));
        assert!(body.contains(USER_PROMPT_NUDGE_MARKER));
        assert!(body.contains(SESSION_START_NUDGE_MARKER));
        assert!(body.contains(STATUSLINE_MARKER));
        // Stop is intentionally NOT installed (its output never reaches the agent).
        assert!(!body.contains("--event stop"));
        assert!(!body.contains("\"Stop\""));
    }

    #[test]
    fn nudge_surface_install_is_idempotent() {
        let tmp = TempDir::new().unwrap();
        install_nudge_surface(tmp.path()).unwrap();
        install_nudge_surface(tmp.path()).unwrap();
        let body = std::fs::read_to_string(settings_path(tmp.path())).unwrap();
        assert_eq!(body.matches(POST_TOOL_USE_COMMAND).count(), 1);
        assert_eq!(body.matches(USER_PROMPT_NUDGE_COMMAND).count(), 1);
        assert_eq!(body.matches(STATUSLINE_COMMAND).count(), 1);
    }

    #[test]
    fn nudge_surface_coexists_with_the_session_and_staleness_hooks() {
        let tmp = TempDir::new().unwrap();
        install_claude_hook(tmp.path()).unwrap(); // session-active (UserPromptSubmit)
        install_session_start_hook(tmp.path()).unwrap(); // staleness (SessionStart)
        install_nudge_surface(tmp.path()).unwrap();
        let body = std::fs::read_to_string(settings_path(tmp.path())).unwrap();
        // Both the pre-existing aristo hooks and the new nudge hooks are present.
        assert!(body.contains(HOOK_MARKER)); // session active
        assert!(body.contains(SESSION_START_MARKER)); // staleness
        assert!(body.contains(USER_PROMPT_NUDGE_MARKER));
        assert!(body.contains(SESSION_START_NUDGE_MARKER));
    }

    #[test]
    fn statusline_install_does_not_clobber_an_existing_one() {
        let tmp = TempDir::new().unwrap();
        let settings = settings_path(tmp.path());
        std::fs::create_dir_all(settings.parent().unwrap()).unwrap();
        std::fs::write(
            &settings,
            r#"{ "statusLine": { "type": "command", "command": "my_custom_bar" } }"#,
        )
        .unwrap();
        assert!(
            !install_statusline(tmp.path()).unwrap(),
            "must not overwrite a user statusLine"
        );
        let body = std::fs::read_to_string(&settings).unwrap();
        assert!(body.contains("my_custom_bar"));
        assert!(!body.contains(STATUSLINE_COMMAND));
        // …and uninstall leaves the user's statusLine alone (not ours).
        assert!(!uninstall_statusline(tmp.path()).unwrap());
        assert!(std::fs::read_to_string(&settings)
            .unwrap()
            .contains("my_custom_bar"));
    }

    #[test]
    fn nudge_surface_uninstall_removes_only_aristo_entries() {
        let tmp = TempDir::new().unwrap();
        install_nudge_surface(tmp.path()).unwrap();
        uninstall_nudge_surface(tmp.path()).unwrap();
        let body = std::fs::read_to_string(settings_path(tmp.path())).unwrap();
        assert!(!body.contains(POST_TOOL_USE_MARKER));
        assert!(!body.contains(USER_PROMPT_NUDGE_MARKER));
        assert!(!body.contains(STATUSLINE_COMMAND));
    }
}