mirror of
https://github.com/lukaszraczylo/filepuff-mcp.git
synced 2026-10-16 05:37:54 +00:00
feat(docs, ci, config): add comprehensive documentation and tooling
- [x] Add API reference documentation with tool descriptions and examples - [x] Add ERROR_CODES reference with error descriptions and remediation steps - [x] Add PERFORMANCE tuning guide with caching and optimization details - [x] Add GitHub Actions workflows for linting and security scanning - [x] Add golangci-lint configuration with comprehensive linter settings - [x] Add pre-commit hooks configuration for local development - [x] Add API documentation generator tool (cmd/docgen) - [x] Update Go version from 1.24 to 1.25 across workflows - [x] Add static build configuration to goreleaser - [x] Add metrics package with Prometheus-style metric types - [x] Add parser benchmarks for performance testing - [x] Add LSP manager integration tests - [x] Add server integration tests with MCP protocol flow testing - [x] Extract regex cache to shared utility package - [x] Add context cancellation handling in AST queries - [x] Add graceful shutdown with timeout to server - [x] Add configurable max parse size (MaxParseSize) - [x] Add Config.Validate() method with comprehensive checks - [x] Add parser cache statistics tracking - [x] Add file permission preservation in edit operations - [x] Improve line splitting for large files with bufio.Scanner - [x] Add comprehensive config tests for edge cases - [x] Update Makefile with new targets and documentation
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -17,6 +18,7 @@ type Config struct {
|
||||
LSPTimeout time.Duration `json:"lsp_timeout"`
|
||||
SearchTimeout time.Duration `json:"search_timeout"`
|
||||
MaxFileSize int64 `json:"max_file_size"`
|
||||
MaxParseSize int64 `json:"max_parse_size"`
|
||||
MaxSearchResults int `json:"max_search_results"`
|
||||
MaxEditSize int64 `json:"max_edit_size"`
|
||||
EnableLSP bool `json:"enable_lsp"`
|
||||
@@ -29,6 +31,7 @@ const (
|
||||
DefaultLSPTimeout = 5 * time.Minute
|
||||
DefaultSearchTimeout = 30 * time.Second
|
||||
DefaultMaxFileSize = 10 * 1024 * 1024 // 10 MB
|
||||
DefaultMaxParseSize = 10 * 1024 * 1024 // 10 MB
|
||||
DefaultMaxSearchResults = 1000
|
||||
DefaultMaxEditSize = 100 * 1024 // 100 KB
|
||||
)
|
||||
@@ -40,6 +43,7 @@ func Default() *Config {
|
||||
LSPTimeout: DefaultLSPTimeout,
|
||||
SearchTimeout: DefaultSearchTimeout,
|
||||
MaxFileSize: DefaultMaxFileSize,
|
||||
MaxParseSize: DefaultMaxParseSize,
|
||||
MaxSearchResults: DefaultMaxSearchResults,
|
||||
MaxEditSize: DefaultMaxEditSize,
|
||||
EnableLSP: true,
|
||||
@@ -172,3 +176,41 @@ func (c *Config) IsPathAllowed(path string) bool {
|
||||
// Also reject empty relative path (which means it's the workspace root itself)
|
||||
return rel != "." && !strings.HasPrefix(rel, "..")
|
||||
}
|
||||
|
||||
// Validate validates the configuration and returns an error if invalid.
|
||||
// Checks include:
|
||||
// - MaxFileSize and MaxParseSize must be positive
|
||||
// - LSPTimeout must be positive
|
||||
// - WorkspaceRoot must exist (when not empty)
|
||||
func (c *Config) Validate() error {
|
||||
// Validate MaxFileSize
|
||||
if c.MaxFileSize <= 0 {
|
||||
return fmt.Errorf("max_file_size must be positive, got %d", c.MaxFileSize)
|
||||
}
|
||||
|
||||
// Validate MaxParseSize
|
||||
if c.MaxParseSize <= 0 {
|
||||
return fmt.Errorf("max_parse_size must be positive, got %d", c.MaxParseSize)
|
||||
}
|
||||
|
||||
// Validate LSPTimeout
|
||||
if c.LSPTimeout <= 0 {
|
||||
return fmt.Errorf("lsp_timeout must be positive, got %v", c.LSPTimeout)
|
||||
}
|
||||
|
||||
// Validate WorkspaceRoot exists
|
||||
if c.WorkspaceRoot != "" {
|
||||
info, err := os.Stat(c.WorkspaceRoot)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return fmt.Errorf("workspace_root does not exist: %s", c.WorkspaceRoot)
|
||||
}
|
||||
return fmt.Errorf("cannot access workspace_root: %w", err)
|
||||
}
|
||||
if !info.IsDir() {
|
||||
return fmt.Errorf("workspace_root is not a directory: %s", c.WorkspaceRoot)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user