mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-05-21 23:24:44 +02:00
fix: Replace deleted REGION_CONTEXT with config method, replace hardcoded city map with config aliases
- Line 763: REGION_CONTEXT.get() → self._region_context() (same method used elsewhere) - Deleted _CITY_TO_REGION hardcoded dict - Scope detection now uses config aliases/cities from RegionAnchor - Fixed Sun Valley/Ketchum geography (was Central ID, should be South Central ID) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
de400068dd
commit
51969050da
2 changed files with 27 additions and 38 deletions
|
|
@ -760,7 +760,7 @@ class MeshReporter:
|
||||||
f"ID: !{node.node_num:08x} (dec: {node.node_num})",
|
f"ID: !{node.node_num:08x} (dec: {node.node_num})",
|
||||||
f"Hardware: {node.hw_model or 'Unknown'}",
|
f"Hardware: {node.hw_model or 'Unknown'}",
|
||||||
f"Role: {node.role} ({'Infrastructure' if node.is_infrastructure else 'Client'})",
|
f"Role: {node.role} ({'Infrastructure' if node.is_infrastructure else 'Client'})",
|
||||||
f"Region: {node.region or 'Unknown'}{' — ' + REGION_CONTEXT.get(node.region, '') if node.region and REGION_CONTEXT.get(node.region) else ''} / Locality: {node.locality or 'Unknown'}",
|
f"Region: {node.region or 'Unknown'}{' — ' + self._region_context(node.region) if node.region and self._region_context(node.region) else ''} / Locality: {node.locality or 'Unknown'}",
|
||||||
]
|
]
|
||||||
|
|
||||||
if node.latitude and node.longitude:
|
if node.latitude and node.longitude:
|
||||||
|
|
|
||||||
|
|
@ -88,40 +88,7 @@ _MESH_PHRASES = [
|
||||||
]
|
]
|
||||||
|
|
||||||
# City name to region mapping (hardcoded fallback)
|
# City name to region mapping (hardcoded fallback)
|
||||||
_CITY_TO_REGION = {
|
# City/alias mapping now built from config - see _build_alias_map()
|
||||||
# Idaho
|
|
||||||
"twin falls": "South Central ID",
|
|
||||||
"boise": "South Western ID",
|
|
||||||
"nampa": "South Western ID",
|
|
||||||
"meridian": "South Western ID",
|
|
||||||
"caldwell": "South Western ID",
|
|
||||||
"idaho falls": "South Eastern ID",
|
|
||||||
"pocatello": "South Eastern ID",
|
|
||||||
"coeur d'alene": "Northern ID",
|
|
||||||
"cda": "Northern ID",
|
|
||||||
"post falls": "Northern ID",
|
|
||||||
"moscow": "Northern ID",
|
|
||||||
"lewiston": "Northern ID",
|
|
||||||
"salmon": "Central ID",
|
|
||||||
"sun valley": "Central ID",
|
|
||||||
"ketchum": "Central ID",
|
|
||||||
# Utah
|
|
||||||
"ogden": "Northern UT",
|
|
||||||
"logan": "Northern UT",
|
|
||||||
"salt lake": "Central UT",
|
|
||||||
"salt lake city": "Central UT",
|
|
||||||
"slc": "Central UT",
|
|
||||||
"provo": "Central UT",
|
|
||||||
"orem": "Central UT",
|
|
||||||
"vernal": "Eastern UT",
|
|
||||||
"moab": "Eastern UT",
|
|
||||||
"price": "Eastern UT",
|
|
||||||
"tooele": "Western UT",
|
|
||||||
"wendover": "Western UT",
|
|
||||||
"st george": "Southern UT",
|
|
||||||
"st. george": "Southern UT",
|
|
||||||
"cedar city": "Southern UT",
|
|
||||||
}
|
|
||||||
|
|
||||||
# Mesh awareness instruction for LLM
|
# Mesh awareness instruction for LLM
|
||||||
# Mesh awareness instruction for LLM
|
# Mesh awareness instruction for LLM
|
||||||
|
|
@ -243,6 +210,28 @@ class MessageRouter:
|
||||||
self._region_abbrevs = _build_region_abbreviations(region_names)
|
self._region_abbrevs = _build_region_abbreviations(region_names)
|
||||||
logger.debug(f"Built region abbreviations: {self._region_abbrevs}")
|
logger.debug(f"Built region abbreviations: {self._region_abbrevs}")
|
||||||
|
|
||||||
|
# Build city/alias mapping from config
|
||||||
|
self._alias_map = self._build_alias_map()
|
||||||
|
if self._alias_map:
|
||||||
|
logger.debug(f"Built alias map with {len(self._alias_map)} entries")
|
||||||
|
|
||||||
|
def _build_alias_map(self) -> dict[str, str]:
|
||||||
|
"""Build city/alias to region mapping from config."""
|
||||||
|
alias_map = {}
|
||||||
|
if self.config.mesh_intelligence and self.config.mesh_intelligence.regions:
|
||||||
|
for region in self.config.mesh_intelligence.regions:
|
||||||
|
# Add aliases
|
||||||
|
for alias in (getattr(region, 'aliases', []) or []):
|
||||||
|
alias_map[alias.lower()] = region.name
|
||||||
|
# Add cities
|
||||||
|
for city in (getattr(region, 'cities', []) or []):
|
||||||
|
alias_map[city.lower()] = region.name
|
||||||
|
# Add local_name
|
||||||
|
local = getattr(region, 'local_name', '') or ''
|
||||||
|
if local:
|
||||||
|
alias_map[local.lower()] = region.name
|
||||||
|
return alias_map
|
||||||
|
|
||||||
def should_respond(self, message: MeshMessage) -> bool:
|
def should_respond(self, message: MeshMessage) -> bool:
|
||||||
"""Determine if we should respond to this message.
|
"""Determine if we should respond to this message.
|
||||||
|
|
||||||
|
|
@ -418,9 +407,9 @@ class MessageRouter:
|
||||||
if re.search(pattern, msg_lower):
|
if re.search(pattern, msg_lower):
|
||||||
return ("region", region_name)
|
return ("region", region_name)
|
||||||
|
|
||||||
# 2. Check city names
|
# 2. Check city names and aliases from config
|
||||||
for city, region_name in _CITY_TO_REGION.items():
|
for alias, region_name in self._alias_map.items():
|
||||||
if city in msg_lower:
|
if alias in msg_lower:
|
||||||
return ("region", region_name)
|
return ("region", region_name)
|
||||||
|
|
||||||
# 3. Full region name matching (SORTED BY LENGTH - longest first)
|
# 3. Full region name matching (SORTED BY LENGTH - longest first)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue