Skip to content

Commit 27a850c

Browse files
authored
Merge pull request #1 from up2itnow0822/fix/hooks-install-no-args-crit
fix(hooks): make install/uninstall/pre_update resilient to any framework caller contract
2 parents fb6d872 + 736dcda commit 27a850c

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

hooks.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,15 @@ def _deploy_skill(skill_dir: Path, dest: Path) -> None:
5252
print(f"[AZPowers] Installed skill: {skill_dir.name}")
5353

5454

55-
def install(plugin_dir: str, data_dir: str) -> None:
56-
"""Install AZPowers-Skills: deploy skill directories and runtime deps."""
55+
def install(plugin_dir: str | None = None, unused_data_dir: str | None = None, **_kwargs) -> None:
56+
"""Install AZPowers-Skills: deploy skill directories and runtime deps.
57+
58+
Accepts the 2 positional args the framework *used* to pass, but also
59+
works when the framework calls us with no args or unexpected kwargs:
60+
we self-discover plugin_dir from __file__. Any extra kwargs are ignored.
61+
"""
62+
if plugin_dir is None:
63+
plugin_dir = str(Path(__file__).parent)
5764
plugin_path = Path(plugin_dir)
5865
# Skills live at usr/skills/ — two levels up from usr/plugins/azpowers_skills/
5966
skills_target = plugin_path.parent.parent / "skills"
@@ -130,8 +137,14 @@ def install(plugin_dir: str, data_dir: str) -> None:
130137
print("[AZPowers] Installation complete.")
131138

132139

133-
def uninstall(plugin_dir: str, data_dir: str) -> None:
134-
"""Uninstall AZPowers-Skills: remove ONLY directories marked as deployed by AZPowers."""
140+
def uninstall(plugin_dir: str | None = None, data_dir: str | None = None, **_kwargs) -> None:
141+
"""Uninstall AZPowers-Skills: remove ONLY directories marked as deployed by AZPowers.
142+
143+
Accepts optional plugin_dir / data_dir, self-discovers from __file__ when omitted,
144+
and absorbs any extra kwargs from the framework.
145+
"""
146+
if plugin_dir is None:
147+
plugin_dir = str(Path(__file__).parent)
135148
skills_target = Path(plugin_dir).parent.parent / "skills"
136149
if not skills_target.is_dir():
137150
print("[AZPowers] No skills directory found — nothing to remove")
@@ -161,7 +174,10 @@ def uninstall(plugin_dir: str, data_dir: str) -> None:
161174
print("[AZPowers] Uninstall complete.")
162175

163176

164-
def pre_update(plugin_dir: str, data_dir: str) -> None:
165-
"""Called before plugin update. Runs uninstall to clean staging."""
177+
def pre_update(plugin_dir: str | None = None, data_dir: str | None = None, **_kwargs) -> None:
178+
"""Called before plugin update. Runs uninstall to clean staging.
179+
180+
Accepts optional args like install/uninstall for framework-agnostic calling.
181+
"""
166182
print("[AZPowers] pre_update: cleaning up deployed skills before upgrade")
167183
uninstall(plugin_dir, data_dir)

0 commit comments

Comments
 (0)