rtk-ai / rtk-ai/rtk

rtk read: no structural filtering on source files (4.2% avg over 7641 calls); -l aggressive drops class-level field declarations

Open
#3,260 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:cli area:performance bug help wanted priority:medium
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 11h
Merged PRs (30d)
40

Description

Summary

rtk read does no structural filtering on source files. On a large Python/XML codebase this makes it the single lowest-yield command in the suite, despite being one of the most used.

From rtk gain on a long-running install (0.42.3):

 3.  rtk read                   7641   13.3M    4.2%     0ms

7641 invocations, 4.2% average reduction. By comparison rtk grep runs at 57.7% and rtk find at 65.1%.

Reproduction

$ wc -c views/some_view.xml
2621
$ rtk read views/some_view.xml | wc -c
2621          # -l none  (default)
2620          # -l minimal
2620          # -l aggressive

XML is passed through verbatim at every level — there appears to be no XML filter at all.

The -l aggressive problem on Python

-l aggressive does compress Python (12012 B → 646 B here), but it drops class-level assignments. For ORM-style frameworks that is exactly the wrong half of the file — the field declarations are the model:

$ rtk read -l aggressive models/sale_order.py
from odoo import api, fields, models, _
class SaleOrder(models.Model):
    // ... implementation
    def _compute_picking_reservation(self):
    // ... implementation

Everything that describes the model — _inherit, and every x = fields.Selection(...) declaration — is gone, along with the decorators (@api.depends(...)) that determine recompute behaviour. An agent reading this cannot answer "what fields does this model add?" and will go read the raw file anyway, so the saving is negative in practice.

(Minor, same output: function bodies are elided with a C-style // ... implementation marker inside Python.)

Suggestion

Keep class-level assignments, decorators and dunder attributes in -l aggressive for Python, and add a structural XML level that keeps tag/attribute skeletons and elides text nodes.

For reference, a ~120-line structural filter along those lines measured -76.9% on .py and -71.1% on .xml over a random 150-file sample of a ~2900-file codebase — so the headroom over the current 4.2% is real. Happy to share the heuristics if useful.

Environment

rtk 0.42.3, macOS (aarch64), Claude Code PreToolUse hook.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported rtk read commands with -l none, minimal, and aggressive on representative Python and XML files, then inspect the implementation behind rtk read. Done means XML output is structurally filtered while retaining its tag and attribute skeleton, and aggressive Python output preserves class assignments, decorators, and dunder attributes without the reported invalid marker.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust, xml
Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.