polyglot

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package polyglot detects multi-language repository structures by scanning manifest files (go.mod, package.json, Cargo.toml, etc.) and grouping source files into language-specific layers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClassifyLayerRole

func ClassifyLayerRole(sources []string) string

ClassifyLayerRole is the public entry point for role classification. It takes source code snippets from a single layer and returns one of: "server", "client", "worker", or "library".

Types

type CargoInfo

type CargoInfo struct {
	Name             string
	Version          string
	Edition          string
	Dependencies     []string
	DevDependencies  []string
	WorkspaceMembers []string
}

CargoInfo contains metadata extracted from a Cargo.toml file.

func ParseCargoToml

func ParseCargoToml(data []byte) CargoInfo

ParseCargoToml extracts dependency and metadata from Cargo.toml content. Uses simple line-based parsing to avoid adding a TOML dependency.

type Layer

type Layer struct {
	Name     string
	Role     string
	RootDir  string
	Language string
	Files    int
}

Layer represents a distinct language area within the repository, typically rooted at a manifest file (go.mod, package.json, etc.).

type Manifest

type Manifest struct {
	Path     string
	Type     string
	Language string
}

Manifest represents a detected build/dependency manifest file.

type RepoStructure

type RepoStructure struct {
	Layers    []Layer
	Languages map[string]int
	Manifests []Manifest
}

RepoStructure describes the detected language layout of a repository.

func DetectStructure

func DetectStructure(files []*ingest.File) *RepoStructure

DetectStructure scans a list of ingested files for manifest files, groups files by the nearest manifest root, and builds layers.

func (*RepoStructure) IsPolyglot

func (rs *RepoStructure) IsPolyglot() bool

IsPolyglot reports whether the repository contains 2 or more languages each with at least polyglotThreshold source files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL