- Create new dss/ Python package at project root - Move MCP core from tools/dss_mcp/ to dss/mcp/ - Move storage layer from tools/storage/ to dss/storage/ - Move domain logic from dss-mvp1/dss/ to dss/ - Move services from tools/api/services/ to dss/services/ - Move API server to apps/api/ - Move CLI to apps/cli/ - Move Storybook assets to storybook/ - Create unified dss/__init__.py with comprehensive exports - Merge configuration into dss/settings.py (Pydantic-based) - Create pyproject.toml for proper package management - Update startup scripts for new paths - Remove old tools/ and dss-mvp1/ directories Architecture changes: - DSS is now MCP-first with 40+ tools for Claude Code - Clean imports: from dss import Projects, Components, FigmaToolSuite - No more sys.path.insert() hacking - apps/ contains thin application wrappers (API, CLI) - Single unified Python package for all DSS logic 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
93 lines
3.3 KiB
Python
Executable File
93 lines
3.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
DSS-CLI - A command-line interface for the DSS Engine
|
|
|
|
This script provides a direct, scriptable interface to the core functionalities
|
|
of the DSS analysis and context engine. It is designed for use in CI/CD
|
|
pipelines and other automated workflows.
|
|
"""
|
|
|
|
import argparse
|
|
import json
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Ensure the script can find the 'dss' module
|
|
# This adds the parent directory of 'dss-mvp1' to the Python path
|
|
# Assuming the script is run from the project root, this will allow `from dss...` imports
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
try:
|
|
from dss.analyze.project_analyzer import run_project_analysis, export_project_context
|
|
except ImportError as e:
|
|
print(f"Error: Could not import DSS modules. Make sure dss-mvp1 is in the PYTHONPATH.", file=sys.stderr)
|
|
print(f"Import error: {e}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
|
|
def main():
|
|
"""Main function to parse arguments and dispatch commands."""
|
|
parser = argparse.ArgumentParser(
|
|
description="DSS Command Line Interface for project analysis and context management."
|
|
)
|
|
subparsers = parser.add_subparsers(dest="command", required=True, help="Available commands")
|
|
|
|
# =========================================================================
|
|
# 'analyze' command
|
|
# =========================================================================
|
|
analyze_parser = subparsers.add_parser(
|
|
"analyze",
|
|
help="Run a deep analysis of a project and save the results to .dss/analysis_graph.json"
|
|
)
|
|
analyze_parser.add_argument(
|
|
"--project-path",
|
|
required=True,
|
|
help="The root path to the project directory to be analyzed."
|
|
)
|
|
|
|
# =========================================================================
|
|
# 'export-context' command
|
|
# =========================================================================
|
|
export_parser = subparsers.add_parser(
|
|
"export-context",
|
|
help="Export the comprehensive project context as a JSON object to stdout."
|
|
)
|
|
export_parser.add_argument(
|
|
"--project-path",
|
|
required=True,
|
|
help="The path to the project directory."
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
# --- Command Dispatch ---
|
|
project_path = Path(args.project_path).resolve()
|
|
if not project_path.is_dir():
|
|
print(f"Error: Provided project path is not a valid directory: {project_path}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
try:
|
|
if args.command == "analyze":
|
|
result = run_project_analysis(str(project_path))
|
|
print(f"Analysis complete. Graph saved to {project_path / '.dss' / 'analysis_graph.json'}")
|
|
# Optionally print a summary to stdout
|
|
summary = {
|
|
"status": "success",
|
|
"nodes_created": len(result.get("nodes", [])),
|
|
"links_created": len(result.get("links", [])),
|
|
}
|
|
print(json.dumps(summary, indent=2))
|
|
|
|
elif args.command == "export-context":
|
|
result = export_project_context(str(project_path))
|
|
# Print the full context to stdout
|
|
print(json.dumps(result, indent=2))
|
|
|
|
except Exception as e:
|
|
print(json.dumps({"success": False, "error": str(e)}), file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|