Skip to content

fix(skills): detect nested SKILL.md in unmanaged scan#1917

Open
zerone0x wants to merge 1 commit intofarion1231:mainfrom
zerone0x:fix/issue-1842-nested-skill-import
Open

fix(skills): detect nested SKILL.md in unmanaged scan#1917
zerone0x wants to merge 1 commit intofarion1231:mainfrom
zerone0x:fix/issue-1842-nested-skill-import

Conversation

@zerone0x
Copy link
Copy Markdown

@zerone0x zerone0x commented Apr 6, 2026

Summary / 概述

Support nested skill layouts when scanning for unmanaged skills by recursively finding SKILL.md and using the relative path as the directory key. This restores detection for repos that bundle multiple skills under subfolders (e.g. ai-skills/skills//SKILL.md).

Related Issue / 关联 Issue

Fixes #1842

Screenshots / 截图

N/A

Before / 修改前 After / 修改后
Nested skills were ignored unless SKILL.md lived at repo root Nested SKILL.md is detected and listed for import

Checklist / 检查清单

  • [ ]

[email protected] typecheck /home/sober/github/working/cc-switch
tsc --noEmit passes / 通过 TypeScript 类型检查 (not run)

  • [ ]

[email protected] format:check /home/sober/github/working/cc-switch
prettier --check "src/**/*.{js,jsx,ts,tsx,css,json}"

Checking formatting...
All matched files use Prettier code style! passes / 通过代码格式检查 (not run)

  • passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)(not run)
  • Updated i18n files if user-facing text changed / 如修改了用户可见文本,已更新国际化文件 (not needed)

@yovinchen
Copy link
Copy Markdown
Collaborator

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0e4b659dcb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

continue;
}
let dir_name = entry.file_name().to_string_lossy().to_string();
let dir_name = rel.to_string_lossy().to_string();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Normalize unmanaged directory key before persisting

Using rel.to_string_lossy() as dir_name makes unmanaged nested skills keep their full relative path (for example repo/skills/foo) as InstalledSkill.directory when imported, but downstream install-state logic still compares by basename (e.g., Path::file_name() in list_skills and install). In that flow, an imported nested skill is shown as not installed and can be reinstalled under a different directory key, which desynchronizes metadata and leaves stale paths behind. Please normalize directory identity consistently (or update all consumers to treat nested keys as canonical).

Useful? React with 👍 / 👎.

let entries = match fs::read_dir(scan_dir) {
Ok(e) => e,
Err(_) => continue,
let skill_dirs = match Self::scan_skills_in_dir(scan_dir) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid recursive symlink traversal in unmanaged scan

scan_unmanaged now calls the recursive scanner for user skill roots, but the recursion follows symlinked directories (path.is_dir()) without any visited-path guard. A symlink cycle inside a skills folder (for example loop -> ..) will recurse forever and can hang or stack-overflow unmanaged scanning. Since this path is now exercised on normal app directories, the scan should skip symlink dirs or track canonicalized visited directories.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v3.12.3 回归:导入已有无法发现本地嵌套 skills,而 v3.12.2 可以

2 participants