mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-29 06:28:23 +02:00
Review follow-up on #3716. CleanupSidecars deletes the recorded SKILL.md but preserves a managed skill directory once it is non-empty (the right call when rolling a local_directory workdir back to pre-task state, where the agent may have added content under a dir we created). On the reuse path that preservation left the canonical slug occupied whenever a prior-run agent wrote a file into .claude/skills/issue-review/, so the refresh still dodged to issue-review-multica. Add removeReusedManagedSkillDirs: before CleanupSidecars on the reuse path, force-remove the skill directories the prior manifest recorded directly under the provider's skills parent -- they are platform-owned by definition (the manifest is proof we created them), so reclaiming them and re-creating each skill at its natural slug is correct and matches the Codex path's os.RemoveAll(skillsDir). Only immediate children of the skills parent are removed, so sibling skills, checked-out repos, and the rest of the workdir are untouched; the reuse path only runs on cloud workdirs (the daemon skips Reuse for local_directory tasks) so there is no user-owned skills tree to protect. Extract skillsDirPath (side-effect-free) from resolveSkillsDir so the rollback can match the manifest's skill roots without re-creating directories. Tests: TestReuseReclaimsManagedSkillDirWithStrayAgentFile reproduces the review's exact repro through real Prepare+Reuse (without the fix: [issue-review issue-review-multica]; with it: [issue-review]). TestReuseSkillRefreshIsCanonicalAcrossProviders table-tests the rollback + refresh sequence across claude/openclaw/copilot/default. MUL-2963 Co-authored-by: multica-agent <github@multica.ai>