Commit Graph

14 Commits

  • feat(api): integrate TokenStore for improved auth entry management
    Replaced file-based auth entry counting with `TokenStore`-backed implementation, enhancing flexibility and context-aware token management. Updated related logic to reflect this change.
  • fix(translator): resolve invalid function name errors by sanitizing Claude tool names
    This commit centralizes tool name sanitization in SanitizeFunctionName,
    applying character compliance, starting character rules, and length limits.
    It also fixes a regression in gemini_schema tests and preserves MCP-specific
    shortening logic while ensuring compliance.
    
    Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
  • fix(translator): address PR feedback for tool name sanitization
    - Pre-compile sanitization regex for better performance.
    - Optimize SanitizeFunctionName for conciseness and correctness.
    - Handle 64-char edge cases by truncating before prepending underscore.
    - Fix bug in Antigravity translator (incorrect join index).
    - Refactor Gemini translators to avoid redundant sanitization calls.
    - Add comprehensive unit tests including 64-char edge cases.
    
    Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
  • feat(translator): sanitize tool/function names for upstream provider compatibility
    Implemented SanitizeFunctionName utility to ensure Claude tool names meet
    Gemini/Upstream strict naming conventions (alphanumeric, starts with letter/underscore, max 64 chars).
    Applied sanitization to tool definitions and usage in all relevant translators.
    
    Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
  • refactor(util): Centralize auth directory path resolution
    Introduces a new utility function, `util.ResolveAuthDir`, to handle the normalization and resolution of the authentication directory path.
    
    Previously, the logic for expanding the tilde (~) to the user's home directory was implemented inline in `main.go`. This refactoring extracts that logic into a reusable function within the `util` package.
    
    The new `ResolveAuthDir` function is now used consistently across the application:
    - During initial server startup in `main.go`.
    - When counting authentication files in `util.CountAuthFiles`.
    - When the configuration is reloaded by the watcher.
    
    This change eliminates code duplication, improves consistency, and makes the path resolution logic more robust and maintainable.
  • chore(docs): add and refine package-level comments across modules
    - Added detailed package-level comments to improve documentation coverage.
    - Clarified parameter descriptions, return types, and functionality of exported methods across packages.
    - Enhanced overall code readability and API documentation consistency.
  • refactor: standardize constant naming and improve file-based auth handling
    - Renamed constants from uppercase to CamelCase for consistency.
    - Replaced redundant file-based auth handling logic with the new `util.CountAuthFiles` helper.
    - Fixed various error-handling inconsistencies and enhanced robustness in file operations.
    - Streamlined auth client reload logic in server and watcher components.
    - Applied minor code readability improvements across multiple packages.
  • Update internal module imports to use v5 package path
    - Updated all `github.com/luispater/CLIProxyAPI/internal/...` imports to point to `github.com/luispater/CLIProxyAPI/v5/internal/...`.
    - Adjusted `go.mod` to specify `module github.com/luispater/CLIProxyAPI/v5`.
  • Add dynamic log level adjustment and "type" field to auth files response
    - Introduced `SetLogLevel` utility function for unified log level management.
    - Updated dynamic log level handling across server and watcher components.
    - Extended auth files response by extracting and including the `type` field from file content.
    - Updated management API documentation with the new `type` field in auth files response.