Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions internal/cli/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"strings"

"github.com/HartBrook/staghorn/internal/cache"
"github.com/HartBrook/staghorn/internal/commands"
"github.com/HartBrook/staghorn/internal/config"
"github.com/HartBrook/staghorn/internal/github"
"github.com/HartBrook/staghorn/internal/language"
"github.com/HartBrook/staghorn/internal/merge"
"github.com/HartBrook/staghorn/internal/optimize"
"github.com/HartBrook/staghorn/internal/skills"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -271,6 +273,42 @@ func showCompactStatus(cfg *config.Config, paths *config.Paths, owner, repo stri
langStatus = strings.Join(activeLanguages, ", ")
}

// Commands count
cmdRegistry, _ := loadCommandRegistryForInfo(paths, owner, repo, projectRoot)
cmdStatus := dim("none")
if cmdRegistry != nil && cmdRegistry.Count() > 0 {
counts := cmdRegistry.CountBySource()
var parts []string
if counts[commands.SourceTeam] > 0 {
parts = append(parts, fmt.Sprintf("%d team", counts[commands.SourceTeam]))
}
if counts[commands.SourcePersonal] > 0 {
parts = append(parts, fmt.Sprintf("%d personal", counts[commands.SourcePersonal]))
}
if counts[commands.SourceProject] > 0 {
parts = append(parts, fmt.Sprintf("%d project", counts[commands.SourceProject]))
}
cmdStatus = fmt.Sprintf("%d (%s)", cmdRegistry.Count(), strings.Join(parts, ", "))
}

// Skills count
skillRegistry, _ := loadSkillRegistryForInfo(paths, owner, repo, projectRoot)
skillStatus := dim("none")
if skillRegistry != nil && skillRegistry.Count() > 0 {
counts := skillRegistry.CountBySource()
var parts []string
if counts[skills.SourceTeam] > 0 {
parts = append(parts, fmt.Sprintf("%d team", counts[skills.SourceTeam]))
}
if counts[skills.SourcePersonal] > 0 {
parts = append(parts, fmt.Sprintf("%d personal", counts[skills.SourcePersonal]))
}
if counts[skills.SourceProject] > 0 {
parts = append(parts, fmt.Sprintf("%d project", counts[skills.SourceProject]))
}
skillStatus = fmt.Sprintf("%d (%s)", skillRegistry.Count(), strings.Join(parts, ", "))
}

// Calculate merged token count
mergedTokens := calculateMergedTokens(cfg, paths, owner, repo, activeLanguages)
tokenStatus := fmt.Sprintf("%d tokens", mergedTokens)
Expand All @@ -283,6 +321,8 @@ func showCompactStatus(cfg *config.Config, paths *config.Paths, owner, repo stri
fmt.Printf(" %s: %s\n", dim("Personal"), personalStatus)
fmt.Printf(" %s: %s\n", dim("Project"), projectStatus)
fmt.Printf(" %s: %s\n", dim("Languages"), langStatus)
fmt.Printf(" %s: %s\n", dim("Commands"), cmdStatus)
fmt.Printf(" %s: %s\n", dim("Skills"), skillStatus)
fmt.Printf(" %s: %s\n", dim("Size"), tokenStatus)

// Suggest optimization if large
Expand Down Expand Up @@ -470,3 +510,23 @@ func calculateMergedTokens(cfg *config.Config, paths *config.Paths, owner, repo
merged := merge.MergeWithLanguages(layers, mergeOpts)
return optimize.CountTokens(merged)
}

// loadCommandRegistryForInfo loads commands from all sources for info display.
func loadCommandRegistryForInfo(paths *config.Paths, owner, repo, projectRoot string) (*commands.Registry, error) {
teamCommandsDir := paths.TeamCommandsDir(owner, repo)
projectCommandsDir := ""
if projectRoot != "" {
projectCommandsDir = config.ProjectCommandsDir(projectRoot)
}
return commands.LoadRegistry(teamCommandsDir, paths.PersonalCommands, projectCommandsDir)
}

// loadSkillRegistryForInfo loads skills from all sources for info display.
func loadSkillRegistryForInfo(paths *config.Paths, owner, repo, projectRoot string) (*skills.Registry, error) {
teamSkillsDir := paths.TeamSkillsDir(owner, repo)
projectSkillsDir := ""
if projectRoot != "" {
projectSkillsDir = config.ProjectSkillsDir(projectRoot)
}
return skills.LoadRegistry(teamSkillsDir, paths.PersonalSkills, projectSkillsDir)
}
1 change: 1 addition & 0 deletions internal/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ configs on top, and outputs a merged file for Claude to consume.`,
rootCmd.AddCommand(NewCommandsCmd())
rootCmd.AddCommand(NewRunCmd())
rootCmd.AddCommand(NewLanguagesCmd())
rootCmd.AddCommand(NewSkillsCmd())
rootCmd.AddCommand(NewTeamCmd())
rootCmd.AddCommand(NewEvalCmd())
rootCmd.AddCommand(NewVersionCmd())
Expand Down
Loading