Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Add session_start hook to run setup.sh automatically (#343)

Rohit Malhotrad281324c6770
diff --git a/.openhands/hooks.json b/.openhands/hooks.json
index b273d634ff..fae5e2cc34 100644
--- a/.openhands/hooks.json
+++ b/.openhands/hooks.json
@@ -1,4 +1,16 @@
{
+ "session_start": [
+ {
+ "matcher": "*",
+ "hooks": [
+ {
+ "type": "command",
+ "command": ".openhands/setup.sh",
+ "timeout": 300
+ }
+ ]
+ }
+ ],
"stop": [
{
"matcher": "*",
diff --git a/.openhands/setup.sh b/.openhands/setup.sh
index 92ba88b869..dc1c46c764 100755
--- a/.openhands/setup.sh
+++ b/.openhands/setup.sh
@@ -22,9 +22,10 @@ if ! command -v uvx &> /dev/null; then
fi
fi
-if [ ! -d node_modules ]; then
- npm ci
-fi
+# Always run npm ci to ensure dependencies are installed and up-to-date.
+# This is idempotent and ensures hooks (like on_stop.sh) have access to
+# npm scripts like lint and test.
+npm ci
if [ ! -f "$ENV_FILE" ]; then
cp .env.sample "$ENV_FILE"