MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / route_prompt

Method route_prompt

claw-code/src/runtime.py:90–107  ·  view source on GitHub ↗
(self, prompt: str, limit: int = 5)

Source from the content-addressed store, hash-verified

88
89class PortRuntime:
90 def route_prompt(self, prompt: str, limit: int = 5) -> list[RoutedMatch]:
91 tokens = {token.lower() for token in prompt.replace('/', ' ').replace('-', ' ').split() if token}
92 by_kind = {
93 'command': self._collect_matches(tokens, PORTED_COMMANDS, 'command'),
94 'tool': self._collect_matches(tokens, PORTED_TOOLS, 'tool'),
95 }
96
97 selected: list[RoutedMatch] = []
98 for kind in ('command', 'tool'):
99 if by_kind[kind]:
100 selected.append(by_kind[kind].pop(0))
101
102 leftovers = sorted(
103 [match for matches in by_kind.values() for match in matches],
104 key=lambda item: (-item.score, item.kind, item.name),
105 )
106 selected.extend(leftovers[: max(0, limit - len(selected))])
107 return selected[:limit]
108
109 def bootstrap_session(self, prompt: str, limit: int = 5) -> RuntimeSession:
110 context = build_port_context()

Callers 4

bootstrap_sessionMethod · 0.95
run_turn_loopMethod · 0.95
routeMethod · 0.80
mainFunction · 0.80

Calls 2

_collect_matchesMethod · 0.95
appendMethod · 0.80

Tested by

no test coverage detected