project

package
v1.12.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 6 Imported by: 0

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

func DetectProject(dir string) string

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:

  1. Case-insensitive exact match (different case, same letters)
  2. Substring containment (query is a substring of candidate or vice-versa)
  3. 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.

Jump to

Keyboard shortcuts

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