Ð޸´ȫÏîĿÉó²éÎÊÌⲢ·¢²¼ v1.1.9

¸ÄÓñ¾»ú¶ÀÁ¢ CA£¬»ָ´ CLI TLS УÑ飬±£»¤ƾ¾ÝÓëÅäÖò¢·¢±£´档
Ð޸´ Cursor Êý¾ݡ¢»Ự·¾¶¡¢´úÀíÉúÃüÖÜÆڡ¢ģÐÍÇëÇóÓë Skills Îļþ²Ù×÷¡£
Ϊ¶ÀÁ¢ Tab ·þÎñÔö¼ӿͻ§¶˼øȨ£¬Éý¼¶ÒÀÀµÓ빤¾ßÁ´£¬ÍêÉƷ¢²¼ԪÐÅϢͬ²½¡£

Ñé֤£ºÁ½¸ö Go ģ¿éµIJâÊÔ/vet¡¢¹ؼüģ¿é race¡¢ǰ¶˲âÊÔ/Éú²ú¹¹½¨/Éó¼ơ¢
Go ¿ɴï©¶´ɨÃèÓë macOS/Linux ¿ÉÐÐģ¿齻²æ±àÒë¾ùͨ¹ý¡£
Windows ¸ôÀëÆô¶¯ͨ¹ý£»δÍê³ɵĵã»÷ðÑ̺ÍԭÉúƽ̨Ñé֤¼ûÉó²鱨¸档
This commit is contained in:
FuDie0915
2026-11-10 09:59:34 +08:00
parent db73cf5a39
commit 188225fae6
98 changed files with 3324 additions and 930 deletions

View File

@@ -4,6 +4,7 @@
package skills
import (
"bytes"
"embed"
"fmt"
"io/fs"
@@ -129,6 +130,16 @@ func Exists(name string) bool {
// 并将其 commands/ 模板分发到项目 .cursor/commands/。
// 目标已存在时同步为最新内置内容,并清理已退役的内置文件。
func Install(projectPath string, name string) error {
name = sanitizeSkillName(name)
projectPath = strings.TrimSpace(projectPath)
operationMu.Lock()
defer operationMu.Unlock()
if !Exists(name) {
return fmt.Errorf("未知的内置 skill")
}
if err := checkManagedPaths(projectPath, name); err != nil {
return err
}
name = sanitizeSkillName(name)
if name == "" || !Exists(name) {
return fmt.Errorf("内置 skill 不存在: %s", name)
@@ -170,6 +181,9 @@ func installCommands(projectPath string, name string) error {
if err != nil {
return fmt.Errorf("读取命令模板失败: %w", err)
}
if err := backupBeforeReplace(filepath.Join(commandsDir, fileName), data); err != nil {
return err
}
if err := os.WriteFile(filepath.Join(commandsDir, fileName), data, 0o644); err != nil {
return fmt.Errorf("写入命令文件失败: %w", err)
}
@@ -179,6 +193,19 @@ func installCommands(projectPath string, name string) error {
// Uninstall 移除项目内的 skill 目录与随附的命令文件。不存在时幂等成功。
func Uninstall(projectPath string, name string) error {
name = sanitizeSkillName(name)
projectPath = strings.TrimSpace(projectPath)
operationMu.Lock()
defer operationMu.Unlock()
if !Exists(name) {
return fmt.Errorf("未知的内置 skill")
}
if err := checkManagedPaths(projectPath, name); err != nil {
return err
}
if err := ensureNoCustomSkillFiles(projectPath, name); err != nil {
return err
}
name = sanitizeSkillName(name)
if name == "" {
return fmt.Errorf("skill 名称不能为空")
@@ -196,6 +223,14 @@ func Uninstall(projectPath string, name string) error {
// 只删除内置清单中的命令文件,不碰用户自建命令。
commandsDir := projectCommandsDir(projectPath)
for _, fileName := range commandFileNames(name) {
expected, _ := builtinFS.ReadFile(path.Join(builtinRoot, name, commandsDirName, fileName))
current, readErr := os.ReadFile(filepath.Join(commandsDir, fileName))
if readErr == nil && !bytes.Equal(current, expected) {
continue
}
if readErr != nil && !os.IsNotExist(readErr) {
return readErr
}
if err := os.Remove(filepath.Join(commandsDir, fileName)); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("移除命令文件失败: %w", err)
}
@@ -258,6 +293,9 @@ func copyEmbeddedDir(embedDir string, targetDir string, skipDir string) error {
if err != nil {
return err
}
if err := backupBeforeReplace(target, data); err != nil {
return err
}
return os.WriteFile(target, data, 0o644)
})
}