Fix import paths and remove organ metaphors
Some checks failed
DSS Project Analysis / dss-context-update (push) Has been cancelled
Some checks failed
DSS Project Analysis / dss-context-update (push) Has been cancelled
- Update all `from storage.` imports to `from dss.storage.` - Update `from config import config` to use `dss.settings` - Update `from auth.` imports to `from dss.auth.` - Update health check to use `dss.mcp.handler` - Fix SmartMerger import (merger.py not smart_merger.py) - Fix TranslationDictionary import path - Fix test assertion for networkx edges/links - Remove organ/body metaphors from: - API server health check - CLI status command and help text - Admin UI logger and error handler 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,147 +1,139 @@
|
|||||||
/**
|
/**
|
||||||
* DSS Error Handler - Immune System Antibodies
|
* DSS Error Handler
|
||||||
*
|
*
|
||||||
* The DSS Component's immune system uses these antibodies to detect and report threats.
|
* Converts technical errors into user-friendly, actionable messages.
|
||||||
* Converts technical errors into human-friendly, actionable treatment plans.
|
|
||||||
* Integrates with the messaging system for structured error reporting.
|
* Integrates with the messaging system for structured error reporting.
|
||||||
*
|
*
|
||||||
* Biological Framework: These error messages use component metaphors to make
|
|
||||||
* issues intuitive. See docs/DSS_ORGANISM_GUIDE.md for the full framework.
|
|
||||||
*
|
|
||||||
* @module error-handler
|
* @module error-handler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { notifyError, ErrorCode } from './messaging.js';
|
import { notifyError, ErrorCode } from './messaging.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error message templates with component metaphors
|
* Error message templates with user-friendly descriptions
|
||||||
*
|
|
||||||
* These messages use biological language from the DSS Component Framework.
|
|
||||||
* Each error is framed as a symptom the immune system detected, with
|
|
||||||
* a diagnosis and treatment plan.
|
|
||||||
*/
|
*/
|
||||||
const errorMessages = {
|
const errorMessages = {
|
||||||
// Figma API Errors - Sensory System Issues
|
// Figma API Errors
|
||||||
figma_403: {
|
figma_403: {
|
||||||
title: '🛡️ IMMUNE ALERT: Sensory Input Blocked',
|
title: 'Access Denied',
|
||||||
message: 'The DSS sensory organs cannot perceive the Figma file. Your access credentials lack permission.',
|
message: 'Cannot access the Figma file. Your access credentials lack permission.',
|
||||||
actions: [
|
actions: [
|
||||||
'Verify your Figma authentication token in Settings (nervous system communication)',
|
'Verify your Figma authentication token in Settings',
|
||||||
'Confirm you have access to this file in Figma (sensory perception)',
|
'Confirm you have access to this file in Figma',
|
||||||
'Check if the file still exists (component awareness)',
|
'Check if the file still exists',
|
||||||
],
|
],
|
||||||
code: ErrorCode.FIGMA_API_ERROR,
|
code: ErrorCode.FIGMA_API_ERROR,
|
||||||
},
|
},
|
||||||
figma_404: {
|
figma_404: {
|
||||||
title: '🛡️ IMMUNE ALERT: Sensory Target Lost',
|
title: 'File Not Found',
|
||||||
message: 'The Figma file the DSS sensory organs were trying to perceive doesn\'t exist or is inaccessible.',
|
message: 'The Figma file doesn\'t exist or is inaccessible.',
|
||||||
actions: [
|
actions: [
|
||||||
'Double-check your Figma file key in Settings (sensory focus)',
|
'Double-check your Figma file key in Settings',
|
||||||
'Verify the file hasn\'t been deleted in Figma',
|
'Verify the file hasn\'t been deleted in Figma',
|
||||||
'Confirm you have access to the file in Figma (sensory perception)',
|
'Confirm you have access to the file in Figma',
|
||||||
],
|
],
|
||||||
code: ErrorCode.FIGMA_API_ERROR,
|
code: ErrorCode.FIGMA_API_ERROR,
|
||||||
},
|
},
|
||||||
figma_401: {
|
figma_401: {
|
||||||
title: '🔌 NERVOUS SYSTEM ALERT: Authentication Expired',
|
title: 'Authentication Failed',
|
||||||
message: 'The DSS nervous system\'s authentication with Figma has failed. Your sensory input token is invalid or expired.',
|
message: 'Figma authentication failed. Your access token is invalid or expired.',
|
||||||
actions: [
|
actions: [
|
||||||
'Refresh your Figma authentication token in Settings (nervous system repair)',
|
'Refresh your Figma authentication token in Settings',
|
||||||
'Get a fresh token from figma.com/settings (Account → Personal Access Tokens)',
|
'Get a fresh token from figma.com/settings (Account -> Personal Access Tokens)',
|
||||||
'Ensure you copied the full token without truncation',
|
'Ensure you copied the full token without truncation',
|
||||||
],
|
],
|
||||||
code: ErrorCode.FIGMA_CONNECTION_FAILED,
|
code: ErrorCode.FIGMA_CONNECTION_FAILED,
|
||||||
},
|
},
|
||||||
figma_429: {
|
figma_429: {
|
||||||
title: '⚡ METABOLISM ALERT: Sensory Overload',
|
title: 'Rate Limit Exceeded',
|
||||||
message: 'The DSS is sensing too quickly. Figma\'s rate limits have been triggered.',
|
message: 'Too many requests. Figma\'s rate limits have been triggered.',
|
||||||
actions: [
|
actions: [
|
||||||
'Let the component rest for 1-2 minutes before sensing again',
|
'Wait 1-2 minutes before trying again',
|
||||||
'Reduce how frequently the sensory system extracts data',
|
'Reduce how frequently you extract data',
|
||||||
],
|
],
|
||||||
code: ErrorCode.FIGMA_API_ERROR,
|
code: ErrorCode.FIGMA_API_ERROR,
|
||||||
},
|
},
|
||||||
figma_500: {
|
figma_500: {
|
||||||
title: '🔌 EXTERNAL SYSTEM ALERT: Figma Component Stressed',
|
title: 'Figma Server Error',
|
||||||
message: 'Figma\'s servers are experiencing stress. This is external to DSS.',
|
message: 'Figma\'s servers are experiencing issues. This is external to DSS.',
|
||||||
actions: [
|
actions: [
|
||||||
'Wait while the external component recovers',
|
'Wait and try again later',
|
||||||
'Check Figma health: status.figma.com',
|
'Check Figma status: status.figma.com',
|
||||||
],
|
],
|
||||||
code: ErrorCode.FIGMA_API_ERROR,
|
code: ErrorCode.FIGMA_API_ERROR,
|
||||||
},
|
},
|
||||||
figma_demo: {
|
figma_demo: {
|
||||||
title: '🛡️ IMMUNE ALERT: Invalid Sensory Configuration',
|
title: 'Invalid Configuration',
|
||||||
message: 'The sensory organs are configured to look at "demo" which doesn\'t exist in Figma.',
|
message: 'The Figma file key is configured to "demo" which doesn\'t exist in Figma.',
|
||||||
actions: [
|
actions: [
|
||||||
'Update Settings with your real Figma file key (configure sensory input)',
|
'Update Settings with your real Figma file key',
|
||||||
'Find your file key in the Figma URL: figma.com/file/[FILE_KEY]/...',
|
'Find your file key in the Figma URL: figma.com/file/[FILE_KEY]/...',
|
||||||
'Use the Figma file selector in Settings',
|
'Use the Figma file selector in Settings',
|
||||||
],
|
],
|
||||||
code: ErrorCode.FIGMA_INVALID_KEY,
|
code: ErrorCode.FIGMA_INVALID_KEY,
|
||||||
},
|
},
|
||||||
|
|
||||||
// API Connection Errors - Nervous System / Heart Issues
|
// API Connection Errors
|
||||||
api_network: {
|
api_network: {
|
||||||
title: '❤️ CRITICAL: Heart Not Responding',
|
title: 'Server Not Responding',
|
||||||
message: 'The DSS nervous system cannot reach the heart (server). The component is not responding.',
|
message: 'Cannot connect to the DSS server.',
|
||||||
actions: [
|
actions: [
|
||||||
'Verify the heart is beating: curl http://localhost:3456/health',
|
'Verify the server is running: curl http://localhost:3456/health',
|
||||||
'Restart the heart: cd tools/api && python3 -m uvicorn server:app --port 3456',
|
'Restart the server: ./scripts/dss start',
|
||||||
'Check your network connection to the component',
|
'Check your network connection',
|
||||||
],
|
],
|
||||||
code: ErrorCode.SYSTEM_NETWORK,
|
code: ErrorCode.SYSTEM_NETWORK,
|
||||||
},
|
},
|
||||||
api_timeout: {
|
api_timeout: {
|
||||||
title: '⚡ METABOLISM ALERT: Component Overloaded',
|
title: 'Request Timeout',
|
||||||
message: 'The DSS component took too long to respond. The heart may be stressed or metabolism sluggish.',
|
message: 'The server took too long to respond.',
|
||||||
actions: [
|
actions: [
|
||||||
'Let the component rest and try again shortly',
|
'Try again in a few moments',
|
||||||
'Check the heart\'s logs for signs of stress: tail -f /tmp/dss-demo.log',
|
'Check the server logs: ./scripts/dss logs',
|
||||||
'Reduce metabolic load (try processing smaller batches)',
|
'Try processing smaller batches',
|
||||||
],
|
],
|
||||||
code: ErrorCode.API_TIMEOUT,
|
code: ErrorCode.API_TIMEOUT,
|
||||||
},
|
},
|
||||||
api_500: {
|
api_500: {
|
||||||
title: '🧠 BRAIN ALERT: Critical Processing Error',
|
title: 'Server Error',
|
||||||
message: 'The DSS brain encountered a fatal error while processing your request.',
|
message: 'The server encountered an error while processing your request.',
|
||||||
actions: [
|
actions: [
|
||||||
'Examine the brain\'s thoughts in the logs: tail -f /tmp/dss-demo.log',
|
'Check the server logs: ./scripts/dss logs',
|
||||||
'Retry the operation to see if it recovers',
|
'Retry the operation',
|
||||||
'Report the issue if the component keeps failing',
|
'Report the issue if it persists',
|
||||||
],
|
],
|
||||||
code: ErrorCode.API_SERVER_ERROR,
|
code: ErrorCode.API_SERVER_ERROR,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Validation Errors - Immune System / Genetics
|
// Validation Errors
|
||||||
validation_missing_field: {
|
validation_missing_field: {
|
||||||
title: '🛡️ IMMUNE ALERT: DNA Incomplete',
|
title: 'Missing Required Field',
|
||||||
message: 'The genetic code (configuration) is missing essential information. The component cannot proceed.',
|
message: 'The configuration is missing required information.',
|
||||||
actions: [
|
actions: [
|
||||||
'Fill in all fields marked as required (complete the genetic code)',
|
'Fill in all fields marked as required',
|
||||||
'Ensure each input field contains valid information',
|
'Ensure each input field contains valid information',
|
||||||
],
|
],
|
||||||
code: ErrorCode.VALIDATION_MISSING_FIELD,
|
code: ErrorCode.VALIDATION_MISSING_FIELD,
|
||||||
},
|
},
|
||||||
validation_invalid_format: {
|
validation_invalid_format: {
|
||||||
title: '🛡️ IMMUNE ALERT: Genetic Mutation Detected',
|
title: 'Invalid Format',
|
||||||
message: 'One or more genetic sequences (configuration values) have an invalid format.',
|
message: 'One or more configuration values have an invalid format.',
|
||||||
actions: [
|
actions: [
|
||||||
'Verify URLs start with http:// or https:// (correct genetic sequence)',
|
'Verify URLs start with http:// or https://',
|
||||||
'Check email addresses follow standard format (valid genetic code)',
|
'Check email addresses follow standard format',
|
||||||
'Ensure file keys contain only letters, numbers, and hyphens (genetic pattern match)',
|
'Ensure file keys contain only letters, numbers, and hyphens',
|
||||||
],
|
],
|
||||||
code: ErrorCode.VALIDATION_INVALID_FORMAT,
|
code: ErrorCode.VALIDATION_INVALID_FORMAT,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Generic fallback
|
// Generic fallback
|
||||||
unknown: {
|
unknown: {
|
||||||
title: '🧬 ORGANISM ALERT: Unexplained Symptom',
|
title: 'Unexpected Error',
|
||||||
message: 'The DSS component experienced an unexpected problem. The root cause is unclear.',
|
message: 'An unexpected problem occurred.',
|
||||||
actions: [
|
actions: [
|
||||||
'Try the operation again (component may self-heal)',
|
'Try the operation again',
|
||||||
'Refresh if the issue persists (restart vitals)',
|
'Refresh the page if the issue persists',
|
||||||
'Check browser console for clues about the component\'s condition',
|
'Check browser console for details',
|
||||||
],
|
],
|
||||||
code: ErrorCode.SYSTEM_UNEXPECTED,
|
code: ErrorCode.SYSTEM_UNEXPECTED,
|
||||||
},
|
},
|
||||||
@@ -253,7 +245,7 @@ export function handleError(error, context = {}) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Log full details to console for debugging
|
// Log full details to console for debugging
|
||||||
console.group(`🔴 ${parsed.title}`);
|
console.group(`[ERROR] ${parsed.title}`);
|
||||||
console.log('Message:', parsed.message);
|
console.log('Message:', parsed.message);
|
||||||
if (parsed.actions) {
|
if (parsed.actions) {
|
||||||
console.log('Actions:', parsed.actions);
|
console.log('Actions:', parsed.actions);
|
||||||
@@ -281,23 +273,23 @@ export async function tryWithErrorHandling(fn, context = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user-friendly HTTP status message using component metaphors
|
* Get user-friendly HTTP status message
|
||||||
* @param {number} status - HTTP status code
|
* @param {number} status - HTTP status code
|
||||||
* @returns {string} User-friendly message with biological context
|
* @returns {string} User-friendly message
|
||||||
*/
|
*/
|
||||||
export function getStatusMessage(status) {
|
export function getStatusMessage(status) {
|
||||||
const messages = {
|
const messages = {
|
||||||
400: '🛡️ Genetic Code Invalid - the DNA sequence doesn\'t compile',
|
400: 'Bad Request - invalid input data',
|
||||||
401: '🔐 Authentication Failed - the nervous system can\'t verify identity',
|
401: 'Authentication Failed - invalid credentials',
|
||||||
403: '🚫 Access Forbidden - immune system rejected this component',
|
403: 'Access Forbidden - permission denied',
|
||||||
404: '👻 Target Lost - sensory organs can\'t perceive the resource',
|
404: 'Not Found - resource doesn\'t exist',
|
||||||
429: '⚡ Metabolism Overloaded - component sensing too quickly',
|
429: 'Rate Limited - too many requests',
|
||||||
500: '🧠 Brain Error - critical neural processing failure',
|
500: 'Server Error - internal processing failure',
|
||||||
502: '💀 Component Unresponsive - the heart has stopped beating',
|
502: 'Bad Gateway - server not responding',
|
||||||
503: '🏥 Component In Recovery - temporarily unable to metabolize requests',
|
503: 'Service Unavailable - temporarily unable to handle requests',
|
||||||
};
|
};
|
||||||
|
|
||||||
return messages[status] || `🔴 Unknown Component State - HTTP ${status}`;
|
return messages[status] || `Unknown Error - HTTP ${status}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -1,35 +1,28 @@
|
|||||||
/**
|
/**
|
||||||
* DSS Logger - Component Brain Consciousness System
|
* DSS Logger - Structured Logging System
|
||||||
*
|
*
|
||||||
* The DSS brain uses this logger to become conscious of what's happening.
|
* Provides structured logging with categories and levels for the DSS admin UI.
|
||||||
* Log levels represent the component's level of awareness and concern.
|
|
||||||
*
|
*
|
||||||
* Framework: DSS Component Framework
|
* Log Categories:
|
||||||
* See: docs/DSS_ORGANISM_GUIDE.md#brain
|
* 'storage' - Database operations and data persistence
|
||||||
*
|
* 'validation' - Validation, analysis, and decision making
|
||||||
* Log Categories (Organ Systems):
|
* 'api' - API calls, webhooks, communication
|
||||||
* 'heart' - ❤️ Database operations and data persistence
|
* 'parser' - Data ingestion, parsing, transformation
|
||||||
* 'brain' - 🧠 Validation, analysis, and decision making
|
* 'tokens' - Design token flow and distribution
|
||||||
* 'nervous' - 🔌 API calls, webhooks, communication
|
* 'transform' - Style-dictionary transformations
|
||||||
* 'digestive' - 🍽️ Data ingestion, parsing, transformation
|
* 'config' - Theme system and configuration
|
||||||
* 'circulatory' - 🩸 Design token flow and distribution
|
* 'security' - Validation, error detection, security
|
||||||
* 'metabolic' - ⚡ Style-dictionary transformations
|
* 'assets' - Asset loading, Figma integration
|
||||||
* 'endocrine' - 🎛️ Theme system and configuration
|
* 'ui' - UI rendering, Storybook output
|
||||||
* 'immune' - 🛡️ Validation, error detection, security
|
* 'schema' - Schema and structure validation
|
||||||
* 'sensory' - 👁️ Asset loading, Figma perception
|
|
||||||
* 'skin' - 🎨 UI rendering, Storybook output
|
|
||||||
* 'skeleton' - 🦴 Schema and structure validation
|
|
||||||
*
|
|
||||||
* Provides structured logging with biological awareness levels and optional remote logging.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Component awareness levels - how conscious is the system?
|
|
||||||
const LOG_LEVELS = {
|
const LOG_LEVELS = {
|
||||||
DEBUG: 0, // 🧠 Deep thought - brain analyzing internal processes
|
DEBUG: 0,
|
||||||
INFO: 1, // 💭 Awareness - component knows what's happening
|
INFO: 1,
|
||||||
WARN: 2, // ⚠️ Symptom - component detected something unusual
|
WARN: 2,
|
||||||
ERROR: 3, // 🛡️ Immune alert - component detected a threat
|
ERROR: 3,
|
||||||
NONE: 4 // 🌙 Sleep - component is silent
|
NONE: 4
|
||||||
};
|
};
|
||||||
|
|
||||||
class Logger {
|
class Logger {
|
||||||
@@ -76,23 +69,22 @@ class Logger {
|
|||||||
this.logs.shift();
|
this.logs.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Console output with component awareness emojis
|
const levelIcons = {
|
||||||
const levelEmojis = {
|
DEBUG: '[D]',
|
||||||
DEBUG: '🧠', // Brain thinking deeply
|
INFO: '[I]',
|
||||||
INFO: '💭', // Component aware
|
WARN: '[W]',
|
||||||
WARN: '⚠️', // Symptom detected
|
ERROR: '[E]'
|
||||||
ERROR: '🛡️' // Immune alert - threat detected
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const colors = {
|
const colors = {
|
||||||
DEBUG: 'color: #666; font-style: italic', // Gray, thoughtful
|
DEBUG: 'color: #666; font-style: italic',
|
||||||
INFO: 'color: #2196F3; font-weight: bold', // Blue, informative
|
INFO: 'color: #2196F3; font-weight: bold',
|
||||||
WARN: 'color: #FF9800; font-weight: bold', // Orange, warning
|
WARN: 'color: #FF9800; font-weight: bold',
|
||||||
ERROR: 'color: #F44336; font-weight: bold' // Red, critical
|
ERROR: 'color: #F44336; font-weight: bold'
|
||||||
};
|
};
|
||||||
|
|
||||||
const emoji = levelEmojis[level] || '🔘';
|
const icon = levelIcons[level] || '[?]';
|
||||||
const prefix = `${emoji} [${category}]`;
|
const prefix = `${icon} [${category}]`;
|
||||||
const style = colors[level] || '';
|
const style = colors[level] || '';
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -120,56 +112,49 @@ class Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 🧠 DEBUG - Brain's deep thoughts
|
* DEBUG - Detailed internal information
|
||||||
* Internal analysis and detailed consciousness
|
|
||||||
*/
|
*/
|
||||||
debug(category, message, data) {
|
debug(category, message, data) {
|
||||||
this._log('DEBUG', category, message, data);
|
this._log('DEBUG', category, message, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 💭 INFO - Component awareness
|
* INFO - General information
|
||||||
* The system knows what's happening, stays informed
|
|
||||||
*/
|
*/
|
||||||
info(category, message, data) {
|
info(category, message, data) {
|
||||||
this._log('INFO', category, message, data);
|
this._log('INFO', category, message, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ⚠️ WARN - Symptom detection
|
* WARN - Warning, something unusual detected
|
||||||
* Component detected something unusual but not critical
|
|
||||||
*/
|
*/
|
||||||
warn(category, message, data) {
|
warn(category, message, data) {
|
||||||
this._log('WARN', category, message, data);
|
this._log('WARN', category, message, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 🛡️ ERROR - Immune alert
|
* ERROR - Error, something went wrong
|
||||||
* Component detected a threat - critical consciousness
|
|
||||||
*/
|
*/
|
||||||
error(category, message, data) {
|
error(category, message, data) {
|
||||||
this._log('ERROR', category, message, data);
|
this._log('ERROR', category, message, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 📜 Get recent consciousness records
|
* Get recent log entries
|
||||||
* Retrieve the component's recent thoughts and awareness
|
|
||||||
*/
|
*/
|
||||||
getRecentLogs(count = 50) {
|
getRecentLogs(count = 50) {
|
||||||
return this.logs.slice(-count);
|
return this.logs.slice(-count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 🧠 Clear the mind
|
* Clear all logs
|
||||||
* Erase recent consciousness logs
|
|
||||||
*/
|
*/
|
||||||
clear() {
|
clear() {
|
||||||
this.logs = [];
|
this.logs = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 📤 Export consciousness
|
* Export logs to file
|
||||||
* Save the component's awareness to a file for analysis
|
|
||||||
*/
|
*/
|
||||||
export() {
|
export() {
|
||||||
const dataStr = JSON.stringify(this.logs, null, 2);
|
const dataStr = JSON.stringify(this.logs, null, 2);
|
||||||
@@ -185,13 +170,11 @@ class Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 🧠 ORGANISM CONSCIOUSNESS
|
* DSS Logger singleton
|
||||||
* Create the DSS component's brain - a singleton logger that tracks all awareness
|
|
||||||
*/
|
*/
|
||||||
const logger = new Logger('DSS', 'INFO');
|
const logger = new Logger('DSS', 'INFO');
|
||||||
|
|
||||||
// Set log level from localStorage or URL param
|
// Set log level from localStorage or URL param
|
||||||
// Allow tuning the component's consciousness level (awareness sensitivity)
|
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const logLevel = urlParams.get('log') || localStorage.getItem('dss_log_level') || 'INFO';
|
const logLevel = urlParams.get('log') || localStorage.getItem('dss_log_level') || 'INFO';
|
||||||
logger.setLevel(logLevel.toUpperCase());
|
logger.setLevel(logLevel.toUpperCase());
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ class TokenDriftCreate(BaseModel):
|
|||||||
|
|
||||||
# === Authentication ===
|
# === Authentication ===
|
||||||
|
|
||||||
from auth.atlassian_auth import get_auth
|
from dss.auth.atlassian_auth import get_auth
|
||||||
|
|
||||||
async def get_current_user(authorization: Optional[str] = Header(None)) -> Dict[str, Any]:
|
async def get_current_user(authorization: Optional[str] = Header(None)) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
@@ -421,71 +421,62 @@ async def root():
|
|||||||
@app.get("/health")
|
@app.get("/health")
|
||||||
async def health():
|
async def health():
|
||||||
"""
|
"""
|
||||||
🏥 ORGANISM VITAL SIGNS CHECK
|
Health check endpoint.
|
||||||
|
|
||||||
Performs a complete health diagnostic on the DSS component.
|
Performs a complete health diagnostic on the DSS server.
|
||||||
Returns 200 OK with vital signs if component is healthy.
|
Returns 200 OK with service status.
|
||||||
|
|
||||||
Vital Signs Checked:
|
Services Checked:
|
||||||
- ❤️ Heart (Database) - Is the source of truth responsive?
|
- Storage - Is the data directory accessible?
|
||||||
- 🧠 Brain (MCP Handler) - Is the decision-making system online?
|
- MCP Handler - Is the MCP handler initialized?
|
||||||
- 👁️ Sensory (Figma) - Are the external perception organs configured?
|
- Figma - Is the Figma integration configured?
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import psutil
|
import psutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# ❤️ Check Heart (storage) connectivity
|
# Check storage connectivity
|
||||||
db_ok = False
|
storage_ok = False
|
||||||
try:
|
try:
|
||||||
from storage.json_store import DATA_DIR
|
from dss.storage.json_store import DATA_DIR
|
||||||
db_ok = DATA_DIR.exists()
|
storage_ok = DATA_DIR.exists()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
error_trace = traceback.format_exc()
|
print(f"[Health] Storage check error: {type(e).__name__}: {e}", flush=True)
|
||||||
print(f"🏥 VITAL SIGN: Heart (storage) error: {type(e).__name__}: {e}", flush=True)
|
|
||||||
print(f" Traceback:\n{error_trace}", flush=True)
|
|
||||||
pass
|
|
||||||
|
|
||||||
# 🧠 Check Brain (MCP handler) functionality
|
# Check MCP handler functionality
|
||||||
mcp_ok = False
|
mcp_ok = False
|
||||||
try:
|
try:
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
# Add project root to path (two levels up from tools/api)
|
|
||||||
project_root = Path(__file__).parent.parent.parent
|
project_root = Path(__file__).parent.parent.parent
|
||||||
if str(project_root) not in sys.path:
|
if str(project_root) not in sys.path:
|
||||||
sys.path.insert(0, str(project_root))
|
sys.path.insert(0, str(project_root))
|
||||||
|
|
||||||
from tools.dss_mcp.handler import get_mcp_handler
|
from dss.mcp.handler import get_mcp_handler
|
||||||
handler = get_mcp_handler()
|
handler = get_mcp_handler()
|
||||||
mcp_ok = handler is not None
|
mcp_ok = handler is not None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
error_trace = ''.join(traceback.format_exception(type(e), e, e.__traceback__))
|
print(f"[Health] MCP handler check error: {type(e).__name__}: {e}", flush=True)
|
||||||
print(f"🧠 BRAIN CHECK: MCP handler error: {type(e).__name__}: {e}", flush=True)
|
|
||||||
print(f" Traceback:\n{error_trace}", flush=True)
|
|
||||||
|
|
||||||
# Get uptime (how long component has been conscious)
|
# Get uptime
|
||||||
try:
|
try:
|
||||||
process = psutil.Process(os.getpid())
|
process = psutil.Process(os.getpid())
|
||||||
uptime_seconds = int((datetime.now() - datetime.fromtimestamp(process.create_time())).total_seconds())
|
uptime_seconds = int((datetime.now() - datetime.fromtimestamp(process.create_time())).total_seconds())
|
||||||
except:
|
except:
|
||||||
uptime_seconds = 0
|
uptime_seconds = 0
|
||||||
|
|
||||||
# Overall vitality assessment
|
# Overall status
|
||||||
status = "healthy" if (db_ok and mcp_ok) else "degraded"
|
status = "healthy" if (storage_ok and mcp_ok) else "degraded"
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"status": status,
|
"status": status,
|
||||||
"vital_signs": {
|
"uptime_seconds": uptime_seconds,
|
||||||
"overall": "🟢 All systems nominal" if status == "healthy" else "🟡 System degradation detected",
|
|
||||||
"consciousness_duration_seconds": uptime_seconds
|
|
||||||
},
|
|
||||||
"version": "0.8.0",
|
"version": "0.8.0",
|
||||||
"timestamp": datetime.utcnow().isoformat() + "Z",
|
"timestamp": datetime.utcnow().isoformat() + "Z",
|
||||||
"services": {
|
"services": {
|
||||||
"storage": "ok" if db_ok else "error",
|
"storage": "ok" if storage_ok else "error",
|
||||||
"mcp": "ok" if mcp_ok else "error",
|
"mcp": "ok" if mcp_ok else "error",
|
||||||
"figma": "connected" if config.figma.is_configured else "not configured"
|
"figma": "connected" if config.figma.is_configured else "not configured"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
/**
|
/**
|
||||||
* 🧬 DSS CLI - Design System Server Organism Controller
|
* DSS CLI - Design System Server Command Line Interface
|
||||||
*
|
*
|
||||||
* A portable companion for UI developers - think of it as the organism's
|
* A portable companion for UI developers. Commands:
|
||||||
* command-line nervous system. Through these commands, you can:
|
|
||||||
*
|
*
|
||||||
* - 🧬 Awaken a new organism (init)
|
* - init: Initialize DSS in a project
|
||||||
* - 💚 Check the organism's vital signs (status)
|
* - status: Check server status
|
||||||
* - 🩸 Direct the sensory organs to perceive Figma (extract)
|
* - extract: Extract tokens/components from Figma
|
||||||
* - 🔄 Circulate extracted nutrients (sync)
|
* - sync: Sync tokens to codebase
|
||||||
* - ⚙️ Adjust the organism's behavior (config)
|
* - config: Manage configuration
|
||||||
* - 🧠 Birth a conscious instance (start)
|
* - start: Start the server
|
||||||
*
|
* - stop: Stop the server
|
||||||
* Framework: DSS Organism Framework
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
@@ -29,63 +27,63 @@ const program = new Command();
|
|||||||
|
|
||||||
program
|
program
|
||||||
.name('dss')
|
.name('dss')
|
||||||
.description('🧬 Design System Server - Organism Controller for UI Developers')
|
.description('Design System Server - CLI for UI Developers')
|
||||||
.version('0.1.0');
|
.version('0.1.0');
|
||||||
|
|
||||||
// Init command - setup DSS in a project
|
// Init command - setup DSS in a project
|
||||||
program
|
program
|
||||||
.command('init')
|
.command('init')
|
||||||
.description('🧬 ORGANISM GENESIS - Create a new design system organism in your project')
|
.description('Initialize DSS in your project')
|
||||||
.option('-f, --figma-key <key>', 'Link to Figma genetic blueprint')
|
.option('-f, --figma-key <key>', 'Figma file key')
|
||||||
.option('-t, --figma-token <token>', 'Figma sensory organ connection token')
|
.option('-t, --figma-token <token>', 'Figma access token')
|
||||||
.action(initCommand);
|
.action(initCommand);
|
||||||
|
|
||||||
// Start command - start the DSS server
|
// Start command - start the DSS server
|
||||||
program
|
program
|
||||||
.command('start')
|
.command('start')
|
||||||
.description('💚 ORGANISM AWAKENING - Bring the design system organism to life')
|
.description('Start the DSS server')
|
||||||
.option('-p, --port <port>', 'Neural pathway port', '3456')
|
.option('-p, --port <port>', 'Server port', '3456')
|
||||||
.option('-d, --dev', 'Live consciousness mode with hot-reload')
|
.option('-d, --dev', 'Development mode with hot-reload')
|
||||||
.option('--no-open', 'Do not open sensory interface')
|
.option('--no-open', 'Do not open browser')
|
||||||
.action(startCommand);
|
.action(startCommand);
|
||||||
|
|
||||||
// Sync command - sync tokens from Figma
|
// Sync command - sync tokens from Figma
|
||||||
program
|
program
|
||||||
.command('sync')
|
.command('sync')
|
||||||
.description('🩸 NUTRIENT CIRCULATION - Distribute extracted tokens through the codebase')
|
.description('Sync tokens from Figma to codebase')
|
||||||
.option('-f, --format <format>', 'Nutrient format: css, scss, json, ts', 'css')
|
.option('-f, --format <format>', 'Output format: css, scss, json, ts', 'css')
|
||||||
.option('-o, --output <path>', 'Circulation destination')
|
.option('-o, --output <path>', 'Output directory')
|
||||||
.option('--file-key <key>', 'Figma file key (overrides config)')
|
.option('--file-key <key>', 'Figma file key (overrides config)')
|
||||||
.action(syncCommand);
|
.action(syncCommand);
|
||||||
|
|
||||||
// Extract command - extract components or tokens
|
// Extract command - extract components or tokens
|
||||||
program
|
program
|
||||||
.command('extract <type>')
|
.command('extract <type>')
|
||||||
.description('👁️ SENSORY PERCEPTION - Direct organism eyes to perceive Figma designs')
|
.description('Extract components or tokens from Figma')
|
||||||
.option('-f, --format <format>', 'Perception output format', 'json')
|
.option('-f, --format <format>', 'Output format', 'json')
|
||||||
.option('-o, --output <path>', 'Memory storage location')
|
.option('-o, --output <path>', 'Output location')
|
||||||
.option('--file-key <key>', 'Figma file key')
|
.option('--file-key <key>', 'Figma file key')
|
||||||
.action(extractCommand);
|
.action(extractCommand);
|
||||||
|
|
||||||
// Config command - manage configuration
|
// Config command - manage configuration
|
||||||
program
|
program
|
||||||
.command('config')
|
.command('config')
|
||||||
.description('⚙️ ENDOCRINE ADJUSTMENT - Configure organism behavior and preferences')
|
.description('Manage DSS configuration')
|
||||||
.option('--set <key=value>', 'Set organism hormone value')
|
.option('--set <key=value>', 'Set configuration value')
|
||||||
.option('--get <key>', 'Read organism hormone value')
|
.option('--get <key>', 'Get configuration value')
|
||||||
.option('--list', 'View all hormones')
|
.option('--list', 'List all configuration')
|
||||||
.action(configCommand);
|
.action(configCommand);
|
||||||
|
|
||||||
// Stop command - stop the server
|
// Stop command - stop the server
|
||||||
program
|
program
|
||||||
.command('stop')
|
.command('stop')
|
||||||
.description('😴 ORGANISM REST - Put the design system organism into sleep mode')
|
.description('Stop the DSS server')
|
||||||
.action(stopCommand);
|
.action(stopCommand);
|
||||||
|
|
||||||
// Status command - check DSS status
|
// Status command - check DSS status
|
||||||
program
|
program
|
||||||
.command('status')
|
.command('status')
|
||||||
.description('🏥 VITAL SIGNS CHECK - Monitor organism health and configuration')
|
.description('Check DSS server status and configuration')
|
||||||
.action(statusCommand);
|
.action(statusCommand);
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* 🏥 DSS Status Command - Organism Vital Signs
|
* DSS Status Command
|
||||||
*
|
*
|
||||||
* Check DSS design system organism's vital signs, consciousness state,
|
* Check DSS server status and configuration.
|
||||||
* and sensory organ configuration.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
@@ -15,48 +14,48 @@ export async function statusCommand(): Promise<void> {
|
|||||||
const config = getConfig();
|
const config = getConfig();
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log(chalk.cyan(' 🏥 ORGANISM VITAL SIGNS'));
|
console.log(chalk.cyan(' DSS Status'));
|
||||||
console.log(chalk.dim(' ────────────────────────'));
|
console.log(chalk.dim(' ────────────────────────'));
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
// Organism status
|
// Project status
|
||||||
if (hasProjectConfig()) {
|
if (hasProjectConfig()) {
|
||||||
console.log(chalk.green(' 🧬 Organism:'), chalk.dim('Born and conscious'));
|
console.log(chalk.green(' Project:'), chalk.dim('Initialized'));
|
||||||
console.log(chalk.dim(` Home: ${cwd}`));
|
console.log(chalk.dim(` Root: ${cwd}`));
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.yellow(' 🧬 Organism:'), chalk.dim('Not yet born'));
|
console.log(chalk.yellow(' Project:'), chalk.dim('Not initialized'));
|
||||||
console.log(chalk.dim(' Genesis: dss init'));
|
console.log(chalk.dim(' Initialize: dss init'));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
// Consciousness status (server)
|
// Server status
|
||||||
const running = isServerRunning(cwd);
|
const running = isServerRunning(cwd);
|
||||||
const pid = getServerPid(cwd);
|
const pid = getServerPid(cwd);
|
||||||
const port = config.port || 3456;
|
const port = config.port || 3456;
|
||||||
|
|
||||||
if (running) {
|
if (running) {
|
||||||
console.log(chalk.green(' 💚 Consciousness:'), chalk.dim(`Awake (PID: ${pid})`));
|
console.log(chalk.green(' Server:'), chalk.dim(`Running (PID: ${pid})`));
|
||||||
console.log(chalk.dim(` Neural port: http://localhost:${port}`));
|
console.log(chalk.dim(` URL: http://localhost:${port}`));
|
||||||
|
|
||||||
// Try to get health info
|
// Try to get health info
|
||||||
try {
|
try {
|
||||||
const api = getApiClient({ port });
|
const api = getApiClient({ port });
|
||||||
const health = await api.health();
|
const health = await api.health();
|
||||||
console.log(chalk.dim(` Awareness: ${health.figma_mode}`));
|
console.log(chalk.dim(` Mode: ${health.figma_mode}`));
|
||||||
} catch {
|
} catch {
|
||||||
console.log(chalk.yellow(' ⚠️ Unable to read consciousness'));
|
console.log(chalk.yellow(' Unable to get health status'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.yellow(' 💚 Consciousness:'), chalk.dim('Sleeping'));
|
console.log(chalk.yellow(' Server:'), chalk.dim('Stopped'));
|
||||||
console.log(chalk.dim(' Awaken: dss start'));
|
console.log(chalk.dim(' Start: dss start'));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
// Sensory organs (Figma)
|
// Figma integration
|
||||||
if (config.figmaToken) {
|
if (config.figmaToken) {
|
||||||
console.log(chalk.green(' 👁️ Sensory Eyes:'), chalk.dim('Configured'));
|
console.log(chalk.green(' Figma:'), chalk.dim('Configured'));
|
||||||
|
|
||||||
// Test connection if server is running
|
// Test connection if server is running
|
||||||
if (running) {
|
if (running) {
|
||||||
@@ -64,21 +63,21 @@ export async function statusCommand(): Promise<void> {
|
|||||||
const api = getApiClient({ port });
|
const api = getApiClient({ port });
|
||||||
const test = await api.testFigmaConnection();
|
const test = await api.testFigmaConnection();
|
||||||
if (test.success) {
|
if (test.success) {
|
||||||
console.log(chalk.green(' Perception:'), chalk.dim(`Clear (${test.user})`));
|
console.log(chalk.green(' Connection:'), chalk.dim(`OK (${test.user})`));
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.red(' Perception:'), chalk.dim(test.error || 'Blinded'));
|
console.log(chalk.red(' Connection:'), chalk.dim(test.error || 'Failed'));
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
console.log(chalk.yellow(' Perception:'), chalk.dim('Cannot test'));
|
console.log(chalk.yellow(' Connection:'), chalk.dim('Cannot test'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.yellow(' 👁️ Sensory Eyes:'), chalk.dim('Not configured'));
|
console.log(chalk.yellow(' Figma:'), chalk.dim('Not configured'));
|
||||||
console.log(chalk.dim(' Configure: dss config --set figmaToken=figd_xxxxx'));
|
console.log(chalk.dim(' Configure: dss config --set figmaToken=figd_xxxxx'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.figmaFileKey) {
|
if (config.figmaFileKey) {
|
||||||
console.log(chalk.green(' 📋 Genetic Blueprint:'), chalk.dim(config.figmaFileKey));
|
console.log(chalk.green(' Figma File:'), chalk.dim(config.figmaFileKey));
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.yellow(' Figma File:'), chalk.dim('Not configured'));
|
console.log(chalk.yellow(' Figma File:'), chalk.dim('Not configured'));
|
||||||
console.log(chalk.dim(' Set: dss config --set figmaFileKey=abc123'));
|
console.log(chalk.dim(' Set: dss config --set figmaFileKey=abc123'));
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
/**
|
/**
|
||||||
* 🧬 DSS CLI - Design System Server Organism Controller
|
* DSS CLI - Design System Server Command Line Interface
|
||||||
*
|
*
|
||||||
* A portable companion for UI developers - think of it as the organism's
|
* A portable companion for UI developers. Commands:
|
||||||
* command-line nervous system. Through these commands, you can:
|
|
||||||
*
|
*
|
||||||
* - 🧬 Awaken a new organism (init)
|
* - init: Initialize DSS in a project
|
||||||
* - 💚 Check the organism's vital signs (status)
|
* - status: Check server status
|
||||||
* - 🩸 Direct the sensory organs to perceive Figma (extract)
|
* - extract: Extract tokens/components from Figma
|
||||||
* - 🔄 Circulate extracted nutrients (sync)
|
* - sync: Sync tokens to codebase
|
||||||
* - ⚙️ Adjust the organism's behavior (config)
|
* - config: Manage configuration
|
||||||
* - 🧠 Birth a conscious instance (start)
|
* - start: Start the server
|
||||||
*
|
* - stop: Stop the server
|
||||||
* Framework: DSS Organism Framework
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Command } from 'commander';
|
import { Command } from 'commander';
|
||||||
@@ -29,63 +27,63 @@ const program = new Command();
|
|||||||
|
|
||||||
program
|
program
|
||||||
.name('dss')
|
.name('dss')
|
||||||
.description('🧬 Design System Server - Organism Controller for UI Developers')
|
.description('Design System Server - CLI for UI Developers')
|
||||||
.version('0.1.0');
|
.version('0.1.0');
|
||||||
|
|
||||||
// Init command - setup DSS in a project
|
// Init command - setup DSS in a project
|
||||||
program
|
program
|
||||||
.command('init')
|
.command('init')
|
||||||
.description('🧬 ORGANISM GENESIS - Create a new design system organism in your project')
|
.description('Initialize DSS in your project')
|
||||||
.option('-f, --figma-key <key>', 'Link to Figma genetic blueprint')
|
.option('-f, --figma-key <key>', 'Figma file key')
|
||||||
.option('-t, --figma-token <token>', 'Figma sensory organ connection token')
|
.option('-t, --figma-token <token>', 'Figma access token')
|
||||||
.action(initCommand);
|
.action(initCommand);
|
||||||
|
|
||||||
// Start command - start the DSS server
|
// Start command - start the DSS server
|
||||||
program
|
program
|
||||||
.command('start')
|
.command('start')
|
||||||
.description('💚 ORGANISM AWAKENING - Bring the design system organism to life')
|
.description('Start the DSS server')
|
||||||
.option('-p, --port <port>', 'Neural pathway port', '3456')
|
.option('-p, --port <port>', 'Server port', '3456')
|
||||||
.option('-d, --dev', 'Live consciousness mode with hot-reload')
|
.option('-d, --dev', 'Development mode with hot-reload')
|
||||||
.option('--no-open', 'Do not open sensory interface')
|
.option('--no-open', 'Do not open browser')
|
||||||
.action(startCommand);
|
.action(startCommand);
|
||||||
|
|
||||||
// Sync command - sync tokens from Figma
|
// Sync command - sync tokens from Figma
|
||||||
program
|
program
|
||||||
.command('sync')
|
.command('sync')
|
||||||
.description('🩸 NUTRIENT CIRCULATION - Distribute extracted tokens through the codebase')
|
.description('Sync tokens from Figma to codebase')
|
||||||
.option('-f, --format <format>', 'Nutrient format: css, scss, json, ts', 'css')
|
.option('-f, --format <format>', 'Output format: css, scss, json, ts', 'css')
|
||||||
.option('-o, --output <path>', 'Circulation destination')
|
.option('-o, --output <path>', 'Output directory')
|
||||||
.option('--file-key <key>', 'Figma file key (overrides config)')
|
.option('--file-key <key>', 'Figma file key (overrides config)')
|
||||||
.action(syncCommand);
|
.action(syncCommand);
|
||||||
|
|
||||||
// Extract command - extract components or tokens
|
// Extract command - extract components or tokens
|
||||||
program
|
program
|
||||||
.command('extract <type>')
|
.command('extract <type>')
|
||||||
.description('👁️ SENSORY PERCEPTION - Direct organism eyes to perceive Figma designs')
|
.description('Extract components or tokens from Figma')
|
||||||
.option('-f, --format <format>', 'Perception output format', 'json')
|
.option('-f, --format <format>', 'Output format', 'json')
|
||||||
.option('-o, --output <path>', 'Memory storage location')
|
.option('-o, --output <path>', 'Output location')
|
||||||
.option('--file-key <key>', 'Figma file key')
|
.option('--file-key <key>', 'Figma file key')
|
||||||
.action(extractCommand);
|
.action(extractCommand);
|
||||||
|
|
||||||
// Config command - manage configuration
|
// Config command - manage configuration
|
||||||
program
|
program
|
||||||
.command('config')
|
.command('config')
|
||||||
.description('⚙️ ENDOCRINE ADJUSTMENT - Configure organism behavior and preferences')
|
.description('Manage DSS configuration')
|
||||||
.option('--set <key=value>', 'Set organism hormone value')
|
.option('--set <key=value>', 'Set configuration value')
|
||||||
.option('--get <key>', 'Read organism hormone value')
|
.option('--get <key>', 'Get configuration value')
|
||||||
.option('--list', 'View all hormones')
|
.option('--list', 'List all configuration')
|
||||||
.action(configCommand);
|
.action(configCommand);
|
||||||
|
|
||||||
// Stop command - stop the server
|
// Stop command - stop the server
|
||||||
program
|
program
|
||||||
.command('stop')
|
.command('stop')
|
||||||
.description('😴 ORGANISM REST - Put the design system organism into sleep mode')
|
.description('Stop the DSS server')
|
||||||
.action(stopCommand);
|
.action(stopCommand);
|
||||||
|
|
||||||
// Status command - check DSS status
|
// Status command - check DSS status
|
||||||
program
|
program
|
||||||
.command('status')
|
.command('status')
|
||||||
.description('🏥 VITAL SIGNS CHECK - Monitor organism health and configuration')
|
.description('Check DSS server status and configuration')
|
||||||
.action(statusCommand);
|
.action(statusCommand);
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* 🏥 DSS Status Command - Organism Vital Signs
|
* DSS Status Command
|
||||||
*
|
*
|
||||||
* Check DSS design system organism's vital signs, consciousness state,
|
* Check DSS server status and configuration.
|
||||||
* and sensory organ configuration.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
@@ -15,48 +14,48 @@ export async function statusCommand(): Promise<void> {
|
|||||||
const config = getConfig();
|
const config = getConfig();
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log(chalk.cyan(' 🏥 ORGANISM VITAL SIGNS'));
|
console.log(chalk.cyan(' DSS Status'));
|
||||||
console.log(chalk.dim(' ────────────────────────'));
|
console.log(chalk.dim(' ────────────────────────'));
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
// Organism status
|
// Project status
|
||||||
if (hasProjectConfig()) {
|
if (hasProjectConfig()) {
|
||||||
console.log(chalk.green(' 🧬 Organism:'), chalk.dim('Born and conscious'));
|
console.log(chalk.green(' Project:'), chalk.dim('Initialized'));
|
||||||
console.log(chalk.dim(` Home: ${cwd}`));
|
console.log(chalk.dim(` Root: ${cwd}`));
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.yellow(' 🧬 Organism:'), chalk.dim('Not yet born'));
|
console.log(chalk.yellow(' Project:'), chalk.dim('Not initialized'));
|
||||||
console.log(chalk.dim(' Genesis: dss init'));
|
console.log(chalk.dim(' Initialize: dss init'));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
// Consciousness status (server)
|
// Server status
|
||||||
const running = isServerRunning(cwd);
|
const running = isServerRunning(cwd);
|
||||||
const pid = getServerPid(cwd);
|
const pid = getServerPid(cwd);
|
||||||
const port = config.port || 3456;
|
const port = config.port || 3456;
|
||||||
|
|
||||||
if (running) {
|
if (running) {
|
||||||
console.log(chalk.green(' 💚 Consciousness:'), chalk.dim(`Awake (PID: ${pid})`));
|
console.log(chalk.green(' Server:'), chalk.dim(`Running (PID: ${pid})`));
|
||||||
console.log(chalk.dim(` Neural port: http://localhost:${port}`));
|
console.log(chalk.dim(` URL: http://localhost:${port}`));
|
||||||
|
|
||||||
// Try to get health info
|
// Try to get health info
|
||||||
try {
|
try {
|
||||||
const api = getApiClient({ port });
|
const api = getApiClient({ port });
|
||||||
const health = await api.health();
|
const health = await api.health();
|
||||||
console.log(chalk.dim(` Awareness: ${health.figma_mode}`));
|
console.log(chalk.dim(` Mode: ${health.figma_mode}`));
|
||||||
} catch {
|
} catch {
|
||||||
console.log(chalk.yellow(' ⚠️ Unable to read consciousness'));
|
console.log(chalk.yellow(' Unable to get health status'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.yellow(' 💚 Consciousness:'), chalk.dim('Sleeping'));
|
console.log(chalk.yellow(' Server:'), chalk.dim('Stopped'));
|
||||||
console.log(chalk.dim(' Awaken: dss start'));
|
console.log(chalk.dim(' Start: dss start'));
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
// Sensory organs (Figma)
|
// Figma integration
|
||||||
if (config.figmaToken) {
|
if (config.figmaToken) {
|
||||||
console.log(chalk.green(' 👁️ Sensory Eyes:'), chalk.dim('Configured'));
|
console.log(chalk.green(' Figma:'), chalk.dim('Configured'));
|
||||||
|
|
||||||
// Test connection if server is running
|
// Test connection if server is running
|
||||||
if (running) {
|
if (running) {
|
||||||
@@ -64,21 +63,21 @@ export async function statusCommand(): Promise<void> {
|
|||||||
const api = getApiClient({ port });
|
const api = getApiClient({ port });
|
||||||
const test = await api.testFigmaConnection();
|
const test = await api.testFigmaConnection();
|
||||||
if (test.success) {
|
if (test.success) {
|
||||||
console.log(chalk.green(' Perception:'), chalk.dim(`Clear (${test.user})`));
|
console.log(chalk.green(' Connection:'), chalk.dim(`OK (${test.user})`));
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.red(' Perception:'), chalk.dim(test.error || 'Blinded'));
|
console.log(chalk.red(' Connection:'), chalk.dim(test.error || 'Failed'));
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
console.log(chalk.yellow(' Perception:'), chalk.dim('Cannot test'));
|
console.log(chalk.yellow(' Connection:'), chalk.dim('Cannot test'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.yellow(' 👁️ Sensory Eyes:'), chalk.dim('Not configured'));
|
console.log(chalk.yellow(' Figma:'), chalk.dim('Not configured'));
|
||||||
console.log(chalk.dim(' Configure: dss config --set figmaToken=figd_xxxxx'));
|
console.log(chalk.dim(' Configure: dss config --set figmaToken=figd_xxxxx'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.figmaFileKey) {
|
if (config.figmaFileKey) {
|
||||||
console.log(chalk.green(' 📋 Genetic Blueprint:'), chalk.dim(config.figmaFileKey));
|
console.log(chalk.green(' Figma File:'), chalk.dim(config.figmaFileKey));
|
||||||
} else {
|
} else {
|
||||||
console.log(chalk.yellow(' Figma File:'), chalk.dim('Not configured'));
|
console.log(chalk.yellow(' Figma File:'), chalk.dim('Not configured'));
|
||||||
console.log(chalk.dim(' Set: dss config --set figmaFileKey=abc123'));
|
console.log(chalk.dim(' Set: dss config --set figmaFileKey=abc123'));
|
||||||
|
|||||||
@@ -56,15 +56,14 @@ from dss.ingest.base import (
|
|||||||
|
|
||||||
# Export/Import
|
# Export/Import
|
||||||
from dss.export_import.service import DSSArchiveExporter, DSSArchiveImporter
|
from dss.export_import.service import DSSArchiveExporter, DSSArchiveImporter
|
||||||
from dss.export_import.smart_merger import SmartMerger
|
from dss.export_import.merger import SmartMerger
|
||||||
|
|
||||||
# Storybook
|
# Storybook
|
||||||
from dss.storybook.generator import StoryGenerator
|
from dss.storybook.generator import StoryGenerator
|
||||||
from dss.storybook.scanner import StorybookScanner
|
from dss.storybook.scanner import StorybookScanner
|
||||||
|
|
||||||
# Translations
|
# Translations
|
||||||
from dss.translations.dictionary import TranslationDictionary
|
from dss.translations import TranslationDictionary, TokenResolver
|
||||||
from dss.translations.resolver import TokenResolver
|
|
||||||
|
|
||||||
# Services
|
# Services
|
||||||
from dss.services.project_manager import ProjectManager
|
from dss.services.project_manager import ProjectManager
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from datetime import datetime, timedelta
|
|||||||
from typing import Optional, Dict, Any
|
from typing import Optional, Dict, Any
|
||||||
from atlassian import Jira, Confluence
|
from atlassian import Jira, Confluence
|
||||||
|
|
||||||
from storage.json_store import read_json, write_json, SYSTEM_DIR
|
from dss.storage.json_store import read_json, write_json, SYSTEM_DIR
|
||||||
|
|
||||||
|
|
||||||
class AtlassianAuth:
|
class AtlassianAuth:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from .security import TimestampConflictResolver
|
|||||||
from ..models.project import Project
|
from ..models.project import Project
|
||||||
from ..models.theme import DesignToken
|
from ..models.theme import DesignToken
|
||||||
from ..models.component import Component
|
from ..models.component import Component
|
||||||
from storage.json_store import Projects, Components, Tokens
|
from dss.storage.json_store import Projects, Components, Tokens
|
||||||
|
|
||||||
|
|
||||||
MergeStrategy = Literal["overwrite", "keep_local", "fork", "skip"]
|
MergeStrategy = Literal["overwrite", "keep_local", "fork", "skip"]
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from .importer import DSSArchiveImporter, ImportAnalysis
|
|||||||
from .merger import SmartMerger, ConflictResolutionMode, MergeAnalysis
|
from .merger import SmartMerger, ConflictResolutionMode, MergeAnalysis
|
||||||
from .security import DatabaseLockingStrategy, MemoryLimitManager
|
from .security import DatabaseLockingStrategy, MemoryLimitManager
|
||||||
from ..models.project import Project
|
from ..models.project import Project
|
||||||
from storage.json_store import Projects, ActivityLog
|
from dss.storage.json_store import Projects, ActivityLog
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -19,18 +19,14 @@ Tools:
|
|||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import asyncio
|
import asyncio
|
||||||
import sys
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Optional, Dict, List, Any
|
from typing import Optional, Dict, List, Any
|
||||||
from dataclasses import dataclass, asdict
|
from dataclasses import dataclass, asdict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
# Add parent to path for imports
|
from dss.settings import settings
|
||||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
from dss.storage.json_store import Cache, ActivityLog
|
||||||
|
|
||||||
from config import config
|
|
||||||
from storage.json_store import Cache, ActivityLog
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DesignToken:
|
class DesignToken:
|
||||||
@@ -67,9 +63,9 @@ class FigmaClient:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, token: Optional[str] = None):
|
def __init__(self, token: Optional[str] = None):
|
||||||
self.token = token or config.figma.token
|
self.token = token or settings.FIGMA_TOKEN
|
||||||
self.base_url = "https://api.figma.com/v1"
|
self.base_url = "https://api.figma.com/v1"
|
||||||
self.cache_ttl = config.figma.cache_ttl
|
self.cache_ttl = settings.FIGMA_CACHE_TTL
|
||||||
self._use_real_api = bool(self.token)
|
self._use_real_api = bool(self.token)
|
||||||
|
|
||||||
def _cache_key(self, endpoint: str) -> str:
|
def _cache_key(self, endpoint: str) -> str:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from typing import Optional, Dict, Any
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from storage.json_store import ActivityLog, append_jsonl, read_jsonl, SYSTEM_DIR # JSON storage
|
from dss.storage.json_store import ActivityLog, append_jsonl, read_jsonl, SYSTEM_DIR # JSON storage
|
||||||
|
|
||||||
|
|
||||||
class AuditEventType(Enum):
|
class AuditEventType(Enum):
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from pathlib import Path
|
|||||||
import sys
|
import sys
|
||||||
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
|
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
|
||||||
|
|
||||||
from storage.json_store import Projects, Components, Tokens
|
from dss.storage.json_store import Projects, Components, Tokens
|
||||||
from analyze.scanner import ProjectScanner
|
from analyze.scanner import ProjectScanner
|
||||||
from ..config import mcp_config
|
from ..config import mcp_config
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ from pathlib import Path
|
|||||||
# Note: sys.path is set up by the importing module (server.py)
|
# Note: sys.path is set up by the importing module (server.py)
|
||||||
# Do NOT modify sys.path here as it causes relative import issues
|
# Do NOT modify sys.path here as it causes relative import issues
|
||||||
|
|
||||||
from storage.json_store import Projects, ActivityLog
|
from dss.storage.json_store import Projects, ActivityLog
|
||||||
from .config import mcp_config, integration_config
|
from .config import mcp_config, integration_config
|
||||||
from .context.project_context import get_context_manager, ProjectContext
|
from .context.project_context import get_context_manager, ProjectContext
|
||||||
from .tools.project_tools import PROJECT_TOOLS, ProjectTools
|
from .tools.project_tools import PROJECT_TOOLS, ProjectTools
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from datetime import datetime, timedelta
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from ..config import mcp_config
|
from ..config import mcp_config
|
||||||
from storage.json_store import Cache, read_json, write_json, SYSTEM_DIR
|
from dss.storage.json_store import Cache, read_json, write_json, SYSTEM_DIR
|
||||||
|
|
||||||
|
|
||||||
class CircuitState(Enum):
|
class CircuitState(Enum):
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from datetime import datetime
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from .config import mcp_config
|
from .config import mcp_config
|
||||||
from storage.json_store import ActivityLog, read_json, write_json, DATA_DIR # JSON storage
|
from dss.storage.json_store import ActivityLog, read_json, write_json, DATA_DIR # JSON storage
|
||||||
|
|
||||||
|
|
||||||
class OperationStatus(Enum):
|
class OperationStatus(Enum):
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
|||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
|
|
||||||
from .config import mcp_config
|
from .config import mcp_config
|
||||||
from storage.json_store import read_json, write_json, SYSTEM_DIR # JSON storage
|
from dss.storage.json_store import read_json, write_json, SYSTEM_DIR # JSON storage
|
||||||
|
|
||||||
|
|
||||||
class CredentialVault:
|
class CredentialVault:
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from mcp import types
|
|||||||
from ..context.project_context import get_context_manager
|
from ..context.project_context import get_context_manager
|
||||||
from ..security import CredentialVault
|
from ..security import CredentialVault
|
||||||
from ..audit import AuditLog, AuditEventType
|
from ..audit import AuditLog, AuditEventType
|
||||||
from storage.json_store import Projects, Components, Tokens, ActivityLog # JSON storage
|
from dss.storage.json_store import Projects, Components, Tokens, ActivityLog # JSON storage
|
||||||
from ..handler import get_mcp_handler, MCPContext
|
from ..handler import get_mcp_handler, MCPContext
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class ProjectManager:
|
|||||||
Initialize project manager.
|
Initialize project manager.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
projects_db: Projects database class (from storage.database)
|
projects_db: Projects database class (from dss.storage.database)
|
||||||
config_service: Optional ConfigService for config initialization
|
config_service: Optional ConfigService for config initialization
|
||||||
"""
|
"""
|
||||||
self.db = projects_db
|
self.db = projects_db
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ class StatusDashboard:
|
|||||||
|
|
||||||
# Database stats
|
# Database stats
|
||||||
try:
|
try:
|
||||||
from storage.json_store import get_stats, ActivityLog, SyncHistory, Projects, Components
|
from dss.storage.json_store import get_stats, ActivityLog, SyncHistory, Projects, Components
|
||||||
|
|
||||||
stats = get_stats()
|
stats = get_stats()
|
||||||
data.projects_count = stats.get("projects", 0)
|
data.projects_count = stats.get("projects", 0)
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ def test_run_project_analysis(mock_react_project: Path):
|
|||||||
|
|
||||||
# Verify the graph structure
|
# Verify the graph structure
|
||||||
assert "nodes" in data, "Graph data should contain 'nodes'."
|
assert "nodes" in data, "Graph data should contain 'nodes'."
|
||||||
assert "links" in data, "Graph data should contain 'links'."
|
# networkx uses 'edges' in newer versions (previously 'links')
|
||||||
|
assert "edges" in data or "links" in data, "Graph data should contain 'edges' or 'links'."
|
||||||
|
|
||||||
# Get a list of node IDs (which are the relative file paths)
|
# Get a list of node IDs (which are the relative file paths)
|
||||||
node_ids = [node['id'] for node in data['nodes']]
|
node_ids = [node['id'] for node in data['nodes']]
|
||||||
|
|||||||
Reference in New Issue
Block a user