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

Feature: Source Code Inspection for Dependencies #3547

Open
mireklzicar opened this issue Mar 15, 2025 · 0 comments
Open

Feature: Source Code Inspection for Dependencies #3547

mireklzicar opened this issue Mar 15, 2025 · 0 comments

Comments

@mireklzicar
Copy link

mireklzicar commented Mar 15, 2025

Feature: Source Code Inspection for Dependencies

Problem

When users ask about library behavior, aider cannot access the actual implementation code of dependencies. This forces aider to rely on pre-trained knowledge rather than analyzing the real code users are working with.
This creates three critical issues:

  1. Inaccurate explanations when documentation differs from implementation
  2. Version-specific behaviors cannot be detected (users often work with specific library versions)
  3. Implementation details critical for debugging remain hidden

Proposed Solution

Implement a source code inspection feature that allows aider to:

  • Directly inspect source code of imported dependencies using introspection tools (such as inspect in Python)
  • Extract actual implementation code to analyze behavior, not just documentation
  • Detect version-specific implementation details by analyzing installed code
  • Generate more accurate explanations based on real code, not pre-trained knowledge

Example

How the source code can be accessed:

# User is wondering about NumPy average implementation details
# Instead of guessing, aider would access actual source
import inspect
import numpy.lib.function_base as fb
print(inspect.getsource(fb.average))

This is the output aider would see after inspection:

@array_function_dispatch(_average_dispatcher)
def average(a, axis=None, weights=None, returned=False, *,
            keepdims=np._NoValue):
    """
    Compute the weighted average along the specified axis.

    Parameters
    ----------
    a : array_like
        Array containing data to be averaged. If `a` is not an array, a
        conversion is attempted.
    axis : None or int or tuple of ints, optional
        Axis or axes along which to average `a`.  The default,
        axis=None, will average over all of the elements of the input array.
        If axis is negative it counts from the last to the first axis.
...

When users ask "How does numpy.random.RandomState work internally?" or "What edge cases does pandas.DataFrame.fillna handle?", aider could access the actual implementation rather than rely on documentation summaries.

Limitations

  • Source navigation across language boundaries (Python → C/C++) – in fact in the numpy example, most functions don't work, because they are implemented in Cython.
  • Multi-language support: there are differences between languages (Python, Javascript, C#, Rust...) on how are packages accessed and inspected). It would probably need handlers or adapters for each of the supported languages.
  • Handling compiled libraries where source might not be included

Benefits

  • More accurate answers about specific version implementations
  • Better debugging assistance for edge cases
  • Deeper insights into performance characteristics and implementation details
  • Reduced hallucination when explaining complex library behavior

Implementation details

  • I am a newcomer here, so I am leaving actual implementation details open to discussion.
  • This capability could be implemented as a "tool" next to the already existing search capability.
  • Advanced functionality: repomap could be enhanced by inspection of crucial dependencies.
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

No branches or pull requests

1 participant