Skip to content

[Plugin] Create JSON Repair Plugin using Plugin Framework #998

@crivetimihai

Description

@crivetimihai

Overview

Create a JSON Repair Plugin that performs conservative JSON string repair for tool outputs with malformed JSON data.

Plugin Requirements

Plugin Details

  • Name: JsonRepairPlugin
  • Type: Self-contained (native) plugin
  • File Location: plugins/json_repair/
  • Complexity: Medium

Functionality

  • Detect and repair common JSON syntax errors
  • Conservative approach to avoid data corruption
  • Support for multiple repair strategies
  • Validation of repaired JSON
  • Detailed repair logging

Hook Integration

  • Primary Hooks: tool_post_invoke
  • Purpose: Repair malformed JSON in tool outputs before returning to user
  • Behavior: Attempt to fix JSON syntax errors automatically

Configuration Schema

plugins:
  - name: "JsonRepair"
    kind: "plugins.json_repair.repair.JsonRepairPlugin"
    description: "Conservative JSON string repair for tool outputs"
    version: "0.1.0"
    hooks: ["tool_post_invoke"]
    mode: "permissive"
    priority: 8
    conditions:
      - tool_names: ["api_call", "data_processor", "json_generator"]
    config:
      # Repair strategies
      repair_strategies:
        - fix_trailing_commas
        - fix_unquoted_keys
        - fix_single_quotes
        - fix_missing_commas
        - fix_unclosed_brackets
        - fix_escape_sequences
      
      # Conservative settings
      conservative_mode:
        enabled: true
        max_repair_attempts: 3
        validate_repaired_json: true
        preserve_original_on_failure: true
      
      # Content detection
      json_detection:
        require_json_markers: false
        min_confidence_threshold: 0.7
        detect_json_blocks: true
        code_block_patterns: ["```json", "```"]
      
      # Logging and metrics
      logging:
        log_repairs: true
        include_diff: true
        log_failures: true
        metrics_enabled: true

Acceptance Criteria

  • Plugin implements JsonRepairPlugin class
  • Repairs common JSON syntax errors
  • Conservative approach prevents data corruption
  • Multiple repair strategies supported
  • Validates repaired JSON
  • Detailed repair logging
  • Plugin manifest and documentation created
  • Unit tests with >90% coverage

Priority

Medium - Data processing utility

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions