Skip to content

Resolve @Project from the project's manifest, whatever the file type #74

Closed

Description

@Shinrai

Problem

@Project should come from the manifest of the project a file belongs to. Today each file-type detector hard-codes which manifest it looks for (src/detectors/*.mjs markers + parseProjectName), so a file gets the right name only when its type happens to match the project's ecosystem:

  • CSS / HTML only know package.json (since fix: take the CSS and HTML @Project from the project's package.json #72) — in a PHP (composer.json), Python (pyproject.toml) or Rust (Cargo.toml) project they fall back to the folder name.
  • YAML and JSON only know package.json — a workflow .yml or a .json config in a Python repo gets the folder name.
  • A .mjs build script in a Python project looks only for package.json and misses pyproject.toml.

Expected

Separate "which project does this file belong to" from "which comment syntax does this file type use":

  1. Walk up from the file; at each folder check for every known manifest: package.json, pyproject.toml (plus the name in setup.cfg / setup.py where present), composer.json, Cargo.toml, go.mod. The nearest folder containing any manifest is the project root.
  2. The name comes from that manifest's parser (name, [project].name / [tool.poetry].name, [package].name, module, …); the folder name only when the manifest yields none.
  3. Tie-break when one folder holds several manifests: the manifest of the file's own language wins (.py → pyproject.toml, .js/.mjs/.ts → package.json, .php → composer.json, .rs → Cargo.toml, .go → go.mod); language-neutral files (CSS, HTML, YAML, JSON, Markdown, …) use the fixed order package.json, pyproject.toml, composer.json, Cargo.toml, go.mod.
  4. Comment syntax / preserved prefixes stay per file type, unchanged.
  5. projectName / --project-name still override everything.

Tests

Every file type × every manifest type (CSS in a composer/pyproject/Cargo/go project, YAML/JSON in a Python project, .mjs in a Python project, …); nearest-folder wins over a farther manifest; same-folder tie-break by language and the fixed order for neutral files; manifests without a name fall back to the folder; malformed manifests; projectName override.

Activity

  1. added
    type: bug
    priority: high
    area: core
    status: in progress
    on Sep 29, 2026
  2. Shinrai commented on Sep 29, 2026

    @Shinrai
    ContributorAuthor

    Design update: resolve project data through one driver per ecosystem, rather than a single winning manifest.

    • Drivers: node, python, php, rust, go, each with its own file. Each has detect(dir), which checks whether the folder is a valid project of that kind, and read(), which returns the data its manifest provides (at least name).
    • The project root is the nearest folder that at least one driver claims.
    • Claiming drivers are ordered with the file's native driver first, then node, python, php, rust, go.
    • Data is merged field by field: each field comes from the first claiming driver whose manifest provides it. If the first manifest has no name and a second driver also claims the folder, the name comes from the second. The folder name is used only when no claiming driver has one.
    • The overrides (projectName, …) still win, and comment syntax stays per file type.
  3. Shinrai commented on Sep 29, 2026

    @Shinrai
    ContributorAuthor

    Refinement: when no driver claiming the nearest folder provides a field, resolution keeps climbing.

    • It checks each next ancestor folder a driver claims, with the same driver ordering, until the field is found or it reaches the root of the scan. It never climbs above the scan root.
    • The folder name is used only when nothing up to the scan root provides a name.
    • The project root, which git lookups and @Filename use, stays the nearest claimed folder. Only field values climb.
  4. Shinrai commented on Sep 29, 2026

    @Shinrai
    ContributorAuthor

    @Filename is the file's path relative to the folder of the manifest detected for that file, the nearest claimed folder. This holds even when @Project climbs to a parent's manifest: the name comes from the parent, the path from the nearest manifest. It's already how the header template builds it (relative(projectRoot, file)), and #74 keeps it that way and adds tests.

  5. Shinrai commented on Sep 29, 2026

    @Shinrai
    ContributorAuthor

    A .git folder is a repository boundary, and it stays a hard stop for both the project-root search and the field climb. A file belongs, at most, to the repository it lives in, so a nested repository or submodule is its own project and its history comes from its own git. As implemented in #75.

  6. added
    status: implemented
    and removed
    status: in progress
    on Sep 29, 2026
  7. cldmv-bot commented on Sep 29, 2026

    @cldmv-bot
    Contributor

    Closed in v2.0.0 — resolved by #75.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corepriority: highstatus: implementedtype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions