Documentation
¶
Overview ¶
Package project provides utilities for detecting and normalizing project names.
It replicates the detection logic from the Claude Code shell helpers and OpenCode TypeScript plugin in pure Go, so CLI and MCP server can share a single canonical implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectProject ¶
DetectProject detects the project name for a given directory. Priority: git remote origin repo name → git root basename → dir basename. The returned name is always non-empty and already normalized (lowercase, trimmed).
Types ¶
type ProjectMatch ¶
type ProjectMatch struct {
Name string // The existing project name
MatchType string // "case-insensitive", "substring", or "levenshtein"
Distance int // Levenshtein distance (0 for case-insensitive and substring matches)
}
ProjectMatch represents a project name that is similar to a query string.
func FindSimilar ¶
func FindSimilar(name string, existing []string, maxDistance int) []ProjectMatch
FindSimilar finds projects similar to the given name from a list of existing project names. Similarity is determined by three criteria:
- Case-insensitive exact match (different case, same letters)
- Substring containment (query is a substring of candidate or vice-versa)
- Levenshtein distance ≤ maxDistance
Exact matches (identical strings) are always excluded.
Results are ordered: case-insensitive matches first, then substring matches, then levenshtein matches sorted by distance ascending.