-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaths.ts
More file actions
89 lines (82 loc) · 3.03 KB
/
paths.ts
File metadata and controls
89 lines (82 loc) · 3.03 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
import * as path from "path"
import os from "os"
import { Filesystem } from "../util/filesystem"
export namespace KilocodePaths {
/**
* Get the platform-specific VSCode global storage path for Kilocode extension.
* - macOS: ~/Library/Application Support/Code/User/globalStorage/kilocode.kilo-code
* - Windows: %APPDATA%/Code/User/globalStorage/kilocode.kilo-code
* - Linux: ~/.config/Code/User/globalStorage/kilocode.kilo-code
*/
export function vscodeGlobalStorage(): string {
const home = os.homedir()
switch (process.platform) {
case "darwin":
return path.join(home, "Library", "Application Support", "Code", "User", "globalStorage", "kilocode.kilo-code")
case "win32":
return path.join(
process.env.APPDATA || path.join(home, "AppData", "Roaming"),
"Code",
"User",
"globalStorage",
"kilocode.kilo-code",
)
default:
return path.join(home, ".config", "Code", "User", "globalStorage", "kilocode.kilo-code")
}
}
/** Global Kilocode directory in user home: ~/.kilocode */
export function globalDir(): string {
return path.join(os.homedir(), ".kilocode")
}
/**
* Discover Kilocode directories containing skills.
* Returns parent directories (.kilocode/) for glob pattern "skills/[*]/SKILL.md".
*
* - Walks up from projectDir to worktreeRoot for .kilocode/
* - Includes global ~/.kilocode/
* - Includes VSCode extension global storage
*
* Does NOT copy/migrate skills - just provides paths for discovery.
* Skills remain in their original locations and can be managed independently
* by the Kilo VSCode extension.
*/
export async function skillDirectories(opts: {
projectDir: string
worktreeRoot: string
skipGlobalPaths?: boolean
}): Promise<string[]> {
const directories: string[] = []
// 1. Walk up from project dir to worktree root for .kilocode/
// Returns .kilocode/ directories (not .kilocode/skills/) because
// the glob pattern "skills/[*]/SKILL.md" is applied from the parent
const projectDirs = await Array.fromAsync(
Filesystem.up({
targets: [".kilocode"],
start: opts.projectDir,
stop: opts.worktreeRoot,
}),
)
for (const dir of projectDirs) {
const skillsDir = path.join(dir, "skills")
if (await Filesystem.isDir(skillsDir)) {
directories.push(dir) // Return parent (.kilocode/), not skills/
}
}
if (!opts.skipGlobalPaths) {
// 2. Global ~/.kilocode/
const global = globalDir()
const globalSkills = path.join(global, "skills")
if (await Filesystem.isDir(globalSkills)) {
directories.push(global) // Return parent, not skills/
}
// 3. VSCode extension global storage (marketplace-installed skills)
const vscode = vscodeGlobalStorage()
const vscodeSkills = path.join(vscode, "skills")
if (await Filesystem.isDir(vscodeSkills)) {
directories.push(vscode) // Return parent, not skills/
}
}
return directories
}
}