# pull_requests

title: Runtime Web Search Control via Command-Line Flag
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1568
merged_at: 2025-07-04 06:56:35+00:00
created_at: 2025-07-16 04:25:34
body:
  # Runtime Web Search Control via Command-Line Flag

  ## Summary

  This PR adds comprehensive web search tool support to the Fabric CLI application, building on the existing support for Anthropic's Claude models.

  The changes introduce new command-line flags for enabling web search functionality and location-based search results while refactoring the Anthropic plugin to use a runtime configuration instead of a setup-time configuration.

  ## Files Changed

  ### `cli/flags.go`
  - Added two new CLI flags: `--search` (boolean) and `--search-location` (string)
  - Integrated the new flags into the `BuildChatOptions()` method to pass search configuration to the chat system

  ### `common/domain.go`
  - Extended `ChatOptions` struct with `Search` (bool) and `SearchLocation` (string) fields to support web search configuration

  ### `plugins/ai/anthropic/anthropic.go`
  - **Major refactoring**: Removed setup-time web search configuration (`UseWebTool` and `WebToolLocation` setup questions)
  - Modified `buildMessageParams()` to use runtime search options from `ChatOptions` instead of plugin configuration
  - Enhanced response processing to extract and format citations from web search results
  - Added citation deduplication logic and proper markdown formatting for sources

  ### `plugins/ai/anthropic/anthropic_test.go`
  - Added comprehensive test coverage for the new web search functionality
  - Tests cover scenarios with/without search enabled, location configuration, and citation formatting
  - Includes edge cases like citation deduplication

  ### `plugins/ai/dryrun/dryrun.go`
  - Updated to display search options in dry-run output for debugging purposes

  ### `plugins/plugin.go`
  - Minor cleanup: Removed unnecessary `return` statements in `FillEnvFileContent()` methods

  ## Code Changes

  ### Key Changes in Anthropic Plugin

  The most significant change is in the `buildMessageParams()` method:

  ```go
  // Before: Used plugin setup configuration
  if plugins.ParseBoolElseFalse(an.UseWebTool.Value) {

  // After: Uses runtime chat options
  if opts.Search {
  ```

  ### Citation Processing Enhancement

  Added sophisticated citation handling in the `Send()` method:

  ```go
  var textParts []string
  var citations []string
  citationMap := make(map[string]bool) // To avoid duplicate citations

  for _, block := range message.Content {
      if block.Type == "text" && block.Text != "" {
          textParts = append(textParts, block.Text)
          
          // Extract and deduplicate citations
          for _, citation := range block.Citations {
              if citation.Type == "web_search_result_location" {
                  citationKey := citation.URL + "|" + citation.Title
                  if !citationMap[citationKey] {
                      // Format citation with title, URL, and quoted text
                  }
              }
          }
      }
  }
  ```

  ## Reason for Changes

  1. **Improved User Experience**: Users can now enable web search on a per-request basis rather than requiring plugin reconfiguration
  2. **Runtime Flexibility**: Search settings can be controlled via CLI flags, making it easier to use in scripts and automation
  3. **Better Citation Handling**: Web search results now include properly formatted citations with source links
  4. **Cleaner Architecture**: Moved from setup-time configuration to runtime options, reducing plugin complexity

  ## Impact of Changes

  ### Positive Impacts
  - **Enhanced Functionality**: Claude models can now access real-time web information when needed
  - **Better Source Attribution**: Citations are automatically extracted and formatted for transparency
  - **Improved CLI Usability**: Simple flags enable/disable web search without plugin reconfiguration
  - **Backward Compatibility**: Existing usage patterns continue to work (search is disabled by default)

  ### Potential Concerns

  - **API Cost**: Web search may increase API usage costs for Anthropic calls - to be fair, this should be better now, since the user has to affirmatively use the `--search` flag (instead of setting it globally for all Anthropic provider calls).
  - **Response Time**: Web search requests take a bit longer to complete

  ## Test Plan

  The changes include comprehensive unit tests covering:

  1. **Basic Functionality**: Web search enabled/disabled scenarios
  2. **Location Configuration**: Proper time zone handling for search results
  3. **Citation Processing**: Extraction, formatting, and deduplication of citations
  4. **Edge Cases**: Empty citations, duplicate sources, malformed data

  ### Manual Testing Recommendations
  ```bash
  # Test basic web search
  fabric -m claude-sonnet-4-20250514 --search 'What is the latest news about AI?'

  # Test with location
  fabric -m claude-sonnet-4-20250514 --search --search-location "America/New_York" "What's the weather today?"

  # Test without search (default behavior)
  fabric -m claude-sonnet-4-20250514  "Explain quantum computing"
  ```

  ## Additional Notes

  - The web search tool is currently only supported for Anthropic's Claude models
  - Location parameter accepts timezone identifiers (e.g., 'America/Los_Angeles')
  - Citations are formatted as markdown links with quoted excerpts when available
  - The feature gracefully degrades when search is disabled or unavailable
  - Existing plugin configurations for web search are now ignored in favor of runtime options

  ### Breaking Changes

  - **Minor**: Anthropic plugin setup questions for web search are no longer used, but this doesn't break existing functionality since the feature now uses runtime configuration. Users will have to manually delete the unused `SEARCH_` related entries from their Fabric `~/.config/fabric/.env` files.

commits:
  [{"SHA":"d23222278731929cabf1367e676fcb892610c50b","Message":"feat: add web search tool support for Anthropic models\n\n## CHANGES\n\n- Add --search flag to enable web search\n- Add --search-location for timezone-based results\n- Pass search options through ChatOptions struct\n- Implement web search tool in Anthropic client\n- Format search citations with sources section\n- Add comprehensive tests for search functionality\n- Remove plugin-level web search configuration","Author":"Kayvan Sylvan"},{"SHA":"4bb090694b06a3b423e850c1fea048e0ba54f3d5","Message":"chore: update `formatOptions` to include search options display\n\n### CHANGES\n\n- Add search option status to `formatOptions`\n- Include `SearchLocation` in formatted output if specified","Author":"Kayvan Sylvan"},{"SHA":"5e6d4110fabe44124b13994f8dd125717c539cfb","Message":"refactor: extract web search tool constants in anthropic plugin\n\n## CHANGES\n\n- Add webSearchToolName constant for tool identification\n- Add webSearchToolType constant for tool versioning\n- Replace hardcoded string literals with named constants\n- Improve code maintainability through constant extraction","Author":"Kayvan Sylvan"},{"SHA":"da29b8e388d28be466bcd9920c1f9bce9d973a73","Message":"chore: remove unused web-search tool parameters for simplification\n\n### CHANGES\n\n- Remove unused `AllowedDomains` and `MaxUses` parameters\n- Simplify `webTool` definition in `buildMessageParams` method","Author":"Kayvan Sylvan"},{"SHA":"d9b8bc32339536871aa903b9d5f198f8d2e00fcf","Message":"chore: refactor `Send` method to optimize string building\n\n### CHANGES\n\n- Add `sourcesHeader` constant for citation section title.\n- Use `strings.Builder` to construct result efficiently.\n- Append sources header and citations in result builder.\n- Update `ret` to use constructed string from builder.","Author":"Kayvan Sylvan"}]


title: OpenAI Plugin Now Supports Web Search Functionality
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1569
merged_at: 2025-07-04 07:24:33+00:00
created_at: 2025-07-16 04:25:34
body:
  # OpenAI Plugin Now Supports Web Search Functionality

  ## Summary

  This pull request adds web search functionality to the OpenAI plugin, expanding the existing search capability beyond Anthropic models to include OpenAI models. The implementation includes proper citation handling and formatting for search results.

  ## Screenshots

  These are both using `gpt-4o` as the default model

  ### Before Change

  ![image](https://github.com/user-attachments/assets/0c5b7bcf-9359-488c-9557-494ccafa68d7)

  ### After Change

  ![image](https://github.com/user-attachments/assets/6d08f269-4bbe-4e5b-8207-aa51721b1d9a)

  ## Files Changed

  ### `cli/flags.go`
  - **Modified**: Updated the description for the `Search` flag to reflect that it now supports both Anthropic and OpenAI models

  ### `plugins/ai/openai/openai.go`
  - **Modified**: Added web search tool integration and citation extraction functionality
  - **Added**: Import for `fmt` package to support citation formatting
  - **Enhanced**: `buildResponseParams` method to include web search tool when enabled
  - **Enhanced**: `extractText` method to parse and format citations from search results

  ### `plugins/ai/openai/openai_test.go`
  - **Modified**: Added comprehensive test coverage for the new web search functionality
  - **Added**: Imports for `strings` and `responses` packages
  - **Added**: Multiple test functions covering search scenarios and citation formatting

  ## Code Changes

  ### Web Search Tool Integration

  The `buildResponseParams` method now includes web search tool configuration:

  ```go
  // Add web search tool if enabled
  if opts.Search {
      webSearchTool := responses.ToolParamOfWebSearchPreview("web_search_preview")

      // Add user location if provided
      if opts.SearchLocation != "" {
          webSearchTool.OfWebSearchPreview.UserLocation = responses.WebSearchToolUserLocationParam{
              Type:     "approximate",
              Timezone: openai.String(opts.SearchLocation),
          }
      }

      ret.Tools = []responses.ToolUnionParam{webSearchTool}
  }
  ```

  ### Citation Extraction and Formatting

  The `extractText` method has been significantly enhanced to handle citations:

  ```go
  func (o *Client) extractText(resp *responses.Response) (ret string) {
      var textParts []string
      var citations []string
      citationMap := make(map[string]bool) // To avoid duplicate citations

      // Extract text and citations from response
      // Format citations as markdown links under "Sources" section
  }
  ```

  ## Reason for Changes

  This enhancement brings feature parity between the Anthropic and OpenAI plugins by adding web search capabilities to OpenAI models. The implementation allows users to leverage real-time web search results when using OpenAI models, with proper citation formatting for transparency and reference.

  ## Impact of Changes

  ### Positive Impacts
  - **Feature Parity**: OpenAI users now have access to web search functionality previously only available with Anthropic models
  - **Enhanced User Experience**: Search results include properly formatted citations for easy reference
  - **Location Awareness**: Users can specify search location for more relevant results
  - **Duplicate Prevention**: Citation deduplication ensures clean, readable output

  ### Potential Risks
  - **API Compatibility**: The implementation relies on OpenAI's web search preview feature, which may change or be deprecated
  - **Response Parsing**: The citation extraction logic assumes specific response structure from OpenAI's API
  - **Performance**: Additional processing for citation extraction may slightly impact response time

  ## Test Plan

  The changes include comprehensive test coverage:

  1. **Unit Tests**: Test web search tool configuration with and without location parameters
  2. **Citation Tests**: Verify proper citation extraction, formatting, and deduplication
  3. **Integration Tests**: Ensure backward compatibility when search is disabled
  4. **Edge Cases**: Test handling of duplicate citations and empty citation lists

  Run the test suite with:
  ```bash
  go test ./plugins/ai/openai/...
  ```

  ## Additional Notes

  - The web search feature uses OpenAI's preview API, which may require specific API access or model versions
  - Citation formatting follows markdown standards for consistency with existing output
  - The implementation maintains backward compatibility - existing functionality remains unchanged when search is disabled
  - Error handling for malformed citations or API responses should be monitored in production use

  **Breaking Changes**: None - all changes are additive and backward compatible.

  **Dependencies**: Requires OpenAI Go SDK with web search preview support.

commits:
  [{"SHA":"50aec6291b4e3a8c8d4274bf3ae7b55363744a57","Message":"feat: add web search tool support for OpenAI models with citation formatting\n\n## CHANGES\n\n- Enable web search tool for OpenAI models\n- Add location parameter support for search results\n- Extract and format citations from search responses\n- Implement citation deduplication to avoid duplicates\n- Add comprehensive test coverage for search functionality\n- Update CLI flag description to include OpenAI\n- Format citations as markdown links with sources","Author":"Kayvan Sylvan"},{"SHA":"bd809a1f94d3e4bf6c69b99a16b8ddaa1b97eb6c","Message":"docs: update README with new web search feature details","Author":"Kayvan Sylvan"}]


title: Add Image Generation Support to Fabric
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1572
merged_at: 2025-07-04 22:38:27+00:00
created_at: 2025-07-16 04:25:34
body:
  # Add Image Generation Support to Fabric

  ## Summary

  This PR adds comprehensive image generation capabilities to the Fabric framework, enabling users to generate images using OpenAI's image generation models through the new `--image-file` flag. The implementation includes proper integration with the existing tool system and maintains compatibility with other features like web search.

  ## Related Issues

  Closes #1551 

  ## Files Changed

  ### Documentation Updates
  - **README.md**: Updated documentation to reflect new image generation features, fixed HTML formatting issues, and improved PowerShell code block indentation
  - **completions/_fabric**: Added zsh completion support for the new `--image-file` flag
  - **completions/fabric.bash**: Added bash completion support for image generation flag
  - **completions/fabric.fish**: Added fish shell completion support for image generation functionality
  - Note: Also added `--search` and `--search-location` flags to the completions scripts.

  ### Core Implementation
  - **cli/flags.go**: Added `ImageFile` flag definition and integrated it into the chat options builder
  - **common/domain.go**: Extended `ChatOptions` struct to include `ImageFile` field
  - **plugins/ai/dryrun/dryrun.go**: Added image file option to dry-run output formatting
  - **plugins/ai/openai/openai.go**: Enhanced request building to support image generation tools
  - **plugins/ai/openai/openai_image.go**: New file containing all image generation logic
  - **plugins/ai/openai/openai_image_test.go**: Comprehensive test suite for image generation functionality

  ## Code Changes

  ### New Image Generation Flag
  ```go
  ImageFile string `long:"image-file" description:"Save generated image to specified file path (e.g., 'output.png')"`
  ```

  ### Image Generation Tool Integration
  The implementation adds an image generation tool to the OpenAI responses API when the `--image-file` flag is present:

  ```go
  imageGenTool := responses.ToolUnionParam{
      OfImageGeneration: &responses.ToolImageGenerationParam{
          Type:         ImageGenerationToolType,
          Model:        "gpt-image-1",
          OutputFormat: "png",
          Quality:      "auto",
          Size:         "auto",
      },
  }
  ```

  ### Image Processing and Saving
  The system automatically extracts generated images from API responses and saves them to the specified file path:

  ```go
  func (o *Client) extractAndSaveImages(resp *responses.Response, opts *common.ChatOptions) error
  ```

  ## Reason for Changes

  This enhancement addresses user requests for integrated image generation capabilities within the Fabric framework. By adding this functionality, users can now:

  1. Generate images directly from text prompts using the `--image-file` flag
  2. Combine image generation with other tools like web search
  3. Save generated images to specified file paths automatically
  4. Use image generation alongside existing Fabric patterns and workflows

  ## Impact of Changes

  ### Positive Impacts
  - **Enhanced Functionality**: Users can now generate images as part of their AI workflows
  - **Seamless Integration**: Image generation works alongside existing features like web search and patterns
  - **Improved User Experience**: Automatic image saving eliminates manual handling of generated content
  - **Comprehensive Shell Support**: All major shells (bash, zsh, fish) have completion support for the new flag

  ### Potential Considerations
  - **API Costs**: Image generation may incur additional costs from OpenAI
  - **File System Dependencies**: The implementation creates directories and writes files, requiring appropriate permissions
  - **Error Handling**: Base64 decoding and file operations could fail in edge cases

  ## Test Plan

  The implementation includes unit tests covering:

  1. **Tool Selection Logic**: Tests verify that image generation tools are added only when appropriate
  2. **Parameter Building**: Ensures request parameters are correctly constructed with image generation tools
  3. **Multi-tool Integration**: Validates that image generation works alongside web search
  4. **Edge Cases: The behavior when no image file is specified is to use normal Fabric flows.

  ### Screenshots

  ![image](https://github.com/user-attachments/assets/5b491e96-5f8a-4214-ae48-4b2dfbdb6ac9)


  ## Additional Notes

  - The implementation uses OpenAI's `gpt-image-1` model for image generation
  - Images are saved in PNG format by default with automatic quality settings
  - The feature is automatically enabled when the `--image-file` flag is provided
  - Directory creation is handled automatically if the specified path doesn't exist
  - The implementation maintains backward compatibility with existing functionality

commits:
  [{"SHA":"12fc6e2000cf6c6ca3d40b52c4b085aa8994ed8d","Message":"feat: add image generation support with OpenAI image generation model\n\n## CHANGES\n\n- Add `--image-file` flag for saving generated images\n- Implement image generation tool integration with OpenAI\n- Support image editing with attachment input files\n- Add comprehensive test coverage for image features\n- Update documentation with image generation examples\n- Fix HTML formatting issues in README\n- Improve PowerShell code block indentation\n- Clean up help text formatting and spacing","Author":"Kayvan Sylvan"},{"SHA":"63a0cfeb1e04f3aad0e11f8b5dd003b2b0701008","Message":"feat: add web search and image file support to fabric CLI\n\n## CHANGES\n\n- Add web search tool for Anthropic and OpenAI models\n- Add search location parameter for web search results\n- Add image file output option with format support\n- Update zsh completion with new search and image flags\n- Update bash completion with new option handling logic\n- Update fish completion with search and image descriptions\n- Support PNG, JPG, JPEG, GIF, BMP image formats","Author":"Kayvan Sylvan"},{"SHA":"d9260bdf26b65b2e1c15b6c8aa40b7a4c3610081","Message":"chore: refactor image generation constants for clarity and reuse\n\n### CHANGES\n\n- Define `ImageGenerationResponseType` constant for response handling\n- Define `ImageGenerationToolType` constant for tool type usage\n- Update `addImageGenerationTool` to use defined constants\n- Refactor `extractAndSaveImages` to use response type constant","Author":"Kayvan Sylvan"}]


title: Add Image File Validation and Dynamic Format Support
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1573
merged_at: 2025-07-05 01:11:36+00:00
created_at: 2025-07-16 04:25:34
body:
  # Add Image File Validation and Dynamic Format Support

  ## Summary

  This PR introduces comprehensive image file validation and dynamic format detection for the image generation feature. The changes ensure that image files are properly validated before processing and that the output format matches the specified file extension.

  Extension of #1572 

  ## Screenshots

  ![image](https://github.com/user-attachments/assets/570d69ae-8db2-4b31-91f9-00052cba5bbc)


  ## Files Changed

  ### `cli/cli.go`
  - Modified the `BuildChatOptions()` call to handle potential errors from validation
  - Added proper error handling for chat options construction

  ### `cli/flags.go`
  - Added `validateImageFile()` function to validate image file paths and extensions
  - Modified `BuildChatOptions()` to return an error and perform image file validation
  - Updated YAML import from `gopkg.in/yaml.v2` to `gopkg.in/yaml.v3`
  - Added `path/filepath` import for file extension handling

  ### `cli/flags_test.go`
  - Added comprehensive test coverage for `validateImageFile()` function
  - Updated existing tests to handle the new error return from `BuildChatOptions()`
  - Added tests for image file validation integration

  ### `plugins/ai/openai/openai_image.go`
  - Added `getOutputFormatFromExtension()` function to dynamically determine output format
  - Modified `addImageGenerationTool()` to use dynamic format detection based on file extension
  - Added support for PNG, WEBP, JPG, and JPEG formats

  ### `plugins/ai/openai/openai_image_test.go`
  - Added comprehensive test coverage for format detection functionality
  - Added tests for dynamic format selection in image generation tools

  ### Shell completion files
  - Updated `completions/_fabric` and `completions/fabric.fish` to reflect supported image formats
  - Removed unsupported formats (GIF, BMP) and added WEBP support

  ### Dependencies
  - Updated `go.mod` and `go.sum` to remove `gopkg.in/yaml.v2` dependency
  - Consolidated on `gopkg.in/yaml.v3` for YAML processing

  ## Code Changes

  ### Key Validation Logic
  ```go
  func validateImageFile(imagePath string) error {
      if imagePath == "" {
          return nil // No validation needed if no image file specified
      }

      // Check if file already exists
      if _, err := os.Stat(imagePath); err == nil {
          return fmt.Errorf("image file already exists: %s", imagePath)
      }

      // Check file extension
      ext := strings.ToLower(filepath.Ext(imagePath))
      validExtensions := []string{".png", ".jpeg", ".jpg", ".webp"}
      // ... validation logic
  }
  ```

  ### Dynamic Format Detection
  ```go
  func getOutputFormatFromExtension(imagePath string) string {
      ext := strings.ToLower(filepath.Ext(imagePath))
      switch ext {
      case ".png": return "png"
      case ".webp": return "webp"
      case ".jpg", ".jpeg": return "jpeg"
      default: return "png" // Default fallback
      }
  }
  ```

  ## Reason for Changes

  1. **File Validation**: Prevents overwriting existing files and ensures only supported image formats are used
  2. **Dynamic Format Detection**: Automatically selects the appropriate API output format based on the requested file extension
  3. **Error Handling**: Provides clear error messages when validation fails
  4. **Dependency Cleanup**: Consolidates YAML processing on a single version

  ## Impact of Changes

  ### Positive Impacts
  - **Improved User Experience**: Clear error messages for invalid file paths or unsupported formats
  - **Data Protection**: Prevents accidental file overwrites
  - **Format Consistency**: Output format matches user expectations based on file extension
  - **Better Error Handling**: Graceful handling of validation failures

  ### Potential Issues
  - **Breaking Change**: `BuildChatOptions()` now returns an error, requiring updates to calling code
  - **Stricter Validation**: Users may encounter new validation errors for previously accepted inputs
  - **File Existence Check**: May cause issues in scenarios where checking file existence is not desired

  ## Test Plan

  The changes include comprehensive test coverage:

  1. **Unit Tests**: All new functions have corresponding unit tests
  2. **Integration Tests**: Tests verify the integration between validation and chat options building
  3. **Edge Cases**: Tests cover empty paths, invalid extensions, existing files, and case sensitivity
  4. **Regression Tests**: Existing functionality is tested to ensure no regressions

  ### Test Coverage Areas
  - Image file validation with various extensions
  - File existence checking
  - Format detection accuracy
  - Error message clarity
  - Integration with existing chat options

  ## Additional Notes

  - The validation is performed early in the process to fail fast on invalid inputs
  - Supported formats are limited to PNG, JPEG, JPG, and WEBP as these are commonly supported by image generation APIs
  - The default format fallback is PNG for maximum compatibility
  - Shell completion files have been updated to reflect the actual supported formats
  - A test image file (`mars-colony.png`) appears to have been added, likely for testing purposes

commits:
  [{"SHA":"e59156ac2b3d7ae610ce1eef05b67ffbf8373162","Message":"feat: add image file validation and format detection for image generation\n\n## CHANGES\n\n• Add image file path validation with extension checking\n• Implement dynamic output format detection from file extensions\n• Update BuildChatOptions method to return error for validation\n• Add comprehensive test coverage for image file validation\n• Upgrade YAML library from v2 to v3\n• Update shell completions to reflect supported image formats\n• Add error handling for existing file conflicts\n• Support PNG, JPEG, JPG, and WEBP image formats","Author":"Kayvan Sylvan"}]


title: Add Model Validation for Image Generation and Fix CLI Flag Mapping
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1574
merged_at: 2025-07-05 01:57:51+00:00
created_at: 2025-07-16 04:25:34
body:
  # Add Model Validation for Image Generation and Fix CLI Flag Mapping

  ## Summary

  This pull request adds model validation for image generation capabilities and fixes a missing model field mapping in the CLI flags. The changes ensure that users receive clear error messages when attempting to use image generation with unsupported models, and that the model parameter is properly passed through the CLI interface.

  ## Files Changed

  - **cli/flags.go**: Added missing `Model` field mapping in `BuildChatOptions()`
  - **plugins/ai/openai/openai.go**: Added model validation for image generation requests
  - **plugins/ai/openai/openai_image.go**: Added model support validation logic and constants
  - **plugins/ai/openai/openai_image_test.go**: Added comprehensive test coverage for model validation
  - **mars-colony.png**: Removed unused binary file

  ## Code Changes

  ### CLI Flag Mapping Fix
  ```go
  ret = &common.ChatOptions{
  +   Model:              o.Model,
      Temperature:        o.Temperature,
      TopP:               o.TopP,
      PresencePenalty:    o.PresencePenalty,
  ```

  ### Model Validation Logic
  ```go
  // Validate model supports image generation if image file is specified
  if opts.ImageFile != "" && !supportsImageGeneration(opts.Model) {
      return "", fmt.Errorf("model '%s' does not support image generation. Supported models: %s", opts.Model, strings.Join(ImageGenerationSupportedModels, ", "))
  }
  ```

  ### Supported Models Definition
  ```go
  var ImageGenerationSupportedModels = []string{
      "gpt-4o",
      "gpt-4o-mini", 
      "gpt-4.1",
      "gpt-4.1-mini",
      "gpt-4.1-nano",
      "o3",
  }
  ```

  ## Reason for Changes

  1. **CLI Bug Fix**: The `Model` field was not being mapped from CLI flags to `ChatOptions`, causing the model parameter to be ignored when specified via command line
  2. **User Experience**: Users were encountering cryptic errors when trying to use image generation with unsupported models (like o1-mini, o3-mini)
  3. **Error Prevention**: Proactive validation prevents API calls that would fail, saving time and API quota
  4. **Code Cleanup**: Removed unused binary asset file

  ## Impact of Changes

  **Positive Impacts:**
  - Users get clear, actionable error messages when using unsupported models for image generation
  - CLI model parameter now works correctly across all functionality
  - Prevents unnecessary API calls for unsupported operations
  - Improved code maintainability with centralized model support definitions

  **Potential Risks:**
  - Model support list needs to be maintained as OpenAI adds/removes model capabilities
  - Validation logic could become outdated if OpenAI changes model capabilities without notice
  - Hard-coded model list may not reflect real-time API capabilities

  ## Test Plan

  The changes include comprehensive test coverage:
  - Unit tests for `supportsImageGeneration()` function with all supported and unsupported models
  - Integration tests for validation logic with different model/image file combinations
  - Edge case testing for empty models and missing image files

  **Manual Testing:**
  1. Test CLI with `--model` flag to ensure it's properly passed through
  2. Test image generation with supported models (gpt-4o, gpt-4o-mini, etc.)
  3. Test image generation with unsupported models (o1-mini, gpt-4, etc.) to verify error messages
  4. Test normal chat functionality without image generation to ensure no regression

  ## Additional Notes

  - The model support list is based on current OpenAI API capabilities as of the implementation date
  - The validation only triggers when both a model is specified AND an image file is provided
  - Error messages include the full list of supported models to guide users toward valid options
  - The removed `mars-colony.png` file appears to be an unused test asset and its removal should not impact functionality

  **Future Considerations:**
  - Consider implementing dynamic model capability detection via OpenAI API
  - Monitor OpenAI model releases to keep the supported models list current
  - Consider adding configuration file support for model capabilities to allow easier updates

commits:
  [{"SHA":"86a044735b93fae4b8d0019896457556b8be1026","Message":"feat: add model validation for image generation support\n\n### CHANGES\n\n- Add model field to `BuildChatOptions` method\n- Implement `supportsImageGeneration` function for model checks\n- Validate model supports image generation in `sendResponses`\n- Remove `mars-colony.png` from repository\n- Add tests for `supportsImageGeneration` function\n- Validate image file support in `TestModelValidationLogic`","Author":"Kayvan Sylvan"},{"SHA":"ad4683952e029528ec342c207aee08333372b1d6","Message":"Merge branch 'main' into 0704-image-tool-model-validation","Author":"Kayvan Sylvan"},{"SHA":"60174f41a4443bfaae234845f52a3ae7a5949dfc","Message":"refactor: extract supported models list to shared constant for image generation validation\n\n## CHANGES\n\n• Extract hardcoded model lists into shared constant\n• Create ImageGenerationSupportedModels variable for reusability\n• Update supportsImageGeneration function to use shared constant\n• Refactor error messages to reference centralized model list\n• Add documentation comment for supported models variable\n• Import strings package in test file\n• Consolidate duplicate model validation logic across files","Author":"Kayvan Sylvan"}]


title: Advanced image generation parameters for OpenAI models
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1575
merged_at: 2025-07-05 07:06:38+00:00
created_at: 2025-07-16 04:25:34
body:
  # Advanced image generation parameters for OpenAI models

  ## Summary

  This PR enhances Fabric's image generation capabilities by adding comprehensive control over image output parameters. The changes introduce four new command-line flags (`--image-size`, `--image-quality`, `--image-compression`, and `--image-background`) that allow users to fine-tune their generated images with proper validation and format-specific restrictions.

  ## Screenshots

  ### Completion scripts updated

  ![image](https://github.com/user-attachments/assets/ada759a5-8c94-4594-b20e-af647bfc9a64)

  ![image](https://github.com/user-attachments/assets/54b4bf5e-45db-4de5-8826-8330c79f5c6f)

  ### Example image generation: Landscape mode

  ![image](https://github.com/user-attachments/assets/36f69d24-1245-4fdd-a339-692906d2d252)


  ## Files Changed

  ### README.md
  - **Updated changelog**: Reorganized the July 4, 2025 release notes to better highlight the new image generation features with clearer formatting and bullet points
  - **Fixed PowerShell code formatting**: Corrected indentation issues in the PowerShell alias examples to improve readability
  - **Added new flag documentation**: Updated the help output section to include descriptions for all four new image parameter flags

  ### cli/flags.go
  - **Added new flag fields**: Introduced `ImageSize`, `ImageQuality`, `ImageCompression`, and `ImageBackground` fields to the `Flags` struct
  - **Implemented comprehensive validation**: Added `validateImageParameters()` function with format-specific validation logic
  - **Enhanced BuildChatOptions()**: Integrated the new validation and parameter passing to chat options

  ### cli/flags_test.go
  - **Added extensive test coverage**: Created 181 new lines of tests covering all validation scenarios, including edge cases, invalid inputs, and format-specific restrictions

  ### common/domain.go
  - **Extended ChatOptions struct**: Added the four new image parameter fields to support passing user preferences through the application

  ### Completion files (3 files)
  - **Updated shell completions**: Added autocompletion support for the new flags in Zsh, Bash, and Fish shells with appropriate value suggestions

  ### plugins/ai/openai/openai_image.go
  - **Enhanced image generation tool**: Modified `addImageGenerationTool()` to respect user-specified parameters instead of hardcoded defaults
  - **Added conditional parameter setting**: Only sets parameters when explicitly provided by the user, allowing OpenAI to use its defaults otherwise

  ### plugins/ai/openai/openai_image_test.go
  - **Added comprehensive parameter testing**: Created 107 new lines of tests to verify correct parameter handling in various scenarios

  ## Code Changes

  ### Key Validation Logic
  ```go
  func validateImageParameters(imagePath, size, quality, background string, compression int) error {
      if imagePath == "" {
          // Check if any image parameters are specified without --image-file
          if size != "" || quality != "" || background != "" || compression != 0 {
              return fmt.Errorf("image parameters can only be used with --image-file")
          }
          return nil
      }
      // ... format-specific validation logic
  }
  ```

  ### Enhanced Image Tool Configuration
  ```go
  // Set quality if specified by user (otherwise let OpenAI use default)
  if opts.ImageQuality != "" {
      imageGenTool.OfImageGeneration.Quality = opts.ImageQuality
  }
  ```

  ## Reason for Changes

  These changes address user requests for more granular control over image generation output. Previously, users could only specify the output file path, but had no control over image dimensions, quality, compression, or background transparency. This enhancement provides professional-grade image generation capabilities while maintaining backward compatibility.

  ## Impact of Changes

  ### Positive Impacts
  - **Enhanced user control**: Users can now specify exact image dimensions, quality levels, and output characteristics
  - **Format-aware validation**: Prevents invalid combinations (e.g., transparent backgrounds with JPEG)
  - **Backward compatibility**: Existing workflows continue to work unchanged
  - **Professional output**: Enables creation of images suitable for various use cases (web, print, etc.)

  ### Potential Risks
  - **Increased complexity**: More parameters mean more potential for user error
  - **Validation overhead**: Additional validation logic could impact performance minimally
  - **API dependency**: Relies on OpenAI's parameter support (though gracefully handles unsupported combinations)

  ## Test Plan

  The changes include comprehensive test coverage with 288 new lines of tests covering:
  - Parameter validation with and without image files
  - Format-specific restrictions (compression for JPEG/WebP only, transparency for PNG/WebP only)
  - Edge cases and invalid input handling
  - Integration with the existing chat options system
  - Shell completion functionality

  Manual testing should verify:
  1. Image generation with various parameter combinations
  2. Error messages for invalid parameter combinations
  3. Shell completion functionality in different environments
  4. Backward compatibility with existing image generation workflows

  ## Additional Notes

  ### Potential Bugs and Considerations

  1. **Parameter precedence**: The implementation allows OpenAI to use its defaults when parameters aren't specified, which may lead to inconsistent behavior if OpenAI changes their defaults
  2. **Compression validation**: The validation allows compression values of 0, which might be interpreted as "no compression" rather than "not set" in some contexts
  3. **File extension case sensitivity**: The validation uses `strings.ToLower()` but should be tested with various case combinations
  4. **Race conditions**: File existence checking in validation could theoretically have race conditions in concurrent environments

  The implementation follows Go best practices and maintains consistency with the existing codebase architecture. All new functionality is properly tested and documented.

commits:
  [{"SHA":"b2418984f832b6107cdd2272edd661982e79b833","Message":"feat: add advanced image generation parameters for OpenAI models\n\n## CHANGES\n\n- Add four new image generation CLI flags\n- Implement validation for image parameter combinations\n- Support size, quality, compression, and background controls\n- Add comprehensive test coverage for new parameters\n- Update shell completions for new image options\n- Enhance README with detailed image generation examples\n- Fix PowerShell code block formatting issues","Author":"Kayvan Sylvan"}]


title: Add Custom Patterns Directory Support
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1577
merged_at: 2025-07-06 07:20:58+00:00
created_at: 2025-07-16 04:25:34
body:
  # Add Custom Patterns Directory Support

  ## Summary

  This pull request adds support for custom patterns directories in the Fabric application, allowing users to specify an external directory for storing and loading custom patterns alongside the default patterns. The implementation includes proper plugin registration, environment variable support, and comprehensive test coverage.

  ## Related Issues

  Closes #1567 #1404 #972 #331

  ## Files Changed

  ### `core/plugin_registry.go`
  - Added import for the new `custom_patterns` plugin
  - Integrated `CustomPatterns` plugin into the registry structure
  - Added plugin to the setup flow and environment file management

  ### `plugins/db/fsdb/db.go`
  - Added support for `CUSTOM_PATTERNS_DIRECTORY` environment variable
  - Implemented home directory expansion for custom patterns path
  - Extended `PatternsEntity` to include custom patterns directory configuration

  ### `plugins/db/fsdb/patterns.go`
  - Modified `getFromDB()` to check custom patterns directory first before fallback to main patterns
  - Overrode `GetNames()` to include patterns from both main and custom directories
  - Added logic to handle custom patterns taking precedence over main patterns with the same name

  ### `plugins/db/fsdb/patterns_test.go`
  - Added comprehensive test coverage for custom patterns functionality
  - Tests cover pattern override behavior, directory precedence, and error handling

  ### `plugins/tools/custom_patterns/custom_patterns.go` (New)
  - Created new plugin for managing custom patterns directory configuration
  - Implements directory path validation, home directory expansion, and automatic directory creation
  - Provides setup interface for user configuration

  ### `plugins/tools/custom_patterns/custom_patterns_test.go` (New)
  - Complete test suite for the custom patterns plugin
  - Tests configuration, directory handling, and validation logic

  ## Code Changes

  ### Key Implementation Details

  The custom patterns functionality works by:

  1. **Plugin Registration**: The `CustomPatterns` plugin is registered in the main plugin registry and appears in the setup flow.

  2. **Directory Precedence**: When loading patterns, the system first checks the custom patterns directory, then falls back to the main patterns directory:
  ```go
  // First check custom patterns directory if it exists
  if o.CustomPatternsDir != "" {
      customPatternPath := filepath.Join(o.CustomPatternsDir, name, o.SystemPatternFile)
      if pattern, customErr := os.ReadFile(customPatternPath); customErr == nil {
          ret = &Pattern{
              Name:    name,
              Pattern: string(pattern),
          }
          return ret, nil
      }
  }
  ```

  3. **Pattern Discovery**: The `GetNames()` method combines patterns from both directories, with custom patterns taking precedence over main patterns with the same name.

  ## Reason for Changes

  This feature addresses the need for users to maintain their own custom patterns separate from the main Fabric patterns repository. It allows for:
  - Personal pattern libraries that persist across updates
  - Organization-specific patterns
  - Testing new patterns without modifying the main patterns directory
  - Easy sharing of custom patterns between team members

  ## Impact of Changes

  ### Positive Impacts
  - **Enhanced Flexibility**: Users can now maintain custom patterns without modifying the core Fabric installation
  - **Better Organization**: Separation of custom and default patterns
  - **Backward Compatibility**: Existing functionality remains unchanged for users who don't use custom patterns
  - **Override Capability**: Custom patterns can override default patterns with the same name

  ### Potential Considerations
  - **Pattern Name Conflicts**: Custom patterns will silently override main patterns with the same name
  - **Directory Management**: Users are responsible for managing their custom patterns directory structure
  - **Error Handling**: Invalid custom patterns directory paths are handled gracefully but may not provide detailed feedback

  ## Test Plan

  The implementation includes comprehensive unit tests covering:
  - Plugin initialization and configuration
  - Custom patterns directory setup and validation
  - Pattern loading precedence (custom over main)
  - Directory expansion and path handling
  - Error handling for invalid or missing directories
  - Integration with existing patterns functionality

  ### Manual Testing Recommendations
  1. Configure a custom patterns directory through the setup process
  2. Create patterns in both main and custom directories with the same name
  3. Verify custom patterns take precedence
  4. Test with various path formats (relative, absolute, home directory expansion)
  5. Verify environment variable `CUSTOM_PATTERNS_DIRECTORY` is respected

  ## Additional Notes

  - The implementation maintains full backward compatibility
  - Custom patterns directory is optional and the system works normally without it
  - The plugin follows the established patterns for other Fabric plugins
  - Error handling is defensive - invalid custom directories are ignored rather than causing failures
  - The feature integrates seamlessly with existing pattern management workflows

commits:
  [{"SHA":"b751d323b1c1dd1308a69ff269846c3e10532258","Message":"feat: add custom patterns directory support with environment variable configuration\n\n## CHANGES\n\n- Add custom patterns directory support via environment variable\n- Implement custom patterns plugin with registry integration\n- Override main patterns with custom directory patterns\n- Expand home directory paths in custom patterns config\n- Add comprehensive test coverage for custom patterns functionality\n- Integrate custom patterns into plugin setup workflow\n- Support pattern precedence with custom over main patterns","Author":"Kayvan Sylvan"}]


title: Document Custom Patterns Directory Support
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1578
merged_at: 2025-07-06 07:38:01+00:00
created_at: 2025-07-16 04:25:34
body:
  # Document Custom Patterns Directory Support

  ## Summary

  This PR introduces a dedicated custom patterns directory feature that allows users to create and manage personal patterns separately from Fabric's built-in patterns. The implementation provides a clean separation between user-created patterns and the core pattern library, ensuring custom patterns persist through updates.

  ## Files Changed

  - **README.md**: Updated documentation to reflect the new custom patterns functionality, replacing the previous manual workflow with an automated setup process.

  ## Code Changes

  The documentation changes include:

  1. **Enhanced Table of Contents**: Added three new subsections under "Custom Patterns":
     ```markdown
     - [Setting Up Custom Patterns](#setting-up-custom-patterns)
     - [Using Custom Patterns](#using-custom-patterns)
     - [How It Works](#how-it-works)
     ```

  2. **Replaced Manual Process**: The old documentation described a manual copy-paste workflow:
     ```markdown
     Just make a directory in `~/.config/custompatterns/` (or wherever) and put your `.md` files in there.
     When you're ready to use them, copy them into `~/.config/fabric/patterns/`
     ```

  3. **New Automated Setup**: Introduced setup command integration:
     ```bash
     fabric --setup
     ```

  4. **Clear Usage Instructions**: Added step-by-step pattern creation and usage examples with proper directory structure and command syntax.

  ## Reason for Changes

  This change addresses several pain points in the previous custom patterns workflow:

  - **Manual Management**: Users previously had to manually copy patterns between directories
  - **Update Conflicts**: Custom patterns could be overwritten during built-in pattern updates
  - **Poor User Experience**: The workflow was cumbersome and error-prone
  - **No Integration**: Custom patterns weren't properly integrated with Fabric's pattern discovery system

  ## Impact of Changes

  **Positive Impacts:**
  - **Improved User Experience**: Streamlined setup process through the `--setup` command
  - **Data Safety**: Custom patterns are protected from being overwritten during updates
  - **Better Organization**: Clear separation between built-in and custom patterns
  - **Enhanced Discoverability**: Custom patterns appear in `--listpatterns` output
  - **Priority System**: Custom patterns can override built-in patterns with the same name

  **Potential Considerations:**
  - **Migration Path**: Existing users with custom patterns in the old location may need guidance on migration
  - **Directory Management**: Users need to understand the new directory structure
  - **Pattern Naming**: Name conflicts between custom and built-in patterns are resolved by priority system

  ## Test Plan

  The documentation changes should be tested by:

  1. **Setup Process**: Verify the `fabric --setup` command correctly creates custom pattern directories
  2. **Pattern Creation**: Test creating custom patterns in the new directory structure
  3. **Pattern Discovery**: Confirm custom patterns appear in `--listpatterns` output
  4. **Pattern Execution**: Validate custom patterns can be executed with `--pattern` flag
  5. **Priority System**: Test that custom patterns override built-in patterns with identical names
  6. **Update Safety**: Verify `--updatepatterns` doesn't affect custom patterns

  ## Additional Notes

  - The documentation maintains backward compatibility information while promoting the new workflow
  - The feature appears to integrate with Fabric's existing setup system, suggesting minimal disruption to current users
  - The priority system design allows for pattern customization and extension of built-in functionality
  - This change positions Fabric for better extensibility and user customization in future releases

commits:
  [{"SHA":"16ac51941583602e713315902230b31f9071991d","Message":"docs: add comprehensive custom patterns setup and usage guide\n\n## CHANGES\n\n- Add custom patterns directory setup instructions\n- Document priority system for custom vs built-in patterns\n- Include step-by-step custom pattern creation workflow\n- Explain update-safe custom pattern storage\n- Add table of contents entries for new sections\n- Document seamless integration with existing fabric commands\n- Clarify privacy and precedence behavior for custom patterns","Author":"Kayvan Sylvan"}]


title: Alphabetical Pattern Sorting and Configuration Refactor
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1580
merged_at: 2025-07-06 08:35:19+00:00
created_at: 2025-07-16 04:25:34
body:
  # Alphabetical Pattern Sorting and Configuration Refactor

  ## Summary

  This PR refactors the custom patterns directory initialization in the filesystem database plugin to ensure proper loading order and adds alphabetical sorting to pattern names. The changes move the custom patterns directory setup from the constructor to the configuration phase, ensuring environment variables are properly loaded before being used.

  ## Files Changed

  - **`plugins/db/fsdb/db.go`**: Refactored custom patterns directory initialization logic
  - **`plugins/db/fsdb/patterns.go`**: Added alphabetical sorting to pattern names and implemented custom ListNames method

  ## Code Changes

  ### `plugins/db/fsdb/db.go`

  **Removed early initialization of custom patterns directory:**
  ```go
  // Removed from NewDb function:
  customPatternsDir := os.Getenv("CUSTOM_PATTERNS_DIRECTORY")
  if customPatternsDir != "" {
      // Expand home directory if needed
      if strings.HasPrefix(customPatternsDir, "~/") {
          if homeDir, err := os.UserHomeDir(); err == nil {
              customPatternsDir = filepath.Join(homeDir, customPatternsDir[2:])
          }
      }
  }
  ```

  **Added deferred initialization in Configure method:**
  ```go
  // Set custom patterns directory after loading .env file
  customPatternsDir := os.Getenv("CUSTOM_PATTERNS_DIRECTORY")
  if customPatternsDir != "" {
      // Expand home directory if needed
      if strings.HasPrefix(customPatternsDir, "~/") {
          if homeDir, err := os.UserHomeDir(); err == nil {
              customPatternsDir = filepath.Join(homeDir, customPatternsDir[2:])
          }
      }
      o.Patterns.CustomPatternsDir = customPatternsDir
  }
  ```

  ### `plugins/db/fsdb/patterns.go`

  **Added alphabetical sorting to GetNames method:**
  ```go
  // Sort the patterns alphabetically
  sort.Strings(ret)
  ```

  **Implemented custom ListNames method:**
  ```go
  // ListNames overrides StorageEntity.ListNames to use PatternsEntity.GetNames
  func (o *PatternsEntity) ListNames(shellCompleteList bool) (err error) {
      var names []string
      if names, err = o.GetNames(); err != nil {
          return
      }
      // ... rest of implementation
  }
  ```

  ## Reason for Changes

  1. **Timing Issue Fix**: The original code attempted to read the `CUSTOM_PATTERNS_DIRECTORY` environment variable during object construction, before the `.env` file was loaded. This could result in the custom patterns directory not being properly configured if it was defined in the `.env` file.

  2. **Improved User Experience**: Adding alphabetical sorting to pattern names makes it easier for users to find specific patterns when listing them.

  3. **Better Architecture**: Moving the custom patterns directory setup to the `Configure()` method follows the proper initialization order where environment setup happens before configuration.

  ## Impact of Changes

  - **Positive**: Custom patterns directory configuration will now work correctly when defined in `.env` files
  - **Positive**: Pattern listings will be consistently sorted alphabetically, improving usability
  - **Positive**: Better separation of concerns between object construction and configuration
  - **Low Risk**: The changes maintain backward compatibility and don't alter the public API

  ## Test Plan

  1. Test with `CUSTOM_PATTERNS_DIRECTORY` set in environment variables
  2. Test with `CUSTOM_PATTERNS_DIRECTORY` set in `.env` file
  3. Test with home directory expansion (`~/` prefix)
  4. Verify pattern names are sorted alphabetically when listed
  5. Test both shell completion and regular listing modes

  ## Additional Notes

  - The `CustomPatternsDir` field is now initialized with an empty string and a comment explaining it will be set after loading the `.env` file
  - The new `ListNames` method specifically uses `PatternsEntity.GetNames()` to ensure consistent sorting behavior
  - Error handling for home directory expansion remains unchanged and robust

commits:
  [{"SHA":"26fd7000989b87513dd6311c1c0005cfab33ca3b","Message":"refactor: move custom patterns directory initialization to Configure method\n\n- Move custom patterns directory logic to Configure method\n- Initialize CustomPatternsDir after loading .env file\n- Add alphabetical sorting to pattern names retrieval\n- Override ListNames method for PatternsEntity class\n- Improve pattern listing with proper error handling\n- Ensure custom patterns loaded after environment configuration","Author":"Kayvan Sylvan"}]


title: Fix Custom Patterns Directory Creation Logic
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1581
merged_at: 2025-07-06 08:59:19+00:00
created_at: 2025-07-16 04:25:34
body:
  # Fix Custom Patterns Directory Creation Logic

  ## Summary

  This pull request improves the directory creation logic in the custom patterns plugin by adding proper existence checks and better error handling. The changes prevent unnecessary directory creation attempts and provide more informative error messages while preserving the configured directory path.

  ## Files Changed

  - `plugins/tools/custom_patterns/custom_patterns.go`: Modified the `configure()` method to improve directory creation logic and error handling

  ## Code Changes

  ### plugins/tools/custom_patterns/custom_patterns.go

  **Added import:**
  ```go
  import (
  +	"fmt"
  	"os"
  	"path/filepath"
  	"strings"
  ```

  **Modified directory creation logic:**
  ```go
  -		// Create the directory if it doesn't exist
  -		if err := os.MkdirAll(o.CustomPatternsDir.Value, 0755); err != nil {
  -			// If we can't create it, clear the value to avoid errors
  -			o.CustomPatternsDir.Value = ""
  +		// Check if directory exists, create only if it doesn't
  +		if _, err := os.Stat(o.CustomPatternsDir.Value); os.IsNotExist(err) {
  +			if err := os.MkdirAll(o.CustomPatternsDir.Value, 0755); err != nil {
  +				// Log the error but don't clear the value - let it persist in env file
  +				fmt.Printf("Warning: Could not create custom patterns directory %s: %v\n", o.CustomPatternsDir.Value, err)
  +			}
  +		}
  ```

  ## Reason for Changes

  The original implementation had several issues:
  1. It attempted to create the directory every time `configure()` was called, even if the directory already existed
  2. It cleared the configured directory path on creation failure, which could lead to loss of user configuration
  3. It provided no feedback when directory creation failed

  ## Impact of Changes

  **Positive impacts:**
  - **Performance improvement**: Eliminates unnecessary `os.MkdirAll()` calls when the directory already exists
  - **Configuration preservation**: The configured directory path is now preserved even if creation fails, allowing users to fix permissions or create the directory manually
  - **Better user experience**: Users now receive clear warning messages when directory creation fails
  - **Reduced system calls**: The `os.Stat()` check is more efficient than always attempting directory creation

  **Potential considerations:**
  - The warning message is printed to stdout, which may not be ideal for all deployment scenarios
  - The code now makes an additional system call (`os.Stat()`) before directory creation, though this is offset by avoiding unnecessary `MkdirAll()` calls

  ## Test Plan

  The changes should be tested by:
  1. Verifying that existing directories are not recreated unnecessarily
  2. Testing directory creation when the path doesn't exist
  3. Confirming that configuration values persist when directory creation fails due to permissions
  4. Validating that appropriate warning messages are displayed on creation failures

  ## Additional Notes

  - The `fmt` package import was added to support the new warning message functionality
  - The error handling approach now follows a "fail gracefully" pattern, allowing the application to continue functioning even when the custom patterns directory cannot be created
  - Users can now manually create the directory or fix permissions after seeing the warning message, and the configuration will remain intact

commits:
  [{"SHA":"bd0c5f730e809ceaa2877fb08915d7c4c6ef7643","Message":"chore: improve directory creation logic in `configure` method\n\n### CHANGES\n\n- Add `fmt` package for logging errors\n- Check directory existence before creating\n- Log error without clearing directory value","Author":"Kayvan Sylvan"}]


title: Fix to persist the CUSTOM_PATTERNS_DIRECTORY variable
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1586
merged_at: 2025-07-06 10:35:05+00:00
created_at: 2025-07-16 04:25:34
body:
  # Fix to persist the CUSTOM_PATTERNS_DIRECTORY variable

  ## Summary

  Fixed a configuration issue in the CustomPatterns plugin where the `IsConfigured()` method was not properly initializing configuration values from environment variables before checking if the plugin was configured.

  ## Files Changed

  - **plugins/tools/custom_patterns/custom_patterns.go**: Modified the `IsConfigured()` method to ensure proper configuration loading before validation.

  ## Code Changes

  ### plugins/tools/custom_patterns/custom_patterns.go

  Added a call to `Configure()` at the beginning of the `IsConfigured()` method:

  ```go
  func (o *CustomPatterns) IsConfigured() bool {
  	// First configure to load values from environment variables
  	o.Configure()
  	// Check if the plugin has been configured with a directory
  	return o.CustomPatternsDir.Value != ""
  }
  ```

  The change adds two lines:
  1. A comment explaining the purpose of the configuration call
  2. A call to `o.Configure()` to ensure configuration values are loaded

  ## Reason for Changes

  This change addresses a potential race condition or initialization issue where `IsConfigured()` could return false even when valid configuration exists in environment variables. Without calling `Configure()` first, the `CustomPatternsDir.Value` field might not be populated from environment variables, leading to incorrect configuration state detection.

  ## Impact of Changes

  - **Positive Impact**: Ensures reliable configuration state detection by guaranteeing that environment variables are loaded before validation
  - **Behavioral Change**: `IsConfigured()` will now have the side effect of loading configuration if not already loaded
  - **Performance**: Minimal impact as `Configure()` should be idempotent and only perform initialization once

  ## Test Plan

  The changes should be tested by:
  1. Setting custom patterns directory via environment variables
  2. Calling `IsConfigured()` before any explicit `Configure()` calls
  3. Verifying that `IsConfigured()` returns true when environment variables are properly set
  4. Testing that multiple calls to `IsConfigured()` don't cause issues (idempotency)

  ## Additional Notes

  **Potential Considerations:**
  - The `Configure()` method should be idempotent to avoid issues with multiple calls
  - This change makes `IsConfigured()` have side effects, which may not be expected behavior for a query method
  - Consider if there are any error conditions from `Configure()` that should be handled
  - Verify that concurrent access to `IsConfigured()` is safe if the plugin is used in multi-threaded contexts

  **Alternative Approach**: Consider whether the configuration should be loaded once during plugin initialization rather than on-demand in `IsConfigured()` to maintain cleaner separation of concerns.

commits:
  [{"SHA":"e8fe4434db986cc6bf3dc15c4b99ccd96e105968","Message":"fix: make custom patterns persist correctly","Author":"Kayvan Sylvan"}]


title: Enhance bug report template
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1587
merged_at: 2025-07-06 19:37:56+00:00
created_at: 2025-07-16 04:25:34
body:
  # Enhance bug report template

  ## Summary

  This PR enhances the GitHub issue template for bug reports by adding more detailed fields to collect comprehensive information about the user's environment and installation method. The changes improve the bug reporting process by gathering essential system information upfront, which will help maintainers better understand and reproduce reported issues.

  ## Files Changed

  - `.github/ISSUE_TEMPLATE/bug.yml` - Enhanced the bug report template with additional fields for OS information, installation method, and version details.

  ## Code Changes

  ### Enhanced User Guidance
  ```yaml
  value: |
    Thanks for taking the time to fill out this bug report!
    Please provide as much detail as possible to help us understand and reproduce the issue.
  ```
  Added clearer instructions encouraging users to provide detailed information.

  ### Improved Bug Description Field
  ```yaml
  value: "Please provide all the steps to reproduce the bug. I was doing THIS, when THAT happened. I was expecting THAT_OTHER_THING to happen instead."
  ```
  Updated the placeholder text to explicitly request reproduction steps.

  ### Operating System Information
  ```yaml
  - type: dropdown
    id: os
    attributes:
      label: Operating System
      options:
        - macOS - Silicon (arm64)
        - macOS - Intel (amd64)
        - Linux - amd64
        - Linux - arm64
        - Windows
  ```
  Replaced the generic version checkbox with a structured OS dropdown that captures specific architecture information.

  ### OS Version Details
  ```yaml
  - type: textarea
    id: os-version
    attributes:
      label: OS Version
      description: Please provide details about your OS version by running one of the following commands.
      placeholder: |
        macOS: `sw_vers`
        Linux: `uname -a` or `cat /etc/os-release`
        Windows: `ver`
  ```
  Added a dedicated field for OS version information with helpful commands for each platform.

  ### Installation Method Tracking
  ```yaml
  - type: dropdown
    id: installation
    attributes:
      label: How did you install Fabric?
      options:
        - Release Binary - Windows
        - Release Binary - macOS (arm64)
        - Release Binary - macOS (amd64)
        - Release Binary - Linux (amd64)
        - Release Binary - Linux (arm64)
        - Package Manager - Homebrew (macOS)
        - Package Manager - AUR (Arch Linux)
        - From Source
        - Other
  ```
  Added comprehensive installation method tracking to help identify installation-specific issues.

  ### Version Information
  ```yaml
  - type: textarea
    id: version
    attributes:
      label: Version
      description: Please copy and paste the output of `fabric --version` (or `fabric-ai --version` if you installed it via brew) here.
  ```
  Replaced the simple checkbox with a proper version field that captures actual version output.

  ## Reason for Changes

  These changes address common issues in bug triage where maintainers need to repeatedly ask for basic environment information. By collecting this information upfront, the template:

  1. Reduces back-and-forth communication between maintainers and users
  2. Provides structured data that's easier to parse and analyze
  3. Helps identify patterns in bugs related to specific OS/architecture combinations
  4. Accounts for different installation methods that may have different behaviors

  ## Impact of Changes

  **Positive Impact:**
  - Faster bug resolution due to better initial information
  - Improved bug report quality and consistency
  - Better data for identifying platform-specific issues
  - Reduced maintainer workload in gathering basic information

  **Potential Considerations:**
  - Slightly longer form may discourage some users from reporting bugs
  - Users may skip optional fields, though key fields are marked as required
  - May need periodic updates as new installation methods are added

  ## Test Plan

  The changes should be tested by:
  1. Creating a test bug report using the new template
  2. Verifying all dropdown options are selectable
  3. Confirming required field validation works correctly
  4. Testing the template renders properly in GitHub's interface
  5. Ensuring the shell rendering works correctly for command outputs

  ## Additional Notes

  - The template maintains backward compatibility while significantly improving data collection
  - The installation method dropdown references the project's README for additional context
  - Shell rendering is used for technical outputs to improve readability
  - Required validation is strategically applied to critical fields while keeping optional fields for additional context

commits:
  [{"SHA":"a774f991ab3e54f71602a77614d628439dbe09cc","Message":"chore: enhance bug report template with detailed system info and installation method fields\n\n## CHANGES\n\n- Add detailed instructions for bug reproduction steps\n- Include operating system dropdown with specific architectures\n- Add OS version textarea with command examples\n- Create installation method dropdown with all options\n- Replace version checkbox with proper version output field\n- Improve formatting and organization of form sections\n- Add helpful links to installation documentation","Author":"Kayvan Sylvan"}]


title: Do not pass non-default TopP values
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1590
merged_at: 2025-07-07 03:04:16+00:00
created_at: 2025-07-16 04:25:34
body:
  # Do not pass non-default TopP values

  ## Summary

  This pull request adds conditional logic to prevent setting the `TopP` parameter when its value is 0 (zero) in OpenAI API requests. The change affects both chat completions and general response parameter building functions.

  ## Related Issues

  Closes #1588 

  ## Files Changed

  - **`plugins/ai/openai/chat_completions.go`**: Modified the `buildChatCompletionParams` function to conditionally set the `TopP` parameter
  - **`plugins/ai/openai/openai.go`**: Modified the `buildResponseParams` function to conditionally set the `TopP` parameter

  ## Code Changes

  ### plugins/ai/openai/chat_completions.go
  ```go
  // Before
  ret.TopP = openai.Float(opts.TopP)

  // After  
  if opts.TopP != 0 {
      ret.TopP = openai.Float(opts.TopP)
  }
  ```

  ### plugins/ai/openai/openai.go
  ```go
  // Before
  ret.TopP = openai.Float(opts.TopP)

  // After
  if opts.TopP != 0 {
      ret.TopP = openai.Float(opts.TopP)
  }
  ```

  Both changes follow the same pattern as the existing `MaxTokens` parameter handling, where the parameter is only set when the value is non-zero.

  ## Reason for Changes

  The changes prevent sending a `TopP` value of 0 to the OpenAI API when it hasn't been explicitly set by the user. This is likely to:

  1. Allow OpenAI to use its default `TopP` value instead of forcing it to 0
  2. Maintain consistency with how other optional parameters like `MaxTokens` are handled
  3. Avoid potential issues where a `TopP` of 0 might cause unexpected behavior in the API

  ## Impact of Changes

  - **Positive Impact**: The OpenAI API will receive more appropriate default parameters when `TopP` is not explicitly configured
  - **Behavioral Change**: When `opts.TopP` is 0, the parameter will now be omitted from API requests rather than explicitly set to 0
  - **Consistency**: Aligns `TopP` parameter handling with the existing `MaxTokens` parameter logic

  ## Test Plan

  The changes should be tested by:

  1. Verifying that API requests work correctly when `TopP` is not set (should omit the parameter)
  2. Confirming that API requests still include `TopP` when explicitly set to a non-zero value
  3. Testing both chat completions and general response scenarios
  4. Ensuring backward compatibility with existing configurations

  ## Screenshots

  This was causing this error in the Web UI

  ![image](https://github.com/user-attachments/assets/64394dff-e27c-42f4-8615-44932cc97c36)

  ## Additional Notes

  **Potential Considerations:**
  - The change assumes that a `TopP` value of 0 indicates "not set" rather than an intentional setting. If there are legitimate use cases for explicitly setting `TopP` to 0, this change could break that functionality
  - The logic treats 0 as the "unset" value, which is consistent with Go's zero-value semantics but may not align with OpenAI's API expectations if 0 is a valid `TopP` value
  - Consider whether a pointer type or optional wrapper might be more appropriate for truly optional parameters to distinguish between "not set" and "set to 0"

  The changes are minimal and follow established patterns in the codebase, reducing the risk of introducing bugs while improving parameter handling consistency.

commits:
  [{"SHA":"6222a613e43fa311141c2717e02ba3fb47db22b6","Message":"fix: add conditional check for TopP parameter in OpenAI client\n\n## CHANGES\n\n- Add zero-value check before setting TopP parameter\n- Prevent sending TopP when value is zero\n- Apply fix to both chat completions method\n- Apply fix to response parameters method\n- Ensure consistent parameter handling across OpenAI calls","Author":"Kayvan Sylvan"}]


title: Improved Anthropic Plugin Configuration Logic
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1591
merged_at: 2025-07-07 10:22:27+00:00
created_at: 2025-07-16 04:25:34
body:
  # Improved Anthropic Plugin Configuration Logic 

  ## Summary

  This PR improves the vendor configuration logic for the Anthropic plugin by adding proper configuration validation and enhancing OAuth token management. The changes ensure that vendors are only added to the active vendor manager when they are properly configured and introduce automatic OAuth flow handling for the Anthropic client.

  ## Related Issues

  Closes #1589 

  ## Files Changed

  - **`core/plugin_registry.go`**: Modified the `ConfigureVendors()` method to add an additional validation check
  - **`plugins/ai/anthropic/anthropic.go`**: Added configuration validation logic and improved OAuth handling

  ## Code Changes

  ### core/plugin_registry.go
  ```go
  // Before
  if vendorErr := vendor.Configure(); vendorErr == nil {
      o.VendorManager.AddVendors(vendor)
  }

  // After  
  if vendorErr := vendor.Configure(); vendorErr == nil && vendor.IsConfigured() {
      o.VendorManager.AddVendors(vendor)
  }
  ```

  ### plugins/ai/anthropic/anthropic.go
  - Added `vendorTokenIdentifier` constant set to "claude"
  - Simplified API key setup question logic by removing conditional required flag based on OAuth setting
  - Added comprehensive `IsConfigured()` method that:
    - Validates API key configuration
    - Handles OAuth token validation with 5-minute buffer
    - Automatically triggers OAuth flow when needed
    - Provides user feedback during authentication process

  ## Reason for Changes

  These changes address configuration validation issues where vendors could be added to the active manager even when not properly configured. The previous logic only checked if the `Configure()` method executed without errors, but didn't verify that the vendor actually had valid credentials or configuration.

  For the Anthropic plugin specifically, this resolves OAuth flow management by automatically handling token validation and renewal, improving the user experience when using OAuth authentication.

  ## Impact of Changes

  - **Improved reliability**: Vendors will only be activated when they have valid configuration
  - **Better user experience**: OAuth users will have automatic token validation and renewal
  - **Reduced errors**: Prevents misconfigured vendors from being used in the application
  - **Enhanced security**: Proper token validation with time-based checks

  ## Test Plan

  - Test vendor configuration with valid API keys
  - Test vendor configuration with invalid/missing API keys  
  - Test OAuth flow with valid tokens
  - Test OAuth flow with expired tokens (should trigger automatic renewal)
  - Test OAuth flow with no existing tokens (should prompt for authentication)
  - Verify that only properly configured vendors appear in the active vendor manager

  ## Additional Notes

  The `IsConfigured()` method includes a 5-minute buffer for OAuth token validation, which provides a reasonable margin for token expiration handling. The automatic OAuth flow trigger improves usability by eliminating the need for manual token management.

  **Potential considerations:**
  - The automatic OAuth flow in `IsConfigured()` could potentially block if the OAuth server is unreachable
  - Console output during OAuth flow may not be appropriate in all execution contexts
  - The hardcoded 5-minute buffer for token validation may need adjustment based on actual token lifetimes

commits:
  [{"SHA":"dbaa0b9754d0deac94031aa7498f847e16ac7cf7","Message":"feat: add vendor configuration validation and OAuth auto-authentication\n\n## CHANGES\n\n- Add IsConfigured check to vendor configuration loop\n- Implement IsConfigured method for Anthropic client validation\n- Remove conditional API key requirement based on OAuth\n- Add automatic OAuth flow when no valid token\n- Validate both API key and OAuth token configurations\n- Simplify API key setup question logic\n- Add token expiration checking with 5-minute buffer","Author":"Kayvan Sylvan"},{"SHA":"d1c614d44ecfaf2464a22f51554f49cf1bb06a09","Message":"refactor: extract vendor token identifier constant and remove redundant configure call\n\n## CHANGES\n\n- Extract vendor token identifier into named constant\n- Remove redundant Configure() call from IsConfigured method\n- Use constant for token validation consistency\n- Improve code maintainability with centralized identifier","Author":"Kayvan Sylvan"}]


title: Fix Streaming Error Handling in Chatter
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1592
merged_at: 2025-07-07 18:57:11+00:00
created_at: 2025-07-16 04:25:34
body:
  # Fix Streaming Error Handling in Chatter

  ## Summary

  This pull request fixes a critical bug in the streaming functionality of the `Chatter` component where errors from the `SendStream` method were not being properly propagated to the caller. The fix implements proper error handling using goroutines and channels, ensuring that streaming errors are captured and returned appropriately.

  ## Related Issues

  Closes #1571

  ## Files Changed

  ### Modified Files
  - **`core/chatter.go`**: Enhanced streaming error handling with proper goroutine synchronization and error propagation

  ### Added Files
  - **`core/chatter_test.go`**: Comprehensive test suite covering both error propagation and successful streaming scenarios

  ## Code Changes

  ### core/chatter.go

  The main changes focus on the streaming section of the `Send` method:

  **Before:**
  ```go
  if o.Stream {
      channel := make(chan string)
      go func() {
          if streamErr := o.vendor.SendStream(session.GetVendorMessages(), opts, channel); streamErr != nil {
              channel <- streamErr.Error()
          }
      }()

      for response := range channel {
          message += response
          fmt.Print(response)
      }
  }
  ```

  **After:**
  ```go
  if o.Stream {
      responseChan := make(chan string)
      errChan := make(chan error, 1)
      done := make(chan struct{})

      go func() {
          defer close(done)
          if streamErr := o.vendor.SendStream(session.GetVendorMessages(), opts, responseChan); streamErr != nil {
              errChan <- streamErr
          }
      }()

      for response := range responseChan {
          message += response
          fmt.Print(response)
      }

      // Wait for goroutine to finish
      <-done

      // Check for errors in errChan
      select {
      case streamErr := <-errChan:
          if streamErr != nil {
              err = streamErr
              return
          }
      default:
          // No errors, continue
      }
  }
  ```

  ### core/chatter_test.go

  Added comprehensive test coverage including:
  - `TestChatter_Send_StreamingErrorPropagation`: Verifies that errors from `SendStream` are properly propagated
  - `TestChatter_Send_StreamingSuccessfulAggregation`: Ensures successful streaming aggregates chunks correctly
  - Mock vendor implementation for isolated testing

  ## Reason for Changes

  The original implementation had a significant flaw where streaming errors were converted to string messages and sent through the response channel, making them indistinguishable from actual response content. This meant:

  1. **Silent failures**: Streaming errors were not returned to the caller
  2. **Data corruption**: Error messages could be mixed with actual response content
  3. **Poor user experience**: Users wouldn't know when streaming failed

  ## Impact of Changes

  ### Positive Impacts
  - **Proper error handling**: Streaming errors are now correctly propagated to callers
  - **Better separation of concerns**: Response data and errors are handled through separate channels
  - **Improved reliability**: The system can now properly handle and report streaming failures
  - **Enhanced testability**: Added comprehensive test coverage for both success and failure scenarios

  ### Potential Risks
  - **Goroutine synchronization**: The fix introduces additional complexity with multiple channels and goroutine coordination
  - **Race conditions**: Improper channel handling could potentially lead to deadlocks (mitigated by using buffered error channel and proper synchronization)
  - **Memory usage**: Additional channels create slight memory overhead

  ## Test Plan

  The changes include comprehensive unit tests that verify:

  1. **Error propagation**: `TestChatter_Send_StreamingErrorPropagation` confirms that `SendStream` errors are properly returned by the `Send` method
  2. **Successful streaming**: `TestChatter_Send_StreamingSuccessfulAggregation` verifies that streaming chunks are correctly aggregated into the final message
  3. **Mock vendor**: A complete mock implementation ensures tests run in isolation without external dependencies

  ### Testing Commands
  ```bash
  go test ./core -v -run TestChatter_Send
  ```

  ## Additional Notes

  - The fix maintains backward compatibility - the public API remains unchanged
  - The error channel is buffered (`make(chan error, 1)`) to prevent goroutine blocking
  - The `done` channel ensures proper synchronization and prevents race conditions
  - Error checking uses a non-blocking select statement to avoid deadlocks
  - The mock vendor properly closes the response channel to simulate real vendor behavior

  This fix addresses a critical reliability issue in the streaming functionality while maintaining the existing API contract and adding robust test coverage.

commits:
  [{"SHA":"ef4364a1aa4090afdd19c164572bf3fc0332761c","Message":"fix: improve error handling in streaming chat functionality\n\n## CHANGES\n\n- Add dedicated error channel for stream operations\n- Separate error handling from message streaming logic\n- Check for streaming errors after channel closure\n- Close error channel properly in goroutine cleanup\n- Remove error messages from message stream channel\n- Add proper error propagation for stream failures","Author":"Kayvan Sylvan"},{"SHA":"e672f9b73f59c67fa0e4975cae5f9dd941c7429a","Message":"chore: simplify error handling in streaming chat response by removing unnecessary select statement","Author":"Kayvan Sylvan"},{"SHA":"115327fdab033ddd399b83953f6b676be329a058","Message":"refactor: use select to handle stream and error channels concurrently\n\n### CHANGES\n\n- Replace for-range loop with a non-blocking select statement.\n- Process message and error channels concurrently for better handling.\n- Improve the robustness of streaming error detection.\n- Exit loop cleanly when the message channel closes.","Author":"Kayvan Sylvan"},{"SHA":"2d2830e9c8eb27a81ea61f5a09275375876ab850","Message":"chore: enhance `Chatter.Send` method with proper goroutine synchronization\n\n### CHANGES\n- Add `done` channel to track goroutine completion.\n- Replace `errChan` closure with `done` channel closure.\n- Ensure main loop waits for goroutine on channel close.\n- Synchronize error handling with `done` channel wait.","Author":"Kayvan Sylvan"},{"SHA":"6b4ce946a560b27535f4072781f8b874b0a5e24a","Message":"chore: refactor error handling and response aggregation in `Send`\n\n### CHANGES\n\n- Simplify response aggregation loop in `Send`\n- Remove redundant select case for closed channel\n- Streamline error checking from `errChan`\n- Ensure goroutine completion before returning","Author":"Kayvan Sylvan"},{"SHA":"b1013ca61bc0f57b943d2e19f2d40ec679110b86","Message":"chore: close `channel` after sending stream in `Send`\n\n### CHANGES\n\n- Add `channel` closure after sending stream\n- Ensure resource cleanup in `Send` method","Author":"Kayvan Sylvan"},{"SHA":"d6a31e68b06943773dd396ba222237de7d1e0330","Message":"refactor: rename `channel` variable to `responseChan` for better clarity in streaming logic\n\n## CHANGES\n\n- Rename `channel` variable to `responseChan` for clarity\n- Update channel references in goroutine defer statements\n- Pass renamed channel to `SendStream` method call\n- Maintain consistent naming throughout streaming flow","Author":"Kayvan Sylvan"},{"SHA":"24e46a6f37fffab12c3476ce2cfbb47116132829","Message":"chore: rename channels for clarity in `Send` method\n\n### CHANGES\n\n- Rename `done` to `doneChan` for clarity\n- Adjust channel closure for `doneChan`\n- Update channel listening logic to use `doneChan`","Author":"Kayvan Sylvan"},{"SHA":"0af458872f8477fc94c94c67449f43bd9b093af6","Message":"feat: add test for Chatter's Send method error propagation\n\n### CHANGES\n\n- Implement mockVendor for testing ai.Vendor interface\n- Add TestChatter_Send_StreamingErrorPropagation test case\n- Verify error propagation in Chatter's Send method\n- Ensure session returns even on streaming error\n- Create temporary database for testing Chatter functionality","Author":"Kayvan Sylvan"},{"SHA":"f8f80ca2060edcb8710d8a276a351c3d6b9ae835","Message":"chore: rename `doneChan` to `done` and add streaming aggregation test\n\n## CHANGES\n\n- Rename `doneChan` variable to `done` for consistency\n- Add `streamChunks` field to mock vendor struct\n- Implement chunk sending logic in mock SendStream method\n- Add comprehensive streaming success aggregation test case\n- Verify message aggregation from multiple stream chunks\n- Test assistant response role and content validation\n- Ensure proper session handling in streaming scenarios","Author":"Kayvan Sylvan"},{"SHA":"d0b5c95d6150eb5e7ccbb0fdc849e689df8e6eb9","Message":"chore: remove redundant channel closure in `Send` method\n\n### CHANGES\n\n- Remove redundant `close(responseChan)` in `Send` method\n- Update `SendStream` to close `responseChan` properly\n- Modify test to reflect channel closure logic","Author":"Kayvan Sylvan"},{"SHA":"38d714dccd56af518804cc9329334d651e47f4cf","Message":"chore: improve error comparison in `TestChatter_Send_StreamingErrorPropagation`","Author":"Kayvan Sylvan"}]


title: Refactor: Generalize OAuth flow for improved token handling.
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1593
merged_at: 2025-07-07 21:24:23+00:00
created_at: 2025-07-16 04:25:34
body:
  # Refactor: Generalize OAuth flow for improved token handling.

  # Pull Request: Refactor OAuth Token Management with Parameterized Token Identifiers

  ## Summary

  This PR refactors the OAuth token management system in the Anthropic plugin to use parameterized token identifiers instead of hardcoded values. The changes improve code maintainability, testability, and prepare the foundation for supporting multiple token types or providers in the future.

  ## Files Changed

  ### `plugins/ai/anthropic/anthropic.go`
  - **Renamed constant**: Changed `vendorTokenIdentifier` to `authTokenIdentifier` for clearer naming
  - **Updated method signatures**: Modified `RunOAuthFlow()` and `RefreshToken()` calls to accept token identifier parameter
  - **Consistent token identifier usage**: All OAuth-related calls now use the `authTokenIdentifier` constant

  ### `plugins/ai/anthropic/oauth.go`
  - **Parameterized OAuth functions**: Added `tokenIdentifier` parameter to `RunOAuthFlow()`, `RefreshToken()`, `exchangeToken()`, and `getValidToken()` methods
  - **Enhanced token reuse logic**: Added logic in `RunOAuthFlow()` to check for existing valid tokens before initiating new OAuth flow
  - **Improved error handling**: Better error messages and fallback logic for token refresh failures

  ### `plugins/ai/anthropic/oauth_test.go` (New File)
  - **Comprehensive test suite**: Added 434 lines of OAuth functionality tests
  - **Safe testing approach**: Tests avoid real OAuth flows and external API calls
  - **Mock infrastructure**: Includes mock token servers and helper functions for isolated testing
  - **Edge case coverage**: Tests for expired tokens, missing tokens, and error scenarios

  ## Code Changes

  ### Key OAuth Flow Enhancement
  ```go
  // Enhanced RunOAuthFlow with existing token check
  func RunOAuthFlow(tokenIdentifier string) (token string, err error) {
      // First check if we have an existing token that can be refreshed
      storage, err := common.NewOAuthStorage()
      if err == nil {
          existingToken, err := storage.LoadToken(tokenIdentifier)
          if err == nil && existingToken != nil {
              // If token exists but is expired, try refreshing first
              if existingToken.IsExpired(5) {
                  refreshedToken, refreshErr := RefreshToken(tokenIdentifier)
                  if refreshErr == nil {
                      return refreshedToken, nil
                  }
              } else {
                  // Token exists and is still valid
                  return existingToken.AccessToken, nil
              }
          }
      }
      // ... rest of OAuth flow
  }
  ```

  ### Parameterized Token Management
  ```go
  // Before: Hardcoded token identifier
  if !storage.HasValidToken("claude", 5) {
      _, err := RunOAuthFlow()
  }

  // After: Parameterized token identifier
  if !storage.HasValidToken(authTokenIdentifier, 5) {
      _, err := RunOAuthFlow(authTokenIdentifier)
  }
  ```

  ## Reason for Changes

  1. **Improved Maintainability**: Eliminates hardcoded "claude" strings scattered throughout the codebase
  2. **Better Testability**: Allows tests to use different token identifiers without affecting production tokens
  3. **Enhanced Reusability**: Prepares the code for potential multi-provider or multi-token scenarios
  4. **Reduced Redundancy**: The enhanced `RunOAuthFlow()` now checks for existing valid tokens before initiating new flows
  5. **Consistent Error Handling**: Standardized error messages and fallback mechanisms

  ## Impact of Changes

  ### Positive Impacts
  - **No Breaking Changes**: All existing functionality remains intact
  - **Improved Performance**: Reduced unnecessary OAuth flows by checking existing tokens first
  - **Better User Experience**: More informative error messages and automatic token refresh
  - **Enhanced Testing**: Comprehensive test coverage without external dependencies

  ### Potential Risks
  - **Token Refresh Logic**: The enhanced token reuse logic could potentially mask authentication issues if not properly tested
  - **Parameter Propagation**: All OAuth-related functions now require the token identifier parameter - missing updates could cause compilation errors
  - **Storage Dependencies**: Increased reliance on the OAuth storage system for token validation

  ## Test Plan

  The new test suite includes:
  - **Unit Tests**: PKCE generation, token expiration logic, helper functions
  - **Integration Tests**: Mocked OAuth flows with temporary storage
  - **Error Path Tests**: Missing tokens, expired tokens, refresh failures
  - **Performance Tests**: Benchmarks for critical operations
  - **Edge Case Tests**: Invalid tokens, network failures, storage errors

  All tests use temporary directories and mock servers to avoid external dependencies.

  ## Additional Notes

  - The constant rename from `vendorTokenIdentifier` to `authTokenIdentifier` better reflects its purpose
  - The test suite follows a "safe testing" approach that never triggers real OAuth flows
  - All OAuth functions now consistently use the parameterized token identifier
  - The enhanced token reuse logic in `RunOAuthFlow()` should reduce unnecessary authentication prompts for users
  - Future enhancements could leverage this parameterization to support multiple authentication providers

commits:
  [{"SHA":"0528556b5cd3c4cf8b0af1951c9bbc04c2dcc411","Message":"refactor: replace hardcoded \"claude\" with configurable `authTokenIdentifier` parameter\n\n## CHANGES\n\n- Replace hardcoded \"claude\" string with `authTokenIdentifier` constant\n- Update `RunOAuthFlow` to accept token identifier parameter\n- Modify `RefreshToken` to use configurable token identifier\n- Update `exchangeToken` to accept token identifier parameter\n- Enhance `getValidToken` to use parameterized token identifier\n- Add token refresh attempt before full OAuth flow\n- Improve OAuth flow with existing token validation","Author":"Kayvan Sylvan"},{"SHA":"a6a63698e1b9cfd976b0caf7a47893cf77602800","Message":"fix: update `RefreshToken` to use `tokenIdentifier` parameter","Author":"Kayvan Sylvan"},{"SHA":"bcd4c6caea4a9b258d3c240db39b09c5c4ee59cb","Message":"test: add comprehensive OAuth testing suite for Anthropic plugin\n\n## CHANGES\n\n- Add OAuth test file with 434 lines coverage\n- Create mock token server for safe testing\n- Implement PKCE generation and validation tests\n- Add token expiration logic verification tests\n- Create OAuth transport round-trip testing\n- Add benchmark tests for performance validation\n- Implement helper functions for test token creation\n- Add comprehensive error path testing scenarios","Author":"Kayvan Sylvan"},{"SHA":"75842d86100dc421ecf81a15ca2a382431a12c5a","Message":"chore: refactor token path to use `authTokenIdentifier`","Author":"Kayvan Sylvan"}]


title: Adds check Dunning-Kruger Telos self-evaluation pattern
author: amancioandre
author_url: https://github.com/amancioandre
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1594
merged_at: 2025-07-08 01:38:29+00:00
created_at: 2025-07-16 04:25:34
body:
  ## What this Pull Request (PR) does

  This PR adds the `t_check_dunning_kruger` TELOS self-evaluation pattern. The check aims to identify the input's owner:
  - Overestimation/Underestimation of Competence
  - Metacognitive Skills
  - And, Impact on Decision-Making

  Recognizing and addressing gaps in self-perception can enhance decision-making and foster growth. Embrace feedback, seek learning opportunities, and reflect on experiences to build a more accurate self-assessment.

  ---
  Summary

  The Dunning-Kruger effect is a cognitive bias wherein individuals with low ability, knowledge, or experience in a particular domain tend to overestimate their own competence. This phenomenon was first described by psychologists David Dunning and Justin Kruger in their 1999 study, which showed that people who scored lowest on tests of humor, grammar, and logic also tended to rate their own abilities far higher than they actually were. The bias occurs because those with insufficient knowledge lack the metacognitive skills to accurately assess their own performance. In contrast, more competent individuals are often more aware of their limitations and may underestimate their abilities.

  This effect has broad implications across education, workplace performance, and decision-making. It suggests that confidence is not always correlated with competence, which can lead to poor decisions made by those unaware of their limitations. The Dunning-Kruger effect is supported by a wide body of psychological research and has been observed in various domains, including finance, medicine, and politics. **However, some recent studies argue that the effect may also be partly explained by statistical artifacts like regression to the mean, rather than pure cognitive bias, suggesting that while the original findings remain robust, the interpretation continues to evolve**.

  Recognizing and addressing the Dunning-Kruger effect in one’s own life is a valuable step toward personal growth and better decision-making. Regular self-evaluation helps identify areas where overconfidence might be masking a lack of competence, allowing individuals to seek feedback, acquire new knowledge, or improve their skills. This kind of honest reflection fosters intellectual humility, making it easier to learn from mistakes and collaborate effectively with others. By being open to the idea that we might not know as much as we think, we can close the gap between perceived and actual ability—leading to more informed choices and healthier relationships, both personally and professionally.

  References:

  Kruger, J., & Dunning, D. (1999). Unskilled and unaware of it: How difficulties in recognizing one's own incompetence lead to inflated self-assessments. Journal of Personality and Social Psychology, 77(6), 1121–1134. https://doi.org/10.1037/0022-3514.77.6.1121

  Dunning, D. (2011). The Dunning–Kruger Effect: On being ignorant of one's own ignorance. Advances in Experimental Social Psychology, 44, 247–296. https://doi.org/10.1016/B978-0-12-385522-0.00005-6



  ## Related issues
  Please reference any open issues this PR relates to in here.
  If it closes an issue, type `closes #[ISSUE_NUMBER]`.
  Does not address any open issue.

  ## Screenshots
  Provide any screenshots you may find relevant to facilitate us understanding your PR.
  Does not provide any screenshot.

commits:
  [{"SHA":"50c05e2d5c31a8d4f589a8abcc416aaa2b077500","Message":"feat: adds pattern telos check dunning kruger","Author":"apollo"},{"SHA":"cab246bc74fa72dccf5ce5de8a9c8f7b7c6ce3e4","Message":"Merge branch 'danielmiessler:main' into main","Author":"Andre Amnc"},{"SHA":"c78fe41ebc455f91e74e4b488e2002c877d1ae37","Message":"fix: sections as heading 1, typos","Author":"apollo"},{"SHA":"a43f267a692180da52988ab80f6f5bde4564f210","Message":"Merge branch 'main' of https://github.com/amancioandre/Fabric","Author":"apollo"}]


title: Restructure project to align with standard Go layout
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1595
merged_at: 2025-07-09 07:38:49+00:00
created_at: 2025-07-16 04:25:34
body:
  # Restructure project to align with standard Go layout

  ## Summary

  This pull request implements a comprehensive restructuring of the Fabric project to align with Go best practices and improve code organization. The changes move from a flat, mixed-concern structure to a well-organized hierarchy that separates executable code, internal libraries, data assets, and auxiliary scripts.

  ## Related Issues

  Closes #1127 

  ## Files Changed

  ### New Directory Structure
  - **`cmd/`** - Created to house all executable entry points following Go conventions
    - `cmd/fabric/` - Main application (moved from root `main.go`)
    - `cmd/code_helper/` - Code analysis tool (moved from `plugins/tools/code_helper/`)
    - `cmd/to_pdf/` - PDF conversion tool (moved from `plugins/tools/to_pdf/`)

  - **`internal/`** - Created to contain all private application code
    - `internal/cli/` - CLI handling code (moved from `cli/`)
    - `internal/core/` - Core application logic (moved from `core/`)
    - `internal/common/` - Shared domain types and utilities (moved from `common/`)
    - `internal/plugins/` - All plugin implementations (moved from `plugins/`)
    - `internal/server/` - HTTP server code (renamed from `restapi/`)
    - `internal/tools/` - Non-binary utility tools (moved from `plugins/tools/`)
    - `internal/chat/` - Chat functionality (moved from `chat/`)

  - **`data/`** - Created to separate data assets from source code
    - `data/patterns/` - Pattern definitions (moved from `patterns/`)
    - `data/strategies/` - Strategy configurations (moved from `strategies/`)

  - **`scripts/`** - Created to organize auxiliary tools and deployment files
    - `scripts/docker/` - Docker deployment files and helpers
    - `scripts/python_ui/` - Streamlit UI and Python dependencies
    - `scripts/pattern_generation/` - Pattern extraction and generation tools

  - **`docs/`** - Created for documentation and related assets
    - `docs/images/` - Project images and assets
    - `docs/NOTES.md` - Development notes
    - ` docs/Project-Restructured.md ` - Notes about this restructuring plan.

  ### Deleted Files
  - `coverage.out` - Removed generated test coverage file

  ## Code Changes

  ### Import Path Updates
  All Go files have been updated to reflect the new internal structure:
  ```go
  // Before
  "github.com/danielmiessler/fabric/cli"
  "github.com/danielmiessler/fabric/plugins/tools/youtube"

  // After  
  "github.com/danielmiessler/fabric/internal/cli"
  "github.com/danielmiessler/fabric/internal/tools/youtube"
  ```

  ### Build Target Changes
  - Main application now builds from `./cmd/fabric` instead of root
  - Additional tools build from `./cmd/code_helper` and `./cmd/to_pdf`
  - GitHub Actions workflow updated to reference new build paths

  ### Configuration Updates
  - Pattern and strategy loading updated to use `data/` directory paths
  - Docker build process updated to work with new structure
  - Version file generation moved to `cmd/fabric/version.go`

  ## Reason for Changes

  This restructuring addresses several issues with the previous organization:

  1. **Go Convention Compliance**: The new structure follows standard Go project layout with `cmd/` for executables and `internal/` for private packages
  2. **Separation of Concerns**: Clear distinction between application code, data assets, deployment scripts, and documentation
  3. **Reduced Root Clutter**: Moves auxiliary files into organized subdirectories, making the project structure immediately comprehensible
  4. **Import Clarity**: The `internal/` structure prevents external projects from depending on private implementation details

  ## Impact of Changes

  ### Positive Impacts
  - **Developer Experience**: New contributors can immediately understand the project structure and locate relevant code
  - **Maintainability**: Clear separation makes it easier to modify individual components without affecting others
  - **Tooling**: Standard Go tools and IDEs work better with conventional project layouts
  - **Packaging**: Cleaner structure for distribution and packaging systems

  ### Breaking Changes
  - **Import Paths**: Any external code importing Fabric packages will need to update import paths
  - **Build Commands**: Build scripts and CI/CD pipelines need to reference new binary locations
  - **File Paths**: Any hardcoded references to old file locations need updating

  ## Test Plan

  The restructuring has been validated through:

  1. **Compilation Testing**: All three binaries (`fabric`, `code_helper`, `to_pdf`) compile successfully
  2. **Unit Tests**: Full test suite passes with `go test ./...`
  3. **Integration Testing**: Manual verification of CLI functionality, API endpoints, and pattern loading
  4. **Build System**: GitHub Actions updated and tested with new structure
  5. **Installation**: Verified `go install` works for all three tools

  ## Additional Notes

  - **Backward Compatibility**: While the internal structure has changed significantly, the user-facing API and CLI remain unchanged
  - **Documentation**: README and setup instructions updated to reflect new structure
  - **Future Extensibility**: The new structure makes it easy to add new tools in `cmd/` or new internal packages as needed
  - **Standards Compliance**: The project now follows established Go community practices, making it more familiar to Go developers

  This restructuring provides a solid foundation for future development while maintaining all existing functionality.

commits:
  [{"SHA":"4004c51b9e54356ce64015b6d649ac4765cbde08","Message":"refactor: restructure project to align with standard Go layout\n\n### CHANGES\n\n- Introduce `cmd` directory for all main application binaries.\n- Move all Go packages into the `internal` directory.\n- Rename the `restapi` package to `server` for clarity.\n- Consolidate patterns and strategies into a new `data` directory.\n- Group all auxiliary scripts into a new `scripts` directory.\n- Move all documentation and images into a `docs` directory.\n- Update all Go import paths to reflect the new structure.\n- Adjust CI/CD workflows and build commands for new layout.","Author":"Kayvan Sylvan"},{"SHA":"e242e0fc523a09daff3dd62655a06179cca6f518","Message":"refactor: alias server package import as restapi for clarity\n\n### CHANGES\n\n*   Rename the `server` package import to `restapi`.\n*   Improve code readability and prevent naming collisions.","Author":"Kayvan Sylvan"},{"SHA":"ebc59ee82a4e23294018ab178d71d2459035a27b","Message":"refactor: move common package to domain and util packages for better organization\n\n## CHANGES\n\n- Move domain types from common to domain package\n- Move utility functions from common to util package\n- Update all import statements across codebase\n- Reorganize OAuth storage functionality into util package\n- Move file management functions to domain package\n- Update test files to use new package structure\n- Maintain backward compatibility for existing functionality","Author":"Kayvan Sylvan"},{"SHA":"81adb3b0500d2c62a7548f8715ae6f4d1c278d39","Message":"docs: update project restructuring status and reorganize pattern scripts\n\n## CHANGES\n\n- Mark all 10 migration steps as completed\n- Add restructuring completion status section\n- Move pattern generation scripts to pattern_descriptions\n- Update completion checkmarks throughout migration plan\n- Document remaining external packaging verification tasks\n- Consolidate pattern description files under new directory\n- Confirm all binaries compile and tests pass\n- Note standard Go project layout achieved","Author":"Kayvan Sylvan"},{"SHA":"da1336e8cbb92519692428ac9a099c985326dcdc","Message":"feat: add new patterns for content tagging and cognitive bias analysis\n\n## CHANGES\n\n- Fix static directory path in extract_patterns.py script\n- Add apply_ul_tags pattern for content categorization\n- Add t_check_dunning_kruger pattern for bias analysis\n- Update pattern descriptions with new entries\n- Sync web static data with latest patterns\n- Include pattern extracts for new functionality\n- Support standardized content topic classification\n- Enable cognitive bias identification capabilities","Author":"Kayvan Sylvan"},{"SHA":"4d7bc7deb83fcd25e045015173de52dfab19451e","Message":"docs: update restructure guide with Homebrew and go install details\n\n### CHANGES\n\n- Document required Homebrew formula update for new structure.\n- Add new `go install` commands for all tools.\n- Specify new build path is `./cmd/fabric`.\n- Include link to the draft Homebrew PR.","Author":"Kayvan Sylvan"},{"SHA":"af318aca17c1f93608f45dcdadc7a2c39f50cf88","Message":"fix: minor edit","Author":"Kayvan Sylvan"},{"SHA":"9a64238f1820e9223aa6fd4e3dbdf9f134818488","Message":"docs: Update README with new go install commands","Author":"Kayvan Sylvan"}]


title: Fix patterns zipping workflow
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1596
merged_at: 2025-07-09 07:48:08+00:00
created_at: 2025-07-16 04:25:34
body:
  # Fix patterns zipping workflow

  ## Summary

  Updated GitHub Actions workflow to reflect the relocation of patterns folder from root directory to `data/patterns/`. This change ensures the CI/CD pipeline correctly monitors and processes pattern files in their new location.

  ## Files Changed

  - **.github/workflows/patterns.yaml**: Modified workflow configuration to update all references from `patterns/` to `data/patterns/` to align with the new directory structure.

  ## Code Changes

  The following changes were made to the workflow file:

  **Trigger path updated:**
  ```yaml
  ## Before
  - "patterns/**"
  ## After  
  - "data/patterns/**"
  ```

  **Git diff verification updated:**
  ```bash
  ## Before
  if git diff --quiet HEAD~1 -- patterns; then
  ## After
  if git diff --quiet HEAD~1 -- data/patterns; then
  ```

  **Zip command updated:**
  ```bash
  ## Before
  run: zip -r patterns.zip patterns/
  ## After
  run: zip -r patterns.zip data/patterns/
  ```

  ## Reason for Changes

  This update appears to be part of a repository restructuring effort where the `patterns` folder has been moved from the root directory to a `data` subdirectory. The workflow needed to be updated to maintain functionality and continue monitoring the correct file paths for changes.

  ## Impact of Changes

  - **Positive Impact**: The workflow will now correctly trigger when files in the relocated patterns directory are modified
  - **Maintains Functionality**: Preserves the existing CI/CD behavior for pattern file processing
  - **Improves Organization**: Supports better project structure by organizing patterns under a dedicated data directory

  ## Test Plan

  To verify these changes work correctly:

  1. Make a change to any file within the `data/patterns/` directory
  2. Push the change to trigger the workflow
  3. Verify the workflow executes and successfully creates the patterns.zip artifact
  4. Confirm the artifact contains the files from `data/patterns/` directory

  ## Additional Notes

  **Potential Issues to Monitor:**
  - Ensure no other workflows or scripts reference the old `patterns/` path
  - Verify that any documentation referencing the patterns folder location is also updated
  - Check if there are any hardcoded references to the old path in application code

  **Dependencies:**
  - This change assumes the actual patterns folder has already been moved to `data/patterns/` in the repository
  - Any external systems or documentation referencing the old path may need corresponding updates

  The changes are straightforward path updates with minimal risk, but thorough testing is recommended to ensure the workflow continues to function as expected with the new directory structure.

commits:
  [{"SHA":"cb5fa50f68f55ad879fff84e7694d1ffad9dfdf3","Message":"chore: update workflow paths to reflect directory structure change\n\n### CHANGES\n\n- Modify trigger path to `data/patterns/**`\n- Update `git diff` command to new path\n- Change zip command to include `data/patterns/` directory","Author":"Kayvan Sylvan"}]


title: CLI Refactoring: Modular Command Processing and Pattern Loading Improvements
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1597
merged_at: 2025-07-09 10:52:25+00:00
created_at: 2025-07-16 04:25:34
body:
  # CLI Refactoring: Modular Command Processing and Pattern Loading Improvements

  ## Summary

  This PR refactors the main CLI module by breaking down a large monolithic `cli.go` file into smaller, focused modules organized by functionality. The changes improve code maintainability, readability, and testability by separating concerns into logical groupings.

  ## Screenshots

  ![image](https://github.com/user-attachments/assets/810ac8f7-9003-4e35-a3af-9ee95368a2f0)


  ## Files Changed

  ### New Files Added:
  - **`internal/cli/chat.go`**: Extracted chat processing logic into a dedicated module
  - **`internal/cli/configuration.go`**: Handles configuration-related commands (pattern updates, model changes)
  - **`internal/cli/extensions.go`**: Manages extension-related operations (list, add, remove)
  - **`internal/cli/initialization.go`**: Contains fabric database and plugin registry initialization logic
  - **`internal/cli/listing.go`**: Handles all listing commands (patterns, models, contexts, sessions, etc.)
  - **`internal/cli/management.go`**: Manages data operations (delete contexts/sessions, print operations)
  - **`internal/cli/setup_server.go`**: Handles setup and server-related commands
  - **`internal/cli/tools.go`**: Manages YouTube and web scraping tool processing

  ### Modified Files:
  - **`internal/cli/cli.go`**: Significantly refactored to use the new modular structure
  - **`internal/tools/patterns_loader.go`**: Enhanced with better error handling, path migration, and pattern validation

  ## Code Changes

  ### Main CLI Refactoring (`cli.go`)

  The main `Cli` function was reduced from ~280 lines to ~67 lines by extracting functionality:

  ```go
  // Old approach: All logic in one function
  func Cli(version string) (err error) {
      // 280+ lines of mixed concerns
  }

  // New approach: Delegated to focused handlers
  func Cli(version string) (err error) {
      // Initialize once
      var registry, err2 = initializeFabric()
      
      // Handle different command categories
      if handled, err = handleSetupAndServerCommands(currentFlags, registry, version); err != nil || handled {
          return
      }
      // ... other handlers
  }
  ```

  ### Enhanced Patterns Loader (`patterns_loader.go`)

  Added robust path migration and validation:

  ```go
  // New path migration logic
  func (o *PatternsLoader) tryPathMigration() (err error) {
      if o.DefaultFolder.Value == "patterns" {
          fmt.Println("🔄 Detected old pattern path 'patterns', trying migration to 'data/patterns'...")
          newPath := "data/patterns"
          // Test and migrate if successful
      }
  }

  // Pattern count validation
  func (o *PatternsLoader) countPatternsInDirectory(dir string) (int, error) {
      // Validates that patterns were actually downloaded
  }
  ```

  ## Reason for Changes

  1. **Code Organization**: The original `cli.go` file was becoming unwieldy with over 280 lines handling multiple concerns
  2. **Maintainability**: Separating functionality into focused modules makes the codebase easier to understand and modify
  3. **Testability**: Smaller, focused functions are easier to unit test
  4. **Error Handling**: Improved error handling and user feedback, especially for pattern loading operations
  5. **Path Migration**: Added automatic migration from old pattern paths to new repository structure

  ## Impact of Changes

  ### Positive Impacts:
  - **Improved Code Organization**: Each module has a single responsibility
  - **Better Error Messages**: More descriptive error messages with context
  - **Automatic Migration**: Users with old configurations will be automatically migrated
  - **Enhanced Debugging**: Easier to trace issues to specific modules
  - **Future Extensibility**: New command categories can be easily added as separate modules

  ### Potential Risks:
  - **Import Dependencies**: New file structure requires careful management of imports
  - **Initialization Order**: Registry initialization must happen before other handlers
  - **Error Propagation**: Need to ensure errors are properly propagated through the handler chain

  ## Test Plan

  1. **Functional Testing**: Verify all existing CLI commands work as before
  2. **Migration Testing**: Test automatic path migration from old "patterns" to "data/patterns"
  3. **Error Handling**: Test error scenarios for each command category
  4. **Integration Testing**: Ensure proper interaction between modules
  5. **Regression Testing**: Verify no existing functionality is broken

  ## Additional Notes

  ## Potential Bugs:
  1. **Registry Nil Check**: If `initializeFabric()` fails and returns nil registry, subsequent handlers could panic
  2. **Path Migration Race Condition**: Multiple concurrent pattern updates could interfere with path migration
  3. **Temp Directory Cleanup**: Pattern loader creates temporary directories that need proper cleanup on errors

  ## Code Quality Improvements:
  - All new functions return `(handled bool, err error)` for consistent control flow
  - Better separation of concerns with clear module boundaries
  - Enhanced logging and user feedback during operations
  - Consistent error wrapping with context

  The refactoring maintains backward compatibility while significantly improving code organization and maintainability.

commits:
  [{"SHA":"137aff226825374e9d6e69da8310f8937ba5987a","Message":"feat: refactor CLI to modularize command handling\n\n### CHANGES\n\n* Extract chat processing logic into separate function\n* Create modular command handlers for setup, configuration, listing, management, and extensions\n* Improve patterns loader with migration support and better error handling\n* Simplify main CLI logic by delegating to specialized handlers\n* Enhance code organization and maintainability\n* Add tool processing for YouTube and web scraping functionality","Author":"Kayvan Sylvan"},{"SHA":"b884c529bd9e4474195f82c2b87f7550047c2a67","Message":"chore: update command handlers to return 'handled' boolean\n\n### CHANGES\n\n- Add `handled` boolean return to command handlers\n- Modify `handleSetupAndServerCommands` to use `handled`\n- Update `handleConfigurationCommands` with `handled` logic\n- Implement `handled` return in `handleExtensionCommands`\n- Revise `handleListingCommands` to support `handled` return\n- Adjust `handleManagementCommands` to return `handled`","Author":"Kayvan Sylvan"},{"SHA":"2c2b3746647f516d154e775ead6fed2b951adb0f","Message":"chore: remove fabric binary","Author":"Kayvan Sylvan"},{"SHA":"6e2f00090c97bbb345c96a2ab76121242ee9a097","Message":"chore: enhance error handling and early returns in CLI\n\n### CHANGES\n- Add early return if registry is nil to prevent panics.\n- Introduce early return for non-chat tool operations.\n- Update error message to use original input on HTML readability failure.\n- Enhance error wrapping for playlist video fetching.\n- Modify temp patterns folder name with timestamp for uniqueness.\n- Improve error handling for patterns directory access.","Author":"Kayvan Sylvan"},{"SHA":"be82b4b0133bdbeeec8b46a519409ad0c0144dc5","Message":"chore: improve error handling for scraping configuration in `tools.go`","Author":"Kayvan Sylvan"},{"SHA":"e64bdd849c1889f17d27317ccd369548851b7cda","Message":"fix: improve error handling and temporary file management in patterns loader\n\n## CHANGES\n\n- Replace println with fmt.Fprintln to stderr for errors\n- Use os.MkdirTemp for secure temporary directory creation\n- Remove unused time import from patterns loader\n- Add proper error wrapping for file operations\n- Handle RemoveAll errors with warning messages\n- Improve error messages with context information\n- Add explicit error checking for cleanup operations","Author":"Kayvan Sylvan"}]


title: flake: fixes and enhancements
author: jaredmontoya
author_url: https://github.com/jaredmontoya
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1598
merged_at: 2025-07-09 14:57:12+00:00
created_at: 2025-07-16 04:25:34
body:
  ## What this Pull Request (PR) does
  - rename `update` helper to `update-mod`
  - fix `gomod2nix.toml` generation path when when using `update-mod` helper from nix shell.
  - use self reference for getting package sources.

commits:
  [{"SHA":"dd5e57477f2310c9783a7249f4f7a2906678fbd0","Message":"nix:pkgs:fabric: use self reference","Author":"jaredmontoya"},{"SHA":"23c1437794d8317f06fe833f944842a10a687a9a","Message":"shell: rename command","Author":"jaredmontoya"},{"SHA":"7d6505fe9856feb705d69838c04c68fd0cb67fe9","Message":"update-mod: fix generation path","Author":"jaredmontoya"},{"SHA":"1bd5f9d7e4680307ca5fd8f7a5064a3bc849c822","Message":"shell: fix typo","Author":"jaredmontoya"}]


title: Update file paths to reflect new data directory structure
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1599
merged_at: 2025-07-09 15:47:21+00:00
created_at: 2025-07-16 04:25:34
body:
  # Update file paths to reflect new data directory structure

  ## Summary

  This PR updates file paths and references throughout the documentation to reflect a reorganization of the project structure. The changes primarily involve moving patterns and strategies from the root level to a `data/` subdirectory, and updating the `code_helper` binary location from `plugins/tools/` to `cmd/`.

  ## Files Changed

  - **README.md**: Updated multiple file path references and links to reflect the new directory structure
  - **data/patterns/create_coding_feature/README.md**: Updated the installation command for the `code_helper` binary

  ## Code Changes

  ### README.md
  1. **Logo path update**: Changed the fabric logo image source from `./images/fabric-logo-gif.gif` to `./docs/images/fabric-logo-gif.gif`
  2. **Patterns directory reference**: Updated the patterns directory link from `/patterns` to `/data/patterns`
  3. **Strategies directory reference**: Updated the strategies directory link from `/strategies` to `/data/strategies`
  4. **Create coding feature pattern link**: Updated the README reference from `./patterns/create_coding_feature/README.md` to `./data/patterns/create_coding_feature/README.md`

  ### data/patterns/create_coding_feature/README.md
  1. **Installation command update**: Changed the Go install path from `github.com/danielmiessler/fabric/plugins/tools/code_helper@latest` to `github.com/danielmiessler/fabric/cmd/code_helper@latest`

  ## Reason for Changes

  These changes appear to be part of a project restructuring effort to better organize the codebase. The modifications serve to:
  - Consolidate data-related directories (patterns, strategies) under a unified `data/` directory
  - Move the `code_helper` binary from `plugins/tools/` to the more conventional `cmd/` directory
  - Update the documentation structure by moving images to a dedicated `docs/` directory

  ## Impact of Changes

  - **Improved Organization**: The new structure provides better separation of concerns with data files grouped together and binaries in a standard Go project layout
  - **Documentation Consistency**: All references now point to the correct locations, ensuring users can find the resources they need
  - **No Functional Changes**: These are purely organizational changes that don't affect the core functionality of the application

  ## Test Plan

  - Verify that all updated links in the README.md file resolve correctly
  - Confirm that the `code_helper` binary can be installed using the new path
  - Ensure that the fabric logo displays correctly with the updated image path
  - Test that users can navigate to the patterns and strategies directories using the updated links

  ## Additional Notes

  - These changes will require users who have bookmarked or referenced the old paths to update their references
  - The installation instructions for `code_helper` will need to be communicated to existing users
  - Consider adding a migration note or changelog entry to help users understand the structural changes

commits:
  [{"SHA":"2e0a4da8768591680b3403da36dfa6a85eda2761","Message":"docs: update file paths to reflect new data directory structure\n\n## CHANGES\n\n- Move fabric logo image path to docs directory\n- Update patterns directory reference to data/patterns location\n- Update strategies directory reference to data/strategies location\n- Fix create_coding_feature README path reference\n- Update code_helper install path to cmd directory","Author":"Kayvan Sylvan"}]


title: Together AI Support with OpenAI Fallback Mechanism Added
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1603
merged_at: 2025-07-11 20:55:02+00:00
created_at: 2025-07-16 04:25:34
body:
  # Together AI Support with OpenAI Fallback Mechanism Added

  ## Summary

  This pull request adds support for the Together AI provider and implements a fallback mechanism for fetching models from OpenAI-compatible APIs that return non-standard response formats. The changes include a new direct API call method and enhanced model listing functionality.

  ## Related Issues

  Closes #1602 

  ## Demo

  ```text
  $ git diff --staged | summarize_git_diff -m deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free
  <think>
  Okay, so I need to figure out the major changes and upgrades from the given Git diff.
  Let's look at the input files.

  First, there's a new file added: direct_models_call.go. It contains a function DirectlyGetModels which seems
  to fetch models directly from an API. The function constructs a URL, makes a GET request, handles
  different response formats (OpenAI and Together), and parses the JSON responses.

  Next, in providers_config.go, the ListModels method is overridden. It first tries the standard OpenAI SDK
  method. If that doesn't return models, it falls back to the new DirectlyGetModels function. Also, a new
  provider "Together" is added to the ProviderMap with its configuration.

  So the main changes are adding a new method to handle direct model fetching and updating the provider
  list to include Together. The intro should reflect that a new method was added and the provider was included.

  Now, for the CHANGES section, I need to create succinct bullets. Each bullet should describe a feature 
  change. The first bullet could be about adding the new method. The second about adding Together as a
  provider. The third about the fallback behavior in ListModels.

  I need to keep each bullet under 10 words and use imperative verbs. Also, ensure the commit prefix is
  correct. Since this is a new feature, it should be "feat:".

  Putting it all together, the intro sentence and the three bullets should cover the main points 
  without being too wordy.
  </think>

  **feat: add direct model fetching support for non-standard providers**

  **CHANGES**
  - Add `DirectlyGetModels` function to handle non-standard API responses
  - Add Together provider configuration to ProviderMap
  - Implement fallback to direct model fetching when standard method fails
  ```

  ## Files Changed

  ### `internal/plugins/ai/openai_compatible/direct_models_call.go` (New File)
  - **Added**: New file containing the `DirectlyGetModels()` method
  - **Purpose**: Provides a fallback mechanism for fetching models when the standard OpenAI SDK fails due to non-standard API response formats

  ### `internal/plugins/ai/openai_compatible/providers_config.go` (Modified)
  - **Added**: New `ListModels()` method that overrides the default implementation
  - **Added**: Together AI provider configuration in the `ProviderMap`
  - **Purpose**: Enhances model listing with fallback support and adds Together AI as a supported provider

  ## Code Changes

  ### New Direct Models Call Implementation

  ```go
  func (c *Client) DirectlyGetModels() ([]string, error) {
      // Constructs API URL and makes direct HTTP request
      // Handles both OpenAI format (object with data field) and direct array format
      // Returns list of model IDs
  }
  ```

  The method implements dual parsing logic:
  1. First attempts to parse as OpenAI standard format (`{data: [{id: "model"}]}`)
  2. Falls back to direct array format (`[{id: "model"}]`) for providers like Together

  ### Enhanced Model Listing

  ```go
  func (c *Client) ListModels() ([]string, error) {
      models, err := c.Client.ListModels()
      if err == nil && len(models) > 0 {
          return models, nil
      }
      return c.DirectlyGetModels()
  }
  ```

  This method provides a graceful fallback mechanism that tries the standard OpenAI SDK first, then falls back to the direct API call if needed.

  ## Reason for Changes

  The changes address compatibility issues with OpenAI-compatible API providers that don't strictly follow the OpenAI API response format. Specifically:

  1. **Together AI Support**: Adds Together AI as a supported provider, which returns models in a direct array format rather than the standard OpenAI object format
  2. **Improved Robustness**: Provides fallback mechanisms for model fetching when providers use non-standard response formats
  3. **Backward Compatibility**: Maintains existing functionality while adding enhanced support for edge cases

  ## Impact of Changes

  ### Positive Impacts
  - **Extended Provider Support**: Users can now use Together AI as an OpenAI-compatible provider
  - **Improved Reliability**: Model fetching is more robust and handles various API response formats
  - **Better User Experience**: Reduces failures when working with non-standard OpenAI-compatible APIs

  ### Potential Risks
  - **Additional HTTP Requests**: The fallback mechanism may result in extra API calls if the primary method fails
  - **Response Parsing Complexity**: The dual parsing logic adds complexity and potential points of failure
  - **Error Handling**: If both methods fail, error messages may not clearly indicate which approach failed

  ## Test Plan

  The changes should be tested with:

  1. **Standard OpenAI API**: Verify that existing functionality remains intact
  2. **Together AI Provider**: Test model listing and basic functionality with Together AI
  3. **Other OpenAI-compatible providers**: Ensure the fallback mechanism doesn't break existing providers
  4. **Error Scenarios**: Test behavior when API calls fail, return invalid JSON, or return unexpected formats
  5. **Edge Cases**: Test with empty responses, malformed JSON, and network timeouts

  ## Additional Notes

  - The implementation assumes that model objects contain an `id` field, which is standard across most providers
  - The method uses `json.RawMessage` to efficiently handle dual parsing without multiple JSON decoding operations
  - Error handling could be enhanced to provide more specific error messages indicating which parsing method failed
  - Consider adding logging to track which parsing method is used for debugging purposes
  - The Together AI provider is configured with `ImplementsResponses: false`, which may need adjustment based on actual API capabilities

commits:
  [{"SHA":"b9df64a0d8dad1258b08ed92154f8e9f517fd9d0","Message":"feat: add direct model fetching support for non-standard providers\n\n- Add `DirectlyGetModels` function to handle non-standard API responses\n- Add Together provider configuration to ProviderMap\n- Implement fallback to direct model fetching when standard method fails","Author":"Kayvan Sylvan"},{"SHA":"2bedf3595741179975b694a6b22f0dd933df4868","Message":"fix: enhance error messages in OpenAI compatible models endpoint with response body details","Author":"Kayvan Sylvan"},{"SHA":"b9f4b9837aa7d24283dff6fafb6f2cf595c7706a","Message":"refactor: extract model ID parsing logic into reusable helper function","Author":"Kayvan Sylvan"},{"SHA":"a6fc54a9919b5e2a3909973230b81a666b701dae","Message":"refactor: improve OpenAI compatible models API client with timeout and cleaner parsing","Author":"Kayvan Sylvan"},{"SHA":"b187a80275d9c24bf575511d9367cdd96e5761df","Message":"refactor: replace string manipulation with url.JoinPath for models endpoint construction","Author":"Kayvan Sylvan"},{"SHA":"b34f249e241e5cd44a44afcca1e986eae607abfd","Message":"feat: add context support to DirectlyGetModels method\n\n## CHANGES\n\n- Add context parameter to DirectlyGetModels method signature\n- Add nil context check with Background fallback\n- Extract magic number 500 into errorResponseLimit constant\n- Update DirectlyGetModels call to pass context.Background\n- Import context package in providers_config.go file","Author":"Kayvan Sylvan"},{"SHA":"6aeca6e4da8c55280d8088eeaa954a99cc773b96","Message":"fix: improve error message in DirectlyGetModels to include provider name\n\n## CHANGES\n\n- Add provider name to API base URL error message\n- Enhance error context for better debugging experience\n- Include GetName() method call in error formatting","Author":"Kayvan Sylvan"},{"SHA":"6bd305906df8b0613acd4246108b7f337c56376d","Message":"fix: increase error response limit and simplify model extraction logic\n\n## CHANGES\n\n- Increase error response limit from 500 to 1024 bytes\n- Add documentation comment for ErrorResponseLimit constant\n- Remove unnecessary error return from extractModelIDs function\n- Fix return statements in DirectlyGetModels parsing logic\n- Add TODO comment for proper context handling\n- Simplify model ID extraction without error propagation","Author":"Kayvan Sylvan"},{"SHA":"7ed4de269eb3b604b211d4a0111d86d1f39e1040","Message":"chore: refactor DirectlyGetModels to read response body once\n\n## CHANGES\n* Read response body once for efficiency\n* Use io.ReadAll for response body\n* Unmarshal json from bodyBytes\n* Return error with raw response bytes\n* Improve error handling for json parsing","Author":"Kayvan Sylvan"},{"SHA":"ecac2b4c34ebd4f85af4891613c74881fff1ca1c","Message":"refactor: clean up HTTP request handling and improve error response formatting\n\n## CHANGES\n\n- Remove unnecessary else block in HTTP request creation\n- Move header setting outside conditional block for clarity\n- Add TODO comment about reusing HTTP client instance\n- Truncate error response output to prevent excessive logging","Author":"Kayvan Sylvan"},{"SHA":"e1945a0b62ceece6afcaf3f83de88bb52db6066b","Message":"fix: improve error message truncation in DirectlyGetModels method\n\n## CHANGES\n\n- Add proper bounds checking for response body truncation\n- Prevent slice out of bounds errors in error messages\n- Add ellipsis indicator when response body is truncated\n- Improve error message clarity for debugging purposes","Author":"Kayvan Sylvan"},{"SHA":"87796d4fa9e49b443c641a80906a242475f22955","Message":"chore: optimize model ID extraction and remove redundant comment\n\n## CHANGES\n\n- Remove duplicate comment about reading response body\n- Preallocate slice capacity in extractModelIDs function\n- Initialize modelIDs slice with known capacity","Author":"Kayvan Sylvan"}]


title: Changelog Generator: AI-Powered Automation for Fabric Project
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1611
merged_at: 2025-07-14 03:42:41+00:00
created_at: 2025-07-16 04:25:34
body:
  # Changelog Generator: AI-Powered Automation for Fabric Project

  ## Summary

  This PR introduces a comprehensive changelog generation system for the Fabric project, featuring a high-performance Go tool with advanced caching, GitHub API integration, and AI-powered summarization capabilities.

  > NOTE: CI/CD integration and automated ChangeLog processing will be in a subsequent PR.

  ## Related Issues

  Closes #1608 

  ## Files Changed

  ### New Files Added:
  - **CHANGELOG.md**: Complete project changelog with 2,343 entries spanning the entire repository history
  - **cmd/generate_changelog/**: New command-line tool with modular architecture
    - `main.go`: CLI entry point with Cobra framework
    - `PRD.md` & `README.md`: Comprehensive documentation
    - `changelog.db`: SQLite cache database
    - `internal/`: Modular packages for git, GitHub, cache, and changelog operations

  ### Modified Files:
  - **.gitignore**: Updated to exclude temporary directories and include VSCode settings
  - **.vscode/**: Added VSCode configuration with spell check and markdown linting
  - **go.mod/go.sum**: Added new dependencies for changelog generation

  ## Code Changes

  ### Core Architecture
  The changelog generator implements a sophisticated multi-module system:

  ```go
  // One-pass git history walking algorithm
  func (w *Walker) WalkHistory() (map[string]*Version, error) {
      // Efficiently processes entire repository history in single pass
      // Buckets commits by version starting with "Unreleased"
  }
  ```

  ### GitHub API Integration
  - **GraphQL optimization**: Reduces API calls by 50%+ through batch fetching
  - **Concurrent processing**: Up to 10 parallel requests with rate limiting
  - **Smart caching**: SQLite-based persistent storage with incremental updates

  ### AI Enhancement System
  ```go
  func SummarizeVersionContent(content string) (string, error) {
      // Uses Fabric CLI for AI-powered changelog summarization
      // Preserves PR headers while condensing change descriptions
  }
  ```

  ## Reason for Changes

  1. **Automation Need**: Manual changelog maintenance was becoming unsustainable with frequent releases
  2. **Performance Requirements**: Needed fast generation suitable for CI/CD integration
  3. **Completeness**: Required capture of ALL commits including unreleased changes
  4. **GitHub Integration**: Wanted rich PR information with author details and change descriptions

  ## Impact of Changes

  ### Performance Benefits
  - **Sub-5 second generation** for large repositories
  - **50%+ reduction in GitHub API calls** through GraphQL optimization
  - **Instant regeneration** from cache for unchanged content
  - **Cross-platform compatibility** with no external dependencies

  ### Workflow Improvements
  - **Automated release process**: Can be integrated into CI/CD pipelines
  - **Comprehensive tracking**: Captures both PR-based and direct commits
  - **AI enhancement**: Optional intelligent summarization for better readability
  - **Incremental updates**: Only processes new commits on subsequent runs

  ### Developer Experience
  - **Rich output format**: Markdown with proper linking and formatting
  - **Flexible configuration**: Multiple output formats and filtering options
  - **Robust error handling**: Graceful fallbacks and detailed error messages

  ## Test Plan

  The changelog generator has been tested with:

  1. **Full repository scan**: Successfully processed 2,343+ changelog entries
  2. **Incremental updates**: Verified proper handling of new commits since last tag
  3. **GitHub API integration**: Tested with both REST and GraphQL endpoints
  4. **Cache performance**: Validated SQLite operations and data persistence
  5. **AI summarization**: Tested optional enhancement with Fabric integration
  6. **Cross-platform compatibility**: Verified operation on multiple operating systems

  ## Additional Notes

  ### Potential Bugs and Considerations

  1. **GitHub Rate Limiting**: The tool respects rate limits but may hit them with very large repositories
  2. **AI Dependency**: AI summarization requires Fabric CLI to be available in PATH
  3. **Memory Usage**: Large repositories may consume significant memory during processing
  4. **Network Dependency**: Requires internet connection for GitHub API access
  5. **Cache Corruption**: SQLite cache could become corrupted, though rebuild functionality exists

  ### Future Enhancements

  The modular architecture supports planned features like:
  - Multiple output formats (JSON, HTML)
  - Custom version patterns
  - Conventional commit support
  - GitLab/Bitbucket integration
  - Breaking change detection

  This implementation provides a solid foundation for automated changelog generation while maintaining flexibility for future requirements.

commits:
  [{"SHA":"cb837bde2d9a89b510ed9fd3f5d12e1c73d034eb","Message":"feat: add AI-powered changelog generation with high-performance Go tool and comprehensive caching\n\n## CHANGES\n\n- Add high-performance Go changelog generator with GraphQL integration\n- Implement SQLite-based persistent caching for incremental updates\n- Create one-pass git history walking algorithm with concurrent processing\n- Add comprehensive CLI with cobra framework and tag-based caching\n- Integrate AI summarization using Fabric CLI for enhanced output\n- Support batch PR fetching with GitHub Search API optimization\n- Add VSCode configuration with spell checking and markdown linting\n- Include extensive documentation with PRD and README files\n- Implement commit-PR mapping for lightning-fast git operations\n- Add content hashing for change detection and cache optimization","Author":"Kayvan Sylvan"},{"SHA":"04c3c0c5128eca8e0569307717ed9b652fdaeb04","Message":"docs: Update CHANGELOG","Author":"Kayvan Sylvan"}]


title: Improve AI Summarization for Consistent Professional Changelog Entries
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1613
merged_at: 2025-07-15 07:05:45+00:00
created_at: 2025-07-16 04:25:34
body:
  # Improve AI Summarization for Consistent Professional Changelog Entries

  ## Summary

  This pull request updates the changelog generation system with bug fixes, performance improvements, and enhanced caching capabilities. The changes focus on improving incremental updates, better handling of version tags, and enhanced pattern management functionality.

  Also, this fixes a bug with the Custom Patterns Directory (it was not persisting after being set).

  ## Files Changed

  ### CHANGELOG.md
  - Refined changelog descriptions for better clarity and consistency
  - Streamlined bullet points and improved formatting across multiple version entries

  ### cmd/generate_changelog/changelog.db
  - Binary database file updated with new cached data

  ### cmd/generate_changelog/internal/changelog/generator.go
  - Enhanced caching logic to handle new tags since last cache update
  - Improved incremental processing by merging new versions with cached data
  - Added proper cache saving for new versions after AI processing
  - Optimized the `collectData()` method to better handle tag progression
  - Removed commit message prefix filtering logic for cleaner output

  ### cmd/generate_changelog/internal/changelog/summarize.go
  - Completely rewrote the AI summarization prompt for better technical writing
  - Added detailed instructions for preserving PR headers and formatting
  - Increased minimum content length handling and improved error messaging
  - Enhanced prompt to focus on top 5 most impactful changes

  ### cmd/generate_changelog/internal/git/walker.go
  - Added new `WalkHistorySinceTag()` method for processing commits between tags
  - Improved git history traversal for incremental changelog generation
  - Enhanced version detection and commit processing logic

  ### internal/core/plugin_registry.go
  - Added configuration for custom patterns directory
  - Implemented home directory expansion for custom patterns path
  - Enhanced database pattern directory refresh after plugin configuration

  ### internal/plugins/db/fsdb/sessions.go
  - Improved message content formatting in session strings
  - Enhanced multi-content message handling with better type switching

  ### internal/tools/patterns_loader.go
  - Added `createUniquePatternsFile()` method for generating pattern lists
  - Implemented pattern deduplication across main and custom directories
  - Enhanced pattern population with unique patterns file creation
  - Added support for custom patterns directory integration

  ## Reason for Changes

  These changes address several key issues:

  1. **Incremental Processing**: The changelog generator now properly handles new tags since the last cache update, avoiding full regeneration
  2. **Cache Optimization**: Improved caching logic reduces redundant AI processing and git history walking
  3. **Pattern Management**: Enhanced pattern loading to support custom directories and generate comprehensive pattern lists
  4. **Content Quality**: Better AI summarization prompts produce more consistent and professional changelog entries

  ## Impact of Changes

  - **Performance**: Significantly faster changelog generation through improved caching and incremental processing
  - **Accuracy**: Better handling of version tags and commit processing reduces errors in changelog generation
  - **Flexibility**: Enhanced pattern management supports custom pattern directories for extended functionality
  - **Quality**: Improved AI summarization produces more consistent and professional changelog content

  ## Test Plan

  The changes should be tested by:
  1. Running the changelog generator with existing cache to verify incremental updates work correctly
  2. Testing pattern loading with both main and custom pattern directories
  3. Verifying AI summarization produces properly formatted output with preserved PR headers
  4. Confirming that new tags are properly processed and cached

  ## Additional Notes

  - The binary database file update indicates successful testing of the caching improvements
  - The AI summarization prompt has been significantly enhanced to produce more consistent technical writing
  - Custom pattern directory support provides better flexibility for users with extended pattern collections
  - The incremental processing improvements should reduce changelog generation time for repositories with extensive history

commits:
  [{"SHA":"cf074d34110f74d861da7364423dd254dbd25906","Message":"feat: enhance changelog generation with incremental caching and improved AI summarization\n\n## CHANGES\n\n- Add incremental processing for new Git tags since cache\n- Implement `WalkHistorySinceTag` method for efficient history traversal\n- Cache new versions and commits after AI processing\n- Update AI summarization prompt for better release note formatting\n- Remove conventional commit prefix stripping from commit messages\n- Add custom patterns directory support to plugin registry\n- Generate unique patterns file including custom directory patterns\n- Improve session string formatting with switch statement","Author":"Kayvan Sylvan"},{"SHA":"c36942570849719cb7396c4895220421f3d9e3d9","Message":"chore: clean up changelog and add debug logging for content length validation","Author":"Kayvan Sylvan"},{"SHA":"9e4ed8ecb3a6dd4509ba8941285cb392be8c0520","Message":"fix: improve git walking termination and error handling in changelog generator\n\n## CHANGES\n\n- Add storer import for proper git iteration control\n- Use storer.ErrStop instead of nil for commit iteration termination\n- Handle storer.ErrStop as expected condition in git walker\n- Update cache comment to clarify Unreleased version skipping\n- Change custom patterns warning to stderr output\n- Add storer to VSCode spell checker dictionary","Author":"Kayvan Sylvan"},{"SHA":"06fc8d8732c6d4e394afe9241eccba10412f38cd","Message":"chore: reorder plugin configuration sequence in PluginRegistry.Configure method\n\n## CHANGES\n\n- Move CustomPatterns.Configure() before PatternsLoader.Configure()\n- Adjust plugin initialization order in Configure method\n- Ensure proper dependency sequence for pattern loading","Author":"Kayvan Sylvan"},{"SHA":"cc378be4852a3dd5aef5e922817b06204d22eba3","Message":"feat: improve error handling in `plugin_registry` and `patterns_loader`\n\n### CHANGES\n\n- Adjust prompt formatting in `summarize.go`\n- Add error handling for `CustomPatterns` configuration\n- Enhance error messages in `patterns_loader`\n- Check for patterns in multiple directories","Author":"Kayvan Sylvan"},{"SHA":"12ee690ae485e28c4fba3351a014d620fa750a96","Message":"chore: remove debug logging and sync custom patterns directory configuration\n\n## CHANGES\n\n- Remove debug stderr logging from content summarization\n- Add custom patterns directory to PatternsLoader configuration\n- Ensure consistent patterns directory setup across components\n- Clean up unnecessary console output during summarization","Author":"Kayvan Sylvan"},{"SHA":"4ef8578e474b43e86f4c0520018c96086d1d7f68","Message":"fix: improve error handling in plugin registry configuration","Author":"Kayvan Sylvan"},{"SHA":"f63e0dfc0550d41897b5e552d2fae744ffb9a181","Message":"chore: update logging output to use os.Stderr","Author":"Kayvan Sylvan"}]


title: Preserve PR Numbers During Version Cache Merges
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1616
merged_at: 2025-07-16 00:23:17+00:00
created_at: 2025-07-16 04:25:34
body:
  # Preserve PR Numbers During Version Cache Merges

  ## Summary

  This pull request enhances the changelog generation system by improving PR number tracking and handling of version data. The changes focus on better collection and preservation of PR numbers across different versions, particularly addressing issues with missing PR numbers in cached versions.

  ## Files Changed

  - **CHANGELOG.md**: Added an "Unreleased" section header to maintain consistent changelog structure
  - **cmd/generate_changelog/changelog.db**: Updated binary database file (likely containing cached changelog data)
  - **cmd/generate_changelog/internal/changelog/generator.go**: Enhanced version merging logic to preserve PR numbers from cached data
  - **cmd/generate_changelog/internal/git/walker.go**: Improved PR number extraction and tracking across all commits, not just merge commits

  ## Code Changes

  ### CHANGELOG.md
  ```markdown
  +## Unreleased
  +
  ```
  Added a new "Unreleased" section to maintain proper changelog structure.

  ### generator.go
  ```go
  -if _, exists := g.versions[name]; !exists {
  +if existingVersion, exists := g.versions[name]; !exists {
      g.versions[name] = version
  +} else {
  +    // Update existing version with new PR numbers if they're missing
  +    if len(existingVersion.PRNumbers) == 0 && len(version.PRNumbers) > 0 {
  +        existingVersion.PRNumbers = version.PRNumbers
  +    }
  +}
  ```
  Enhanced the version merging logic to update existing cached versions with PR numbers when they're missing, preventing data loss during cache updates.

  ### walker.go
  ```go
  +prNumbers := make(map[string][]int)

  -if commit.IsMerge {
  -    if matches := prPattern.FindStringSubmatch(commit.Message); len(matches) > 1 {
  -        if prNumber, err := strconv.Atoi(matches[1]); err == nil {
  -            commit.PRNumber = prNumber
  -        }
  -    }
  -}
  +if matches := prPattern.FindStringSubmatch(commit.Message); len(matches) > 1 {
  +    prNumber := 0
  +    fmt.Sscanf(matches[1], "%d", &prNumber)
  +    commit.PRNumber = prNumber
  +
  +    prNumbers[currentVersion] = append(prNumbers[currentVersion], prNumber)
  +}
  ```
  Removed the restriction that only merge commits can have PR numbers, allowing all commits with PR references to be tracked. Also added centralized PR number collection per version.

  ## Reason for Changes

  These changes address several issues in the changelog generation system:

  1. **Missing PR Numbers**: The previous implementation only tracked PR numbers for merge commits, missing PR references in regular commits
  2. **Data Loss in Cache Updates**: When merging new version data with cached data, PR numbers were being lost if they existed in the cache but not in the new data
  3. **Inconsistent Changelog Structure**: The changelog needed a proper "Unreleased" section for ongoing development

  ## Impact of Changes

  - **Improved Data Integrity**: PR numbers are now preserved across cache updates, preventing data loss
  - **Better PR Tracking**: All commits with PR references are now tracked, not just merge commits
  - **Enhanced Changelog Quality**: More complete and accurate changelog entries with proper PR attribution
  - **Consistent Structure**: Standardized changelog format with proper section headers

  ## Test Plan

  The changes should be tested by:
  1. Running the changelog generator on a repository with various commit types (merge commits, regular commits with PR references)
  2. Verifying that PR numbers are correctly extracted and preserved across multiple runs
  3. Checking that cached data is properly merged without losing existing PR number information
  4. Ensuring the "Unreleased" section appears correctly in generated changelogs

  ## Additional Notes

  - The binary database file update suggests that the caching mechanism has been updated to reflect the new PR number handling
  - The use of `fmt.Sscanf` instead of `strconv.Atoi` provides more robust number parsing
  - The `dedupInts` function is used to remove duplicate PR numbers, ensuring clean output
  - These changes maintain backward compatibility while improving the robustness of the changelog generation process

commits:
  [{"SHA":"7e299666226048b312099fe22649ca3170df51b8","Message":"feat: enhance changelog to correctly associate PR numbers with version tags\n\n### CHANGES\n\n-   Collect all PR numbers for commits between version tags.\n-   Associate aggregated PR numbers with each version entry.\n-   Update cached versions with newly found PR numbers.\n-   Attribute all changes in a version to relevant PRs.","Author":"Kayvan Sylvan"},{"SHA":"3176adf59ba5f72c3dd653b4f79f35713e7ac77a","Message":"fix: improve PR number parsing with proper error handling","Author":"Kayvan Sylvan"}]


title: Improve PR Sync Logic for Changelog Generator
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1617
merged_at: 2025-07-16 01:30:42+00:00
created_at: 2025-07-16 04:25:34
body:
  # Improve PR Sync Logic for Changelog Generator

  ## Summary

  This PR enhances the changelog generation system to properly preserve and associate PR numbers with version tags during cache merges. The changes improve the accuracy of changelog entries by ensuring that PR numbers are correctly maintained when versions are cached and retrieved.

  ## Files Changed

  - **CHANGELOG.md**: Added new version entry v1.4.248 with detailed changelog improvements
  - **cmd/generate_changelog/changelog.db**: Updated binary database file with new cached data
  - **cmd/generate_changelog/internal/changelog/generator.go**: Enhanced PR fetching logic to handle missing PRs in cached versions

  ## Code Changes

  ### cmd/generate_changelog/internal/changelog/generator.go

  The most significant changes are in the `fetchPRs()` method:

  ```go
  // Check if we need to sync for missing PRs
  missingPRs := false
  for _, version := range g.versions {
      for _, prNum := range version.PRNumbers {
          if _, exists := g.prs[prNum]; !exists {
              missingPRs = true
              break
          }
      }
      if missingPRs {
          break
      }
  }

  // If we have never synced or it's been more than 24 hours, do a full sync
  // Also sync if we have versions with PR numbers that aren't cached
  needsSync := lastSync.IsZero() || time.Since(lastSync) > 24*time.Hour || g.cfg.ForcePRSync || missingPRs
  ```

  This code adds a check to determine if any versions have PR numbers that aren't present in the cached PR data, and forces a sync if missing PRs are detected.

  ### CHANGELOG.md

  Added a new version entry documenting the improvements made to the changelog system itself, including proper attribution of changes to PR #1616.

  ## Reason for Changes

  The changes address an issue where PR numbers associated with version tags were not being properly preserved during cache operations. Previously, when versions were cached and later retrieved, the PR number associations could be lost, leading to incomplete or inaccurate changelog entries.

  ## Impact of Changes

  - **Improved Accuracy**: Changelog entries will now correctly display all associated PR numbers for each version
  - **Better Caching Logic**: The system now intelligently detects when cached PR data is incomplete and triggers appropriate syncing
  - **Enhanced User Experience**: Users will see more complete and accurate changelog information with proper PR attributions

  ## Test Plan

  The changes should be tested by:
  1. Running the changelog generator with existing cached data to ensure missing PRs are detected
  2. Verifying that forced syncing occurs when PR numbers are missing from the cache
  3. Confirming that the generated changelog properly associates PR numbers with their respective versions
  4. Testing the caching mechanism to ensure it doesn't unnecessarily sync when all PR data is present

  ## Additional Notes

  - The binary database file has been updated to reflect the new caching logic
  - The `missingPRs` flag ensures that the system is more robust in handling incomplete cached data
  - The changelog now properly documents its own improvements, creating a self-referential but accurate record of the enhancement

  **Potential Issues to Monitor:**
  - Performance impact of the additional PR number checking logic
  - Ensure the nested loop breaks properly to avoid unnecessary iterations
  - Verify that the database updates don't cause corruption or compatibility issues

commits:
  [{"SHA":"d3bba5d026dd17ddcc0f366c65c7de5fe749a7cd","Message":"feat: preserve PR numbers during version cache merges\n\n### CHANGES\n\n- Enhance changelog to associate PR numbers with version tags\n- Improve PR number parsing with proper error handling\n- Collect all PR numbers for commits between version tags\n- Associate aggregated PR numbers with each version entry\n- Update cached versions with newly found PR numbers\n- Add check for missing PRs to trigger sync if needed","Author":"Kayvan Sylvan"},{"SHA":"6d8eb3d2b9cf7e5188d07248bbea7894ed409971","Message":"chore: add log message for missing PRs in cache","Author":"Kayvan Sylvan"}]


title: Update GitHub Workflow to Ignore Additional File Paths
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1618
merged_at: 2025-07-16 03:47:35+00:00
created_at: 2025-07-16 04:25:34
body:
  # Update GitHub Workflow to Ignore Additional File Paths

  ## Summary

  This PR modifies the GitHub workflow configuration to exclude additional file paths from triggering the version update and tag creation workflow. The changes add two new path patterns to the `paths-ignore` list in the workflow trigger configuration.

  ## Files Changed

  - **`.github/workflows/update-version-and-create-tag.yml`**: Updated the workflow trigger configuration to ignore additional file paths that should not trigger version updates and tag creation.

  ## Code Changes

  The following paths were added to the `paths-ignore` section of the workflow trigger:

  ```yaml
  - "data/strategies/**"
  - "cmd/generate_changelog/*.db"
  ```

  These additions expand the existing ignore patterns which already included:
  - `"data/patterns/**"`
  - `"**/*.md"`

  ## Reason for Changes

  These changes prevent the version update and tag creation workflow from being triggered by:

  1. **Strategy files** (`data/strategies/**`): Changes to strategy files do not merit a new release.
  2. **Database files** (`cmd/generate_changelog/*.db`): Database files in the changelog generation command are cache files used to regenerate the CHANGELOG.md file.

  This follows the same pattern as the existing ignores for pattern data files and markdown documentation, which are considered non-release-worthy changes.

  ## Impact of Changes

  - **Reduced unnecessary workflow runs**: The workflow will no longer trigger for changes to strategy files or changelog database files, reducing CI/CD resource usage
  - **More precise release triggers**: Version updates and tags will only be created for substantive code changes, not for data or temporary file updates
  - **Improved workflow efficiency**: Fewer false-positive triggers will result in a cleaner release history

  ## Test Plan

  - Verify that changes to files matching `data/strategies/**` do not trigger the workflow
  - Verify that changes to files matching `cmd/generate_changelog/*.db` do not trigger the workflow
  - Confirm that substantive code changes outside these paths still trigger the workflow as expected
  - Test that the existing ignore patterns continue to work correctly

  ## Additional Notes

  This change maintains consistency with the existing workflow design philosophy of ignoring non-code changes that don't impact the application's functionality. The workflow will continue to trigger for all other file changes, ensuring that actual code modifications still result in appropriate version updates and tag creation.

commits:
  [{"SHA":"135433b74990102cf3a58c40fd97958168ab6a5e","Message":"ci: update workflow to ignore additional paths during version updates\n\n## CHANGES\n\n- Add `data/strategies/**` to paths-ignore list\n- Add `cmd/generate_changelog/*.db` to paths-ignore list\n- Prevent workflow triggers from strategy data changes\n- Prevent workflow triggers from changelog database files","Author":"Kayvan Sylvan"}]


title: Feature: Optional Hiding of Model Thinking Process with Configurable Tags
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1619
merged_at: 2025-07-16 05:04:12+00:00
created_at: 2025-07-16 05:07:47
body:
  # Feature: Optional Hiding of Model Thinking Process with Configurable Tags

  ## Summary

  This pull request implements a new feature to suppress "thinking" output from Claude models. The feature allows users to hide internal reasoning text that appears between configurable start and end tags (defaulting to `<think>` and `</think>`), while still displaying the final response to the user.

  <img width="788" height="123" alt="image" src="https://github.com/user-attachments/assets/dffd9b11-6630-424b-bc8e-dffd88c8a2ad" />


  ## Related Issues

  Closes #1458 

  ## Files Changed

  - **internal/cli/chat.go**: Modified output logic to handle suppressed thinking mode
  - **internal/cli/example.yaml**: Added configuration examples for the new thinking suppression feature
  - **internal/cli/flags.go**: Added new command-line flags and YAML configuration options for thinking suppression
  - **internal/cli/flags_test.go**: Added test coverage for the new thinking suppression flags
  - **internal/core/chatter.go**: Implemented core logic to suppress streaming output and filter thinking blocks
  - **internal/core/chatter_test.go**: Added comprehensive tests for the thinking suppression functionality
  - **internal/domain/domain.go**: Extended ChatOptions struct with thinking suppression configuration
  - **internal/domain/think.go**: New utility module for stripping thinking blocks from text
  - **internal/domain/think_test.go**: Test coverage for the thinking block stripping functionality

  ## Code Changes

  ### New Command-Line Flags
  ```go
  SuppressThink     bool   `long:"suppress-think" yaml:"suppressThink" description:"Suppress text enclosed in thinking tags"`
  ThinkStartTag     string `long:"think-start-tag" yaml:"thinkStartTag" description:"Start tag for thinking sections" default:"<think>"`
  ThinkEndTag       string `long:"think-end-tag" yaml:"thinkEndTag" description:"End tag for thinking sections" default:"</think>"`
  ```

  ### Core Filtering Logic
  ```go
  if opts.SuppressThink {
      message = domain.StripThinkBlocks(message, opts.ThinkStartTag, opts.ThinkEndTag)
  }
  ```

  ### Streaming Output Control
  ```go
  if !opts.SuppressThink {
      fmt.Print(response)
  }
  ```

  ### Text Processing Function
  ```go
  func StripThinkBlocks(input, startTag, endTag string) string {
      if startTag == "" || endTag == "" {
          return input
      }
      pattern := "(?s)" + regexp.QuoteMeta(startTag) + ".*?" + regexp.QuoteMeta(endTag) + "\\s*"
      re := regexp.MustCompile(pattern)
      return re.ReplaceAllString(input, "")
  }
  ```

  ## Reason for Changes

  This feature addresses the need to hide Claude's internal reasoning process from end users while still allowing the model to perform its thinking steps. When Claude models use thinking tags to show their reasoning process, users may want to see only the final answer without the intermediate steps. This is particularly useful for:

  1. Cleaner output in production environments
  2. Focusing on results rather than process
  3. Reducing cognitive load for end users
  4. Maintaining the benefits of model reasoning without exposing internal details

  ## Impact of Changes

  ### Positive Impacts:
  - **User Experience**: Provides cleaner, more focused output when thinking suppression is enabled
  - **Flexibility**: Configurable tags allow adaptation to different model behaviors
  - **Backward Compatibility**: Feature is opt-in and doesn't affect existing functionality
  - **Performance**: Minimal overhead when feature is disabled

  ### Potential Concerns:
  - **Regex Performance**: The regex-based stripping could impact performance with very large responses
  - **Tag Matching**: Malformed or nested tags might cause unexpected behavior
  - **Streaming Behavior**: When thinking is suppressed, streaming effectively becomes disabled for the thinking portions

  ## Test Plan

  The changes include comprehensive test coverage:

  1. **Unit Tests**: New tests verify thinking block stripping with default and custom tags
  2. **Integration Tests**: Tests ensure the feature works end-to-end with the chatter system
  3. **Flag Tests**: Verification that command-line flags and YAML configuration work correctly
  4. **Edge Cases**: Tests handle empty tags and malformed input

  Testing should verify:
  - Thinking blocks are properly removed from output
  - Custom tags work as expected
  - Streaming behavior is correct when suppression is enabled
  - Configuration via both CLI flags and YAML works
  - Performance with large responses containing thinking blocks

  ## Additional Notes

  - The feature uses regex with the `(?s)` flag to handle multi-line thinking blocks
  - Default tags are `<think>` and `</think>` but can be customized
  - When thinking suppression is enabled, the final output logic treats it similarly to non-streaming mode
  - The regex pattern includes `\s*` to clean up whitespace after thinking blocks
  - All existing functionality remains unchanged when the feature is disabled

commits:
  [{"SHA":"cb90379b30505329327738d8b5d75840f7fdb9db","Message":"feat: add suppress-think feature to filter AI reasoning output\n\n## CHANGES\n\n- Add suppress-think flag to hide thinking blocks\n- Configure customizable start and end thinking tags\n- Strip thinking content from final response output\n- Update streaming logic to respect suppress-think setting\n- Add YAML configuration support for thinking options\n- Implement StripThinkBlocks utility function for content filtering\n- Add comprehensive tests for thinking suppression functionality","Author":"Kayvan Sylvan"},{"SHA":"a2e618e11c5bacca975c15e3d6ebc3ad1090296e","Message":"perf: add regex caching to `StripThinkBlocks` function for improved performance","Author":"Kayvan Sylvan"}]


title: Update Shell Completions for New Think-Block Suppression Options
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1620
merged_at: 2025-07-16 05:32:41+00:00
created_at: 2025-07-16 05:35:14
body:
  # Update Shell Completions for New Think-Block Suppression Options

  ## Summary

  This PR introduces thinking tag suppression functionality to Fabric and streamlines the README documentation. The changes add the ability to filter out AI model "thinking" sections from output while consolidating changelog information into a dedicated file.

  ## Related Issues

  #1458 

  ## Files Changed

  - **README.md**: Removed detailed changelog entries and replaced with reference to CHANGELOG.md
  - **completions/_fabric**: Added zsh completion support for new thinking tag options
  - **completions/fabric.bash**: Added bash completion support for new thinking tag options  
  - **completions/fabric.fish**: Added fish shell completion support for new thinking tag options

  ## Code Changes

  ### README.md
  The most significant change removes approximately 20 lines of detailed update notes and replaces them with a concise reference:

  ```markdown
  -July 4, 2025
  -- **Web Search**: Fabric now supports web search for Anthropic and OpenAI models...
  -- **Image Generation**: Fabric now has powerful image generation capabilities...
  -June 17, 2025
  -- Fabric now supports Perplexity AI...
  -June 11, 2025  
  -- Fabric's YouTube transcription now needs `yt-dlp` to be installed...

  +Fabric is evolving rapidly.
  +
  +Stay current with the latest features by reviewing the [CHANGELOG](./CHANGELOG.md) for all recent changes.
  ```

  ### Shell Completions
  All three shell completion files add support for three new command-line options:
  - `--suppress-think`: Boolean flag to suppress thinking sections
  - `--think-start-tag`: Configurable start tag (default: `<think>`)
  - `--think-end-tag`: Configurable end tag (default: `</think>`)

  ## Reason for Changes

  1. **Documentation Organization**: Moving changelog details to a dedicated CHANGELOG.md file improves README maintainability and reduces clutter
  2. **Thinking Tag Suppression**: AI models often include internal reasoning in `<think>` tags that users may want to filter out from final output
  3. **Customizable Tags**: Allowing custom thinking tags provides flexibility for different AI models or use cases

  ## Impact of Changes

  **Positive Impacts:**
  - Cleaner, more focused README that's easier to maintain
  - Enhanced user control over AI output formatting
  - Better shell completion experience with new options
  - Improved separation of concerns (README vs. changelog)

  **Potential Issues:**
  - Users accustomed to finding changelog in README may need to adjust
  - The thinking tag suppression could inadvertently filter legitimate content if users configure tags poorly
  - No validation appears to be in place for custom thinking tags

  ## Test Plan

  The changes should be tested by:
  1. Verifying shell completions work correctly for all three shells (bash, zsh, fish)
  2. Testing the `--suppress-think` flag with default `<think>` tags
  3. Testing custom thinking tags with `--think-start-tag` and `--think-end-tag`
  4. Ensuring the CHANGELOG.md link in README resolves correctly
  5. Confirming that malformed or overlapping thinking tags are handled gracefully

  ## Additional Notes

  - The implementation assumes the CHANGELOG.md file exists and is properly maintained
  - Consider adding validation for thinking tag configuration to prevent edge cases
  - The feature appears to be purely client-side filtering, which is appropriate for this use case
  - Shell completion updates are comprehensive and consistent across all supported shells

commits:
  [{"SHA":"c38c16f0db8fb2d64148fceae412d28f9435b1e0","Message":"docs: Update CHANGELOG after v.1.4.252","Author":"Kayvan Sylvan"},{"SHA":"1473ac1465b250d3643eedad59c15c7434e26a7d","Message":"feat: add 'think' tag options for text suppression and completion\n\n### CHANGES\n\n- Remove outdated update notes from README\n- Add `--suppress-think` option to suppress 'think' tags\n- Introduce `--think-start-tag` and `--think-end-tag` options\n- Update bash completion with 'think' tag options\n- Update fish completion with 'think' tag options","Author":"Kayvan Sylvan"}]


title: Adds generate code rules pattern
author: robertocarvajal
author_url: https://github.com/robertocarvajal
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1621
merged_at: 2025-07-16 21:19:46+00:00
created_at: 2025-07-16 21:43:59
body:
  ## What this Pull Request (PR) does

  Adds a pattern to quickly generate coding rules from articles, YT tutorials, etc. Useful to update best practices patterns for AI assisted coding tools like Cursor, Claude Code, etc.

commits:
  [{"SHA":"63f4370ff14a8ec2450360e691fb1c9bda63c9fe","Message":"Adds generate code rules pattern\n\nSigned-off-by: Roberto Carvajal \u003croberto.carvajal@gmail.com\u003e","Author":"Roberto Carvajal"}]


title: Feature: Add Automatic ~/.fabric.yaml Config Detection
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1624
merged_at: 2025-07-17 14:13:17+00:00
created_at: 2025-07-17 14:16:02
body:
  # Feature: Add Automatic ~/.fabric.yaml Config Detection

  ## Summary

  This PR introduces several improvements to the CLI flag handling system, enhances the dry run functionality, and adds automatic configuration file detection. The changes focus on better flag-to-YAML mapping, improved dry run output consistency, and automatic detection of the default `~/.fabric.yaml` configuration file.

  ## Files Changed

  - **`internal/cli/flags.go`**: Enhanced flag parsing logic with improved YAML tag mapping and automatic config file detection
  - **`internal/core/chatter.go`**: Fixed think block suppression logic for dry run mode
  - **`internal/plugins/ai/dryrun/dryrun.go`**: Improved dry run output formatting and consistency
  - **`internal/util/utils.go`**: Added utility function for default configuration path detection

  ## Code Changes

  ### `internal/cli/flags.go`
  - Replaced simple `yamlFields` map with `flagToYamlTag` mapping that connects both short and long flags to their corresponding YAML tags
  - Enhanced argument parsing to handle both long (`--flag`) and short (`-f`) flag formats
  - Added automatic detection and loading of `~/.fabric.yaml` when no config is explicitly specified
  - Improved debug logging to show flag-to-YAML tag mappings

  ```go
  // Create mapping from flag names (both short and long) to yaml tag names
  flagToYamlTag := make(map[string]string)
  ```

  ### `internal/core/chatter.go`
  - Fixed think block suppression logic to only apply when not in dry run mode:

  ```go
  if opts.SuppressThink && !o.DryRun {
      message = domain.StripThinkBlocks(message, opts.ThinkStartTag, opts.ThinkEndTag)
  }
  ```

  ### `internal/plugins/ai/dryrun/dryrun.go`
  - Added consistent dry run response constant
  - Enhanced options formatting to include think suppression settings
  - Refactored request construction into reusable `_ConstructRequest` method
  - Made `Send` method return actual response instead of empty string

  ### `internal/util/utils.go`
  - Added `GetDefaultConfigPath()` function to check for and return the default `~/.fabric.yaml` configuration file path

  ## Reason for Changes

  These changes address several usability and functionality issues:

  1. **Improved Flag Handling**: The previous system only mapped long flags to YAML tags, missing short flag support
  2. **Better User Experience**: Automatic detection of `~/.fabric.yaml` eliminates the need to explicitly specify the config path
  3. **Dry Run Consistency**: The dry run plugin now provides consistent output and proper response handling
  4. **Think Block Logic**: Fixed a bug where think blocks were being stripped even in dry run mode, which could hide important debugging information

  ## Impact of Changes

  - **Enhanced CLI Usability**: Users can now use short flags that will properly map to YAML configuration values
  - **Simplified Configuration**: Automatic config file detection reduces setup friction for new users
  - **Better Debugging**: Dry run mode now preserves think blocks and provides more informative output
  - **Improved Code Organization**: Refactored dry run logic is more maintainable and testable

  ## Test Plan

  - Test both short and long flag formats with YAML configuration files
  - Verify automatic detection of `~/.fabric.yaml` works when no config is specified
  - Confirm dry run mode shows complete request information including think block settings
  - Validate that think blocks are preserved in dry run mode but suppressed in normal operation when requested

  ## Additional Notes

  **Potential Issues to Monitor:**
  - The automatic config file detection could potentially load unintended configuration if a `~/.fabric.yaml` exists from previous installations
  - The flag-to-YAML mapping relies on reflection and could impact performance with a large number of flags
  - The dry run response format change might affect any code that depends on the previous empty string return value

  **Backward Compatibility:**
  - All existing long flag functionality remains unchanged
  - YAML configuration file format is unchanged
  - API signatures are preserved with only internal implementation changes

commits:
  [{"SHA":"16e92690aa38273febb290d2c7e0e6e2ab2a891d","Message":"feat: improve flag handling and add default config support\n\n## CHANGES\n\n- Map both short and long flags to yaml tags\n- Add support for short flag parsing with dashes\n- Implement default ~/.fabric.yaml config file detection\n- Fix think block suppression in dry run mode\n- Add think options to dry run output formatting\n- Refactor dry run response construction into helper method\n- Return actual response content from dry run client\n- Create utility function for default config path resolution","Author":"Kayvan Sylvan"},{"SHA":"fe94165d31b95e2fd11b7427e93dac474528e98a","Message":"chore: update `Send` method to append `request` to `DryRunResponse`\n\n### CHANGES\n\n- Assign `_ConstructRequest` output to `request` variable\n- Concatenate `request` with `DryRunResponse` in `Send` method","Author":"Kayvan Sylvan"},{"SHA":"181b812eaf443897922395d7bcd7b691536451e1","Message":"chore: remove unneeded parenthesis around function call","Author":"Kayvan Sylvan"},{"SHA":"ac97f9984f596e3edef0dda5f800899c60eef093","Message":"chore: refactor `constructRequest` method for consistency\n\n### CHANGES\n\n- Rename `_ConstructRequest` to `constructRequest` for consistency\n- Update `SendStream` to use `constructRequest`\n- Update `Send` method to use `constructRequest`","Author":"Kayvan Sylvan"},{"SHA":"da1c8ec979fae98d44a6eaab40330c85e9452b0a","Message":"fix: improve dry run output formatting and config path error handling\n\n## CHANGES\n\n- Remove leading newline from DryRunResponse constant\n- Add newline separator in SendStream method output\n- Add newline separator in Send method output\n- Improve GetDefaultConfigPath error handling logic\n- Add stderr error message for config access failures\n- Return empty string when config file doesn't exist","Author":"Kayvan Sylvan"},{"SHA":"dd5173963bdb815a975a50b2166429eda602784e","Message":"fix: improve error handling for default config path resolution\n\n## CHANGES\n\n- Update `GetDefaultConfigPath` to return error alongside path\n- Add proper error handling in flags initialization\n- Include debug logging for config path failures\n- Move channel close to defer in dryrun SendStream\n- Return wrapped errors with context messages\n- Handle non-existent config as valid case","Author":"Kayvan Sylvan"},{"SHA":"96c18b4c994ebd7ac07db81ff7025b86c2535def","Message":"refactor: extract flag parsing logic into separate extractFlag function","Author":"Kayvan Sylvan"}]


title: Introduce CLI Flag to Disable OpenAI Responses API
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1628
merged_at: 2025-07-17 18:02:19+00:00
created_at: 2025-07-17 18:14:09
body:
  # Introduce CLI Flag to Disable Responses API

  ## Summary

  This pull request adds a new CLI flag `--disable-responses-api` to control whether the OpenAI Responses API is enabled or disabled. The change includes comprehensive updates to shell completions, configuration handling, and the OpenAI client implementation to support this new functionality.

  ## Related Issues

  Closes #1625 

  Anyone using llama-server or other OpenAPI-compatible servers that are not already supported will use the OpenAI provider setting with their custom API endpoint. This change makes it possible to use those local LLM servers.

  In addition, users can create a `~/.config/fabriic/config.yaml` file containing this snippet.

  ```yaml
  # OpenAI Responses API settings
  # (use this for llama-server or other OpenAI-compatible local servers)
  disableResponsesAPI: true
  ```

  ## Files Changed

  - **`.vscode/settings.json`**: Added "testpattern" to the spell checker dictionary
  - **`completions/_fabric`**: Added zsh completion support for the new `--disable-responses-api` flag
  - **`completions/fabric.bash`**: Added bash completion support for the new flag
  - **`completions/fabric.fish`**: Added fish shell completion support for the new flag
  - **`internal/cli/cli.go`**: Added configuration logic for the OpenAI Responses API setting
  - **`internal/cli/example.yaml`**: Added example configuration for the new setting with documentation
  - **`internal/cli/flags.go`**: Added the new flag definition and updated default config path
  - **`internal/plugins/ai/openai/openai.go`**: Added method to configure Responses API enablement
  - **`internal/util/utils.go`**: Updated default configuration path from `~/.fabric.yaml` to `~/.config/fabric/config.yaml`

  ## Code Changes

  ### New CLI Flag Implementation
  ```go
  DisableResponsesAPI bool `long:"disable-responses-api" yaml:"disableResponsesAPI" description:"Disable OpenAI Responses API (default: false)"`
  ```

  ### OpenAI Client Configuration
  ```go
  func (o *Client) SetResponsesAPIEnabled(enabled bool) {
      o.ImplementsResponses = enabled
  }
  ```

  ### Configuration Path Update
  ```go
  defaultConfigPath := filepath.Join(homeDir, ".config", "fabric", "config.yaml")
  ```

  ## Reason for Changes

  This change addresses the need to disable the OpenAI Responses API for compatibility with local servers like llama-server or other OpenAI-compatible implementations that may not support this specific API endpoint. The flag provides users with control over this functionality without requiring code changes.

  ## Impact of Changes

  1. **Backward Compatibility**: The default behavior remains unchanged (Responses API enabled by default)
  2. **Configuration Management**: Users can now control this setting via CLI flag or configuration file
  3. **Local Server Support**: Enables better compatibility with local OpenAI-compatible servers
  4. **Shell Integration**: All major shells (bash, zsh, fish) now support autocompletion for the new flag
  5. **Configuration Path**: Standardizes configuration location to follow XDG Base Directory specification

  ## Test Plan

  - Verify the new flag works correctly with `--disable-responses-api`
  - Test shell completions in bash, zsh, and fish
  - Confirm OpenAI client respects the setting when making API calls
  - Validate configuration file parsing includes the new setting
  - Test backward compatibility with existing configurations

  ## Additional Notes

  The configuration path change from `~/.fabric.yaml` to `~/.config/fabric/config.yaml` follows standard XDG Base Directory conventions and improves organization of configuration files. The example configuration file includes helpful comments explaining when to use the disable flag (specifically mentioning llama-server compatibility).

  **Potential Issues to Monitor:**
  - Ensure existing users with `~/.fabric.yaml` configurations are properly migrated
  - Verify that disabling the Responses API doesn't break core functionality
  - Monitor for any edge cases where the flag setting might not be properly propagated to the OpenAI client

commits:
  [{"SHA":"3fca3489fb229d08d979842947e268019bd72150","Message":"feat: add OpenAI Responses API configuration control via CLI flag\n\n## CHANGES\n\n- Add `--disable-responses-api` CLI flag for OpenAI control\n- Implement `SetResponsesAPIEnabled` method in OpenAI client\n- Configure OpenAI Responses API setting during CLI initialization\n- Update default config path to `~/.config/fabric/config.yaml`\n- Add OpenAI import to CLI package dependencies","Author":"Kayvan Sylvan"},{"SHA":"3b9782f942220f75b8e2c9939af546d458f54f05","Message":"feat: add disable-responses-api flag for OpenAI compatibility\n\n## CHANGES\n\n- Add disable-responses-api flag to CLI completions\n- Update zsh completion with new API flag\n- Update bash completion options list\n- Add fish shell completion for API flag\n- Add testpattern to VSCode spell checker dictionary\n- Configure disableResponsesAPI in example YAML config\n- Enable flag for llama-server compatibility","Author":"Kayvan Sylvan"}]


title: Create Default (empty) .env in ~/.config/fabric on Demand
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1629
merged_at: 2025-07-17 22:26:37+00:00
created_at: 2025-07-17 22:29:20
body:
  # Create Default (empty) .env in ~/.config/fabric on Demand

  ## Summary

  This pull request adds a new `--setup` flag to the CLI that automatically creates the necessary configuration directory and environment file for the Fabric application. The changes ensure that users can easily initialize their Fabric configuration without manual file system setup.

  ## Related Issues

  Closes #1627 

  ## Files Changed

  - **`internal/cli/cli.go`**: Added handling for the new `--setup` flag in the main CLI flow
  - **`internal/cli/initialization.go`**: Added new function `ensureEnvFile()` with supporting constants for file permissions

  ## Code Changes

  ### internal/cli/cli.go

  Added a new conditional block to handle the `--setup` flag:

  ```go
  if currentFlags.Setup {
      if err = ensureEnvFile(); err != nil {
          return
      }
  }
  ```

  This code block is executed early in the CLI flow, right after flag parsing and before version checking, ensuring setup operations complete before other functionality.

  ### internal/cli/initialization.go

  Added new constants for file permissions:

  ```go
  const ConfigDirPerms os.FileMode = 0755
  const EnvFilePerms os.FileMode = 0644
  ```

  Added the `ensureEnvFile()` function that:
  - Determines the user's home directory
  - Constructs the path to `~/.config/fabric/.env`
  - Creates the directory structure if it doesn't exist
  - Creates an empty `.env` file if it doesn't exist
  - Handles errors gracefully with descriptive error messages

  ## Reason for Changes

  This change addresses the need for easier Fabric setup by automating the creation of required configuration files. Instead of users manually creating directories and files, they can now run the CLI with a `--setup` flag to automatically initialize their environment.

  ## Impact of Changes

  - **User Experience**: Significantly improves the initial setup experience for new users
  - **Error Reduction**: Reduces common setup errors related to missing configuration directories or files
  - **Consistency**: Ensures all users have the same directory structure and file permissions
  - **Backward Compatibility**: Existing installations are unaffected as the setup is only triggered by the explicit `--setup` flag

  ## Test Plan

  The changes should be tested by:
  1. Running the CLI with `--setup` flag on a clean system without existing Fabric configuration
  2. Verifying that `~/.config/fabric/` directory is created with correct permissions (0755)
  3. Verifying that `~/.config/fabric/.env` file is created with correct permissions (0644)
  4. Testing the setup command on a system that already has the configuration to ensure it doesn't overwrite existing files
  5. Testing error scenarios (e.g., insufficient permissions, invalid home directory)

  ## Additional Notes

  - The implementation uses defensive programming practices with proper error handling and descriptive error messages
  - File permissions are set to standard values (0755 for directories, 0644 for files) following Unix conventions
  - The function gracefully handles cases where the `.env` file already exists by checking with `os.Stat()` before attempting creation
  - The setup functionality is isolated in its own function, making it easy to test and maintain

commits:
  [{"SHA":"8bab58f2253e7a57094c310f6c8c568c12028725","Message":"feat: add startup check to initialize config and .env file\n\n### CHANGES\n- Introduce ensureEnvFile function to create ~/.config/fabric/.env if missing.\n- Add directory creation for config path in ensureEnvFile.\n- Integrate setup flag in CLI to call ensureEnvFile on demand.\n- Handle errors for home directory detection and file operations.","Author":"Kayvan Sylvan"},{"SHA":"75a7f25642c26ff34b5562513071b3f3f69941c6","Message":"refactor: improve error handling and permissions in `ensureEnvFile`","Author":"Kayvan Sylvan"},{"SHA":"2b2a25daaac5e354ce73fe06874bd9e0a36f859a","Message":"chore: improve error handling in `ensureEnvFile` function","Author":"Kayvan Sylvan"},{"SHA":"5cf15d22d3f5e3ba8ce96e9020e239cdd069dd26","Message":"chore: define constants for file and directory permissions","Author":"Kayvan Sylvan"}]


title: YouTube VTT Processing Enhancement
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1633
merged_at: 2025-07-18 18:55:44+00:00
created_at: 2025-07-18 19:00:46
body:
  # YouTube VTT Processing Enhancement

  ## Summary

  This pull request implements intelligent duplicate content filtering for YouTube VTT (WebVTT) subtitle processing. The changes introduce time-based deduplication logic that preserves legitimate repeated content (like choruses or recurring phrases) while filtering out immediate duplicates caused by VTT formatting issues.

  ## Related Issues

  Closes #1614 
  Closes #1632 

  ## Demo

  ```text
  fabric-v1.4.258 -y 'https://www.youtube.com/watch?v=mzSjAxYCEow' --transcript-with-timestamps | wc -l
      5132

  fabric -y 'https://www.youtube.com/watch?v=mzSjAxYCEow' --transcript-with-timestamps | wc -l
      1711
  ```

  And even without transcript timestamps:

  ```text
  fabric-v1.4.258 -y 'https://www.youtube.com/watch?v=mzSjAxYCEow' | wc -c
    192314

  fabric -y 'https://www.youtube.com/watch?v=mzSjAxYCEow' | wc -c
     64128
  ```

  ## Files Changed

  ### `.vscode/settings.json`
  - **Added**: New words to the spell checker dictionary: "horts", "mbed", "WEBVTT", "youtu"
  - **Purpose**: Prevents false positive spelling errors for YouTube-related terminology and technical terms

  ### `internal/tools/youtube/timestamp_test.go` (New File)
  - **Added**: Comprehensive test suite for timestamp parsing and repeat detection logic
  - **Purpose**: Ensures reliability of the new deduplication functionality with edge cases

  ### `internal/tools/youtube/youtube.go`
  - **Modified**: Enhanced VTT processing with intelligent duplicate detection
  - **Added**: New constants, helper functions, and time-based filtering logic

  ## Code Changes

  ### Core Algorithm Enhancement

  The main improvement is in the `readAndFormatVTTWithTimestamps` function:

  ```go
  // Track content with timestamps to allow repeats after significant time gaps
  seenSegments := make(map[string]string) // text -> last timestamp seen

  // Check if we should include this segment
  shouldInclude := true
  if lastTimestamp, exists := seenSegments[cleanText]; exists {
      if !shouldIncludeRepeat(lastTimestamp, currentTimestamp) {
          shouldInclude = false
      }
  }
  ```

  ### New Helper Functions

  1. **`shouldIncludeRepeat`**: Determines if repeated content should be included based on a 10-second time gap threshold
  2. **`parseTimestampToSeconds`**: Converts timestamp strings (HH:MM:SS or MM:SS) to total seconds for comparison

  ### Constants and Regex Updates

  ```go
  const TimeGapForRepeats = 10 // seconds
  var timestampRegex = regexp.MustCompile(`^\d+$|^\d{1,2}:\d{2}(:\d{2})?(\.\d{3})?$`)
  ```

  ## Reason for Changes

  This change addresses a common issue with YouTube VTT subtitle files where the same content appears multiple times due to formatting quirks or overlapping subtitle segments. The previous implementation either kept all duplicates or removed all duplicates, which could eliminate legitimate repeated content like song choruses or important repeated phrases.

  ## Impact of Changes

  ### Positive Impacts
  - **Improved Content Quality**: Eliminates redundant subtitle text while preserving meaningful repetitions
  - **Better User Experience**: Cleaner, more readable transcript output
  - **Configurable Threshold**: The 10-second gap can be easily adjusted for different use cases

  ### Potential Considerations
  - **Memory Usage**: The `seenSegments` map grows with unique content, but this is typically manageable for video transcripts
  - **Processing Time**: Slight increase due to timestamp parsing and comparison, but negligible for typical use cases
  - **Threshold Sensitivity**: The 10-second threshold may need adjustment based on content type (music vs. speech)

  ## Test Plan

  The new test suite covers:
  - **Timestamp Parsing**: Various formats (MM:SS, HH:MM:SS) and edge cases
  - **Repeat Detection**: Time gap calculations and boundary conditions
  - **Error Handling**: Invalid timestamp formats and malformed input

  Tests can be run with:
  ```bash
  go test ./internal/tools/youtube/
  ```

  ## Additional Notes

  - The implementation errs on the side of inclusion when timestamp parsing fails, ensuring no legitimate content is lost
  - The 10-second threshold is conservative and works well for most content types
  - Future enhancements could make the time gap threshold configurable via command-line flags or configuration files
  - The regex pattern has been moved to package level for better performance and reusability

commits:
  [{"SHA":"2aad4caf9b029e0bdee865e9dc4e3dee1c6f599f","Message":"fix: prevent duplicate segments in VTT file processing\n\n- Add deduplication map to track seen segments\n- Skip duplicate text segments in plain VTT processing\n- Skip duplicate segments in timestamped VTT processing\n- Improve timestamp regex to handle more formats\n- Use clean text as deduplication key consistently","Author":"Kayvan Sylvan"},{"SHA":"15151fe9ee8127b365d72ef412c90d201871ca0a","Message":"chore: refactor timestamp regex to global scope and add spell check words\n\n## CHANGES\n\n- Move timestamp regex to global package scope\n- Remove duplicate regex compilation from isTimeStamp function\n- Add \"horts\", \"mbed\", \"WEBVTT\", \"youtu\" to spell checker\n- Improve regex performance by avoiding repeated compilation\n- Clean up code organization in YouTube module","Author":"Kayvan Sylvan"},{"SHA":"570c9a9404001320750ebc3a45609bc502593ec8","Message":"chore: refactor timestamp regex and seenSegments logic\n\n### CHANGES\n\n- Update `timestampRegex` to support optional seconds/milliseconds\n- Change `seenSegments` to use `struct{}` for memory efficiency\n- Refactor duplicate check using `struct{}` pattern\n- Improve readability by restructuring timestamp logic","Author":"Kayvan Sylvan"},{"SHA":"65bd2753c20ce3043522919a67385c1e8a78f4df","Message":"feat: enhance VTT duplicate filtering to allow legitimate repeated content\n\n## CHANGES\n\n- Fix regex escape sequence for timestamp parsing\n- Add configurable time gap constant for repeat detection\n- Track content with timestamps instead of simple deduplication\n- Implement time-based repeat inclusion logic for choruses\n- Add timestamp parsing helper functions for calculations\n- Allow repeated content after significant time gaps\n- Preserve legitimate recurring phrases while filtering duplicates","Author":"Kayvan Sylvan"},{"SHA":"1a35f32a4822af9f990100477231ac3f10782c63","Message":"fix: Youtube VTT parsing gap test","Author":"Kayvan Sylvan"},{"SHA":"dc722f9724d6ef825a1e4eb0ae442b39b9a764c9","Message":"feat: improve timestamp parsing to handle fractional seconds in YouTube tool\n\n## CHANGES\n\n- Move timestamp regex initialization to init function\n- Add parseSeconds helper function for fractional seconds\n- Replace direct strconv.Atoi calls with parseSeconds function\n- Support decimal seconds in timestamp format parsing\n- Extract seconds parsing logic into reusable function","Author":"Kayvan Sylvan"}]


title: Fix abort in Exo-Labs provider plugin; with credit to @sakithahSenid
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1634
merged_at: 2025-07-18 19:55:58+00:00
created_at: 2025-07-18 20:00:34
body:
  # Fix abort in Exo-Labs provider plugin; with credit to @sakithahSenid

  ## Summary

  This pull request adds API key configuration support to the Exolab AI plugin and updates the VS Code spell checker dictionary to include the new "openaiapi" term.

  ## Related Issues

  Closes #1622 

  ## Files Changed

  - `.vscode/settings.json`: Added "openaiapi" to the spell checker dictionary
  - `internal/plugins/ai/exolab/exolab.go`: Added API key setup question to the Exolab client configuration

  ## Code Changes

  ### `.vscode/settings.json`
  ```json
  "openaiapi",
  ```
  Added the term "openaiapi" to the `cSpell.words` array to prevent spell checker warnings.

  ### `internal/plugins/ai/exolab/exolab.go`
  ```go
  ret.ApiKey = ret.AddSetupQuestion("API Key", false)
  ```
  Added a new setup question for API key configuration.

  ## Reason for Changes

  Prevents the following abort when trying to set up exolabs:

  <img width="1176" height="646" alt="exo-labs-fail" src="https://github.com/user-attachments/assets/58e2f28f-9396-444c-b2d0-27240679fabb" />

  ## Impact of Changes

  1. **Improved User Experience**: The setup process now guides users through both URL and authentication configuration
  2. **Consistency**: Aligns the Exolab plugin with other AI plugins. The API Key is optional.

  ## Test Plan

  - Verify that the Exolab plugin setup process now prompts for both API Base URL and API Key
  - Confirm that the API key is properly stored and used in subsequent API calls
  - Validate that existing configurations continue to work after the update

commits:
  [{"SHA":"cdbcb0a5121f748043f83916ff88b7c6ae2bb34f","Message":"chore: add API key setup question to Exolab AI plugin configuration\n\n## CHANGES\n\n- Add \"openaiapi\" to VSCode spell check dictionary\n- Include API key setup question in Exolab client\n- Configure API key as required field for setup\n- Maintain existing API base URL configuration order","Author":"Kayvan Sylvan"}]


title: chore: update `NeedsRawMode` to include `mistral` prefix for Ollama
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1637
merged_at: 2025-07-19 14:19:14+00:00
created_at: 2025-07-19 14:21:55
body:
  # chore: update `NeedsRawMode` to include `mistral` prefix for Ollama

  ## Summary

  Added "mistral" to the list of model prefixes that require raw mode in the Ollama AI plugin. This is a single-line addition to support Mistral models when using the Ollama integration.

  ## Related Issues

  Closes #1636 

  ## Files Changed

  - **`internal/plugins/ai/ollama/ollama.go`**: Added "mistral" to the `ollamaPrefixes` slice in the `NeedsRawMode` function.

  ## Code Changes

  In the `NeedsRawMode` function, the `ollamaPrefixes` slice was updated to include Mistral models:

  ```go
  ollamaPrefixes := []string{
      "llama3",
      "llama2",
  +   "mistral",
  }
  ```

  This change ensures that any model name starting with "mistral" will be identified as requiring raw mode processing.

  ## Reason for Changes

  This change extends support for Mistral models in the Ollama plugin. The `NeedsRawMode` function appears to determine which models require special handling (raw mode) based on their name prefixes. Mistral models likely have similar characteristics to the existing Llama models that necessitate this special processing mode.

  ## Impact of Changes

  - **Functionality**: Enables proper handling of Mistral models when used with the Ollama AI plugin
  - **Compatibility**: Maintains backward compatibility while extending model support
  - **Performance**: Minimal impact - only adds one string comparison to the existing prefix matching logic

  ## Test Plan

  - Verify that models with names starting with "mistral" (e.g., "mistral-7b", "mistral-instruct") properly trigger raw mode
  - Ensure existing functionality for "llama2" and "llama3" prefixes remains unchanged
  - Test with actual Mistral models through Ollama to confirm proper behavior

  ## Additional Notes

  This is a straightforward addition that follows the existing pattern for model prefix detection. The change is minimal and low-risk, as it only adds support for an additional model family without modifying existing logic. However, it would be beneficial to verify that Mistral models indeed require raw mode processing similar to Llama models, and that this addition doesn't inadvertently affect other models that might have "mistral" in their names but don't require raw mode.

commits:
  [{"SHA":"63475784c74619852d385b5eefe14da212e9c99c","Message":"chore: update `NeedsRawMode` to include `mistral` prefix\n\n### CHANGES\n\n- Add `mistral` to `ollamaPrefixes` list.","Author":"Kayvan Sylvan"}]


title: Implement Automated Changelog System for CI/CD Integration
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1640
merged_at: 2025-07-21 18:18:26+00:00
created_at: 2025-07-21 21:27:10
body:
  # Implement Automated Changelog System for CI/CD Integration

  ## Summary

  This pull request implements a comprehensive automated changelog system for CI/CD integration, adding new functionality to pre-process pull requests during development and aggregate changelog entries during release workflows.

  ## Related Issues

  Closes #1630 

  ## Files Changed

  ### New Files Added
  - `cmd/generate_changelog/incoming/1640.txt` - Example incoming changelog entry for PR #1640
  - `cmd/generate_changelog/internal/changelog/generator_test.go` - Test coverage for changelog generation functionality
  - `cmd/generate_changelog/internal/changelog/processing.go` - Core processing logic for PR handling and release aggregation
  - `cmd/generate_changelog/internal/changelog/processing_test.go` - Comprehensive test suite for processing functionality
  - `docs/Automated-ChangeLog.md` - Technical specification and implementation details
  - `docs/Automated-Changelog-Usage.md` - Developer guide and usage documentation

  ### Modified Files
  - `.github/workflows/update-version-and-create-tag.yml` - Updated CI/CD workflow to integrate changelog processing
  - `.gitignore` - Added `.claude/` directory exclusion
  - `.vscode/settings.json` - Added new spell check words for project terminology
  - `cmd/generate_changelog/internal/config/config.go` - Extended configuration with new fields for PR processing
  - `cmd/generate_changelog/internal/git/walker.go` - Added git operations for staging, committing, and pushing changes
  - `cmd/generate_changelog/internal/github/client.go` - Enhanced GitHub API client with validation methods and PR details
  - `cmd/generate_changelog/internal/github/types.go` - Added PRDetails struct for comprehensive PR information
  - `cmd/generate_changelog/main.go` - Added new command-line flags and processing modes

  ## Code Changes

  ### Core Processing Logic (`processing.go`)
  ```go
  func (g *Generator) ProcessIncomingPR(prNumber int) error
  func (g *Generator) CreateNewChangelogEntry(version string) error
  func (g *Generator) getDirectCommitsSinceLastRelease(processedPRs map[int]bool, processedCommitSHAs map[string]bool) (string, error)
  ```

  ### GitHub API Enhancements (`client.go`)
  ```go
  func (c *Client) GetPRValidationDetails(prNumber int) (*PRDetails, error)
  func (c *Client) GetPRWithCommits(prNumber int) (*PR, error)
  func (c *Client) buildPRWithCommits(ctx context.Context, ghPR *github.PullRequest) (*PR, error)
  ```

  ### Git Operations (`walker.go`)
  ```go
  func (w *Walker) IsWorkingDirectoryClean() (bool, error)
  func (w *Walker) AddFile(filename string) error
  func (w *Walker) CommitChanges(message string) (plumbing.Hash, error)
  func (w *Walker) PushToRemote() error
  ```

  ### CI/CD Workflow Integration
  ```yaml
  - name: Generate Changelog Entry
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    run: |
      go run ./cmd/generate_changelog --process-prs ${{ env.new_tag }}
  ```

  ## Reason for Changes

  This implementation addresses the need for automated changelog generation in CI/CD pipelines while maintaining developer control over content quality. The system eliminates manual CHANGELOG.md editing, reduces merge conflicts, and ensures consistent formatting across releases.

  Key motivations:
  - **Developer Experience**: Pre-process PR entries during development with AI-enhanced summaries
  - **CI/CD Integration**: Automatically aggregate entries during release workflows
  - **Consistency**: Standardized formatting and comprehensive coverage of all changes
  - **Performance**: Leverages existing caching and optimization infrastructure

  ## Impact of Changes

  ### Positive Impacts
  - **Automated Workflow**: Developers can generate changelog entries with `--incoming-pr` flag
  - **Release Integration**: CI/CD automatically processes incoming files with `--process-prs`
  - **Reduced Conflicts**: No multiple PRs editing CHANGELOG.md simultaneously
  - **Enhanced Quality**: AI-powered summaries provide professional, consistent formatting
  - **Backward Compatibility**: Existing changelog generation remains unchanged

  ### Potential Risks
  - **Git State Dependencies**: Tool requires clean working directory for processing
  - **GitHub API Rate Limits**: Increased API usage for PR validation and commit fetching
  - **File System Operations**: Auto-commit and push functionality requires proper authentication
  - **Validation Complexity**: Multiple validation layers could introduce failure points

  ## Test Plan

  The implementation includes comprehensive test coverage:

  ### Unit Tests
  - `generator_test.go`: Version detection, directory creation, changelog insertion
  - `processing_test.go`: File aggregation, error handling, validation logic
  - Tests cover edge cases like permission errors, malformed files, and git state validation

  ### Integration Testing
  - PR validation workflow with GitHub API
  - Git operations including staging, committing, and pushing
  - End-to-end processing from incoming files to CHANGELOG.md updates

  ### Manual Testing
  - Test with actual PR numbers for validation
  - Verify CI/CD integration in GitHub Actions workflow
  - Validate file cleanup and git staging operations

  ## Additional Notes

  ### Configuration Extensions
  New configuration fields support the automated workflow:
  - `IncomingPR`: PR number for pre-processing
  - `ProcessPRsVersion`: Version string for release aggregation  
  - `IncomingDir`: Directory path for incoming PR files
  - `Push`: Enable automatic git push after commits

  ### Error Handling
  Robust error handling covers:
  - PR state validation (open, mergeable)
  - Git working directory cleanliness
  - File system permissions and disk space
  - Network failures with GitHub API
  - Authentication issues for git operations

  ### Developer Workflow
  1. Create PR and ensure it's mergeable
  2. Run `generate_changelog --incoming-pr XXXX --ai-summarize`
  3. Review generated `incoming/XXXX.txt` file
  4. Commit is auto-created; use `--push` for automatic remote push
  5. PR includes pre-processed changelog entry for review

  The system maintains full backward compatibility while providing opt-in automation features that significantly improve the development and release process.

commits:
  [{"SHA":"7ff04658f3103eb95a2d54cc1285dbf5f6ce7feb","Message":"chore: add automated changelog processing for CI/CD integration\n\n## CHANGES\n\n- Add incoming PR preprocessing with validation\n- Implement release aggregation for incoming files\n- Create git operations for staging changes\n- Add comprehensive test coverage for processing\n- Extend GitHub client with validation methods\n- Support version detection from nix files\n- Include documentation for automated workflow\n- Add command flags for PR processing","Author":"Kayvan Sylvan"},{"SHA":"951bd134ebb0b6a0e5166f9195368ed37c13ed9d","Message":"Fix CLI error handling and improve git status validation\n\n- Add SilenceUsage to prevent help output on errors\n- Add GetStatusDetails method to show which files are dirty\n- Include direct commits in ProcessIncomingPRs for complete AI summaries","Author":"Kayvan Sylvan"},{"SHA":"e56ecfb7aeb9ac6b80577560611df8bf3d184e2a","Message":"chore: update gitignore and simplify changelog generator error handling\n\n## CHANGES\n\n- Add .claude/ directory to gitignore exclusions\n- Update comment clarity for SilenceUsage flag\n- Remove redundant error handling in main function\n- Simplify command execution without explicit error checking","Author":"Kayvan Sylvan"},{"SHA":"b0d096d0ea6adb229cbafafa64f7ca2e6b1c572d","Message":"feat: change push behavior from opt-out to opt-in with GitHub token auth\n\n## CHANGES\n\n- Change `NoPush` config field to `Push` boolean\n- Update CLI flag from `--no-push` to `--push`\n- Add GitHub token authentication for push operations\n- Import `os` and HTTP transport packages\n- Reverse push logic to require explicit enable\n- Update documentation for new push behavior\n- Add automatic GitHub repository detection for auth","Author":"Kayvan Sylvan"},{"SHA":"482759ae724a299e379eb681f7a92ef5acc5667a","Message":"fix: ensure the PR#.txt file ends with a newline.","Author":"Kayvan Sylvan"},{"SHA":"b8008a34fb04fdc6db2d97809dece8d4d0e3ec24","Message":"feat: enhance changelog generation to avoid duplicate commit entries\n\n## CHANGES\n\n- Extract PR numbers from processed changelog files\n- Pass processed PRs map to direct commits function\n- Filter out commits already included via PR files\n- Reduce extra newlines in changelog version insertion\n- Add strconv import for PR number parsing\n- Prevent duplicate entries between PRs and direct commits\n- Improve changelog formatting consistency","Author":"Kayvan Sylvan"},{"SHA":"91c1aca0ddb0906484d05e054487861706ef3bd6","Message":"feat: enhance changelog generator to accept version parameter for PR processing\n\n## CHANGES\n\n- Pass version parameter to changelog generation workflow\n- Update ProcessIncomingPRs method to accept version string\n- Add commit SHA tracking to prevent duplicate entries\n- Modify process-prs flag to require version parameter\n- Improve changelog formatting with proper spacing\n- Update configuration to use ProcessPRsVersion string field\n- Enhance direct commit filtering with SHA exclusion\n- Update documentation to reflect version parameter requirement","Author":"Kayvan Sylvan"},{"SHA":"7d562096d1efb2afacbe16cbd0f70d1999cd351f","Message":"fix: formatting fixes in tests.","Author":"Kayvan Sylvan"},{"SHA":"76d6b1721ee94c320fa529b30bcbca8da9e96fdf","Message":"chore: incoming 1640 changelog entry","Author":"Changelog Bot"},{"SHA":"42afd92f31c3ffe91ca15e7eb30d858fca3ebb46","Message":"refactor: rename ProcessIncomingPRs to CreateNewChangelogEntry for clarity\n\n## CHANGES\n\n- Rename ProcessIncomingPRs method to CreateNewChangelogEntry\n- Update method comment to reflect new name\n- Update main.go to call renamed method\n- Reduce newline spacing in content formatting","Author":"Kayvan Sylvan"},{"SHA":"cab6df88ea93602af80a2d625a3d992b5a950c2b","Message":"chore: simplify direct commits content handling in changelog generation","Author":"Kayvan Sylvan"},{"SHA":"8ab891fcffaa59faeca45173d1bc1b800cfd7ab3","Message":"chore: trim leading newline in changelog entry content","Author":"Kayvan Sylvan"},{"SHA":"28432a50f0d35fdf1c26826135ead5dc7d6b0b58","Message":"chore: adjust newline handling in `insertVersionAtTop` method","Author":"Kayvan Sylvan"},{"SHA":"edaca7a045b447c4465ea6ebe70fc0d660928ed3","Message":"chore: adjust `insertVersionAtTop` for consistent newline handling","Author":"Kayvan Sylvan"},{"SHA":"c50486b6117f59e319b6c1175f7dfb1f54ca5f24","Message":"chore: fix tests for generate_changelog","Author":"Kayvan Sylvan"},{"SHA":"15a355f08a4795a0e13998245a9db963f54c736e","Message":"docs: Remove duplicated section.","Author":"Kayvan Sylvan"}]


title: Fix Fabric Web timeout error
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1641
merged_at: 2025-07-21 19:26:53+00:00
created_at: 2025-07-21 21:27:10
body:
  # Fix Fabric Web timeout error

  ## Summary

  This pull request increases the proxy timeout configuration in the Vite development server from 30 seconds to 15 minutes (900,000ms) for API requests and pattern/model/session name endpoints.

  ## Related Issues

  Closes #1604

  ## Files Changed

  - **web/vite.config.ts**: Modified proxy timeout settings for development server configuration

  ## Code Changes

  The changes involve updating two proxy configurations in the Vite config file:

  1. **API proxy timeout update**:
  ```typescript
  '/api': {
    target: FABRIC_BASE_URL,
    changeOrigin: true,
  - timeout: 30000,
  + timeout: 900000,
    rewrite: (path) => path.replace(/^\/api/, ''),
  ```

  2. **Patterns/models/sessions proxy timeout update**:
  ```typescript
  '^/(patterns|models|sessions)/names': {
    target: FABRIC_BASE_URL,
    changeOrigin: true,
  - timeout: 30000,
  + timeout: 900000,
  ```

  ## Reason for Changes

  The timeout increase from 30 seconds to 15 minutes addresses scenarios where:
  - API requests may take longer to process, particularly for complex operations
  - Pattern, model, or session name retrieval operations may require extended processing time
  - Network latency or server processing delays could cause legitimate requests to timeout prematurely

  This change prevents development workflow interruptions caused by timeout errors on slower operations.

  ## Impact of Changes

  **Positive impacts:**
  - Eliminates premature timeouts during development for long-running operations
  - Improves developer experience by allowing complex requests to complete
  - Reduces frustration from timeout errors on legitimate operations

  **Potential concerns:**
  - Longer timeout periods may mask actual performance issues
  - Failed requests will now hang for up to 15 minutes before timing out
  - Memory usage could increase if multiple long-running requests accumulate

  ## Test Plan

  - Test API endpoints that previously timed out at 30 seconds
  - Verify that legitimate long-running operations now complete successfully
  - Confirm that truly failed requests still eventually timeout (within 15 minutes)
  - Monitor development server performance with the extended timeout

  ## Additional Notes

  This change only affects the development environment proxy configuration and will not impact production deployments. The 15-minute timeout should accommodate most legitimate long-running operations while still providing an upper bound for failed requests. Consider monitoring actual request durations to determine if this timeout value needs further adjustment based on real-world usage patterns.

commits:
  [{"SHA":"9bdd77c27743bf936960ebb97e54f5ef3b5fe568","Message":"chore: extend proxy timeout in `vite.config.ts` to 15 minutes\n\n### CHANGES\n\n- Increase `/api` proxy timeout to 900,000 ms\n- Increase `/names` proxy timeout to 900,000 ms","Author":"Kayvan Sylvan"},{"SHA":"a522d4a41182cabc7bb1db9209a7aa610bf815b6","Message":"chore: incoming 1641 changelog entry","Author":"Changelog Bot"}]


title: Add --sync-db to `generate_changelog`, plus many fixes
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1642
merged_at: 2025-07-22 04:53:20+00:00
created_at: 2025-07-26 14:34:29
body:
  # Add --sync-db to `generate_changelog`, plus many fixes

  ## Summary

  This PR introduces database synchronization capabilities to the changelog generation system, along with enhanced merge commit detection, improved timestamp handling, and better error reporting. The changes focus on maintaining database integrity and providing comprehensive validation tools for the CI/CD pipeline.

  ## Files Changed

  ### GitHub Workflow Configuration
  - **`.github/workflows/update-version-and-create-tag.yml`**: Added exclusion for incoming changelog files (`cmd/generate_changelog/incoming/*.txt`) to prevent unnecessary workflow triggers when processing PR files.

  ### Database and Binary Files
  - **`cmd/generate_changelog/changelog.db`**: Updated binary database file with latest PR and commit data.
  - **Incoming PR Files**: Removed processed PR files (#1640, #1641) and added new PR file (#1642) containing changelog entries for recent changes.

  ### Core Application Changes
  - **`cmd/generate_changelog/main.go`**: Added `--sync-db` command-line flag for database synchronization operations.
  - **`cmd/generate_changelog/internal/config/config.go`**: Added `SyncDB` boolean field to configuration structure.

  ### Cache System Enhancements
  - **`cmd/generate_changelog/internal/cache/cache.go`**: 
    - Enhanced time parsing with RFC3339Nano fallback support for better timestamp precision
    - Added `VersionExists()` and `CommitExists()` methods for database validation
    - Improved error handling with detailed feedback messages

  ### Changelog Generation System
  - **`cmd/generate_changelog/internal/changelog/generator.go`**: 
    - Implemented comprehensive `SyncDatabase()` method for full database synchronization
    - Added `syncGitHistory()` and `verifyCommitPRMappings()` helper methods
    - Modified `fetchPRs()` to accept explicit force sync parameter
    - Enhanced version date calculation using actual commit timestamps

  - **`cmd/generate_changelog/internal/changelog/processing.go`**: 
    - Added `isMergeCommit()` function with dual detection methods (parent count + message patterns)
    - Implemented `calculateVersionDate()` for accurate version timestamping
    - Enhanced PR processing with proper git operations and improved error handling
    - Better integration with cache system for commit and PR data

  ### GitHub API Integration
  - **`cmd/generate_changelog/internal/github/client.go`**: 
    - Added email field population from GitHub API responses
    - Enhanced commit timestamp capture from GitHub API
    - Implemented parent commit SHA collection for merge detection

  - **`cmd/generate_changelog/internal/github/types.go`**: 
    - Added `Email`, `Date`, and `Parents` fields to `PRCommit` struct
    - Updated GraphQL query structure to include `AuthoredDate` field

  ### Git Operations
  - **`cmd/generate_changelog/internal/git/walker.go`**: Added comprehensive documentation for version pattern regex matching.

  ### Test Coverage
  - **`cmd/generate_changelog/internal/changelog/merge_detection_test.go`**: New comprehensive test suite for merge commit detection functionality.
  - **`cmd/generate_changelog/internal/github/email_test.go`**: New test suite for email field handling in PR commits.

  ## Code Changes

  ### Key Implementation: Database Synchronization

  ```go
  func (g *Generator) SyncDatabase() error {
      // Force PR sync from GitHub
      if err := g.fetchPRs(true); err != nil {
          return fmt.Errorf("failed to sync PRs: %w", err)
      }
      
      // Verify git history and version completeness
      if err := g.syncGitHistory(); err != nil {
          return fmt.Errorf("failed to sync git history: %w", err)
      }
      
      // Verify commit-PR mappings
      if err := g.verifyCommitPRMappings(); err != nil {
          return fmt.Errorf("failed to verify commit-PR mappings: %w", err)
      }
      
      return nil
  }
  ```

  ### Enhanced Merge Commit Detection

  ```go
  func isMergeCommit(commit github.PRCommit) bool {
      // Primary method: Check parent count
      if len(commit.Parents) > 1 {
          return true
      }
      
      // Fallback method: Check commit message patterns
      mergePatterns := []string{
          `^Merge pull request #\d+`,
          `^Merge branch '.*' into .*`,
          // ... additional patterns
      }
      
      for _, pattern := range mergePatterns {
          if matched, _ := regexp.MatchString(pattern, commit.Message); matched {
              return true
          }
      }
      
      return false
  }
  ```

  ### Improved Time Parsing

  ```go
  // Try RFC3339Nano first, then fall back to RFC3339
  v.Date, err = time.Parse(time.RFC3339Nano, dateStr.String)
  if err != nil {
      v.Date, err = time.Parse(time.RFC3339, dateStr.String)
      if err != nil {
          fmt.Fprintf(os.Stderr, "Error parsing date '%s': %v\n", dateStr.String, err)
      }
  }
  ```

  ## Reason for Changes

  These changes address several critical needs in the changelog generation system:

  1. **Database Integrity**: The `--sync-db` flag provides a comprehensive way to validate and synchronize the local database with git history and GitHub API data.

  2. **Merge Commit Detection**: Improved detection prevents merge commits from being included as regular commits in changelog entries, ensuring cleaner output.

  3. **Timestamp Accuracy**: Enhanced time parsing and actual commit timestamp capture from GitHub API provides more accurate version dating.

  4. **Error Resilience**: Better error handling and fallback mechanisms improve system reliability.

  5. **CI/CD Integration**: Workflow exclusions prevent unnecessary builds when processing changelog files.

  ## Impact of Changes

  ### Positive Impacts
  - **Data Consistency**: Database synchronization ensures all git history and PR data is properly cached and consistent
  - **Accuracy**: Better timestamp handling and merge commit detection improve changelog quality
  - **Reliability**: Enhanced error handling prevents system failures and provides actionable feedback
  - **Performance**: Existence checks prevent duplicate database entries during sync operations

  ### Potential Risks
  - **Database Operations**: New database methods could potentially cause issues if the database schema is inconsistent
  - **API Rate Limits**: Force syncing PRs may hit GitHub API rate limits in repositories with many PRs
  - **Merge Detection**: The dual detection method for merge commits might occasionally misclassify commits, though this is unlikely given the comprehensive patterns

  ## Test Plan

  The changes include comprehensive test coverage:

  1. **Merge Detection Tests**: `merge_detection_test.go` validates all merge commit detection scenarios
  2. **Email Handling Tests**: `email_test.go` ensures proper email field population
  3. **Integration Testing**: The `--sync-db` flag should be tested on a repository with various git history patterns
  4. **Manual Validation**: Compare database contents before and after sync operations to ensure data integrity

  ## Additional Notes

  - The database synchronization is designed to be non-destructive - it preserves existing data while adding missing entries
  - Error messages include actionable troubleshooting steps for manual intervention when automated recovery fails
  - The system maintains backward compatibility with existing database schemas
  - Performance optimizations include existence checks to avoid redundant database operations during sync

  This PR significantly enhances the robustness and reliability of the changelog generation system while maintaining full backward compatibility.

commits:
  [{"SHA":"38c4211649a260789e5226ad75c254b94061d305","Message":"docs: clean up duplicate CHANGELOG for v1.4.262","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-21T20:27:37Z","Parents":null},{"SHA":"be1e2485ee8bdda24ade8167acfa4656a1855c03","Message":"feat: add database synchronization and improve changelog processing workflow\n\n## CHANGES\n\n- Add database sync command with comprehensive validation\n- Implement version and commit existence checking methods\n- Enhance time parsing with RFC3339Nano fallback support\n- Cache fetched PRs during changelog entry creation\n- Remove individual incoming files using git operations\n- Add sync-db flag for database integrity validation\n- Improve commit-PR mapping verification process\n- Exclude incoming directory from workflow trigger paths","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-21T21:33:05Z","Parents":null},{"SHA":"f2b2501767c4848429f91c8473ce1d5322675f82","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-21T21:38:32Z","Parents":null},{"SHA":"63bc7a7e79b21c5576d4cebc34acc62a09d19643","Message":"feat: improve timestamp handling and merge commit detection in changelog generator\n\n## CHANGES\n\n- Add debug logging for date parsing failures\n- Pass forcePRSync parameter explicitly to fetchPRs method\n- Implement comprehensive merge commit detection using parents\n- Capture actual commit timestamps from GitHub API\n- Calculate version dates from most recent commit\n- Add parent commit SHAs for merge detection\n- Use real commit dates instead of current time\n- Add timestamp validation with fallback handling","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-21T22:43:14Z","Parents":null},{"SHA":"8d621654448d08c18f3bb0b292195695470ebd60","Message":"feat: add email field support and improve error logging in changelog generation\n\n## CHANGES\n\n- Add Email field to PRCommit struct for author information\n- Extract version date calculation into reusable helper function\n- Redirect error messages from stdout to stderr properly\n- Populate commit email from GitHub API responses correctly\n- Add comprehensive test coverage for email field handling\n- Remove duplicate version date calculation code blocks\n- Import os package for proper stderr output handling","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-21T23:14:12Z","Parents":null},{"SHA":"055ed32ab86e9420ed88b906dc6fe5d80ccbd93d","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-21T23:15:16Z","Parents":null},{"SHA":"a83d57065fe9adac5b41cafce6bed1910dde503b","Message":"chore: improve error message clarity in version existence check for git history sync\n\n## CHANGES\n\n- Enhance warning message with additional context details\n- Add guidance for users when version check fails\n- Improve error handling feedback in sync operation\n- Provide actionable steps for troubleshooting sync issues","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-21T23:37:32Z","Parents":null},{"SHA":"ac19c81ef0abe7c88467447e6a9ad2e05b7341bb","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-21T23:37:49Z","Parents":null},{"SHA":"fcda0338cbf6f313077a8d2ce9e0ac797bb050d0","Message":"chore: improve error logging and documentation in changelog generation components\n\n## CHANGES\n\n- Add date string to RFC3339 parsing error messages\n- Enhance isMergeCommit function documentation with detailed explanation\n- Document calculateVersionDate function with comprehensive behavior description\n- Improve error context for date parsing failures\n- Add implementation details for merge commit detection methods\n- Clarify fallback behavior in version date calculation","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-21T23:45:52Z","Parents":null},{"SHA":"3cf2557af3d3f5aad1c1fe5493db4422e29bb88a","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-21T23:46:04Z","Parents":null},{"SHA":"dd96014f9b480fc77e34a82bff9a796b2ff470c4","Message":"chore: improve error message clarity in changelog generation and cache operations\n\n## CHANGES\n\n- Clarify RFC3339Nano date parsing error message\n- Improve PR batch cache save error description\n- Add context for commit timestamp fallback warning\n- Specify git index in file removal error message","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-21T23:59:50Z","Parents":null},{"SHA":"4dc84bd64db17b344307da9ebbe6231b1fb0f8f1","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-22T00:00:03Z","Parents":null},{"SHA":"73c7a8c147c4b1c0cbb855d4d41c8e6c8f607743","Message":"feat: improve changelog entry creation and error messages\n\n### CHANGES\n\n- Rename `changelogDate` to `versionDate` for clarity\n- Enhance error message for git index removal failure\n- Add comments for `versionPattern` regex in `walker.go`","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T00:14:14Z","Parents":null},{"SHA":"19d95b901495c20aa1f2e3bec32f77d0ed29a420","Message":"docs: improve code comments for version pattern and PR commit fields\n\n## CHANGES\n\n- Expand version pattern regex documentation with examples\n- Add matching and non-matching commit message examples\n- Clarify version pattern behavior with optional prefix\n- Update PR commit field comments for clarity\n- Document email field availability from GitHub API\n- Simplify timestamp and parents field descriptions","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T00:21:28Z","Parents":null},{"SHA":"a415409a48317acfeeda3a8fc013c48162e5fa5d","Message":"fix: improve error handling and guidance for file removal failures\n\n## CHANGES\n\n- Replace generic warning with detailed error message\n- Add step-by-step manual intervention instructions\n- Provide multiple recovery options for users\n- Separate git and filesystem error reporting\n- Include specific commands for manual cleanup","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T00:35:53Z","Parents":null},{"SHA":"a922032756eb9309c1a5cdd0caee50d902289f40","Message":"chore: optimize error logging and regex pattern matching for better performance\n\n## CHANGES\n\n- Remove redundant RFC3339Nano parsing error message\n- Enhance RFC3339 error message with version name\n- Pre-compile regex patterns for merge commit detection\n- Replace regexp.MatchString with compiled pattern matching\n- Improve merge commit pattern matching performance\n- Add structured regex compilation for better efficiency","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T01:21:23Z","Parents":null},{"SHA":"db5aaf9da61f188a973e32f076fe5a7891fcf0c7","Message":"fix: improve warning message clarity for invalid commit timestamps\n\n## CHANGES\n\n- Simplify warning message for invalid commit timestamps\n- Remove parenthetical explanation about git history rewrites\n- Make error message more concise and readable","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T01:24:03Z","Parents":null},{"SHA":"616f51748eb5b54bd47fabdcd68b8a8b3c96d8f4","Message":"refactor: improve merge commit detection and update error messages\n\n## CHANGES\n\n- Move merge patterns to package-level variables\n- Update date parsing error message for clarity\n- Simplify author email field comment\n- Extract regex compilation from function scope\n- Improve merge commit detection performance\n- Clarify RFC3339 fallback error context","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T01:37:31Z","Parents":null},{"SHA":"f548ca5f8230f13bd2146d5f8597de41e1b7dc54","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-22T01:39:15Z","Parents":null},{"SHA":"f6fd6f535a7c225eb4fdcba250e1f78afce3b4cf","Message":"perf: optimize merge pattern matching with lazy initialization and sync.Once\n\n## CHANGES\n\n- Add sync package import for concurrency safety\n- Implement lazy initialization for merge patterns using sync.Once\n- Wrap merge patterns in getMergePatterns function\n- Replace direct mergePatterns access with function call\n- Ensure thread-safe pattern compilation on first use","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T01:57:51Z","Parents":null},{"SHA":"771a1ac2e62d772c8c8f2d6a8836f78f760c6266","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-22T01:59:17Z","Parents":null},{"SHA":"38ff2288daf779a9f7652d619c45dbce7936f9e0","Message":"refactor: replace sync.Once with mutex for merge patterns initialization\n\n## CHANGES\n\n- Replace sync.Once with mutex and boolean flag\n- Add thread-safe initialization check for merge patterns\n- Remove overly broad merge pattern regex rule\n- Improve error messaging for file removal failures\n- Clarify filesystem vs git index error contexts\n- Add detailed manual intervention instructions for failures","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T02:44:46Z","Parents":null},{"SHA":"5b97b0e56a2a65c7f5bea49d23dd9efcc7ee4595","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-22T02:45:07Z","Parents":null},{"SHA":"839296e3ba7bbc3ab3a1d25d1ffaa3d1eca51410","Message":"feat: add cross-platform file removal instructions for changelog generation\n\n## CHANGES\n\n- Import runtime package for OS detection\n- Add Windows-specific file deletion commands in error messages\n- Provide both Command Prompt and PowerShell alternatives\n- Maintain existing Unix/Linux rm command for non-Windows systems\n- Improve user experience across different operating systems","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T02:58:56Z","Parents":null},{"SHA":"e3fcbcb12b7af504877d6b5153c97d67e813e089","Message":"fix: improve error reporting in date parsing and merge commit detection\n\n## CHANGES\n\n- Capture first RFC3339Nano parsing error for better diagnostics\n- Display both RFC3339Nano and RFC3339 errors in output\n- Extract merge patterns to variable for cleaner code\n- Improve error message clarity in date parsing failures","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T03:08:13Z","Parents":null},{"SHA":"dde21d2337dbf17211716e7bb94d3d8bdad9da33","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-22T03:08:33Z","Parents":null},{"SHA":"58e635c8734d0adc4333e8cedb0b1b0d9076a2e6","Message":"refactor: improve error handling and simplify merge pattern management in changelog generation\n\n## CHANGES\n\n- Remove unused runtime import from processing.go\n- Simplify date parsing error messages in cache\n- Replace global merge pattern variables with struct\n- Use sync.Once for thread-safe pattern initialization\n- Remove OS-specific file deletion instructions from errors\n- Clean up merge commit detection function documentation\n- Eliminate redundant error variable in date parsing","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T03:25:52Z","Parents":null},{"SHA":"3de85eb50ef808dabec37960788aed816f455c05","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-22T03:26:17Z","Parents":null},{"SHA":"e2b0d3c3685eafa8a1902ad8b91e2bb1d81b6ea2","Message":"chore: standardize logging output format and improve error messages in changelog generator\n\n## CHANGES\n\n- Replace emoji prefixes with bracketed text labels\n- Standardize synchronization step logging format across methods\n- Simplify version existence check error message text\n- Update commit author email extraction comment clarity\n- Maintain consistent stderr output formatting throughout sync process","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T03:36:11Z","Parents":null},{"SHA":"15fad3da87800992f4af968a4d44255afe079389","Message":"refactor: simplify merge pattern management by removing unnecessary struct wrapper\n\n## CHANGES\n\n- Remove mergePatternManager struct wrapper for patterns\n- Replace struct fields with package-level variables\n- Simplify getMergePatterns function implementation\n- Clean up merge commit detection documentation\n- Reduce code complexity in pattern initialization\n- Maintain thread-safe lazy initialization with sync.Once","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T03:59:25Z","Parents":null},{"SHA":"e8ba57be9096057014f74a8cce37964a4a942f49","Message":"fix: improve error message formatting in version date parsing\n\n## CHANGES\n\n- Add actual error details to date parsing failure message\n- Include error variable in stderr output formatting\n- Enhance debugging information for invalid date formats","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-22T04:17:06Z","Parents":null},{"SHA":"c300262804171c8d0478fa4e1a455a1619cf9a04","Message":"chore: incoming 1642 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-22T04:17:44Z","Parents":null}]


title: Simplify Workflow with Single Version Retrieval Step
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1647
merged_at: 2025-07-25 14:45:58+00:00
created_at: 2025-07-26 14:34:29
body:
  # Simplify Workflow with Single Version Retrieval Step

  ## Summary

  This pull request refactors the version retrieval mechanism in the GitHub Actions release workflow. The changes replace OS-specific git tag commands with a unified approach that reads version information directly from a Nix configuration file.

  ## Files Changed

  - `.github/workflows/release.yml`: Modified the version retrieval step in the release workflow to use a single, cross-platform approach instead of separate OS-specific implementations.

  ## Code Changes

  The most significant change is the replacement of two separate version retrieval steps with a single unified step:

  **Removed:**
  ```yaml
  - name: Get latest tag
    if: matrix.os != 'windows-latest'
    id: get_latest_tag
    run: |
      latest_tag=$(git tag --sort=-creatordate | head -n 1)
      echo "latest_tag=$latest_tag" >> $GITHUB_ENV

  - name: Get latest tag
    if: matrix.os == 'windows-latest'
    id: get_latest_tag_windows
    run: |
      $latest_tag = git tag --sort=-creatordate | Select-Object -First 1
      Add-Content -Path $env:GITHUB_ENV -Value "latest_tag=$latest_tag"
  ```

  **Added:**
  ```yaml
  - name: Get version from source
    id: get_version
    shell: bash
    run: |
      if [ ! -f "nix/pkgs/fabric/version.nix" ]; then
        echo "Error: version.nix file not found"
        exit 1
      fi
      version=$(cat nix/pkgs/fabric/version.nix | tr -d '"' | tr -cd '0-9.')
      if [ -z "$version" ]; then
        echo "Error: version is empty"
        exit 1
      fi
      if ! echo "$version" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+' > /dev/null; then
        echo "Error: Invalid version format: $version"
        exit 1
      fi
      echo "latest_tag=v$version" >> $GITHUB_ENV
  ```

  ## Reason for Changes

  This change addresses several issues with the previous implementation:

  1. **Cross-platform compatibility**: Eliminates the need for separate Windows and Unix implementations
  2. **Single source of truth**: Uses the version defined in `nix/pkgs/fabric/version.nix` instead of relying on git tags
  3. **Improved reliability**: Adds comprehensive error handling and validation
  4. **Consistency**: Ensures the same version retrieval logic across all operating systems

  ## Impact of Changes

  - **Positive impacts**:
    - Simplified workflow maintenance with a single version retrieval step
    - More robust error handling prevents silent failures
    - Version format validation ensures consistency
    - Eliminates potential race conditions between git tagging and releases

  - **Potential risks**:
    - Dependency on the `nix/pkgs/fabric/version.nix` file existing and being properly formatted
    - If the Nix file format changes, the parsing logic may need updates
    - The `tr` command usage assumes a specific file format that may be fragile

  ## Test Plan

  The changes should be tested by:

  1. Verifying the workflow runs successfully on all matrix combinations (Linux, macOS, Windows)
  2. Confirming that the version is correctly extracted from `nix/pkgs/fabric/version.nix`
  3. Testing error conditions (missing file, empty version, invalid format)
  4. Ensuring the `latest_tag` environment variable is properly set for subsequent steps

  ## Additional Notes

  The new implementation uses `shell: bash` to ensure consistent behavior across all platforms, including Windows (which will use Git Bash or WSL). The version parsing logic strips quotes and non-numeric/period characters, then validates the format matches semantic versioning patterns. Consider adding unit tests for the version parsing logic if this becomes a critical path in the release process.

commits:
  [{"SHA":"12d7803044cf249361d13b381fd9c2e3cf3e60d7","Message":"chore: replace git tag lookup with version.nix file reading for release workflow\n\n## CHANGES\n\n- Remove OS-specific git tag retrieval steps\n- Add unified version extraction from nix file\n- Include version format validation with regex check\n- Add error handling for missing version file\n- Consolidate cross-platform version logic into single step\n- Use bash shell for consistent version parsing","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-25T14:33:18Z","Parents":null},{"SHA":"a241c9883765dbaa1a1d6631bd7c2b38eba2ee9b","Message":"chore: incoming 1647 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-25T14:39:52Z","Parents":null}]


title: Fix Conditional API Initialization to Prevent Unnecessary Error Messages
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1649
merged_at: 2025-07-26 00:02:41+00:00
created_at: 2025-07-26 14:34:29
body:
  # Fix Conditional API Initialization to Prevent Unnecessary Error Messages

  ## Summary

  This PR fixes an issue where Fabric would attempt to initialize and call Ollama and Bedrock APIs even when they weren't properly configured, resulting in confusing error messages during model listing operations. The changes implement proper configuration checks to ensure only explicitly configured API providers are initialized.

  ## Related Issues

  Closes #1195 
  Closes #1645
  Closes #1648 

  ## Files Changed

  ### 1. `.vscode/settings.json`
  - **Change**: Added new spell check words: `adduser`, `testuser`, `unconfigured`
  - **Reason**: Supporting new test infrastructure and terminology used in the fix

  ### 2. `internal/core/plugin_registry.go`
  - **Change**: Enhanced `hasAWSCredentials()` function to require both AWS credentials AND `BEDROCK_AWS_REGION` environment variable
  - **Reason**: Prevents Bedrock client initialization when AWS credentials exist for other purposes but Bedrock isn't specifically configured

  ### 3. `internal/plugins/ai/ollama/ollama.go`
  - **Change**: Added `IsConfigured()` method that explicitly checks for `OLLAMA_API_URL` environment variable
  - **Reason**: Ensures Ollama client is only initialized when explicitly configured, not just when using default localhost settings

  ### 4. `scripts/docker-test/` (New Directory)
  - **Change**: Added comprehensive Docker-based testing infrastructure
  - **Reason**: Provides isolated test environments to verify the fix works across different API configuration scenarios

  ## Code Changes

  ### Bedrock Configuration Check
  ```go
  // Before: Only checked for AWS credentials
  func hasAWSCredentials() bool {
      if os.Getenv("AWS_PROFILE") != "" || /* ... */ {
          return true
      }
      // ...
  }

  // After: Requires both AWS credentials AND Bedrock region
  func hasAWSCredentials() bool {
      // First check if BEDROCK_AWS_REGION is set - this is required for Bedrock
      if os.Getenv("BEDROCK_AWS_REGION") == "" {
          return false
      }
      
      // Then check if AWS credentials are available
      if os.Getenv("AWS_PROFILE") != "" || /* ... */ {
          return true
      }
      // ...
  }
  ```

  ### Ollama Configuration Check
  ```go
  // New method added to Ollama client
  func (o *Client) IsConfigured() bool {
      return os.Getenv("OLLAMA_API_URL") != ""
  }
  ```

  ## Reason for Changes

  This fix addresses issue #1195 where users with only some APIs configured (e.g., just Gemini) would see error messages like:
  - `Ollama Get "http://localhost:11434/api/tags": dial tcp...`
  - `Bedrock failed to list foundation models...`

  These errors occurred because the plugin registry would initialize all providers that had any potential configuration, rather than only those explicitly configured by the user.

  ## Impact of Changes

  ### Positive Impact
  - **Cleaner user experience**: Eliminates confusing error messages for unconfigured services
  - **Faster startup**: Avoids unnecessary network calls to unconfigured services
  - **Better error handling**: Only shows errors for services the user actually intends to use

  ### Potential Risks
  - **Breaking change risk**: Low - the changes make the configuration requirements more explicit rather than changing existing functionality
  - **Default behavior change**: Ollama will no longer auto-initialize with localhost:11434 unless `OLLAMA_API_URL` is explicitly set
  - **AWS integration**: Users must now set `BEDROCK_AWS_REGION` in addition to AWS credentials to use Bedrock

  ## Test Plan

  The PR includes a comprehensive Docker-based test suite with the following test cases:

  1. **no-config**: Verifies no error messages when no APIs are configured
  2. **gemini-only**: Reproduces and validates the fix for the original issue #1195
  3. **openai-only**: Tests OpenAI-only configuration
  4. **ollama-only**: Tests Ollama-only configuration with explicit URL
  5. **bedrock-only**: Tests Bedrock-only configuration with region requirement
  6. **mixed**: Tests multiple API configurations working together

  ### Running Tests
  ```bash
  # Run all tests
  ./scripts/docker-test/test-runner.sh

  # Interactive testing
  ./scripts/docker-test/test-runner.sh -i

  # Test specific scenario
  ./scripts/docker-test/test-runner.sh gemini-only
  ```

  ## Additional Notes

  - The fix maintains backward compatibility for users who have properly configured their APIs
  - Users with existing AWS credentials will need to add `BEDROCK_AWS_REGION` to use Bedrock
  - The test infrastructure can be used for future API integration testing and provides a good foundation for regression testing

commits:
  [{"SHA":"52246dda282d3ac6c18d821ed7a123a93abe73f1","Message":"feat: prevent unconfigured API initialization and add Docker test suite\n\n## CHANGES\n\n- Add BEDROCK_AWS_REGION requirement for Bedrock initialization\n- Implement IsConfigured check for Ollama API URL\n- Create comprehensive Docker testing environment with 6 scenarios\n- Add interactive test runner with shell access\n- Include environment files for different API configurations\n- Update spell checker dictionary with new test terms\n- Document testing workflow and expected results","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-25T23:50:44Z","Parents":null},{"SHA":"3a1eaf375f3d2ac56a44c2c31ab4e584af753429","Message":"chore: incoming 1649 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-25T23:58:59Z","Parents":null},{"SHA":"489c481acc8e0bb873d98053426a5462fb012fd9","Message":"docs: minor formatting of CHANGELOG","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-25T23:59:51Z","Parents":null}]


title: Update Gemini Plugin to New SDK with TTS Support
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1650
merged_at: 2025-07-26 20:04:32+00:00
created_at: 2025-07-26 23:15:15
body:
  # Update Gemini Plugin to New SDK with TTS Support

  ## Summary

  This pull request updates the Gemini plugin to use the new Google GenAI SDK and adds Text-to-Speech (TTS) audio output support. The changes include replacing the deprecated `generative-ai-go` library with `google.golang.org/genai`, implementing TTS model detection, adding WAV file generation capabilities, and updating the changelog generation workflow.

  ## Related Issues

  Closes #1606 
  Closes #1607

  ## Files Changed

  ### Core Plugin Changes
  - **`internal/plugins/ai/gemini/gemini.go`**: Complete rewrite of the Gemini client to use the new GenAI SDK, added TTS audio generation capabilities with WAV file output
  - **`internal/plugins/ai/gemini/gemini_test.go`**: Updated unit tests to work with the new SDK and added tests for TTS functionality

  ### CLI and Domain Changes
  - **`internal/cli/chat.go`**: Added TTS model detection, audio output validation, and user-friendly messaging for TTS operations
  - **`internal/cli/output.go`**: Added `CreateAudioOutputFile()` function for binary audio data and `IsAudioFormat()` utility for file format detection
  - **`internal/domain/domain.go`**: Extended `ChatOptions` struct with `AudioOutput` and `AudioFormat` fields

  ### Dependency Updates
  - **`go.mod`** and **`go.sum`**: Replaced `github.com/google/generative-ai-go` with `google.golang.org/genai v1.17.0` and updated related dependencies

  ### Development Environment
  - **`.vscode/settings.json`**: Added spelling dictionary entries for new dependencies (`atotto`, `flac`, `Kore`, `subchunk`)

  ### Changelog and Workflow
  - **`.github/workflows/update-version-and-create-tag.yml`**: Added `--sync-db` flag to changelog generation
  - **`CHANGELOG.md`**: Removed extra newline formatting
  - **`cmd/generate_changelog/`**: Updated database and added PR #1650 entry, fixed newline handling in processing

  ## Code Changes

  ### TTS Audio Generation
  ```go
  // New TTS generation method
  func (o *Client) generateTTSAudio(ctx context.Context, msgs []*chat.ChatCompletionMessage, opts *domain.ChatOptions) (ret string, err error) {
      textToSpeak, err := o.extractTextForTTS(msgs)
      if err != nil {
          return "", err
      }
      
      client, err := o.createGenaiClient(ctx)
      if err != nil {
          return "", err
      }
      
      return o.performTTSGeneration(ctx, client, textToSpeak, opts)
  }
  ```

  ### WAV File Generation
  ```go
  // WAV file creation with proper headers
  func (o *Client) generateWAVFile(pcmData []byte) ([]byte, error) {
      // Validate input and create WAV headers
      // Returns properly formatted WAV audio data
  }
  ```

  ### CLI Audio Validation
  ```go
  // TTS model and audio output validation
  isAudioOutput := currentFlags.Output != "" && IsAudioFormat(currentFlags.Output)
  isTTSModel := isTTSModel(currentFlags.Model)

  if isTTSModel && !isAudioOutput {
      err = fmt.Errorf("TTS model '%s' requires audio output", currentFlags.Model)
      return
  }
  ```

  ## Reason for Changes

  1. **SDK Migration**: The previous `generative-ai-go` library was deprecated, requiring migration to the official `google.golang.org/genai` SDK
  2. **TTS Support**: Added comprehensive Text-to-Speech functionality to support Gemini's TTS models like `gemini-2.5-flash-preview-tts`
  3. **Audio Output**: Implemented WAV file generation to properly handle binary audio data from TTS models
  4. **User Experience**: Added validation and user-friendly error messages for TTS operations

  ## Impact of Changes

  ### Positive Impacts
  - **New Functionality**: Users can now generate audio output using Gemini TTS models
  - **Future-Proof**: Updated to the official Google GenAI SDK ensuring long-term support
  - **Better Validation**: Comprehensive error checking prevents invalid TTS operations
  - **Audio Quality**: Proper WAV file generation with correct headers and format

  ### Potential Issues
  - **Breaking Change**: The SDK migration may affect existing Gemini integrations
  - **File Overwrite Protection**: TTS operations now check for existing files before generation
  - **Memory Usage**: Audio data processing may increase memory consumption for large TTS outputs
  - **Error Handling**: New error paths for TTS-specific failures

  ## Test Plan

  The changes include comprehensive unit tests for:
  - Model name building and validation
  - Text extraction from responses  
  - TTS model detection
  - WAV file generation with proper headers
  - Audio format detection utilities

  Manual testing should verify:
  - Regular text generation still works with Gemini models
  - TTS models generate valid WAV audio files
  - Error messages are clear and actionable
  - File existence checking prevents overwrites

  ## Additional Notes

  - **Security**: Added validation limits for audio data size (100MB max) to prevent potential security issues
  - **Performance**: Used efficient string building and pre-allocated buffers for audio processing
  - **Compatibility**: Maintained backward compatibility for existing text generation workflows
  - **Documentation**: The changes are self-documenting with clear error messages and validation logic

  The implementation follows Go best practices and includes proper error handling throughout the TTS pipeline. The WAV file generation uses standard audio format specifications with configurable parameters for future extensibility.

commits:
  [{"SHA":"3e75aa260f701de3ffe40c92f834868f1bdccb01","Message":"chore: update Gemini SDK to new genai library and add TTS audio output support\n\n## CHANGES\n\n- Replace deprecated generative-ai-go with google.golang.org/genai library\n- Add TTS model detection and audio output validation\n- Implement WAV file generation for TTS audio responses\n- Add audio format checking utilities in CLI output\n- Update Gemini client to support streaming with new SDK\n- Add \"Kore\" and \"subchunk\" to VSCode spell checker dictionary\n- Remove extra blank line from changelog formatting\n- Update dependency imports and remove unused packages","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-26T17:54:34Z","Parents":null},{"SHA":"8b6b8fbd4468d58699313ba8402bc0dd74e4dd96","Message":"chore: incoming 1650 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-26T18:07:12Z","Parents":null},{"SHA":"5d7137804a1ea512dfadeaa9117e0b191ef4d895","Message":"chore: update changelog generation to sync database\n\n### CHANGES\n\n- Add database sync command to changelog workflow\n- Remove unnecessary newline addition in changelog processing","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-26T18:14:02Z","Parents":null},{"SHA":"5cdf297d85157e0cefe4d8b4d7769a4e9ac20e87","Message":"refactor: extract TTS methods and add audio validation with security limits\n\n## CHANGES\n\n- Extract text extraction logic into separate method\n- Add GenAI client creation helper function\n- Split TTS generation into focused helper methods\n- Add audio data size validation with security limits\n- Implement MIME type validation for audio responses\n- Add WAV file generation input validation checks\n- Pre-allocate buffer capacity for better performance\n- Define audio constants for reusable configuration\n- Add comprehensive error handling for edge cases\n- Validate generated WAV data before returning results","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-26T18:29:12Z","Parents":null},{"SHA":"95e2e6a5ac1824267f027dee8f03559afb777a91","Message":"chore: more spelling words","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-26T18:30:04Z","Parents":null},{"SHA":"71c08648c675e525a55d2ff21bcc208d0f7f130a","Message":"chore: minor format fix","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-26T18:33:50Z","Parents":null},{"SHA":"c766915764e0b9fee0366c1d33d2fd91fad5fbf9","Message":"fix: initialize Parts slice in genai.Content struct to prevent nil pointer errors\n\n## CHANGES\n\n- Initialize Parts slice with empty slice in Content struct\n- Prevent potential nil pointer dereference during message conversion\n- Ensure Parts field is ready for append operations\n- Improve robustness of convertMessages function in Gemini client","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-26T19:06:39Z","Parents":null},{"SHA":"3a4bb4b9b270e729d22e23772b889fa6945ff535","Message":"fix: correct audio data extraction to avoid double byte conversion\n\n## CHANGES\n\n- Remove redundant byte conversion from audio data extraction\n- Extract audio data as string before converting once\n- Simplify audio data processing in chat handler\n- Fix potential data corruption in audio output","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-26T19:18:29Z","Parents":null}]


title: Implement Voice Selection for Gemini Text-to-Speech
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1652
merged_at: 2025-07-26 23:01:07+00:00
created_at: 2025-07-26 23:15:15
body:
  # Implement Voice Selection for Gemini Text-to-Speech

  ## Summary

  This pull request adds comprehensive Text-to-Speech (TTS) support for Google Gemini models in Fabric, including voice selection capabilities, shell completion support, and extensive documentation.

  ## Related Issues

  Closes #1651 

  ## Files Changed

  ### Configuration and Documentation Files
  - **`.vscode/settings.json`** - Added spell check entries for new TTS-related terms and voice names
  - **`README.md`** - Updated help documentation to include new `--voice` and `--list-gemini-voices` flags
  - **`docs/Gemini-TTS.md`** - New comprehensive guide for using Gemini TTS features
  - **`docs/voices/README.md`** - New documentation for voice samples directory

  ### Shell Completion Files
  - **`completions/_fabric`** (Zsh) - Added completion support for voice selection and voice listing
  - **`completions/fabric.bash`** (Bash) - Added TTS-related flags and voice completion
  - **`completions/fabric.fish`** (Fish) - Added voice completion function and TTS flags

  ### Core Implementation Files
  - **`internal/cli/flags.go`** - Added `Voice` and `ListGeminiVoices` flags with configuration support
  - **`internal/cli/listing.go`** - Added handler for listing available Gemini voices
  - **`internal/domain/domain.go`** - Extended `ChatOptions` struct to include `Voice` field
  - **`internal/plugins/ai/gemini/gemini.go`** - Enhanced TTS generation with voice validation and selection
  - **`internal/plugins/ai/gemini/voices.go`** - New comprehensive voice management system

  ## Code Changes

  ### Voice Management System
  The most significant addition is the new voice management system in `internal/plugins/ai/gemini/voices.go`:

  ```go
  type GeminiVoice struct {
      Name            string
      Description     string
      Characteristics []string
  }
  ```

  This provides a structured approach to managing 30+ Gemini TTS voices with descriptions and characteristics.

  ### TTS Generation Enhancement
  Enhanced the TTS generation in `gemini.go` to support voice selection:

  ```go
  // Validate voice name before making API call
  if opts.Voice != "" && !IsValidGeminiVoice(opts.Voice) {
      validVoices := GetGeminiVoiceNames()
      return "", fmt.Errorf("invalid voice '%s'. Valid voices are: %v", opts.Voice, validVoices)
  }
  ```

  ### Shell Completion Support
  Added comprehensive shell completion across all three supported shells (Bash, Zsh, Fish) for voice selection:

  ```bash
  _fabric_gemini_voices() {
    local -a voices
    voices=(${(f)"$(fabric --list-gemini-voices --shell-complete-list 2>/dev/null)"})
    compadd -X "Gemini TTS Voices:" ${voices}
  }
  ```

  ## Reason for Changes

  This enhancement addresses the need for advanced TTS capabilities in Fabric by:

  1. **Voice Variety** - Providing access to 30+ different AI voices with distinct characteristics
  2. **User Experience** - Adding intuitive voice selection with shell completion support
  3. **Documentation** - Comprehensive guides for users to understand TTS features and limitations
  4. **Validation** - Preventing API errors through client-side voice name validation

  ## Impact of Changes

  ### Positive Impacts
  - **Enhanced TTS Capabilities** - Users can now select from a wide variety of voices for different use cases
  - **Better User Experience** - Shell completion makes voice selection intuitive and error-free
  - **Comprehensive Documentation** - Users have clear guidance on TTS usage, rate limits, and troubleshooting
  - **Robust Error Handling** - Voice validation prevents unnecessary API calls with invalid voice names

  ### Potential Issues
  - **Rate Limiting** - Gemini TTS has strict rate limits (15 requests/day for free tier) which could frustrate users
  - **Voice List Maintenance** - The voice list is hardcoded and requires manual updates when Google adds new voices
  - **API Dependency** - TTS functionality depends on Google's Gemini API availability and quotas

  ## Test Plan

  The changes should be tested by:

  1. **Voice Selection Testing** - Verify all listed voices work correctly with TTS generation
  2. **Shell Completion Testing** - Test completion functionality in Bash, Zsh, and Fish shells
  3. **Error Handling Testing** - Verify proper error messages for invalid voices and quota exceeded scenarios
  4. **Documentation Testing** - Ensure all examples in documentation work as expected
  5. **Integration Testing** - Test TTS with various patterns and input methods

  ## Additional Notes

  ### Rate Limit Considerations
  Users should be aware that Gemini TTS has strict rate limits. The documentation clearly explains these limitations and provides guidance on managing usage.

  ### Voice List Maintenance
  The voice list is currently maintained manually based on Google's documentation. Future improvements could include dynamic voice discovery if Google provides an API endpoint for this purpose.

  ### Backward Compatibility
  All changes are backward compatible. Existing TTS usage will continue to work with the default "Kore" voice if no voice is specified.

commits:
  [{"SHA":"614b1322d5c378b75fd8ea15b98425c72dc0f6cf","Message":"feat: add Gemini TTS voice selection and listing functionality\n\n## CHANGES\n\n- Add `--voice` flag for TTS voice selection\n- Add `--list-gemini-voices` command for voice discovery\n- Implement voice validation for Gemini TTS models\n- Update shell completions for voice options\n- Add comprehensive Gemini TTS documentation\n- Create voice samples directory structure\n- Extend spell checker dictionary with voice names","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-26T22:11:30Z","Parents":null},{"SHA":"0b71b54698798588d7235b8d9e72cb9a1581a96e","Message":"chore: incoming 1652 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-26T22:23:00Z","Parents":null},{"SHA":"8c27b34d0fecae9b75b30d831afcc28b00e87e5b","Message":"chore: differentiate voice descriptions","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-26T22:58:29Z","Parents":null}]


title: docs: update Gemini TTS model references to gemini-2.5-flash-preview-tts
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1653
merged_at: 2025-07-26 23:34:38+00:00
created_at: 2025-07-27 21:15:24
body:
  # docs: update Gemini TTS model references to gemini-2.5-flash-preview-tts

  ## Summary

  Updated Gemini TTS model references from `gemini-2.0-flash-tts` to `gemini-2.5-flash-preview-tts` across documentation and code examples. This change reflects the migration to a newer version of Google's Gemini TTS model.

  ## Files Changed

  - **`docs/Gemini-TTS.md`**: Updated all model references and examples to use the new TTS model name
  - **`internal/plugins/ai/gemini/voices.go`**: Updated example command in the voice listing function
  - **`cmd/generate_changelog/changelog.db`**: Binary database file updated (likely tracking these changes)

  ## Code Changes

  ### Documentation Updates (`docs/Gemini-TTS.md`)
  Multiple command examples were updated to reflect the new model name:

  ```bash
  # Before
  echo "Hello, this is a test of Gemini TTS" | fabric -m gemini-2.0-flash-tts -o output.wav

  # After  
  echo "Hello, this is a test of Gemini TTS" | fabric -m gemini-2.5-flash-preview-tts -o output.wav
  ```

  All instances of `gemini-2.0-flash-tts` were systematically replaced with `gemini-2.5-flash-preview-tts` in:
  - Basic usage examples
  - Voice-specific examples
  - Pattern usage examples
  - CLI reference documentation

  ### Code Example Update (`internal/plugins/ai/gemini/voices.go`)
  The example command in the voice listing help text was updated:

  ```go
  // Before
  result += "Example: fabric --voice Charon -m gemini-2.0-flash-tts -o output.wav \"Hello world\"\n"

  // After
  result += "Example: fabric --voice Charon -m gemini-2.5-flash-preview-tts -o output.wav \"Hello world\"\n"
  ```

  ## Reason for Changes

  This change appears to be a model version upgrade from Google's Gemini 2.0 Flash TTS to Gemini 2.5 Flash Preview TTS. The "preview" designation suggests this is likely a newer, potentially improved version of the TTS model that may offer enhanced capabilities or performance.

  ## Impact of Changes

  - **User Experience**: Users following documentation will now use the updated model version
  - **Backward Compatibility**: Existing scripts using the old model name may need to be updated
  - **Functionality**: The change should be transparent to end users, maintaining the same API and voice options
  - **Documentation Consistency**: All references now point to the same model version

  ## Test Plan

  - Verify that the new model name `gemini-2.5-flash-preview-tts` is recognized by the Fabric CLI
  - Test basic TTS functionality with the updated model
  - Confirm all documented voice options work with the new model
  - Validate that example commands in documentation execute successfully

  ## Additional Notes

  - The binary database update suggests this change is being tracked in the changelog system
  - No functional code changes were made - only documentation and example updates
  - Users should verify that the new model is available in their Google AI/Gemini API access before updating their scripts
  - Consider adding a deprecation notice or migration guide if the old model will be discontinued

commits:
  [{"SHA":"27f913491237365227744efe1e819c53335c928c","Message":"docs: update Gemini TTS model references to gemini-2.5-flash-preview-tts\n\n## CHANGES\n\n- Update documentation examples to use gemini-2.5-flash-preview-tts\n- Replace gemini-2.0-flash-tts references throughout Gemini-TTS.md\n- Update voice selection example commands\n- Modify CLI help text example command\n- Update changelog database binary file","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-26T23:23:56Z","Parents":null},{"SHA":"612ae4e3b51658c1b346403c21fc0c1a3262229a","Message":"chore: incoming 1653 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-26T23:26:28Z","Parents":null}]


title: Refine Output File Handling for Safety
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1654
merged_at: 2025-07-27 05:36:43+00:00
created_at: 2025-07-27 21:15:24
body:
  # Refine Output File Handling for Safety

  ## Summary

  This PR adds file existence checking to the `CreateOutputFile` function and improves output messaging for better user experience. The changes prevent accidental file overwrites and redirect informational messages to stderr to maintain clean stdout output.

  ## Related Issues

  Closes https://github.com/danielmiessler/Fabric/issues/1646

  ## Files Changed

  - **internal/cli/output.go**: Modified the `CreateOutputFile` function to add file existence validation and improved output messaging.

  ## Code Changes

  ### internal/cli/output.go

  **Added file existence check:**
  ```go
  if _, err = os.Stat(fileName); err == nil {
      err = fmt.Errorf("file %s already exists, not overwriting. Rename the existing file or choose a different name", fileName)
      return
  }
  ```

  **Updated success message:**
  ```go
  // Changed from:
  fmt.Printf("\n\n... written to %s\n", fileName)
  // To:
  fmt.Fprintf(os.Stderr, "\n\n[Output also written to %s]\n", fileName)
  ```

  ## Reason for Changes

  1. **Prevent data loss**: The file existence check prevents accidental overwriting of existing files, which could result in unintended data loss.
  2. **Improve user experience**: Clear error messaging helps users understand why the operation failed and provides guidance on how to resolve the issue.
  3. **Better output separation**: Moving the informational message to stderr keeps stdout clean, which is important for CLI tools that may have their output piped or redirected.

  ## Impact of Changes

  - **Safety improvement**: Users can no longer accidentally overwrite existing files without explicit action
  - **Better CLI behavior**: Informational messages on stderr allow for cleaner stdout output when the tool is used in scripts or pipelines
  - **Enhanced error handling**: More descriptive error messages improve the overall user experience
  - **Backward compatibility**: The function signature remains unchanged, maintaining compatibility with existing code

  ## Test Plan

  The changes should be tested by:
  1. Attempting to create a file that doesn't exist (should work as before)
  2. Attempting to create a file that already exists (should fail with descriptive error)
  3. Verifying that success messages appear on stderr, not stdout
  4. Testing the function in pipeline scenarios to ensure stdout remains clean

  ## Additional Notes

  **Potential considerations:**
  - The current implementation uses `os.Stat()` to check file existence, which will also fail if there are permission issues accessing the file's directory
  - The error message provides clear guidance to users on how to resolve the conflict
  - The stderr output change may affect any existing code that expects the success message on stdout, though this is likely an improvement for most use cases

  **Edge cases to consider:**
  - Race conditions between the existence check and file creation (though this is minimal risk in typical CLI usage)
  - Permission issues that might cause `os.Stat()` to return errors other than "file not found"

commits:
  [{"SHA":"6aa38d2abc3ef9f687a56e6f774deac6595bb4ce","Message":"fix: prevent file overwrite and improve output messaging in CreateOutputFile\n\n## CHANGES\n\n- Add file existence check before creating output file\n- Return error if target file already exists\n- Change success message to write to stderr\n- Update message format with brackets for clarity\n- Prevent accidental file overwrites during output creation","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-27T03:16:47Z","Parents":null},{"SHA":"4887cdc353406018cdb07ccfc0c6f2ba85debfed","Message":"chore: incoming 1654 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-27T05:29:17Z","Parents":null}]


title: Add GitHub Release Description Update Feature
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1657
merged_at: 2025-07-28 04:30:40+00:00
created_at: 2025-07-28 04:43:02
body:
  # Add GitHub Release Description Update Feature

  ## Summary

  This PR adds functionality to automatically update GitHub release descriptions with AI-generated summaries. A new `--release` flag has been added to the changelog generator that allows updating existing GitHub releases with enhanced descriptions pulled from the cached AI summaries.

  ## Files Changed

  ### `.github/workflows/release.yml`
  - **Added**: Automatic execution of changelog generator with `--release` flag during the release workflow
  - **Purpose**: Ensures release descriptions are updated with AI summaries immediately after release creation

  ### `cmd/generate_changelog/README.md`
  - **Added**: Documentation for the new `--release` flag parameter
  - **Purpose**: Provides usage instructions for the new release update functionality

  ### `cmd/generate_changelog/changelog.db`
  - **Modified**: Binary database file updated with new data
  - **Purpose**: Contains cached version and AI summary data needed for release updates

  ### `cmd/generate_changelog/internal/config/config.go`
  - **Added**: `Release string` field to the Config struct
  - **Purpose**: Stores the version tag for release description updates

  ### `cmd/generate_changelog/internal/release.go`
  - **Added**: Complete new file implementing release management functionality
  - **Purpose**: Handles GitHub API interactions for updating release descriptions

  ### `cmd/generate_changelog/main.go`
  - **Added**: Command-line flag parsing and validation for `--release` parameter
  - **Added**: Release manager initialization and execution logic
  - **Purpose**: Integrates release update functionality into the main application flow

  ## Code Changes

  ### New Release Manager Implementation
  ```go
  type ReleaseManager struct {
      cache       *cache.Cache
      githubToken string
      owner       string
      repo        string
  }
  ```

  The new `ReleaseManager` struct provides methods to:
  - Retrieve AI summaries from the cache database
  - Authenticate with GitHub API using OAuth2
  - Fetch existing releases by tag
  - Update release descriptions with formatted AI summaries

  ### GitHub Workflow Integration
  ```yaml
  go run ./cmd/generate_changelog --release ${{ env.latest_tag }}
  ```

  The release workflow now automatically updates release descriptions after creating releases.

  ### Command Validation
  ```go
  if cfg.Release != "" && (cfg.IncomingPR > 0 || cfg.ProcessPRsVersion != "" || cfg.SyncDB) {
      return fmt.Errorf("--release cannot be used with other processing flags")
  }
  ```

  Added mutual exclusion validation to prevent conflicting flag combinations.

  ## Reason for Changes

  This feature addresses the need to automatically enhance GitHub release descriptions with AI-generated summaries of changes. Previously, releases would have minimal or generic descriptions. Now, the system can leverage the existing AI summarization capabilities to provide rich, informative release notes that help users understand what changed in each version.

  ## Impact of Changes

  ### Positive Impacts
  - **Enhanced User Experience**: Release pages now contain meaningful, AI-generated summaries of changes
  - **Automation**: Reduces manual effort required to write release descriptions
  - **Consistency**: Ensures all releases have properly formatted, informative descriptions
  - **Integration**: Seamlessly works with existing CI/CD pipeline

  ### Potential Risks
  - **API Rate Limits**: GitHub API calls could hit rate limits in high-frequency release scenarios
  - **Authentication Dependency**: Requires valid GitHub token for API access
  - **Cache Dependency**: Relies on AI summaries being present in the cache database
  - **Network Dependencies**: Requires network connectivity to GitHub API during release process

  ## Test Plan

  The changes should be tested by:

  1. **Manual Testing**: Run `go run ./cmd/generate_changelog --release v1.x.x` with an existing release tag
  2. **Workflow Testing**: Create a test release to verify the GitHub Actions integration
  3. **Error Handling**: Test with invalid version tags and missing AI summaries
  4. **Authentication**: Test with and without GitHub tokens to verify proper error handling
  5. **Flag Validation**: Verify mutual exclusion of `--release` with other processing flags

  ## Additional Notes

  - The implementation hardcodes the repository owner/name as "danielmiessler/fabric" - this should be made configurable for broader reusability
  - The release description format is currently fixed as "## Changes\n\n{ai_summary}" - this could be made customizable
  - Error handling includes specific messages for missing versions and empty AI summaries
  - The feature requires existing AI summaries in the cache database, so it should be used after running the AI summarization process
  - GitHub API authentication falls back to unauthenticated requests if no token is provided, which may have lower rate limits

commits:
  [{"SHA":"5203cba5a7ab53178601abd0c82d2798d1e7bd1f","Message":"feat: add GitHub release description update via `--release` flag\n\n### CHANGES\n\n- Add `--release` flag to generate_changelog to update GitHub release\n- Implement `ReleaseManager` for managing release descriptions\n- Create `release.go` for handling release updates\n- Update `release.yml` to run changelog generation\n- Ensure mutual exclusivity for `--release` with other flags\n- Modify `Config` struct to include `Release` field\n- Update `main.go` to handle new release functionality","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-28T04:12:04Z","Parents":null},{"SHA":"8ea264e96cabed884c82dedefa417c732ea460d5","Message":"feat: add GitHub release description update with AI summary\n\n## CHANGES\n\n- Add `--release` flag to command line options documentation\n- Enable AI summary updates for GitHub releases\n- Support version-specific release description updates\n- Reorder internal package imports for consistency","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-28T04:22:30Z","Parents":null},{"SHA":"98968d972f6e3a5289e40e39e51d549a2183e148","Message":"chore: incoming 1657 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-28T04:24:46Z","Parents":null}]


title: Update Release Process for Data Consistency
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1658
merged_at: 2025-07-28 04:49:56+00:00
created_at: 2025-08-08 15:05:13
body:
  # Update Release Process for Data Consistency

  ## Summary

  This pull request adds a database synchronization step to the release workflow before generating the changelog. The change ensures that the changelog generation process has access to the most up-to-date database state.

  ## Files Changed

  - **`.github/workflows/release.yml`**: Modified the release workflow to include a database synchronization command before changelog generation.

  ## Code Changes

  In the release workflow, a new command has been added before the existing changelog generation:

  ```yaml
  go run ./cmd/generate_changelog --sync-db
  go run ./cmd/generate_changelog --release ${{ env.latest_tag }}
  ```

  The new line `go run ./cmd/generate_changelog --sync-db` is executed immediately before the existing changelog generation command.

  ## Reason for Changes

  This change addresses a potential issue where the changelog generation might be working with stale or incomplete database information. By adding the `--sync-db` flag execution, we ensure that any database-dependent operations in the changelog generation process have access to the most current data state before proceeding with the actual release changelog creation.

  ## Impact of Changes

  - **Improved Data Consistency**: The changelog generation will now operate with synchronized database state, potentially improving the accuracy and completeness of generated changelogs.
  - **Minimal Performance Impact**: The addition of one extra command will slightly increase the release workflow execution time, but this is likely negligible compared to the benefits of data consistency.
  - **Enhanced Reliability**: Reduces the risk of changelog generation failures or incomplete information due to database synchronization issues.

  ## Test Plan

  - Verify that the release workflow completes successfully with the new database sync step
  - Confirm that the `--sync-db` flag is properly implemented in the `generate_changelog` command
  - Test that changelog generation produces expected results after database synchronization
  - Monitor release workflow execution times to ensure the additional step doesn't cause significant delays

  ## Additional Notes

  - The database synchronization step is positioned strategically before release note generation to ensure data consistency
  - No breaking changes are introduced, as this only adds a preparatory step to the existing workflow

commits:
  [{"SHA":"ea009ff64ba732a4b778cbbce6071a507bb73842","Message":"feat: add database sync before generating changelog in release workflow\n\n### CHANGES\n- Add database sync command to release workflow\n- Ensure changelog generation includes latest database updates","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-28T04:40:04Z","Parents":null},{"SHA":"75875ba9f511e81ce9baee4685288d6a81a257d9","Message":"chore: Update changelog cache db","Author":"Kayvan Sylvan","Email":"","Date":"2025-07-28T04:43:39Z","Parents":null},{"SHA":"f0998d36863322bd69ff57270b49c24543644508","Message":"chore: incoming 1658 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-07-28T04:47:56Z","Parents":null}]


title: Fix typos in t_ patterns
author: pbulteel
author_url: https://github.com/pbulteel
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1660
merged_at: 2025-07-30 02:18:45+00:00
created_at: 2025-08-08 15:05:13
body:
  ## What this Pull Request (PR) does
  There are typos in some of the TELOS patterns - ouptut instead of output

  ## Related issues
  No issues.

commits:
  [{"SHA":"72d099d40a8a1c1365043a96405bf9b689cf7037","Message":"Fix typos in t_ patterns","Author":"Patrick Bulteel","Email":"","Date":"2025-07-29T10:59:22Z","Parents":null}]


title: chore: remove redundant words
author: queryfast
author_url: https://github.com/queryfast
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1671
merged_at: 2025-08-05 04:04:35+00:00
created_at: 2025-08-08 15:05:13
body:
  ## What this Pull Request (PR) does


  remove redundant words

  ## Related issues
  Please reference any open issues this PR relates to in here.
  If it closes an issue, type `closes #[ISSUE_NUMBER]`.

  ## Screenshots
  Provide any screenshots you may find relevant to facilitate us understanding your PR.

commits:
  [{"SHA":"34ff4d30f24f7c175abc94fb912e4abb6be873f7","Message":"chore: remove redundant words\n\nSigned-off-by: queryfast \u003cqueryfast@outlook.com\u003e","Author":"queryfast","Email":"","Date":"2025-08-05T03:16:43Z","Parents":null}]


title: Add Support for Claude Opus 4.1 Model
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1673
merged_at: 2025-08-07 04:36:19+00:00
created_at: 2025-08-08 15:05:13
body:
  # Add Support for Claude Opus 4.1 Model

  ## Summary

  This PR refactors the GitHub Actions release workflow to improve build reliability and adds support for the Claude Opus 4.1 model. The main changes include separating the version retrieval into its own job, simplifying OS detection logic, fixing parameter conflicts for Anthropic models, and updating the anthropic-sdk-go dependency.

  ## Files Changed

  - **.github/workflows/release.yml**: Restructured the release workflow to separate concerns and improve maintainability
  - **cmd/generate_changelog/incoming/1673.txt**: Added changelog entry documenting these changes
  - **go.mod / go.sum**: Updated anthropic-sdk-go dependency from v1.4.0 to v1.7.0
  - **internal/plugins/ai/anthropic/anthropic.go**: Added Claude Opus 4.1 model support and fixed parameter handling

  ## Code Changes

  ### Release Workflow Refactoring
  The workflow now has a dedicated `get_version` job that runs before the build:
  ```yaml
  get_version:
    name: Get version
    runs-on: ubuntu-latest
    outputs:
      latest_tag: ${{ steps.get_version.outputs.latest_tag }}
  ```

  OS detection has been simplified from a multi-step process to inline ternary operators:
  ```yaml
  GOOS: ${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }}
  ```

  Changelog generation has been moved to a separate `update_release_notes` job that runs after all builds complete:
  ```yaml
  update_release_notes:
    needs: [build, get_version]
    runs-on: ubuntu-latest
  ```

  ### Anthropic Client Updates
  Added support for the new Claude Opus 4.1 model:
  ```go
  string(anthropic.ModelClaudeOpus4_1_20250805),
  ```

  Fixed temperature/topP parameter conflict issue:
  ```go
  // Only set one of Temperature or TopP as some models don't allow both
  if opts.Temperature != 0 {
      params.Temperature = anthropic.Opt(opts.Temperature)
  } else if opts.TopP != 0 {
      params.TopP = anthropic.Opt(opts.TopP)
  }
  ```

  ## Reason for Changes

  1. **Workflow Reliability**: The previous workflow had version retrieval duplicated across matrix jobs, which could lead to race conditions and inefficiencies. Separating this into its own job ensures it runs once and provides consistent output.

  2. **Claude Opus 4.1 Support**: Adding support for the latest Claude model provides users with access to improved AI capabilities.

  3. **Parameter Conflict Fix**: Some Anthropic models don't allow both temperature and topP parameters to be set simultaneously, which was causing API errors.

  4. **Simplified OS Detection**: The previous multi-step OS detection was unnecessarily complex and could be replaced with inline conditionals.

  ## Impact of Changes

  - **Improved CI/CD Performance**: Version retrieval now happens once instead of multiple times across matrix jobs
  - **Better Error Handling**: The temperature/topP fix prevents API errors when using certain Anthropic models
  - **Enhanced Model Support**: Users can now leverage the latest Claude Opus 4.1 model
  - **Cleaner Workflow**: Separation of concerns makes the workflow easier to maintain and debug

  ## Test Plan

  1. Verify the workflow runs successfully on push to main branch
  2. Confirm version is correctly extracted from `nix/pkgs/fabric/version.nix`
  3. Test that binaries are built for all OS/architecture combinations
  4. Verify release notes are properly generated after all builds complete
  5. Test Claude Opus 4.1 model integration with various temperature/topP combinations

  ## Additional Notes

  - The workflow now has explicit job dependencies (`needs: [test, get_version]`) ensuring proper execution order
  - The changelog generation runs as a final step to avoid conflicts with concurrent build jobs
  - The anthropic-sdk-go upgrade from v1.4.0 to v1.7.0 may include additional improvements beyond the Opus 4.1 model support

  **Potential Issues to Monitor:**
  - The ternary operator approach for OS detection should be tested across all matrix combinations
  - The temperature/topP logic prioritizes temperature when both are set - this behavior should be documented
  - The separate `update_release_notes` job requires all builds to complete successfully before running

commits:
  [{"SHA":"29aaf430ca088cdfc369d3a119ca9ac1389af548","Message":"fix: update anthropic SDK and refactor release workflow for release notes generation\n\n## CHANGES\n\n- Upgrade anthropic-sdk-go from v1.4.0 to v1.7.0\n- Move changelog generation to separate workflow job\n- Add Claude Opus 4.1 model support\n- Fix temperature/topP parameter conflict for models\n- Separate release artifact upload from changelog update\n- Add dedicated update_release_notes job configuration","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-07T02:50:36Z","Parents":null},{"SHA":"31f7f22629a2dafcdc3c9b2ce258a5a521d404b4","Message":"chore: incoming 1673 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-08-07T02:58:24Z","Parents":null},{"SHA":"e2dabc406dcc4d3e11b606100ac4efebb2afd569","Message":"ci: refactor release workflow to use shared version job and simplify OS handling","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-07T03:18:46Z","Parents":null},{"SHA":"d5431f984383eb4d868af370e2dbdd391b20ec85","Message":"chore: incoming 1673 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-08-07T03:29:04Z","Parents":null},{"SHA":"1a933e1c9ac272734232b40e5e698ff9f87a2086","Message":"refactor: improve chat parameter defaults handling with domain constants\n\n## CHANGES\n\n- Add domain constants for default chat parameter values\n- Update Anthropic client to check explicitly set parameters\n- Add documentation linking CLI flags to domain defaults\n- Improve temperature and TopP parameter selection logic\n- Ensure consistent default values across CLI and domain\n- Replace zero-value checks with explicit default comparisons\n- Centralize chat option defaults in domain package","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-07T03:56:08Z","Parents":null},{"SHA":"9e72df9c6c5525b5527a39c0af72a3b7806cf333","Message":"chore: incoming 1673 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-08-07T03:56:26Z","Parents":null},{"SHA":"2d414ec3947ad6f669719e1149cc4e1ea8098062","Message":"fix: ensure Anthropic client always sets temperature to override API default\n\n## CHANGES\n\n- Always set temperature parameter for consistent behavior\n- Prioritize TopP over temperature when explicitly set\n- Override Anthropic's default 1.0 with Fabric's 0.7\n- Add comprehensive tests for parameter precedence logic\n- Update VSCode dictionary with Keploy entry\n- Simplify conditional logic for temperature/TopP selection","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-07T04:25:24Z","Parents":null},{"SHA":"fa135036f4a335dc42206d6918843cd23b5e9554","Message":"chore: incoming 1673 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-08-07T04:25:57Z","Parents":null}]


title: Refactor authentication to support GITHUB_TOKEN and GH_TOKEN
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1676
merged_at: 2025-08-07 19:24:47+00:00
created_at: 2025-08-08 15:05:13
body:
  # GPT-5 support and Changelog/Release Notes generator fixes

  ## Summary

  - Document and clarify the precedence behavior of GetTokenFromEnv to support both GITHUB_TOKEN and GH_TOKEN (with examples).
  - Extend OpenAI client’s raw-mode model list to include gpt-5 to bypass structured chat formatting where required.

  ## Files Changed

  - Modified: cmd/generate_changelog/util/token.go
    - Add comprehensive documentation for GetTokenFromEnv including explicit precedence rules and examples.
  - Modified: internal/plugins/ai/openai/openai.go
    - Include gpt-5 in the set of models that require raw-mode requests.

  ## Code Changes

  - Token utility (documentation only; function behavior clarified):
    ```go
    // GetTokenFromEnv returns a GitHub token based on the following precedence order:
    //  1. If tokenValue is non-empty, it is returned.
    //  2. Otherwise, if the GITHUB_TOKEN environment variable is set, its value is returned.
    //  3. Otherwise, if the GH_TOKEN environment variable is set, its value is returned.
    //  4. If none of the above are set, an empty string is returned.
    //
    // Example:
    //
    //  os.Setenv("GITHUB_TOKEN", "abc")
    //  os.Setenv("GH_TOKEN", "def")
    //  GetTokenFromEnv("xyz") // returns "xyz"
    //  GetTokenFromEnv("")    // returns "abc"
    //  os.Unsetenv("GITHUB_TOKEN")
    //  GetTokenFromEnv("")    // returns "def"
    //  os.Unsetenv("GH_TOKEN")
    //  GetTokenFromEnv("")    // returns ""
    func GetTokenFromEnv(tokenValue string) string {
        if tokenValue == "" {
            tokenValue = os.Getenv("GITHUB_TOKEN")
            // ...
        }
        return tokenValue
    }
    ```
    Note: Only documentation was added in this diff; the underlying implementation should already fall back to GH_TOKEN after GITHUB_TOKEN, as documented.

  - OpenAI raw-mode models:
    ```go
    func (o *Client) NeedsRawMode(modelName string) bool {
        modelsNeedingRaw := []string{
            "o1",
            "o3",
            "o4",
            "gpt-5",
        }
        // ...
    }
    ```

  ## Reason for Changes

  - Improve discoverability and correctness of authentication behavior by explicitly documenting precedence and examples for GetTokenFromEnv, ensuring consistent usage across the codebase and environment setups.
  - Extend compatibility with the latest OpenAI model lineup by sending gpt-5 requests in raw mode, avoiding structured chat formatting that is not supported by certain models.

  ## Impact of Changes

  - Developer experience:
    - Clear guidance on how tokens are resolved reduces confusion and misconfiguration, especially in CI where either GITHUB_TOKEN or GH_TOKEN may be present.
  - AI integration:
    - Ensures that gpt-5 requests follow the correct request format, reducing runtime errors due to unsupported message structures.
  - Backward compatibility:
    - Token resolution precedence is explicitly documented. If the implementation already matched this behavior, there is no functional change; otherwise, consumers may see GH_TOKEN correctly picked up as a fallback when GITHUB_TOKEN is absent.

  ## Test Plan

  - Token resolution:
    - Unit tests for GetTokenFromEnv with combinations:
      - tokenValue set vs empty
      - GITHUB_TOKEN set/unset
      - GH_TOKEN set/unset
      - Both env vars set (ensure tokenValue takes precedence, then GITHUB_TOKEN, then GH_TOKEN).
  - OpenAI raw mode:
    - Unit test NeedsRawMode("gpt-5") returns true.
    - Integration smoke test to ensure requests to gpt-5 are sent without structured chat formatting and complete successfully.

  Example unit test scenarios:
  - tokenValue="xyz", GITHUB_TOKEN unset, GH_TOKEN unset => returns "xyz"
  - tokenValue="", GITHUB_TOKEN="abc", GH_TOKEN="def" => returns "abc"
  - tokenValue="", GITHUB_TOKEN unset, GH_TOKEN="def" => returns "def"
  - tokenValue="", both unset => returns ""

  ## Additional Notes

  - If the OpenAI API introduces gpt-5 variants (e.g., gpt-5.1), we may need prefix-based matching or to enumerate additional variants; current implementation uses exact string matching.
  - Consider updating user-facing docs/README to reflect the token precedence and GH_TOKEN support if not already documented.

commits:
  [{"SHA":"768e87879e315b0b42ba9b1f36529e5d5efcd37d","Message":"refactor: centralize GitHub token retrieval logic into utility function\n\n## CHANGES\n\n- Extract token retrieval into `util.GetTokenFromEnv` function\n- Support both `GITHUB_TOKEN` and `GH_TOKEN` environment variables\n- Replace direct `os.Getenv` calls with utility function\n- Add new `util/token.go` file for token handling\n- Update walker.go to use centralized token logic\n- Update main.go to use token utility function","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-07T17:01:11Z","Parents":null},{"SHA":"efcd7dcac28cef093be816e76ed86170cea95679","Message":"chore: incoming 1676 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-08-07T18:33:36Z","Parents":null},{"SHA":"9d18ad523e837d1a5b1110075b73cf451da672e3","Message":"docs: document GetTokenFromEnv behavior and token environment fallback","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-07T18:38:19Z","Parents":null},{"SHA":"f7c5c6d344281fb2323b5d653c73e092816ce18b","Message":"docs: document GetTokenFromEnv behavior and token environment fallback","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-07T18:42:48Z","Parents":null},{"SHA":"836557f41c23fa6e55ac43221e6d483ef58ae940","Message":"feat: add 'gpt-5' to raw-mode models in OpenAI client\n\n## CHANGES\n- Add gpt-5 to raw mode model requirements list.\n- Ensure gpt-5 responses bypass structured chat message formatting.\n- Align NeedsRawMode logic with expanded OpenAI model support.","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-07T19:15:44Z","Parents":null},{"SHA":"08ec89bbe17f6d951a9b3d638d238bf0e51b9534","Message":"chore: incoming 1676 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-08-07T19:16:21Z","Parents":null}]


title: Grant GITHUB_TOKEN write permissions for release notes job
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1677
merged_at: 2025-08-08 02:22:22+00:00
created_at: 2025-08-08 15:05:13
body:
  # Grant GITHUB_TOKEN write permissions for release notes job

  ## Summary

  Grant write permissions to the GITHUB_TOKEN for the update_release_notes job in the release workflow to enable updating GitHub Releases (release notes) during the pipeline.

  ## Files Changed

  - .github/workflows/release.yml
    - Added a job-level permissions block to allow writing to repository contents for the update_release_notes job.

  ## Code Changes

  In the update_release_notes job, explicitly request write permissions for repository contents:

  ```yaml
  jobs:
    update_release_notes:
      needs: [build, get_version]
      runs-on: ubuntu-latest
      permissions:
        contents: write
      steps:
        - name: Checkout code
          uses: actions/checkout@v4
  ```

  ## Reason for Changes

  - The update_release_notes job needs to create or update release notes via the GitHub API, which requires contents: write. Without this explicit permission, the default GITHUB_TOKEN may only have read access, causing failures such as “Resource not accessible by integration.”
  - Scoping permissions at the job level follows the principle of least privilege and avoids granting elevated permissions to other jobs.

  ## Impact of Changes

  - The release pipeline should now be able to successfully update or publish release notes.
  - Scope of elevated permissions is limited to the update_release_notes job only, reducing security risk while ensuring required functionality.
  - No impact on other jobs; their permissions remain unchanged.

  ## Test Plan

  - Trigger the release workflow (e.g., via workflow_dispatch or a tag push) and verify:
    - The update_release_notes job completes successfully without 403/permission errors.
    - The target GitHub Release has updated notes as expected.
  - If available, re-run a previously failing workflow to confirm the fix.
  - Validate that other jobs in the workflow are unaffected.

  ## Additional Notes

  - If the repository or organization enforces stricter global workflow permissions, this job-level override should generally suffice, but an org policy could still prevent escalation; if failures persist, confirm org/repo “Workflow permissions” settings.
  - actions/checkout@v4 remains compatible, as contents: write includes read access necessary for checkout.

commits:
  [{"SHA":"dc435dcc6ea81e5daa4300aba0d9575659740ca6","Message":"ci: add write permissions to update_release_notes job\n\n## CHANGES\n\n- Add contents write permission to release notes job\n- Enable GitHub Actions to modify repository contents\n- Fix potential permission issues during release process","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-08T02:17:19Z","Parents":null}]


title: Add cross-platform desktop notifications to Fabric CLI
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1679
merged_at: 2025-08-08 07:37:40+00:00
created_at: 2025-08-08 15:05:13
body:
  # Add cross-platform desktop notifications to Fabric CLI

  ## Summary

  Add cross-platform desktop notifications to the Fabric CLI with both built-in providers (macOS, Linux, Windows) and a user-specified custom command. Introduce two new CLI/YAML options, wire notifications into the chat processing flow, document usage, and add tests. Harden notification execution to prevent command/script injection from AI-generated content.

  ## Screenshot

  <img width="390" height="252" alt="image" src="https://github.com/user-attachments/assets/08deb81d-a361-427e-a7d6-f5a231c85941" />

  ## Related Issues

  Closes #1674 

  ## Files Changed

  - .vscode/settings.json
    - Add spelling dictionary entries for notification-related terms.

  - README.md
    - Document new CLI flags:
      - --notification
      - --notification-command

  - completions/_fabric
    - Add zsh completion entries for the two new flags.

  - completions/fabric.bash
    - Add bash completion entries and argument handling for the two new flags.

  - completions/fabric.fish
    - Add fish completion entries for the two new flags.

  - docs/Desktop-Notifications.md (new)
    - Add end-to-end documentation for notifications: usage, configuration, platform specifics, and troubleshooting.

  - docs/notification-config.yaml (new)
    - Provide example Fabric config enabling notifications and optional custom command.

  - internal/domain/domain.go
    - Extend ChatOptions with:
      - Notification bool
      - NotificationCommand string

  - internal/cli/flags.go
    - Add Flags:
      - Notification bool (CLI: --notification, YAML: notification)
      - NotificationCommand string (CLI: --notification-command, YAML: notificationCommand)
    - Propagate flags into ChatOptions, auto-enabling Notification if a NotificationCommand is set.

  - internal/cli/chat.go
    - Integrate notification sending at end of chat processing.
    - Implement sendNotification helper with title/message generation and security hardening.
    - Utilize internal/tools/notifications manager when no custom command is provided.

  - internal/cli/chat_test.go (new)
    - Unit tests around notification security, title generation, and message truncation.

  - internal/tools/notifications/notifications.go (new)
    - Implement cross-platform notification providers:
      - macOS: terminal-notifier (preferred), osascript (fallback)
      - Linux: notify-send
      - Windows: PowerShell MessageBox
      - Noop: unsupported environments
    - Provider selection via NotificationManager with availability checks.

  - internal/tools/notifications/notifications_test.go (new)
    - Provider availability and send-path tests (OS-aware), with special-character handling.

  - cmd/generate_changelog/incoming/1679.txt (new)
    - Changelog entry for this feature.

  ## Code Changes

  - New CLI flags (flags.go)
    ```go
    type Flags struct {
        // ...
        Notification        bool   `long:"notification" yaml:"notification" description:"Send desktop notification when command completes"`
        NotificationCommand string `long:"notification-command" yaml:"notificationCommand" description:"Custom command to run for notifications (overrides built-in notifications)"`
    }

    // BuildChatOptions: auto-enable Notification if a custom command is provided
    Notification:        o.Notification || o.NotificationCommand != "",
    NotificationCommand: o.NotificationCommand,
    ```

  - Chat integration (chat.go)
    ```go
    if chatOptions.Notification {
        if err = sendNotification(chatOptions, chatReq.PatternName, result); err != nil {
            // Do not fail main command; log only
            fmt.Fprintf(os.Stderr, "Failed to send notification: %v\n", err)
        }
    }
    ```

  - Notification execution with injection hardening (chat.go)
    ```go
    // Custom command: pass title/message as $1 and $2, not interpolated into shell
    cmd := exec.Command("sh", "-c", options.NotificationCommand+" \"$1\" \"$2\"", "--", title, message)
    cmd.Stdout = os.Stdout
    cmd.Stderr = os.Stderr
    return cmd.Run()
    ```

  - Built-in providers (notifications.go)
    - macOS (osascript): pass content via environment variables to avoid AppleScript injection:
      ```go
      script := `display notification (system attribute "FABRIC_MESSAGE") with title (system attribute "FABRIC_TITLE") sound name "Glass"`
      cmd := exec.Command("osascript", "-e", script)
      cmd.Env = append(os.Environ(), "FABRIC_TITLE="+title, "FABRIC_MESSAGE="+message)
      ```
    - Linux (notify-send): standard CLI call.
    - Windows (PowerShell): pass content via environment variables to avoid injection:
      ```go
      script := `Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.MessageBox]::Show($env:FABRIC_MESSAGE, $env:FABRIC_TITLE)`
      cmd := exec.Command("powershell", "-Command", script)
      cmd.Env = append(os.Environ(), "FABRIC_TITLE="+title, "FABRIC_MESSAGE="+message)
      ```

  - Message formatting (chat.go)
    - Title: "Fabric Command Complete" or "Fabric: <pattern> Complete"
    - Message: "Output: <first 100 code points...>" with newline-to-space normalization
    - Note: Truncation is code point-based, not grapheme cluster-aware.

  ## Reason for Changes

  - Feature addition: Provide user feedback when long-running or background Fabric tasks complete.
  - UX improvement: Cross-platform notifications without extra user setup; optional custom command for advanced workflows.
  - Security: Prevent command and script injection via notification payloads originating from AI-generated output.

  ## Impact of Changes

  - Functionality:
    - New optional notification capability on macOS, Linux, and Windows.
    - Non-breaking defaults; notifications only activate when requested.
    - Custom commands receive title ($1) and message ($2) safely as positional args, mitigating injection.
  - Documentation and discoverability:
    - New docs and README help entries.
    - Shell completions updated for all major shells.
  - Runtime:
    - Minimal overhead when disabled.
    - When enabled, performs provider detection and one subprocess execution at completion time.
  - Compatibility:
    - Built-in providers rely on commonly available tools:
      - macOS: osascript is built-in; terminal-notifier optional (Homebrew).
      - Linux: notify-send requires libnotify-bin.
      - Windows: PowerShell with WinForms; may not work in headless environments.

  ## Test Plan

  - Unit tests:
    - internal/cli/chat_test.go
      - Verify no panics and proper handling for special characters/backticks/quotes/newlines in payload.
      - Validate title generation with and without pattern name.
      - Exercise message truncation logic.
    - internal/tools/notifications/notifications_test.go
      - Provider availability checks (OS-aware).
      - Send-path smoke tests with tolerant assertions.
      - Special character handling.

  - Manual tests:
    - macOS:
      - With terminal-notifier installed and without (osascript fallback).
      - Example: fabric --pattern summarize --notification < file.txt
    - Linux:
      - With notify-send installed; verify notification appears.
    - Windows:
      - Verify PowerShell-based MessageBox appears after completion.
    - Custom command:
      - Example:
        fabric --pattern summarize --notification-command 'notify-send --urgency=normal "$1" "$2"' < input.txt
      - Validate correct positional parameter passing with: 'echo "Title: $1, Message: $2"'
    - Config-based enablement via docs/notification-config.yaml.

  ## Additional Notes

  - Potential issues and follow-ups:
    - Windows tests: chat_test.go invokes sh -c for custom commands and may fail on Windows environments without a POSIX shell. Consider gating these tests by OS or using a cross-platform execution strategy for tests.
    - Windows MessageBox is modal and can block in unattended/headless environments; consider switching to Toast Notifications for non-blocking behavior in a future iteration.
    - When notifications are enabled but no provider is available, we log a non-fatal error. This could be noisy; consider suppressing the warning unless a verbose/debug mode is set.
    - Unicode truncation is rune-based; complex graphemes may be cut mid-cluster. If necessary, replace with grapheme-aware truncation.
    - Custom command stdout/stderr are currently attached to the parent process for debugging; consider making this conditional on a debug flag to avoid unexpected console output.

commits:
  [{"SHA":"21f258caa4903ddb72b25b2b732534fee421877a","Message":"feat(cli): add cross-platform desktop notifications with secure custom commands\n\nCHANGES\n- Integrate notification sending into chat processing workflow\n- Add --notification and --notification-command CLI flags and help\n- Provide cross-platform providers: macOS, Linux, Windows with fallbacks\n- Escape shell metacharacters to prevent injection vulnerabilities\n- Truncate Unicode output safely for notification message previews\n- Update bash, zsh, fish completions with new notification options\n- Add docs and YAML examples for configuration and customization\n- Add unit tests for providers and notification integration paths","Author":"github-actions[bot]","Email":"","Date":"2025-08-08T02:24:57Z","Parents":null},{"SHA":"0a718be6224c743dae8e000503c984f1157db413","Message":"chore: incoming 1679 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-08-08T07:30:20Z","Parents":null},{"SHA":"30d23f15bea1f18a67bd9889a291c1f6979c617d","Message":"chore: format fix","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-08T07:35:04Z","Parents":null}]


title: Enhance YouTube Support with Custom yt-dlp Arguments
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1681
merged_at: 2025-08-09 17:24:09+00:00
merge_commit: d82122b6245323ba5f411b1b33dcd0410b9edf81
created_at: 2025-08-09 17:26:32
body:
  # Enhance YouTube Support with Custom yt-dlp Arguments

  ## Summary

  Add support for passing custom yt-dlp arguments to YouTube transcript extraction, improve robustness against rate limiting and authentication requirements, introduce language fallback handling, and document the full YouTube processing workflow. Also update CLI help and shell completions, and add a dedicated YouTube processing guide.

  ## Files Changed

  - CHANGELOG.md
    - Minor formatting and wording cleanup for recent entries.

  - README.md
    - Add new CLI option to help text:
      - `--yt-dlp-args=                Additional arguments to pass to yt-dlp (e.g. '--cookies-from-browser brave')`

  - cmd/generate_changelog/changelog.db
    - Regenerated database (binary change).

  - completions/_fabric (zsh)
    - Add `--yt-dlp-args` completion and description.

  - completions/fabric.bash (bash)
    - Include `--yt-dlp-args` in the options list and in the branch of options that take a value.

  - completions/fabric.fish (fish)
    - Add `--yt-dlp-args` completion and description.

  - docs/YouTube-Processing.md
    - New documentation file covering YouTube transcript/comments/metadata features, advanced yt-dlp usage, argument precedence, troubleshooting (incl. 429 rate limiting), and configuration.

  - internal/cli/cli.go
    - Wire `--yt-dlp-args` through the YouTube transcript processing path.

  - internal/cli/flags.go
    - Add new CLI flag and YAML config mapping for yt-dlp args.

  - internal/tools/youtube/youtube.go
    - Core enhancements to yt-dlp integration: user-provided args, arg precedence, improved error handling, language fallback, and more resilient subtitle file discovery.

  ## Code Changes

  - internal/cli/flags.go
    - New flag and config key:
      ```go
      YtDlpArgs string `long:"yt-dlp-args" yaml:"ytDlpArgs" description:"Additional arguments to pass to yt-dlp (e.g. '--cookies-from-browser brave')"`
      ```

  - internal/cli/cli.go
    - Pass user-specified yt-dlp args through the transcript calls:
      ```go
      if flags.YouTubeTranscriptWithTimestamps {
          transcript, err = registry.YouTube.GrabTranscriptWithTimestampsWithArgs(videoId, language, flags.YtDlpArgs)
      } else {
          transcript, err = registry.YouTube.GrabTranscriptWithArgs(videoId, language, flags.YtDlpArgs)
      }
      ```

  - internal/tools/youtube/youtube.go
    - New arg parsing helper for shell-like strings:
      ```go
      func parseShellArgs(argsStr string) []string { /* handles quotes and basic escaping */ }
      ```
    - New API that accepts additional yt-dlp args and routes existing methods through them:
      ```go
      func (o *YouTube) GrabTranscriptWithArgs(videoId, language, additionalArgs string) (string, error)
      func (o *YouTube) GrabTranscriptWithTimestampsWithArgs(videoId, language, additionalArgs string) (string, error)
      ```
    - Construct yt-dlp invocation with explicit precedence:
      ```go
      baseArgs := []string{"--write-auto-subs", "--skip-download", "--sub-format", "vtt", "--quiet", "--no-warnings", "-o", outputPath}

      // 1) built-in base args
      args := append([]string{}, baseArgs...)

      // 2) built-in language selection (if provided)
      if language != "" {
          langMatch := language
          if len(langMatch) > 2 { langMatch = langMatch[:2] }
          args = append(args, "--sub-langs", langMatch)
      }

      // 3) user args (last, so they override)
      if additionalArgs != "" {
          args = append(args, parseShellArgs(additionalArgs)...)
      }

      // 4) URL
      args = append(args, videoURL)
      cmd := exec.Command("yt-dlp", args...)
      ```
      Note: The option used is `--sub-langs` (plural), consistent with yt-dlp’s expected flag.

    - Improved error messages and handling:
      - Detects rate limiting (HTTP 429 / “Too Many Requests”) and suggests mitigations (e.g., `--sleep-requests`).
      - Detects bot-protection/authentication failures and suggests using `--cookies-from-browser`.
      - On failure with a requested language, automatically retries without language to let yt-dlp choose any available subtitle.

    - More resilient VTT discovery with fallback:
      ```go
      // Prefer requested language; otherwise fall back to any language-coded VTT, then any VTT
      func (o *YouTube) findVTTFilesWithFallback(dir, requestedLanguage string) ([]string, error)
      ```

  - Completions (zsh, bash, fish)
    - Add `--yt-dlp-args` to completions and mark it as a value-taking option.

  - docs/YouTube-Processing.md
    - Comprehensive guide including:
      - Usage for transcript, timestamps, comments, metadata
      - Advanced yt-dlp args and precedence model
      - Handling auth (cookies-from-browser), rate limits, and language fallbacks
      - YAML config (`ytDlpArgs`) and examples
      - Troubleshooting section for common issues and 429s

  - CHANGELOG.md
    - Small formatting and wording cleanup.

  ## Reason for Changes

  - Provide users with the flexibility to pass arbitrary yt-dlp options to:
    - Authenticate with cookies for age-restricted/private videos.
    - Tweak network behavior (e.g., avoid 429s via sleep/backoff).
    - Override language/format decisions when needed.
  - Improve reliability of transcript extraction by:
    - Handling common YouTube failure modes with clear guidance.
    - Falling back gracefully when the requested language is unavailable or blocked.
    - Selecting a usable VTT when language-specific files aren’t present.
  - Enhance usability by documenting the full workflow and exposing the new option in help and completions.

  ## Impact of Changes

  - Backwards compatible:
    - Default behavior remains unchanged if `--yt-dlp-args` is not provided.
    - Transcript extraction remains yt-dlp based.
  - More robust YouTube processing:
    - Better resilience against YouTube’s rate limiting and anti-bot measures.
    - Automatic fallback when language-specific subtitles are not available.
  - Improved UX:
    - Clearer error messages.
    - Easy authentication path via `--cookies-from-browser`.
    - Discoverable via CLI help and shell completions.
  - Documentation uplift:
    - New dedicated guide should reduce support burden and help users self-serve.

  ## Test Plan

  Manual tests:
  - Baseline transcript
    - `fabric -y "https://www.youtube.com/watch?v=VIDEO_ID" --pattern summarize`
    - Verify transcript is produced as before.
  - With timestamps
    - `fabric -y "https://www.youtube.com/watch?v=VIDEO_ID" --transcript-with-timestamps`
    - Verify timestamps are preserved.
  - Language selection
    - `fabric -g es -y "..."` and confirm Spanish (or fallback) is used.
  - Language fallback
    - Use a video without the requested language: `fabric -g xx -y "..."` and verify fallback to any available VTT.
  - Custom yt-dlp args precedence
    - Provide conflicting args, e.g. `--yt-dlp-args "--sub-langs fr"` with `-g es` and verify fr takes precedence.
    - Provide authentication: `--yt-dlp-args "--cookies-from-browser brave"`.
    - Provide throttling: `--yt-dlp-args "--sleep-requests 1"`.
  - Error handling
    - Simulate conditions that trigger 429/anti-bot (or verify via crafted stderr) and confirm user-facing guidance.
  - VTT discovery
    - Confirm correct file selected when multiple languages exist.
  - Completions
    - Verify `--yt-dlp-args` appears in zsh/bash/fish completions and accepts values.
  - YAML config
    - Add `ytDlpArgs: "--cookies-from-browser brave"` to config and ensure it’s applied by default.

  ## Additional Notes

  - parseShellArgs is a minimal shell-like splitter designed to handle quoted strings; it does not fully emulate shell parsing (e.g., complex escaping outside quotes). This should be sufficient for common yt-dlp arg strings. If we encounter edge cases, we can consider a more robust parser or require array-like config in the future.
  - The switch to `--sub-langs` aligns with yt-dlp’s flag name and enables selecting multiple languages should we extend in the future.
  - Users can still override any built-in behavior by specifying the same option in `--yt-dlp-args` (user args are appended last).

commits:
  [{"SHA":"2b195f204db0e8bf08872f5e768ddd06badb6994","Message":"ci: separate release notes generation into dedicated job\n\n## CHANGES\n\n- Move changelog generation to separate workflow job\n- Add fallback logic for YouTube subtitle language detection\n- Remove changelog commands from main release job\n- Create dedicated update_release_notes job with Go setup\n- Implement retry mechanism without language specification\n- Improve yt-dlp command argument construction flexibility\n- Add proper checkout and Go configuration steps","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-04T04:46:24Z","Parents":["1d9596bf3da375b538c663488abcb92b68f13271"]},{"SHA":"bdb36ee296c76c72d9fab1019a731b73b46dd9d1","Message":"Merge branch 'main' into 0803-youtube-transcript-lang-fix","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-08T23:42:37Z","Parents":["2b195f204db0e8bf08872f5e768ddd06badb6994","1351f138fb95a0d7f7c3ed1ab6cdfb63f6e859c0"]},{"SHA":"261eb30951979d36e85a7cdf8c11812180cfa4a8","Message":"feat: add `--yt-dlp-args` flag for custom YouTube downloader options\n\n### CHANGES\n\n- Introduce `--yt-dlp-args` flag for advanced control\n- Allow passing browser cookies for authentication\n- Improve error handling for YouTube rate limits\n- Add comprehensive documentation for YouTube processing\n- Refactor YouTube methods to accept additional arguments\n- Update shell completions to include new flag","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-09T06:03:02Z","Parents":["bdb36ee296c76c72d9fab1019a731b73b46dd9d1"]},{"SHA":"caca366511a208949d9d10e738ac5d1d1acff89f","Message":"docs: update YouTube processing documentation for yt-dlp argument precedence control\n\n## CHANGES\n\n- Add user argument precedence over built-in flags\n- Document argument order and override behavior\n- Include new precedence section with detailed explanation\n- Add override examples for language and format\n- Update tips section with precedence guidance\n- Modify Go code to append user args last\n- Add testing tip for subtitle language discovery\n- Include practical override use case examples","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-09T06:14:28Z","Parents":["261eb30951979d36e85a7cdf8c11812180cfa4a8"]},{"SHA":"8414e72545fb4a762a1fda764e1856de3fe3537f","Message":"feat: add smart subtitle language fallback when requested locale unavailable\n\nCHANGES\n- Introduce findVTTFilesWithFallback to handle subtitle language absence\n- Prefer requested language VTT, gracefully fallback to available alternatives\n- Auto-detect downloaded subtitle language and proceed without interruption\n- Update yt-dlp processing to use fallback-aware VTT discovery\n- Document language fallback behavior and provide usage example\n- Return first available VTT when no specific language requested\n- Detect language-coded filenames using regex for robust matching","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-09T06:39:12Z","Parents":["caca366511a208949d9d10e738ac5d1d1acff89f"]},{"SHA":"30525ef1c010f37c271f4d14e54941cb70031115","Message":"chore: incoming 1681 changelog entry","Author":"Changelog Bot","Email":"kayvan@sylvan.com","Date":"2025-08-09T06:44:42Z","Parents":["8414e72545fb4a762a1fda764e1856de3fe3537f"]},{"SHA":"d69757908f1aeda8a8e8f757e5038e85dedb00c1","Message":"docs: update release notes","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-09T06:49:55Z","Parents":["30525ef1c010f37c271f4d14e54941cb70031115"]},{"SHA":"9a118cf637deb872d4e40a654680e0bf75c2de10","Message":"refactor: replace custom arg parser with shellquote; precompile regexes\n\nCHANGES\n- Precompile regexes for video, playlist, VTT tags, durations.\n- Parse yt-dlp additional arguments using shellquote.Split for safety.\n- Validate user-provided yt-dlp args and surface quoting errors.\n- Reuse compiled regex in GetVideoOrPlaylistId extractions for stability.\n- Simplify removeVTTTags by leveraging precompiled VTT tag matcher.\n- Parse ISO-8601 durations with precompiled pattern for efficiency.\n- Replace inline VTT language regex with cached compiled matcher.\n- Remove unused findVTTFiles helper and redundant language checks.\n- Add go-shellquote dependency in go.mod and go.sum.\n- Reduce allocations by eliminating per-call regexp.MustCompile invocations.","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-09T17:01:24Z","Parents":["d69757908f1aeda8a8e8f757e5038e85dedb00c1"]},{"SHA":"9470ee1655aef692012335a468e68a2d5b64fdee","Message":"chore: incoming 1681 changelog entry","Author":"Changelog Bot","Email":"kayvan@sylvan.com","Date":"2025-08-09T17:06:50Z","Parents":["9a118cf637deb872d4e40a654680e0bf75c2de10"]},{"SHA":"f5966af95ab65860ec49704faca629a4e3a0e30c","Message":"docs: update release notes","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-09T17:09:32Z","Parents":["9470ee1655aef692012335a468e68a2d5b64fdee"]}]


title: Fix Gemini Role Mapping for API Compatibility
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1685
merged_at: 2025-08-10 12:11:16+00:00
merge_commit: b974e1bfd5e396f12daae8bf8e21b10e577fa3b1
created_at: 2025-08-10 12:13:41
body:
  # Fix Gemini Role Mapping for API Compatibility

  ## Summary

  This PR fixes role mapping in the Gemini AI plugin and adds corresponding test coverage. The changes ensure that chat completion messages are properly converted to Gemini API format by explicitly mapping message roles to the limited role types supported by Gemini's API.

  ## Related Issues

  Closes #1672

  ## Files Changed

  - **`.vscode/settings.json`**: Added two new words to the spell checker dictionary: "kballard" and "shellquote"
  - **`internal/plugins/ai/gemini/gemini.go`**: Added explicit role mapping logic in the `convertMessages` method
  - **`internal/plugins/ai/gemini/gemini_test.go`**: Added new test case to verify role mapping functionality

  ## Code Changes

  ### internal/plugins/ai/gemini/gemini.go

  Added role mapping logic in the `convertMessages` method:

  ```go
  switch msg.Role {
  case chat.ChatMessageRoleAssistant:
      content.Role = "model"
  case chat.ChatMessageRoleUser:
      content.Role = "user"
  case chat.ChatMessageRoleSystem, chat.ChatMessageRoleDeveloper, chat.ChatMessageRoleFunction, chat.ChatMessageRoleTool:
      // Gemini's API only accepts "user" and "model" roles.
      // Map all other roles to "user" to preserve instruction context.
      content.Role = "user"
  default:
      content.Role = "user"
  }
  ```

  ### internal/plugins/ai/gemini/gemini_test.go

  Added `TestConvertMessagesRoles` function to verify that:
  - User messages are mapped to "user" role
  - Assistant messages are mapped to "model" role  
  - System messages are mapped to "user" role

  ## Reason for Changes

  The Gemini API only supports two role types: "user" and "model". Previously, the code was not explicitly handling role mapping, which could have caused issues when messages with unsupported roles (like "system", "developer", "function", or "tool") were sent to the API. This change ensures compatibility with Gemini's API requirements while preserving the context of system and other instruction messages by mapping them to the "user" role.

  ## Impact of Changes

  - **Compatibility**: Ensures all message types are properly handled when communicating with Gemini API
  - **Reliability**: Prevents potential API errors due to unsupported role types
  - **Functionality**: System messages and other instruction types are preserved as user messages, maintaining their instructional context
  - **Testing**: Improved test coverage for the role conversion functionality

  ## Test Plan

  The changes include a new unit test `TestConvertMessagesRoles` that verifies:
  1. User messages are correctly mapped to "user" role
  2. Assistant messages are correctly mapped to "model" role
  3. System messages are correctly mapped to "user" role
  4. The conversion maintains the correct number of messages

  ## Additional Notes

  ### Potential Issues to Monitor

  1. **Context Loss**: While system messages are preserved by mapping to "user" role, the semantic distinction between system instructions and user input is lost at the API level
  2. **Message Order**: The mapping might affect how Gemini interprets conversation flow, particularly when system messages are interspersed with user/assistant messages
  3. **Token Usage**: Converting system messages to user messages might affect token counting and billing

commits:
  [{"SHA":"33c24e0cb205c33ce7d7d88fc812b8f2091863b6","Message":"fix(gemini): map chat roles to Gemini user/model in convertMessages\n\nCHANGES\n- Map assistant role to model per Gemini constraints\n- Map system, developer, function, tool roles to user\n- Default unrecognized roles to user to preserve instruction context\n- Add unit test validating convertMessages role mapping logic\n- Import chat package in tests for role constants","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-10T11:55:33Z","Parents":["8fb0c5b8a8fd91cabdd8af12971a86db745c931f"]},{"SHA":"8dda68b3b9b1e9dc6eae65dd5c72f0b65309f5ea","Message":"chore: incoming 1685 changelog entry","Author":"Changelog Bot","Email":"kayvan@sylvan.com","Date":"2025-08-10T12:07:06Z","Parents":["33c24e0cb205c33ce7d7d88fc812b8f2091863b6"]}]


title: Prevent duplicate text output in OpenAI streaming responses
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1686
merged_at: 2025-08-10 12:32:17+00:00
merge_commit: 1694324261bdf6c25e1999c418683311f0029111
created_at: 2025-08-10 12:34:49
body:
  # Prevent duplicate text output in OpenAI streaming responses

  ## Summary

  Stop forwarding the final ResponseOutputTextDone text payload in streaming responses to prevent duplicated output. The OpenAI Responses API sends the full accumulated text again in the “done” event; since we already stream all deltas, emitting the final text duplicates content. We now ignore the final text and rely on the stream closing to signal completion.

  ## Related Issues

  Closes #1684 

  ## Files Changed

  - internal/plugins/ai/openai/openai.go
    - Modified sendStreamResponses to no longer send the final text on ResponseOutputTextDone events. Added an explanatory comment.

  ## Code Changes

  - In sendStreamResponses, replace emitting the final text with a no-op:

  ```go
  case string(constant.ResponseOutputTextDone("").Default()):
      // The Responses API sends the full text again in the
      // final "done" event. Since we've already streamed all
      // delta chunks above, sending it would duplicate the
      // output. Ignore it here to prevent doubled results.
      continue
  ```

  Previously this branch sent the final text:
  ```go
  channel <- event.AsResponseOutputTextDone().Text
  ```

  ## Reason for Changes

  - Bug fix: Streaming consumers were receiving duplicated output because we:
    1) streamed text via ResponseOutputTextDelta chunks, and then
    2) sent the full accumulated text again on ResponseOutputTextDone.
  - This resulted in repeated content in UIs and logs and forced downstream consumers to implement deduplication. Ignoring the final text eliminates the duplication.

  ## Impact of Changes

  - Behavior:
    - Consumers of the streaming channel will no longer get a final “full text” message. They will only receive the deltas and must assemble them if they need the full text.
    - The end of the stream (and channel closure) remains the signal for completion.
  - Compatibility:
    - If any downstream logic relied on the content of the done event (rather than the deltas) to render the final output, it will need to switch to aggregating deltas.
  - Reliability vs duplication trade-off:
    - Previously, the done event could act as a “fallback” full text if a delta were missed. We are opting for correctness (no duplication) and consistency with typical streaming semantics. If needed, we can revisit with an opt-in behavior or conditional logic (see Additional Notes).

  ## Test Plan

  - Unit tests:
    - Simulate a stream of:
      - ResponseOutputTextDelta: “Hel”, “lo”
      - ResponseOutputTextDone: “Hello”
    - Assert the channel yields only “Hel”, “lo” and does not include “Hello”.
    - Verify the channel closes properly and that stream.Err() handling is unchanged.
  - Integration tests:
    - Manual test against the OpenAI Responses API to confirm:
      - No duplicated content is rendered in the UI/logs.
      - Finalization and channel closure still occur as expected.
  - Regression:
    - Confirm non-text events and error propagation are unaffected.

  ## Additional Notes

  - If we later discover providers that include additional metadata (not just duplicated text) in the done event, we may:
    - Forward only metadata while skipping text, or
    - Make forwarding the done payload configurable.
  - As a future improvement, we could conditionally drop the done text only if at least one delta has been streamed or if the done payload equals the concatenation of deltas, but this adds buffering/complexity and was not necessary for this fix.

commits:
  [{"SHA":"b1abfd71c27f48574a4c888719f7930fe19b9ccf","Message":"fix: prevent duplicate text output in OpenAI streaming responses\n\n## CHANGES\n\n- Skip processing of ResponseOutputTextDone events\n- Prevent doubled text in stream output\n- Add clarifying comment about API behavior\n- Maintain delta chunk streaming functionality\n- Fix duplicate content issue in responses","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-10T12:24:30Z","Parents":["f5b72792256e68c41dd2650ac2a9e2ea907149e2"]},{"SHA":"3a3f5c50a80d19be523f9079eca566e1a164c5f0","Message":"chore: incoming 1686 changelog entry","Author":"Changelog Bot","Email":"kayvan@sylvan.com","Date":"2025-08-10T12:27:29Z","Parents":["b1abfd71c27f48574a4c888719f7930fe19b9ccf"]}]


title: Add Web Search Tool Support for Gemini Models
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1687
merged_at: 2025-08-11 03:13:58+00:00
merge_commit: 6000e7469eb3730a50283ba6e7cdd0957f879232
created_at: 2025-08-11 03:16:28
body:
  # Add Web Search Tool Support for Gemini Models

  ## Summary

  Add first-class web search tool support for Gemini models behind the existing --search flag, with optional location controls, and append standardized citations to Gemini responses. Update CLI help text, README, and shell completions to reflect Gemini support.

  ## Related Issues

  Closes #1656

  ## Demo of Change

  Before change:

  ```text
  fabric --search -m gemini-2.5-flash 'What are the top three news items for today?'
  I am sorry, but I do not have access to real-time news feeds or current events. My knowledge base was last updated at a specific point in time, and I cannot provide information on "today's" top three news items.

  To find out the top news items for today, I recommend checking reputable news sources such as:

  *   **Major News Websites:** BBC News, Reuters, Associated Press, The New York Times, The Wall Street Journal, The Guardian, CNN, Fox News, etc.
  *   **News Aggregators:** Google News, Apple News, Flipboard.
  *   **Local News Outlets:** For news specific to your region.
  ```

  After change:

  ```text
  fabric --search -m gemini-2.5-flash 'What are the top three news items for today?'
  Here are the top three news items for August 11, 2025:

  *   **INDIA Bloc's Protest March to Election Commission:** The INDIA bloc, led by Rahul Gandhi, is scheduled to march to the Election Commission of India (ECI) headquarters to protest against alleged electoral malpractices and "vote chori" (vote theft) in Bihar. Congress president Mallikarjun Kharge is set to host a dinner meeting with MPs to strategize on this issue.
  *   **Israel's Plans for Gaza and International Reactions:** Israeli Prime Minister Benjamin Netanyahu has defended his plan to take control of Gaza City and target remaining Hamas strongholds, stating it is "the best way to end the war." The United States has supported Israel's right to decide its security, while other UN Security Council members and officials have expressed alarm over the humanitarian crisis, with China calling the "collective punishment" of people in Gaza unacceptable.
  *   **Europe Advocates for Ukraine's Inclusion in Trump-Putin Talks:** European leaders are pushing for Ukraine to be part of negotiations between the United States and Russia, ahead of anticipated talks between presidents Vladimir Putin and Donald Trump.

  ## Sources

  - [indiatimes.com](https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUZIYQERkrlC-VmVMPstFBPEimkuA0KPydcS868jLIjOGgk3Ph3D6SVSoo7MzItKUPBDl1zieJFLNGEQTLFHAgrVu-XFy3Q-8o1uPt36RIw7aRJDU5qgy3NAk-IHn-kSJAim7kj9nQkJKJU9aemY5igLXxWHBfRPYXOzfarZ60PVwZD-feUsLezPkUgGjzvlQZJY6aejJltrxZ9ogw==)
  - [thehindu.com](https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUZIYQFWFC-DJZlK1QvOrD9XgCvUzgtUWOV-LqD61JGZreiJP5OcUCXYq8bcDGeeAEL3bfsoTb9XipDQ8fKPA-CVTZu-eHgkUVXlNQbIpNsQsvc2rR7n_n-8VoFl9yDB-TyfHi7tBHlPu7yg1qyeoss9s1g0bhNv7LsoNjdKeqPgdwKB-VFt2Ivu2a9KsIc=)
  - [youtube.com](https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUZIYQEnYKg5VKnewAh6pou9YvY--w1k6-ChD652Z915CWmnbSS1mtUGfbKSw0XTWHgyIS_-Te8KX2gjBudTpWoHpE5C_yHKtgLnbCsM7G9lqLiHgAFFrD0zcTk0Atrx66z0Wo4IG-monFU=)
  - [leverageedu.com](https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUZIYQGW5tuMkLCc3PFRNrMsHsjLyL_q94AjOV_vP1E9fk1nhdxa17J_ogqSPVLvIYQmt922KQERhvqL3RBZ7iuqCexe5GeY2C3mYy90eSaGG4ZB38t_QyY_sBrYsxXTOZ94l0DtfAbkJTzgXW1IywTAd_REv-4jw7S0kYKlgRdfzsXxl53up7e27bhC4UiDgxVjfLK_SAnMs6qwD6alVg==)
  - [hindustantimes.com](https://vertexaisearch.cloud.google.com/grounding-api-redirect/AUZIYQEJas8rf8KiIzJvxr4BYnjiwE7OB2wjBQD0uaCvWPMigp6j46dfHoUv7_AVYh8HPKyraIJqb36tOsqrhYLEqfidC777c67BNMUT0-VFGAP8dlQTPE7lt01rgyzN4XlVd6f0V3LYBHzlU9HkqMM2xIjOZBf0ydxVnF7arAgh0Myi8kI-a2PbS1_MuTIq0Q_g_nXnpk4VkD0Ap6kDcvtnMwheaejd6_gg8znj3IeSf3-EqTSobC4fDqbqCIpDKOQMBhZnylT7qIGveK6dimPdms949i6l8JF7)
  ```

  ## Files Changed

  - README.md
    - Updated the --search flag description to include Gemini.
  - completions/_fabric (zsh)
    - Updated the --search completion description to include Gemini.
  - completions/fabric.fish (fish)
    - Updated the --search completion description to include Gemini.
  - internal/cli/flags.go
    - Updated the --search flag description string to include Gemini.
  - internal/plugins/ai/gemini/gemini.go
    - Inject Google Search tool for Gemini when --search is enabled, validate and normalize search-location, and append deduplicated web citations to responses.
    - Small refactors and constants to improve readability and reusability.
  - internal/plugins/ai/gemini/gemini_test.go
    - Added unit tests for search tooling, location validation/normalization, and citation formatting.

  ## Code Changes

  - Enable Google Search tool for Gemini models:

  ```go
  func (o *Client) buildGenerateContentConfig(opts *domain.ChatOptions) (*genai.GenerateContentConfig, error) {
    temperature := float32(opts.Temperature)
    topP := float32(opts.TopP)
    cfg := &genai.GenerateContentConfig{
      Temperature:     &temperature,
      TopP:            &topP,
      MaxOutputTokens: int32(opts.ModelContextLength),
    }

    if opts.Search {
      cfg.Tools = []*genai.Tool{{GoogleSearch: &genai.GoogleSearch{}}}
      if loc := opts.SearchLocation; loc != "" {
        if isValidLocationFormat(loc) {
          loc = normalizeLocation(loc) // e.g., en_US -> en-US
          cfg.ToolConfig = &genai.ToolConfig{
            RetrievalConfig: &genai.RetrievalConfig{LanguageCode: loc},
          }
        } else {
          return nil, fmt.Errorf(errInvalidLocationFormat, loc)
        }
      }
    }
    return cfg, nil
  }
  ```

  - Validate and normalize location input:
    - Accept either timezone-like strings "Continent/City" or language codes "ll" or "ll-CC".
    - Normalize underscores to hyphens for language codes:
  ```go
  func isValidLocationFormat(location string) bool { ... }
  func normalizeLocation(location string) string { ... }
  func isValidLanguageCode(code string) bool { ... }
  ```

  - Append citations to Gemini responses when present, with deduplication and stable formatting:

  ```go
  const (
    citationHeader = "\n\n## Sources\n\n"
    citationFormat = "- [%s](%s)"
  )

  func (o *Client) extractTextFromResponse(response *genai.GenerateContentResponse) string {
    if response == nil { return "" }
    text := o.extractTextParts(response)
    citations := o.extractCitations(response)
    if len(citations) > 0 {
      return text + citationHeader + strings.Join(citations, "\n")
    }
    return text
  }
  ```

  - Minor refactors:
    - Centralized "models/" prefix constant:
      ```go
      const modelPrefix = "models/"
      ...
      func (o *Client) buildModelNameFull(modelName string) string { ... }
      ```
    - TTS detection uses constants for model type tokens.

  - CLI/documentation updates:
    - README, zsh, fish completions, and flag descriptions now include “Gemini” for --search.

  ## Reason for Changes

  - Feature parity: Extend the web search capability previously available for Anthropic and OpenAI to Gemini.
  - Better results and transparency: Enable grounding via Google Search and provide inline citations to improve verifiability of model outputs.
  - UX consistency: Reflect Gemini support across help, README, and shell completions.

  ## Impact of Changes

  - New behavior for Gemini when --search is provided:
    - The Google Search tool is enabled, potentially improving factuality.
    - If --search-location is provided, it is validated and normalized (e.g., en_US → en-US). Invalid values now produce an error.
  - Output format change for Gemini responses:
    - When citations are available, the text will include a “## Sources” section with a bulleted list of unique sources, e.g.:
      - [- [Title](https://example.com)]
    - This can affect downstream consumers expecting only raw model text. Consumers should strip or handle the Sources section if necessary.
  - Performance/latency:
    - Searches can add latency and token usage; users can disable with --search=false (default behavior unchanged).

  ## Test Plan

  - Unit tests (internal/plugins/ai/gemini/gemini_test.go):
    - buildGenerateContentConfig: with/without search, valid/invalid search-location, and normalization (en_US → en-US).
    - extractTextFromResponse: nil response, empty grounding chunks, and citation formatting with deduplication.
  - Manual tests:
    - Run with Gemini models:
      - fabric --vendor Gemini --search "What’s the latest on X?"
      - fabric --vendor Gemini --search --search-location en-US "topic"
      - fabric --vendor Gemini --search --search-location America/Los_Angeles "local news"
    - Verify Sources section presence when web grounding occurs.
    - Validate errors for invalid --search-location (e.g., "invalid").
    - Streamed mode: confirm streaming works and errors surface early for invalid location.

  ## Additional Notes

  - Location semantics: The search-location supports either timezone (“Continent/City”) or language code (“ll”/“ll-CC”). Internally this is applied to RetrievalConfig.LanguageCode. Depending on upstream API behavior, timezone strings may be treated similarly to locale; if the API changes, we may need to map timezones to locales explicitly.
  - Language code validation is intentionally strict (ll or ll-CC). Locales with script codes (e.g., zh-Hans-CN) are not currently supported and will be rejected.
  - Citation deduplication uses the (URI|Title) pair as the uniqueness key. Items missing either title or URI are ignored.

commits:
  [{"SHA":"558e7f877d791e365ae16f2fd1865d490aeb8a77","Message":"feat(gemini): enable web search, citations, and search-location validation\n\nCHANGES\n- Enable Gemini models to use web search tool\n- Validate search-location timezone or language code formats\n- Normalize language codes from underscores to hyphenated form\n- Inject Google Search tool when --search flag enabled\n- Append deduplicated web citations under standardized Sources section\n- Improve robustness for nil candidates and content parts\n- Factor generation config builder for reuse in streaming\n- Update CLI help and completions to include Gemini","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-11T02:56:02Z","Parents":["f33d27f836b663cbf433d541cadf263b532ba46d"]},{"SHA":"88d3fe65f355584ad5b09c1d9890d8c12e7b4021","Message":"chore: incoming 1687 changelog entry","Author":"Changelog Bot","Email":"bot@changelog.local","Date":"2025-08-11T03:07:03Z","Parents":["558e7f877d791e365ae16f2fd1865d490aeb8a77"]}]


title: Enhanced Shell Completions for Fabric CLI Binaries
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1689
merged_at: 2025-08-11 18:24:27+00:00
merge_commit: 298a9007ad530edac01d4ff3ae022faa525beec1
created_at: 2025-08-11 18:26:43
body:
  # Enhanced Shell Completions for Fabric CLI Binaries

  ## Summary

  Improve and generalize shell completion support for the fabric CLI across Zsh, Bash, and Fish by:
  - Supporting both binary names: `fabric` and `fabric-ai`
  - Removing hardcoded binary references inside completion functions
  - Adding an automated setup script to install completions into standard locations with sudo fallback and dry-run support
  - Adding documentation with manual and automated install instructions, symlink guidance, and troubleshooting tips

  This makes completions more robust, easier to install, and consistent regardless of how the binary is named.

  ## Files Changed

  - completions/_fabric
    - Zsh completion now supports both `fabric` and `fabric-ai`, and dynamically calls the actual invoked binary for data-driven suggestions.

  - completions/fabric.bash
    - Bash completion now derives the invoked binary from `COMP_WORDS[0]` and registers completions for both `fabric` and `fabric-ai`.

  - completions/fabric.fish
    - Fish completion now uses the first token of the command line to call the correct binary and registers completions for both command names via a reusable function.

  - completions/setup-completions.sh (added)
    - New installer for completion files that detects the installed command (`fabric` or `fabric-ai`), detects the user’s shell, and copies the appropriate files into standard completion directories with sudo fallback. Supports a `--dry-run` mode.

  - docs/Shell-Completions.md (added)
    - Documentation covering automated and manual installation, symlink guidance for dual command names, features, and troubleshooting.

  ## Code Changes

  - Zsh (completions/_fabric)
    - Enable both binaries for completion:
      ```zsh
      #compdef fabric fabric-ai
      ```
    - Dynamically call the invoked command instead of hardcoding:
      ```zsh
      local cmd=${words[1]}
      patterns=(${(f)"$($cmd --listpatterns --shell-complete-list 2>/dev/null)"})
      ```
    - The same pattern is applied to models, contexts, sessions, strategies, extensions, and Gemini voices:
      ```zsh
      local cmd=${words[1]}
      models=(${(f)"$($cmd --listmodels --shell-complete-list 2>/dev/null)"})
      ```

  - Bash (completions/fabric.bash)
    - Use the actual command being completed:
      ```bash
      _fabric_get_list() {
        "${COMP_WORDS[0]}" "$1" --shell-complete-list 2>/dev/null
      }
      ```
    - Register the completer for both names:
      ```bash
      complete -F _fabric fabric fabric-ai
      ```

  - Fish (completions/fabric.fish)
    - Use the invoked command for dynamic lists:
      ```fish
      set cmd (commandline -opc)[1]
      $cmd --listpatterns --shell-complete-list 2>/dev/null
      ```
    - Factor a registration function and apply to both commands:
      ```fish
      function __fabric_register_completions
        set cmd $argv[1]
        complete -c $cmd -f
        # ... all flag and arg completions for $cmd ...
      end

      __fabric_register_completions fabric
      __fabric_register_completions fabric-ai
      ```

  - New setup script (completions/setup-completions.sh)
    - Key features:
      - Detect installed command name:
        ```sh
        if command -v fabric >/dev/null 2>&1; then
          echo "fabric"
        elif command -v fabric-ai >/dev/null 2>&1; then
          echo "fabric-ai"
        fi
        ```
      - Detect shell from $SHELL and select appropriate install routine.
      - For Zsh, attempt to use fpath from the user’s zsh environment and fall back to standard paths. Install under `_${fabric_cmd}`.
      - For Bash, install into common bash-completion directories.
      - For Fish, install into `~/.config/fish/completions`.
      - Sudo fallback for directory creation and copying.
      - `--dry-run` mode to print intended actions without executing.

  - New docs (docs/Shell-Completions.md)
    - Covers:
      - Automated install with the setup script and dry-run example
      - Manual install for each shell
      - Symlink guidance when the binary is installed as `fabric-ai`
      - Feature overview and troubleshooting

  ## Reason for Changes

  - Users may install or package the CLI as `fabric` or `fabric-ai`. Hardcoding `fabric` inside completions broke dynamic suggestions when the binary was renamed or symlinked.
  - Provide a frictionless, cross-shell setup experience with a single installer script that handles detection, installation locations, and permissions.
  - Add clear documentation to streamline onboarding and reduce support overhead.

  ## Impact of Changes

  - Backwards compatible: existing `fabric` users retain working completions.
  - Adds first-class support for `fabric-ai` by:
    - Dynamically using the actual invoked command within completion helpers
    - Registering completions for both command names (Bash/Fish)
    - Providing a Zsh installation path that ensures the correct autoload filename (`_${fabric_cmd}`)
  - Improves UX by enabling up-to-date, model/pattern/context-aware completions regardless of binary naming.

  ## Test Plan

  - Zsh:
    - Copy completion file to zsh site-functions and name according to the installed command (e.g., `_fabric-ai` if using `fabric-ai`).
    - Restart zsh or run `autoload -U compinit && compinit`.
    - Verify tab-completion for flags and dynamic lists:
      - `fabric-ai -p <TAB>` shows patterns
      - `fabric-ai -m <TAB>` shows models
      - `fabric-ai --listpatterns<TAB>` completes flags
  - Bash:
    - Install the completion file into `/etc/bash_completion.d/` or user’s `~/.local/share/bash-completion/completions`.
    - Verify both `fabric` and `fabric-ai` complete flags and dynamic items.
  - Fish:
    - Install to `~/.config/fish/completions/` and verify both `fabric` and `fabric-ai` complete flags and dynamic items without restarting Fish.
  - Setup script:
    - Run `./completions/setup-completions.sh --dry-run` to validate detection and planned actions.
    - Run without `--dry-run` to install and re-test completions for your shell and command name.
  - Smoke test dynamic lists:
    - Ensure that changing available patterns/models reflects immediately in tab-completion output (since the helpers now call the invoked binary).

  ## Additional Notes

  - Zsh autoloading relies on the filename `_COMMAND`. If you use `fabric-ai`, ensure a file named `_fabric-ai` exists in your `$fpath`. The setup script installs the file under the detected command name; if you need both `fabric` and `fabric-ai`, create a symlink so both `_fabric` and `_fabric-ai` resolve:
    ```bash
    ln -s /path/to/_fabric /path/to/_fabric-ai
    ```
  - Bash user-specific completions typically require the file to be named after the command (without .bash) under `~/.local/share/bash-completion/completions/`. The documentation shows the correct manual copy and symlink steps. If you use the setup script and find completions not loading in user mode, verify the filename in that directory matches the command name (e.g., `fabric` or `fabric-ai`).
  - On macOS, `readlink -f` may not be available; the script falls back to `realpath` or `$0`.
  - Zsh `$fpath` detection uses the first few entries for installation. The script also falls back to well-known site-functions directories if `$fpath` could not be retrieved or is empty.
  - If both `fabric` and `fabric-ai` exist on the same system and you want completions for both in Zsh, ensure both `_fabric` and `_fabric-ai` files are present (one can be a symlink). Bash and Fish register for both by default.

commits:
  [{"SHA":"b36e5d3372b1ad4de193841e747aced3636a1e11","Message":"feat: enhance completions with 'fabric-ai' alias, dynamic exec, installer\n\nCHANGES\n- Support 'fabric-ai' alias across Zsh, Bash, and Fish\n- Use invoked command for dynamic completion list queries\n- Refactor Fish completions into reusable registrar for multiple commands\n- Update Bash completion to reference executable via COMP_WORDS[0]\n- Extend Zsh compdef to register fabric and fabric-ai\n- Add cross-shell installer script with autodetection and dry-run mode\n- Document installation, features, troubleshooting in new completions guide","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-11T17:45:27Z","Parents":["d1b8eb10ce9247eb27a4a36b99281708c3233a24"]}]


title: Add Vendor Selection Support for Models
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1692
merged_at: 2025-08-12 14:12:41+00:00
merge_commit: 4c2ebf25fa3fddad511fd74b1c54787ac3d64d33
created_at: 2025-08-12 14:15:10
body:
  # Add Vendor Selection Support for Models

  ## Summary

  This PR introduces vendor selection functionality for AI models, allowing users to explicitly specify which vendor to use when multiple vendors provide the same model. This addresses ambiguity issues when models are available from multiple sources and provides better control over model selection.

  ## Related Issues

  Closes #1691 

  ## Files Changed

  ### Core Changes
  - **internal/cli/flags.go**: Added new `-V/--vendor` flag to specify vendor for chosen model
  - **internal/core/plugin_registry.go**: Enhanced `GetChatter()` to handle vendor selection with validation and warning messages
  - **internal/plugins/ai/models.go**: Added `PrintWithVendor()` method to display models with their vendor information

  ### Shell Completion Updates
  - **completions/_fabric**: Added Zsh completion support for vendor flag
  - **completions/fabric.bash**: Added Bash completion support for vendor flag  
  - **completions/fabric.fish**: Added Fish completion support for vendor flag

  ### Documentation Updates
  - **README.md**: Documented new vendor flag in application options
  - **data/patterns/show_fabric_options_markmap/system.md**: Updated pattern documentation with vendor flag
  - **docs/YouTube-Processing.md**: Fixed yt-dlp argument syntax in examples (quotes around arguments)

  ### Web Interface
  - **internal/server/chat.go**: Updated chat handler to support vendor selection
  - **web/README.md**: Fixed image path reference
  - **docs/images/svelte-preview.png**: Added new preview image for web interface
  - **web/src/routes/about/README.md**: Minor formatting and typo fixes

  ### Dependencies
  - **go.mod**: Added `github.com/kballard/go-shellquote` dependency

  ### Tests
  - **internal/core/plugin_registry_test.go**: Added comprehensive test for vendor selection and ambiguous model warnings

  ## Code Changes

  ### Vendor Selection Logic
  The main enhancement in `GetChatter()` now handles three scenarios:

  1. **Explicit vendor specified**: Validates that the vendor exists and provides the requested model
  ```go
  if vendorName != "" {
      ret.vendor = vendorManager.FindByName(vendorName)
      availableVendors := models.FindGroupsByItem(model)
      if ret.vendor == nil || !lo.Contains(availableVendors, vendorName) {
          err = fmt.Errorf("model %s not available for vendor %s", model, vendorName)
          return
      }
  }
  ```

  2. **No vendor specified with ambiguous model**: Warns user about multiple vendors and uses first available
  ```go
  availableVendors := models.FindGroupsByItem(model)
  if len(availableVendors) > 1 {
      fmt.Fprintf(os.Stderr, "Warning: multiple vendors provide model %s: %s. Using %s. Specify --vendor to select a vendor.\n", 
          model, strings.Join(availableVendors, ", "), availableVendors[0])
  }
  ```

  3. **Default behavior**: Uses configured defaults when no model or vendor specified

  ### Enhanced Model Display
  New `PrintWithVendor()` method shows vendor information alongside models:
  ```
  [1] VendorA|model-1
  [2] VendorB|model-2
  [3] VendorB|shared-model
  [4] VendorC|shared-model
  ```

  ## Reason for Changes

  This change addresses a critical usability issue where users couldn't control which vendor to use when multiple vendors provide the same model name. This is particularly important for:
  - Users with local LLM servers (like LM Studio) that may expose models with common names
  - Environments where multiple API providers offer similar models
  - Testing and debugging scenarios where vendor-specific behavior needs to be isolated

  ## Impact of Changes

  ### Positive Impact
  - **Better Control**: Users can explicitly choose vendors for ambiguous models
  - **Improved Clarity**: Warning messages inform users when models are available from multiple sources
  - **Backward Compatibility**: Existing behavior preserved when vendor flag not used

  ### Potential Considerations
  - Users may see new warning messages for ambiguous models (informational only)
  - Shell completion scripts will need to be regenerated for users who built custom completions

  ## Test Plan

  ### Manual Testing
  1. Test vendor selection with valid vendor/model combination
  2. Test vendor selection with invalid vendor for given model
  3. Test ambiguous model warning when no vendor specified
  4. Test shell completions for vendor flag
  5. Verify backward compatibility with existing commands

  ### Automated Testing
  Added comprehensive test coverage in `plugin_registry_test.go`:
  - Tests warning message generation for ambiguous models
  - Validates correct vendor selection
  - Ensures proper error handling for invalid vendor/model combinations

  ## Additional Notes

  ### Documentation Fixes
  This PR also includes important fixes to the YouTube processing documentation where yt-dlp arguments were incorrectly formatted. The correct syntax now includes the needed `=`:
  ```bash
  # Correct
  --yt-dlp-args="--cookies-from-browser brave"

  # Previously incorrect
  --yt-dlp-args "--cookies-from-browser brave"
  ```

commits:
  [{"SHA":"cc3e4226d7233898b2b23a9df648683ef046feb4","Message":"feat: add -V/--vendor flag and vendor-aware model selection\n\nCHANGES\n- Add -V/--vendor flag to specify model vendor\n- Implement vendor-aware model resolution and availability validation\n- Warn on ambiguous models; suggest --vendor to disambiguate\n- Update bash, zsh, fish completions with vendor suggestions\n- Extend --listmodels to print vendor|model when interactive\n- Add VendorsModels.PrintWithVendor; sort vendors and models alphabetically\n- Pass vendor through API; update server chat handler\n- Standardize docs and errors to --yt-dlp-args=\"...\" syntax\n- Add test covering ambiguous model warning across multiple vendors\n- Promote go-shellquote to direct dependency in go.mod","Author":"Kayvan Sylvan","Email":"kayvan@sylvan.com","Date":"2025-08-12T13:39:02Z","Parents":["0f994d8136bfc45b5d4fd2ebc6b4a7186af2f8d4"]},{"SHA":"b1b748dc9c4f31f946460e11f3101b9abe909367","Message":"chore: incoming 1692 changelog entry","Author":"Changelog Bot","Email":"kayvan@sylvan.com","Date":"2025-08-12T14:06:45Z","Parents":["cc3e4226d7233898b2b23a9df648683ef046feb4"]}]


title: Introduce One-Liner Curl Install for Completions
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1695
merged_at: 2025-08-12 18:48:58+00:00
created_at: 2025-09-11 18:18:34
body:
  # Introduce One-Liner Curl Install for Completions

  ## Summary

  Add “no-clone” install support for shell completions by teaching the setup script to fetch completion files from GitHub when they are not present locally. Update README and docs with a one-liner install, dry-run support, and an environment variable to override the download source.

  ## Files Changed

  - README.md
    - Added a “Quick install (no clone required)” section under Shell Completions with:
      - A one-liner install command (curl | sh).
      - Optional dry-run and override source examples.

  - completions/setup-completions.sh
    - Enhancements:
      - Auto-download completion files (_fabric, fabric.bash, fabric.fish) if not found locally.
      - Support for overriding download base via FABRIC_COMPLETIONS_BASE_URL.
      - Added curl/wget fallback downloader and GitHub URL “blob/tree” → “raw” conversion.
      - Temporary directory handling and cleanup via trap.
      - Updated help text and examples.
      - Minor API change: setup_other_shell_completions now accepts script_dir.

  - docs/Shell-Completions.md
    - Rewrote “Quick Setup (Automated)” to document:
      - No-clone install path.
      - Dry-run and override source examples.
      - Clarification that the script will download files if they aren’t present locally.
    - Retained instructions for running from a cloned repo.

  ## Code Changes

  - New configurable download base (defaults to the repo’s main branch):
  ```sh
  ## Base URL to fetch completion files when not available locally
  ## Can be overridden via environment variable FABRIC_COMPLETIONS_BASE_URL
  FABRIC_COMPLETIONS_BASE_URL="${FABRIC_COMPLETIONS_BASE_URL:-https://raw.githubusercontent.com/danielmiessler/Fabric/refs/heads/main/completions}"
  ```

  - GitHub URL normalization for user-supplied override sources:
  ```sh
  to_github_raw_url() {
      in_url="$1"
      case "$in_url" in
          https://github.com/*/*/blob/*)
              echo "$in_url" | sed -E 's#https://github.com/([^/]+)/([^/]+)/blob/([^/]+)/#https://raw.githubusercontent.com/\1/\2/\3/#'
              ;;
          https://github.com/*/*/tree/*)
              echo "$in_url" | sed -E 's#https://github.com/([^/]+)/([^/]+)/tree/([^/]+)/#https://raw.githubusercontent.com/\1/\2/\3/#'
              ;;
          *)
              echo "$in_url"
              ;;
      esac
  }
  ```

  - Robust downloader with curl → wget fallback and error messaging:
  ```sh
  download_file() {
      url="$1"; dest="$2"
      [ "$DRY_RUN" = true ] && { print_dry_run "Would download: $url -> $dest"; return 0; }

      eff_url="$(to_github_raw_url "$url")"
      if command -v curl >/dev/null 2>&1; then
          curl -fsSL "$eff_url" -o "$dest"
      elif command -v wget >/dev/null 2>&1; then
          wget -q "$eff_url" -O "$dest"
      else
          print_error "Neither 'curl' nor 'wget' is available to download: $url"
          return 1
      fi
  }
  ```

  - Auto-acquire completion files into a temporary directory when missing locally, with basic content validation and cleanup:
  ```sh
  obtain_completion_files() {
      obf_script_dir="$1"
      # If local copies are present, use them
      if [ -f "$obf_script_dir/_fabric" ] && [ -f "$obf_script_dir/fabric.bash" ] && [ -f "$obf_script_dir/fabric.fish" ]; then
          echo "$obf_script_dir"; return 0
      fi

      printf "%s\n" "[INFO] Local completion files not found; will download from GitHub." 1>&2
      printf "%s\n" "[INFO] Source: $FABRIC_COMPLETIONS_BASE_URL" 1>&2

      [ "$DRY_RUN" = true ] && { printf "%s\n" "[DRY-RUN] Would create temporary directory for downloads" 1>&2; echo "$obf_script_dir"; return 0; }

      TEMP_DIR="$(mktemp -d 2>/dev/null || mktemp -d -t fabric-completions)" || { print_error "Failed to create temporary directory for downloads."; return 1; }

      download_file "$FABRIC_COMPLETIONS_BASE_URL/_fabric" "$TEMP_DIR/_fabric"     || { print_error "Failed to download _fabric"; return 1; }
      download_file "$FABRIC_COMPLETIONS_BASE_URL/fabric.bash" "$TEMP_DIR/fabric.bash" || { print_error "Failed to download fabric.bash"; return 1; }
      download_file "$FABRIC_COMPLETIONS_BASE_URL/fabric.fish" "$TEMP_DIR/fabric.fish" || { print_error "Failed to download fabric.fish"; return 1; }

      # Reject obvious HTML/empty responses
      for f in _fabric fabric.bash fabric.fish; do
          if [ ! -s "$TEMP_DIR/$f" ] || head -n1 "$TEMP_DIR/$f" | grep -qi "^<!DOCTYPE\|^<html"; then
              print_error "Downloaded $f appears invalid (empty or HTML). Check FABRIC_COMPLETIONS_BASE_URL."
              return 1
          fi
      done

      echo "$TEMP_DIR"
  }
  ```

  - Integrate auto-acquisition and cleanup into main flow; pass script_dir to “other shell” handler:
  ```sh
  script_dir="$(get_script_dir)"
  script_dir="$(obtain_completion_files "$script_dir" || echo "")"
  [ -z "$script_dir" ] && { print_error "Unable to obtain completion files. Aborting."; exit 1; }

  if [ -n "$TEMP_DIR" ] && [ -d "$TEMP_DIR" ]; then
      trap 'if [ -n "$TEMP_DIR" ] && [ -d "$TEMP_DIR" ]; then rm -rf "$TEMP_DIR"; fi' EXIT INT TERM
  fi

  ## ...
  setup_other_shell_completions "$fabric_cmd" "$shell_name" "$script_dir"
  ```

  - Updated usage/help text and examples to reflect new behavior, including override of FABRIC_COMPLETIONS_BASE_URL.

  ## Reason for Changes

  - Improve onboarding and reduce friction: enable users to install completions without cloning the repository.
  - Provide a safer, more robust installation path:
    - Dry-run mode to preview actions.
    - Explicit download source overrides for advanced users or mirrors.
    - Curl/wget fallback to work across environments.
    - Sanity checks and cleanup to avoid littering tmp directories and to detect invalid downloads.

  ## Impact of Changes

  - User experience: A single command installs completions for Zsh/Bash/Fish; documentation is clearer.
  - Backwards compatibility: Existing workflows that run the script from a cloned repo continue to work unchanged.
  - Operational robustness:
    - Works when completion files aren’t next to the script (e.g., curl | sh).
    - Cleaner behavior due to validation and trap-based tmp cleanup.
  - Minimal maintenance overhead: Default base URL points at main; advanced users can override to pin to tags/commits or private mirrors.

  ## Test Plan

  Manual verification across shells and platforms:

  - Dry-run:
    - curl … | sh -s -- --dry-run on macOS and Linux with zsh/bash/fish to confirm no changes are made and all intended actions are listed.
  - No-clone install:
    - zsh: curl … | sh → confirm _fabric installed to a searchable completion dir and zcompinit instructions are shown or appended where appropriate.
    - bash: confirm fabric.bash is installed and either auto-sourced or instructions are shown.
    - fish: confirm fabric.fish installed under ~/.config/fish/completions.
  - Override source:
    - Set FABRIC_COMPLETIONS_BASE_URL to:
      - The default raw URL (control).
      - A specific tag/commit raw URL.
      - A GitHub “blob” and “tree” URL to exercise to_github_raw_url conversions.
  - Tool availability:
    - Disable curl to force wget path; verify downloads succeed.
    - Disable both curl and wget to verify user-friendly error.
  - Validation:
    - Temporarily set FABRIC_COMPLETIONS_BASE_URL to an invalid URL; confirm error about invalid/HTML content.
  - Cleanup:
    - Confirm temporary directories are removed after successful and failed runs.
  - “Other shell” path:
    - Force unsupported shell_name and verify instructions include correct paths using provided script_dir.

  ## Additional Notes

  - Interpreter compatibility: The docs demonstrate piping to sh. If the script contains bash-specific constructs in parts not modified here, running via sh may fail because piping bypasses the script’s shebang. If we rely on bash features, we should change the docs’ one-liner to use bash explicitly:
    - Example: curl -fsSL …/setup-completions.sh | bash
    Please confirm the script is POSIX-sh clean end-to-end or update the docs accordingly.

  - Security: As with any curl | shell pattern, users should review the script or use the dry-run first.

  - Potential edge cases:
    - Sudo prompts in non-interactive contexts may fail; dry-run and manual instructions help mitigate.
    - If a user overrides FABRIC_COMPLETIONS_BASE_URL to a directory listing or non-raw endpoint, downloads will fail or be flagged as invalid—this is by design.

  - Future improvement:
    - Option to pin FABRIC_COMPLETIONS_BASE_URL to a release tag in the docs to ensure reproducibility.

commits:
  [{"SHA":"b6fa44d003b121dc9d3ff2b942106741f04b10fb","Message":"docs: add quick install method for shell completions without cloning repo\n\n## CHANGES\n\n- Add one-liner curl install for completions\n- Support downloading completions when files missing locally\n- Add dry-run option for preview changes\n- Enable custom download source via environment variable\n- Create temp directory for downloaded completion files\n- Add automatic cleanup of temporary files\n- Update documentation with new installation methods","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-12T17:00:11Z","Parents":null},{"SHA":"3a4082a1f318c6ae3db1b6ed01686ef87f2b1236","Message":"fix: convert GitHub blob/tree URLs to raw and validate completion downloads\n\nCHANGES\n- Add helper to translate GitHub blob/tree to raw URLs\n- Use effective URL in curl and wget download paths\n- Validate downloaded files are non-empty and not HTML\n- Redirect info and dry-run messages to standard error\n- Relocate temporary directory cleanup trap into main execution\n- Improve error messages when completion download sources appear invalid","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-12T17:49:55Z","Parents":null},{"SHA":"41821efd279d074e61b5785e89ad9ce9a586b5a1","Message":"refactor: standardize obtain_completion_files logging; use stderr-only printf\n\nCHANGES\n- Replace print_info with tagged printf directed to stderr.\n- Replace print_dry_run with tagged printf directed to stderr.\n- Add comment enforcing stderr-only output inside this function.\n- Preserve dry-run behavior by echoing path only on stdout.\n- Retain error handling using print_error for directory creation.\n- Normalize log message prefixes to [INFO] and [DRY-RUN].\n- Avoid stdout pollution by routing informational messages to stderr.","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-12T18:16:25Z","Parents":null},{"SHA":"aafca303ad167d96b1852cfb2c678cb14be70796","Message":"chore: incoming 1695 changelog entry","Author":"Changelog Bot","Email":"","Date":"2025-08-12T18:48:21Z","Parents":null}]


title: Enable One Million Token Context Beta Feature for Sonnet-4
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1698
merged_at: 2025-08-13 13:32:50+00:00
created_at: 2025-09-11 18:18:34
body:
  # Enable One Million Token Context Beta Feature for Sonnet-4

  ## Summary

  Enable Anthropic model beta features with safe fallback and OAuth header preservation. Specifically, default-enable the 1M-token context beta for Claude Sonnet 4 (2025-05-14) while ensuring requests gracefully fall back if the beta is unavailable. Update the Anthropic SDK and a few indirect dependencies. Add tests for the beta configuration.

  Read this blog post: https://www.anthropic.com/news/1m-context

  ## Related Issues

  Closes #1697 

  ## Files Changed

  - go.mod
    - Bump github.com/anthropics/anthropic-sdk-go to v1.9.1.
    - Bump golang.org/x/crypto to v0.40.0 (indirect).
  - go.sum
    - Update checksums for anthropic-sdk-go, x/crypto, and x/term (v0.33.0).
  - internal/plugins/ai/anthropic/anthropic.go
    - Add model-to-beta mapping and use RequestOptions to set the anthropic-beta header when applicable.
    - Implement fallback logic if beta usage fails for both streaming and non-streaming paths.
    - Minor import change to support stderr logging for beta failures.
  - internal/plugins/ai/anthropic/anthropic_test.go
    - Add a test validating the model beta configuration (Sonnet 4 => context-1m-2025-08-07).
  - internal/plugins/ai/anthropic/oauth.go
    - Preserve any existing anthropic-beta header and append the OAuth beta flag instead of overwriting.

  ## Code Changes

  - Add model beta mapping in the Anthropic client:

  ```go
  // NewClient()
  ret.modelBetas = map[string][]string{
      string(anthropic.ModelClaudeSonnet4_20250514): {"context-1m-2025-08-07"},
  }
  ```

  - Use RequestOptions to set beta header in streaming requests and fall back on error:

  ```go
  params := an.buildMessageParams(messages, opts)
  betas := an.modelBetas[opts.Model]
  var reqOpts []option.RequestOption
  if len(betas) > 0 {
      reqOpts = append(reqOpts, option.WithHeader("anthropic-beta", strings.Join(betas, ",")))
  }
  stream := an.client.Messages.NewStreaming(ctx, params, reqOpts...)
  if stream.Err() != nil && len(betas) > 0 {
      fmt.Fprintf(os.Stderr, "Anthropic beta feature %s failed: %v\n", strings.Join(betas, ","), stream.Err())
      stream = an.client.Messages.NewStreaming(ctx, params)
  }
  ```

  - Apply the same beta header and fallback for non-streaming requests:

  ```go
  params := an.buildMessageParams(messages, opts)
  betas := an.modelBetas[opts.Model]
  var reqOpts []option.RequestOption
  if len(betas) > 0 {
      reqOpts = append(reqOpts, option.WithHeader("anthropic-beta", strings.Join(betas, ",")))
  }
  if message, err = an.client.Messages.New(ctx, params, reqOpts...); err != nil {
      if len(betas) > 0 {
          fmt.Fprintf(os.Stderr, "Anthropic beta feature %s failed: %v\n", strings.Join(betas, ","), err)
          if message, err = an.client.Messages.New(ctx, params); err != nil {
              return
          }
      } else {
          return
      }
  }
  ```

  - Preserve existing anthropic-beta header in OAuth transport:

  ```go
  existing := newReq.Header.Get("anthropic-beta")
  beta := "oauth-2025-04-20"
  if existing != "" {
      beta = existing + "," + beta
  }
  newReq.Header.Set("anthropic-beta", beta)
  ```

  - New unit test to validate the model beta mapping:

  ```go
  func TestModelBetasConfiguration(t *testing.T) {
      client := NewClient()
      model := string(anthropic.ModelClaudeSonnet4_20250514)
      betas, ok := client.modelBetas[model]
      if !ok || len(betas) != 1 || betas[0] != "context-1m-2025-08-07" {
          t.Errorf("expected beta mapping for %s", model)
      }
  }
  ```

  ## Reason for Changes

  - Feature enablement: Turn on Anthropic’s 1M context beta for Claude Sonnet 4 by default to provide larger context windows where supported.
  - Robustness: Add explicit fallback to non-beta requests to avoid breaking functionality if the beta is unavailable or errors.
  - Compatibility: Update to anthropic-sdk-go v1.9.1 to ensure proper support for request options and the latest model constants.
  - Security/maintenance: Bump golang.org/x/crypto and golang.org/x/term to latest versions pulled by dependency updates.
  - OAuth correctness: Ensure the OAuth transport does not clobber any already-defined anthropic-beta header (e.g., from model betas).

  ## Impact of Changes

  - Functionality:
    - For Claude Sonnet 4 (2025-05-14), requests will attempt to use the 1M context beta, potentially improving usability for large inputs.
    - If the beta is unavailable, requests will transparently fall back without failing the operation.
  - Headers:
    - anthropic-beta header may contain multiple comma-separated features; OAuth beta is appended rather than replacing.
  - Costs/Performance:
    - Using 1M context may increase token usage and costs for applicable requests. Only Sonnet 4 with the configured date string is affected.
  - Stability:
    - Fallback logic minimizes risk from beta instability.
    - Minor stderr logging has been added when beta usage fails; in high-volume environments this could add log noise.

  ## Test Plan

  - Unit tests:
    - Added TestModelBetasConfiguration to ensure the model beta mapping is present and correct.
    - Existing tests for message parameter building and citation formatting continue to pass.
  - Manual verification:
    - Exercise both streaming and non-streaming calls on Sonnet 4:
      - Confirm anthropic-beta header includes context-1m-2025-08-07 and oauth-2025-04-20 when using OAuth.
      - Simulate beta failure (e.g., via a test environment or by forcing an invalid beta) and verify fallback request succeeds without the beta and logs to stderr.
  - Dependency checks:
    - Build and run with anthropic-sdk-go v1.9.1.
    - Validate no breaking changes in SDK usage (Message params, RequestOptions).

  ## Additional Notes

  - If we add more model-specific betas, insert them into modelBetas with comma-joined values applied per-model via RequestOptions.
  - We are not deduplicating beta flags; if upstream sets the same beta elsewhere, it may appear twice in the header but should still be accepted by the API.
  - Consider adding an integration test for OAuth header merging if we have a suitable test harness to assert final outbound headers.

commits:
  [{"SHA":"17b7d96da1ea2b0aa43e1efd47eeabd1f87929c5","Message":"chore: upgrade anthropic-sdk-go to v1.9.1 and add beta feature support for context-1m\n\n## CHANGES\n\n- Upgrade anthropic-sdk-go from v1.7.0 to v1.9.1\n- Upgrade golang.org/x/crypto from v0.39.0 to v0.40.0\n- Add modelBetas map for beta feature configuration\n- Implement context-1m-2025-08-07 beta for Claude Sonnet 4\n- Add beta header support in streaming requests\n- Add beta header support in standard requests\n- Implement fallback mechanism when beta features fail\n- Preserve existing beta headers in OAuth transport\n- Add test coverage for model beta configuration","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-13T05:30:27Z","Parents":null}]


title: Introduce Thinking Config Across Anthropic and OpenAI Providers
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1700
merged_at: 2025-08-14 14:15:40+00:00
created_at: 2025-09-11 18:18:34
body:
  # Introduce Thinking Config Across Anthropic and OpenAI Providers

  ## Summary

  Introduce a provider-agnostic thinking/reasoning control across Fabric with a new CLI flag: --thinking. This enables users to request different levels of reasoning from Anthropic and OpenAI models in a consistent way. The change includes:

  - New --thinking flag and shell completions.
  - Domain support for thinking levels and standardized token budgets.
  - Anthropic: map thinking levels (and numeric tokens) to ThinkingConfig.
  - OpenAI: map thinking levels to Reasoning Effort for both Chat Completions and Responses APIs.
  - Dry-run output shows selected thinking level.
  - Overhaul of suggest_pattern docs: categorized pattern index, workflows, and usage guidance.
  - Minor VSCode dictionary updates.
  - Add changelog entry.

  ## Related Issues

  Closes #1694 

  ## Files Changed

  - .vscode/settings.json
    - Added dictionary entries: Anki, DMARC, wireframes.

  - cmd/generate_changelog/incoming/1700.txt
    - New changelog entry summarizing this PR.

  - completions/_fabric (zsh)
    - Added --thinking completion with allowed values: off, low, medium, high.

  - completions/fabric.bash
    - Included --thinking in options and tab-completion choices.

  - completions/fabric.fish
    - Added --thinking with completion choices.

  - data/patterns/suggest_pattern/system.md
    - Rewrote and expanded the system prompt: clear identity/purpose, stepwise approach, categorized pattern catalog, workflow guidance, and output instructions.

  - data/patterns/suggest_pattern/user.md
    - Major restructure: patterns organized by category (AI, ANALYSIS, DEVELOPMENT, SECURITY, etc.), brief descriptions, and usage guidance.

  - data/patterns/suggest_pattern/user_clean.md
    - Deleted (unused duplicate).

  - data/patterns/suggest_pattern/user_updated.md
    - Deleted (replaced by consolidated user.md).

  - internal/cli/flags.go
    - Added Flags.Thinking domain.ThinkingLevel with help text.
    - Propagated Thinking to ChatOptions in BuildChatOptions.

  - internal/cli/flags_test.go
    - Updated expected ChatOptions with default Thinking value.

  - internal/domain/domain.go
    - Added Thinking field to ChatOptions.

  - internal/domain/thinking.go
    - New: ThinkingLevel type and constants (off, low, medium, high).
    - Standardized token budgets for Anthropic thinking-enabled models:
      - low: 1024, medium: 2048, high: 4096.

  - internal/plugins/ai/anthropic/anthropic.go
    - Added parseThinking() to translate CLI thinking level (or numeric tokens) into anthropic.ThinkingConfigParamUnion.
    - Inject Thinking config into message params when specified.

  - internal/plugins/ai/dryrun/dryrun.go
    - Show Thinking level in dry-run formatted options.

  - internal/plugins/ai/openai/chat_completions.go
    - Map Thinking level to ReasoningEffort for Chat Completions requests.

  - internal/plugins/ai/openai/openai.go
    - Added parseReasoningEffort() mapping low/medium/high to shared.ReasoningEffort.
    - Set ReasoningEffort for Chat Completions and Reasoning.Effort for Responses API when specified.

  - internal/server/chat.go
    - Thread Thinking from API request to ChatOptions.

  ## Code Changes

  - CLI flag definition:
    ```go
    // internal/cli/flags.go
    Thinking domain.ThinkingLevel `long:"thinking" yaml:"thinking" description:"Set reasoning/thinking level (e.g., off, low, medium, high, or numeric tokens for Anthropic)"`
    ```

  - Domain support:
    ```go
    // internal/domain/thinking.go
    type ThinkingLevel string

    const (
      ThinkingOff    ThinkingLevel = "off"
      ThinkingLow    ThinkingLevel = "low"
      ThinkingMedium ThinkingLevel = "medium"
      ThinkingHigh   ThinkingLevel = "high"
    )

    var ThinkingBudgets = map[ThinkingLevel]int64{
      ThinkingLow:    1024,
      ThinkingMedium: 2048,
      ThinkingHigh:   4096,
    }
    ```

  - Anthropic mapping:
    ```go
    // internal/plugins/ai/anthropic/anthropic.go
    func parseThinking(level domain.ThinkingLevel) (anthropic.ThinkingConfigParamUnion, bool) {
      lower := strings.ToLower(string(level))
      switch domain.ThinkingLevel(lower) {
      case domain.ThinkingOff:
        disabled := anthropic.NewThinkingConfigDisabledParam()
        return anthropic.ThinkingConfigParamUnion{OfDisabled: &disabled}, true
      case domain.ThinkingLow, domain.ThinkingMedium, domain.ThinkingHigh:
        if budget, ok := domain.ThinkingBudgets[domain.ThinkingLevel(lower)]; ok {
          return anthropic.ThinkingConfigParamOfEnabled(budget), true
        }
      default:
        if tokens, err := strconv.ParseInt(lower, 10, 64); err == nil {
          return anthropic.ThinkingConfigParamOfEnabled(tokens), true
        }
      }
      return anthropic.ThinkingConfigParamUnion{}, false
    }
    ```

  - OpenAI mapping:
    ```go
    // internal/plugins/ai/openai/openai.go
    func parseReasoningEffort(level domain.ThinkingLevel) (shared.ReasoningEffort, bool) {
      switch domain.ThinkingLevel(strings.ToLower(string(level))) {
      case domain.ThinkingLow:
        return shared.ReasoningEffortLow, true
      case domain.ThinkingMedium:
        return shared.ReasoningEffortMedium, true
      case domain.ThinkingHigh:
        return shared.ReasoningEffortHigh, true
      default:
        return "", false
      }
    }
    ```

  - Dry-run visibility:
    ```go
    // internal/plugins/ai/dryrun/dryrun.go
    if opts.Thinking != "" {
      builder.WriteString(fmt.Sprintf("Thinking: %s\n", string(opts.Thinking)))
    }
    ```

  ## Reason for Changes

  - Add a simple, consistent user-facing control for model reasoning/thinking across providers.
  - Standardize Anthropic thinking budgets to common levels and allow advanced users to specify a numeric token budget.
  - Surface OpenAI’s Reasoning Effort in a consistent way with the same flag.
  - Improve discoverability and usability via shell completions and dry-run visibility.
  - Make suggest_pattern documentation substantially more useful with categorized patterns, workflows, and practical examples.

  ## Impact of Changes

  - User experience: New --thinking flag offers a straightforward way to request more/less reasoning. Defaults remain unchanged; no behavior change unless the flag is used.
  - Anthropic: Sets ThinkingConfig when present. Levels map to sensible defaults; advanced numeric override supported.
  - OpenAI: Sets Reasoning Effort on supported models via both Chat Completions and Responses API paths. Ignored if model doesn’t support reasoning effort.
  - Dry-run: Users can verify reasoning level before sending a request.
  - Docs: Suggest pattern becomes an entry point for discovering patterns by category and planning multi-step workflows.

  ## Test Plan

  - Unit tests:
    - Updated flags_test.go to include default Thinking value; run go test ./... to ensure compilation and test pass.

  - Manual smoke tests:
    - Dry run shows thinking level:
      - fabric -p ai --thinking high --dry-run
      - Confirm “Thinking: high” in formatted options.
    - Anthropic reasoning:
      - fabric -V anthropic -m claude-3-7-sonnet-thought -p ai --thinking medium
      - fabric -V anthropic -m claude-3-7-sonnet-thought -p ai --thinking 8192
      - Verify successful responses; compare cost/latency vs. off/low.
    - OpenAI reasoning:
      - Responses API (default): fabric -V openai -m o4-mini -p ai --thinking high
      - Chat Completions API: fabric -V openai -m o4-mini -p ai --thinking low --disable-responses-api
      - Confirm responses are returned and no client errors for supported models.

  - Shell completions:
    - zsh/bash/fish: verify --thinking offers choices off/low/medium/high.

  - Docs:
    - Ensure suggest_pattern loads and renders; internal links or examples are coherent.

  ## Additional Notes

  - The --thinking completions offer off/low/medium/high; numeric token inputs (Anthropic-only advanced usage) are accepted by the flag even though not suggested by completion.
  - OpenAI Reasoning Effort is set only when a supported model is used. For unsupported models, the SDK should ignore the field; if not, we may need conditional gating by model name.
  - REST API:
    - Server now forwards request.Thinking to ChatOptions. Ensure the client request DTO includes a Thinking field; otherwise, add it to maintain parity with CLI usage.
  - Interactions with suppress-think:
    - --suppress-think still controls visibility of <think>…</think> content in output; --thinking controls whether/what kind of reasoning is requested from the provider. They are complementary.
  - Backward compatibility:
    - No default behavior changes; the feature is opt-in.

commits:
  [{"SHA":"f4dbafc63870ed5360d16df22511ade7f7649586","Message":"feat: add cross-provider --thinking flag mapping to Anthropic/OpenAI\n\nCHANGES\n- Add --thinking flag to set reasoning level cross-vendors\n- Map Anthropic thinking levels and token budgets appropriately\n- Translate OpenAI reasoning effort from thinking levels\n- Propagate Thinking through ChatOptions, server, and dry-run output\n- Update zsh, bash, fish completions with thinking choices\n- Expand suggest_pattern docs with categories, workflows, usage examples\n- Remove outdated suggest_pattern user files to avoid duplication\n- Add VSCode dictionary terms: Anki, DMARC, wireframes\n- Extend tests to include Thinking defaults in ChatOptions","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-14T02:50:36Z","Parents":null},{"SHA":"b485a4584f596fe474002ef5771130da32620cc9","Message":"refactor: extract token budget constants for thinking levels with validation bounds\n\n## CHANGES\n\n- Extract hardcoded token values into named constants\n- Add comprehensive documentation for token budget purposes\n- Implement token validation bounds (1-10000) in parsing\n- Replace magic numbers with semantic constant references\n- Improve code maintainability through constant extraction","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-14T14:11:04Z","Parents":null}]


title: Gemini Thinking Support and README (New Features) automation
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1706
merged_at: 2025-08-16 07:26:55+00:00
created_at: 2025-09-11 18:18:34
body:
  # Gemini Thinking Support and README (New Features) automation

  ## Summary

  This PR adds first-class “Thinking/Reasoning” support for Google Gemini models, updates CLI help/README to reflect the change, introduces unit tests for the new Gemini reasoning behavior, and adds a small scripts suite to automate the “Recent Major Features” section of the main README from the changelog database.

  ## Related Issues

  Closes #1707 

  ## Files Changed

  - README.md
    - Added an “Updates” section with a “Recent Major Features” list and adjusted table of contents.
    - Renamed the previous “Updates” section to “Changelog” for clarity.
    - Updated CLI help text to reflect Gemini support for the `--thinking` flag.
  - internal/cli/flags.go
    - Updated the `--thinking` flag description to include “Google Gemini”.
  - internal/plugins/ai/gemini/gemini.go
    - Implemented parsing and application of the Thinking/Reasoning config for Gemini models.
  - internal/plugins/ai/gemini/gemini_test.go
    - Added tests to validate that the thinking config is set correctly for both named levels and numeric token budgets.
  - scripts/readme_updates/README.md
    - New documentation describing scripts for auto-generating README release features.
  - scripts/readme_updates/update_readme_features.py
    - New script to generate the “Recent Major Features” section in README from the SQLite changelog database.

  ## Code Changes

  - Add Thinking/Reasoning support for Gemini:
    - Parse thinking level (off/low/medium/high) and optional numeric budgets.
    - Map named levels to token budgets using existing `domain.ThinkingBudgets`.
    - Apply Gemini SDK `ThinkingConfig` when enabled.

  Key snippets:

  ```go
  // internal/plugins/ai/gemini/gemini.go
  func parseThinkingConfig(level domain.ThinkingLevel) (*genai.ThinkingConfig, bool) {
      lower := strings.ToLower(strings.TrimSpace(string(level)))
      switch domain.ThinkingLevel(lower) {
      case "", domain.ThinkingOff:
          return nil, false
      case domain.ThinkingLow, domain.ThinkingMedium, domain.ThinkingHigh:
          if budget, ok := domain.ThinkingBudgets[domain.ThinkingLevel(lower)]; ok {
              b := int32(budget)
              return &genai.ThinkingConfig{IncludeThoughts: true, ThinkingBudget: &b}, true
          }
      default:
          if tokens, err := strconv.ParseInt(lower, 10, 32); err == nil && tokens > 0 {
              t := int32(tokens)
              return &genai.ThinkingConfig{IncludeThoughts: true, ThinkingBudget: &t}, true
          }
      }
      return nil, false
  }
  ```

  ```go
  // internal/plugins/ai/gemini/gemini.go
  func (o *Client) buildGenerateContentConfig(opts *domain.ChatOptions) (*genai.GenerateContentConfig, error) {
      // ...
      if tc, ok := parseThinkingConfig(opts.Thinking); ok {
          cfg.ThinkingConfig = tc
      }
      return cfg, nil
  }
  ```

  - CLI/help text updates:

  ```go
  // internal/cli/flags.go
  Thinking domain.ThinkingLevel `long:"thinking" ... description:"Set reasoning/thinking level (e.g., off, low, medium, high, or numeric tokens for Anthropic or Google Gemini)"`
  ```

  - Tests:

  ```go
  // internal/plugins/ai/gemini/gemini_test.go
  func TestBuildGenerateContentConfig_Thinking(t *testing.T) { /* validates low level maps to domain.TokenBudgetLow */ }
  func TestBuildGenerateContentConfig_ThinkingTokens(t *testing.T) { /* validates numeric tokens are honored */ }
  ```

  - README changes:
    - New “Updates” section with “Recent Major Features”.
    - “Updates” → “Changelog” to reduce ambiguity.
    - Updated CLI help block for `--thinking` to mention Gemini.

  - New script to populate README features:
    - Reads from `cmd/generate_changelog/changelog.db`.
    - Filters AI summaries using include/exclude keyword heuristics.
    - Outputs markdown list items in the format used by README.
    - Usage: `python scripts/readme_updates/update_readme_features.py --limit 20`

  ## Reason for Changes

  - Feature parity: Extend the existing “Thinking” capability beyond Anthropic to Google Gemini models to enable better reasoning workflows in Fabric regardless of provider choice.
  - Documentation and discoverability: Ensure users see and understand Gemini support in the CLI help and README. Add a curated “Recent Major Features” section to highlight the pace of improvements.
  - Automation: Provide a tooling path to keep README feature highlights fresh with minimal manual effort.

  ## Impact of Changes

  - Functionality:
    - Users can now enable reasoning with Gemini by passing `--thinking {off|low|medium|high|<tokens>}`.
    - When enabled, Gemini requests include `IncludeThoughts: true` and a token budget aligned with named levels or user-provided numeric value.
  - UX/Docs:
    - README and CLI help are up to date, improving clarity and lowering onboarding friction.
    - The “Recent Major Features” section can be programmatically generated, reducing manual maintenance.
  - Performance/Cost:
    - Enabling thinking increases token usage for Gemini responses; by default it remains off, so no impact unless explicitly enabled.

  ## Test Plan

  - Unit tests:
    - Run `go test ./...` to execute new tests:
      - Verifies that `domain.ThinkingLow` maps to `domain.TokenBudgetLow`.
      - Verifies that numeric token budgets (e.g., `--thinking 123`) are applied.
  - Manual tests:
    - Run CLI with a Gemini model:
      - `fabric --model gemini-1.5-pro --thinking low "Explain how hashing works"`
      - Confirm response includes reasoning/thoughts when not hidden by config, and that generation succeeds.
    - Validate disabling:
      - `fabric --model gemini-1.5-pro --thinking off "Short answer test"`
      - Confirm no thinking config is sent.
  - Documentation script:
    - Ensure changelog DB exists at `cmd/generate_changelog/changelog.db`.
    - Run `python scripts/readme_updates/update_readme_features.py --limit 10` and verify output format matches README expectations.

  ## Additional Notes

  - Provider capability mismatches:
    - If a Gemini model does not support reasoning, the SDK or API may ignore `ThinkingConfig` or return an error. Current implementation relies on provider behavior; future enhancement could gate reasoning by model capability.
  - Token budget mapping:
    - We reuse `domain.ThinkingBudgets` for Gemini named levels. If Gemini’s recommended budgets diverge, consider introducing provider-specific budgets.
  - README updates automation:
    - The new script uses heuristics and AI summary structure; as summaries evolve, classifiers and extractors may need tuning.

commits:
  [{"SHA":"d8690c7cecf23e679e268ca8a48d9227a74207de","Message":"feat: add release updates section and Gemini thinking support\n\n- Add comprehensive \"Recent Major Features\" section to README\n- Introduce new readme_updates Python script for automation\n- Enable Gemini thinking configuration with token budgets\n- Update CLI help text for Gemini thinking support\n- Add comprehensive test coverage for Gemini thinking\n- Create documentation for README update automation\n- Reorganize README navigation structure with changelog section","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-14T23:38:43Z","Parents":null}]


title: Enhanced YouTube Subtitle Language Fallback Handling
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1709
merged_at: 2025-08-16 16:17:09+00:00
created_at: 2025-09-11 18:18:34
body:
  # Enhanced YouTube Subtitle Language Fallback Handling

  ## Summary

  This PR improves YouTube subtitle language fallback handling in the yt-dlp integration, allowing for more flexible subtitle selection when the exact language match is not available. Additionally, it includes minor documentation and configuration fixes.

  ## Related Issues

  Closes #1237 

  ## Files Changed

  - **`.vscode/settings.json`**: Added new words to the VSCode spell checker dictionary
  - **`README.md`**: Fixed a typo in the feature list
  - **`cmd/generate_changelog/incoming/1709.txt`**: Added changelog entry for this PR
  - **`internal/tools/youtube/youtube.go`**: Enhanced subtitle language fallback logic

  ## Code Changes

  ### YouTube Subtitle Language Handling Enhancement
  The main change improves how yt-dlp handles subtitle language selection:

  ```go
  // Before:
  args = append(args, "--sub-langs", langMatch)

  // After:
  langOpts := language + "," + langMatch + ".*," + langMatch
  args = append(args, "--sub-langs", langOpts)
  ```

  This modification creates a comma-separated list of language options that includes:
  1. The full original language code
  2. A wildcard pattern for language variants (e.g., `en.*` matches `en-US`, `en-GB`, etc.)
  3. The base language code as a fallback

  ### Documentation Fix
  ```diff
  -- [v1.4.268] — **Gemmini TTS Voice Selection**: add Gemini TTS voice selection
  +- [v1.4.268] — **Gemini TTS Voice Selection**: add Gemini TTS voice selection
  ```

  ## Reason for Changes

  The primary motivation for this change is to improve the reliability of subtitle extraction from YouTube videos. Previously, if an exact language match wasn't available, the subtitle extraction could fail. With this enhancement, yt-dlp will now attempt to find the best available match using:
  - The exact language code specified
  - Any regional variants of that language
  - The base language code without regional specifications

  The typo fix improves documentation accuracy by correctly spelling "Gemini" instead of "Gemmini".

  ## Impact of Changes

  **Positive impacts:**
  - Increased success rate for subtitle extraction from YouTube videos
  - Better handling of videos that have regional language variants (e.g., en-US vs en-GB)
  - More resilient subtitle fetching that gracefully falls back to available options

  **Potential considerations:**
  - The order of language preferences in the comma-separated list determines priority
  - Users may receive subtitles in a slightly different dialect than requested (e.g., en-GB when en-US was requested), but this is preferable to no subtitles at all

  ## Test Plan

  To verify these changes:
  1. Test with YouTube videos that have subtitles in various language formats
  2. Verify that specifying `en` successfully retrieves `en-US` or `en-GB` subtitles when exact match isn't available
  3. Confirm that the original exact language match still works when available
  4. Test edge cases with less common language codes

  ## Additional Notes

  - The change maintains backward compatibility while extending functionality
  - The VSCode dictionary updates help maintain code quality by preventing false positive spell-check warnings
  - This fix addresses potential issues users may encounter when working with YouTube content from different regions

commits:
  [{"SHA":"992936dbd89d791192443de6edd99dd8ca33de25","Message":"fix: improve YouTube subtitle language fallback handling in yt-dlp integration\n\n- Fix typo \"Gemmini\" to \"Gemini\" in README\n- Add \"kballard\" and \"shellquote\" to VSCode dictionary\n- Add \"YTDLP\" to VSCode spell checker\n- Enhance subtitle language options with fallback variants\n- Build language options string with comma-separated alternatives","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-16T15:46:19Z","Parents":null}]


title: Add `--no-variable-replacement` Flag for Literal Pattern Handling
author: ksylvan
author_url: https://github.com/ksylvan
author_type: user
url: https://github.com/danielmiessler/Fabric/pull/1710
merged_at: 2025-08-16 21:20:18+00:00
created_at: 2025-09-11 18:18:34
body:
  # Add `--no-variable-replacement` Flag for Literal Pattern Handling

  ## Summary

  Introduce a new CLI flag `--no-variable-replacement` that disables pattern variable substitution while still inserting the user input. Wire this behavior through the CLI, domain request, and session builder. Refactor pattern-loading logic into reusable helpers and add a new `PatternsEntity.GetWithoutVariables` method to support input-only processing. Update shell completions and documentation accordingly, and add tests for the new behavior.

  ## Related Issues

  Closes #1708 

  ## Files Changed

  - README.md
    - Document the new `--no-variable-replacement` flag in the application options.
  - cmd/generate_changelog/incoming/1710.txt
    - Add changelog entry describing the feature and its scope.
  - completions/_fabric
    - Add zsh completion for `--no-variable-replacement`.
  - completions/fabric.bash
    - Add bash completion for `--no-variable-replacement`.
  - completions/fabric.fish
    - Add fish completion for `--no-variable-replacement`.
  - internal/cli/flags.go
    - Add `NoVariableReplacement` flag and pass it into the chat request.
  - internal/core/chatter.go
    - Respect `NoVariableReplacement` when applying variables to input and when loading patterns.
  - internal/domain/domain.go
    - Extend `ChatRequest` with a `NoVariableReplacement` boolean field.
  - internal/plugins/db/fsdb/patterns.go
    - Refactor pattern loading and variable application into helpers.
    - Add `GetWithoutVariables` to process only `{{input}}` and skip variable replacement.
  - internal/plugins/db/fsdb/patterns_test.go
    - Add tests for `GetWithoutVariables`.

  ## Code Changes

  - CLI flag definition and propagation:
    ```go
    // internal/cli/flags.go
    NoVariableReplacement           bool `long:"no-variable-replacement" description:"Disable pattern variable replacement"`

    // passed into domain request
    NoVariableReplacement: o.NoVariableReplacement,
    ```

  - Disable variable substitution when flag is set:
    ```go
    // internal/core/chatter.go
    if request.InputHasVars && !request.NoVariableReplacement {
        request.Message.Content, err = template.ApplyTemplate(request.Message.Content, request.PatternVariables, "")
        ...
    }

    if request.PatternName != "" {
        var pattern *fsdb.Pattern
        if request.NoVariableReplacement {
            pattern, err = o.db.Patterns.GetWithoutVariables(request.PatternName, request.Message.Content)
        } else {
            pattern, err = o.db.Patterns.GetApplyVariables(request.PatternName, request.PatternVariables, request.Message.Content)
        }
        ...
    }
    ```

  - Domain struct extension:
    ```go
    // internal/domain/domain.go
    type ChatRequest struct {
        ...
        InputHasVars          bool
        NoVariableReplacement bool
        StrategyName          string
    }
    ```

  - Patterns refactor and new method:
    ```go
    // internal/plugins/db/fsdb/patterns.go
    func (o *PatternsEntity) GetApplyVariables(source string, variables map[string]string, input string) (*Pattern, error) {
        pattern, err := o.loadPattern(source)
        if err != nil { return nil, err }
        return pattern, o.applyVariables(pattern, variables, input)
    }

    // New: process only {{input}}, skip variable replacement
    func (o *PatternsEntity) GetWithoutVariables(source, input string) (*Pattern, error) {
        pattern, err := o.loadPattern(source)
        if err != nil { return nil, err }
        o.applyInput(pattern, input)
        return pattern, nil
    }

    // Helpers used by both paths
    func (o *PatternsEntity) loadPattern(source string) (*Pattern, error) { ... }
    func (o *PatternsEntity) ensureInput(pattern *Pattern) { ... }
    func (o *PatternsEntity) applyInput(pattern *Pattern, input string) { ... }
    func (o *PatternsEntity) applyVariables(pattern *Pattern, variables map[string]string, input string) error { ... }
    ```

  - New tests for input-only processing:
    ```go
    // internal/plugins/db/fsdb/patterns_test.go
    result, err := entity.GetWithoutVariables("test-pattern", "hello")
    assert.Equal(t, "Prefix hello {{roam}}", result.Pattern)

    result, err = entity.GetWithoutVariables("no-input", "hi")
    assert.Equal(t, "Static content\nhi", result.Pattern)
    ```

  - Shell completions:
    - zsh, bash, fish completions now include `--no-variable-replacement`.

  ## Reason for Changes

  - Provide a way to prevent unintended mustache-style variable substitution when patterns (or input) intentionally contain `{{...}}` literals (e.g., code samples, documentation, or other templating syntaxes).
  - Improve maintainability and reuse by refactoring pattern loading and input/variable application into separate helpers.
  - Allow a middle-ground behavior where only `{{input}}` is interpolated while all other placeholders remain literal.

  ## Impact of Changes

  - Default behavior remains unchanged.
  - When `--no-variable-replacement` is set:
    - Pattern variables are not substituted; only `{{input}}` is inserted (and appended with a newline if the pattern lacks `{{input}}`).
    - User input variable substitution is also disabled (i.e., `--input-has-vars` is effectively ignored when no-variable-replacement is set). This prevents any variable expansion in both the pattern and the input for consistent, safe behavior.
  - Internal refactor reduces duplication and clarifies intent in the pattern processing code.
  - Shell completions and README are updated to reflect the new flag.
  - API: `ChatRequest` gains a new optional field; existing clients remain unaffected, and new clients can opt-in to the new behavior. Absence of the field behaves as before.

  ## Test Plan

  - Unit tests:
    - Added `TestGetWithoutVariables` to validate input-only insertion and `{{input}}` auto-append behavior.
    - Existing pattern tests continue to pass using the refactored code paths.

  - Manual CLI verification:
    - With variables: `--pattern test --variable name=Bob` where pattern is `Hello, {{name}}: {{input}}` and input "test".
      - Without flag: "Hello, Bob: test"
      - With `--no-variable-replacement`: "Hello, {{name}}: test"
    - With `--input-has-vars` on message content such as "Do {{thing}}":
      - Without flag (and `-v thing=foo`): "Do foo"
      - With `--no-variable-replacement`: "Do {{thing}}" (no substitution)
    - Patterns without `{{input}}` should append input on a new line in both modes.

  ## Additional Notes

  - Precedence: `--no-variable-replacement` takes precedence over `--input-has-vars`, disabling all variable substitution while still inserting the input into the pattern.
  - The new helpers (`loadPattern`, `ensureInput`, `applyInput`, `applyVariables`) reduce the cognitive load and make future extensions safer.
  - Completions updated for bash, zsh, and fish to surface the new flag.

commits:
  [{"SHA":"b4b5b0a4d97a094517f4ec925cec14e69c3a1f27","Message":"feat: add --no-variable-replacement flag to disable pattern variable substitution\n\n- Introduce CLI flag to skip pattern variable replacement.\n- Wire flag into domain request and session builder.\n- Avoid applying input variables when replacement is disabled.\n- Provide PatternsEntity.GetWithoutVariables for input-only pattern processing support.\n- Refactor patterns code into reusable load and apply helpers.\n- Update bash, zsh, fish completions with new flag.\n- Document flag in README and CLI help output.\n- Add unit tests covering GetWithoutVariables path and behavior.\n- Ensure {{input}} placeholder appends when missing in patterns.","Author":"Kayvan Sylvan","Email":"","Date":"2025-08-16T21:10:05Z","Parents":null}]


