Skip to content

feat(C++): add C++/CMake/MSBuild/PowerShell command handlers#1615

Open
isink17 wants to merge 16 commits into
rtk-ai:developfrom
isink17:feat/cpp-msbuild-powershell-handlers
Open

feat(C++): add C++/CMake/MSBuild/PowerShell command handlers#1615
isink17 wants to merge 16 commits into
rtk-ai:developfrom
isink17:feat/cpp-msbuild-powershell-handlers

Conversation

@isink17
Copy link
Copy Markdown

@isink17 isink17 commented Apr 29, 2026

C++ / MSBuild / PowerShell handler support

Adds token filtering for C++ build toolchains and PowerShell commands
used in Windows-native MSVC development workflows.

New handlers

Command Filter Savings
cmake --build GCC/Clang errors only ~85%
cmake -B CMake errors + key settings ~70%
ctest Failed tests only ~85%
make / ninja Build errors only ~80%
msbuild MSVC C/LNK errors only ~80%
codegraph index Summary line only ~90%
rtk grep on MSBuild log 97.39% (308 KB → 8 KB) real log
rtk read on MSBuild log 97.16% (308 KB → 8.7 KB) real log

Benchmarks measured on a real 308 KB UTF-16 LE MSBuild solution log.

PowerShell auto-rewrites

Raw Rewritten to
Select-String -Path f -Pattern p rtk grep p f
Get-Content <file> rtk read <file>
GC <file> rtk read <file>
Remove-Item <path> -Force ok <basename>
msbuild ... *> file.log redirect hint + log path

Key implementation notes

  • MSBuild stderr capturelink.exe writes to stderr; handler
    merges both streams so LNK errors are never silently dropped
  • UTF-16 LE support — MSBuild logs on Windows are UTF-16 LE;
    rtk read now detects BOM, transcodes, then applies MSBuild filter
  • MSBuild log auto-detectionrtk read samples first 200 lines
    to detect MSBuild format and route through the msbuild filter pipeline
  • make install/clean exclusion — implemented procedurally since the
    regex crate has no negative lookahead
  • codegraph — MCP tool calls (context_for_task, find_callers etc.)
    bypass the bash hook entirely; only CLI commands are filtered

Known limitation

*> PowerShell redirect is detected at rewrite time and emits a log
path hint, but RTK cannot intercept the build output in transit — the
shell consumes *> before the hook runs. Workflow: build with *>,
then rtk read <logfile>.

Tests

1643 pass, 0 fail. cargo fmt --check clean.
11 fixtures in tests/fixtures/cpp/.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 29, 2026

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added effort-large Plusieurs jours, nouveau module enhancement New feature or request labels Apr 29, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

Type feature
🟡 Risk medium

Summary

Adds comprehensive C++/CMake/MSBuild/PowerShell command handlers to RTK, including token-filtering for build toolchain output (cmake, make, ninja, msbuild, ctest, codegraph) and automatic rewriting of PowerShell commands (Select-String, Get-Content, Remove-Item) into RTK equivalents. Includes UTF-16 LE support for MSBuild logs, stderr merging for link.exe, and MSBuild log auto-detection.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

@isink17 isink17 changed the base branch from master to develop April 29, 2026 12:23
@mgerhardy
Copy link
Copy Markdown

googletest would be great, too - but this is already really helpful - thanks a lot

@isink17 isink17 force-pushed the feat/cpp-msbuild-powershell-handlers branch from 3a62e05 to 30d569f Compare May 8, 2026 00:50
@isink17
Copy link
Copy Markdown
Author

isink17 commented May 8, 2026

googletest would be great, too - but this is already really helpful - thanks a lot

Added a narrow ctest/GoogleTest-style output filter. It keeps failure blocks + failed summaries, drops passing-test noise, handles ctest -V prefixes, and filters combined stdout/stderr.

@isink17 isink17 force-pushed the feat/cpp-msbuild-powershell-handlers branch from 17099b1 to 9ba8a4d Compare May 8, 2026 20:56
@isink17 isink17 force-pushed the feat/cpp-msbuild-powershell-handlers branch from d646909 to db93cc0 Compare May 27, 2026 09:35
@isink17
Copy link
Copy Markdown
Author

isink17 commented May 28, 2026

I've noticed potential room for optimization so adding a commit for it as well
image

isink17 added 16 commits May 30, 2026 11:15
New module src/cmds/cpp/ with handlers for:
- cmake --build / cmake -B  (GCC/Clang error filter)
- ctest                     (failed tests only)
- make / ninja              (build errors only)
- msbuild                   (MSVC cl.exe + link.exe errors)
- codegraph                 (index/update summary, search truncation)

PowerShell rewrites in registry.rs:
- Select-String  →  rtk grep
- Get-Content / GC  →  rtk read
- Remove-Item  →  rtk remove-item
- msbuild *> file.log  →  redirect hint with log path

rtk read: detect and filter MSBuild UTF-16 LE log files

Benchmarks on real MSBuild log (308 KB, UTF-16 LE, Windows):
  rtk grep on log:  97.39% reduction (308 KB → 8 KB)
  rtk read on log:  97.16% reduction (308 KB → 8.7 KB)

Implementation notes:
- msbuild handler merges stdout+stderr (link.exe writes to stderr)
- UTF-16 LE BOM detection + transcode before filter pipeline
- MSBuild log auto-detection in rtk read (samples first 200 lines)
- make install/clean excluded procedurally (regex crate lacks
  negative lookahead)
- codegraph serve never rewritten (long-running MCP server process)

Tests: 1643 pass, 0 fail. cargo fmt clean.
11 fixtures in tests/fixtures/cpp/.
… blocks + failed summaries, drops passing-test noise, handles ctest -V prefixes, and filters combined stdout/stderr.
- grep fixed-mode logic clarified and commented
- GNU grep fallback now honors fixed mode with -F
- rg extra args are inserted before pattern/path
- patch wording changed from byte-preserving to encoding-aware best-effort roundtrip
- auto encoding no longer guesses cp949; cp949 is explicit via --encoding cp949
- README updated with grep/read/patch usage, safety notes, and encoding behavior
* Add Windows C++ MSBuild and PowerShell diagnostics
Add agent-focused grep ergonomics:
- parse RTK grep flags before or after the search path
- add files-only, count-by-file, top-files, and JSON output modes
- add agent-safe preset via CLI, RTK_AGENT_SAFE, and agent.safe_mode
- support explicit caps for total matches, per-file matches, and line length
- keep legacy default grep behavior unless safe mode or new modes are used
- improve summaries with concrete rtk read hints
- document agent-safe grep usage in README

Also harden:
- UTF-8 clipping and tiny max-line handling
- no-match behavior
- unknown rg-arg forwarding
- capped JSON output using a running current_count counter
- JSON mode stability across grep modes

Add Windows-focused diagnostics for C++/MSBuild and PowerShell workflows.

Address review feedback:
- avoid double HashSet lookup in MSBuild diagnostic deduplication
- use Unicode character counts for log truncation thresholds
- allow UTF-16 no-BOM detection to ignore one trailing odd byte

Includes tests for Unicode-safe log truncation and odd-length UTF-16 no-BOM samples.
New module src/cmds/cpp/ with handlers for:
- cmake --build / cmake -B  (GCC/Clang error filter)
- ctest                     (failed tests only)
- make / ninja              (build errors only)
- msbuild                   (MSVC cl.exe + link.exe errors)
- codegraph                 (index/update summary, search truncation)

PowerShell rewrites in registry.rs:
- Select-String  →  rtk grep
- Get-Content / GC  →  rtk read
- Remove-Item  →  rtk remove-item
- msbuild *> file.log  →  redirect hint with log path

rtk read: detect and filter MSBuild UTF-16 LE log files

Benchmarks on real MSBuild log (308 KB, UTF-16 LE, Windows):
  rtk grep on log:  97.39% reduction (308 KB → 8 KB)
  rtk read on log:  97.16% reduction (308 KB → 8.7 KB)

Implementation notes:
- msbuild handler merges stdout+stderr (link.exe writes to stderr)
- UTF-16 LE BOM detection + transcode before filter pipeline
- MSBuild log auto-detection in rtk read (samples first 200 lines)
- make install/clean excluded procedurally (regex crate lacks
  negative lookahead)
- codegraph serve never rewritten (long-running MCP server process)

Tests: 1643 pass, 0 fail. cargo fmt clean.
11 fixtures in tests/fixtures/cpp/.
… blocks + failed summaries, drops passing-test noise, handles ctest -V prefixes, and filters combined stdout/stderr.
- grep fixed-mode logic clarified and commented
- GNU grep fallback now honors fixed mode with -F
- rg extra args are inserted before pattern/path
- patch wording changed from byte-preserving to encoding-aware best-effort roundtrip
- auto encoding no longer guesses cp949; cp949 is explicit via --encoding cp949
- README updated with grep/read/patch usage, safety notes, and encoding behavior
* Add Windows C++ MSBuild and PowerShell diagnostics
Add agent-focused grep ergonomics:
- parse RTK grep flags before or after the search path
- add files-only, count-by-file, top-files, and JSON output modes
- add agent-safe preset via CLI, RTK_AGENT_SAFE, and agent.safe_mode
- support explicit caps for total matches, per-file matches, and line length
- keep legacy default grep behavior unless safe mode or new modes are used
- improve summaries with concrete rtk read hints
- document agent-safe grep usage in README

Also harden:
- UTF-8 clipping and tiny max-line handling
- no-match behavior
- unknown rg-arg forwarding
- capped JSON output using a running current_count counter
- JSON mode stability across grep modes

Add Windows-focused diagnostics for C++/MSBuild and PowerShell workflows.

Address review feedback:
- avoid double HashSet lookup in MSBuild diagnostic deduplication
- use Unicode character counts for log truncation thresholds
- allow UTF-16 no-BOM detection to ignore one trailing odd byte

Includes tests for Unicode-safe log truncation and odd-length UTF-16 no-BOM samples.
@isink17 isink17 force-pushed the feat/cpp-msbuild-powershell-handlers branch from 1b96164 to d01d17f Compare May 31, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-large Plusieurs jours, nouveau module enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants