mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-09-10 18:22:20 +02:00
fix(skills): require manage_skills action (#5856)
This commit is contained in:
+4
-2
@@ -46,7 +46,9 @@ async def do_manage_skills(content: str, owner: Optional[str] = None) -> Dict:
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
return {"error": "Invalid JSON arguments", "exit_code": 1}
|
return {"error": "Invalid JSON arguments", "exit_code": 1}
|
||||||
|
|
||||||
action = (args.get("action") or "").lower()
|
action = (args.get("action") or "").strip().lower()
|
||||||
|
if not action:
|
||||||
|
return {"error": "action is required (list|view|view_ref|add|edit|patch|publish|delete|search)", "exit_code": 1}
|
||||||
from services.memory.skills import SkillsManager
|
from services.memory.skills import SkillsManager
|
||||||
from services.memory.skill_format import Skill, slugify
|
from services.memory.skill_format import Skill, slugify
|
||||||
from src.constants import DATA_DIR
|
from src.constants import DATA_DIR
|
||||||
@@ -55,7 +57,7 @@ async def do_manage_skills(content: str, owner: Optional[str] = None) -> Dict:
|
|||||||
# Accept legacy `skill_id` as an alias for `name`.
|
# Accept legacy `skill_id` as an alias for `name`.
|
||||||
name = (args.get("name") or args.get("skill_id") or "").strip()
|
name = (args.get("name") or args.get("skill_id") or "").strip()
|
||||||
|
|
||||||
if action in ("list", "index", ""):
|
if action in ("list", "index"):
|
||||||
all_skills = sm.load(owner=owner)
|
all_skills = sm.load(owner=owner)
|
||||||
if not all_skills:
|
if not all_skills:
|
||||||
return {"results": "No skills yet. Create one with action='add'."}
|
return {"results": "No skills yet. Create one with action='add'."}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from src.tools.system import do_manage_skills
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"payload",
|
||||||
|
[
|
||||||
|
{},
|
||||||
|
{"action": ""},
|
||||||
|
{"action": " "},
|
||||||
|
{"name": "demo", "description": "x", "procedure": ["step"]},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
async def test_manage_skills_requires_action(payload):
|
||||||
|
result = await do_manage_skills(json.dumps(payload), owner="test")
|
||||||
|
|
||||||
|
assert result == {
|
||||||
|
"error": "action is required (list|view|view_ref|add|edit|patch|publish|delete|search)",
|
||||||
|
"exit_code": 1,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user