Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Add read-only stub files feature #3056

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lutzleonhardt
Copy link

@lutzleonhardt lutzleonhardt commented Jan 29, 2025

Add Read-Only Stub Files Feature

📝 Draft PR: This PR is currently in the idea/prototype phase. Feedback is welcome!

Unit tests are pending: This proof of concept currently lacks unit tests, which will be added upon merge approval. The build may fail due to this.

see also Navigating Large Codebases: Aider's Read-Only Stub Solution for a deeper explanation

Overview

This PR adds support for read-only stub files, which show only the structural outline of source files rather than their full content. This helps reduce context window usage while maintaining awareness of code structure.

Key Changes

  • Added new /read-only-stub command to add files as read-only stubs
  • Files can be converted between editable, read-only, and read-only stub modes
  • Stubs show function/class definitions without implementation details
  • Updated token counting and context management to handle stub files
  • Added support for stub files in save/load commands
  • Improved file listing display to clearly indicate stub status

Implementation Details

  • Added abs_read_only_stubs_fnames to track stub files
  • Refactored file handling code to support three file states (editable, read-only, stub)
  • Added stub file conversion logic in commands
  • Updated UI to show "(stub)" indicator for stub files
  • Reused existing repo map stub generation code for consistency

Testing

The changes have been tested for:

  • Converting between file modes (editable ↔ read-only ↔ stub)
  • Directory handling
  • Token counting accuracy
  • Save/load functionality
  • UI display in both pretty and plain modes

Documentation

The new /read-only-stub command is self-documenting via the help system.

Related Issues

This feature helps address context window management for large codebases by providing a way to include structural information about files without their full content.

@CLAassistant
Copy link

CLAassistant commented Jan 29, 2025

CLA assistant check
All committers have signed the CLA.

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