Skip to main content

Module shell_file_effects

Module shell_file_effects 

Source
Expand description

Which files a shell command reads or rewrites, for bounce accounting.

The bounce tracker books a correction when a lossy compressed view of a file is followed by its full content, and cancels it when the file is edited right after (read-before-edit). Agents read and edit through the shell as well, so ctx_shell commands are classified here:

  • full reads — cat, bat/batcat (without -r), less, more whose output reaches the model unfiltered;
  • partial reads — head, tail, sed without -i, bat -r, or a full reader whose output is piped onward: they never start or complete a correction;
  • edits — sed -i, perl -i, output redirections (>, >>, >|, N>, &>), tee, cp/mv/install onto a path, and apply_patch patch bodies (*** Update File: …).

The parse is deliberately conservative: duplications (2>&1, >&2), /dev/* targets and targets built from expansions ($VAR, `cmd`) are never edits, and anything not recognised is ignored rather than guessed. A missed edit leaves today’s behaviour; a wrongly reported edit only cancels a provisional correction.

Structs§

ShellFileEffects
The files one shell command reads and rewrites, paths as written (relative paths joined onto a preceding cd DIR).

Enums§

ShellReadKind
How much of a file a shell read delivered.

Functions§

analyze
Classify the file reads and edits of command. A command longer than the shell gate validates is not analysed: the hooks run this before the gate, and each nested sh -c level is another recursive pass.
apply_patch_targets
Paths an apply_patch body touches: *** Update File:, *** Add File:, *** Delete File: and *** Move to: headers. Shared with the host-edit hook, which receives Codex apply_patch calls as raw patch text.