Skip to content

Enhancement: Language grouping in mixed-language directories #17

@dreamlx

Description

@dreamlx

Problem

When a directory contains files from multiple languages (e.g., widget.php + widget.ts), the generated README_AI.md lists all files together without language separation. This can confuse AI agents, especially when:

  • Same class name exists in both languages (e.g., DashboardWidget in PHP and TS)
  • Dependencies from different ecosystems are mixed together
  • No explicit language indicator on TS/JS files (PHP has Namespace: marker)

Example

mixed/ directory with widget.php + widget.ts currently generates:

## Files

### widget.php
**Namespace:** `App\Widgets`
**class** `class DashboardWidget`

### widget.ts
**class** `class DashboardWidget`

## Dependencies
- chart.js

No visual separation between PHP and TypeScript sections.

Proposed Solution

In SmartWriter._generate_detailed(), group files by language before listing:

## PHP Files

### widget.php
**Namespace:** `App\Widgets`
**class** `class DashboardWidget`

## TypeScript Files

### widget.ts
**class** `class DashboardWidget`

Also split Dependencies by language.

Scope

  • Only affects directories with mixed languages (single-language dirs unchanged)
  • Minimal change: add language detection in _generate_detailed() using file extension → language mapping from scanner.py

Priority

Low — Standard project structures (Laravel, Spring Boot, Next.js) naturally separate languages by directory. Mixed-language directories are uncommon in practice.

Affected Files

  • src/codeindex/smart_writer.py (_generate_detailed)
  • src/codeindex/scanner.py (reuse LANGUAGE_EXTENSIONS mapping)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions