feat: skip already-indexed revisions, add --force flag
When indexing a revision that already exists, the indexer now returns early with information about the existing revision instead of re-indexing. Use the --force flag to re-index an existing revision. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -217,6 +217,20 @@ func (s *Server) makeIndexHandler(indexer *nixos.Indexer) ToolHandler {
|
||||
return ErrorContent(fmt.Errorf("indexing failed: %w", err)), nil
|
||||
}
|
||||
|
||||
// If already indexed, return early with info
|
||||
if result.AlreadyIndexed {
|
||||
var sb strings.Builder
|
||||
sb.WriteString(fmt.Sprintf("Revision already indexed: %s\n", result.Revision.GitHash))
|
||||
if result.Revision.ChannelName != "" {
|
||||
sb.WriteString(fmt.Sprintf("Channel: %s\n", result.Revision.ChannelName))
|
||||
}
|
||||
sb.WriteString(fmt.Sprintf("Options: %d\n", result.OptionCount))
|
||||
sb.WriteString(fmt.Sprintf("Indexed at: %s\n", result.Revision.IndexedAt.Format("2006-01-02 15:04")))
|
||||
return CallToolResult{
|
||||
Content: []Content{TextContent(sb.String())},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Index files by default
|
||||
fileCount, err := indexer.IndexFiles(ctx, result.Revision.ID, result.Revision.GitHash)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user