skill-linker 4.1.3 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/file-system.js +6 -1
- package/src/utils/git.js +29 -8
package/package.json
CHANGED
package/src/utils/file-system.js
CHANGED
|
@@ -32,6 +32,11 @@ function ensureDir(dirPath) {
|
|
|
32
32
|
*/
|
|
33
33
|
function createSymlink(source, target) {
|
|
34
34
|
try {
|
|
35
|
+
// Resolve the source to an absolute path. A relative source (e.g.
|
|
36
|
+
// "./my-skill") would otherwise be stored verbatim and resolved
|
|
37
|
+
// relative to the link's own directory, producing a broken link.
|
|
38
|
+
const resolvedSource = path.resolve(source);
|
|
39
|
+
|
|
35
40
|
// Ensure parent directory exists
|
|
36
41
|
ensureDir(path.dirname(target));
|
|
37
42
|
|
|
@@ -57,7 +62,7 @@ function createSymlink(source, target) {
|
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
|
|
60
|
-
fs.symlinkSync(
|
|
65
|
+
fs.symlinkSync(resolvedSource, target, 'dir');
|
|
61
66
|
return true;
|
|
62
67
|
} catch (error) {
|
|
63
68
|
console.error(`Failed to create symlink: ${error.message}`);
|
package/src/utils/git.js
CHANGED
|
@@ -13,7 +13,8 @@ const DEFAULT_LIB_PATH = path.join(os.homedir(), "Documents/AgentSkills");
|
|
|
13
13
|
function parseGitHubUrl(url) {
|
|
14
14
|
let cleanUrl = url;
|
|
15
15
|
let subpath = "";
|
|
16
|
-
|
|
16
|
+
// null means "no explicit branch" — let git use the remote default.
|
|
17
|
+
let branch = null;
|
|
17
18
|
|
|
18
19
|
// Check for /tree/branch/path format
|
|
19
20
|
const treeMatch = url.match(/(.+)\/tree\/([^/]+)\/(.+)$/);
|
|
@@ -39,19 +40,38 @@ function parseGitHubUrl(url) {
|
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Build the argument list for `git clone`.
|
|
45
|
+
* @param {string} url - GitHub URL
|
|
46
|
+
* @param {string} targetPath - Target directory
|
|
47
|
+
* @param {Object} [opts]
|
|
48
|
+
* @param {boolean} [opts.shallow] - Use shallow clone (default true)
|
|
49
|
+
* @param {string|null} [opts.branch] - Branch to check out, or null for default
|
|
50
|
+
* @returns {string[]} git arguments
|
|
51
|
+
*/
|
|
52
|
+
function buildCloneArgs(url, targetPath, { shallow = true, branch = null } = {}) {
|
|
53
|
+
const args = ["clone"];
|
|
54
|
+
if (shallow) {
|
|
55
|
+
args.push("--depth", "1");
|
|
56
|
+
}
|
|
57
|
+
if (branch) {
|
|
58
|
+
args.push("--branch", branch);
|
|
59
|
+
}
|
|
60
|
+
args.push(url, targetPath);
|
|
61
|
+
return args;
|
|
62
|
+
}
|
|
63
|
+
|
|
42
64
|
/**
|
|
43
65
|
* Clone a GitHub repository
|
|
44
66
|
* @param {string} url - GitHub URL
|
|
45
67
|
* @param {string} targetPath - Target directory
|
|
46
68
|
* @param {boolean} shallow - Use shallow clone (default true)
|
|
69
|
+
* @param {string|null} branch - Branch to check out, or null for default
|
|
47
70
|
* @returns {Promise<void>}
|
|
48
71
|
*/
|
|
49
|
-
async function cloneRepo(url, targetPath, shallow = true) {
|
|
72
|
+
async function cloneRepo(url, targetPath, shallow = true, branch = null) {
|
|
50
73
|
try {
|
|
51
|
-
|
|
52
|
-
? ["clone", "--depth", "1", url, targetPath]
|
|
53
|
-
: ["clone", url, targetPath];
|
|
54
|
-
await execa("git", args);
|
|
74
|
+
await execa("git", buildCloneArgs(url, targetPath, { shallow, branch }));
|
|
55
75
|
} catch (error) {
|
|
56
76
|
throw new Error(`Failed to clone repository: ${error.message}`);
|
|
57
77
|
}
|
|
@@ -85,8 +105,8 @@ async function cloneOrUpdateRepo(url) {
|
|
|
85
105
|
// Repo exists, ask if user wants to update
|
|
86
106
|
needsUpdate = true;
|
|
87
107
|
} else {
|
|
88
|
-
// Clone new repo
|
|
89
|
-
await cloneRepo(parsed.cleanUrl, targetPath);
|
|
108
|
+
// Clone new repo (honour an explicit branch from /tree/<branch>/ URLs)
|
|
109
|
+
await cloneRepo(parsed.cleanUrl, targetPath, true, parsed.branch);
|
|
90
110
|
}
|
|
91
111
|
|
|
92
112
|
// Determine final skill path
|
|
@@ -106,6 +126,7 @@ async function cloneOrUpdateRepo(url) {
|
|
|
106
126
|
module.exports = {
|
|
107
127
|
DEFAULT_LIB_PATH,
|
|
108
128
|
parseGitHubUrl,
|
|
129
|
+
buildCloneArgs,
|
|
109
130
|
cloneRepo,
|
|
110
131
|
pullRepo,
|
|
111
132
|
cloneOrUpdateRepo,
|