Content Sanitization & PHP Documentation Transformer #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a powerful content sanitization system and a PHP-to-documentation transformer to the context generator.
1. Content Sanitization System
Introduces a comprehensive system for sanitizing and transforming content:
CommentInsertionRule: Adds structured comments to code blocks
{ "documents": [{ "description": "Sanitized API Code", "outputPath": "docs/sanitized-api.md", "sources": [{ "type": "file", "sourcePaths": ["src/Api"], "modifiers": [{ "name": "sanitizer", "options": { "rules": [{ "type": "comment", "fileHeaderComment": "WARNING: This file contains sensitive operations", "methodComment": "Security critical method", "frequency": 0 }] } }] }] }] }KeywordRemovalRule: Removes sensitive content based on keywords
{ "documents": [{ "description": "Redacted Documentation", "outputPath": "docs/redacted.md", "sources": [{ "type": "file", "sourcePaths": ["config"], "modifiers": [{ "name": "sanitizer", "options": { "rules": [{ "type": "keyword", "keywords": ["API_KEY", "SECRET", "PASSWORD"], "replacement": "[REDACTED]", "caseSensitive": false, "removeLines": true }] } }] }] }] }RegexReplacementRule: Pattern-based text transformations
{ "documents": [{ "description": "Anonymized Content", "outputPath": "docs/anonymized.md", "sources": [{ "type": "file", "sourcePaths": ["src/User"], "modifiers": [{ "name": "sanitizer", "options": { "rules": [{ "type": "regex", "patterns": { "/[\\w.+-]+@[\\w-]+\\.[\\w.-]+/": "[EMAIL]", "/\\d{3}-\\d{2}-\\d{4}/": "[SSN]" } }] } }] }] }] }2. AST Documentation Transformer
Added
AstDocTransformerthat converts PHP code into structured markdown documentation:Configuration Example:
{ "documents": [{ "description": "API Documentation", "outputPath": "docs/api-docs.md", "sources": [{ "type": "file", "description": "Controllers", "sourcePaths": ["src/Controller"], "modifiers": [{ "name": "php-docs", "options": { "include_private_methods": false, "include_protected_methods": true, "extract_routes": true, "include_implementations": true, "class_heading_level": 1, "method_heading_format": "### {name}", "code_block_format": "php" } }] }] }] }Combined Usage Example:
{ "documents": [{ "description": "Clean API Documentation", "outputPath": "docs/clean-api-docs.md", "sources": [{ "type": "file", "description": "API Controllers", "sourcePaths": ["src/Controller"], "modifiers": [ { "name": "php-docs", "options": { "include_private_methods": false, "extract_routes": true } }, { "name": "context-sanitizer", "options": { "rules": [{ "type": "keyword", "keywords": ["SECRET", "INTERNAL"] }] } } ] }] }] }This transformer is ideal for: