Skip to content

feat: complete with-watch command inference#362

Merged
kdy1 merged 4 commits intomainfrom
kdy1/with-watch-adapter-inference
Apr 10, 2026
Merged

feat: complete with-watch command inference#362
kdy1 merged 4 commits intomainfrom
kdy1/with-watch-adapter-inference

Conversation

@kdy1
Copy link
Copy Markdown
Contributor

@kdy1 kdy1 commented Apr 10, 2026

Summary

  • add adapter-driven command analysis for passthrough and shell mode, including wrapper unwrapping, shell redirect handling, and conservative fallback inference
  • exclude known outputs, scripts, and pattern operands from watched inputs while enabling safe current-directory defaults for ls/dir/vdir/du/find
  • suppress self-triggered reruns for commands that mutate watched inputs and cover the new behavior with CLI/integration tests

Testing

  • cargo test -p with-watch
  • cargo test --workspace --all-targets

@kdy1 kdy1 enabled auto-merge (squash) April 10, 2026 18:23
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f101cdc5f8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +142 to +145
starbase_args::Argument::Option(option, Some(value)) => {
shell_command
.argv
.push(format!("{option}={}", value.as_str()));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep shell option values as separate argv tokens

build_shell_command rewrites every Argument::Option(option, Some(value)) into a single "{option}={value}" token, which breaks short-option inference in shell mode. For example, grep -f patterns.txt file.txt becomes -f=patterns.txt, and adapters like analyze_grep strip -f then treat "=patterns.txt" as the watched path, so changes to patterns.txt are missed. This causes false watch targets and missed reruns for common short-option commands parsed via --shell.

Useful? React with 👍 / 👎.

Comment on lines +191 to +193
let should_rerun = pending_rerun
&& plan.metadata.side_effect_profile != SideEffectProfile::WritesWatchedInputs
&& inputs_changed_since_baseline;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Rerun when non-self changes happen during self-mutating runs

The rerun gate unconditionally disables reruns for WritesWatchedInputs commands, so any external input updates that occur while the child is running are dropped together with self-writes. In that case pending_rerun is true, but should_rerun is forced false and baseline is advanced to the post-run snapshot, which loses the first legitimate external change instead of replaying once after completion.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6209fc6cf3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1149 to +1151
if token.starts_with('-') {
index += 1;
continue;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse grouped grep flags that carry a pattern file

analyze_grep only handles -f when it appears as -f/--file (or -fFILE), then drops any other short-flag group via token.starts_with('-'). grep --help documents -f, --file=FILE take PATTERNS from FILE, and grouped forms like grep -rf patterns.txt src are valid; here patterns.txt is treated as the positional regex instead of a watched input file, so edits to the pattern file do not trigger reruns.

Useful? React with 👍 / 👎.

Comment on lines +1370 to +1372
if !saw_expression && FIND_GLOBAL_OPTIONS.contains(&token) {
index += 1;
continue;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Consume find debug/optimize option arguments

analyze_find advances only one token for every entry in FIND_GLOBAL_OPTIONS, but find --help shows -D debugopts and -Olevel/-O LEVEL semantics. With inputs like find -D stat -name '*.rs', the stat debug argument is incorrectly inferred as a watched path; because inputs are now non-empty, the default . watch root is not added, so normal cwd changes can be missed.

Useful? React with 👍 / 👎.

@kdy1 kdy1 merged commit ea48fc5 into main Apr 10, 2026
15 checks passed
@kdy1 kdy1 deleted the kdy1/with-watch-adapter-inference branch April 10, 2026 18:45
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d97322a5b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1490 to +1493
if token == "-C" || token == "--directory" {
filtered_output_count += usize::from(matches!(mode, TarMode::ReadArchive));
index += 2;
continue;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Track tar -C/--directory as an input in create mode

analyze_tar skips the value of -C/--directory entirely, and only increments filtered_output_count when the mode is currently ReadArchive. GNU tar --help defines -C, --directory=DIR as “change to directory DIR”, which in create flows (tar -cf out.tar -C src .) changes where inputs are read from. Because this path is never added to inputs, edits under src can be missed and reruns won’t fire even though the archive contents should change.

Useful? React with 👍 / 👎.

Comment on lines +1714 to +1717
if !metadata_arg_consumed {
metadata_arg_consumed = true;
} else {
push_inferred_input(&mut inputs, token, cwd)?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve first FILE operand for --reference attr commands

analyze_change_attributes always treats the first positional token as metadata (MODE/OWNER) and drops it, even when --reference is used. For commands like chmod --reference=ref.txt target.txt (documented as --reference=RFILE FILE...), target.txt is the first positional FILE, but this branch discards it, so the target path is not watched and changes to that file will not trigger reruns.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant