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.
- robotframework_plugins/__init__.py +14 -0
- robotframework_plugins/_assets/catalog.json +143 -0
- robotframework_plugins/_assets/plugins/rf-agentskills/.claude-plugin/plugin.json +25 -0
- robotframework_plugins/_assets/plugins/rf-agentskills/CHANGELOG.md +198 -0
- robotframework_plugins/_assets/plugins/rf-agentskills/README.md +27 -0
- robotframework_plugins/_assets/plugins/rf-agentskills/catalog.yaml +25 -0
- robotframework_plugins/_assets/plugins/rf-api/.claude-plugin/plugin.json +25 -0
- robotframework_plugins/_assets/plugins/rf-api/CHANGELOG.md +9 -0
- robotframework_plugins/_assets/plugins/rf-api/README.md +27 -0
- robotframework_plugins/_assets/plugins/rf-api/catalog.yaml +27 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/SKILL.md +110 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/authentication-patterns.robot +39 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/basic-crud.robot +46 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/file-upload.robot +28 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/assets/examples/session-handling.robot +48 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/authentication.md +58 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/install.md +10 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/request-options.md +90 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/response-validation.md +64 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-requests/references/troubleshooting.md +64 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/SKILL.md +119 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/assets/examples/basic-rest.robot +51 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/assets/examples/schema-validation.robot +38 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/assets/examples/schemas/user.json +10 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/authentication.md +61 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/install.md +11 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/json-handling.md +89 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/migrate-from-requests.md +15 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/schema-validation.md +85 -0
- robotframework_plugins/_assets/plugins/rf-api/skills/rf-restinstance/references/troubleshooting.md +68 -0
- robotframework_plugins/_assets/plugins/rf-core/.claude-plugin/plugin.json +19 -0
- robotframework_plugins/_assets/plugins/rf-core/CHANGELOG.md +11 -0
- robotframework_plugins/_assets/plugins/rf-core/README.md +38 -0
- robotframework_plugins/_assets/plugins/rf-core/agents/rf-debug-expert.md +104 -0
- robotframework_plugins/_assets/plugins/rf-core/agents/rf-migration-guide.md +73 -0
- robotframework_plugins/_assets/plugins/rf-core/agents/rf-test-architect.md +98 -0
- robotframework_plugins/_assets/plugins/rf-core/catalog.yaml +19 -0
- robotframework_plugins/_assets/plugins/rf-core/hooks/README.md +435 -0
- robotframework_plugins/_assets/plugins/rf-core/hooks/hooks.json +70 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/_hook_input.mjs +101 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/_pending_errors.mjs +65 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/_python_env.mjs +181 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/check_rf_environment.mjs +181 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/maybe_inject_rf_context.mjs +74 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/maybe_remind_robot_tests.mjs +108 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/report_pending_errors.mjs +72 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/rf_error_hints.mjs +126 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/validate_robot.mjs +509 -0
- robotframework_plugins/_assets/plugins/rf-core/scripts/validate_robot_project.mjs +103 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/SKILL.md +313 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/api.resource +30 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/calc.resource +23 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/embedded.resource +20 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/keywords.resource +26 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/resources/login.resource +10 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/01__keyword_driven.robot +15 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/02__data_driven.robot +10 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/03__templates.robot +17 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/04__bdd.robot +10 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/05__embedded.robot +13 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/__init__.robot +6 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/api/__init__.robot +7 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/api/users.robot +18 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/tests/env.robot +15 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/variables/common.py +11 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/variables/dev.yaml +3 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/assets/examples/variables/staging.yaml +3 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/arguments.md +139 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/control-structures.md +175 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/embedded-arguments.md +135 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/migration.md +90 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/resources-and-variable-files.md +127 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/styles.md +92 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/suites-and-init.md +96 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/tags-and-selection.md +104 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/templates.md +124 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/references/variables-and-scopes.md +129 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-language/scripts/rf_conventions.py +883 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/SKILL.md +216 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/ExampleLibrary.py +61 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/ResultListener.py +60 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/converters.py +48 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/converters.robot +20 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/example_library.robot +31 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/assets/examples/listener.robot +12 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/api-variants.md +291 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/communication.md +248 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/conversion.md +347 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/listeners.md +150 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/references/packaging-and-docs.md +155 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-python-library/scripts/check_library.py +842 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/SKILL.md +159 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/github-actions-robot.yml +32 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/gitignore.txt +22 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/pyproject.poetry.toml +28 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/pyproject.uv.toml +20 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/requirements.txt +9 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/robot.toml +16 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/assets/examples/smoke.robot +22 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/ci.md +61 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/cli-tools.md +33 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/libraries.md +47 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/poetry.md +77 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/project-layout.md +86 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/troubleshooting.md +73 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/uv.md +108 -0
- robotframework_plugins/_assets/plugins/rf-core/skills/rf-setup/references/venv-pip.md +71 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/codex/agents/rf-debug-expert.toml +103 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/codex/agents/rf-migration-guide.toml +72 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/codex/agents/rf-test-architect.toml +97 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/opencode/agents/rf-debug-expert.md +107 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/opencode/agents/rf-migration-guide.md +76 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/opencode/agents/rf-test-architect.md +101 -0
- robotframework_plugins/_assets/plugins/rf-core/variants/opencode/plugins/rf-core.js +93 -0
- robotframework_plugins/_assets/plugins/rf-desktop/.claude-plugin/plugin.json +24 -0
- robotframework_plugins/_assets/plugins/rf-desktop/CHANGELOG.md +9 -0
- robotframework_plugins/_assets/plugins/rf-desktop/README.md +26 -0
- robotframework_plugins/_assets/plugins/rf-desktop/catalog.yaml +23 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/SKILL.md +266 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/assets/examples/calculator.robot +45 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/assets/examples/mock-deterministic.robot +33 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/cli-and-inspector.md +82 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/install.md +14 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/keywords-reference.md +102 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/locators-and-queries.md +95 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/platform-setup.md +65 -0
- robotframework_plugins/_assets/plugins/rf-desktop/skills/rf-platynui/references/status-and-migration.md +41 -0
- robotframework_plugins/_assets/plugins/rf-mobile/.claude-plugin/plugin.json +24 -0
- robotframework_plugins/_assets/plugins/rf-mobile/CHANGELOG.md +9 -0
- robotframework_plugins/_assets/plugins/rf-mobile/README.md +26 -0
- robotframework_plugins/_assets/plugins/rf-mobile/catalog.yaml +23 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/SKILL.md +134 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/android-basic.robot +60 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/gestures-example.robot +59 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/hybrid-app.robot +54 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/assets/examples/ios-basic.robot +48 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/capabilities.md +117 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/gestures-touch.md +84 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/install.md +21 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/locators-mobile.md +74 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/platform-specific.md +105 -0
- robotframework_plugins/_assets/plugins/rf-mobile/skills/rf-appium/references/troubleshooting.md +70 -0
- robotframework_plugins/_assets/plugins/rf-web/.claude-plugin/plugin.json +25 -0
- robotframework_plugins/_assets/plugins/rf-web/CHANGELOG.md +9 -0
- robotframework_plugins/_assets/plugins/rf-web/README.md +27 -0
- robotframework_plugins/_assets/plugins/rf-web/catalog.yaml +27 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/SKILL.md +132 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/authentication-flow.robot +34 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/basic-web-test.robot +29 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/form-handling.robot +49 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/assets/examples/iframe-shadow-dom.robot +31 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/assertion-engine.md +79 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/authentication-storage.md +86 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/browser-context-page.md +110 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/downloads-uploads.md +51 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/iframes-shadow-dom.md +67 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/install.md +67 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/locators.md +83 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/migrate-from-selenium.md +22 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-browser/references/troubleshooting.md +100 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/SKILL.md +123 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/assets/examples/basic-web-test.robot +64 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/assets/examples/multi-window.robot +55 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/assets/examples/wait-patterns.robot +53 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/browser-setup.md +103 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/frames-windows.md +84 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/install.md +12 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/javascript-execution.md +65 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/locators.md +86 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/troubleshooting.md +122 -0
- robotframework_plugins/_assets/plugins/rf-web/skills/rf-selenium/references/waiting-strategies.md +84 -0
- robotframework_plugins/_assets.py +120 -0
- robotframework_plugins/_catalog.py +123 -0
- robotframework_plugins/_snapshot.py +230 -0
- robotframework_plugins/adapters/__init__.py +53 -0
- robotframework_plugins/adapters/_base.py +400 -0
- robotframework_plugins/adapters/claude_code.py +312 -0
- robotframework_plugins/adapters/claude_desktop.py +129 -0
- robotframework_plugins/adapters/codex.py +276 -0
- robotframework_plugins/adapters/copilot.py +87 -0
- robotframework_plugins/adapters/cursor.py +295 -0
- robotframework_plugins/adapters/goose.py +240 -0
- robotframework_plugins/adapters/opencode.py +170 -0
- robotframework_plugins/bundle.py +85 -0
- robotframework_plugins/cli.py +1311 -0
- robotframework_plugins/detect.py +121 -0
- robotframework_plugins/manifest.py +338 -0
- robotframework_plugins/py.typed +0 -0
- robotframework_plugins/skillzip.py +39 -0
- robotframework_plugins/transforms.py +725 -0
- robotframework_plugins-2026.11.0.dev1.dist-info/METADATA +178 -0
- robotframework_plugins-2026.11.0.dev1.dist-info/RECORD +195 -0
- robotframework_plugins-2026.11.0.dev1.dist-info/WHEEL +4 -0
- robotframework_plugins-2026.11.0.dev1.dist-info/entry_points.txt +2 -0
- robotframework_plugins-2026.11.0.dev1.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// _hook_input.mjs — one reader for every agent's hook input.
|
|
2
|
+
//
|
|
3
|
+
// The plugin's Claude-format hooks.json runs in Claude Code, Copilot CLI,
|
|
4
|
+
// VS Code, Codex and Cursor. Each sends the same event names but its own tool
|
|
5
|
+
// names and input shapes (observed 2026-10-08):
|
|
6
|
+
//
|
|
7
|
+
// Claude Code / Copilot CLI tool_name Write|Edit|MultiEdit, tool_input.file_path
|
|
8
|
+
// Cursor (converted hooks) tool_name Write|Shell, file_path or tool_input.file_path
|
|
9
|
+
// VS Code create_file / replace_string_in_file: tool_input.filePath
|
|
10
|
+
// multi_replace_string_in_file: tool_input.replacements[].filePath
|
|
11
|
+
// apply_patch: tool_input.input (patch text); run_in_terminal
|
|
12
|
+
// Codex apply_patch: tool_input.command (patch text); Bash
|
|
13
|
+
//
|
|
14
|
+
// VS Code ignores matchers in Claude-format hooks and runs every command for
|
|
15
|
+
// every tool, so callers must check `isEdit` / `isShell` and exit quietly.
|
|
16
|
+
import { readFileSync } from "node:fs";
|
|
17
|
+
import { isAbsolute, resolve } from "node:path";
|
|
18
|
+
|
|
19
|
+
const EDIT_TOOLS =
|
|
20
|
+
/^(write|edit|multiedit|apply_patch|create_file|replace_string_in_file|multi_replace_string_in_file|insert_edit_into_file|edit_file|edit_notebook_file|create)$/i;
|
|
21
|
+
const SHELL_TOOLS = /^(bash|shell|run_in_terminal|powershell|exec_command|local_shell)$/i;
|
|
22
|
+
const PATCH_FILE_RE = /^\*\*\* (?:Add File|Update File|Move to): (.+)$/;
|
|
23
|
+
|
|
24
|
+
function parseJson(text) {
|
|
25
|
+
if (typeof text !== "string" || !text.trim()) return null;
|
|
26
|
+
try {
|
|
27
|
+
const obj = JSON.parse(text);
|
|
28
|
+
return obj && typeof obj === "object" ? obj : null;
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Paths of every file an `apply_patch` envelope adds, updates or moves to. */
|
|
35
|
+
export function patchFiles(patch) {
|
|
36
|
+
if (typeof patch !== "string" || !patch.includes("*** ")) return [];
|
|
37
|
+
const files = [];
|
|
38
|
+
for (const line of patch.split(/\r?\n/)) {
|
|
39
|
+
const m = PATCH_FILE_RE.exec(line.trim());
|
|
40
|
+
if (m) files.push(m[1].trim());
|
|
41
|
+
}
|
|
42
|
+
return files;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function patchText(toolInput) {
|
|
46
|
+
if (typeof toolInput === "string") return toolInput;
|
|
47
|
+
for (const key of ["input", "command", "patch"]) {
|
|
48
|
+
const v = toolInput?.[key];
|
|
49
|
+
if (typeof v === "string" && /\*\*\* (Begin Patch|Add File:|Update File:)/.test(v)) return v;
|
|
50
|
+
}
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Normalize one hook event.
|
|
56
|
+
* @returns {{event: object|null, tool: string, isEdit: boolean, isShell: boolean,
|
|
57
|
+
* files: string[], command: string, cwd: string}}
|
|
58
|
+
*/
|
|
59
|
+
export function normalizeHookInput(event) {
|
|
60
|
+
const empty = { event: null, tool: "", isEdit: false, isShell: false, files: [], command: "", cwd: process.cwd() };
|
|
61
|
+
if (!event || typeof event !== "object") return empty;
|
|
62
|
+
const tool = String(event.tool_name ?? event.toolName ?? "");
|
|
63
|
+
let toolInput = event.tool_input ?? event.toolArgs ?? {};
|
|
64
|
+
if (typeof toolInput === "string") toolInput = parseJson(toolInput) ?? toolInput;
|
|
65
|
+
const cwd = String(event.cwd || process.cwd());
|
|
66
|
+
|
|
67
|
+
const raw = [];
|
|
68
|
+
const patch = patchText(toolInput);
|
|
69
|
+
raw.push(...patchFiles(patch));
|
|
70
|
+
if (toolInput && typeof toolInput === "object") {
|
|
71
|
+
for (const key of ["file_path", "filePath"]) {
|
|
72
|
+
if (typeof toolInput[key] === "string") raw.push(toolInput[key]);
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(toolInput.replacements)) {
|
|
75
|
+
for (const r of toolInput.replacements) if (typeof r?.filePath === "string") raw.push(r.filePath);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (typeof event.file_path === "string") raw.push(event.file_path);
|
|
79
|
+
|
|
80
|
+
const files = [...new Set(raw.filter(Boolean).map((f) => (isAbsolute(f) ? f : resolve(cwd, f))))];
|
|
81
|
+
// No tool name (legacy TOOL_INPUT, Cursor afterFileEdit): a file path means an edit.
|
|
82
|
+
const isEdit = tool ? EDIT_TOOLS.test(tool) : files.length > 0;
|
|
83
|
+
const isShell = SHELL_TOOLS.test(tool);
|
|
84
|
+
const command = isShell && !patch && typeof toolInput?.command === "string" ? toolInput.command : "";
|
|
85
|
+
return { event, tool, isEdit, isShell, files: isEdit ? files : [], command, cwd };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Read the hook event from stdin (legacy `TOOL_INPUT` env var as a fallback). */
|
|
89
|
+
export function readHookInput() {
|
|
90
|
+
let stdin = "";
|
|
91
|
+
try {
|
|
92
|
+
stdin = readFileSync(0, "utf-8");
|
|
93
|
+
} catch {
|
|
94
|
+
// no stdin
|
|
95
|
+
}
|
|
96
|
+
for (const source of [stdin, process.env.TOOL_INPUT ?? ""]) {
|
|
97
|
+
const obj = parseJson(source);
|
|
98
|
+
if (obj) return normalizeHookInput(obj);
|
|
99
|
+
}
|
|
100
|
+
return normalizeHookInput(null);
|
|
101
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// _pending_errors.mjs — per-session record of .robot/.resource files whose
|
|
2
|
+
// last PostToolUse validation found real errors.
|
|
3
|
+
//
|
|
4
|
+
// Why: VS Code's Local agent mode (1.142) sends the next model request
|
|
5
|
+
// without waiting for PostToolUse hooks, so the validation error never
|
|
6
|
+
// reaches the model. Stop hooks ARE awaited, so validate_robot.mjs records
|
|
7
|
+
// failing files here and report_pending_errors.mjs re-checks them at Stop.
|
|
8
|
+
// In agents where PostToolUse feedback works, the fixing edit clears the
|
|
9
|
+
// entry again and the Stop hook stays silent.
|
|
10
|
+
//
|
|
11
|
+
// State: { "<abs path>": { reported: "<sha1 of content when last reported at Stop>" | null } }
|
|
12
|
+
// in the OS temp dir, keyed by session_id. All I/O is best-effort.
|
|
13
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
|
+
import { tmpdir } from "node:os";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
|
|
18
|
+
export function pendingPath(sessionId) {
|
|
19
|
+
const sid = (sessionId ?? "").toString();
|
|
20
|
+
if (!sid) return "";
|
|
21
|
+
return join(tmpdir(), `rf-agentskills-pending-${sid.replace(/[^A-Za-z0-9._-]/g, "_")}.json`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function loadPending(sessionId) {
|
|
25
|
+
const p = pendingPath(sessionId);
|
|
26
|
+
if (!p) return {};
|
|
27
|
+
try {
|
|
28
|
+
const data = JSON.parse(readFileSync(p, "utf-8"));
|
|
29
|
+
return data && typeof data === "object" && !Array.isArray(data) ? data : {};
|
|
30
|
+
} catch {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function savePending(sessionId, state) {
|
|
36
|
+
const p = pendingPath(sessionId);
|
|
37
|
+
if (!p) return;
|
|
38
|
+
try {
|
|
39
|
+
writeFileSync(p, JSON.stringify(state));
|
|
40
|
+
} catch {
|
|
41
|
+
// Read-only temp dir: only the Stop-time re-check is lost.
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Record (failed=true) or clear (failed=false) one file's validation result. */
|
|
46
|
+
export function recordResult(sessionId, file, failed) {
|
|
47
|
+
if (!pendingPath(sessionId)) return;
|
|
48
|
+
const state = loadPending(sessionId);
|
|
49
|
+
if (failed) {
|
|
50
|
+
if (!(file in state)) state[file] = { reported: null };
|
|
51
|
+
} else if (file in state) {
|
|
52
|
+
delete state[file];
|
|
53
|
+
} else {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
savePending(sessionId, state);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function contentHash(file) {
|
|
60
|
+
try {
|
|
61
|
+
return createHash("sha1").update(readFileSync(file)).digest("hex");
|
|
62
|
+
} catch {
|
|
63
|
+
return "";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// _python_env.mjs — shared Python interpreter resolution for the hook scripts.
|
|
2
|
+
//
|
|
3
|
+
// Not a hook itself (the leading underscore marks a helper). Imported by
|
|
4
|
+
// validate_robot.mjs, validate_robot_project.mjs and check_rf_environment.mjs.
|
|
5
|
+
// findRobotcode() resolves the `robotcode` executable the same way: robotcode has
|
|
6
|
+
// no `python -m robotcode` entry point, so the executable next to each
|
|
7
|
+
// interpreter (bin/robotcode, Scripts\robotcode.exe) is used.
|
|
8
|
+
//
|
|
9
|
+
// Resolution order (first interpreter that can import the needed module wins):
|
|
10
|
+
// 1. the active virtual environment ($VIRTUAL_ENV)
|
|
11
|
+
// 2. the project's .venv under the event's working directory
|
|
12
|
+
// (POSIX: .venv/bin/python, Windows: .venv\Scripts\python.exe)
|
|
13
|
+
// 3. the installer-recorded interpreter (python_runtime.json next to this file,
|
|
14
|
+
// plus its fallbacks)
|
|
15
|
+
// 4. python3 / python on PATH
|
|
16
|
+
//
|
|
17
|
+
// The project environment wins so that Robocop and `robot` see the project's
|
|
18
|
+
// Robot Framework version. A package manager (`uv run`, `poetry run`) is never
|
|
19
|
+
// started: it can create environments, sync dependencies or reach the network.
|
|
20
|
+
//
|
|
21
|
+
// Every probe has a timeout (5 s by default). RF_AGENTSKILLS_HOOK_TIMEOUT_MS is a
|
|
22
|
+
// test-only override that caps every hook timeout (probes, Robocop, dry run).
|
|
23
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
24
|
+
import { spawnSync } from "node:child_process";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
import { basename, dirname, join } from "node:path";
|
|
27
|
+
|
|
28
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
29
|
+
const IS_WIN = process.platform === "win32";
|
|
30
|
+
|
|
31
|
+
export const PROBE_TIMEOUT_MS = 5000;
|
|
32
|
+
|
|
33
|
+
// Timeout for a spawned process: the given default, capped by the test-only
|
|
34
|
+
// override when it is a positive integer.
|
|
35
|
+
export function timeoutMs(defaultMs) {
|
|
36
|
+
const raw = (process.env.RF_AGENTSKILLS_HOOK_TIMEOUT_MS ?? "").trim();
|
|
37
|
+
const n = /^\d+$/.test(raw) ? Number(raw) : 0;
|
|
38
|
+
return n > 0 ? Math.min(n, defaultMs) : defaultMs;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Options shared by every spawnSync in the hooks: bounded time and output.
|
|
42
|
+
export function spawnOptions(defaultTimeoutMs, extra = {}) {
|
|
43
|
+
return {
|
|
44
|
+
timeout: timeoutMs(defaultTimeoutMs),
|
|
45
|
+
killSignal: "SIGKILL",
|
|
46
|
+
maxBuffer: 1024 * 1024,
|
|
47
|
+
windowsHide: true,
|
|
48
|
+
...extra,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function venvPython(root) {
|
|
53
|
+
return IS_WIN
|
|
54
|
+
? join(root, "Scripts", "python.exe")
|
|
55
|
+
: join(root, "bin", "python");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function installerInterpreters() {
|
|
59
|
+
const out = [];
|
|
60
|
+
try {
|
|
61
|
+
const cfg = JSON.parse(readFileSync(join(HERE, "python_runtime.json"), "utf-8"));
|
|
62
|
+
if (typeof cfg.interpreter === "string" && cfg.interpreter) out.push(cfg.interpreter);
|
|
63
|
+
for (const fb of cfg.fallbacks ?? []) {
|
|
64
|
+
if (typeof fb === "string" && fb) out.push(fb);
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
// Config missing or unreadable (plugin checkout) — PATH fallbacks only.
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Ordered, de-duplicated interpreter candidates for a project directory.
|
|
73
|
+
export function pythonCandidates(cwd) {
|
|
74
|
+
const candidates = [];
|
|
75
|
+
const add = (py) => {
|
|
76
|
+
if (py && !candidates.includes(py)) candidates.push(py);
|
|
77
|
+
};
|
|
78
|
+
const venv = (process.env.VIRTUAL_ENV ?? "").trim();
|
|
79
|
+
if (venv) {
|
|
80
|
+
const py = venvPython(venv);
|
|
81
|
+
if (existsSync(py)) add(py);
|
|
82
|
+
}
|
|
83
|
+
const root = cwd || process.cwd();
|
|
84
|
+
const projectPy = venvPython(join(root, ".venv"));
|
|
85
|
+
if (existsSync(projectPy)) add(projectPy);
|
|
86
|
+
for (const py of installerInterpreters()) add(py);
|
|
87
|
+
add("python3");
|
|
88
|
+
add("python");
|
|
89
|
+
return candidates;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function scriptsExe(binDir, name) {
|
|
93
|
+
return join(binDir, IS_WIN ? `${name}.exe` : name);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Ordered, de-duplicated `robotcode` executable candidates for a project
|
|
97
|
+
// directory, in the same order as pythonCandidates(): the active venv, the
|
|
98
|
+
// project's .venv, the installer interpreter's directory, then PATH.
|
|
99
|
+
export function robotcodeCandidates(cwd) {
|
|
100
|
+
const out = [];
|
|
101
|
+
const add = (exe) => {
|
|
102
|
+
if (exe && !out.includes(exe)) out.push(exe);
|
|
103
|
+
};
|
|
104
|
+
const venv = (process.env.VIRTUAL_ENV ?? "").trim();
|
|
105
|
+
if (venv) {
|
|
106
|
+
const exe = scriptsExe(join(venv, IS_WIN ? "Scripts" : "bin"), "robotcode");
|
|
107
|
+
if (existsSync(exe)) add(exe);
|
|
108
|
+
}
|
|
109
|
+
const root = cwd || process.cwd();
|
|
110
|
+
const projectExe = scriptsExe(join(root, ".venv", IS_WIN ? "Scripts" : "bin"), "robotcode");
|
|
111
|
+
if (existsSync(projectExe)) add(projectExe);
|
|
112
|
+
for (const py of installerInterpreters()) {
|
|
113
|
+
if (basename(py) === py) continue; // bare command name: covered by PATH below
|
|
114
|
+
const exe = scriptsExe(dirname(py), "robotcode");
|
|
115
|
+
if (existsSync(exe)) add(exe);
|
|
116
|
+
}
|
|
117
|
+
add("robotcode");
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// First robotcode candidate that answers `--version`, as {exe, version}
|
|
122
|
+
// ("2.8.0"), or null. Paths that exist are trusted without a probe unless the
|
|
123
|
+
// version is wanted; the bare PATH name is always probed.
|
|
124
|
+
export function findRobotcode(cwd, { withVersion = false } = {}) {
|
|
125
|
+
for (const exe of robotcodeCandidates(cwd)) {
|
|
126
|
+
if (!withVersion && exe !== "robotcode") return { exe, version: null };
|
|
127
|
+
const r = spawnSync(exe, ["--version"], {
|
|
128
|
+
...spawnOptions(PROBE_TIMEOUT_MS),
|
|
129
|
+
encoding: "utf-8",
|
|
130
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
131
|
+
});
|
|
132
|
+
if (r.error || r.status !== 0) continue;
|
|
133
|
+
const m = /(\d+\.\d+(?:\.\d+)?)/.exec(r.stdout ?? "");
|
|
134
|
+
return { exe, version: m ? m[1] : null };
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// True when `version` ("2.8.0") is at least `min` ("2.8").
|
|
140
|
+
export function versionAtLeast(version, min) {
|
|
141
|
+
const a = String(version ?? "").split(".").map(Number);
|
|
142
|
+
const b = String(min).split(".").map(Number);
|
|
143
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
144
|
+
const x = a[i] || 0;
|
|
145
|
+
const y = b[i] || 0;
|
|
146
|
+
if (x !== y) return x > y;
|
|
147
|
+
}
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// The event's working directory (falls back to the process cwd).
|
|
152
|
+
export function projectRoot(event) {
|
|
153
|
+
const cwd = event && typeof event.cwd === "string" ? event.cwd : "";
|
|
154
|
+
if (cwd && existsSync(cwd)) return cwd;
|
|
155
|
+
return process.cwd();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// First candidate for which `import <module>` succeeds, or null.
|
|
159
|
+
export function findInterpreterWith(moduleName, cwd) {
|
|
160
|
+
for (const py of pythonCandidates(cwd)) {
|
|
161
|
+
const probe = spawnSync(py, ["-c", `import ${moduleName}`], {
|
|
162
|
+
...spawnOptions(PROBE_TIMEOUT_MS),
|
|
163
|
+
stdio: ["ignore", "ignore", "ignore"],
|
|
164
|
+
});
|
|
165
|
+
if (probe.error) continue; // missing interpreter, timeout, …
|
|
166
|
+
if (probe.status === 0) return py;
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// First candidate that exists at all (`--version` answers), or null.
|
|
172
|
+
export function firstPython(cwd) {
|
|
173
|
+
for (const py of pythonCandidates(cwd)) {
|
|
174
|
+
const r = spawnSync(py, ["--version"], {
|
|
175
|
+
...spawnOptions(PROBE_TIMEOUT_MS),
|
|
176
|
+
stdio: "ignore",
|
|
177
|
+
});
|
|
178
|
+
if (!r.error) return py;
|
|
179
|
+
}
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// check_rf_environment.mjs — Check the Robot Framework environment at session start.
|
|
3
|
+
//
|
|
4
|
+
// Called by the SessionStart hook. Writes a diagnostic summary to stderr so the
|
|
5
|
+
// agent sees the environment state. Always exits 0 (informational only — never
|
|
6
|
+
// blocks session start).
|
|
7
|
+
//
|
|
8
|
+
// Interpreter resolution is shared with the validation hooks (_python_env.mjs):
|
|
9
|
+
// VIRTUAL_ENV -> <cwd>/.venv -> python_runtime.json -> python3/python. The
|
|
10
|
+
// SessionStart event's `cwd` selects the project (process cwd when it has none);
|
|
11
|
+
// a missing, empty or malformed event produces no output. Install advice follows the rf-setup skill (project environment,
|
|
12
|
+
// `uv add …`); it never recommends `pip install`, and leaves library post-install steps to
|
|
13
|
+
// the library's own skill.
|
|
14
|
+
import { spawnSync } from "node:child_process";
|
|
15
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
import {
|
|
18
|
+
PROBE_TIMEOUT_MS,
|
|
19
|
+
findInterpreterWith,
|
|
20
|
+
findRobotcode,
|
|
21
|
+
firstPython,
|
|
22
|
+
projectRoot,
|
|
23
|
+
spawnOptions,
|
|
24
|
+
versionAtLeast,
|
|
25
|
+
} from "./_python_env.mjs";
|
|
26
|
+
|
|
27
|
+
const ROBOTCODE_MIN = "2.8";
|
|
28
|
+
const MARKETPLACE = "robotframework-plugins";
|
|
29
|
+
|
|
30
|
+
// Libraries a technology plugin covers (detection signals only; the install
|
|
31
|
+
// steps live in each library's skill). Import name, label, plugin, skill.
|
|
32
|
+
const LIBRARIES = [
|
|
33
|
+
["Browser", "Browser Library", "rf-web", "rf-browser"],
|
|
34
|
+
["SeleniumLibrary", "SeleniumLibrary", "rf-web", "rf-selenium"],
|
|
35
|
+
["RequestsLibrary", "RequestsLibrary", "rf-api", "rf-requests"],
|
|
36
|
+
["REST", "RESTinstance", "rf-api", "rf-restinstance"],
|
|
37
|
+
["AppiumLibrary", "AppiumLibrary", "rf-mobile", "rf-appium"],
|
|
38
|
+
["PlatynUI", "PlatynUI", "rf-desktop", "rf-platynui"],
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
// Whether the skill is already there: in this plugin tree (the rf-agentskills
|
|
42
|
+
// bundle, or a file-mode install's support folder next to the skills), or in
|
|
43
|
+
// a sibling plugin of the same marketplace cache. Best effort; unknown = no.
|
|
44
|
+
function skillPresent(plugin, skill) {
|
|
45
|
+
const root = process.env.CLAUDE_PLUGIN_ROOT;
|
|
46
|
+
if (!root) return false;
|
|
47
|
+
const candidates = [
|
|
48
|
+
join(root, "skills", skill),
|
|
49
|
+
join(root, "..", "skills", skill),
|
|
50
|
+
join(root, "..", plugin, "skills", skill),
|
|
51
|
+
join(root, "..", "..", plugin),
|
|
52
|
+
];
|
|
53
|
+
return candidates.some((p) => existsSync(p));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// The command that installs a plugin in the agent running this hook, judged by
|
|
57
|
+
// where the agent put the plugin; a file-mode install gets the installer.
|
|
58
|
+
function installCommand(plugin) {
|
|
59
|
+
const root = (process.env.CLAUDE_PLUGIN_ROOT ?? "").replace(/\\/g, "/");
|
|
60
|
+
if (root.includes("/.copilot/")) return `copilot plugin install ${plugin}@${MARKETPLACE}`;
|
|
61
|
+
if (root.includes("/.codex/")) return `codex plugin add ${plugin}@${MARKETPLACE}`;
|
|
62
|
+
if (root.includes("/.claude/plugins/")) return `/plugin install ${plugin}@${MARKETPLACE}`;
|
|
63
|
+
return "uvx robotframework-plugins install (adds the plugins for the libraries the project declares)";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Missing, empty or malformed event -> no output (the hook never blocks).
|
|
67
|
+
let event = null;
|
|
68
|
+
try {
|
|
69
|
+
event = JSON.parse(readFileSync(0, "utf-8"));
|
|
70
|
+
} catch {
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
73
|
+
if (!event || typeof event !== "object" || Array.isArray(event)) process.exit(0);
|
|
74
|
+
const cwd = projectRoot(event);
|
|
75
|
+
|
|
76
|
+
const found = [];
|
|
77
|
+
const missing = [];
|
|
78
|
+
|
|
79
|
+
function pythonImportExists(py, importName) {
|
|
80
|
+
if (!py) return false;
|
|
81
|
+
const r = spawnSync(py, ["-c", `import ${importName}`], {
|
|
82
|
+
...spawnOptions(PROBE_TIMEOUT_MS),
|
|
83
|
+
stdio: "ignore",
|
|
84
|
+
});
|
|
85
|
+
return r.status === 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function check(ok, label) {
|
|
89
|
+
(ok ? found : missing).push(label);
|
|
90
|
+
return ok;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
process.stderr.write("=== Robot Framework Environment Check ===\n");
|
|
94
|
+
|
|
95
|
+
// Prefer the interpreter that has Robot Framework; else the first one that runs.
|
|
96
|
+
const py = findInterpreterWith("robot", cwd) ?? firstPython(cwd);
|
|
97
|
+
|
|
98
|
+
process.stderr.write("\nCore:\n");
|
|
99
|
+
check(py !== null, "python3");
|
|
100
|
+
const rfOk = pythonImportExists(py, "robot");
|
|
101
|
+
check(rfOk, "robotframework");
|
|
102
|
+
let rfVersion = "not installed";
|
|
103
|
+
if (rfOk) {
|
|
104
|
+
const r = spawnSync(py, ["-c", "import robot; print(robot.version.VERSION)"], {
|
|
105
|
+
...spawnOptions(PROBE_TIMEOUT_MS),
|
|
106
|
+
encoding: "utf-8",
|
|
107
|
+
});
|
|
108
|
+
if (r.status === 0) rfVersion = (r.stdout ?? "").trim() || rfVersion;
|
|
109
|
+
}
|
|
110
|
+
process.stderr.write(` Robot Framework version: ${rfVersion}\n`);
|
|
111
|
+
if (py) process.stderr.write(` Interpreter: ${py}\n`);
|
|
112
|
+
|
|
113
|
+
process.stderr.write("\nrobotcode (required by rf-core):\n");
|
|
114
|
+
const rc = findRobotcode(cwd, { withVersion: true });
|
|
115
|
+
const rcOk = rc !== null && versionAtLeast(rc.version, ROBOTCODE_MIN);
|
|
116
|
+
check(rcOk, `robotcode[all]>=${ROBOTCODE_MIN}`);
|
|
117
|
+
if (rcOk) {
|
|
118
|
+
process.stderr.write(` robotcode ${rc.version}: available (${rc.exe}); errors are checked on every .robot/.resource edit\n`);
|
|
119
|
+
} else {
|
|
120
|
+
process.stderr.write(
|
|
121
|
+
(rc
|
|
122
|
+
? ` robotcode ${rc.version ?? "(unknown version)"} is older than ${ROBOTCODE_MIN} (robotcode doc needs ${ROBOTCODE_MIN}): `
|
|
123
|
+
: " robotcode: not installed — ") +
|
|
124
|
+
"keyword lookup (robotcode doc), result analysis (robotcode results) and the error check on edit " +
|
|
125
|
+
"need it. Install it into the project environment: uv add --dev \"robotcode[all]>=2.8\" " +
|
|
126
|
+
"(see the rf-setup skill). Recommended companion plugin: robotcode@robotframework-agent-plugins.\n",
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const robocopOk = check(pythonImportExists(py, "robocop") ||
|
|
130
|
+
findInterpreterWith("robocop", cwd) !== null, "robotframework-robocop");
|
|
131
|
+
process.stderr.write(
|
|
132
|
+
robocopOk
|
|
133
|
+
? " Robocop: available (deprecation and formatting advice on edit)\n"
|
|
134
|
+
: " Robocop: not installed — deprecation and formatting advice on edit is disabled " +
|
|
135
|
+
"(it comes with robotcode[all])\n",
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
// Test libraries: report the ones the project has, and the plugin for each.
|
|
139
|
+
const plugins = new Map();
|
|
140
|
+
for (const [importName, label, plugin, skill] of LIBRARIES) {
|
|
141
|
+
if (pythonImportExists(py, importName)) {
|
|
142
|
+
found.push(label);
|
|
143
|
+
if (!plugins.has(plugin)) plugins.set(plugin, { labels: [], present: true });
|
|
144
|
+
const entry = plugins.get(plugin);
|
|
145
|
+
entry.labels.push(label);
|
|
146
|
+
entry.present = entry.present && skillPresent(plugin, skill);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (plugins.size) {
|
|
150
|
+
process.stderr.write("\nTest libraries and their plugins:\n");
|
|
151
|
+
for (const [plugin, { labels, present }] of plugins) {
|
|
152
|
+
process.stderr.write(
|
|
153
|
+
present
|
|
154
|
+
? ` ${labels.join(", ")}: covered by plugin ${plugin} (installed)\n`
|
|
155
|
+
: ` ${labels.join(", ")}: covered by plugin ${plugin}, not installed. Install: ${installCommand(plugin)}\n`,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
process.stderr.write("\n--- Summary ---\n");
|
|
161
|
+
if (found.length) {
|
|
162
|
+
process.stderr.write(`Available: ${found.join(", ")}\n`);
|
|
163
|
+
}
|
|
164
|
+
if (missing.length) {
|
|
165
|
+
process.stderr.write(`Not installed: ${missing.join(", ")}\n`);
|
|
166
|
+
process.stderr.write(
|
|
167
|
+
"\nInstall only what the project needs, into the project environment. " +
|
|
168
|
+
"See the rf-setup skill for the full steps (uv, venv, poetry):\n",
|
|
169
|
+
);
|
|
170
|
+
process.stderr.write(" uv add robotframework # core\n");
|
|
171
|
+
process.stderr.write(" uv add --dev \"robotcode[all]>=2.8\" # required: robotcode CLI + Robocop\n");
|
|
172
|
+
process.stderr.write(
|
|
173
|
+
" Test libraries: the library's own skill gives its install steps " +
|
|
174
|
+
"(plugins rf-web, rf-api, rf-mobile, rf-desktop).\n",
|
|
175
|
+
);
|
|
176
|
+
} else {
|
|
177
|
+
process.stderr.write("All checked packages are installed.\n");
|
|
178
|
+
}
|
|
179
|
+
process.stderr.write("=== End Environment Check ===\n");
|
|
180
|
+
|
|
181
|
+
process.exit(0);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// maybe_inject_rf_context.mjs — Conditional UserPromptSubmit hook.
|
|
3
|
+
//
|
|
4
|
+
// Reads the Claude Code UserPromptSubmit event JSON on stdin, inspects
|
|
5
|
+
// the user's prompt for Robot Framework signals, and only emits an
|
|
6
|
+
// additionalContext injection when at least one signal is present.
|
|
7
|
+
// The injection is a short routing text (<= 450 characters): which skill
|
|
8
|
+
// to load for which kind of work, keyword lookup via `robotcode doc keyword`,
|
|
9
|
+
// results via `robotcode results`, and a one-line RF 7 syntax reminder.
|
|
10
|
+
//
|
|
11
|
+
// Schema:
|
|
12
|
+
// stdin — Claude Code UserPromptSubmit event JSON.
|
|
13
|
+
// stdout — Either empty (no injection) or one JSON object of the form
|
|
14
|
+
// {"hookSpecificOutput": {"hookEventName": "UserPromptSubmit",
|
|
15
|
+
// "additionalContext": "..."}}.
|
|
16
|
+
// exit — Always 0. The hook is non-blocking by design.
|
|
17
|
+
import { readFileSync } from "node:fs";
|
|
18
|
+
|
|
19
|
+
let raw = "";
|
|
20
|
+
try { raw = readFileSync(0, "utf-8"); } catch { process.exit(0); }
|
|
21
|
+
if (!raw) process.exit(0);
|
|
22
|
+
|
|
23
|
+
let event;
|
|
24
|
+
try { event = JSON.parse(raw); } catch { process.exit(0); }
|
|
25
|
+
const prompt = (event?.prompt ?? "").toString();
|
|
26
|
+
if (!prompt) process.exit(0);
|
|
27
|
+
|
|
28
|
+
// Robot Framework signal regex (case-insensitive). Conservative on
|
|
29
|
+
// purpose — better to under-inject than over-inject. Categories covered:
|
|
30
|
+
// - Direct RF mentions: "robot framework", "robot-framework"
|
|
31
|
+
// - File extensions: .robot, .resource
|
|
32
|
+
// - Library names: SeleniumLibrary, Browser Library, AppiumLibrary,
|
|
33
|
+
// RequestsLibrary, RESTinstance, PlatynUI
|
|
34
|
+
// - skill ids: rf-setup, rf-language, rf-python-library (rf-core);
|
|
35
|
+
// rf-browser, rf-selenium (rf-web); rf-requests, rf-restinstance (rf-api);
|
|
36
|
+
// rf-appium (rf-mobile); rf-platynui (rf-desktop)
|
|
37
|
+
// - rf-core subagent ids: rf-test-architect, rf-debug-expert,
|
|
38
|
+
// rf-migration-guide
|
|
39
|
+
// - Tooling: libdoc, robotidy, robocop, rfbrowser, robotcode,
|
|
40
|
+
// robot-debug, robot.toml
|
|
41
|
+
// - Python library API: @keyword, robot.api.deco, ROBOT_LIBRARY_SCOPE (and
|
|
42
|
+
// other ROBOT_LIBRARY_* / ROBOT_LISTENER_* settings), "contains no keywords",
|
|
43
|
+
// "robot listener" / "listener API" (bare "listener" is too generic)
|
|
44
|
+
// - RF section headers pasted into the prompt: *** Settings ***, *** Variables ***,
|
|
45
|
+
// *** Test Cases ***, *** Tasks ***, *** Keywords ***, *** Comments ***
|
|
46
|
+
// (singular legacy spellings included)
|
|
47
|
+
// Things NOT matched: bare "test" (too noisy), bare "RF" (ambiguous).
|
|
48
|
+
const RF_REGEX = /robot[ -]?framework|\.robot\b|\.resource\b|\b(selenium|browser|appium|requests)library\b|\brestinstance\b|\b(selenium|browser|appium|requests) library\b|\bplatynui\b|\blibdoc\b|\b(robotidy|robocop|rfbrowser|robotcode)\b|\brobot-debug\b|\brobot\.toml\b|@keyword\b|\brobot\.api\.deco\b|\bROBOT_(LIBRARY|LISTENER)_[A-Z_]+|contains no keywords|\brobot( framework)? listeners?\b|\blistener api\b|\brf-(setup|language|python-library|browser|selenium|appium|requests|restinstance|platynui)\b|\brf-(test-architect|debug-expert|migration-guide)\b|\*\*\*\s*(settings?|variables?|test cases?|tasks?|keywords?|comments?)\s*\*\*\*/i;
|
|
49
|
+
|
|
50
|
+
if (!RF_REGEX.test(prompt)) process.exit(0);
|
|
51
|
+
|
|
52
|
+
// Routing text (<= 450 characters, ~80 tokens). Skill descriptions are already in
|
|
53
|
+
// the agent's context and subagents are listed by the Task tool; what the model
|
|
54
|
+
// lacks is which skill to load when. Names only rf-core skills and the
|
|
55
|
+
// technology plugins (tests check it): a library skill may not be installed,
|
|
56
|
+
// so library work routes generically and to installing its plugin.
|
|
57
|
+
const CONTEXT = [
|
|
58
|
+
"Robot Framework context detected. Load the matching skill before writing RF: ",
|
|
59
|
+
"tests, suites, keywords, resources, variables -> rf-language; ",
|
|
60
|
+
"Python libraries/listeners -> rf-python-library; installs -> rf-setup; ",
|
|
61
|
+
"a library -> its own skill; if missing, suggest its plugin (rf-web, rf-api, rf-mobile, rf-desktop). ",
|
|
62
|
+
"Keywords: `robotcode doc keyword`, not memory; results: `robotcode results`, not output.xml. ",
|
|
63
|
+
"Write RF 7 syntax: RETURN, VAR, IF, Test Tags.",
|
|
64
|
+
].join("");
|
|
65
|
+
|
|
66
|
+
const payload = {
|
|
67
|
+
hookSpecificOutput: {
|
|
68
|
+
hookEventName: "UserPromptSubmit",
|
|
69
|
+
additionalContext: CONTEXT,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
process.stdout.write(JSON.stringify(payload) + "\n");
|
|
74
|
+
process.exit(0);
|