oh-my-agent 20.5.1 → 20.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,13 +2,32 @@
2
2
 
3
3
  import argparse
4
4
  import asyncio
5
+ import inspect
5
6
  import json
6
7
  import subprocess
7
8
  import sys
8
9
  from pathlib import Path
9
10
 
10
11
  from mcp import ClientSession
11
- from mcp.client.streamable_http import streamablehttp_client
12
+
13
+ try: # mcp 1.x
14
+ from mcp.client.streamable_http import (
15
+ streamablehttp_client as _streamable_http_client,
16
+ )
17
+ except ImportError: # mcp 2.x renamed the transport
18
+ from mcp.client.streamable_http import (
19
+ streamable_http_client as _streamable_http_client,
20
+ )
21
+
22
+
23
+ def streamable_http_client(url, timeout):
24
+ """Yield (read, write) streams for both mcp 1.x (3-tuple) and 2.x (2-tuple)."""
25
+ parameters = inspect.signature(_streamable_http_client).parameters
26
+ if "timeout" in parameters:
27
+ return _streamable_http_client(
28
+ url, timeout=timeout, sse_read_timeout=timeout
29
+ )
30
+ return _streamable_http_client(url)
12
31
 
13
32
 
14
33
  def git(root, *args):
@@ -57,9 +76,8 @@ async def run(args):
57
76
  sdk = Path(args.dart_sdk).expanduser().resolve(strict=True)
58
77
  index = check_index(root, package) if args.staged else None
59
78
  url = args.url
60
- async with streamablehttp_client(
61
- url, timeout=args.timeout, sse_read_timeout=args.timeout
62
- ) as (read, write, _):
79
+ async with streamable_http_client(url, args.timeout) as streams:
80
+ read, write = streams[0], streams[1]
63
81
  async with ClientSession(read, write) as session:
64
82
  await session.initialize()
65
83
  response = await session.call_tool(
@@ -7,11 +7,32 @@ import importlib.util
7
7
  import json
8
8
  import os
9
9
  from pathlib import Path
10
+ import re
10
11
  import tempfile
11
12
 
12
13
  IMPORT = "from .oma_dart import GetDartProjectDiagnosticsTool\n"
13
14
  CACHE_IMPORT = "from .oma_symbol_cache import install_symbol_cache as _install_symbol_cache\n_install_symbol_cache()\n"
14
- SUPPORTED = {"1.7.0"}
15
+ # Patches target APIs that stayed stable across 1.7 and 2.0. Minors and patches
16
+ # above the tested versions reuse them; a new major requires API re-validation.
17
+ MIN_VERSION = (1, 7, 0)
18
+ MAX_MAJOR = 2
19
+
20
+
21
+ def version_tuple(version):
22
+ match = re.match(r"(\d+(?:\.\d+)*)", version)
23
+ if not match:
24
+ return None
25
+ parts = [int(part) for part in match.group(1).split(".")]
26
+ return tuple(parts + [0] * (3 - len(parts)))
27
+
28
+
29
+ def is_supported(version):
30
+ parsed = version_tuple(version)
31
+ return (
32
+ parsed is not None
33
+ and parsed >= MIN_VERSION
34
+ and parsed[0] <= MAX_MAJOR
35
+ )
15
36
 
16
37
 
17
38
  def atomic_write(path, content):
@@ -28,11 +49,13 @@ def atomic_write(path, content):
28
49
 
29
50
 
30
51
  def reconcile(package, version, source, check_only=False):
31
- if version not in SUPPORTED:
52
+ if not is_supported(version):
32
53
  return {
33
54
  "status": "unsupported",
34
55
  "version": version,
35
- "error": f"Serena {version} is not supported by this OMA adapter (tested: 1.7.0)",
56
+ "error": f"Serena {version} is not supported by this OMA adapter "
57
+ f"(supported: >={'.'.join(map(str, MIN_VERSION))}, "
58
+ f"<{MAX_MAJOR + 1}.0.0)",
36
59
  }
37
60
  payload = (source / "oma_dart.py").read_text()
38
61
  cache_payload = (source / "oma_symbol_cache.py").read_text()
@@ -1,4 +1,4 @@
1
- """Dart project diagnostics on Serena's existing language server (Serena 1.7).
1
+ """Dart project diagnostics on Serena's existing language server (Serena 1.7/2.0).
2
2
 
3
3
  Installed as serena.tools.oma_dart. No second analysis server is launched.
4
4
  """
@@ -1,4 +1,4 @@
1
- """File-granular symbol caching for Serena 1.7.0's long-lived Python process.
1
+ """File-granular symbol caching for Serena 1.7/2.0's long-lived Python process.
2
2
 
3
3
  Legacy pickles eagerly restore every file and retain mutable workspace trees.
4
4
  SQLite keeps cold files on disk; serialized entries isolate request mutations.