mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 07:41:52 +08:00
Rewriting Project Claw Code - Python port with Rust on the way
This commit is contained in:
34
src/command_graph.py
Normal file
34
src/command_graph.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from .commands import get_commands
|
||||
from .models import PortingModule
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CommandGraph:
|
||||
builtins: tuple[PortingModule, ...]
|
||||
plugin_like: tuple[PortingModule, ...]
|
||||
skill_like: tuple[PortingModule, ...]
|
||||
|
||||
def flattened(self) -> tuple[PortingModule, ...]:
|
||||
return self.builtins + self.plugin_like + self.skill_like
|
||||
|
||||
def as_markdown(self) -> str:
|
||||
lines = [
|
||||
'# Command Graph',
|
||||
'',
|
||||
f'Builtins: {len(self.builtins)}',
|
||||
f'Plugin-like commands: {len(self.plugin_like)}',
|
||||
f'Skill-like commands: {len(self.skill_like)}',
|
||||
]
|
||||
return '\n'.join(lines)
|
||||
|
||||
|
||||
def build_command_graph() -> CommandGraph:
|
||||
commands = get_commands()
|
||||
builtins = tuple(module for module in commands if 'plugin' not in module.source_hint.lower() and 'skills' not in module.source_hint.lower())
|
||||
plugin_like = tuple(module for module in commands if 'plugin' in module.source_hint.lower())
|
||||
skill_like = tuple(module for module in commands if 'skills' in module.source_hint.lower())
|
||||
return CommandGraph(builtins=builtins, plugin_like=plugin_like, skill_like=skill_like)
|
||||
Reference in New Issue
Block a user