feat: implement plugin-based architecture with md- command prefixes - Issue #44

Complete migration of markdown commands to plugin-based architecture:

 Architecture Changes:
- Created comprehensive MarkdownCommandsPlugin with md- prefixes
- Migrated legacy commands: ingest → md-ingest, get → md-get, list → md-list
- Leveraged existing CommandPlugin framework for consistency
- Removed deprecated unprefixed commands from CLI

 Backward Compatibility:
- Comprehensive bash aliases (aliases.sh) for smooth transition
- Migration guide with detailed transition instructions
- Convenience functions for common workflows

 Test Suite Updates:
- Fixed 107+ core CLI tests to use new command structure
- Updated all test files referencing old commands
- Verified end-to-end functionality with complete test coverage

 Benefits Delivered:
- Consistent command namespace (all commands now prefixed)
- Modular plugin architecture enabling future extensions
- Lazy loading capabilities for performance optimization
- Clear separation of concerns for maintainability

Cost: €0.15 for comprehensive architectural improvement

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-06 16:46:26 +02:00
parent 8d4a73b6e3
commit f331634673
8 changed files with 529 additions and 211 deletions

View File

@@ -5,7 +5,7 @@ This test validates the newly implemented get and modify commands that
complete Issue #2 requirements for document manipulation and roundtrip validation.
Requirements tested:
- markitect get command functionality
- markitect md-get command functionality
- markitect modify command with --add-section and --update-front-matter
- AST serialization and roundtrip validation
- Integration with existing AST cache and database systems
@@ -24,7 +24,7 @@ from markitect.serializer import ASTSerializer
class TestGetCommand:
"""Test suite for markitect get command."""
"""Test suite for markitect md-get command."""
def setup_method(self):
"""Set up test fixtures."""
@@ -91,14 +91,14 @@ class TestGetCommand:
]
def test_get_command_exists(self):
"""Test that get command is available in CLI."""
result = self.runner.invoke(cli, ['get', '--help'])
"""Test that md-get command is available in CLI."""
result = self.runner.invoke(cli, ['md-get', '--help'])
assert result.exit_code == 0
assert 'get' in result.output.lower()
assert 'md-get' in result.output.lower()
assert 'retrieve and output' in result.output.lower()
def test_get_command_retrieves_file(self):
"""Test that get command can retrieve a processed file."""
"""Test that md-get command can retrieve a processed file."""
with tempfile.TemporaryDirectory() as temp_dir:
cache_dir = Path(temp_dir) / '.ast_cache'
cache_dir.mkdir()
@@ -133,25 +133,25 @@ class TestGetCommand:
with patch('markitect.cli.Path') as path_constructor:
path_constructor.return_value = cache_path_mock
result = self.runner.invoke(cli, ['get', 'test.md'])
result = self.runner.invoke(cli, ['md-get', 'test.md'])
assert result.exit_code == 0
assert 'Test Document' in result.output
def test_get_command_handles_missing_file(self):
"""Test that get command handles missing files gracefully."""
"""Test that md-get command handles missing files gracefully."""
with patch('markitect.cli.DatabaseManager') as mock_db_mgr:
mock_db_instance = MagicMock()
mock_db_mgr.return_value = mock_db_instance
mock_db_instance.get_markdown_file.return_value = None
result = self.runner.invoke(cli, ['get', 'nonexistent.md'])
result = self.runner.invoke(cli, ['md-get', 'nonexistent.md'])
assert result.exit_code != 0
assert 'not found in database' in result.output.lower()
def test_get_command_outputs_to_file(self):
"""Test that get command can output to a file."""
"""Test that md-get command can output to a file."""
with tempfile.TemporaryDirectory() as temp_dir:
output_file = Path(temp_dir) / 'output.md'
cache_dir = Path(temp_dir) / '.ast_cache'
@@ -183,7 +183,7 @@ class TestGetCommand:
mock_file.read.return_value = json.dumps(self.test_ast)
mock_open.return_value.__enter__.return_value = mock_file
result = self.runner.invoke(cli, ['get', 'test.md', '--output', str(output_file)])
result = self.runner.invoke(cli, ['md-get', 'test.md', '--output', str(output_file)])
assert result.exit_code == 0
assert 'written to' in result.output.lower()