# Try jdx/jouet: a checked edit that refuses stale input

**Agent Signal lab — 3 November 2026 · 10–15 minutes**

**Tested status: DOCUMENTATION REVIEW ONLY.** The following commands are an optional reader exercise. They were not run by the publication process. Expected results are predictions from official maintainer examples, not recorded measurements.

## What you will learn
A coding agent often replaces text by writing a temporary Python script. [jouet](https://github.com/jdx/jouet), an MIT-licensed CLI, exposes exact-match, check-before-writing edit commands. This lab tests a small concrete property: the same stale replacement cannot silently alter a file once the original text is gone. It does not test an AI model.

The initial **30 October v0.0.1** release only supported help and version. Later functionality is documented for **v0.0.3, published 2 November 2026**. jouet is pre-1.0 and its syntax may change. Read the [v0.0.3 release](https://github.com/jdx/jouet/releases/tag/v0.0.3), [edit reference](https://github.com/jdx/jouet/blob/main/docs/commands/edit.md), and [license](https://github.com/jdx/jouet/blob/main/LICENSE) before attempting it.

## Requirements and costs
- Shell terminal, a disposable directory, internet, and Rust/Cargo if installing from crates.io.
- **No model key, cloud agent service, GPU or paid API.** Building the CLI may take CPU/disk and network. No purchased or paid service is needed. There is no reason to use a work account or privileged repository.
- Install a pinned version, only after reviewing the publisher and command's local file permissions. Avoid a curl-to-shell installer.

## Steps
Install the optional command from the published crate:

```sh
cargo install jouet --locked --version 0.0.3
jouet --version
```

Create a disposable working directory and fixture:

```sh
mkdir -p /tmp/agent-signal-jouet-2026-11-03
cd /tmp/agent-signal-jouet-2026-11-03
printf 'flag=off\n' > demo.txt
cat demo.txt
```

Preview the one replacement without changing the file:

```sh
jouet edit replace demo.txt --old 'flag=off' --new 'flag=on' --dry-run
cat demo.txt
```

Now perform only that checked replacement:

```sh
jouet edit replace demo.txt --old 'flag=off' --new 'flag=on'
cat demo.txt
```

Finally, try the **stale** replacement again. A nonzero exit on the second call is expected and is the desired safeguard:

```sh
jouet edit replace demo.txt --old 'flag=off' --new 'flag=other'
cat demo.txt
test "$(cat demo.txt)" = "flag=on" && echo 'PASS: stale request did not change file'
```

## Expected output (not measured)
The dry-run previews a **single** edit while `demo.txt` still reads `flag=off`. The first actual write reports one file updated and the file becomes `flag=on`. The stale retry reports a failed exact-match check, **does not write**, and the final test prints `PASS: stale request did not change file`. Actual formatting, exit codes, and error wording may depend on the installed CLI version.

## Scoring (0–5)
Give one point each for: (1) the CLI reports the pinned version; (2) preview leaves the original untouched; (3) a single intended match is applied; (4) stale second call is refused; (5) the content still equals `flag=on` after the refusal. Record command output and exit codes rather than inferring them.

## Troubleshooting and limitations
- `cargo: command not found`: install Rust/Cargo from the official Rust project, or skip this exercise. No cost upgrade needed.
- Version unavailable: check the canonical releases and registry; do not silently use a newer unstable version.
- `jouet: command not found` after installation: inspect Cargo's bin directory on your PATH.
- The preview changes the file: stop, preserve the exact output and check the version's docs before going further.
- A stale retry unexpectedly succeeds: stop and inspect the file; do not use the tool on real repositories without understanding the difference.
- File permissions or shell quoting prevent matching: compare byte-for-byte text and ensure you work only in your scratch folder.

**Not tested here:** Cargo installation, CLI output, any model, agent, CI workflow, paid API, benchmarks or real repository edits. This local demonstration checks one safeguard only; it cannot establish broad reliability or developer productivity savings.
