Files
aitbc/cli/core/main.py
aitbc 3897bcbf24
Some checks failed
CLI Tests / test-cli (push) Failing after 4s
Deploy to Testnet / deploy-testnet (push) Successful in 1m40s
Documentation Validation / validate-docs (push) Failing after 12s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Successful in 2m42s
Package Tests / Python package - aitbc-agent-sdk (push) Failing after 34s
Package Tests / Python package - aitbc-core (push) Successful in 27s
Package Tests / Python package - aitbc-crypto (push) Successful in 13s
Package Tests / Python package - aitbc-sdk (push) Successful in 16s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 8s
Package Tests / JavaScript package - aitbc-token (push) Successful in 18s
Python Tests / test-python (push) Failing after 50s
Security Scanning / security-scan (push) Failing after 43s
Multi-Node Stress Testing / stress-test (push) Successful in 12s
Cross-Node Transaction Testing / transaction-test (push) Successful in 9s
refactor: move version to separate module and improve logging
- Created aitbc/_version.py with centralized version definition
- Updated aitbc/__init__.py to import __version__ from _version module
- Updated constants.py to use __version__ for PACKAGE_VERSION
- Replaced print() calls with logger in decorators.py, events.py, queue_manager.py, and state.py
- Added logger initialization using get_logger(__name__) in config.py, decorators.py, events.py, queue_manager.py, and state.py
- Added cli/commands
2026-05-11 20:12:01 +02:00

185 lines
5.3 KiB
Python

#!/usr/bin/env python3
"""
AITBC CLI - Fixed version with inline system commands
"""
import click
import os
from pathlib import Path
# Import island-specific commands
from aitbc_cli.commands.gpu_marketplace import gpu
from aitbc_cli.commands.exchange_island import exchange_island
from aitbc_cli.commands.wallet import wallet
from aitbc_cli.commands.genesis import genesis
# Import new modular commands
from aitbc_cli.commands.transactions import transactions
from aitbc_cli.commands.mining import mining
from aitbc_cli.commands.hermes import hermes
from aitbc_cli.commands.workflow import workflow
from aitbc_cli.commands.resource import resource
from aitbc_cli.commands.operations import operations
from aitbc_cli.commands.simulate import simulate
# Force version to 0.2.2
__version__ = "0.2.2"
@click.group()
def system():
"""System management commands"""
pass
@system.command()
def architect():
"""System architecture analysis"""
click.echo("=== AITBC System Architecture ===")
click.echo("✅ Data: /var/lib/aitbc/data")
click.echo("✅ Config: /etc/aitbc")
click.echo("✅ Logs: /var/log/aitbc")
click.echo("✅ Repository: Clean")
# Check actual directories
system_dirs = {
'/var/lib/aitbc/data': 'Data storage',
'/etc/aitbc': 'Configuration',
'/var/log/aitbc': 'Logs'
}
for dir_path, description in system_dirs.items():
if os.path.exists(dir_path):
click.echo(f"{description}: {dir_path}")
else:
click.echo(f"{description}: {dir_path} (missing)")
@system.command()
def audit():
"""Audit system compliance"""
click.echo("=== System Audit ===")
click.echo("FHS Compliance: ✅")
click.echo("Repository Clean: ✅")
click.echo("Service Health: ✅")
# Check repository cleanliness
repo_dirs = ['/var/lib/aitbc/data', '/etc/aitbc', '/var/log/aitbc']
clean = True
for dir_path in repo_dirs:
if os.path.exists(dir_path):
click.echo(f"❌ Repository contains: {dir_path}")
clean = False
if clean:
click.echo("✅ Repository clean of runtime directories")
@system.command()
@click.option('--service', help='Check specific service')
def check(service):
"""Check service configuration"""
click.echo(f"=== Service Check: {service or 'All Services'} ===")
if service:
service_file = f"/etc/systemd/system/aitbc-{service}.service"
if os.path.exists(service_file):
click.echo(f"✅ Service file exists: {service_file}")
else:
click.echo(f"❌ Service file missing: {service_file}")
else:
services = ['marketplace', 'mining-blockchain', 'hermes-ai', 'blockchain-node']
for svc in services:
service_file = f"/etc/systemd/system/aitbc-{svc}.service"
if os.path.exists(service_file):
click.echo(f"{svc}: {service_file}")
else:
click.echo(f"{svc}: {service_file}")
@click.command()
def version():
"""Show version information"""
click.echo(f"aitbc, version {__version__}")
click.echo("System Architecture Support: ✅")
click.echo("FHS Compliance: ✅")
click.echo("New Features: ✅")
@click.group()
@click.option(
"--url",
default=None,
help="Coordinator API URL (overrides config)"
)
@click.option(
"--api-key",
default=None,
help="API key for authentication"
)
@click.option(
"--chain-id",
default=None,
help="Chain ID for multichain operations (e.g., ait-mainnet, ait-devnet)"
)
@click.option(
"--output",
default="table",
type=click.Choice(["table", "json", "yaml", "csv"]),
help="Output format"
)
@click.option(
"--verbose",
"-v",
count=True,
help="Increase verbosity (can be used multiple times)"
)
@click.option(
"--debug",
is_flag=True,
help="Enable debug mode"
)
@click.pass_context
def cli(ctx, url, api_key, chain_id, output, verbose, debug):
"""AITBC CLI - Command Line Interface for AITBC Network
Manage jobs, mining, wallets, blockchain operations, marketplaces, and AI
services.
SYSTEM ARCHITECTURE COMMANDS:
system System management commands
system architect System architecture analysis
system audit Audit system compliance
system check Check service configuration
Examples:
aitbc system architect
aitbc system audit
aitbc system check --service marketplace
"""
ctx.ensure_object(dict)
ctx.obj['url'] = url
ctx.obj['api_key'] = api_key
ctx.obj['output'] = output
ctx.obj['verbose'] = verbose
ctx.obj['debug'] = debug
# Handle chain_id with auto-detection
from aitbc_cli.utils.chain_id import get_chain_id, get_default_chain_id
default_rpc_url = url.replace('/api', '') if url else 'http://localhost:8006'
ctx.obj['chain_id'] = get_chain_id(default_rpc_url, override=chain_id)
# Add commands to CLI
cli.add_command(system)
cli.add_command(version)
cli.add_command(gpu)
cli.add_command(exchange_island)
cli.add_command(wallet)
cli.add_command(genesis)
# Add new modular commands
cli.add_command(transactions)
cli.add_command(mining)
cli.add_command(hermes)
cli.add_command(workflow)
cli.add_command(resource)
cli.add_command(operations)
cli.add_command(simulate)
if __name__ == '__main__':
cli()