From 452b0fda86f4982dff0791e5143334cdc85a8ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Tue, 3 Feb 2026 18:45:50 +0100 Subject: [PATCH] feat: enable file indexing by default File indexing only adds ~3 seconds to the indexing process, so enable it by default to make the get_file tool work out of the box. - MCP index_revision tool now indexes files automatically - CLI flag changed from --files to --no-files (opt-out) - Update README examples Co-Authored-By: Claude Opus 4.5 --- README.md | 6 +++--- cmd/nixos-options/main.go | 6 +++--- internal/mcp/handlers.go | 7 +++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 88f55ec..02dd4b7 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,14 @@ nixos-options serve **Index a nixpkgs revision:** ```bash -# Index by channel name +# Index by channel name (includes file contents by default) nixos-options index nixos-unstable # Index by git hash nixos-options index e6eae2ee2110f3d31110d5c222cd395303343b08 -# Index with file contents (enables get_file tool, slower) -nixos-options index --files nixos-unstable +# Index without file contents (faster, disables get_file tool) +nixos-options index --no-files nixos-unstable ``` **List indexed revisions:** diff --git a/cmd/nixos-options/main.go b/cmd/nixos-options/main.go index d36fb1b..7b893a6 100644 --- a/cmd/nixos-options/main.go +++ b/cmd/nixos-options/main.go @@ -43,15 +43,15 @@ func main() { ArgsUsage: "", Flags: []cli.Flag{ &cli.BoolFlag{ - Name: "files", - Usage: "Also index file contents (slower, enables get_file tool)", + Name: "no-files", + Usage: "Skip indexing file contents (faster, disables get_file tool)", }, }, Action: func(c *cli.Context) error { if c.NArg() < 1 { return fmt.Errorf("revision argument required") } - return runIndex(c, c.Args().First(), c.Bool("files")) + return runIndex(c, c.Args().First(), !c.Bool("no-files")) }, }, { diff --git a/internal/mcp/handlers.go b/internal/mcp/handlers.go index 0dc82ec..0761cb1 100644 --- a/internal/mcp/handlers.go +++ b/internal/mcp/handlers.go @@ -217,12 +217,19 @@ func (s *Server) makeIndexHandler(indexer *nixos.Indexer) ToolHandler { return ErrorContent(fmt.Errorf("indexing failed: %w", err)), nil } + // Index files by default + fileCount, err := indexer.IndexFiles(ctx, result.Revision.ID, result.Revision.GitHash) + if err != nil { + s.logger.Printf("Warning: file indexing failed: %v", err) + } + var sb strings.Builder sb.WriteString(fmt.Sprintf("Indexed revision: %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("Files: %d\n", fileCount)) sb.WriteString(fmt.Sprintf("Duration: %s\n", result.Duration.Round(time.Millisecond))) return CallToolResult{