feat: add AI Workspace context MCP configuration and enhance communication channel filtering in server
This commit is contained in:
@@ -61,6 +61,56 @@ class ContextMCPTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual([item["message"] for item in result["records"]], ["m1", "m2"])
|
||||
|
||||
def test_communication_latest_filters_to_profile_channels_by_default(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
latest = root / "ai" / "inbox" / "mattermost-mirror" / "latest.jsonl"
|
||||
profile_config = root / "profiles" / "fidelity" / "context-sources.json"
|
||||
latest.parent.mkdir(parents=True)
|
||||
profile_config.parent.mkdir(parents=True)
|
||||
profile_config.write_text(json.dumps({
|
||||
"communication_sources": {
|
||||
"mattermost": {"context_channels": ["fidelity-code-review", "dm-david--jeff"]}
|
||||
}
|
||||
}), encoding="utf-8")
|
||||
latest.write_text(
|
||||
"\n".join([
|
||||
json.dumps({"post_id": "1", "channel_name": "design-team", "message": "ignore"}),
|
||||
json.dumps({"post_id": "2", "channel_name": "fidelity-code-review", "message": "keep"}),
|
||||
]) + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
with patch.object(server, "ROOT", root), patch.dict(server.os.environ, {"AIW_MATTERMOST_CONTEXT_CHANNELS": "", "AIW_MATTERMOST_PROJECT_CHANNELS": ""}, clear=False):
|
||||
result = server.communication_latest({"profile": "fidelity", "limit": 10})["structuredContent"]
|
||||
|
||||
self.assertEqual([item["message"] for item in result["records"]], ["keep"])
|
||||
self.assertEqual(result["channel_scope"], "profile")
|
||||
|
||||
def test_communication_latest_can_include_all_channels(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
latest = root / "ai" / "inbox" / "mattermost-mirror" / "latest.jsonl"
|
||||
profile_config = root / "profiles" / "fidelity" / "context-sources.json"
|
||||
latest.parent.mkdir(parents=True)
|
||||
profile_config.parent.mkdir(parents=True)
|
||||
profile_config.write_text(json.dumps({
|
||||
"communication_sources": {"mattermost": {"context_channels": ["fidelity-code-review"]}}
|
||||
}), encoding="utf-8")
|
||||
latest.write_text(
|
||||
"\n".join([
|
||||
json.dumps({"post_id": "1", "channel_name": "design-team", "message": "include"}),
|
||||
json.dumps({"post_id": "2", "channel_name": "fidelity-code-review", "message": "keep"}),
|
||||
]) + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
with patch.object(server, "ROOT", root), patch.dict(server.os.environ, {"AIW_MATTERMOST_CONTEXT_CHANNELS": "", "AIW_MATTERMOST_PROJECT_CHANNELS": ""}, clear=False):
|
||||
result = server.communication_latest({"profile": "fidelity", "include_all_channels": True, "limit": 10})["structuredContent"]
|
||||
|
||||
self.assertEqual([item["message"] for item in result["records"]], ["include", "keep"])
|
||||
self.assertEqual(result["channel_scope"], "all")
|
||||
|
||||
def test_project_search_skips_templates(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
|
||||
Reference in New Issue
Block a user