robotcode-core 2.9.0.dev214__tar.gz → 2.9.0.dev264__tar.gz

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.
Files changed (34) hide show
  1. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/.gitignore +1 -1
  2. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/PKG-INFO +1 -1
  3. robotcode_core-2.9.0.dev264/src/robotcode/core/__version__.py +1 -0
  4. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/uri.py +89 -2
  5. robotcode_core-2.9.0.dev214/src/robotcode/core/__version__.py +0 -1
  6. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/README.md +0 -0
  7. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/pyproject.toml +0 -0
  8. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/__init__.py +0 -0
  9. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/async_tools.py +0 -0
  10. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/concurrent.py +0 -0
  11. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/documents_manager.py +0 -0
  12. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/event.py +0 -0
  13. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/filewatcher.py +0 -0
  14. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/ignore_spec.py +0 -0
  15. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/language.py +0 -0
  16. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/lsp/__init__.py +0 -0
  17. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/lsp/types.py +0 -0
  18. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/py.typed +0 -0
  19. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/text_document.py +0 -0
  20. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/types.py +0 -0
  21. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/__init__.py +0 -0
  22. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/caching.py +0 -0
  23. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/cli.py +0 -0
  24. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/dataclasses.py +0 -0
  25. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/debugpy.py +0 -0
  26. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/glob_path.py +0 -0
  27. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/inspect.py +0 -0
  28. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/logging.py +0 -0
  29. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/net.py +0 -0
  30. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/path.py +0 -0
  31. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/process.py +0 -0
  32. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/safe_eval.py +0 -0
  33. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/utils/version.py +0 -0
  34. {robotcode_core-2.9.0.dev214 → robotcode_core-2.9.0.dev264}/src/robotcode/core/workspace.py +0 -0
@@ -340,7 +340,7 @@ bundled/libs
340
340
  .kilocode/
341
341
 
342
342
  # .agents
343
- .agents/
343
+ #.agents/
344
344
  skills-lock.json
345
345
  #.claude
346
346
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: robotcode-core
3
- Version: 2.9.0-dev.214
3
+ Version: 2.9.0-dev.264
4
4
  Summary: Some core classes for RobotCode
5
5
  Project-URL: Homepage, https://robotcode.io
6
6
  Project-URL: Donate, https://opencollective.com/robotcode
@@ -0,0 +1 @@
1
+ __version__ = "2.9.0-dev.264"
@@ -5,7 +5,7 @@ import re
5
5
  import sys
6
6
  from dataclasses import astuple, dataclass, fields
7
7
  from pathlib import Path
8
- from typing import Any, Iterator, Mapping, Optional, Union, overload
8
+ from typing import Any, Iterable, Iterator, Mapping, Optional, Union, overload
9
9
  from urllib import parse
10
10
 
11
11
  from .utils.path import normalized_path
@@ -21,6 +21,80 @@ class InvalidUriError(Exception):
21
21
  pass
22
22
 
23
23
 
24
+ @dataclass(frozen=True)
25
+ class PathMapping:
26
+ """A root of the client's file URIs, such as `file://wsl.localhost/Ubuntu/`, and the local path it stands for,
27
+ such as `/`."""
28
+
29
+ client_root: str
30
+ local_root: str
31
+
32
+
33
+ @dataclass(frozen=True)
34
+ class _ParsedPathMapping:
35
+ client_root: str
36
+ scheme: str
37
+ netloc: str
38
+ segments: tuple[str, ...]
39
+ local_root: str
40
+
41
+
42
+ _path_mappings: list[_ParsedPathMapping] = []
43
+
44
+
45
+ def _segments(path: str) -> list[str]:
46
+ return [s for s in path.split("/") if s]
47
+
48
+
49
+ def set_path_mappings(mappings: Iterable[PathMapping]) -> None:
50
+ """Sets the path mappings of this process. A client URI below a client root becomes a path below its local root,
51
+ and a path below a local root becomes a URI below its client root; the longest root wins."""
52
+ parsed = []
53
+ for m in mappings:
54
+ client_root = m.client_root if m.client_root.endswith("/") else m.client_root + "/"
55
+ parts = parse.urlparse(client_root)
56
+ local_root = m.local_root.replace("\\", "/")
57
+ if not local_root.endswith("/"):
58
+ local_root += "/"
59
+ parsed.append(
60
+ _ParsedPathMapping(
61
+ client_root,
62
+ parts.scheme.lower(),
63
+ parse.unquote(parts.netloc).lower(),
64
+ tuple(s.lower() for s in _segments(parse.unquote(parts.path))),
65
+ local_root,
66
+ )
67
+ )
68
+ _path_mappings[:] = parsed
69
+
70
+
71
+ def _client_to_local(scheme: str, netloc: str, path: str) -> Optional[str]:
72
+ segments = _segments(path)
73
+ lowered = [s.lower() for s in segments]
74
+ best: Optional[_ParsedPathMapping] = None
75
+ for m in _path_mappings:
76
+ if (
77
+ m.scheme == scheme.lower()
78
+ and m.netloc == netloc.lower()
79
+ and tuple(lowered[: len(m.segments)]) == m.segments
80
+ and (best is None or len(m.segments) > len(best.segments))
81
+ ):
82
+ best = m
83
+ if best is None:
84
+ return None
85
+ return best.local_root + "/".join(segments[len(best.segments) :])
86
+
87
+
88
+ def _local_to_client(path: str) -> Optional[str]:
89
+ best: Optional[_ParsedPathMapping] = None
90
+ for m in _path_mappings:
91
+ if (path + "/").startswith(m.local_root) and (best is None or len(m.local_root) > len(best.local_root)):
92
+ best = m
93
+ if best is None:
94
+ return None
95
+ return best.client_root + parse.quote(path[len(best.local_root) :])
96
+
97
+
24
98
  @dataclass
25
99
  class _Parts:
26
100
  scheme: str = _DEFAULT_SCHEME
@@ -124,7 +198,15 @@ class Uri(Mapping[str, str]):
124
198
  if self._parts.scheme not in ["file", "untitled"]:
125
199
  raise InvalidUriError(f"Invalid URI scheme '{self!s}'.")
126
200
 
127
- if netloc and self._parts.scheme == "file":
201
+ mapped = (
202
+ _client_to_local(self._parts.scheme, netloc, path)
203
+ if _path_mappings and self._parts.scheme == "file"
204
+ else None
205
+ )
206
+ if mapped is not None:
207
+ value = mapped
208
+
209
+ elif netloc and self._parts.scheme == "file":
128
210
  # unc path: file://shares/c$/far/boo
129
211
  value = "//{}{}".format(netloc, path or "")
130
212
 
@@ -167,6 +249,11 @@ class Uri(Mapping[str, str]):
167
249
 
168
250
  @staticmethod
169
251
  def from_path(path: Union[str, Path, os.PathLike[str]]) -> Uri:
252
+ if _path_mappings:
253
+ mapped = _local_to_client(Path(path).as_posix())
254
+ if mapped is not None:
255
+ return Uri(mapped)
256
+
170
257
  result = Uri(Path(path).as_uri())
171
258
 
172
259
  result._parts.path = parse.quote(parse.unquote(result._parts.path))
@@ -1 +0,0 @@
1
- __version__ = "2.9.0-dev.214"