-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp_skill.go
More file actions
1227 lines (1157 loc) · 33.4 KB
/
app_skill.go
File metadata and controls
1227 lines (1157 loc) · 33.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package main
import (
"archive/zip"
"bufio"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"os/exec"
"path/filepath"
goruntime "runtime"
"strings"
"time"
)
// SkillMeta represents metadata of an installed skill
type SkillMeta struct {
Name string `json:"name"`
Title string `json:"title"`
TitleEn string `json:"titleEn"`
TitleZh string `json:"titleZh"`
Description string `json:"description"`
DescEn string `json:"descEn"`
DescZh string `json:"descZh"`
Owner string `json:"owner"`
Version string `json:"version"`
Tags []string `json:"tags"`
IsMarket bool `json:"isMarket"`
MarketID int `json:"marketId"`
SyncedTools []string `json:"syncedTools"`
Location string `json:"location"`
UpdatedAt string `json:"updatedAt"`
SkillContent string `json:"skillContent"`
}
// IDEToolInfo represents an IDE or AI coding tool detected on the system
type IDEToolInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Installed bool `json:"installed"`
Path string `json:"path"`
SkillRulesDir string `json:"skillRulesDir"`
}
// skillUIJson is the structure saved as skillui.json inside market-installed skills
type skillUIJson struct {
MarketID int `json:"marketId"`
Name string `json:"name"`
TitleEn string `json:"titleEn"`
TitleZh string `json:"titleZh"`
DescEn string `json:"descEn"`
DescZh string `json:"descZh"`
Owner string `json:"owner"`
Version string `json:"version"`
Md5 string `json:"md5"`
InstalledAt string `json:"installedAt"`
}
// ideToolDef defines detection rules for an IDE tool per platform
type ideToolDef struct {
ID string
Name string
CheckPathsMac []string
CheckPathsWin []string
CheckPathsLin []string
RulesDirMac string
RulesDirWin string
RulesDirLin string
}
// expandHome replaces leading ~ with the user's home directory
func expandHome(path string) string {
if path == "" {
return path
}
if strings.HasPrefix(path, "~/") || path == "~" {
homeDir, err := os.UserHomeDir()
if err != nil {
return path
}
return filepath.Join(homeDir, path[1:])
}
return path
}
// getSkillDir returns the expanded skill directory path.
// On macOS the default is ~/Documents/SkillUI so that skills are stored in a
// user-accessible location, satisfying App Sandbox Guideline 2.4.5(i).
func (a *App) getSkillDir() string {
if a.config.SkillDir != "" {
return expandHome(a.config.SkillDir)
}
homeDir, _ := os.UserHomeDir()
if goruntime.GOOS == "darwin" {
return filepath.Join(homeDir, "Documents", "SkillUI")
}
return filepath.Join(homeDir, ".skillui", "skills")
}
// GetAutoSyncToolIDs returns the list of tool IDs with auto-sync enabled
func (a *App) GetAutoSyncToolIDs() []string {
if a.config.AutoSyncToolIDs == nil {
return []string{}
}
return a.config.AutoSyncToolIDs
}
// SetAutoSyncToolIDs saves the list of tool IDs with auto-sync enabled
func (a *App) SetAutoSyncToolIDs(ids []string) error {
if ids == nil {
ids = []string{}
}
a.config.AutoSyncToolIDs = ids
return a.store.Save(a.config)
}
// syncToInstalledTools syncs a skill to all tools that are installed AND have auto-sync enabled
func (a *App) syncToInstalledTools(skillName string) {
autoIDs := map[string]bool{}
for _, id := range a.config.AutoSyncToolIDs {
autoIDs[id] = true
}
if len(autoIDs) == 0 {
return
}
scanned, err := a.ScanIDETools()
if err != nil {
return
}
targets := make([]string, 0)
for _, t := range scanned {
if t.Installed && autoIDs[t.ID] {
targets = append(targets, t.ID)
}
}
if len(targets) > 0 {
_ = a.SyncSkillToTools(skillName, targets)
}
}
// GetSkillDir returns the current skill directory to the frontend
func (a *App) GetSkillDir() string {
return a.getSkillDir()
}
// SetSkillDir changes the skill directory, optionally migrating existing skills
func (a *App) SetSkillDir(newDir string, migrate bool) error {
newDir = expandHome(newDir)
if err := os.MkdirAll(newDir, 0755); err != nil {
return fmt.Errorf("无法创建目录: %w", err)
}
if migrate {
oldDir := a.getSkillDir()
if oldDir != newDir {
if err := moveDir(oldDir, newDir); err != nil {
return fmt.Errorf("迁移技能失败: %w", err)
}
}
}
a.config.SkillDir = newDir
return a.store.Save(a.config)
}
// moveDir moves all immediate subdirectories from src to dst
func moveDir(src, dst string) error {
entries, err := os.ReadDir(src)
if err != nil {
if os.IsNotExist(err) {
return nil
}
return err
}
for _, entry := range entries {
if !entry.IsDir() {
continue
}
srcPath := filepath.Join(src, entry.Name())
dstPath := filepath.Join(dst, entry.Name())
if err := os.Rename(srcPath, dstPath); err != nil {
// cross-device: fallback to copy+delete
if err2 := copyDir(srcPath, dstPath); err2 != nil {
return err2
}
os.RemoveAll(srcPath)
}
}
return nil
}
// copyDir recursively copies a directory
func copyDir(src, dst string) error {
if err := os.MkdirAll(dst, 0755); err != nil {
return err
}
return filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
rel, _ := filepath.Rel(src, path)
dstPath := filepath.Join(dst, rel)
if info.IsDir() {
return os.MkdirAll(dstPath, info.Mode())
}
return copyFile(path, dstPath)
})
}
// copyFile copies a single file
func copyFile(src, dst string) error {
in, err := os.Open(src)
if err != nil {
return err
}
defer in.Close()
if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil {
return err
}
out, err := os.Create(dst)
if err != nil {
return err
}
defer out.Close()
_, err = io.Copy(out, in)
return err
}
// parseSkillMeta reads SKILL.md frontmatter and optionally skillui.json from a skill directory
func parseSkillMeta(dir string) SkillMeta {
meta := SkillMeta{
Name: filepath.Base(dir),
Location: dir,
}
// Parse SKILL.md frontmatter
skillFile := filepath.Join(dir, "SKILL.md")
if f, err := os.Open(skillFile); err == nil {
defer f.Close()
scanner := bufio.NewScanner(f)
inFrontmatter := false
firstLine := true
for scanner.Scan() {
line := scanner.Text()
if firstLine {
firstLine = false
if line == "---" {
inFrontmatter = true
continue
}
break
}
if inFrontmatter {
if line == "---" {
break
}
if idx := strings.Index(line, ":"); idx > 0 {
key := strings.TrimSpace(line[:idx])
val := strings.TrimSpace(line[idx+1:])
val = strings.Trim(val, "'\"")
switch key {
case "name":
meta.Name = val
case "title":
meta.Title = val
case "description":
meta.Description = val
case "owner":
meta.Owner = val
case "version":
meta.Version = val
}
}
}
}
}
// Read full SKILL.md content
if data, err := os.ReadFile(skillFile); err == nil {
meta.SkillContent = string(data)
}
// Fallback: use dir name as title if empty
if meta.Title == "" {
meta.Title = meta.Name
}
// Read skillui.json if present (market-installed skill)
skillUIFile := filepath.Join(dir, "skillui.json")
if data, err := os.ReadFile(skillUIFile); err == nil {
var sj skillUIJson
if json.Unmarshal(data, &sj) == nil {
meta.IsMarket = true
meta.MarketID = sj.MarketID
meta.TitleEn = sj.TitleEn
meta.TitleZh = sj.TitleZh
meta.DescEn = sj.DescEn
meta.DescZh = sj.DescZh
if sj.Owner != "" {
meta.Owner = sj.Owner
}
if sj.Version != "" {
meta.Version = sj.Version
}
}
}
// UpdatedAt from directory mod time
if info, err := os.Stat(dir); err == nil {
meta.UpdatedAt = info.ModTime().Format("2006/01/02 15:04:05")
}
return meta
}
// ListLocalSkills scans the skill directory and returns all installed skills
func (a *App) ListLocalSkills() ([]SkillMeta, error) {
skillDir := a.getSkillDir()
if err := os.MkdirAll(skillDir, 0755); err != nil {
return nil, err
}
entries, err := os.ReadDir(skillDir)
if err != nil {
return nil, err
}
skills := make([]SkillMeta, 0)
for _, entry := range entries {
if !entry.IsDir() || strings.HasPrefix(entry.Name(), ".") {
continue
}
dir := filepath.Join(skillDir, entry.Name())
skill := parseSkillMeta(dir)
// Detect synced tools
skill.SyncedTools = detectSyncedTools(entry.Name(), a.getSkillDir())
skills = append(skills, skill)
}
return skills, nil
}
// InstallSkillFromUrl downloads a zip from the given URL and installs it
func (a *App) InstallSkillFromUrl(url, name string) error {
skillDir := a.getSkillDir()
if err := os.MkdirAll(skillDir, 0755); err != nil {
return err
}
// 将临时文件创建在 skillDir 下(~/Documents/SkillUI),该目录已在 macOS App Sandbox
// 的授权范围内,避免用 os.TempDir()(/var/folders/...)触发 EPERM。
// 写完后直接 Seek 回头部复用同一文件描述符,无需重新 open 路径。
tmpFile, err := os.CreateTemp(skillDir, ".tmp-skill-*.zip")
if err != nil {
return fmt.Errorf("创建临时文件失败: %w", err)
}
tmpPath := tmpFile.Name()
defer os.Remove(tmpPath)
defer tmpFile.Close()
resp, err := http.Get(url)
if err != nil {
return fmt.Errorf("下载失败: %w", err)
}
defer resp.Body.Close()
size, err := io.Copy(tmpFile, resp.Body)
if err != nil {
return fmt.Errorf("写入临时文件失败: %w", err)
}
if _, err = tmpFile.Seek(0, io.SeekStart); err != nil {
return fmt.Errorf("读取临时文件失败: %w", err)
}
destDir := filepath.Join(skillDir, name)
return extractZipReader(tmpFile, size, destDir)
}
// findSkillDirs recursively walks rootDir and returns all directories containing
// a SKILL.md file. It does NOT recurse into already-identified skill directories.
func findSkillDirs(rootDir string) ([]string, error) {
var skillDirs []string
err := filepath.WalkDir(rootDir, func(path string, d os.DirEntry, err error) error {
if err != nil {
return nil // skip unreadable paths
}
if !d.IsDir() {
return nil
}
if path != rootDir && strings.HasPrefix(d.Name(), ".") {
return filepath.SkipDir
}
if _, e := os.Stat(filepath.Join(path, "SKILL.md")); e == nil {
skillDirs = append(skillDirs, path)
return filepath.SkipDir // don't recurse into a skill directory
}
return nil
})
return skillDirs, err
}
// InstallSkillFromGit clones a git repository and installs all detected skills (directories containing SKILL.md)
func (a *App) InstallSkillFromGit(repoUrl string) ([]string, error) {
// Verify git is available
if _, err := exec.LookPath("git"); err != nil {
return nil, fmt.Errorf("未找到 git 命令,请先安装 Git")
}
// Create temp dir for clone
tmpDir, err := os.MkdirTemp("", "skill-git-*")
if err != nil {
return nil, err
}
defer os.RemoveAll(tmpDir)
// git clone --depth=1 <repoUrl> <tmpDir>
cmd := exec.Command("git", "clone", "--depth=1", repoUrl, tmpDir)
output, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("git clone 失败: %w\n%s", err, strings.TrimSpace(string(output)))
}
skillDir := a.getSkillDir()
if err := os.MkdirAll(skillDir, 0755); err != nil {
return nil, err
}
var installed []string
// Recursively find all directories containing SKILL.md
skillPaths, err := findSkillDirs(tmpDir)
if err != nil {
return nil, fmt.Errorf("扫描仓库失败: %w", err)
}
for _, subDir := range skillPaths {
name := filepath.Base(subDir)
// If the repo root itself is detected, use the repo name
if subDir == tmpDir {
name = filepath.Base(strings.TrimSuffix(repoUrl, ".git"))
}
destDir := filepath.Join(skillDir, name)
if err := copyDir(subDir, destDir); err != nil {
continue
}
installed = append(installed, name)
}
if len(installed) == 0 {
return nil, fmt.Errorf("未在仓库中找到任何有效技能(含 SKILL.md 的目录)")
}
// Auto-sync each installed skill
for _, name := range installed {
if len(a.config.AutoSyncToolIDs) > 0 {
a.syncToInstalledTools(name)
}
}
return installed, nil
}
// InstallSkillFromMarket downloads a zip and writes skillui.json metadata
func (a *App) InstallSkillFromMarket(url string, meta SkillMeta) error {
if err := a.InstallSkillFromUrl(url, meta.Name); err != nil {
return err
}
// Write skillui.json
sj := skillUIJson{
MarketID: meta.MarketID,
Name: meta.Name,
TitleEn: meta.TitleEn,
TitleZh: meta.TitleZh,
DescEn: meta.DescEn,
DescZh: meta.DescZh,
Owner: meta.Owner,
Version: meta.Version,
InstalledAt: time.Now().Format("2006-01-02T15:04:05Z"),
}
data, err := json.MarshalIndent(sj, "", " ")
if err != nil {
return err
}
destDir := filepath.Join(a.getSkillDir(), meta.Name)
if err := os.WriteFile(filepath.Join(destDir, "skillui.json"), data, 0644); err != nil {
return err
}
// Auto-sync to configured IDE tools if any
if len(a.config.AutoSyncToolIDs) > 0 {
a.syncToInstalledTools(meta.Name)
}
return nil
}
// InstallSkillFromLocalPath installs a skill from a local directory or file path
func (a *App) InstallSkillFromLocalPath(srcPath string) error {
skillDir := a.getSkillDir()
if err := os.MkdirAll(skillDir, 0755); err != nil {
return err
}
name := filepath.Base(srcPath)
// strip extension for zip/tar files
name = strings.TrimSuffix(name, ".zip")
name = strings.TrimSuffix(name, ".tar.gz")
info, err := os.Stat(srcPath)
if err != nil {
return err
}
destDir := filepath.Join(skillDir, name)
if info.IsDir() {
return copyDir(srcPath, destDir)
}
// treat as zip
return extractZip(srcPath, destDir)
}
// InstallSkillFromText creates a skill from pasted markdown text
func (a *App) InstallSkillFromText(name, content string) error {
skillDir := a.getSkillDir()
destDir := filepath.Join(skillDir, name)
if err := os.MkdirAll(destDir, 0755); err != nil {
return err
}
return os.WriteFile(filepath.Join(destDir, "SKILL.md"), []byte(content), 0644)
}
// DeleteSkill removes a skill directory and cleans up all synced tool files
func (a *App) DeleteSkill(name string) error {
// Remove synced files from all IDE tool rules directories
defs := ideToolDefs()
for _, def := range defs {
rulesDir := def.getRulesDir()
if rulesDir == "" {
continue
}
// Remove skillName.md symlink/file
skillFile := filepath.Join(rulesDir, name+".md")
if _, err := os.Lstat(skillFile); err == nil {
os.Remove(skillFile)
}
// Remove skillName dir/link (fallback path)
skillLink := filepath.Join(rulesDir, name)
if _, err := os.Lstat(skillLink); err == nil {
os.RemoveAll(skillLink)
}
}
skillDir := filepath.Join(a.getSkillDir(), name)
return os.RemoveAll(skillDir)
}
// extractZip extracts a zip file to destDir, auto-handling single-root nesting
// extractZipReader extracts zip content from an io.ReaderAt of the given size to destDir.
// Using an already-open reader avoids reopening by path, which can fail under macOS App Sandbox.
func extractZipReader(r io.ReaderAt, size int64, destDir string) error {
zr, err := zip.NewReader(r, size)
if err != nil {
return fmt.Errorf("无法打开ZIP: %w", err)
}
// Detect common root prefix
rootPrefix := ""
for _, f := range zr.File {
name := filepath.ToSlash(f.Name)
parts := strings.SplitN(name, "/", 2)
if len(parts) < 2 {
rootPrefix = ""
break
}
if rootPrefix == "" {
rootPrefix = parts[0]
} else if rootPrefix != parts[0] {
rootPrefix = ""
break
}
}
if err := os.MkdirAll(destDir, 0755); err != nil {
return err
}
for _, f := range zr.File {
name := filepath.ToSlash(f.Name)
if rootPrefix != "" {
prefix := rootPrefix + "/"
if strings.HasPrefix(name, prefix) {
name = name[len(prefix):]
} else {
continue
}
}
if name == "" {
continue
}
targetPath := filepath.Join(destDir, filepath.FromSlash(name))
// Prevent zip-slip
if !strings.HasPrefix(targetPath, filepath.Clean(destDir)+string(os.PathSeparator)) &&
targetPath != filepath.Clean(destDir) {
return fmt.Errorf("非法路径: %s", targetPath)
}
if f.FileInfo().IsDir() {
os.MkdirAll(targetPath, f.Mode())
continue
}
if err := os.MkdirAll(filepath.Dir(targetPath), 0755); err != nil {
return err
}
rc, err := f.Open()
if err != nil {
return err
}
out, err := os.Create(targetPath)
if err != nil {
rc.Close()
return err
}
_, err = io.Copy(out, rc)
rc.Close()
out.Close()
if err != nil {
return err
}
}
return nil
}
// extractZip extracts a zip file (by path) to destDir.
func extractZip(zipPath, destDir string) error {
f, err := os.Open(zipPath)
if err != nil {
return fmt.Errorf("无法打开ZIP: %w", err)
}
defer f.Close()
info, err := f.Stat()
if err != nil {
return err
}
return extractZipReader(f, info.Size(), destDir)
}
// ideToolDefs returns the list of known IDE tools with per-platform detection rules
func ideToolDefs() []ideToolDef {
home, _ := os.UserHomeDir()
return []ideToolDef{
{
ID: "cursor",
Name: "Cursor",
CheckPathsMac: []string{
filepath.Join(home, ".cursor"),
"/Applications/Cursor.app",
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("LOCALAPPDATA"), "Programs", "cursor", "Cursor.exe"),
filepath.Join(os.Getenv("APPDATA"), "Cursor"),
},
CheckPathsLin: []string{
filepath.Join(home, ".config", "Cursor"),
"/usr/share/applications/cursor.desktop",
},
RulesDirMac: filepath.Join(home, ".cursor", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "Cursor", "User", "rules"),
RulesDirLin: filepath.Join(home, ".config", "Cursor", "User", "rules"),
},
{
ID: "claude_code",
Name: "Claude Code",
CheckPathsMac: []string{},
CheckPathsWin: []string{},
CheckPathsLin: []string{},
RulesDirMac: filepath.Join(home, ".claude", "commands"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), ".claude", "commands"),
RulesDirLin: filepath.Join(home, ".claude", "commands"),
},
{
ID: "windsurf",
Name: "Windsurf",
CheckPathsMac: []string{
"/Applications/Windsurf.app",
filepath.Join(home, "Library", "Application Support", "Windsurf"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("LOCALAPPDATA"), "Programs", "windsurf", "Windsurf.exe"),
filepath.Join(os.Getenv("APPDATA"), "Windsurf"),
},
CheckPathsLin: []string{
filepath.Join(home, ".config", "Windsurf"),
"/usr/share/applications/windsurf.desktop",
},
RulesDirMac: filepath.Join(home, ".codeium", "windsurf", "memories"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "Codeium", "windsurf", "memories"),
RulesDirLin: filepath.Join(home, ".codeium", "windsurf", "memories"),
},
{
ID: "trae",
Name: "TRAE IDE",
CheckPathsMac: []string{
"/Applications/Trae.app",
filepath.Join(home, "Library", "Application Support", "Trae"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("LOCALAPPDATA"), "Programs", "trae", "Trae.exe"),
filepath.Join(os.Getenv("APPDATA"), "Trae"),
},
CheckPathsLin: []string{
filepath.Join(home, ".config", "Trae"),
},
RulesDirMac: filepath.Join(home, "Library", "Application Support", "Trae", "User", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "Trae", "User", "rules"),
RulesDirLin: filepath.Join(home, ".config", "Trae", "User", "rules"),
},
{
ID: "zed",
Name: "Zed",
CheckPathsMac: []string{
"/Applications/Zed.app",
filepath.Join(home, "Library", "Application Support", "Zed"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "Zed"),
},
CheckPathsLin: []string{
filepath.Join(home, ".config", "zed"),
},
RulesDirMac: filepath.Join(home, "Library", "Application Support", "Zed", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "Zed", "rules"),
RulesDirLin: filepath.Join(home, ".config", "zed", "rules"),
},
{
ID: "kilo_code",
Name: "Kilo Code",
CheckPathsMac: []string{
filepath.Join(home, ".kilo"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "Kilo"),
},
CheckPathsLin: []string{
filepath.Join(home, ".kilo"),
},
RulesDirMac: filepath.Join(home, ".kilo", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "Kilo", "rules"),
RulesDirLin: filepath.Join(home, ".kilo", "rules"),
},
{
ID: "roo_code",
Name: "Roo Code",
CheckPathsMac: []string{
filepath.Join(home, ".roo"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "Roo"),
},
CheckPathsLin: []string{
filepath.Join(home, ".roo"),
},
RulesDirMac: filepath.Join(home, ".roo", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "Roo", "rules"),
RulesDirLin: filepath.Join(home, ".roo", "rules"),
},
{
ID: "goose",
Name: "Goose",
CheckPathsMac: []string{
filepath.Join(home, ".config", "goose"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "goose"),
},
CheckPathsLin: []string{
filepath.Join(home, ".config", "goose"),
},
RulesDirMac: filepath.Join(home, ".config", "goose", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "goose", "rules"),
RulesDirLin: filepath.Join(home, ".config", "goose", "rules"),
},
{
ID: "gemini_cli",
Name: "Gemini CLI",
CheckPathsMac: []string{},
CheckPathsWin: []string{},
CheckPathsLin: []string{},
RulesDirMac: filepath.Join(home, ".gemini", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "gemini", "rules"),
RulesDirLin: filepath.Join(home, ".gemini", "rules"),
},
{
ID: "github_copilot",
Name: "GitHub Copilot",
CheckPathsMac: []string{
filepath.Join(home, "Library", "Application Support", "GitHub Copilot"),
filepath.Join(home, ".config", "github-copilot"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "GitHub Copilot"),
},
CheckPathsLin: []string{
filepath.Join(home, ".config", "github-copilot"),
},
RulesDirMac: filepath.Join(home, ".github", "copilot", "rules"),
RulesDirWin: filepath.Join(os.Getenv("USERPROFILE"), ".github", "copilot", "rules"),
RulesDirLin: filepath.Join(home, ".github", "copilot", "rules"),
},
{
ID: "opencode",
Name: "OpenCode",
CheckPathsMac: []string{
filepath.Join(home, ".config", "opencode"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "opencode"),
},
CheckPathsLin: []string{
filepath.Join(home, ".config", "opencode"),
},
RulesDirMac: filepath.Join(home, ".config", "opencode", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "opencode", "rules"),
RulesDirLin: filepath.Join(home, ".config", "opencode", "rules"),
},
{
ID: "amp",
Name: "Amp",
CheckPathsMac: []string{
filepath.Join(home, ".amp"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "Amp"),
},
CheckPathsLin: []string{
filepath.Join(home, ".amp"),
},
RulesDirMac: filepath.Join(home, ".amp", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "Amp", "rules"),
RulesDirLin: filepath.Join(home, ".amp", "rules"),
},
{
ID: "codex",
Name: "Codex",
CheckPathsMac: []string{},
CheckPathsWin: []string{},
CheckPathsLin: []string{},
RulesDirMac: filepath.Join(home, ".codex", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "codex", "rules"),
RulesDirLin: filepath.Join(home, ".codex", "rules"),
},
{
ID: "amazon_q",
Name: "Amazon Q",
CheckPathsMac: []string{
filepath.Join(home, ".aws", "amazonq"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("USERPROFILE"), ".aws", "amazonq"),
},
CheckPathsLin: []string{
filepath.Join(home, ".aws", "amazonq"),
},
RulesDirMac: filepath.Join(home, ".aws", "amazonq", "rules"),
RulesDirWin: filepath.Join(os.Getenv("USERPROFILE"), ".aws", "amazonq", "rules"),
RulesDirLin: filepath.Join(home, ".aws", "amazonq", "rules"),
},
{
ID: "cline",
Name: "Cline",
CheckPathsMac: []string{
filepath.Join(home, ".cline"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "cline"),
},
CheckPathsLin: []string{
filepath.Join(home, ".cline"),
},
RulesDirMac: filepath.Join(home, ".cline", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "cline", "rules"),
RulesDirLin: filepath.Join(home, ".cline", "rules"),
},
{
ID: "antigravity",
Name: "Antigravity",
CheckPathsMac: []string{
filepath.Join(home, ".antigravity"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "antigravity"),
},
CheckPathsLin: []string{
filepath.Join(home, ".antigravity"),
},
RulesDirMac: filepath.Join(home, ".antigravity", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "antigravity", "rules"),
RulesDirLin: filepath.Join(home, ".antigravity", "rules"),
},
{
ID: "qoder",
Name: "Qoder",
CheckPathsMac: []string{
filepath.Join(home, ".qoder"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "qoder"),
},
CheckPathsLin: []string{
filepath.Join(home, ".qoder"),
},
RulesDirMac: filepath.Join(home, ".qoder", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "qoder", "rules"),
RulesDirLin: filepath.Join(home, ".qoder", "rules"),
},
{
ID: "auggie_cli",
Name: "Auggie CLI",
CheckPathsMac: []string{},
CheckPathsWin: []string{},
CheckPathsLin: []string{},
RulesDirMac: filepath.Join(home, ".augment", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "augment", "rules"),
RulesDirLin: filepath.Join(home, ".augment", "rules"),
},
{
ID: "qwen_code",
Name: "Qwen Code",
CheckPathsMac: []string{},
CheckPathsWin: []string{},
CheckPathsLin: []string{},
RulesDirMac: filepath.Join(home, ".qwen-code", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "qwen-code", "rules"),
RulesDirLin: filepath.Join(home, ".qwen-code", "rules"),
},
{
ID: "codebuddy",
Name: "CodeBuddy",
CheckPathsMac: []string{
filepath.Join(home, "Library", "Application Support", "CodeBuddy"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "CodeBuddy"),
},
CheckPathsLin: []string{
filepath.Join(home, ".config", "CodeBuddy"),
},
RulesDirMac: filepath.Join(home, ".codebuddy", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "CodeBuddy", "rules"),
RulesDirLin: filepath.Join(home, ".codebuddy", "rules"),
},
{
ID: "costrict",
Name: "CoStrict",
CheckPathsMac: []string{
filepath.Join(home, ".costrict"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "costrict"),
},
CheckPathsLin: []string{
filepath.Join(home, ".costrict"),
},
RulesDirMac: filepath.Join(home, ".costrict", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "costrict", "rules"),
RulesDirLin: filepath.Join(home, ".costrict", "rules"),
},
{
ID: "crush",
Name: "Crush",
CheckPathsMac: []string{},
CheckPathsWin: []string{},
CheckPathsLin: []string{},
RulesDirMac: filepath.Join(home, ".crush", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "crush", "rules"),
RulesDirLin: filepath.Join(home, ".crush", "rules"),
},
{
ID: "factory_droid",
Name: "Factory Droid",
CheckPathsMac: []string{
filepath.Join(home, ".factory"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "factory"),
},
CheckPathsLin: []string{
filepath.Join(home, ".factory"),
},
RulesDirMac: filepath.Join(home, ".factory", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "factory", "rules"),
RulesDirLin: filepath.Join(home, ".factory", "rules"),
},
{
ID: "iflow",
Name: "iFlow",
CheckPathsMac: []string{
filepath.Join(home, ".iflow"),
},
CheckPathsWin: []string{
filepath.Join(os.Getenv("APPDATA"), "iflow"),
},
CheckPathsLin: []string{
filepath.Join(home, ".iflow"),
},
RulesDirMac: filepath.Join(home, ".iflow", "rules"),
RulesDirWin: filepath.Join(os.Getenv("APPDATA"), "iflow", "rules"),
RulesDirLin: filepath.Join(home, ".iflow", "rules"),