ali-skills 0.1.3 → 0.1.5
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/node_modules/@ali/cli-skills/dist/_chunks/plugin.mjs +1 -1
- package/node_modules/@ali/cli-skills/dist/_chunks/publish.mjs +1 -1
- package/node_modules/@ali/cli-skills/dist/_chunks/skill-lock.mjs +63 -61
- package/node_modules/@ali/cli-skills/dist/cli.mjs +625 -443
- package/node_modules/@ali/cli-skills/package.json +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import { i as __toESM } from "./rolldown-runtime.mjs";
|
|
|
2
2
|
import { l as pD, u as require_picocolors } from "./libs/@clack/core.mjs";
|
|
3
3
|
import { a as Y, n as M, s as fe } from "./libs/@clack/prompts.mjs";
|
|
4
4
|
import { i as SKILLS_API_BASE_URL, n as findPluginPackageRoots, t as validatePluginPackage } from "./plugin-manifest-validate.mjs";
|
|
5
|
-
import { A as getDisplaySource, D as redactCliSnippet, F as resolveSourceInput, I as toInternalHttpsCloneUrl, P as parseSource,
|
|
5
|
+
import { A as getDisplaySource, D as redactCliSnippet, F as resolveSourceInput, I as toInternalHttpsCloneUrl, P as parseSource, _ as trackPluginCommand, b as PLUGINS_SUBDIR, d as saveSelectedAgents, k as embedInternalGitCredentials, o as getLastSelectedAgents, v as trackPluginInstall, w as cloneRepo, y as AGENTS_DIR } from "./skill-lock.mjs";
|
|
6
6
|
import "./libs/@kwsites/file-exists.mjs";
|
|
7
7
|
import "./libs/@kwsites/promise-deferred.mjs";
|
|
8
8
|
import "./libs/simple-git.mjs";
|
|
@@ -741,4 +741,4 @@ async function runPluginPublish(_options = {}) {
|
|
|
741
741
|
spinner.stop(`${import_picocolors.default.green("✓")} Registered ${items.length} plugin(s)`);
|
|
742
742
|
Se(import_picocolors.default.green("插件录入成功,已可在平台检索安装。"));
|
|
743
743
|
}
|
|
744
|
-
export { addSkillToLocalLock as a,
|
|
744
|
+
export { addSkillToLocalLock as a, writeLocalLock as c, getSkillDisplayName as d, isValidSkillName as f, logSkillParseFailures as i, discoverSkills as l, runPluginPublish as n, computeSkillFolderHash as o, parseSkillMd as p, runPublish as r, readLocalLock as s, parsePublishOptions as t, filterSkills as u };
|
|
@@ -64,7 +64,15 @@ function parseOwnerRepo(ownerRepo) {
|
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
66
|
async function isRepoPrivate(owner, repo) {
|
|
67
|
-
|
|
67
|
+
try {
|
|
68
|
+
const source = encodeURIComponent(`${owner}/${repo}`);
|
|
69
|
+
const res = await fetch(`${SKILLS_API_BASE_URL}/github/repository?source=${source}`);
|
|
70
|
+
if (!res.ok) return null;
|
|
71
|
+
const data = await res.json();
|
|
72
|
+
return data.success && typeof data.data?.private === "boolean" ? data.data.private : null;
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
68
76
|
}
|
|
69
77
|
function sanitizeSubpath(subpath) {
|
|
70
78
|
const segments = subpath.replace(/\\/g, "/").split("/");
|
|
@@ -360,6 +368,9 @@ async function cloneRepo(url, ref) {
|
|
|
360
368
|
throw new GitCloneError(`Failed to clone ${safeUrl}: ${safeErrorMessage}`, safeUrl, false, false);
|
|
361
369
|
}
|
|
362
370
|
}
|
|
371
|
+
async function getGitHeadHash(repoDir) {
|
|
372
|
+
return (await esm_default(repoDir).revparse(["HEAD"])).trim();
|
|
373
|
+
}
|
|
363
374
|
async function listRemoteBranches(url) {
|
|
364
375
|
const git = esm_default({
|
|
365
376
|
timeout: { block: 15e3 },
|
|
@@ -555,72 +566,63 @@ async function writeSkillLock(lock) {
|
|
|
555
566
|
await mkdir(dirname(lockPath), { recursive: true });
|
|
556
567
|
await writeFile(lockPath, JSON.stringify(lock, null, 2), "utf-8");
|
|
557
568
|
}
|
|
558
|
-
function
|
|
559
|
-
if (process.env.GITHUB_TOKEN) return process.env.GITHUB_TOKEN;
|
|
560
|
-
if (process.env.GH_TOKEN) return process.env.GH_TOKEN;
|
|
561
|
-
try {
|
|
562
|
-
const token = execSync("gh auth token", {
|
|
563
|
-
encoding: "utf-8",
|
|
564
|
-
stdio: [
|
|
565
|
-
"pipe",
|
|
566
|
-
"pipe",
|
|
567
|
-
"pipe"
|
|
568
|
-
]
|
|
569
|
-
}).trim();
|
|
570
|
-
if (token) return token;
|
|
571
|
-
} catch {}
|
|
572
|
-
return null;
|
|
573
|
-
}
|
|
574
|
-
async function fetchSkillFolderHash(ownerRepo, skillPath, token) {
|
|
575
|
-
let folderPath = skillPath.replace(/\\/g, "/");
|
|
576
|
-
if (folderPath.endsWith("/SKILL.md")) folderPath = folderPath.slice(0, -9);
|
|
577
|
-
else if (folderPath.endsWith("SKILL.md")) folderPath = folderPath.slice(0, -8);
|
|
578
|
-
if (folderPath.endsWith("/")) folderPath = folderPath.slice(0, -1);
|
|
579
|
-
for (const ref of [
|
|
580
|
-
"HEAD",
|
|
581
|
-
"master",
|
|
582
|
-
"main"
|
|
583
|
-
]) try {
|
|
584
|
-
const url = `https://api.github.com/repos/${ownerRepo}/git/trees/${ref}?recursive=1`;
|
|
585
|
-
const headers = {
|
|
586
|
-
Accept: "application/vnd.github.v3+json",
|
|
587
|
-
"User-Agent": "skills-cli"
|
|
588
|
-
};
|
|
589
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
590
|
-
const response = await fetch(url, { headers });
|
|
591
|
-
if (!response.ok) continue;
|
|
592
|
-
const data = await response.json();
|
|
593
|
-
if (!folderPath) return data.sha;
|
|
594
|
-
const folderEntry = data.tree.find((entry) => entry.type === "tree" && entry.path === folderPath);
|
|
595
|
-
if (folderEntry) return folderEntry.sha;
|
|
596
|
-
} catch {
|
|
597
|
-
continue;
|
|
598
|
-
}
|
|
599
|
-
return null;
|
|
600
|
-
}
|
|
601
|
-
async function fetchAliInternalCommitHash(source, skillPath = "", token) {
|
|
569
|
+
async function fetchAliInternalSkillVersion(source, skillPath = "", token) {
|
|
602
570
|
const refs = [
|
|
603
571
|
"HEAD",
|
|
604
572
|
"master",
|
|
605
573
|
"main"
|
|
606
574
|
];
|
|
607
575
|
const privateToken = token || process.env.GITLAB_PRIVATE_TOKEN || process.env.CODE_ALIBABA_TOKEN || GITLAB_ACCOUNT.token;
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
const
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
576
|
+
const encodedSource = encodeURIComponent(source);
|
|
577
|
+
const normalizedPath = skillPath.trim().replace(/\\/g, "/").replace(/^\/+|\/+$/g, "").replace(/\/?SKILL\.md$/i, "").replace(/\/+$/g, "");
|
|
578
|
+
const skillFile = normalizedPath ? `${normalizedPath}/SKILL.md` : "SKILL.md";
|
|
579
|
+
const headers = {
|
|
580
|
+
Accept: "application/json",
|
|
581
|
+
"User-Agent": "skills-cli",
|
|
582
|
+
"Private-Token": privateToken
|
|
583
|
+
};
|
|
584
|
+
let sawNotFound = false;
|
|
585
|
+
for (const ref of refs) {
|
|
586
|
+
const controller = new AbortController();
|
|
587
|
+
const timer = setTimeout(() => controller.abort(), 8e3);
|
|
588
|
+
try {
|
|
589
|
+
const fileUrl = `https://code.alibaba-inc.com/api/v4/projects/${encodedSource}/repository/files/${encodeURIComponent(skillFile)}?ref=${encodeURIComponent(ref)}`;
|
|
590
|
+
const fileResponse = await fetch(fileUrl, {
|
|
591
|
+
headers,
|
|
592
|
+
signal: controller.signal
|
|
593
|
+
});
|
|
594
|
+
if (fileResponse.status === 404) {
|
|
595
|
+
sawNotFound = true;
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
if (fileResponse.status === 401 || fileResponse.status === 403) return { status: "unauthorized" };
|
|
599
|
+
if (fileResponse.status === 429) return { status: "rate-limited" };
|
|
600
|
+
if (!fileResponse.ok) return { status: "upstream-error" };
|
|
601
|
+
let commitUrl = `https://code.alibaba-inc.com/api/v4/projects/${encodedSource}/repository/commits?ref_name=${encodeURIComponent(ref)}&per_page=1`;
|
|
602
|
+
if (normalizedPath) commitUrl += `&path=${encodeURIComponent(normalizedPath)}`;
|
|
603
|
+
const commitResponse = await fetch(commitUrl, {
|
|
604
|
+
headers,
|
|
605
|
+
signal: controller.signal
|
|
606
|
+
});
|
|
607
|
+
if (commitResponse.status === 401 || commitResponse.status === 403) return { status: "unauthorized" };
|
|
608
|
+
if (commitResponse.status === 429) return { status: "rate-limited" };
|
|
609
|
+
if (!commitResponse.ok) return { status: "upstream-error" };
|
|
610
|
+
const commits = await commitResponse.json();
|
|
611
|
+
return commits[0]?.id ? {
|
|
612
|
+
status: "ok",
|
|
613
|
+
latestHash: commits[0].id
|
|
614
|
+
} : { status: "upstream-error" };
|
|
615
|
+
} catch (error) {
|
|
616
|
+
return { status: error instanceof Error && error.name === "AbortError" ? "timeout" : "upstream-error" };
|
|
617
|
+
} finally {
|
|
618
|
+
clearTimeout(timer);
|
|
619
|
+
}
|
|
622
620
|
}
|
|
623
|
-
return
|
|
621
|
+
return { status: sawNotFound ? "not-found" : "upstream-error" };
|
|
622
|
+
}
|
|
623
|
+
async function fetchAliInternalCommitHash(source, skillPath = "", token) {
|
|
624
|
+
const result = await fetchAliInternalSkillVersion(source, skillPath, token);
|
|
625
|
+
return result.status === "ok" ? result.latestHash ?? null : null;
|
|
624
626
|
}
|
|
625
627
|
async function addSkillToLock(skillName, entry) {
|
|
626
628
|
const lock = await readSkillLock();
|
|
@@ -689,4 +691,4 @@ function sanitizeSourceUrl(url) {
|
|
|
689
691
|
}
|
|
690
692
|
return url;
|
|
691
693
|
}
|
|
692
|
-
export { getDisplaySource as A,
|
|
694
|
+
export { getDisplaySource as A, cleanupTempDir as C, redactCliSnippet as D, listRemoteBranches as E, resolveSourceInput as F, toInternalHttpsCloneUrl as I, isRepoPrivate as M, parseOwnerRepo as N, redactSensitiveText as O, parseSource as P, GitCloneError as S, getGitHeadHash as T, trackPluginCommand as _, getAllLockedSkills as a, PLUGINS_SUBDIR as b, isPromptDismissed as c, saveSelectedAgents as d, fetchAuditData as f, track as g, setVersion as h, fetchAliInternalSkillVersion as i, getOwnerRepo as j, embedInternalGitCredentials as k, removeSkillFromLock as l, getPendingTelemetryCount as m, dismissPrompt as n, getLastSelectedAgents as o, flushTelemetry as p, fetchAliInternalCommitHash as r, getSkillFromLock as s, addSkillToLock as t, sanitizeSourceUrl as u, trackPluginInstall as v, cloneRepo as w, SKILLS_SUBDIR as x, AGENTS_DIR$1 as y };
|