mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 07:41:52 +08:00
The old tracked TypeScript snapshot has been removed from the repository history and the root directory is now a Python porting workspace. README and tests now describe and verify the Python-first layout instead of treating the exposed snapshot as the active source tree. A local archive can still exist outside Git, but the tracked repository now presents only the Python porting surface, related essay context, and OmX workflow artifacts. Constraint: Tracked history should collapse to a single commit while excluding the archived snapshot from Git Rejected: Keep the exposed TypeScript tree in tracked history under an archive path | user explicitly wanted only the Python porting repo state in Git Confidence: medium Scope-risk: broad Reversibility: messy Directive: Keep future tracked additions focused on the Python port itself; do not reintroduce the exposed snapshot into Git history Tested: python3 -m unittest discover -s tests -v; python3 -m src.main summary; git diff --check Not-tested: Behavioral parity with the original TypeScript system beyond the current Python workspace surface
106 lines
3.9 KiB
Python
106 lines
3.9 KiB
Python
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
import unittest
|
|
|
|
from src.commands import PORTED_COMMANDS
|
|
from src.parity_audit import run_parity_audit
|
|
from src.port_manifest import build_port_manifest
|
|
from src.query_engine import QueryEnginePort
|
|
from src.tools import PORTED_TOOLS
|
|
|
|
|
|
class PortingWorkspaceTests(unittest.TestCase):
|
|
def test_manifest_counts_python_files(self) -> None:
|
|
manifest = build_port_manifest()
|
|
self.assertGreaterEqual(manifest.total_python_files, 20)
|
|
self.assertTrue(manifest.top_level_modules)
|
|
|
|
def test_query_engine_summary_mentions_workspace(self) -> None:
|
|
summary = QueryEnginePort.from_workspace().render_summary()
|
|
self.assertIn('Python Porting Workspace Summary', summary)
|
|
self.assertIn('Command surface:', summary)
|
|
self.assertIn('Tool surface:', summary)
|
|
|
|
def test_cli_summary_runs(self) -> None:
|
|
result = subprocess.run(
|
|
[sys.executable, '-m', 'src.main', 'summary'],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
self.assertIn('Python Porting Workspace Summary', result.stdout)
|
|
|
|
def test_parity_audit_runs(self) -> None:
|
|
result = subprocess.run(
|
|
[sys.executable, '-m', 'src.main', 'parity-audit'],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
self.assertIn('Parity Audit', result.stdout)
|
|
|
|
def test_root_file_coverage_is_complete_when_local_archive_exists(self) -> None:
|
|
audit = run_parity_audit()
|
|
if audit.archive_present:
|
|
self.assertEqual(audit.root_file_coverage[0], audit.root_file_coverage[1])
|
|
self.assertGreaterEqual(audit.directory_coverage[0], 28)
|
|
self.assertGreaterEqual(audit.command_entry_ratio[0], 150)
|
|
self.assertGreaterEqual(audit.tool_entry_ratio[0], 100)
|
|
|
|
def test_command_and_tool_snapshots_are_nontrivial(self) -> None:
|
|
self.assertGreaterEqual(len(PORTED_COMMANDS), 150)
|
|
self.assertGreaterEqual(len(PORTED_TOOLS), 100)
|
|
|
|
def test_commands_and_tools_cli_run(self) -> None:
|
|
commands_result = subprocess.run(
|
|
[sys.executable, '-m', 'src.main', 'commands', '--limit', '5', '--query', 'review'],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
tools_result = subprocess.run(
|
|
[sys.executable, '-m', 'src.main', 'tools', '--limit', '5', '--query', 'MCP'],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
self.assertIn('Command entries:', commands_result.stdout)
|
|
self.assertIn('Tool entries:', tools_result.stdout)
|
|
|
|
def test_subsystem_packages_expose_archive_metadata(self) -> None:
|
|
from src import assistant, bridge, utils
|
|
|
|
self.assertGreater(assistant.MODULE_COUNT, 0)
|
|
self.assertGreater(bridge.MODULE_COUNT, 0)
|
|
self.assertGreater(utils.MODULE_COUNT, 100)
|
|
self.assertTrue(utils.SAMPLE_FILES)
|
|
|
|
def test_route_and_show_entry_cli_run(self) -> None:
|
|
route_result = subprocess.run(
|
|
[sys.executable, '-m', 'src.main', 'route', 'review MCP tool', '--limit', '5'],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
show_command = subprocess.run(
|
|
[sys.executable, '-m', 'src.main', 'show-command', 'review'],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
show_tool = subprocess.run(
|
|
[sys.executable, '-m', 'src.main', 'show-tool', 'MCPTool'],
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
self.assertIn('review', route_result.stdout.lower())
|
|
self.assertIn('review', show_command.stdout.lower())
|
|
self.assertIn('mcptool', show_tool.stdout.lower())
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|