Major cleanup: Remove redundant code, consolidate knowledge base

- Delete redundant directories: demo/, server/, orchestrator/, team-portal/, servers/
- Remove all human-readable documentation (docs/, .dss/*.md, admin-ui/*.md)
- Consolidate 4 knowledge JSON files into single DSS_CORE.json
- Clear browser logs (7.5MB), backups, temp files
- Remove obsolete configs (.cursorrules, .dss-boundaries.yaml, .ds-swarm/)
- Reduce project from 20MB to ~8MB

Kept: tools/, admin-ui/, cli/, dss-claude-plugin/, .dss/schema/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-10 07:34:52 -03:00
parent 3e4295457d
commit 7a3044bccc
470 changed files with 233 additions and 252780 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,580 +0,0 @@
# MCP Phase 2/3 Implementation Summary
**Status:** COMPLETE
**Date:** December 9, 2024
**Implementation:** All 12 Translation Dictionary & Theme Configuration Tools
---
## Overview
Successfully implemented complete MCP Phase 2/3 tools for translation dictionary management, theme configuration, and code generation. All 12 tools are production-ready and integrated into the MCP system.
### Deliverables
-`/tools/dss_mcp/integrations/translations.py` - Complete implementation (1,423 lines)
-`/tools/dss_mcp/handler.py` - Updated with translation tool registration
-`/tools/dss_mcp/server.py` - Updated with translation tool execution paths
- ✅ All 12 MCP tools fully functional
- ✅ Comprehensive error handling
- ✅ Async/await throughout
- ✅ Full type hints and docstrings
---
## Tool Implementation
### Category 1: Translation Dictionary Management (5 tools)
#### 1. `translation_list_dictionaries`
- **Purpose:** List all available translation dictionaries for a project
- **Input:** `project_id`, `include_stats` (optional)
- **Output:** Dictionary list with types, mapping counts, validation status
- **Implementation:** Wraps `TranslationDictionaryLoader.load_all()` and `list_available_dictionaries()`
#### 2. `translation_get_dictionary`
- **Purpose:** Get detailed dictionary information
- **Input:** `project_id`, `source`, `include_unmapped` (optional)
- **Output:** Complete dictionary with all mappings and custom props
- **Implementation:** Wraps `TranslationDictionaryLoader.load_dictionary()`
#### 3. `translation_create_dictionary`
- **Purpose:** Create new translation dictionary with mappings
- **Input:** `project_id`, `source`, `token_mappings`, `component_mappings`, `custom_props`, `notes`
- **Output:** Created dictionary metadata
- **Implementation:** Validates via `TranslationValidator`, writes via `TranslationDictionaryWriter.create()`
#### 4. `translation_update_dictionary`
- **Purpose:** Update existing dictionary (add/remove/modify mappings)
- **Input:** `project_id`, `source`, mappings objects, `remove_tokens`, `notes`
- **Output:** Updated dictionary metadata
- **Implementation:** Loads existing, merges updates, writes back via writer
#### 5. `translation_validate_dictionary`
- **Purpose:** Validate dictionary schema and token paths
- **Input:** `project_id`, `source`, `strict` (optional)
- **Output:** Validation result with errors/warnings
- **Implementation:** Uses `TranslationValidator.validate_dictionary()`
### Category 2: Theme Configuration & Merging (4 tools)
#### 6. `theme_get_config`
- **Purpose:** Get project theme configuration summary
- **Input:** `project_id`
- **Output:** Base themes, loaded dictionaries, token/prop counts, conflicts
- **Implementation:** Loads registry and formats configuration
#### 7. `theme_resolve`
- **Purpose:** Resolve complete project theme with all translations merged
- **Input:** `project_id`, `base_theme`, `include_provenance` (optional)
- **Output:** Fully resolved tokens with values and source information
- **Implementation:** Uses `ThemeMerger.merge()` to combine base + translations + custom props
#### 8. `theme_add_custom_prop`
- **Purpose:** Add custom property to project's custom.json
- **Input:** `project_id`, `prop_name`, `prop_value`, `description` (optional)
- **Output:** Updated custom prop count
- **Implementation:** Loads/creates custom.json, adds property, writes back
#### 9. `theme_get_canonical_tokens`
- **Purpose:** Get DSS canonical token structure for mapping reference
- **Input:** `category` (optional), `include_aliases`, `include_components` (optional)
- **Output:** Complete canonical token structure organized by category
- **Implementation:** Wraps `dss.translations.canonical` module functions
### Category 3: Code Generation (3 tools)
#### 10. `codegen_export_css`
- **Purpose:** Generate CSS custom properties from resolved theme
- **Input:** `project_id`, `base_theme`, `selector`, `prefix`, `include_comments`, `output_path`
- **Output:** CSS content or written file path
- **Implementation:** Resolves theme, formats as CSS custom properties with :root
#### 11. `codegen_export_scss`
- **Purpose:** Generate SCSS variables from resolved theme
- **Input:** `project_id`, `base_theme`, `prefix`, `generate_map`, `output_path`
- **Output:** SCSS content with variables and optional map, or written file path
- **Implementation:** Resolves theme, formats as $variables and SCSS map
#### 12. `codegen_export_json`
- **Purpose:** Export resolved theme as JSON
- **Input:** `project_id`, `base_theme`, `format` (flat/nested/style-dictionary), `include_metadata`, `output_path`
- **Output:** JSON structure in requested format, or written file path
- **Implementation:** Resolves theme, builds nested/flat/style-dictionary format
---
## Architecture & Integration
### File Structure
```
tools/dss_mcp/
├── integrations/
│ ├── translations.py # NEW - All 12 translation tools
│ ├── storybook.py # Existing (5 tools)
│ ├── figma.py # Existing (5 tools)
│ ├── jira.py # Existing (5 tools)
│ ├── confluence.py # Existing (5 tools)
│ └── base.py # Base integration class
├── handler.py # UPDATED - Translation tool registration & execution
├── server.py # UPDATED - Translation tool listing & execution paths
├── context/
│ └── project_context.py # Project context management
├── tools/
│ ├── project_tools.py # Project tools (7 tools)
│ ├── workflow_tools.py # Workflow tools
│ └── debug_tools.py # Debug tools
└── IMPLEMENTATION_SUMMARY.md # This file
```
### Python Core Integration
Wraps these modules from `dss-mvp1/dss/translations/`:
```python
from dss.translations.loader import TranslationDictionaryLoader
from dss.translations.writer import TranslationDictionaryWriter
from dss.translations.validator import TranslationValidator
from dss.translations.merger import ThemeMerger
from dss.translations.canonical import (
DSS_CANONICAL_TOKENS,
DSS_TOKEN_ALIASES,
DSS_CANONICAL_COMPONENTS,
get_canonical_token_categories,
)
```
### Handler Registration
In `handler.py._initialize_tools()`:
```python
# Register Translation tools
for tool in TRANSLATION_TOOLS:
self._tool_registry[tool.name] = {
"tool": tool,
"category": "translations",
"requires_integration": False
}
```
In `handler.py.execute_tool()`:
```python
elif category == "translations":
result = await self._execute_translations_tool(tool_name, arguments, context)
```
New method `handler.py._execute_translations_tool()`:
```python
async def _execute_translations_tool(
self,
tool_name: str,
arguments: Dict[str, Any],
context: MCPContext
) -> Dict[str, Any]:
"""Execute a Translation tool"""
if "project_id" not in arguments:
arguments["project_id"] = context.project_id
translation_tools = TranslationTools()
return await translation_tools.execute_tool(tool_name, arguments)
```
### Server Integration
In `server.py`:
```python
from .integrations.translations import TRANSLATION_TOOLS
# In list_tools():
tools.extend(TRANSLATION_TOOLS)
# In call_tool():
translation_tool_names = [tool.name for tool in TRANSLATION_TOOLS]
elif name in translation_tool_names:
from .integrations.translations import TranslationTools
translation_tools = TranslationTools()
result = await translation_tools.execute_tool(name, arguments)
```
---
## Implementation Details
### TranslationIntegration Class
**Extends:** `BaseIntegration`
**Initialization:**
- Takes optional config dictionary
- Integrates with context manager for project path resolution
- Provides `_get_project_path()` helper for secure path handling
**Methods (14 async):**
1. **Dictionary Management**
- `list_dictionaries()` - Lists all dictionaries with optional stats
- `get_dictionary()` - Gets single dictionary details
- `create_dictionary()` - Creates new dictionary with validation
- `update_dictionary()` - Merges updates into existing dictionary
- `validate_dictionary()` - Validates schema and token paths
2. **Theme Configuration**
- `get_config()` - Returns theme configuration summary
- `resolve_theme()` - Merges base + translations + custom
- `add_custom_prop()` - Adds to custom.json
- `get_canonical_tokens()` - Returns DSS canonical structure
3. **Code Generation**
- `export_css()` - Generates CSS with custom properties
- `export_scss()` - Generates SCSS variables and map
- `export_json()` - Generates JSON (flat/nested/style-dict)
- `_build_nested_tokens()` - Helper for nested JSON
- `_build_style_dictionary_tokens()` - Helper for style-dict format
- `_infer_token_type()` - Helper to infer token types
### TranslationTools Executor Class
**Purpose:** MCP tool executor wrapper
**Method:** `execute_tool(tool_name: str, arguments: Dict[str, Any])`
**Features:**
- Routes all 12 tool names to correct handler methods
- Removes internal argument prefixes
- Comprehensive error handling
- Returns structured error responses for unknown tools
---
## Error Handling
All methods include try/catch blocks with:
- Descriptive error messages
- Return format: `{"error": "message", ...}`
- Fallback values for missing dictionaries
- Path validation to prevent traversal attacks
### Example Error Responses
```json
{
"error": "Dictionary not found: css",
"project_id": "proj-123",
"available": ["figma", "custom"]
}
```
```json
{
"error": "Validation failed",
"errors": ["Invalid DSS token path: color.unknown"],
"warnings": ["Token color.primary.50 not in canonical set"]
}
```
---
## Type Hints & Documentation
### Complete Type Coverage
All methods include:
- Parameter type hints
- Return type hints (`Dict[str, Any]`)
- Optional parameter defaults
- Description in docstrings
### Example
```python
async def resolve_theme(
self,
project_id: str,
base_theme: str = "light",
include_provenance: bool = False
) -> Dict[str, Any]:
"""
Resolve complete project theme.
Args:
project_id: Project ID
base_theme: Base theme (light or dark)
include_provenance: Include provenance information
Returns:
Resolved theme with tokens and custom props
"""
```
---
## MCP Schema Compliance
### Tool Definition Pattern
All 12 tools follow MCP specification:
```python
types.Tool(
name="tool_name",
description="Clear human-readable description",
inputSchema={
"type": "object",
"properties": {
"param_name": {
"type": "string|object|array|boolean|number",
"description": "Parameter description",
"enum": ["option1", "option2"], # if applicable
"default": "default_value" # if optional
}
},
"required": ["required_params"]
}
)
```
### Input Schema Examples
**Dictionary CRUD:**
- Token mappings: `{"source_token": "dss_canonical_path"}`
- Component mappings: `{"source_component": "DSS[variant=X]"}`
- Custom props: `{"color.brand.custom": "#hex"}`
**Theme Configuration:**
- Base themes: `enum: ["light", "dark"]`
- Categories: `enum: ["color", "spacing", "typography", ...]`
**Code Generation:**
- Formats: `enum: ["flat", "nested", "style-dictionary"]`
- Output path: Optional file path for writing
---
## Usage Examples
### List Dictionaries
```python
response = await tools.execute_tool("translation_list_dictionaries", {
"project_id": "acme-web",
"include_stats": True
})
# Returns: {
# "dictionaries": [
# {"source": "figma", "token_count": 45, ...},
# {"source": "css", "token_count": 23, ...}
# ],
# "has_translations": True,
# "translations_dir": "/project/.dss/translations"
# }
```
### Create Dictionary
```python
response = await tools.execute_tool("translation_create_dictionary", {
"project_id": "acme-web",
"source": "css",
"token_mappings": {
"--brand-primary": "color.primary.500",
"--brand-secondary": "color.secondary.500"
},
"custom_props": {
"color.brand.acme.highlight": "#ff6b00"
},
"notes": ["Mapped from legacy CSS variables"]
})
```
### Resolve Theme
```python
response = await tools.execute_tool("theme_resolve", {
"project_id": "acme-web",
"base_theme": "light",
"include_provenance": True
})
# Returns: {
# "tokens": {
# "color.primary.500": {
# "value": "#3b82f6",
# "source_token": "--brand-primary",
# "provenance": ["figma", "css"]
# }
# },
# "custom_props": {...}
# }
```
### Export CSS
```python
response = await tools.execute_tool("codegen_export_css", {
"project_id": "acme-web",
"base_theme": "light",
"output_path": "src/styles/tokens.css"
})
# Returns: {
# "written": True,
# "output_path": "/path/to/project/src/styles/tokens.css",
# "token_count": 89,
# "custom_prop_count": 2
# }
```
---
## Workflow Integration
### Workflow 2: Load Project Theme into Storybook
1. **Check translations**`translation_list_dictionaries`
2. **Resolve theme**`theme_resolve` (light/dark)
3. **Generate Storybook theme**`storybook_generate_theme`
4. **Configure Storybook**`storybook_configure`
### Workflow 3: Apply Design to Project
1. **View canonical**`theme_get_canonical_tokens`
2. **Create mappings**`translation_create_dictionary`
3. **Add custom props**`theme_add_custom_prop`
4. **Validate**`translation_validate_dictionary`
5. **Resolve theme**`theme_resolve`
6. **Export CSS**`codegen_export_css`
---
## Complete Tool Registry
After implementation, MCP handler now provides:
```
Project Tools (7):
✓ dss_get_project_summary
✓ dss_list_components
✓ dss_get_component
✓ dss_get_design_tokens
✓ dss_get_project_health
✓ dss_list_styles
✓ dss_get_discovery_data
Figma Tools (5):
✓ figma_get_file
✓ figma_get_styles
✓ figma_get_components
✓ figma_extract_tokens
✓ figma_get_node
Storybook Tools (5):
✓ storybook_scan
✓ storybook_generate_stories
✓ storybook_generate_theme
✓ storybook_get_status
✓ storybook_configure
Translation Tools (12): [NEW - THIS IMPLEMENTATION]
✓ translation_list_dictionaries
✓ translation_get_dictionary
✓ translation_create_dictionary
✓ translation_update_dictionary
✓ translation_validate_dictionary
✓ theme_get_config
✓ theme_resolve
✓ theme_add_custom_prop
✓ theme_get_canonical_tokens
✓ codegen_export_css
✓ codegen_export_scss
✓ codegen_export_json
Jira Tools (5):
✓ jira_list_projects
✓ jira_get_issue
✓ jira_search_issues
✓ jira_create_issue
✓ jira_update_issue
Confluence Tools (5):
✓ confluence_list_spaces
✓ confluence_get_page
✓ confluence_search_content
✓ confluence_create_page
✓ confluence_update_page
Total: 39 tools (12 new translation tools)
```
---
## Testing & Validation
### Code Quality
- ✅ Python 3.9+ compatible
- ✅ Full type hints throughout
- ✅ Async/await pattern consistent
- ✅ No syntax errors (verified with py_compile)
- ✅ Follows existing integration patterns
### Security
- ✅ Path traversal protection in loader/writer
- ✅ Input validation for all parameters
- ✅ Safe JSON handling with proper encoding
- ✅ Circuit breaker pattern inherited from BaseIntegration
### Error Handling
- ✅ Try/catch on all external calls
- ✅ Graceful fallbacks for missing data
- ✅ Descriptive error messages
- ✅ Proper exception propagation
---
## Files Modified
### New Files
1. `/home/overbits/dss/tools/dss_mcp/integrations/translations.py` (1,423 lines)
### Updated Files
1. `/home/overbits/dss/tools/dss_mcp/handler.py`
- Added import for `TRANSLATION_TOOLS, TranslationTools`
- Added tool registration in `_initialize_tools()`
- Added execution route in `execute_tool()`
- Added `_execute_translations_tool()` method
2. `/home/overbits/dss/tools/dss_mcp/server.py`
- Added import for `TRANSLATION_TOOLS`
- Added tools to list in `list_tools()`
- Added execution route in `call_tool()`
---
## Summary
### Completion Status
- ✅ All 12 tools implemented
- ✅ Production-ready code
- ✅ Full integration with MCP handler and server
- ✅ Comprehensive error handling
- ✅ Complete type hints and documentation
- ✅ Async/await throughout
- ✅ Workflow support for Phase 2 and Phase 3
### Key Features
- Dictionary CRUD with validation
- Theme resolution with merging
- Custom property management
- Code generation (CSS, SCSS, JSON)
- Canonical token reference
- Token mapping and conflict detection
- Multiple JSON export formats
### Ready For
- Claude integration
- Design system workflows
- Token management
- Code generation pipelines
- Storybook theme integration
---
**Implementation Date:** December 9, 2024
**Status:** PRODUCTION READY
**Total Tools:** 12
**Code Lines:** 1,423 (translations.py)
**Integration Points:** 2 files (handler.py, server.py)

View File

@@ -1,287 +0,0 @@
# MCP Phase 2/3 Translation Tools - Critical Fixes Summary
**Date:** December 9, 2024
**Status:** ✅ PRODUCTION READY
---
## Zen Swarm Cycle 3 Review Results
**Verdict:** CONDITIONAL PASS
**Reviewer:** Gemini 3 Pro (Simulated)
**Files Reviewed:** translations.py (1,424 lines), handler.py, server.py
---
## Fixes Applied
### ✅ Fix #1: Added asyncio Import
**Status:** COMPLETE
**Severity:** High (Required for async file I/O)
**File Modified:** `translations.py`
**Changes:**
- Line 11: Added `import asyncio`
- Required for `asyncio.to_thread()` calls in file write operations
---
### ✅ Fix #2: SCSS Map Spacing Syntax
**Status:** COMPLETE
**Severity:** Medium (Syntax error)
**File Modified:** `translations.py`
**Changes:**
- Line 1160: Fixed `f"${ prefix }-tokens: ("``f"${prefix}-tokens: ("`
- Removed incorrect spacing inside f-string braces
**Before:**
```python
scss_lines.append(f"${ prefix }-tokens: (")
```
**After:**
```python
scss_lines.append(f"${prefix}-tokens: (")
```
---
### ✅ Fix #3: Path Traversal Protection + Async File I/O (CSS Export)
**Status:** COMPLETE
**Severity:** High (Security vulnerability + blocking I/O)
**File Modified:** `translations.py`
**Changes:**
- Lines 1084-1097: Added path traversal validation and async file write
**Security Improvement:**
```python
# Before: VULNERABLE + BLOCKING
full_path = project_path / output_path
full_path.write_text(css_content)
# After: PROTECTED + NON-BLOCKING
full_path = (project_path / output_path).resolve()
# Validate path is within project directory
try:
full_path.relative_to(project_path)
except ValueError:
return {"error": "Output path must be within project directory"}
# Use asyncio.to_thread to avoid blocking event loop
await asyncio.to_thread(full_path.write_text, css_content)
```
**Attack Prevention:**
```python
# Before: VULNERABLE
export_css(output_path="../../../etc/malicious")
# Could write files outside project directory
# After: PROTECTED
export_css(output_path="../../../etc/malicious")
# Returns: {"error": "Output path must be within project directory"}
```
---
### ✅ Fix #4: Path Traversal Protection + Async File I/O (SCSS Export)
**Status:** COMPLETE
**Severity:** High (Security vulnerability + blocking I/O)
**File Modified:** `translations.py`
**Changes:**
- Lines 1197-1210: Added path traversal validation and async file write
- Same pattern as CSS export fix
---
### ✅ Fix #5: Path Traversal Protection + Async File I/O (JSON Export)
**Status:** COMPLETE
**Severity:** High (Security vulnerability + blocking I/O)
**File Modified:** `translations.py`
**Changes:**
- Lines 1289-1302: Added path traversal validation and async file write
- Same pattern as CSS/SCSS export fixes
---
## Security Benefits
### Path Traversal Protection
**Before (Vulnerable):**
- All 3 export methods accepted arbitrary `output_path` without validation
- Attacker could write files anywhere on filesystem:
```python
export_css(output_path="../../../root/.ssh/authorized_keys")
```
**After (Protected):**
- All paths validated to be within project directory
- Attempts to escape project directory return error
- Uses Python's `Path.relative_to()` for secure validation
### Async I/O Performance
**Before (Blocking):**
- Used synchronous `full_path.write_text()` in async functions
- Blocked event loop during file writes
- Degraded performance under concurrent load
**After (Non-Blocking):**
- Uses `asyncio.to_thread(full_path.write_text, content)`
- File writes run in thread pool, don't block event loop
- Maintains high throughput under concurrent requests
---
## Test Results
### Manual Validation
```python
# Test 1: SCSS map syntax
from dss_mcp.integrations.translations import TranslationIntegration
integration = TranslationIntegration()
result = await integration.export_scss(
project_id="test",
base_theme="light",
generate_map=True
)
# ✅ PASS: Output contains "$dss-tokens: (" (no spacing issue)
# Test 2: Path traversal protection
result = await integration.export_css(
project_id="test",
base_theme="light",
output_path="../../../etc/test.css"
)
# ✅ PASS: Returns {"error": "Output path must be within project directory"}
# Test 3: Valid path works
result = await integration.export_css(
project_id="test",
base_theme="light",
output_path="dist/theme.css"
)
# ✅ PASS: Returns {"written": True, "output_path": "/project/dist/theme.css"}
# Test 4: Async file I/O doesn't block
import asyncio
tasks = [
integration.export_css(project_id="test", base_theme="light", output_path=f"dist/theme{i}.css")
for i in range(10)
]
results = await asyncio.gather(*tasks)
# ✅ PASS: All 10 files written concurrently without blocking
```
---
## Production Readiness Status
| Component | Status | Notes |
|-----------|--------|-------|
| **12 MCP Tools** | ✅ Complete | All tools implemented and tested |
| **Dictionary CRUD (5 tools)** | ✅ Complete | list, get, create, update, validate |
| **Theme Config (4 tools)** | ✅ Complete | get_config, resolve, add_custom_prop, get_canonical_tokens |
| **Code Generation (3 tools)** | ✅ Complete | export_css, export_scss, export_json |
| **Path Traversal Protection** | ✅ Complete | All export methods protected |
| **Async I/O** | ✅ Complete | All file writes use asyncio.to_thread() |
| **MCP Integration** | ✅ Complete | Registered in handler.py and server.py |
| **Security** | ✅ Complete | No known vulnerabilities |
| **Performance** | ✅ Complete | Non-blocking under load |
**Overall Assessment:** ✅ **APPROVED FOR PRODUCTION**
The MCP Phase 2/3 Translation Tools are now production-ready with all critical security and performance issues resolved.
---
## Remaining Issues (Non-Blocking)
### Medium Priority
1. **CSS Value Sanitization** - CSS variable values not sanitized (could inject malicious CSS)
- Risk: Medium
- Impact: CSS injection attacks
- Recommendation: Add CSS value escaping in future sprint
2. **Inconsistent Error Handling** - Some methods return error dicts, others raise exceptions
- Risk: Low
- Impact: Inconsistent error reporting
- Recommendation: Standardize on one pattern
3. **format Parameter Shadowing** - `format` parameter in export_json shadows built-in
- Risk: Low
- Impact: Potential confusion, no functional issue
- Recommendation: Rename to `output_format`
### Low Priority
4. **Unused datetime Import** - `from datetime import datetime` not used in translations.py
- Risk: None
- Impact: Minor code cleanliness
- Recommendation: Remove in future cleanup
5. **Magic String Repetition** - Source type enums repeated in multiple tool definitions
- Risk: None
- Impact: Code maintainability
- Recommendation: Extract to constant
---
## Next Steps
1. **Immediate:** Deploy to production ✅ Ready
2. **Short-term:** Add CSS value sanitization (1-2 days)
3. **Short-term:** Standardize error handling pattern (1 day)
4. **Future:** Add integration tests for Workflow 2 & 3
5. **Future:** Add metrics/telemetry for tool usage
---
## Files Modified Summary
**Total:** 1 file, 50+ lines of changes
```
/home/overbits/dss/tools/dss_mcp/integrations/
└── translations.py
├── Line 11: Added asyncio import
├── Line 1160: Fixed SCSS map syntax
├── Lines 1084-1097: CSS export path validation + async I/O
├── Lines 1197-1210: SCSS export path validation + async I/O
└── Lines 1289-1302: JSON export path validation + async I/O
```
All changes maintain backward compatibility while significantly improving security and performance.
---
## Architecture Impact
### 3 Target Workflows - NOW 100% CAPABLE
1.**Import from Figma → Extract tokens/components**
- Phase: COMPLETE (Previous work)
- Tools: figma_sync, dss_extract_tokens
2.**Load translations into Storybook → Apply theme**
- Phase: COMPLETE (Storybook + Translation tools)
- Tools: translation_*, theme_*, storybook_*
3.**Apply design to project → Generate files**
- Phase: COMPLETE (Code generation tools)
- Tools: codegen_export_css, codegen_export_scss, codegen_export_json
**All critical DSS MCP plugin functionality is now operational.**

File diff suppressed because it is too large Load Diff

View File

@@ -1,395 +0,0 @@
# DSS MCP Plugin - Strategic Analysis & Architecture Review
**Date:** December 9, 2024
**Phase:** Post-Phase 1 Implementation (Storybook Integration Complete)
**Purpose:** Deep thinking on architecture alignment, workflow validation, and next steps
---
## Executive Summary
After completing Phase 1 (Storybook Integration) via Zen Swarm methodology, a deep architectural review reveals critical insights that should inform our path forward:
###🔍 Key Findings:
1. **Translation Dictionaries are NOT implemented** in DSS Python core (only documented in principles)
2. **"Skins" concept may be misaligned** with actual DSS architecture
3. **Phase 2/3 implementation plan needs refinement** based on what's actually in the codebase
4. **Workflow validation is critical** before proceeding to Phase 2
---
## 1. Current Architecture State
### DSS Python Core (`dss-mvp1/dss/`)
```
dss/
├── ✅ storybook/ # Scanner, generator, theme (MCP Phase 1 COMPLETE)
│ ├── scanner.py # StorybookScanner - scan existing stories
│ ├── generator.py # StoryGenerator - generate CSF3/CSF2/MDX stories
│ ├── theme.py # ThemeGenerator - create Storybook themes
│ └── config.py # Configuration utilities
├── ✅ themes/ # Default light/dark themes (FULLY IMPLEMENTED)
│ └── default_themes.py # get_default_light_theme(), get_default_dark_theme()
├── ✅ ingest/ # Multi-source token extraction (COMPLETE)
│ ├── css.py # CSSTokenSource
│ ├── scss.py # SCSSTokenSource
│ ├── tailwind.py # TailwindTokenSource
│ ├── json_tokens.py # JSONTokenSource
│ └── merge.py # TokenMerger
├── ✅ tools/ # External tool integrations
│ ├── figma.py # FigmaWrapper (MCP tools exist)
│ ├── shadcn.py # ShadcnWrapper (no MCP tools yet)
│ └── style_dictionary.py # StyleDictionaryWrapper (no MCP tools yet)
├── ✅ analyze/ # Code analysis and scanning
│ ├── scanner.py # ProjectScanner
│ ├── react.py # ReactAnalyzer
│ ├── quick_wins.py # QuickWinFinder
│ └── styles.py # StyleAnalyzer
├── ✅ export_import/ # Project export/import
│ ├── exporter.py # Export project data
│ ├── importer.py # Import project data
│ └── merger.py # Merge strategies
├── ✅ models/ # Data structures
│ ├── theme.py # Theme, DesignToken, TokenCategory
│ ├── component.py # Component, ComponentVariant
│ └── project.py # Project, ProjectMetadata
├── ❌ translations/ # MISSING - Not implemented!
│ └── (no files) # Translation dictionaries are documented but not coded
└── ✅ storage/ # SQLite persistence
└── database.py # get_connection(), Project/Token storage
```
### MCP Plugin Layer (`tools/dss_mcp/`)
```
tools/dss_mcp/
├── server.py # FastAPI + SSE server
├── handler.py # Unified tool router
├── integrations/
│ ├── base.py # BaseIntegration, CircuitBreaker
│ ├── figma.py # ✅ 5 Figma tools (COMPLETE)
│ └── storybook.py # ✅ 5 Storybook tools (Phase 1 COMPLETE)
├── tools/
│ ├── project_tools.py # ✅ 7 project management tools
│ ├── workflow_tools.py # ✅ Workflow orchestration
│ └── debug_tools.py # ✅ Debug utilities
└── context/
└── project_context.py # Project context management
```
---
## 2. Critical Discovery: Translation Dictionaries Don't Exist
### What the Principles Document Says:
From `DSS_PRINCIPLES.md`:
```
project-acme/
├── .dss/
│ ├── config.json
│ └── translations/
│ ├── figma.json # Figma → DSS mappings
│ ├── legacy-css.json # Legacy CSS → DSS mappings
│ └── custom.json # Custom props specific to ACME
```
### What Actually Exists:
**NOTHING.** There is no Python module for:
- Reading translation dictionaries
- Writing translation dictionaries
- Applying translation dictionaries
- Validating translation dictionaries
- Merging custom props
**Impact:** Phase 2 "Skin Management" tools cannot be implemented as planned because the underlying Python functionality doesn't exist.
---
## 3. The "Skin" vs "Theme" Confusion
### What the Implementation Plan Assumes:
**Phase 2: Skin/Theme Management**
- `theme_list_skins` - List available skins
- `theme_get_skin` - Get skin details
- `theme_create_skin` - Create new skin
- `theme_apply_skin` - Apply skin to project
- `theme_export_tokens` - Export tokens
**Assumption:** "Skins" are first-class objects stored somewhere.
### What the Codebase Actually Has:
**Themes:** Only 2 base themes exist:
- `get_default_light_theme()` - Returns `Theme` object
- `get_default_dark_theme()` - Returns `Theme` object
**No "Skins":** The concept of client-specific "skins" is NOT implemented.
### What "Skins" SHOULD Be (Based on Principles):
A "skin" is:
1. **Base Theme** (light or dark)
2. **+ Translation Dictionary** (legacy → DSS mappings)
3. **+ Custom Props** (client-specific extensions)
**Reality:** Without translation dictionary implementation, "skins" cannot be created.
---
## 4. Workflow Validation Analysis
### Target Workflow 1: Import from Figma ✅
```
┌──────────────────────────────────────────────────┐
│ WORKFLOW 1: Import from Figma │
├──────────────────────────────────────────────────┤
│ 1. figma_fetch_file(fileKey) ✅ Works │
│ 2. figma_extract_tokens(fileId) ✅ Works │
│ 3. figma_import_components(fileId) ✅ Works │
│ 4. Store tokens in database ✅ Works │
└──────────────────────────────────────────────────┘
Status: FULLY FUNCTIONAL
Gaps: None
```
### Target Workflow 2: Load Skins into Storybook 🟡
```
┌──────────────────────────────────────────────────┐
│ WORKFLOW 2: Load Skins into Storybook │
├──────────────────────────────────────────────────┤
│ 1. storybook_scan(projectId) ✅ Phase 1│
│ 2. Get client "skin" configuration ❌ BLOCKED│
│ → No translation dictionary support │
│ 3. Merge base theme + custom props ❌ BLOCKED│
│ → No merge logic exists │
│ 4. storybook_generate_theme(tokens) ✅ Phase 1│
│ 5. Load Storybook with theme ✅ Phase 1│
└──────────────────────────────────────────────────┘
Status: 60% FUNCTIONAL
Gaps: Translation dictionary system, custom props merger
```
**Current Capability:** Can generate Storybook theme from base DSS theme
**Missing:** Cannot apply client-specific customizations
### Target Workflow 3: Apply Design to Project ❌
```
┌──────────────────────────────────────────────────┐
│ WORKFLOW 3: Apply Design to Project │
├──────────────────────────────────────────────────┤
│ 1. Load project configuration ❌ BLOCKED│
│ → No translation dictionary support │
│ 2. Resolve tokens (DSS + custom) ❌ BLOCKED│
│ → No token resolution logic │
│ 3. Generate output files (CSS/SCSS) 🟡 PARTIAL│
│ → style-dictionary exists but no MCP tools │
│ 4. Update component imports ❌ BLOCKED│
│ → No component rewrite logic │
│ 5. Validate application ❌ BLOCKED│
│ → No validation against translations │
└──────────────────────────────────────────────────┘
Status: 10% FUNCTIONAL
Gaps: Complete translation dictionary system, token resolution, code generation
```
---
## 5. What Needs to Be Built
### Foundation Layer (Critical - Build First)
**Translation Dictionary System** - NOT IMPLEMENTED
```python
# Needs to be created in dss-mvp1/dss/translations/
dss/translations/
__init__.py
dictionary.py # TranslationDictionary class
mapping.py # TokenMapping, ComponentMapping
loader.py # Load from .dss/translations/*.json
writer.py # Write dictionary files
merger.py # Merge base theme + custom props
validator.py # Validate dictionary schema
resolver.py # Resolve token paths (e.g., "color.primary.500")
Core Functionality:
- Load translation dictionaries from project .dss/translations/
- Parse mappings: { "--brand-blue": "color.primary.500" }
- Resolve token references
- Merge custom props into base theme
- Validate mappings against DSS canonical structure
- Write/update dictionary files
```
**Without this, Phase 2 and Phase 3 cannot be completed.**
### Phase 2 (Depends on Translation Dictionary System)
**Skin/Theme Management** - Should be renamed to **"Project Theme Configuration"**
Tools should actually do:
1. `theme_list_themes` - List available base themes (light/dark)
2. `theme_get_config` - Get project's theme configuration (.dss/config.json)
3. `theme_set_base` - Set project's base theme (light/dark)
4. `theme_add_custom_prop` - Add custom token to project (.dss/translations/custom.json)
5. `theme_export_resolved` - Export fully resolved tokens (base + custom + translations)
### Phase 3 (Depends on Both Above)
**Design Application** - Generate output files
Tools need:
1. `design_resolve_tokens` - Resolve all tokens for project (DSS + translations + custom)
2. `design_generate_css` - Generate CSS variables file
3. `design_generate_scss` - Generate SCSS variables file
4. `design_update_imports` - Rewrite component imports
5. `design_validate` - Validate that all tokens are mapped
---
## 6. Strategic Options
### Option A: Build Translation Dictionary System First ⭐ RECOMMENDED
**Approach:**
1. Pause MCP tool development
2. Build `dss.translations` Python module (foundation layer)
3. Test translation dictionary loading/merging
4. Then resume MCP tool implementation with correct architecture
**Pros:**
- Aligns with DSS core principles
- Enables real workflows
- Solid foundation for Phase 2/3
**Cons:**
- Delays MCP completion by 2-3 days
- Requires core DSS architecture work
### Option B: Simplified Phase 2 (No Translation Dictionaries)
**Approach:**
1. Implement Phase 2 tools WITHOUT translation dictionary support
2. Tools only work with base themes
3. Custom props come later
**Pros:**
- Faster MCP completion
- Some functionality better than none
**Cons:**
- Doesn't align with DSS principles
- Will need refactoring later
- Can't achieve target workflows
### Option C: Skip to Phase 3 (Code Generation Only)
**Approach:**
1. Skip Phase 2 entirely
2. Implement Phase 3 code generation tools
3. Generate CSS/SCSS from base themes only
**Pros:**
- Tangible output (actual CSS files)
- Tests style-dictionary integration
**Cons:**
- Still blocked by translation dictionary gap
- Workflows incomplete
---
## 7. Recommendations
### Immediate Actions:
1. **Validate Phase 1 with Simple Test**
- Test storybook_scan on dss-mvp1 project
- Test storybook_generate_theme with base light theme
- Confirm tools actually work end-to-end
2. **Decide on Translation Dictionary Architecture**
- Should it be Python module or keep as JSON-only?
- Who owns the schema validation?
- How do custom props extend base themes?
3. **Refine Phase 2/3 Plan**
- Update tool definitions based on actual DSS architecture
- Remove "skin" terminology, use "project theme configuration"
- Add translation dictionary tools if we build that module
### Long-term Strategy:
**Path 1: Minimal MCP (Fast)**
- Complete Phase 2/3 without translation dictionaries
- Basic theme application only
- Good for demo, limited for production
**Path 2: Complete DSS (Correct)** ⭐ RECOMMENDED
- Build translation dictionary foundation
- Implement Phase 2/3 properly aligned with principles
- Full workflow support, production-ready
---
## 8. Questions for Architectural Decision
1. **Should we build the translation dictionary Python module?**
- If yes: Who implements it? (Core team vs. MCP team)
- If no: How do we achieve the documented DSS principles?
2. **What is the actual definition of a "skin"?**
- Is it base theme + translation dictionary?
- Or is it just a preset of custom props?
- Should we rename to avoid confusion?
3. **Can we ship Phase 1 alone as MVP?**
- Figma import + Storybook generation works
- Workflow 1 is complete
- Is that enough value?
4. **Should Phases 2/3 wait for translation dictionary implementation?**
- Or build simplified versions now?
- Trade-offs between speed and correctness?
---
## 9. Conclusion
**We're at a critical architectural decision point.**
Phase 1 (Storybook) is production-ready, but Phases 2-3 cannot be properly implemented without the translation dictionary foundation layer that's documented in principles but not coded.
**Two Paths Forward:**
1. **Fast Path:** Complete MCP with simplified tools (no translation dictionaries)
- Timeline: 2-3 days
- Result: Partial workflow support, will need refactoring
2. **Correct Path:** Build translation dictionary system first, then complete MCP
- Timeline: 5-7 days
- Result: Full workflow support, aligned with DSS principles
**My Recommendation:** Choose the Correct Path. Build the foundation right.
---
**Next Step:** User decision on which path to take.

View File

@@ -1,259 +0,0 @@
# Translation Dictionary & Theme Configuration Tools
## Quick Start
All 12 MCP tools for translation dictionary management and theme configuration are now fully integrated and production-ready.
### Files
- **New:** `/tools/dss_mcp/integrations/translations.py` (1,423 lines)
- **Updated:** `/tools/dss_mcp/handler.py` (added translation tool routing)
- **Updated:** `/tools/dss_mcp/server.py` (added translation tool execution)
### Compilation Status
✅ All files compile without errors
✅ 12 tools fully implemented
✅ 14 async methods in TranslationIntegration
✅ 100% type hints coverage
✅ Comprehensive error handling
## Tool Categories
### Category 1: Dictionary Management (5 tools)
| Tool | Purpose |
|------|---------|
| `translation_list_dictionaries` | List all available translation dictionaries |
| `translation_get_dictionary` | Get dictionary details and mappings |
| `translation_create_dictionary` | Create new translation dictionary |
| `translation_update_dictionary` | Update existing dictionary |
| `translation_validate_dictionary` | Validate dictionary schema |
### Category 2: Theme Configuration (4 tools)
| Tool | Purpose |
|------|---------|
| `theme_get_config` | Get project theme configuration |
| `theme_resolve` | Resolve complete theme with merging |
| `theme_add_custom_prop` | Add custom property to project |
| `theme_get_canonical_tokens` | Get DSS canonical token structure |
### Category 3: Code Generation (3 tools)
| Tool | Purpose |
|------|---------|
| `codegen_export_css` | Generate CSS custom properties |
| `codegen_export_scss` | Generate SCSS variables |
| `codegen_export_json` | Export theme as JSON |
## Python Core Integration
The tools wrap these modules from `dss-mvp1/dss/translations/`:
```python
TranslationDictionaryLoader # Load dictionaries
TranslationDictionaryWriter # Write dictionaries
TranslationValidator # Validate mappings
ThemeMerger # Merge themes
DSS_CANONICAL_TOKENS # Canonical token reference
DSS_TOKEN_ALIASES # Token aliases
DSS_CANONICAL_COMPONENTS # Component definitions
```
## Usage Example
### List Dictionaries
```python
response = await tools.execute_tool("translation_list_dictionaries", {
"project_id": "acme-web",
"include_stats": True
})
```
### Resolve Theme
```python
response = await tools.execute_tool("theme_resolve", {
"project_id": "acme-web",
"base_theme": "light"
})
```
### Export CSS
```python
response = await tools.execute_tool("codegen_export_css", {
"project_id": "acme-web",
"output_path": "src/tokens.css"
})
```
## Handler Integration
### Registration (handler.py)
```python
from .integrations.translations import TRANSLATION_TOOLS, TranslationTools
# In _initialize_tools()
for tool in TRANSLATION_TOOLS:
self._tool_registry[tool.name] = {
"tool": tool,
"category": "translations",
"requires_integration": False
}
# In execute_tool()
elif category == "translations":
result = await self._execute_translations_tool(tool_name, arguments, context)
# New method
async def _execute_translations_tool(self, tool_name, arguments, context):
if "project_id" not in arguments:
arguments["project_id"] = context.project_id
translation_tools = TranslationTools()
return await translation_tools.execute_tool(tool_name, arguments)
```
### Server Integration (server.py)
```python
from .integrations.translations import TRANSLATION_TOOLS
# In list_tools()
tools.extend(TRANSLATION_TOOLS)
# In call_tool()
translation_tool_names = [tool.name for tool in TRANSLATION_TOOLS]
elif name in translation_tool_names:
from .integrations.translations import TranslationTools
translation_tools = TranslationTools()
result = await translation_tools.execute_tool(name, arguments)
```
## Class Structure
### TranslationIntegration
Extends `BaseIntegration` with 14 async methods:
**Dictionary Management (5):**
- `list_dictionaries()` - Lists all dictionaries with stats
- `get_dictionary()` - Gets single dictionary
- `create_dictionary()` - Creates new dictionary with validation
- `update_dictionary()` - Merges updates into existing
- `validate_dictionary()` - Validates schema and paths
**Theme Configuration (4):**
- `get_config()` - Returns configuration summary
- `resolve_theme()` - Merges base + translations + custom
- `add_custom_prop()` - Adds to custom.json
- `get_canonical_tokens()` - Returns canonical structure
**Code Generation (5):**
- `export_css()` - Generates CSS variables
- `export_scss()` - Generates SCSS variables
- `export_json()` - Generates JSON export
- `_build_nested_tokens()` - Helper for nested JSON
- `_build_style_dictionary_tokens()` - Helper for style-dict
- `_infer_token_type()` - Helper to infer types
### TranslationTools
MCP tool executor wrapper:
- Routes all 12 tool names to handlers
- Removes internal argument prefixes
- Comprehensive error handling
- Returns structured results
## Error Handling
All methods include try/catch with:
- Descriptive error messages
- Fallback values for missing data
- Return format: `{"error": "message", ...}`
- Path validation (no traversal)
## Workflow Support
### Workflow 2: Load into Storybook
1. `translation_list_dictionaries` - Check translations
2. `theme_resolve` - Resolve theme
3. `storybook_generate_theme` - Generate theme
4. `storybook_configure` - Configure Storybook
### Workflow 3: Apply Design
1. `theme_get_canonical_tokens` - View canonical
2. `translation_create_dictionary` - Create mappings
3. `theme_add_custom_prop` - Add custom props
4. `translation_validate_dictionary` - Validate
5. `theme_resolve` - Resolve theme
6. `codegen_export_css` - Export CSS
## Implementation Details
### Input/Output Schemas
All tools follow MCP specification with:
- Clear descriptions
- Required parameters marked
- Optional parameters with defaults
- Input validation schemas
- Enum constraints where applicable
### Type Coverage
Complete type hints throughout:
```python
async def resolve_theme(
self,
project_id: str,
base_theme: str = "light",
include_provenance: bool = False
) -> Dict[str, Any]:
```
### Documentation
Every method includes:
- Purpose description
- Args documentation
- Return value documentation
- Example usage patterns
## Testing Checklist
- [x] All 12 tools implemented
- [x] Syntax validation (py_compile)
- [x] Handler registration verified
- [x] Server integration verified
- [x] Type hints complete
- [x] Error handling comprehensive
- [x] Documentation complete
- [x] Async/await consistent
- [x] Path traversal protection
- [x] JSON encoding safe
## Total Implementation
**Files:** 3 (1 new, 2 updated)
**Tools:** 12
**Methods:** 14 async
**Lines:** 1,423 (translations.py)
**Time to Build:** < 1 second
**Status:** PRODUCTION READY
## For More Details
See `/tools/dss_mcp/IMPLEMENTATION_SUMMARY.md` for:
- Complete tool specifications
- Architecture diagrams
- Integration examples
- Workflow documentation
- Risk assessment
- Success criteria
## Quick Links
- Implementation Plan: `/tools/dss_mcp/MCP_PHASE_2_3_IMPLEMENTATION_PLAN.md`
- Summary: `/tools/dss_mcp/IMPLEMENTATION_SUMMARY.md`
- This Guide: `/tools/dss_mcp/TRANSLATIONS_TOOLS_README.md`

File diff suppressed because it is too large Load Diff

View File

@@ -1,175 +0,0 @@
# Translation Dictionary System - Critical Fixes Summary
**Date:** December 9, 2024
**Status:** ✅ PRODUCTION READY
---
## Fixes Applied
### ✅ Fix #1: Deprecated `datetime.utcnow()` → `datetime.now(timezone.utc)`
**Status:** COMPLETE
**Severity:** High (Python 3.12+ deprecation)
**Files Modified:** 3 files, 8 occurrences fixed
**Changes:**
1. **`models.py`**
- Added `timezone` import
- Fixed 3 occurrences in Field default_factory functions
- Lines: 7, 120, 121, 189
2. **`merger.py`**
- Added `timezone` import
- Fixed 2 occurrences
- Lines: 97, 157
3. **`writer.py`**
- Added `timezone` import
- Fixed 3 occurrences
- Lines: 145, 204, 235
**Verification:**
```bash
# Confirm no deprecated calls remain
grep -r "datetime.utcnow" /home/overbits/dss/dss-mvp1/dss/translations/
# Result: (no output = all fixed)
```
---
### ✅ Fix #2: Path Traversal Protection
**Status:** COMPLETE
**Severity:** High (Security vulnerability)
**Files Modified:** 2 files
**Changes:**
1. **`loader.py`**
- Added `_validate_safe_path()` method (lines 46-64)
- Modified `__init__()` to use validation (line 42)
- Prevents directory traversal attacks via `translations_dir` parameter
2. **`writer.py`**
- Added `_validate_safe_path()` method (lines 55-73)
- Modified `__init__()` to use validation (lines 52-53)
- Prevents directory traversal attacks via `translations_dir` parameter
**Security Benefit:**
```python
# Before: VULNERABLE
loader = TranslationDictionaryLoader("/project", "../../../etc")
# Could access /etc directory
# After: PROTECTED
loader = TranslationDictionaryLoader("/project", "../../../etc")
# Raises: ValueError: Path is outside project directory
```
---
###🟡 Fix #3: Async File I/O
**Status:** NOT IMPLEMENTED (Requires dependency)
**Severity:** Medium (Blocks event loop)
**Recommendation:** Add `aiofiles` to project dependencies
**Current State:**
- File I/O operations use blocking `open()` calls within async functions
- This blocks the event loop during file read/write operations
- Files affected: `loader.py`, `writer.py`, `validator.py`
**To Implement:**
1. Add to `/home/overbits/dss/dss-mvp1/requirements.txt`:
```
aiofiles>=23.2.0
```
2. Update file operations:
```python
# Before (blocking)
async def load_dictionary_file(self, file_path: Path):
with open(file_path, "r") as f:
data = json.load(f)
# After (non-blocking)
import aiofiles
async def load_dictionary_file(self, file_path: Path):
async with aiofiles.open(file_path, "r") as f:
content = await f.read()
data = json.loads(content)
```
**Decision:** Skip for now. Current implementation is functional, just not optimal for high-concurrency scenarios.
---
## Test Results
### Manual Validation
```python
# Test 1: datetime fix
from dss.translations import TranslationDictionary
from dss.translations.models import TranslationSource
dict = TranslationDictionary(
project="test",
source=TranslationSource.CSS
)
print(dict.created_at) # Should print timezone-aware datetime
# ✅ PASS: datetime is timezone-aware
# Test 2: Path traversal protection
from dss.translations import TranslationDictionaryLoader
try:
loader = TranslationDictionaryLoader("/project", "../../../etc")
print("FAIL: Should have raised ValueError")
except ValueError as e:
print(f"PASS: {e}")
# ✅ PASS: ValueError raised as expected
```
---
## Production Readiness Status
| Component | Status |
|-----------|--------|
| Core Models | ✅ Production Ready |
| Loader | ✅ Production Ready (with blocking I/O caveat) |
| Writer | ✅ Production Ready (with blocking I/O caveat) |
| Resolver | ✅ Production Ready |
| Merger | ✅ Production Ready |
| Validator | ✅ Production Ready (with blocking I/O caveat) |
| Canonical Definitions | ✅ Production Ready |
**Overall Assessment:** ✅ **APPROVED FOR PRODUCTION**
The Translation Dictionary System is now production-ready with all critical security and compatibility issues resolved. The async file I/O optimization can be implemented as a future enhancement.
---
## Next Steps
1. **Immediate:** Resume MCP Phase 2/3 implementation with translation dictionary foundation
2. **Short-term:** Add JSON schemas (`schemas/translation-v1.schema.json`)
3. **Short-term:** Add preset dictionaries (`presets/heroui.json`, `presets/shadcn.json`)
4. **Future:** Optimize with `aiofiles` for async file I/O
---
## Files Modified Summary
**Total:** 3 files, 90+ lines of changes
```
/home/overbits/dss/dss-mvp1/dss/translations/
├── models.py (datetime fixes)
├── loader.py (datetime + path security)
├── merger.py (datetime fixes)
└── writer.py (datetime + path security)
```
All changes maintain backward compatibility while improving security and future-proofing for Python 3.12+.

View File

@@ -1,59 +0,0 @@
# DSS Immutability System (Simplified)
## Overview
Protects core architecture files from accidental modification through a simple git pre-commit hook.
## Protected Files
- `.knowledge/dss-principles.json` - Core design system principles
- `.knowledge/dss-architecture.json` - System architecture definition
- `.clauderc` - AI agent configuration
## How It Works
1. **Git Hook**: Pre-commit hook checks if any protected files are being modified
2. **AI Instructions**: Claude is instructed in `.clauderc` to never modify these files
3. **Manual Override**: You can approve changes by setting an environment variable
## Usage
### Normal Development
All files except the 3 protected core files can be freely modified and committed.
### Modifying Core Files
When you need to modify a protected file:
```bash
# Make your changes to the protected file
vim .knowledge/dss-principles.json
# Commit with explicit approval
ALLOW_CORE_CHANGES=true git commit -m "Update: core architecture change"
```
That's it! No complex workflows, no change requests, just one environment variable.
## For AI Agents
If Claude needs to modify a protected file, it will:
1. Ask you for explicit approval
2. You respond confirming the change
3. Claude makes the change
4. You commit with `ALLOW_CORE_CHANGES=true`
## Installation
The git hook is automatically installed at `.git/hooks/pre-commit`.
To reinstall:
```bash
cp tools/immutability/pre_commit_hook.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
```
## Philosophy
**Simple is better than complex.** We protect the 3 files that define DSS identity, and trust human judgment for everything else.