mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 02:05:22 -04:00
POST /api/skills/{id}/markdown set sk.name = slugify(sk.name or match['name']),
taking the name parsed from the edited markdown frontmatter. A changed name
makes update_skill() move the skill directory on disk and re-key its usage
sidecar, orphaning the original id. The UI still holds that original id, so the
next DELETE /api/skills/{id} fails the name/id lookup and 404s — 'can't delete
them now'.
The audit save path (_apply_skill_md) already guards against exactly this with
sk.name = name and an explicit 'must NEVER rename the skill' comment. Apply the
same pin here: keep the stored name on markdown save (content edits still take
effect; only the rename is suppressed). Drops the now-unused slugify import.
Adds tests/test_skill_save_no_rename.py: saving markdown whose frontmatter
renames the skill keeps the original name and applies the edit, and a
subsequent delete-by-original-id succeeds. Pure unit test — calls the route
handlers directly with a mock Request (no server/network), like
test_skills_delete_owner.py.
Co-authored-by: lalalune <shawgotbags@gmail.com>
This commit is contained in:
@@ -1442,7 +1442,7 @@ def setup_skills_routes(skills_manager: SkillsManager) -> APIRouter:
|
||||
@router.post("/{skill_id}/markdown")
|
||||
async def save_skill_markdown(request: Request, skill_id: str):
|
||||
"""Replace SKILL.md with new raw content. Parses + validates first."""
|
||||
from services.memory.skill_format import Skill, slugify
|
||||
from services.memory.skill_format import Skill
|
||||
user = _owner(request)
|
||||
body = await request.json()
|
||||
new_content = body.get("markdown")
|
||||
@@ -1457,7 +1457,10 @@ def setup_skills_routes(skills_manager: SkillsManager) -> APIRouter:
|
||||
sk = Skill.from_markdown(new_content)
|
||||
except Exception as e:
|
||||
raise HTTPException(400, f"Could not parse SKILL.md: {e}")
|
||||
sk.name = slugify(sk.name or match.get("name"))
|
||||
# Never rename on save: a changed `name` in the markdown would move
|
||||
# the skill dir (update_skill) and orphan the original id, so a later
|
||||
# delete 404s (#1333). Pin to the stored name, like _apply_skill_md.
|
||||
sk.name = match.get("name")
|
||||
if not sk.owner:
|
||||
sk.owner = match.get("owner") or user
|
||||
ok = skills_manager.update_skill(match.get("name"), {
|
||||
|
||||
Reference in New Issue
Block a user