robotframework-plugins 2026.11.0.dev1__py3-none-any.whl

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 (195) hide show
  1. robotframework_plugins/__init__.py +14 -0
  2. robotframework_plugins/_assets/catalog.json +143 -0
  3. robotframework_plugins/_assets/plugins/rf-agentskills/.claude-plugin/plugin.json +25 -0
  4. robotframework_plugins/_assets/plugins/rf-agentskills/CHANGELOG.md +198 -0
  5. robotframework_plugins/_assets/plugins/rf-agentskills/README.md +27 -0
  6. robotframework_plugins/_assets/plugins/rf-agentskills/catalog.yaml +25 -0
  7. robotframework_plugins/_assets/plugins/rf-api/.claude-plugin/plugin.json +25 -0
  8. robotframework_plugins/_assets/plugins/rf-api/CHANGELOG.md +9 -0
  9. robotframework_plugins/_assets/plugins/rf-api/README.md +27 -0
  10. robotframework_plugins/_assets/plugins/rf-api/catalog.yaml +27 -0
  11. robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/SKILL.md +110 -0
  12. robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/authentication-patterns.robot +39 -0
  13. robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/basic-crud.robot +46 -0
  14. robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/file-upload.robot +28 -0
  15. robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/session-handling.robot +48 -0
  16. robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/authentication.md +58 -0
  17. robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/install.md +10 -0
  18. robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/request-options.md +90 -0
  19. robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/response-validation.md +64 -0
  20. robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/troubleshooting.md +64 -0
  21. robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/SKILL.md +119 -0
  22. robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/assets/examples/basic-rest.robot +51 -0
  23. robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/assets/examples/schema-validation.robot +38 -0
  24. robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/assets/examples/schemas/user.json +10 -0
  25. robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/authentication.md +61 -0
  26. robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/install.md +11 -0
  27. robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/json-handling.md +89 -0
  28. robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/migrate-from-requests.md +15 -0
  29. robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/schema-validation.md +85 -0
  30. robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/troubleshooting.md +68 -0
  31. robotframework_plugins/_assets/plugins/rf-core/.claude-plugin/plugin.json +19 -0
  32. robotframework_plugins/_assets/plugins/rf-core/CHANGELOG.md +11 -0
  33. robotframework_plugins/_assets/plugins/rf-core/README.md +38 -0
  34. robotframework_plugins/_assets/plugins/rf-core/agents/rf-debug-expert.md +104 -0
  35. robotframework_plugins/_assets/plugins/rf-core/agents/rf-migration-guide.md +73 -0
  36. robotframework_plugins/_assets/plugins/rf-core/agents/rf-test-architect.md +98 -0
  37. robotframework_plugins/_assets/plugins/rf-core/catalog.yaml +19 -0
  38. robotframework_plugins/_assets/plugins/rf-core/hooks/README.md +435 -0
  39. robotframework_plugins/_assets/plugins/rf-core/hooks/hooks.json +70 -0
  40. robotframework_plugins/_assets/plugins/rf-core/scripts/_hook_input.mjs +101 -0
  41. robotframework_plugins/_assets/plugins/rf-core/scripts/_pending_errors.mjs +65 -0
  42. robotframework_plugins/_assets/plugins/rf-core/scripts/_python_env.mjs +181 -0
  43. robotframework_plugins/_assets/plugins/rf-core/scripts/check_rf_environment.mjs +181 -0
  44. robotframework_plugins/_assets/plugins/rf-core/scripts/maybe_inject_rf_context.mjs +74 -0
  45. robotframework_plugins/_assets/plugins/rf-core/scripts/maybe_remind_robot_tests.mjs +108 -0
  46. robotframework_plugins/_assets/plugins/rf-core/scripts/report_pending_errors.mjs +72 -0
  47. robotframework_plugins/_assets/plugins/rf-core/scripts/rf_error_hints.mjs +126 -0
  48. robotframework_plugins/_assets/plugins/rf-core/scripts/validate_robot.mjs +509 -0
  49. robotframework_plugins/_assets/plugins/rf-core/scripts/validate_robot_project.mjs +103 -0
  50. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/SKILL.md +313 -0
  51. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/api.resource +30 -0
  52. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/calc.resource +23 -0
  53. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/embedded.resource +20 -0
  54. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/keywords.resource +26 -0
  55. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/login.resource +10 -0
  56. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/01__keyword_driven.robot +15 -0
  57. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/02__data_driven.robot +10 -0
  58. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/03__templates.robot +17 -0
  59. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/04__bdd.robot +10 -0
  60. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/05__embedded.robot +13 -0
  61. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/__init__.robot +6 -0
  62. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/api/__init__.robot +7 -0
  63. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/api/users.robot +18 -0
  64. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/env.robot +15 -0
  65. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/variables/common.py +11 -0
  66. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/variables/dev.yaml +3 -0
  67. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/variables/staging.yaml +3 -0
  68. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/arguments.md +139 -0
  69. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/control-structures.md +175 -0
  70. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/embedded-arguments.md +135 -0
  71. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/migration.md +90 -0
  72. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/resources-and-variable-files.md +127 -0
  73. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/styles.md +92 -0
  74. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/suites-and-init.md +96 -0
  75. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/tags-and-selection.md +104 -0
  76. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/templates.md +124 -0
  77. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/variables-and-scopes.md +129 -0
  78. robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/scripts/rf_conventions.py +883 -0
  79. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/SKILL.md +216 -0
  80. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/ExampleLibrary.py +61 -0
  81. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/ResultListener.py +60 -0
  82. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/converters.py +48 -0
  83. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/converters.robot +20 -0
  84. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/example_library.robot +31 -0
  85. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/listener.robot +12 -0
  86. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/api-variants.md +291 -0
  87. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/communication.md +248 -0
  88. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/conversion.md +347 -0
  89. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/listeners.md +150 -0
  90. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/packaging-and-docs.md +155 -0
  91. robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/scripts/check_library.py +842 -0
  92. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/SKILL.md +159 -0
  93. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/github-actions-robot.yml +32 -0
  94. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/gitignore.txt +22 -0
  95. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/pyproject.poetry.toml +28 -0
  96. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/pyproject.uv.toml +20 -0
  97. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/requirements.txt +9 -0
  98. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/robot.toml +16 -0
  99. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/smoke.robot +22 -0
  100. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/ci.md +61 -0
  101. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/cli-tools.md +33 -0
  102. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/libraries.md +47 -0
  103. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/poetry.md +77 -0
  104. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/project-layout.md +86 -0
  105. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/troubleshooting.md +73 -0
  106. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/uv.md +108 -0
  107. robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/venv-pip.md +71 -0
  108. robotframework_plugins/_assets/plugins/rf-core/variants/codex/agents/rf-debug-expert.toml +103 -0
  109. robotframework_plugins/_assets/plugins/rf-core/variants/codex/agents/rf-migration-guide.toml +72 -0
  110. robotframework_plugins/_assets/plugins/rf-core/variants/codex/agents/rf-test-architect.toml +97 -0
  111. robotframework_plugins/_assets/plugins/rf-core/variants/opencode/agents/rf-debug-expert.md +107 -0
  112. robotframework_plugins/_assets/plugins/rf-core/variants/opencode/agents/rf-migration-guide.md +76 -0
  113. robotframework_plugins/_assets/plugins/rf-core/variants/opencode/agents/rf-test-architect.md +101 -0
  114. robotframework_plugins/_assets/plugins/rf-core/variants/opencode/plugins/rf-core.js +93 -0
  115. robotframework_plugins/_assets/plugins/rf-desktop/.claude-plugin/plugin.json +24 -0
  116. robotframework_plugins/_assets/plugins/rf-desktop/CHANGELOG.md +9 -0
  117. robotframework_plugins/_assets/plugins/rf-desktop/README.md +26 -0
  118. robotframework_plugins/_assets/plugins/rf-desktop/catalog.yaml +23 -0
  119. robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/SKILL.md +266 -0
  120. robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/assets/examples/calculator.robot +45 -0
  121. robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/assets/examples/mock-deterministic.robot +33 -0
  122. robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/cli-and-inspector.md +82 -0
  123. robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/install.md +14 -0
  124. robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/keywords-reference.md +102 -0
  125. robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/locators-and-queries.md +95 -0
  126. robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/platform-setup.md +65 -0
  127. robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/status-and-migration.md +41 -0
  128. robotframework_plugins/_assets/plugins/rf-mobile/.claude-plugin/plugin.json +24 -0
  129. robotframework_plugins/_assets/plugins/rf-mobile/CHANGELOG.md +9 -0
  130. robotframework_plugins/_assets/plugins/rf-mobile/README.md +26 -0
  131. robotframework_plugins/_assets/plugins/rf-mobile/catalog.yaml +23 -0
  132. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/SKILL.md +134 -0
  133. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/android-basic.robot +60 -0
  134. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/gestures-example.robot +59 -0
  135. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/hybrid-app.robot +54 -0
  136. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/ios-basic.robot +48 -0
  137. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/capabilities.md +117 -0
  138. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/gestures-touch.md +84 -0
  139. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/install.md +21 -0
  140. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/locators-mobile.md +74 -0
  141. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/platform-specific.md +105 -0
  142. robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/troubleshooting.md +70 -0
  143. robotframework_plugins/_assets/plugins/rf-web/.claude-plugin/plugin.json +25 -0
  144. robotframework_plugins/_assets/plugins/rf-web/CHANGELOG.md +9 -0
  145. robotframework_plugins/_assets/plugins/rf-web/README.md +27 -0
  146. robotframework_plugins/_assets/plugins/rf-web/catalog.yaml +27 -0
  147. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/SKILL.md +132 -0
  148. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/authentication-flow.robot +34 -0
  149. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/basic-web-test.robot +29 -0
  150. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/form-handling.robot +49 -0
  151. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/iframe-shadow-dom.robot +31 -0
  152. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/assertion-engine.md +79 -0
  153. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/authentication-storage.md +86 -0
  154. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/browser-context-page.md +110 -0
  155. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/downloads-uploads.md +51 -0
  156. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/iframes-shadow-dom.md +67 -0
  157. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/install.md +67 -0
  158. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/locators.md +83 -0
  159. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/migrate-from-selenium.md +22 -0
  160. robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/troubleshooting.md +100 -0
  161. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/SKILL.md +123 -0
  162. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/assets/examples/basic-web-test.robot +64 -0
  163. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/assets/examples/multi-window.robot +55 -0
  164. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/assets/examples/wait-patterns.robot +53 -0
  165. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/browser-setup.md +103 -0
  166. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/frames-windows.md +84 -0
  167. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/install.md +12 -0
  168. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/javascript-execution.md +65 -0
  169. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/locators.md +86 -0
  170. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/troubleshooting.md +122 -0
  171. robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/waiting-strategies.md +84 -0
  172. robotframework_plugins/_assets.py +120 -0
  173. robotframework_plugins/_catalog.py +123 -0
  174. robotframework_plugins/_snapshot.py +230 -0
  175. robotframework_plugins/adapters/__init__.py +53 -0
  176. robotframework_plugins/adapters/_base.py +400 -0
  177. robotframework_plugins/adapters/claude_code.py +312 -0
  178. robotframework_plugins/adapters/claude_desktop.py +129 -0
  179. robotframework_plugins/adapters/codex.py +276 -0
  180. robotframework_plugins/adapters/copilot.py +87 -0
  181. robotframework_plugins/adapters/cursor.py +295 -0
  182. robotframework_plugins/adapters/goose.py +240 -0
  183. robotframework_plugins/adapters/opencode.py +170 -0
  184. robotframework_plugins/bundle.py +85 -0
  185. robotframework_plugins/cli.py +1311 -0
  186. robotframework_plugins/detect.py +121 -0
  187. robotframework_plugins/manifest.py +338 -0
  188. robotframework_plugins/py.typed +0 -0
  189. robotframework_plugins/skillzip.py +39 -0
  190. robotframework_plugins/transforms.py +725 -0
  191. robotframework_plugins-2026.11.0.dev1.dist-info/METADATA +178 -0
  192. robotframework_plugins-2026.11.0.dev1.dist-info/RECORD +195 -0
  193. robotframework_plugins-2026.11.0.dev1.dist-info/WHEEL +4 -0
  194. robotframework_plugins-2026.11.0.dev1.dist-info/entry_points.txt +2 -0
  195. robotframework_plugins-2026.11.0.dev1.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,121 @@
1
+ """Pick the plugins a project needs from the libraries it declares.
2
+
3
+ Reads the project root's ``pyproject.toml`` (PEP 621 ``dependencies`` and
4
+ ``optional-dependencies``, PEP 735 ``dependency-groups``, Poetry
5
+ ``dependencies``, ``dev-dependencies`` and ``group.*.dependencies``) and its
6
+ ``requirements*.txt`` files, and matches the package names against the
7
+ ``libraries[].package`` of each bundled plugin (spec ``plugin-split``,
8
+ "The installer picks plugins from the project").
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import re
13
+ from dataclasses import dataclass
14
+ from pathlib import Path
15
+ from typing import Any
16
+
17
+ try: # Python 3.11+
18
+ import tomllib
19
+ except ModuleNotFoundError: # pragma: no cover - Python 3.10
20
+ import tomli as tomllib
21
+
22
+ #: The start of a requirement: the distribution name (PEP 508).
23
+ _NAME = re.compile(r"^\s*([A-Za-z0-9][A-Za-z0-9._-]*)")
24
+
25
+
26
+ def normalize(name: str) -> str:
27
+ """PEP 503 name: lower case, runs of ``-``, ``_`` and ``.`` become ``-``."""
28
+ return re.sub(r"[-_.]+", "-", name).lower()
29
+
30
+
31
+ def _requirement_name(spec: str) -> str | None:
32
+ m = _NAME.match(spec)
33
+ return normalize(m.group(1)) if m else None
34
+
35
+
36
+ def _strings(value: Any) -> list[str]:
37
+ return [v for v in value if isinstance(v, str)] if isinstance(value, list) else []
38
+
39
+
40
+ def _pyproject_packages(path: Path) -> set[str]:
41
+ try:
42
+ data = tomllib.loads(path.read_text(encoding="utf-8"))
43
+ except (OSError, ValueError):
44
+ return set()
45
+ specs: list[str] = []
46
+ project = data.get("project", {})
47
+ specs += _strings(project.get("dependencies"))
48
+ for group in (project.get("optional-dependencies") or {}).values():
49
+ specs += _strings(group)
50
+ for group in (data.get("dependency-groups") or {}).values():
51
+ specs += _strings(group) # include-group tables are skipped
52
+ names = {n for n in map(_requirement_name, specs) if n}
53
+ poetry = data.get("tool", {}).get("poetry", {})
54
+ tables = [poetry.get("dependencies"), poetry.get("dev-dependencies")]
55
+ tables += [g.get("dependencies") for g in (poetry.get("group") or {}).values() if isinstance(g, dict)]
56
+ for table in tables:
57
+ if isinstance(table, dict):
58
+ names |= {normalize(k) for k in table if k.lower() != "python"}
59
+ return names
60
+
61
+
62
+ def _requirements_packages(path: Path) -> set[str]:
63
+ try:
64
+ lines = path.read_text(encoding="utf-8").splitlines()
65
+ except OSError:
66
+ return set()
67
+ names = set()
68
+ for line in lines:
69
+ line = line.split("#", 1)[0].strip()
70
+ if not line or line.startswith("-"):
71
+ continue # options such as -r, -e, --index-url
72
+ name = _requirement_name(line)
73
+ if name:
74
+ names.add(name)
75
+ return names
76
+
77
+
78
+ def declared_packages(project: Path) -> dict[str, str]:
79
+ """``{normalized package: file that declares it}`` for the project root."""
80
+ found: dict[str, str] = {}
81
+ files = [project / "pyproject.toml", *sorted(project.glob("requirements*.txt"))]
82
+ for f in files:
83
+ if not f.is_file():
84
+ continue
85
+ names = _pyproject_packages(f) if f.name == "pyproject.toml" else _requirements_packages(f)
86
+ for n in sorted(names):
87
+ found.setdefault(n, f.name)
88
+ return found
89
+
90
+
91
+ @dataclass(frozen=True)
92
+ class Detection:
93
+ """Plugins chosen for a project, and why."""
94
+ plugins: list[str]
95
+ #: ``{plugin: [(package, declaring file), ...]}`` for the detected plugins.
96
+ reasons: dict[str, list[tuple[str, str]]]
97
+
98
+ @property
99
+ def detected(self) -> bool:
100
+ return bool(self.reasons)
101
+
102
+
103
+ def detect(project: Path, catalog: list[dict[str, Any]], core: str = "rf-core") -> Detection:
104
+ """``core`` plus every active verified plugin whose library packages the
105
+ project declares; with no match, every active verified plugin with content.
106
+
107
+ Bundles are never chosen: their dependencies are listed instead."""
108
+ candidates = [p for p in catalog
109
+ if p.get("status") == "active" and p.get("tier") == "verified" and not p.get("bundle")]
110
+ candidates.sort(key=lambda p: p["name"] != core) # core first: the others depend on it
111
+ declared = declared_packages(project)
112
+ reasons: dict[str, list[tuple[str, str]]] = {}
113
+ for p in candidates:
114
+ for lib in p.get("libraries", []):
115
+ package = normalize(str(lib.get("package", "")))
116
+ if package and package in declared:
117
+ reasons.setdefault(p["name"], []).append((lib["package"], declared[package]))
118
+ if not reasons:
119
+ return Detection(plugins=[p["name"] for p in candidates], reasons={})
120
+ chosen = [p["name"] for p in candidates if p["name"] == core or p["name"] in reasons]
121
+ return Detection(plugins=chosen, reasons=reasons)
@@ -0,0 +1,338 @@
1
+ """Manifest of files written by the installer, used for safe uninstall.
2
+
3
+ Every successful ``robotframework-plugins install`` writes (or updates) a JSON
4
+ record at ``$XDG_DATA_HOME/rf-agentskills/installed.json`` listing
5
+ every destination path, its sha256 at install time, and any
6
+ config-merge that added keys to a pre-existing file.
7
+
8
+ ``uninstall`` re-reads the manifest:
9
+ * For each tracked file, re-hash the on-disk copy. If it still matches
10
+ what we wrote, delete it. If it differs, leave it (the user has
11
+ edited it) and just drop the manifest entry.
12
+ * For each tracked config-merge, parse the current file, remove only
13
+ the keys we added, write back. Never blow away the whole file.
14
+
15
+ Borrowed from ``pre-commit install/uninstall`` and ``jupyter
16
+ labextension install/uninstall`` — every robust external-file
17
+ installer in the Python ecosystem uses the same pattern.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ import hashlib
23
+ import json
24
+ import os
25
+ import time
26
+ from dataclasses import asdict, dataclass, field
27
+ from pathlib import Path
28
+ from typing import Iterator, Sequence
29
+
30
+
31
+ MANIFEST_VERSION = 1
32
+
33
+
34
+ def default_manifest_path() -> Path:
35
+ """Return ``$XDG_DATA_HOME/rf-agentskills/installed.json``.
36
+
37
+ Honours ``XDG_DATA_HOME``; falls back to ``~/.local/share`` on
38
+ Linux/macOS and ``%LOCALAPPDATA%`` on Windows (set by Python's
39
+ ``Path.home()`` callers separately — we just read what's set).
40
+ """
41
+ base = os.environ.get("XDG_DATA_HOME")
42
+ if base:
43
+ return Path(base) / "rf-agentskills" / "installed.json"
44
+ if os.name == "nt":
45
+ appdata = os.environ.get("LOCALAPPDATA") or os.environ.get("APPDATA")
46
+ if appdata:
47
+ return Path(appdata) / "rf-agentskills" / "installed.json"
48
+ return Path.home() / ".local" / "share" / "rf-agentskills" / "installed.json"
49
+
50
+
51
+ def manifest_path_for(scope: str, project_dir: Path | None) -> Path:
52
+ """Resolve the manifest location for a given install scope.
53
+
54
+ Project-scope installs keep their manifest **inside the project**
55
+ (``<project_or_cwd>/.rf-agentskills/installed.json``) so two projects
56
+ never collide on the ``(agent, scope)`` key and ``uninstall`` run from
57
+ within a repo needs no ``--project``. User-scope installs use the global
58
+ ``default_manifest_path()``.
59
+ """
60
+ if scope == "project":
61
+ base = project_dir if project_dir is not None else Path.cwd()
62
+ return base / ".rf-agentskills" / "installed.json"
63
+ return default_manifest_path()
64
+
65
+
66
+ def sha256_file(path: Path) -> str:
67
+ """SHA256 hex digest of the file at ``path``."""
68
+ h = hashlib.sha256()
69
+ with path.open("rb") as fh:
70
+ for chunk in iter(lambda: fh.read(64 * 1024), b""):
71
+ h.update(chunk)
72
+ return h.hexdigest()
73
+
74
+
75
+ @dataclass
76
+ class FileEntry:
77
+ """One file the installer wrote to a destination path."""
78
+ path: str # absolute destination path
79
+ sha256: str # hash at install time (used to detect user edits)
80
+ transform: str | None = None # name of transform applied, if any
81
+ # Install category ("skills", "agents", "hooks", "support", "hints",
82
+ # "other"). Written from installer 0.7.0 on; older records lack it and
83
+ # the category is derived from the path (see ``category_for_path``).
84
+ category: str | None = None
85
+ # Bundled plugin the file belongs to. Written from robotframework-plugins
86
+ # on; older records lack it and mean ``rf-agentskills``, the only plugin
87
+ # earlier installers shipped.
88
+ plugin: str | None = None
89
+
90
+
91
+ @dataclass
92
+ class ConfigMerge:
93
+ """A merge into a pre-existing config file (settings.json, .toml, .yaml).
94
+
95
+ ``added_keys`` lists the keys we added at the location identified
96
+ by ``key_path``. ``key_path`` is the parent traversal: ``[]`` for
97
+ top-level merges (e.g. settings.json's ``hooks`` block);
98
+ ``["mcpServers"]`` for nested merges (e.g. ``.mcp.json`` MCP server
99
+ additions). The kind tags the file format so uninstall can
100
+ dispatch to the right remover (json_top / json_nested today;
101
+ toml_table / yaml_block in later phases).
102
+ """
103
+ path: str
104
+ added_keys: list[str]
105
+ kind: str = "json_top" # "json_top" | "json_nested" | "json_hooks" | "toml_table" | "yaml_block"
106
+ key_path: list[str] = field(default_factory=list)
107
+ backup_path: str | None = None # optional pre-merge backup we can restore
108
+ # For kind="json_hooks": install-dir ownership marker. ``added_keys``
109
+ # then holds the hook event names rf-agentskills contributed to, and
110
+ # uninstall removes only matcher-groups whose command contains this
111
+ # marker — preserving hooks added by the user or other tools.
112
+ marker: str | None = None
113
+
114
+
115
+ @dataclass
116
+ class Installation:
117
+ """All side-effects of one ``install --agent X`` invocation."""
118
+ agent: str
119
+ scope: str # "user" | "project"
120
+ installed_at: str # ISO-8601 UTC
121
+ bundle_version: str # robotframework-plugins version that wrote this
122
+ files: list[FileEntry] = field(default_factory=list)
123
+ config_merges: list[ConfigMerge] = field(default_factory=list)
124
+ notes: list[str] = field(default_factory=list)
125
+
126
+
127
+ @dataclass
128
+ class Manifest:
129
+ """Top-level manifest record. There is at most one per machine."""
130
+ version: int = MANIFEST_VERSION
131
+ installations: list[Installation] = field(default_factory=list)
132
+
133
+ # ---- I/O ---------------------------------------------------------------
134
+
135
+ @classmethod
136
+ def load(cls, path: Path | None = None) -> "Manifest":
137
+ path = path or default_manifest_path()
138
+ if not path.is_file():
139
+ return cls()
140
+ try:
141
+ data = json.loads(path.read_text(encoding="utf-8"))
142
+ except (OSError, json.JSONDecodeError):
143
+ return cls()
144
+ if not isinstance(data, dict) or data.get("version") != MANIFEST_VERSION:
145
+ return cls()
146
+ installations = []
147
+ for entry in data.get("installations", []):
148
+ installations.append(
149
+ Installation(
150
+ agent=entry["agent"],
151
+ scope=entry.get("scope", "user"),
152
+ installed_at=entry.get("installed_at", ""),
153
+ bundle_version=entry.get("bundle_version", "unknown"),
154
+ files=[
155
+ FileEntry(
156
+ path=f["path"],
157
+ sha256=f["sha256"],
158
+ transform=f.get("transform"),
159
+ category=f.get("category"),
160
+ plugin=f.get("plugin"),
161
+ )
162
+ for f in entry.get("files", [])
163
+ ],
164
+ config_merges=[
165
+ # Tolerate older manifest entries that lack the
166
+ # newer `kind` / `key_path` fields by
167
+ # supplying defaults.
168
+ ConfigMerge(
169
+ path=m["path"],
170
+ added_keys=list(m.get("added_keys", [])),
171
+ kind=m.get("kind", "json_top"),
172
+ key_path=list(m.get("key_path", [])),
173
+ backup_path=m.get("backup_path"),
174
+ marker=m.get("marker"),
175
+ )
176
+ for m in entry.get("config_merges", [])
177
+ ],
178
+ notes=list(entry.get("notes", [])),
179
+ )
180
+ )
181
+ return cls(version=MANIFEST_VERSION, installations=installations)
182
+
183
+ def save(self, path: Path | None = None) -> Path:
184
+ path = path or default_manifest_path()
185
+ path.parent.mkdir(parents=True, exist_ok=True)
186
+ payload = {
187
+ "version": self.version,
188
+ "installations": [
189
+ {
190
+ "agent": ins.agent,
191
+ "scope": ins.scope,
192
+ "installed_at": ins.installed_at,
193
+ "bundle_version": ins.bundle_version,
194
+ "files": [asdict(f) for f in ins.files],
195
+ "config_merges": [asdict(m) for m in ins.config_merges],
196
+ "notes": ins.notes,
197
+ }
198
+ for ins in self.installations
199
+ ],
200
+ }
201
+ # Atomic-ish write: tmp + rename.
202
+ tmp = path.with_suffix(path.suffix + ".tmp")
203
+ tmp.write_text(json.dumps(payload, indent=2, sort_keys=False), encoding="utf-8")
204
+ os.replace(tmp, path)
205
+ return path
206
+
207
+ # ---- queries -----------------------------------------------------------
208
+
209
+ def for_agent(self, agent: str, scope: str = "user") -> Installation | None:
210
+ for ins in self.installations:
211
+ if ins.agent == agent and ins.scope == scope:
212
+ return ins
213
+ return None
214
+
215
+ def iter_agents(self) -> Iterator[Installation]:
216
+ yield from self.installations
217
+
218
+ # ---- mutators ----------------------------------------------------------
219
+
220
+ def upsert(self, installation: Installation) -> None:
221
+ """Replace any existing record for the same (agent, scope) pair."""
222
+ self.installations = [
223
+ ins
224
+ for ins in self.installations
225
+ if not (ins.agent == installation.agent and ins.scope == installation.scope)
226
+ ]
227
+ self.installations.append(installation)
228
+
229
+ def remove(self, agent: str, scope: str = "user") -> Installation | None:
230
+ """Drop and return the matching installation record."""
231
+ for i, ins in enumerate(self.installations):
232
+ if ins.agent == agent and ins.scope == scope:
233
+ return self.installations.pop(i)
234
+ return None
235
+
236
+
237
+ def now_iso() -> str:
238
+ return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
239
+
240
+
241
+ def file_entry_for(dest: Path, transform: str | None = None, plugin: str | None = None) -> FileEntry:
242
+ """Build a FileEntry by reading the on-disk hash at ``dest``."""
243
+ return FileEntry(
244
+ path=str(dest),
245
+ sha256=sha256_file(dest),
246
+ transform=transform,
247
+ category=category_for_path(dest),
248
+ plugin=plugin,
249
+ )
250
+
251
+
252
+ # Directory that holds the co-located plugin files (scripts/, servers/,
253
+ # hooks/, .claude-plugin/) for every adapter: ``<plugin>-files``. Installs
254
+ # before robotframework-plugins only ever wrote this one.
255
+ SUPPORT_DIR_NAME = "rf-agentskills-files"
256
+ SUPPORT_DIR_SUFFIX = "-files"
257
+
258
+
259
+ def support_dir_index(parts: tuple[str, ...]) -> int | None:
260
+ """Index of the ``<plugin>-files`` component in an installed path, if any."""
261
+ for i, part in enumerate(parts[:-1]):
262
+ if part.endswith(SUPPORT_DIR_SUFFIX) and len(part) > len(SUPPORT_DIR_SUFFIX):
263
+ return i
264
+ return None
265
+
266
+
267
+ def category_for_path(path: str | Path) -> str:
268
+ """Classify an installed file by its destination path.
269
+
270
+ * ``.../rf-agentskills-files/...`` -> ``"support"`` (shared scripts,
271
+ servers, hooks, plugin manifest)
272
+ * ``.goosehints`` -> ``"hints"``
273
+ * nearest ``skills`` / ``agents`` path component (searched from the
274
+ file upwards) -> ``"skills"`` / ``"agents"``
275
+ * ``hooks.json`` -> ``"hooks"`` (Codex)
276
+ * anything else -> ``"other"``
277
+
278
+ Used both for new manifest entries and for records written by
279
+ installers older than 0.7.0 that carry no ``category``.
280
+ """
281
+ p = Path(path)
282
+ parts = p.parts
283
+ if support_dir_index(parts) is not None:
284
+ return "support"
285
+ if p.name == ".goosehints":
286
+ return "hints"
287
+ for part in reversed(parts[:-1]):
288
+ if part == "skills":
289
+ return "skills"
290
+ if part == "agents":
291
+ return "agents"
292
+ if p.name == "hooks.json":
293
+ return "hooks"
294
+ return "other"
295
+
296
+
297
+ def entry_category(entry: FileEntry) -> str:
298
+ """The recorded category, or the path-derived one for old records."""
299
+ return entry.category or category_for_path(entry.path)
300
+
301
+
302
+ def is_user_modified(entry: FileEntry) -> bool:
303
+ """True if the on-disk file differs from what we recorded.
304
+
305
+ Treats a missing file as 'not user-modified' (unrelated event;
306
+ uninstall just skips it).
307
+ """
308
+ p = Path(entry.path)
309
+ if not p.is_file():
310
+ return False
311
+ return sha256_file(p) != entry.sha256
312
+
313
+
314
+ def files_to_remove(installation: Installation) -> Iterator[Path]:
315
+ """Yield paths whose hash still matches the recorded one (safe to delete)."""
316
+ for entry in installation.files:
317
+ p = Path(entry.path)
318
+ if not p.is_file():
319
+ continue
320
+ if not is_user_modified(entry):
321
+ yield p
322
+
323
+
324
+ def prune_empty_parents(path: Path, stop_at: Path | None = None) -> None:
325
+ """Remove parent dirs of ``path`` while they are empty, up to ``stop_at``.
326
+
327
+ Stops at the first non-empty directory or at ``stop_at`` (exclusive).
328
+ Used to clean up ``~/.claude/skills/<name>/`` after the SKILL.md is
329
+ deleted, but never to traverse above a sentinel root.
330
+ """
331
+ parent = path.parent
332
+ home = stop_at or Path.home()
333
+ while parent != home and parent.exists():
334
+ try:
335
+ parent.rmdir()
336
+ except OSError:
337
+ return
338
+ parent = parent.parent
File without changes
@@ -0,0 +1,39 @@
1
+ """Upload archives for Claude Desktop / claude.ai skills (stdlib only).
2
+
3
+ Kept free of the installer's third-party imports so
4
+ ``scripts/build-skill-zips.py`` runs on a bare Python in CI.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import io
10
+ import zipfile
11
+ from pathlib import Path
12
+
13
+ #: Fixed timestamp so the same skill tree always yields identical bytes
14
+ #: (the manifest's hash checks rely on it).
15
+ _ZIP_EPOCH = (1980, 1, 1, 0, 0, 0)
16
+
17
+
18
+ def skill_zip_bytes(skill_dir: Path) -> bytes:
19
+ """A ``<name>.zip`` for uploading one skill: ``<name>/SKILL.md`` + its tree.
20
+
21
+ The skill folder is the archive's root entry, as Claude's skill upload
22
+ expects. Bytecode caches are left out; entries are sorted and stamped
23
+ with a fixed date, so the output is deterministic.
24
+ """
25
+ if not (skill_dir / "SKILL.md").is_file():
26
+ raise ValueError(f"{skill_dir} has no SKILL.md")
27
+ files = sorted(
28
+ f for f in skill_dir.rglob("*")
29
+ if f.is_file() and "__pycache__" not in f.parts and f.suffix != ".pyc"
30
+ )
31
+ buf = io.BytesIO()
32
+ with zipfile.ZipFile(buf, "w", compression=zipfile.ZIP_DEFLATED) as zf:
33
+ for f in files:
34
+ arc = f"{skill_dir.name}/{f.relative_to(skill_dir).as_posix()}"
35
+ info = zipfile.ZipInfo(arc, date_time=_ZIP_EPOCH)
36
+ info.compress_type = zipfile.ZIP_DEFLATED
37
+ info.external_attr = (0o755 if f.suffix in (".py", ".sh") else 0o644) << 16
38
+ zf.writestr(info, f.read_bytes())
39
+ return buf.getvalue()