This guide documents the differences between the original JavaScript Copilot CLI and this Python implementation.
The command-line interface is 100% compatible with the JavaScript version:
march-cli # Start REPL (same as original)
march-cli --version # Show version
march-cli --experimental # Enable experimental mode
march-cli --model gpt-4 # Specify modelAll slash commands work identically:
/login # Authenticate with GitHub
/logout # Logout
/model <name> # Switch model
/status # Show status
/help # Show help
Python version uses the same configuration locations:
~/.march/config.json # User configuration
~/.march/preferences.json # User preferences (NEW in Python)
~/.march/lsp-config.json # LSP configuration
.github/lsp.json # Repository LSP config
Configuration format is identical - existing JSON files work without modification.
Token storage is compatible:
export GH_TOKEN="..." # Environment variable (same)
~/.march/github_token.json # File storage (same location)Simpler installation:
# Python version (no build/compile needed)
pip install march
# Original (required npm and building)
npm install -g @github/copilot-cli| Metric | JavaScript | Python |
|---|---|---|
| Startup | ~100ms | ~500ms |
| Memory | ~30MB | ~80MB |
| Size | 13.3MB | ~2MB (code) |
Python version is larger in memory but much smaller on disk (no bundled deps).
-
React TUI: JavaScript version used React reconciler for terminal UI
- Python version uses Rich library (simpler, declarative)
- No virtual DOM needed - Rich handles direct rendering
-
Webpack Bundling: JavaScript version was a large minified bundle
- Python version uses modular imports
- Each feature is in its own module
-
Redux State Management: Complex state in JavaScript
- Python version uses simple dataclasses and singletons
- Easier to understand and debug
-
Native Modules: Sharp (image), node-gyp, platform-specific
- Python version uses Pillow (cross-platform, pure Python)
- Native modules installed via pip, not npm
-
Validation Module: Built-in health checks and dependency auditing
- Verify system compatibility
- Check for required dependencies
- Audit for security vulnerabilities
-
LSP Configuration Manager: Centralized LSP server management
- 9 built-in language server configurations
- Easy enable/disable per language
- Custom server configuration support
-
Platform Utilities: Explicit cross-platform support
- Platform detection
- Console capabilities checking
- Platform-native directory paths
- Clipboard abstraction layer
-
State Persistence Manager: Structured session management
- User preferences with recent models
- Session state snapshots
- Conversation history persistence
- Automatic cleanup of old sessions
JavaScript Version:
app.js (13.3MB minified)
- UI rendering (React)
- CLI parsing
- GitHub integration
- LSP client
- Tree-sitter interface
- State management
Python Version:
src/mARCH/
├── CLI
│ ├── cli.py (Typer)
│ ├── slash_commands.py
│ └── config.py
├── GitHub
│ ├── github_auth.py (PAT)
│ ├── github_api.py (PyGithub)
│ └── github_context.py
├── Code Intelligence
│ ├── tree_sitter.py
│ ├── ripgrep_search.py
│ ├── lsp_client.py
│ └── syntax_highlight.py
├── TUI
│ ├── tui_conversation.py
│ ├── tui_banner.py
│ ├── tui_layout.py
│ └── tui.py (Rich)
├── AI & Agents
│ ├── agent_state.py
│ ├── ai_client.py (Anthropic Claude)
│ └── mcp_integration.py
├── Configuration & State
│ ├── state_persistence.py
│ ├── lsp_config.py
│ └── config.py
├── Platform & Utils
│ ├── platform_utils.py
│ ├── clipboard.py
│ ├── image_utils.py
│ ├── validation.py
│ └── logging_config.py
└── Core
├── exceptions.py
└── __init__.py
JavaScript: Limited testing in bundle Python: 328 comprehensive tests organized by phase:
tests/
├── test_phase1_foundation.py (11 tests)
├── test_phase2_cli.py (20 tests)
├── test_phase3_github.py (19 tests)
├── test_phase4_code_intelligence.py (36 tests)
├── test_phase5_tui.py (66 tests)
├── test_phase6_agent.py (54 tests)
├── test_phase7_config.py (44 tests)
├── test_phase8_platform.py (47 tests)
└── test_phase9_validation.py (31 tests)
Breaking Changes: None for end users
For Developers Importing Modules:
# SAME - These APIs are stable
from config import get_config_manager
from github_integration import GitHubIntegration
from code_intelligence import CodeIntelligence
from tui import CopilotTUI
from agent_state import AgentManager
# NEW - Python-specific utilities
from platform_utils import get_platform_info
from clipboard import get_clipboard_manager
from image_utils import get_image_processor
from validation import HealthChecker| Feature | JS Version | Python Version |
|---|---|---|
| CLI | Commander.js | Typer |
| GitHub API | Octokit | PyGithub |
| TUI | React + Ink | Rich |
| Syntax Parsing | tree-sitter WASM | tree-sitter-python |
| Code Search | ripgrep (subprocess) | ripgrep (subprocess) |
| LSP | Custom client | pylsp-client |
| AI Models | No integration | Anthropic SDK |
| Image Handling | sharp | Pillow |
| HTTP Client | node-fetch | httpx |
100% Compatible:
{
"model": "claude-sonnet-4.5",
"experimental": true,
"log_level": "DEBUG",
"lsp_enabled": true
}Configuration values are read identically from:
- User config file
- Environment variables
- Command-line arguments
- Defaults
| Feature | JS | Python | Notes |
|---|---|---|---|
| CLI REPL | ✓ | ✓ | Identical interface |
| GitHub Auth | ✓ | ✓ | PAT only, no OAuth |
| Slash Commands | ✓ | ✓ | 8 commands, same behavior |
| Code Intelligence | ✓ | ✓ | All 11 languages |
| TUI Rendering | ✓ | ✓ | Rich instead of React |
| LSP Support | ✓ | ✓ | 9 default servers |
| Configuration | ✓ | ✓ | Same format |
| Cross-Platform | ✓ | ✓ | Windows/macOS/Linux |
| Streaming | ✓ | ✓ | Claude streaming |
| Multi-turn | ✓ | ✓ | Conversation history |
None - Python version achieves 100% feature parity with original.
- Built-in health checks (
HealthChecker) - Dependency auditing (
DependencyAuditor) - Enhanced platform utilities
- Simplified LSP configuration
- Structured state persistence
- Module validation (
IntegrationValidator)
- Install Python version:
pip install march - No configuration needed: Existing
~/.march/config.jsonworks - Run:
marchworks identically
- Review new module structure (more modular than monolithic bundle)
- Use
src/mARCH/modules instead of unpacking bundle - Type hints available throughout (new development advantage)
- Comprehensive tests as examples
Solution: Install Python 3.10+ and reinstall:
pip install -e .Why: Python interpreter startup overhead (~400ms) Mitigation: Keep REPL running (no restart needed)
Solution: Install optional packages:
pip install anthropic Pillow tree-sitter- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: README.md, CONTRIBUTING.md
Phase 1 establishes the foundational infrastructure for I/O and execution:
-
Stream Buffer Management (
stream_buffer.py)- Async stream handling with backpressure control
- Support for binary and text modes
- Event-based callbacks for data, errors, and close events
-
Shell Executor (
shell_executor.py)- Execute shell commands with timeout and output capture
- Streaming and buffered output modes
- Error handling and signal management
-
Process Manager (
process_manager.py)- Singleton pattern for process lifecycle management
- Real-time resource monitoring (CPU, memory)
- Graceful termination with timeout
-
Async Executor (
async_executor.py)- Task pool with concurrency limiting
- Retry logic with exponential backoff
- Cancellation token propagation
-
Payload Handler (
payload_handler.py)- JSON, Base64, and binary encoding/decoding
- Optional gzip compression
- Schema validation with error reporting
from mARCH.core import StreamBuffer, StreamMode
# Create a text stream
buffer = StreamBuffer(mode=StreamMode.TEXT)
# Write and read data
await buffer.write("Hello, World!")
data = await buffer.read()
# Pause/resume flow control
buffer.pause()
buffer.resume()from mARCH.core import ShellExecutor, CommandOptions, CaptureMode
executor = ShellExecutor()
# Basic execution
result = await executor.execute("echo 'test'")
print(result.stdout) # 'test'
# With options
options = CommandOptions(
timeout=10.0,
capture_mode=CaptureMode.BOTH,
)
result = await executor.execute("git commit -m 'test'", options)
# Streaming output
async def on_stdout(line):
print(f"OUT: {line}")
result = await executor.execute_streaming(
"npm run build",
on_stdout=on_stdout,
)from mARCH.core import ProcessManager
manager = ProcessManager()
# Register a process
process_info = await manager.register_process(
pid=12345,
metadata={"service": "web-server"}
)
# Get process info
info = manager.get_process_info(12345)
print(f"Status: {info.status}")
print(f"CPU: {info.resource_usage.cpu_percent}%")
# Cleanup
await manager.cleanup_all()from mARCH.core import TaskPool
pool = TaskPool(max_concurrency=5)
# Submit tasks
result = await pool.submit(async_function(arg1, arg2))
# Map over items
results = await pool.map(async_fn, [1, 2, 3, 4, 5])
# Retry with backoff
result = await pool.retry(
lambda: async_operation(),
max_retries=3,
)
await pool.shutdown()from mARCH.core import PayloadCodec, PayloadFormat
codec = PayloadCodec(enable_compression=True)
# Encode data
data = {"key": "value", "nested": {"number": 42}}
encoded = codec.encode(data, PayloadFormat.JSON)
# Decode
decoded = codec.decode(encoded, PayloadFormat.JSON)Phase 2 adds data parsing and transformation capabilities:
-
Command Parser (
command_parser.py)- Advanced CLI argument parsing
- Flag extraction and positional arguments
- Subcommand detection
-
Text Parser (
text_parser.py)- Multi-format text parsing (markdown, JSON, code blocks)
- Automatic format detection
- Structure extraction (sections, headers, code)
-
Encoding Utils (
encoding_utils.py)- UTF-8, UTF-16, ASCII, Latin-1 encoding
- Base64, hex, and URL encoding
- Encoding detection
-
String Transform (
string_transform.py)- Case conversion (camelCase, snake_case, kebab-case, etc.)
- String normalization and truncation
- Template formatting
-
Data Validation (
data_validation.py)- Schema-based validation
- Email and URL validation
- Data normalization and sanitization
- PII removal
from mARCH.parsing import CommandParser
parser = CommandParser()
# Parse a command
parsed = parser.parse("git commit -m 'message' --amend --force")
print(parsed.command_name) # "git"
print(parsed.get_flag("--amend")) # True
print(parsed.get_flag("--force")) # True
print(parsed.get_flag("-m")) # 'message'from mARCH.parsing import TextParser, TextFormat
parser = TextParser()
markdown_text = """
# Introduction
This is a test.
## Section 1
Content here.
```python
print("hello")"""
parsed = parser.parse(markdown_text)
blocks = parsed.get_code_blocks() for block in blocks: print(f"Language: {block.language}") print(f"Code: {block.code}")
sections = parsed.get_sections() for section in sections: print(f"Level {section.level}: {section.heading}")
#### Encoding Utils
```python
from mARCH.parsing import Encoder, Decoder, EncodingFormat
# Encode to different formats
text = "Hello, World!"
utf8_encoded = Encoder.encode(text, EncodingFormat.UTF8)
base64_encoded = Encoder.encode(text, EncodingFormat.BASE64)
hex_encoded = Encoder.encode(text, EncodingFormat.HEX)
# Decode
decoded = Decoder.decode(base64_encoded, EncodingFormat.BASE64)
# Auto-detect encoding
detected = Decoder.detect_encoding(utf8_encoded)
from mARCH.parsing import StringTransform, TextFormatter, CaseStyle
# Case conversion
snake = StringTransform.to_snake_case("myVariableName") # "my_variable_name"
camel = StringTransform.to_camel_case("my_variable_name") # "myVariableName"
kebab = StringTransform.to_kebab_case("my_variable_name") # "my-variable-name"
# String utilities
truncated = StringTransform.truncate("Very long text", 10) # "Very lon..."
pluralized = StringTransform.pluralize("item", 5) # "items"
# Template formatting
formatter = TextFormatter()
result = formatter.format("Hello, {name}!", name="World")from mARCH.parsing import (
DataValidator,
DataNormalizer,
SanitizationRules,
)
# Validate
validator = DataValidator()
is_valid_email = validator.is_valid_email("test@example.com")
is_valid_url = validator.is_valid_url("https://example.com")
# Normalize
normalizer = DataNormalizer()
data = {"firstName": "John", "lastName": "Doe"}
normalized = normalizer.normalize_keys(data, "snake_case")
# {"first_name": "John", "last_name": "Doe"}
# Sanitize
sanitizer = SanitizationRules()
text = "My password is secret123"
sanitized = sanitizer.sanitize(text, ["password"])
# "My password is [REDACTED_PASSWORD]"Phase 1 and 2 modules are organized in:
src/mARCH/
├── core/ # Phase 1: Core Infrastructure
│ ├── stream_buffer.py
│ ├── shell_executor.py
│ ├── process_manager.py
│ ├── async_executor.py
│ ├── payload_handler.py
│ └── __init__.py
├── parsing/ # Phase 2: Parsing & Data Processing
│ ├── command_parser.py
│ ├── text_parser.py
│ ├── encoding_utils.py
│ ├── string_transform.py
│ ├── data_validation.py
│ └── __init__.py
└── ...
Comprehensive tests for Phase 1 and 2:
# Run all Phase 1/2 tests
pytest tests/test_phase1_phase2.py -v
# Run specific test class
pytest tests/test_phase1_phase2.py::TestStreamBuffer -v
# Run with coverage
pytest tests/test_phase1_phase2.py --cov=src/mARCH/core --cov=src/mARCH/parsingTest coverage includes:
- Unit Tests: Individual module functionality
- Integration Tests: Cross-module workflows
- Async Tests: Concurrent operations
- Error Handling: Edge cases and exceptions
New exceptions for Phase 1 and 2:
StreamError # Stream operations
ShellExecutionError # Shell command execution
ProcessError # Process management
AsyncExecutionError # Async operations
PayloadError # Payload encoding/decoding
ParsingError # Parsing operations
CommandParsingError # Command parsing
TextParsingError # Text parsing
EncodingError # Encoding/decoding
ValidationError # Data validation
SanitizationError # Data sanitization| Operation | Typical Time |
|---|---|
| Stream write | <1ms |
| Shell command (simple) | ~50ms |
| Process registration | <1ms |
| Task pool submit | <1ms |
| Payload encode/decode | <5ms |
| Operation | Typical Time |
|---|---|
| Command parse | <1ms |
| Markdown parse | 1-10ms (text size dependent) |
| Text encode/decode | <1ms |
| Case conversion | <1ms |
| Data validation | <1ms |
- Python: 3.10+
- Dependencies: All stdlib except
psutil(optional for process monitoring) - Async Runtime: Compatible with asyncio
- Type Hints: Full type hints throughout