Skip to content

feat(filter): preserve important comments for AI context & multi-area improvements#1077

Open
saoqixiaomm wants to merge 3 commits intortk-ai:masterfrom
saoqixiaomm:feature/preserve-comments-for-ai
Open

feat(filter): preserve important comments for AI context & multi-area improvements#1077
saoqixiaomm wants to merge 3 commits intortk-ai:masterfrom
saoqixiaomm:feature/preserve-comments-for-ai

Conversation

@saoqixiaomm
Copy link
Copy Markdown

Summary

  • MinimalFilter comment preservation: Instead of stripping all comments, the minimal filter now preserves comments containing important markers (TODO, FIXME, NOTE, HACK, BUG, WARNING, SECURITY, PERF, WHY, etc.). This gives AI agents better context when reading filtered code. Unknown file types are now handled conservatively (no comment patterns assumed) to avoid stripping semantically important content.

  • TOML filter safety rail: Added ERROR_SIGNAL_RE check to prevent success short-circuit messages (e.g., "ok") from being emitted when the raw output clearly contains error signals (error, failed, panic, traceback, etc.).

  • Config defaults raised: Increased status_max_files 15→30, status_max_untracked 10→20, passthrough_max_chars 2000→6000 to keep more context in AI/code-review workflows.

  • Analytics improvements: Adaptive precision for percentage formatting, comma-separated exact token counts alongside compact notation, and separate tracking of token-tracked vs passthrough/fallback commands in rtk gain.

  • Codex session support: rtk session / rtk discover now parse Codex (~/.codex/sessions/) JSONL logs alongside Claude Code logs. Supports exec_command / function_call_output event types and session_meta CWD-based project filtering.

  • Registry hardening: Improved shell tokenizer to handle variable assignments, command substitutions, heredocs, and complex quoting — reducing false-positive rewrite suggestions.

  • New TOML filter: poetry-api-test (tail-based, strips ANSI, keeps last 10 lines).

  • Codex awareness hook: Expanded guidance to prefer RTK-native commands and the rtk proxy <cmd> | rtk tail pattern for bounded output.

Test plan

  • All 1308 tests pass (cargo test --all)
  • cargo fmt --all --check passes
  • cargo clippy --all-targets — 0 errors, 4 pre-existing warnings
  • No company/personal information in diff (sanitized test fixtures)
  • Manual: rtk read -l minimal <file> preserves TODO/FIXME comments
  • Manual: rtk gain shows token-tracked vs passthrough breakdown

Made with Cursor

@saoqixiaomm
Copy link
Copy Markdown
Author

@aeppling Hi! Could you please review this PR when you have a moment?

This PR improves the MinimalFilter to preserve important comments (TODO/FIXME/NOTE/etc.) for AI context, adds a TOML filter safety rail against false-positive success messages, raises config defaults for richer AI workflows, and adds Codex session log support to rtk discover/session. All 1308 tests pass.

Thanks!

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 8, 2026

CLA assistant check
All committers have signed the CLA.

@saoqixiaomm saoqixiaomm force-pushed the feature/preserve-comments-for-ai branch from ad22e35 to 9373d19 Compare April 8, 2026 09:46
@saoqixiaomm
Copy link
Copy Markdown
Author

recheck

… improvements

- MinimalFilter now keeps TODO/FIXME/NOTE/HACK/etc. comments instead of stripping all
- Unknown languages handled conservatively (no comment patterns assumed)
- TOML filter safety rail: skip success short-circuit when output contains error signals
- Config defaults raised: status_max_files 15→30, status_max_untracked 10→20, passthrough_max_chars 2000→6000
- Analytics: adaptive precision formatting, token-tracked vs passthrough breakdown
- Discover: Codex session support (exec_command parsing, session_meta CWD filter)
- Registry: shell variable assignment, command substitution, heredoc tokenization
- New TOML filter: poetry-api-test (tail-based)
- Codex awareness hook: prefer RTK-native commands, proxy+tail pattern

Made-with: Cursor
@saoqixiaomm saoqixiaomm force-pushed the feature/preserve-comments-for-ai branch from 9373d19 to 50bc444 Compare April 9, 2026 06:37
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.

2 participants