diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-11 07:38:07 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-11 07:38:07 -0500 |
| commit | c62aa7af377e74d617ba09fe97b9df4718c6f1c4 (patch) | |
| tree | a9acfc2e38c38716722726ee1555daf4ae745ffb /.ai/scripts/maildir-flag-manager.py | |
| parent | c462a13acd893f16e6e9b9358071435adf439c86 (diff) | |
| download | rulesets-c62aa7af377e74d617ba09fe97b9df4718c6f1c4.tar.gz rulesets-c62aa7af377e74d617ba09fe97b9df4718c6f1c4.zip | |
chore(ai): sync template updates from claude-templates
Pull in the latest maildir-flag-manager.py and cross-agent-comms doc updates from the claude-templates source.
Diffstat (limited to '.ai/scripts/maildir-flag-manager.py')
| -rwxr-xr-x | .ai/scripts/maildir-flag-manager.py | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/.ai/scripts/maildir-flag-manager.py b/.ai/scripts/maildir-flag-manager.py index 9c4a59c..97ed1d8 100755 --- a/.ai/scripts/maildir-flag-manager.py +++ b/.ai/scripts/maildir-flag-manager.py @@ -119,28 +119,34 @@ def process_maildir(maildir_path, flag, dry_run=False): print(f" Skipping {maildir_path} (not found)", file=sys.stderr) return 0, 0, 0 - changed = 0 - skipped = 0 - errors = 0 - + # Snapshot the file list before any rename. Adding S to a new/ file + # moves it to cur/ via rename_with_flag; without a snapshot, the + # moved file gets re-encountered during the cur/ scan and inflates + # the skipped count. + file_paths = [] for subdir in ('new', 'cur'): subdir_path = os.path.join(maildir_path, subdir) if not os.path.isdir(subdir_path): continue - for filename in os.listdir(subdir_path): file_path = os.path.join(subdir_path, filename) - if not os.path.isfile(file_path): - continue - - try: - if rename_with_flag(file_path, flag, dry_run): - changed += 1 - else: - skipped += 1 - except Exception as e: - print(f" Error on {filename}: {e}", file=sys.stderr) - errors += 1 + if os.path.isfile(file_path): + file_paths.append(file_path) + + changed = 0 + skipped = 0 + errors = 0 + + for file_path in file_paths: + try: + if rename_with_flag(file_path, flag, dry_run): + changed += 1 + else: + skipped += 1 + except Exception as e: + print(f" Error on {os.path.basename(file_path)}: {e}", + file=sys.stderr) + errors += 1 return changed, skipped, errors |
