Skip to content

Commit 374d54f

Browse files
committed
docs: expand with-watch documentation
1 parent ea48fc5 commit 374d54f

File tree

10 files changed

+164
-3
lines changed

10 files changed

+164
-3
lines changed

apps/public-docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ pnpm --filter public-docs test
2323
- `nodeup.mdx`: Public project guide for `nodeup`.
2424
- `cargo-mono.mdx`: Public project guide for `cargo-mono`.
2525
- `derun.mdx`: Public project guide for `derun`.
26+
- `with-watch.mdx`: Public project guide for `with-watch`.

apps/public-docs/docs.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@
4646
}
4747
]
4848
},
49+
{
50+
"tab": "With Watch",
51+
"groups": [
52+
{
53+
"group": "Command Rerun Watcher",
54+
"pages": ["with-watch"]
55+
}
56+
]
57+
},
4958
{
5059
"tab": "DexDex",
5160
"groups": [

apps/public-docs/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This site provides a curated, user-facing layer of documentation that complement
99
- Read [Getting Started](getting-started) for local setup and editing workflow.
1010
- See [Projects Overview](projects-overview) for the current public project catalog.
1111
- Review [Documentation Lifecycle](documentation-lifecycle) for update rules between `docs/` and `apps/public-docs`.
12-
- Open [Nodeup](nodeup), [Cargo Mono](cargo-mono), and [Derun](derun) from the top navigation for dedicated project guides.
12+
- Open [Nodeup](nodeup), [Cargo Mono](cargo-mono), [Derun](derun), and [With Watch](with-watch) from the top navigation for dedicated project guides.
1313

1414
## Scope
1515

apps/public-docs/projects-overview.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This page provides a high-level public catalog of projects in the Delino OSS mon
77
- [`cargo-mono`](cargo-mono): Cargo subcommand tooling for Rust monorepo workflows.
88
- [`nodeup`](nodeup): Rust-based Node.js runtime manager.
99
- [`derun`](derun): Terminal-fidelity run execution and MCP bridge tool.
10+
- [`with-watch`](with-watch): Command rerun watcher for inferred or explicit filesystem inputs.
1011
- [`dexdex`](dexdex): Connect RPC-first desktop + server orchestration platform.
1112
- `mpapp`: Expo React Native mobile app.
1213
- `devkit`: Next.js micro-app host platform.

apps/public-docs/with-watch.mdx

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# with-watch
2+
3+
`with-watch` is a Rust-based command rerun watcher that repeats a delegated command when its inferred or explicit filesystem inputs change.
4+
5+
## Why use with-watch
6+
7+
- Keep familiar CLI tools such as `cat`, `cp`, `sed`, and `find`.
8+
- Let `with-watch` infer watched inputs for common file-oriented commands.
9+
- Declare explicit inputs with `exec --input` when you want fully predictable reruns.
10+
11+
## Install
12+
13+
Tag contract:
14+
15+
- `with-watch@v<semver>`
16+
17+
Package manager:
18+
19+
- macOS/Linux: `brew install delinoio/tap/with-watch`
20+
21+
Cargo:
22+
23+
```bash
24+
cargo install with-watch
25+
```
26+
27+
## Quick start
28+
29+
Rerun a file reader when its input changes:
30+
31+
```bash
32+
with-watch cat input.txt
33+
```
34+
35+
Watch the current directory with a safe pathless default:
36+
37+
```bash
38+
with-watch ls -l
39+
```
40+
41+
Run a simple shell expression:
42+
43+
```bash
44+
with-watch --shell 'cat input.txt | grep hello'
45+
```
46+
47+
Provide explicit inputs for an arbitrary command:
48+
49+
```bash
50+
with-watch exec --input 'src/**/*.rs' -- cargo test -p with-watch
51+
```
52+
53+
## Input inference model
54+
55+
- Passthrough mode and `--shell` use built-in command adapters first.
56+
- Known outputs, inline scripts, and output redirects are filtered out of the watch set.
57+
- Safe pathless defaults are intentionally narrow: `ls`, `dir`, `vdir`, `du`, and `find`.
58+
- If `with-watch` cannot infer safe filesystem inputs, it fails instead of guessing.
59+
60+
## When exec --input is required
61+
62+
Some commands do not expose meaningful filesystem inputs on their own. For example, `echo hello` has nothing safe to watch.
63+
64+
In those cases, use `exec --input` to declare the watch set explicitly:
65+
66+
```bash
67+
with-watch exec --input 'src/**/*.rs' -- cargo test -p with-watch
68+
```
69+
70+
`with-watch` reruns the delegated command unchanged. It does not inject changed file paths into argv or environment variables.
71+
72+
## Shell support boundaries
73+
74+
- `--shell` supports command-line expressions with `&&`, `||`, and `|`.
75+
- Input redirects (`<`, `<>`) become watched inputs.
76+
- Output redirects (`>`, `>>`, `&>`, `&>>`, `>|`) are treated as outputs and filtered from watching.
77+
- Full shell control-flow is out of scope for v1.
78+
79+
## Rerun behavior
80+
81+
- Default rerun filtering uses content hashes.
82+
- `--no-hash` switches to metadata-only comparison.
83+
- Self-mutating commands such as `sed -i.bak -e 's/old/new/' config.txt` refresh their baseline after each run so they do not loop on their own writes.
84+
- Replace-style writers remain watchable because path inputs subscribe from the nearest existing directory anchor.
85+
86+
## Related pages
87+
88+
- [Projects Overview](projects-overview)
89+
- [Documentation Lifecycle](documentation-lifecycle)

crates/with-watch/README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,31 @@
22

33
`with-watch` reruns a delegated command when its inferred or explicit filesystem inputs change.
44

5+
## Why use
6+
7+
- Keep familiar POSIX/coreutils-style commands while adding automatic reruns.
8+
- Let `with-watch` infer watched inputs for common read/write utilities such as `cat`, `cp`, `sed`, and `find`.
9+
- Fall back to explicit `exec --input` globs when inference would be ambiguous or when the delegated command has no meaningful filesystem inputs.
10+
511
## Install
612

713
```sh
814
cargo install with-watch
915
brew install delinoio/tap/with-watch
1016
```
1117

12-
## Examples
18+
## Command modes
19+
20+
- Passthrough mode: `with-watch [--no-hash] <utility> [args...]`
21+
- Shell mode: `with-watch [--no-hash] --shell '<expr>'`
22+
- Explicit-input mode: `with-watch exec [--no-hash] --input <glob>... -- <command> [args...]`
23+
24+
Use passthrough mode for a single delegated command, shell mode for simple command-line expressions that need `&&`, `||`, or `|`, and `exec --input` when you want to declare the watched files yourself.
25+
26+
## Quick start
1327

1428
```sh
29+
with-watch cat input.txt
1530
with-watch cp src.txt dest.txt
1631
with-watch ls -l
1732
with-watch --shell 'cat src.txt | grep hello'
@@ -25,3 +40,37 @@ with-watch exec --input 'src/**/*.rs' -- cargo test -p with-watch
2540
- Known outputs, inline scripts, patterns, and shell output redirects are filtered out of the watch set.
2641
- Pathless defaults are intentionally narrow: only `ls`, `dir`, `vdir`, `du`, and `find` implicitly watch the current directory.
2742
- `exec --input` remains the explicit escape hatch when a delegated command has no meaningful filesystem inputs or when fallback inference would be ambiguous.
43+
44+
## When to use exec --input
45+
46+
Use `exec --input` when the delegated command does not read a stable filesystem input by itself, or when you want the watch set to be explicit.
47+
48+
For example, commands like `echo hello` are intentionally rejected because there is nothing safe to watch:
49+
50+
```sh
51+
with-watch exec --input 'src/**/*.rs' -- cargo test -p with-watch
52+
```
53+
54+
`with-watch` reruns the delegated command exactly as provided. It does not inject changed paths into argv or environment variables.
55+
56+
## Shell limitations
57+
58+
- `--shell` is for command-line expressions, not shell scripts.
59+
- Supported operators are `&&`, `||`, and `|`.
60+
- Input redirects (`<`, `<>`) are treated as watched inputs.
61+
- Output redirects (`>`, `>>`, `&>`, `&>>`, `>|`) are filtered as outputs and are not watched.
62+
- Broader shell control-flow remains out of scope for v1.
63+
64+
## Rerun behavior
65+
66+
- The default rerun filter compares content hashes, which avoids reruns from metadata churn alone.
67+
- `--no-hash` switches the filter to metadata-only comparison.
68+
- Commands that write excluded outputs such as `cp src.txt dest.txt` should rerun when the source input changes, not when the output file changes.
69+
- Commands that mutate watched inputs directly, such as `sed -i.bak -e 's/old/new/' config.txt`, refresh their baseline after each run so they do not loop on their own writes.
70+
- Path-based inputs anchor the watcher at the nearest existing directory so replace-style writers keep producing later external change events.
71+
72+
## Troubleshooting
73+
74+
- `No watch inputs could be inferred from the delegated command`: switch to `with-watch exec --input ... -- <command>`.
75+
- `--shell cannot be combined with delegated argv or the exec subcommand`: choose exactly one command mode per invocation.
76+
- `--shell` works only for simple command-line expressions on Unix-like platforms.

docs/apps-public-docs-foundation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
## Interfaces and Contracts
1616
- Navigation and page ID contracts in `apps/public-docs/docs.json` must remain stable.
1717
- Public-facing routes and content groupings must map to canonical docs contracts.
18+
- Top-level product page IDs currently include `nodeup`, `cargo-mono`, `derun`, `with-watch`, and `dexdex`.
19+
- The `With Watch` tab must route to the stable page ID `with-watch` and keep the `Command Rerun Watcher` grouping unless contracts are updated together.
1820
- Breaking navigation changes require explicit migration notes.
1921

2022
## Storage

docs/crates-with-watch-foundation.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
- Root passthrough mode must remain `with-watch [--no-hash] <utility> [args...]`.
1818
- Shell mode must remain `with-watch [--no-hash] --shell '<expr>'`.
1919
- `exec` mode must remain `with-watch exec [--no-hash] --input <glob>... -- <command> [args...]`.
20+
- The CLI must continue to reject mixed modes and empty delegated-command requests with operator-facing guidance.
21+
- Passthrough and shell modes must infer watch inputs before the first run; if inference does not produce safe filesystem inputs, the command must fail with `exec --input` guidance instead of guessing.
22+
- `exec --input` must accept repeatable explicit glob/path values, keep the delegated command unchanged, and remain the canonical fallback for otherwise ambiguous or pathless commands.
23+
- `--no-hash` must remain a global flag that switches rerun filtering from content hashes to metadata-only comparison.
2024
- Public crate installation must remain `cargo install with-watch`.
2125
- Publish tag naming must remain `with-watch@v<version>`.
2226
- Stable internal enums must remain aligned with the current v1 contract:
@@ -36,6 +40,7 @@
3640
- `exec --input` remains the canonical explicit input contract when inference is insufficient, but command-side side-effect metadata may still be inferred for rerun suppression and logging.
3741
- Commands marked as `WritesWatchedInputs` must refresh the baseline snapshot after each run and suppress reruns caused only by their own writes while they were executing.
3842
- Path watch inputs must attach their OS watcher to the nearest existing directory so replace-style writers such as GNU `sed -i` do not orphan follow-up change detection on Linux.
43+
- Operator-facing documentation must explain the three command modes, the `exec --input` escape hatch, shell support boundaries, and why self-mutating commands do not loop on their own writes.
3944
- Homebrew installation must consume prebuilt GitHub release archives for `darwin/amd64`, `darwin/arm64`, and `linux/amd64`.
4045

4146
## Storage
@@ -56,6 +61,7 @@
5661
- Local validation: `cargo test -p with-watch`
5762
- Workspace validation baseline: `cargo test --workspace --all-targets`
5863
- Tests must cover CLI modes, shell parsing, adapter classification, fallback ambiguity handling, snapshot diffing, self-write suppression, and representative rerun flows.
64+
- Documentation changes should be checked against `cargo run -p with-watch -- --help` and the integration scenarios in `crates/with-watch/tests/cli.rs`.
5965
- Publishability validation: `cargo publish -p with-watch --dry-run`
6066
- Release contract checks should align with `.github/workflows/release-with-watch.yml`.
6167
- Release assets must include standalone binaries (`with-watch-<os>-<arch>[.exe]`) and compressed archives (`with-watch-<os>-<arch>.tar.gz|zip`) for the supported release matrix.

docs/project-public-docs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Provide the Mintlify-based public documentation site for user-facing product and
1515
## Cross-Domain Invariants
1616
- Mintlify navigation IDs and docs structure must stay aligned with documented contracts.
1717
- User-facing content changes should be versioned alongside relevant contract updates.
18+
- Public project pages currently exposed in top-level navigation include `nodeup`, `cargo-mono`, `derun`, `with-watch`, and `dexdex`.
1819

1920
## Change Policy
2021
- Update this index and `docs/apps-public-docs-foundation.md` in the same change for navigation, runtime, or publishing workflow updates.

docs/project-with-watch.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ Provide a Rust-based CLI wrapper that reruns delegated shell utilities and arbit
1616
- Root passthrough mode must remain `with-watch [--no-hash] <utility> [args...]`.
1717
- Shell mode must remain `with-watch [--no-hash] --shell '<expr>'` and is the supported entrypoint for `&&`, `||`, and `|`.
1818
- Arbitrary command mode must remain `with-watch exec [--no-hash] --input <glob>... -- <command> [args...]`.
19+
- The public CLI surface must keep exactly one delegated-command entrypoint per invocation: passthrough argv, `--shell`, or `exec --input`.
1920
- Default change detection must prefer content hashing, while `--no-hash` must switch the rerun filter to metadata-only comparison.
2021
- `exec --input` reruns the delegated command unchanged and must not inject changed paths into argv or environment variables.
22+
- Commands without safe inferred filesystem inputs must fail clearly and direct operators to `with-watch exec --input ...`.
2123
- Passthrough and shell modes must use adapter-driven input inference that excludes known outputs, scripts, and pattern operands from the watch set.
2224
- Shell redirects must treat `<` and `<>` targets as watched inputs and `>`, `>>`, `&>`, `&>>`, and `>|` targets as filtered outputs.
25+
- Shell parsing support is limited to command-line expressions plus `&&`, `||`, and `|`; broader shell control-flow stays out of scope until documented otherwise.
2326
- Safe pathless default watch roots are limited to the built-in allowlist (`ls`, `dir`, `vdir`, `du`, and `find`).
2427
- Commands that mutate watched inputs directly must refresh the baseline snapshot after each run and suppress self-triggered reruns caused by their own writes.
2528
- Path-based watch inputs must anchor watcher subscriptions at the nearest existing directory so replace-style writers keep emitting later external changes.
@@ -29,7 +32,7 @@ Provide a Rust-based CLI wrapper that reruns delegated shell utilities and arbit
2932
- Homebrew installation must consume prebuilt `with-watch` release archives for `darwin/amd64`, `darwin/arm64`, and `linux/amd64`.
3033

3134
## Change Policy
32-
- Update this index and `docs/crates-with-watch-foundation.md` together when CLI shape, watch inference behavior, release automation, side-effect suppression, or storage/logging contracts change.
35+
- Update this index and `docs/crates-with-watch-foundation.md` together when CLI shape, watch inference behavior, operator guidance, release automation, side-effect suppression, or storage/logging contracts change.
3336
- Update root `Cargo.toml`, `.github/workflows/release-with-watch.yml`, `scripts/release/update-homebrew.sh`, and `packaging/homebrew/templates/with-watch.rb.tmpl` in the same change when with-watch release tags, artifact names, or package-manager distribution contracts change.
3437
- Keep root `AGENTS.md` and `crates/AGENTS.md` aligned with ownership and project-ID changes.
3538

0 commit comments

Comments
 (0)