skilluse 0.1.10 → 0.2.1
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/dist/cli.js +469 -442
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -50437,6 +50437,25 @@ var getInstance = (stdout, createInstance) => {
|
|
|
50437
50437
|
};
|
|
50438
50438
|
// node_modules/ink/build/components/Static.js
|
|
50439
50439
|
var import_react14 = __toESM(require_react(), 1);
|
|
50440
|
+
function Static(props) {
|
|
50441
|
+
const { items, children: render2, style: customStyle } = props;
|
|
50442
|
+
const [index, setIndex] = import_react14.useState(0);
|
|
50443
|
+
const itemsToRender = import_react14.useMemo(() => {
|
|
50444
|
+
return items.slice(index);
|
|
50445
|
+
}, [items, index]);
|
|
50446
|
+
import_react14.useLayoutEffect(() => {
|
|
50447
|
+
setIndex(items.length);
|
|
50448
|
+
}, [items.length]);
|
|
50449
|
+
const children = itemsToRender.map((item, itemIndex) => {
|
|
50450
|
+
return render2(item, index + itemIndex);
|
|
50451
|
+
});
|
|
50452
|
+
const style = import_react14.useMemo(() => ({
|
|
50453
|
+
position: "absolute",
|
|
50454
|
+
flexDirection: "column",
|
|
50455
|
+
...customStyle
|
|
50456
|
+
}), [customStyle]);
|
|
50457
|
+
return import_react14.default.createElement("ink-box", { internal_static: true, style }, children);
|
|
50458
|
+
}
|
|
50440
50459
|
// node_modules/ink/build/components/Transform.js
|
|
50441
50460
|
var import_react15 = __toESM(require_react(), 1);
|
|
50442
50461
|
// node_modules/ink/build/components/Newline.js
|
|
@@ -66561,18 +66580,63 @@ function getSkillsPath(agentId, scope) {
|
|
|
66561
66580
|
}
|
|
66562
66581
|
return join(process.cwd(), agent.localPath);
|
|
66563
66582
|
}
|
|
66583
|
+
// src/services/github.ts
|
|
66584
|
+
function buildGitHubHeaders(token) {
|
|
66585
|
+
const headers = {
|
|
66586
|
+
Accept: "application/vnd.github+json",
|
|
66587
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
66588
|
+
};
|
|
66589
|
+
if (token) {
|
|
66590
|
+
headers.Authorization = `Bearer ${token}`;
|
|
66591
|
+
}
|
|
66592
|
+
return headers;
|
|
66593
|
+
}
|
|
66594
|
+
function buildGitHubRawHeaders(token) {
|
|
66595
|
+
const headers = {
|
|
66596
|
+
Accept: "application/vnd.github.raw+json",
|
|
66597
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
66598
|
+
};
|
|
66599
|
+
if (token) {
|
|
66600
|
+
headers.Authorization = `Bearer ${token}`;
|
|
66601
|
+
}
|
|
66602
|
+
return headers;
|
|
66603
|
+
}
|
|
66604
|
+
function isAuthRequired(response) {
|
|
66605
|
+
return response.status === 401 || response.status === 403 && !isRateLimited(response);
|
|
66606
|
+
}
|
|
66607
|
+
function isRateLimited(response) {
|
|
66608
|
+
return response.headers.get("X-RateLimit-Remaining") === "0";
|
|
66609
|
+
}
|
|
66610
|
+
function getGitHubErrorMessage(response) {
|
|
66611
|
+
if (response.status === 401) {
|
|
66612
|
+
return "This repository requires authentication. Run 'skilluse login' to access private repos.";
|
|
66613
|
+
}
|
|
66614
|
+
if (response.status === 403) {
|
|
66615
|
+
if (isRateLimited(response)) {
|
|
66616
|
+
return "Rate limit exceeded. Run 'skilluse login' for higher rate limits (5000 req/hr vs 60 req/hr).";
|
|
66617
|
+
}
|
|
66618
|
+
return "This repository requires authentication. Run 'skilluse login' to access private repos.";
|
|
66619
|
+
}
|
|
66620
|
+
if (response.status === 404) {
|
|
66621
|
+
return "Repository not found or requires authentication.";
|
|
66622
|
+
}
|
|
66623
|
+
return `GitHub API error: ${response.status}`;
|
|
66624
|
+
}
|
|
66625
|
+
|
|
66564
66626
|
// src/services/discovery.ts
|
|
66565
66627
|
var GITHUB_API_URL2 = "https://api.github.com";
|
|
66566
66628
|
async function discoverSkillPaths(owner, repo, branch, token) {
|
|
66567
66629
|
const url2 = `${GITHUB_API_URL2}/repos/${owner}/${repo}/git/trees/${branch}?recursive=1`;
|
|
66568
66630
|
const response = await fetch(url2, {
|
|
66569
|
-
headers:
|
|
66570
|
-
Accept: "application/vnd.github+json",
|
|
66571
|
-
Authorization: `Bearer ${token}`,
|
|
66572
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
66573
|
-
}
|
|
66631
|
+
headers: buildGitHubHeaders(token)
|
|
66574
66632
|
});
|
|
66575
66633
|
if (!response.ok) {
|
|
66634
|
+
if (isAuthRequired(response)) {
|
|
66635
|
+
return {
|
|
66636
|
+
authRequired: true,
|
|
66637
|
+
message: getGitHubErrorMessage(response)
|
|
66638
|
+
};
|
|
66639
|
+
}
|
|
66576
66640
|
if (response.status === 404) {
|
|
66577
66641
|
throw new Error(`Repository ${owner}/${repo} not found or branch '${branch}' doesn't exist`);
|
|
66578
66642
|
}
|
|
@@ -66677,24 +66741,23 @@ async function getRemoteSkillInfo(token, skillName, repos) {
|
|
|
66677
66741
|
try {
|
|
66678
66742
|
const apiPath = basePath ? `https://api.github.com/repos/${repo}/contents/${basePath}?ref=${branch}` : `https://api.github.com/repos/${repo}/contents?ref=${branch}`;
|
|
66679
66743
|
const response = await fetch(apiPath, {
|
|
66680
|
-
headers:
|
|
66681
|
-
Authorization: `Bearer ${token}`,
|
|
66682
|
-
Accept: "application/vnd.github+json",
|
|
66683
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
66684
|
-
}
|
|
66744
|
+
headers: buildGitHubHeaders(token)
|
|
66685
66745
|
});
|
|
66686
|
-
if (!response.ok)
|
|
66746
|
+
if (!response.ok) {
|
|
66747
|
+
if (isAuthRequired(response)) {
|
|
66748
|
+
return {
|
|
66749
|
+
authRequired: true,
|
|
66750
|
+
message: getGitHubErrorMessage(response)
|
|
66751
|
+
};
|
|
66752
|
+
}
|
|
66687
66753
|
continue;
|
|
66754
|
+
}
|
|
66688
66755
|
const contents = await response.json();
|
|
66689
66756
|
const dirs = contents.filter((item) => item.type === "dir" && item.name.toLowerCase() === skillName.toLowerCase());
|
|
66690
66757
|
for (const dir of dirs) {
|
|
66691
66758
|
const skillMdUrl = `https://api.github.com/repos/${repo}/contents/${dir.path}/SKILL.md?ref=${branch}`;
|
|
66692
66759
|
const skillResponse = await fetch(skillMdUrl, {
|
|
66693
|
-
headers:
|
|
66694
|
-
Authorization: `Bearer ${token}`,
|
|
66695
|
-
Accept: "application/vnd.github.raw+json",
|
|
66696
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
66697
|
-
}
|
|
66760
|
+
headers: buildGitHubRawHeaders(token)
|
|
66698
66761
|
});
|
|
66699
66762
|
if (skillResponse.ok) {
|
|
66700
66763
|
const content = await skillResponse.text();
|
|
@@ -66722,12 +66785,6 @@ function Info({ args: [skillName] }) {
|
|
|
66722
66785
|
const [state, setState] = import_react31.useState({ phase: "checking" });
|
|
66723
66786
|
import_react31.useEffect(() => {
|
|
66724
66787
|
async function loadInfo() {
|
|
66725
|
-
const credentials = await getCredentials();
|
|
66726
|
-
if (!credentials) {
|
|
66727
|
-
setState({ phase: "not_logged_in" });
|
|
66728
|
-
exit();
|
|
66729
|
-
return;
|
|
66730
|
-
}
|
|
66731
66788
|
setState({ phase: "loading" });
|
|
66732
66789
|
const config2 = getConfig();
|
|
66733
66790
|
const installedSkill = config2.installed.find((s) => s.name.toLowerCase() === skillName.toLowerCase());
|
|
@@ -66739,9 +66796,16 @@ function Info({ args: [skillName] }) {
|
|
|
66739
66796
|
return;
|
|
66740
66797
|
}
|
|
66741
66798
|
}
|
|
66742
|
-
const
|
|
66743
|
-
|
|
66744
|
-
|
|
66799
|
+
const credentials = await getCredentials();
|
|
66800
|
+
const token = credentials?.token;
|
|
66801
|
+
const remoteResult = await getRemoteSkillInfo(token, skillName, config2.repos);
|
|
66802
|
+
if (remoteResult && "authRequired" in remoteResult) {
|
|
66803
|
+
setState({ phase: "auth_required", message: remoteResult.message });
|
|
66804
|
+
exit();
|
|
66805
|
+
return;
|
|
66806
|
+
}
|
|
66807
|
+
if (remoteResult) {
|
|
66808
|
+
setState({ phase: "success", info: remoteResult });
|
|
66745
66809
|
} else {
|
|
66746
66810
|
setState({ phase: "not_found", skillName });
|
|
66747
66811
|
}
|
|
@@ -66760,20 +66824,14 @@ function Info({ args: [skillName] }) {
|
|
|
66760
66824
|
return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Spinner2, {
|
|
66761
66825
|
text: "Initializing..."
|
|
66762
66826
|
}, undefined, false, undefined, this);
|
|
66763
|
-
case "
|
|
66827
|
+
case "auth_required":
|
|
66764
66828
|
return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
|
|
66765
66829
|
flexDirection: "column",
|
|
66766
|
-
children:
|
|
66767
|
-
|
|
66768
|
-
|
|
66769
|
-
|
|
66770
|
-
|
|
66771
|
-
/* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
|
|
66772
|
-
dimColor: true,
|
|
66773
|
-
children: "Run 'skilluse login' to authenticate with GitHub"
|
|
66774
|
-
}, undefined, false, undefined, this)
|
|
66775
|
-
]
|
|
66776
|
-
}, undefined, true, undefined, this);
|
|
66830
|
+
children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(StatusMessage, {
|
|
66831
|
+
type: "error",
|
|
66832
|
+
children: state.message
|
|
66833
|
+
}, undefined, false, undefined, this)
|
|
66834
|
+
}, undefined, false, undefined, this);
|
|
66777
66835
|
case "loading":
|
|
66778
66836
|
return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Spinner2, {
|
|
66779
66837
|
text: `Loading info for "${skillName}"...`
|
|
@@ -67004,35 +67062,30 @@ async function findSkill(token, repos, skillName) {
|
|
|
67004
67062
|
try {
|
|
67005
67063
|
const apiPath = basePath ? `https://api.github.com/repos/${repo}/contents/${basePath}?ref=${branch}` : `https://api.github.com/repos/${repo}/contents?ref=${branch}`;
|
|
67006
67064
|
const response = await fetch(apiPath, {
|
|
67007
|
-
headers:
|
|
67008
|
-
Authorization: `Bearer ${token}`,
|
|
67009
|
-
Accept: "application/vnd.github+json",
|
|
67010
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
67011
|
-
}
|
|
67065
|
+
headers: buildGitHubHeaders(token)
|
|
67012
67066
|
});
|
|
67013
|
-
if (!response.ok)
|
|
67067
|
+
if (!response.ok) {
|
|
67068
|
+
if (isAuthRequired(response)) {
|
|
67069
|
+
return {
|
|
67070
|
+
authRequired: true,
|
|
67071
|
+
message: getGitHubErrorMessage(response)
|
|
67072
|
+
};
|
|
67073
|
+
}
|
|
67014
67074
|
continue;
|
|
67075
|
+
}
|
|
67015
67076
|
const contents = await response.json();
|
|
67016
67077
|
const dirs = contents.filter((item) => item.type === "dir" && item.name.toLowerCase() === skillName.toLowerCase());
|
|
67017
67078
|
for (const dir of dirs) {
|
|
67018
67079
|
const skillMdUrl = `https://api.github.com/repos/${repo}/contents/${dir.path}/SKILL.md?ref=${branch}`;
|
|
67019
67080
|
const skillResponse = await fetch(skillMdUrl, {
|
|
67020
|
-
headers:
|
|
67021
|
-
Authorization: `Bearer ${token}`,
|
|
67022
|
-
Accept: "application/vnd.github.raw+json",
|
|
67023
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
67024
|
-
}
|
|
67081
|
+
headers: buildGitHubRawHeaders(token)
|
|
67025
67082
|
});
|
|
67026
67083
|
if (skillResponse.ok) {
|
|
67027
67084
|
const content = await skillResponse.text();
|
|
67028
67085
|
const frontmatter = parseFrontmatter2(content);
|
|
67029
67086
|
const refUrl = `https://api.github.com/repos/${repo}/commits/${branch}`;
|
|
67030
67087
|
const refResponse = await fetch(refUrl, {
|
|
67031
|
-
headers:
|
|
67032
|
-
Authorization: `Bearer ${token}`,
|
|
67033
|
-
Accept: "application/vnd.github+json",
|
|
67034
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
67035
|
-
}
|
|
67088
|
+
headers: buildGitHubHeaders(token)
|
|
67036
67089
|
});
|
|
67037
67090
|
let commitSha = branch;
|
|
67038
67091
|
if (refResponse.ok) {
|
|
@@ -67056,18 +67109,20 @@ async function findSkill(token, repos, skillName) {
|
|
|
67056
67109
|
} catch {}
|
|
67057
67110
|
}
|
|
67058
67111
|
}
|
|
67059
|
-
return results;
|
|
67112
|
+
return { results };
|
|
67060
67113
|
}
|
|
67061
67114
|
async function downloadSkillFiles(token, repo, skillPath, branch, targetDir, onProgress) {
|
|
67062
67115
|
const treeUrl = `https://api.github.com/repos/${repo}/git/trees/${branch}?recursive=1`;
|
|
67063
67116
|
const treeResponse = await fetch(treeUrl, {
|
|
67064
|
-
headers:
|
|
67065
|
-
Authorization: `Bearer ${token}`,
|
|
67066
|
-
Accept: "application/vnd.github+json",
|
|
67067
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
67068
|
-
}
|
|
67117
|
+
headers: buildGitHubHeaders(token)
|
|
67069
67118
|
});
|
|
67070
67119
|
if (!treeResponse.ok) {
|
|
67120
|
+
if (isAuthRequired(treeResponse)) {
|
|
67121
|
+
return {
|
|
67122
|
+
authRequired: true,
|
|
67123
|
+
message: getGitHubErrorMessage(treeResponse)
|
|
67124
|
+
};
|
|
67125
|
+
}
|
|
67071
67126
|
throw new Error(`Failed to fetch repository tree: ${treeResponse.status}`);
|
|
67072
67127
|
}
|
|
67073
67128
|
const treeData = await treeResponse.json();
|
|
@@ -67086,13 +67141,15 @@ async function downloadSkillFiles(token, repo, skillPath, branch, targetDir, onP
|
|
|
67086
67141
|
}
|
|
67087
67142
|
const fileUrl = `https://api.github.com/repos/${repo}/contents/${file2.path}?ref=${branch}`;
|
|
67088
67143
|
const fileResponse = await fetch(fileUrl, {
|
|
67089
|
-
headers:
|
|
67090
|
-
Authorization: `Bearer ${token}`,
|
|
67091
|
-
Accept: "application/vnd.github.raw+json",
|
|
67092
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
67093
|
-
}
|
|
67144
|
+
headers: buildGitHubRawHeaders(token)
|
|
67094
67145
|
});
|
|
67095
67146
|
if (!fileResponse.ok) {
|
|
67147
|
+
if (isAuthRequired(fileResponse)) {
|
|
67148
|
+
return {
|
|
67149
|
+
authRequired: true,
|
|
67150
|
+
message: getGitHubErrorMessage(fileResponse)
|
|
67151
|
+
};
|
|
67152
|
+
}
|
|
67096
67153
|
throw new Error(`Failed to download file: ${file2.path}`);
|
|
67097
67154
|
}
|
|
67098
67155
|
const content = await fileResponse.text();
|
|
@@ -67109,13 +67166,15 @@ async function fetchGitHubSkill(token, owner, repo, path6, branch = "main") {
|
|
|
67109
67166
|
try {
|
|
67110
67167
|
const refUrl = `https://api.github.com/repos/${fullRepo}/commits/${branch}`;
|
|
67111
67168
|
const refResponse = await fetch(refUrl, {
|
|
67112
|
-
headers:
|
|
67113
|
-
Authorization: `Bearer ${token}`,
|
|
67114
|
-
Accept: "application/vnd.github+json",
|
|
67115
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
67116
|
-
}
|
|
67169
|
+
headers: buildGitHubHeaders(token)
|
|
67117
67170
|
});
|
|
67118
67171
|
if (!refResponse.ok) {
|
|
67172
|
+
if (isAuthRequired(refResponse)) {
|
|
67173
|
+
return {
|
|
67174
|
+
authRequired: true,
|
|
67175
|
+
message: getGitHubErrorMessage(refResponse)
|
|
67176
|
+
};
|
|
67177
|
+
}
|
|
67119
67178
|
return null;
|
|
67120
67179
|
}
|
|
67121
67180
|
const refData = await refResponse.json();
|
|
@@ -67123,13 +67182,15 @@ async function fetchGitHubSkill(token, owner, repo, path6, branch = "main") {
|
|
|
67123
67182
|
const skillMdPath = skillPath ? `${skillPath}/SKILL.md` : "SKILL.md";
|
|
67124
67183
|
const skillMdUrl = `https://api.github.com/repos/${fullRepo}/contents/${skillMdPath}?ref=${branch}`;
|
|
67125
67184
|
const skillResponse = await fetch(skillMdUrl, {
|
|
67126
|
-
headers:
|
|
67127
|
-
Authorization: `Bearer ${token}`,
|
|
67128
|
-
Accept: "application/vnd.github.raw+json",
|
|
67129
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
67130
|
-
}
|
|
67185
|
+
headers: buildGitHubRawHeaders(token)
|
|
67131
67186
|
});
|
|
67132
67187
|
if (!skillResponse.ok) {
|
|
67188
|
+
if (isAuthRequired(skillResponse)) {
|
|
67189
|
+
return {
|
|
67190
|
+
authRequired: true,
|
|
67191
|
+
message: getGitHubErrorMessage(skillResponse)
|
|
67192
|
+
};
|
|
67193
|
+
}
|
|
67133
67194
|
return null;
|
|
67134
67195
|
}
|
|
67135
67196
|
const content = await skillResponse.text();
|
|
@@ -67253,14 +67314,15 @@ function Install({ args: [skillName], options: opts }) {
|
|
|
67253
67314
|
}
|
|
67254
67315
|
}
|
|
67255
67316
|
const credentials = await getCredentials();
|
|
67256
|
-
|
|
67257
|
-
setState({ phase: "not_logged_in" });
|
|
67258
|
-
exit();
|
|
67259
|
-
return;
|
|
67260
|
-
}
|
|
67317
|
+
const token = credentials?.token;
|
|
67261
67318
|
if (source.type === "github") {
|
|
67262
67319
|
setState({ phase: "searching", repo: `${source.owner}/${source.repo}` });
|
|
67263
|
-
const result = await fetchGitHubSkill(
|
|
67320
|
+
const result = await fetchGitHubSkill(token, source.owner, source.repo, source.path);
|
|
67321
|
+
if (result && "authRequired" in result) {
|
|
67322
|
+
setState({ phase: "auth_required", message: result.message });
|
|
67323
|
+
exit();
|
|
67324
|
+
return;
|
|
67325
|
+
}
|
|
67264
67326
|
if (!result) {
|
|
67265
67327
|
setState({
|
|
67266
67328
|
phase: "not_found",
|
|
@@ -67290,7 +67352,7 @@ function Install({ args: [skillName], options: opts }) {
|
|
|
67290
67352
|
});
|
|
67291
67353
|
try {
|
|
67292
67354
|
const skillPath = source.path || "";
|
|
67293
|
-
await downloadSkillFiles(
|
|
67355
|
+
const downloadResult = await downloadSkillFiles(token, `${source.owner}/${source.repo}`, skillPath, "main", installPath2, (downloaded, total) => {
|
|
67294
67356
|
const downloadProgress = 25 + downloaded / total * 50;
|
|
67295
67357
|
setState((prev) => {
|
|
67296
67358
|
if (prev.phase !== "installing")
|
|
@@ -67298,6 +67360,11 @@ function Install({ args: [skillName], options: opts }) {
|
|
|
67298
67360
|
return { ...prev, progress: Math.round(downloadProgress) };
|
|
67299
67361
|
});
|
|
67300
67362
|
});
|
|
67363
|
+
if (downloadResult && "authRequired" in downloadResult) {
|
|
67364
|
+
setState({ phase: "auth_required", message: downloadResult.message });
|
|
67365
|
+
exit();
|
|
67366
|
+
return;
|
|
67367
|
+
}
|
|
67301
67368
|
steps2[1].status = "done";
|
|
67302
67369
|
steps2[2].status = "in_progress";
|
|
67303
67370
|
setState((prev) => {
|
|
@@ -67342,7 +67409,13 @@ function Install({ args: [skillName], options: opts }) {
|
|
|
67342
67409
|
for (const repo of allRepos) {
|
|
67343
67410
|
setState({ phase: "searching", repo: repo.repo });
|
|
67344
67411
|
}
|
|
67345
|
-
const
|
|
67412
|
+
const findResult = await findSkill(token, allRepos, source.name);
|
|
67413
|
+
if ("authRequired" in findResult) {
|
|
67414
|
+
setState({ phase: "auth_required", message: findResult.message });
|
|
67415
|
+
exit();
|
|
67416
|
+
return;
|
|
67417
|
+
}
|
|
67418
|
+
const { results } = findResult;
|
|
67346
67419
|
if (results.length === 0) {
|
|
67347
67420
|
setState({ phase: "not_found", skillName: source.name });
|
|
67348
67421
|
exit();
|
|
@@ -67382,7 +67455,7 @@ function Install({ args: [skillName], options: opts }) {
|
|
|
67382
67455
|
try {
|
|
67383
67456
|
const repoConfig = config2.repos.find((r) => r.repo === skill.repo);
|
|
67384
67457
|
const branch = repoConfig?.branch || "main";
|
|
67385
|
-
await downloadSkillFiles(
|
|
67458
|
+
const downloadResult = await downloadSkillFiles(token, skill.repo, skill.path, branch, installPath, (downloaded, total) => {
|
|
67386
67459
|
const downloadProgress = 25 + downloaded / total * 50;
|
|
67387
67460
|
setState((prev) => {
|
|
67388
67461
|
if (prev.phase !== "installing")
|
|
@@ -67390,6 +67463,11 @@ function Install({ args: [skillName], options: opts }) {
|
|
|
67390
67463
|
return { ...prev, progress: Math.round(downloadProgress) };
|
|
67391
67464
|
});
|
|
67392
67465
|
});
|
|
67466
|
+
if (downloadResult && "authRequired" in downloadResult) {
|
|
67467
|
+
setState({ phase: "auth_required", message: downloadResult.message });
|
|
67468
|
+
exit();
|
|
67469
|
+
return;
|
|
67470
|
+
}
|
|
67393
67471
|
steps[1].status = "done";
|
|
67394
67472
|
steps[2].status = "in_progress";
|
|
67395
67473
|
setState((prev) => {
|
|
@@ -67449,20 +67527,14 @@ function Install({ args: [skillName], options: opts }) {
|
|
|
67449
67527
|
return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Spinner2, {
|
|
67450
67528
|
text: "Initializing..."
|
|
67451
67529
|
}, undefined, false, undefined, this);
|
|
67452
|
-
case "
|
|
67530
|
+
case "auth_required":
|
|
67453
67531
|
return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
67454
67532
|
flexDirection: "column",
|
|
67455
|
-
children:
|
|
67456
|
-
|
|
67457
|
-
|
|
67458
|
-
|
|
67459
|
-
|
|
67460
|
-
/* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Text, {
|
|
67461
|
-
dimColor: true,
|
|
67462
|
-
children: "Run 'skilluse login' to authenticate with GitHub"
|
|
67463
|
-
}, undefined, false, undefined, this)
|
|
67464
|
-
]
|
|
67465
|
-
}, undefined, true, undefined, this);
|
|
67533
|
+
children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(StatusMessage, {
|
|
67534
|
+
type: "error",
|
|
67535
|
+
children: state.message
|
|
67536
|
+
}, undefined, false, undefined, this)
|
|
67537
|
+
}, undefined, false, undefined, this);
|
|
67466
67538
|
case "no_repos":
|
|
67467
67539
|
return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Box_default, {
|
|
67468
67540
|
flexDirection: "column",
|
|
@@ -67669,13 +67741,15 @@ async function checkForUpdate(token, skill, repoConfig) {
|
|
|
67669
67741
|
try {
|
|
67670
67742
|
const refUrl = `https://api.github.com/repos/${repo}/commits/${branch}`;
|
|
67671
67743
|
const refResponse = await fetch(refUrl, {
|
|
67672
|
-
headers:
|
|
67673
|
-
Authorization: `Bearer ${token}`,
|
|
67674
|
-
Accept: "application/vnd.github+json",
|
|
67675
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
67676
|
-
}
|
|
67744
|
+
headers: buildGitHubHeaders(token)
|
|
67677
67745
|
});
|
|
67678
67746
|
if (!refResponse.ok) {
|
|
67747
|
+
if (isAuthRequired(refResponse)) {
|
|
67748
|
+
return {
|
|
67749
|
+
authRequired: true,
|
|
67750
|
+
message: getGitHubErrorMessage(refResponse)
|
|
67751
|
+
};
|
|
67752
|
+
}
|
|
67679
67753
|
return { ...skill, hasUpdate: false };
|
|
67680
67754
|
}
|
|
67681
67755
|
const refData = await refResponse.json();
|
|
@@ -67685,11 +67759,7 @@ async function checkForUpdate(token, skill, repoConfig) {
|
|
|
67685
67759
|
}
|
|
67686
67760
|
const skillMdUrl = `https://api.github.com/repos/${repo}/contents/${skill.repoPath}/SKILL.md?ref=${branch}`;
|
|
67687
67761
|
const skillResponse = await fetch(skillMdUrl, {
|
|
67688
|
-
headers:
|
|
67689
|
-
Authorization: `Bearer ${token}`,
|
|
67690
|
-
Accept: "application/vnd.github.raw+json",
|
|
67691
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
67692
|
-
}
|
|
67762
|
+
headers: buildGitHubRawHeaders(token)
|
|
67693
67763
|
});
|
|
67694
67764
|
let latestVersion = skill.version;
|
|
67695
67765
|
if (skillResponse.ok) {
|
|
@@ -67712,14 +67782,9 @@ async function checkForUpdate(token, skill, repoConfig) {
|
|
|
67712
67782
|
function List({ options: opts }) {
|
|
67713
67783
|
const { exit } = use_app_default();
|
|
67714
67784
|
const [state, setState] = import_react33.useState({ phase: "checking" });
|
|
67785
|
+
const [outputItems, setOutputItems] = import_react33.useState([]);
|
|
67715
67786
|
import_react33.useEffect(() => {
|
|
67716
67787
|
async function loadSkills() {
|
|
67717
|
-
const credentials = await getCredentials();
|
|
67718
|
-
if (!credentials) {
|
|
67719
|
-
setState({ phase: "not_logged_in" });
|
|
67720
|
-
exit();
|
|
67721
|
-
return;
|
|
67722
|
-
}
|
|
67723
67788
|
const config2 = getConfig();
|
|
67724
67789
|
const currentAgent = getCurrentAgent();
|
|
67725
67790
|
const skills = opts.all ? config2.installed : config2.installed.filter((s) => s.agent === currentAgent || !s.agent);
|
|
@@ -67731,9 +67796,10 @@ function List({ options: opts }) {
|
|
|
67731
67796
|
currentAgent,
|
|
67732
67797
|
showingAll: opts.all
|
|
67733
67798
|
});
|
|
67734
|
-
exit();
|
|
67735
67799
|
return;
|
|
67736
67800
|
}
|
|
67801
|
+
const credentials = await getCredentials();
|
|
67802
|
+
const token = credentials?.token;
|
|
67737
67803
|
const skillsWithUpdates = [];
|
|
67738
67804
|
for (let i = 0;i < skills.length; i++) {
|
|
67739
67805
|
setState({
|
|
@@ -67744,9 +67810,16 @@ function List({ options: opts }) {
|
|
|
67744
67810
|
const skill = skills[i];
|
|
67745
67811
|
const repoConfig = config2.repos.find((r) => r.repo === skill.repo);
|
|
67746
67812
|
if (repoConfig) {
|
|
67747
|
-
const
|
|
67748
|
-
if (
|
|
67749
|
-
|
|
67813
|
+
const result = await checkForUpdate(token, skill, repoConfig);
|
|
67814
|
+
if ("authRequired" in result) {
|
|
67815
|
+
setState({
|
|
67816
|
+
phase: "auth_required",
|
|
67817
|
+
message: result.message
|
|
67818
|
+
});
|
|
67819
|
+
return;
|
|
67820
|
+
}
|
|
67821
|
+
if (result.hasUpdate) {
|
|
67822
|
+
skillsWithUpdates.push(result);
|
|
67750
67823
|
}
|
|
67751
67824
|
}
|
|
67752
67825
|
}
|
|
@@ -67757,48 +67830,44 @@ function List({ options: opts }) {
|
|
|
67757
67830
|
currentAgent,
|
|
67758
67831
|
showingAll: opts.all
|
|
67759
67832
|
});
|
|
67760
|
-
exit();
|
|
67761
67833
|
}
|
|
67762
67834
|
loadSkills();
|
|
67763
|
-
}, [opts.outdated, opts.all
|
|
67764
|
-
|
|
67765
|
-
|
|
67766
|
-
|
|
67767
|
-
|
|
67835
|
+
}, [opts.outdated, opts.all]);
|
|
67836
|
+
import_react33.useEffect(() => {
|
|
67837
|
+
const isFinalState = state.phase === "success" || state.phase === "error" || state.phase === "auth_required";
|
|
67838
|
+
if (isFinalState && outputItems.length === 0) {
|
|
67839
|
+
setOutputItems([{ id: "output" }]);
|
|
67840
|
+
}
|
|
67841
|
+
}, [state.phase, outputItems.length]);
|
|
67842
|
+
import_react33.useEffect(() => {
|
|
67843
|
+
if (outputItems.length > 0) {
|
|
67844
|
+
process.nextTick(() => exit());
|
|
67845
|
+
}
|
|
67846
|
+
}, [outputItems.length, exit]);
|
|
67847
|
+
const renderContent = () => {
|
|
67848
|
+
if (state.phase === "auth_required") {
|
|
67849
|
+
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(StatusMessage, {
|
|
67850
|
+
type: "error",
|
|
67851
|
+
children: state.message
|
|
67768
67852
|
}, undefined, false, undefined, this);
|
|
67769
|
-
|
|
67770
|
-
|
|
67771
|
-
|
|
67772
|
-
|
|
67773
|
-
|
|
67774
|
-
type: "error",
|
|
67775
|
-
children: "Not authenticated"
|
|
67776
|
-
}, undefined, false, undefined, this),
|
|
67777
|
-
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Text, {
|
|
67778
|
-
dimColor: true,
|
|
67779
|
-
children: "Run 'skilluse login' to authenticate with GitHub"
|
|
67780
|
-
}, undefined, false, undefined, this)
|
|
67781
|
-
]
|
|
67782
|
-
}, undefined, true, undefined, this);
|
|
67783
|
-
case "checking_updates":
|
|
67784
|
-
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Spinner2, {
|
|
67785
|
-
text: `Checking for updates (${state.current}/${state.total})...`
|
|
67853
|
+
}
|
|
67854
|
+
if (state.phase === "error") {
|
|
67855
|
+
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(StatusMessage, {
|
|
67856
|
+
type: "error",
|
|
67857
|
+
children: state.message
|
|
67786
67858
|
}, undefined, false, undefined, this);
|
|
67787
|
-
|
|
67859
|
+
}
|
|
67860
|
+
if (state.phase === "success") {
|
|
67788
67861
|
const agentInfo = getAgent(state.currentAgent);
|
|
67789
67862
|
const agentName = agentInfo?.name || state.currentAgent;
|
|
67790
67863
|
if (state.skills.length === 0) {
|
|
67791
67864
|
if (state.showingOutdated) {
|
|
67792
|
-
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(
|
|
67793
|
-
|
|
67794
|
-
children:
|
|
67795
|
-
type: "success",
|
|
67796
|
-
children: "All skills are up to date"
|
|
67797
|
-
}, undefined, false, undefined, this)
|
|
67865
|
+
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(StatusMessage, {
|
|
67866
|
+
type: "success",
|
|
67867
|
+
children: "All skills are up to date"
|
|
67798
67868
|
}, undefined, false, undefined, this);
|
|
67799
67869
|
}
|
|
67800
|
-
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(
|
|
67801
|
-
flexDirection: "column",
|
|
67870
|
+
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(jsx_dev_runtime10.Fragment, {
|
|
67802
67871
|
children: [
|
|
67803
67872
|
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
|
|
67804
67873
|
children: [
|
|
@@ -67840,8 +67909,7 @@ function List({ options: opts }) {
|
|
|
67840
67909
|
}, undefined, true, undefined, this);
|
|
67841
67910
|
}
|
|
67842
67911
|
if (state.showingOutdated) {
|
|
67843
|
-
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(
|
|
67844
|
-
flexDirection: "column",
|
|
67912
|
+
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(jsx_dev_runtime10.Fragment, {
|
|
67845
67913
|
children: [
|
|
67846
67914
|
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
|
|
67847
67915
|
children: [
|
|
@@ -67921,8 +67989,7 @@ function List({ options: opts }) {
|
|
|
67921
67989
|
]
|
|
67922
67990
|
}, undefined, true, undefined, this);
|
|
67923
67991
|
}
|
|
67924
|
-
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(
|
|
67925
|
-
flexDirection: "column",
|
|
67992
|
+
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(jsx_dev_runtime10.Fragment, {
|
|
67926
67993
|
children: [
|
|
67927
67994
|
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
|
|
67928
67995
|
children: [
|
|
@@ -68003,12 +68070,22 @@ function List({ options: opts }) {
|
|
|
68003
68070
|
]
|
|
68004
68071
|
}, undefined, true, undefined, this);
|
|
68005
68072
|
}
|
|
68006
|
-
|
|
68007
|
-
|
|
68008
|
-
|
|
68009
|
-
|
|
68010
|
-
|
|
68011
|
-
|
|
68073
|
+
return null;
|
|
68074
|
+
};
|
|
68075
|
+
return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(jsx_dev_runtime10.Fragment, {
|
|
68076
|
+
children: [
|
|
68077
|
+
(state.phase === "checking" || state.phase === "checking_updates") && /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Spinner2, {
|
|
68078
|
+
text: state.phase === "checking_updates" ? `Checking for updates (${state.current}/${state.total})...` : "Loading..."
|
|
68079
|
+
}, undefined, false, undefined, this),
|
|
68080
|
+
/* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Static, {
|
|
68081
|
+
items: outputItems,
|
|
68082
|
+
children: (item) => /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Box_default, {
|
|
68083
|
+
flexDirection: "column",
|
|
68084
|
+
children: renderContent()
|
|
68085
|
+
}, item.id, false, undefined, this)
|
|
68086
|
+
}, undefined, false, undefined, this)
|
|
68087
|
+
]
|
|
68088
|
+
}, undefined, true, undefined, this);
|
|
68012
68089
|
}
|
|
68013
68090
|
|
|
68014
68091
|
// src/commands/login.tsx
|
|
@@ -68331,12 +68408,6 @@ function RepoAdd({ args: [repoArg], options: opts }) {
|
|
|
68331
68408
|
const [state, setState] = import_react36.useState({ phase: "checking" });
|
|
68332
68409
|
import_react36.useEffect(() => {
|
|
68333
68410
|
async function checkAndAdd() {
|
|
68334
|
-
const credentials = await getCredentials();
|
|
68335
|
-
if (!credentials) {
|
|
68336
|
-
setState({ phase: "not_logged_in" });
|
|
68337
|
-
exit();
|
|
68338
|
-
return;
|
|
68339
|
-
}
|
|
68340
68411
|
if (!repoArg.match(/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/)) {
|
|
68341
68412
|
setState({ phase: "invalid_repo" });
|
|
68342
68413
|
exit();
|
|
@@ -68371,15 +68442,22 @@ function RepoAdd({ args: [repoArg], options: opts }) {
|
|
|
68371
68442
|
}
|
|
68372
68443
|
setState({ phase: "discovering", repo: repoArg });
|
|
68373
68444
|
try {
|
|
68445
|
+
const credentials = await getCredentials();
|
|
68446
|
+
const token = credentials?.token;
|
|
68374
68447
|
const [owner, repo] = repoArg.split("/");
|
|
68375
|
-
const
|
|
68376
|
-
if (
|
|
68448
|
+
const result = await discoverSkillPaths(owner, repo, opts.branch, token);
|
|
68449
|
+
if ("authRequired" in result) {
|
|
68450
|
+
setState({ phase: "auth_required", message: result.message });
|
|
68451
|
+
exit();
|
|
68452
|
+
return;
|
|
68453
|
+
}
|
|
68454
|
+
if (result.totalSkills === 0) {
|
|
68377
68455
|
setState({ phase: "no_skills_found", repo: repoArg });
|
|
68378
68456
|
} else {
|
|
68379
68457
|
setState({
|
|
68380
68458
|
phase: "select_paths",
|
|
68381
68459
|
repo: repoArg,
|
|
68382
|
-
discovery
|
|
68460
|
+
discovery: result
|
|
68383
68461
|
});
|
|
68384
68462
|
}
|
|
68385
68463
|
} catch (error46) {
|
|
@@ -68485,20 +68563,14 @@ function RepoAdd({ args: [repoArg], options: opts }) {
|
|
|
68485
68563
|
return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Spinner2, {
|
|
68486
68564
|
text: "Checking..."
|
|
68487
68565
|
}, undefined, false, undefined, this);
|
|
68488
|
-
case "
|
|
68566
|
+
case "auth_required":
|
|
68489
68567
|
return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
68490
68568
|
flexDirection: "column",
|
|
68491
|
-
children:
|
|
68492
|
-
|
|
68493
|
-
|
|
68494
|
-
|
|
68495
|
-
|
|
68496
|
-
/* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
68497
|
-
dimColor: true,
|
|
68498
|
-
children: "Run 'skilluse login' to authenticate with GitHub"
|
|
68499
|
-
}, undefined, false, undefined, this)
|
|
68500
|
-
]
|
|
68501
|
-
}, undefined, true, undefined, this);
|
|
68569
|
+
children: /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(StatusMessage, {
|
|
68570
|
+
type: "error",
|
|
68571
|
+
children: state.message
|
|
68572
|
+
}, undefined, false, undefined, this)
|
|
68573
|
+
}, undefined, false, undefined, this);
|
|
68502
68574
|
case "invalid_repo":
|
|
68503
68575
|
return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Box_default, {
|
|
68504
68576
|
flexDirection: "column",
|
|
@@ -68705,13 +68777,7 @@ function RepoEdit({ args: [repoArg], options: opts }) {
|
|
|
68705
68777
|
const { exit } = use_app_default();
|
|
68706
68778
|
const [state, setState] = import_react37.useState({ phase: "checking" });
|
|
68707
68779
|
import_react37.useEffect(() => {
|
|
68708
|
-
|
|
68709
|
-
const credentials = await getCredentials();
|
|
68710
|
-
if (!credentials) {
|
|
68711
|
-
setState({ phase: "not_logged_in" });
|
|
68712
|
-
exit();
|
|
68713
|
-
return;
|
|
68714
|
-
}
|
|
68780
|
+
function checkAndEdit() {
|
|
68715
68781
|
const config2 = getConfig();
|
|
68716
68782
|
const existingConfig = config2.repos.find((r) => r.repo === repoArg);
|
|
68717
68783
|
if (!existingConfig) {
|
|
@@ -68784,20 +68850,6 @@ function RepoEdit({ args: [repoArg], options: opts }) {
|
|
|
68784
68850
|
return /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Spinner2, {
|
|
68785
68851
|
text: "Checking..."
|
|
68786
68852
|
}, undefined, false, undefined, this);
|
|
68787
|
-
case "not_logged_in":
|
|
68788
|
-
return /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
68789
|
-
flexDirection: "column",
|
|
68790
|
-
children: [
|
|
68791
|
-
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(StatusMessage, {
|
|
68792
|
-
type: "error",
|
|
68793
|
-
children: "Not authenticated"
|
|
68794
|
-
}, undefined, false, undefined, this),
|
|
68795
|
-
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
68796
|
-
dimColor: true,
|
|
68797
|
-
children: "Run 'skilluse login' to authenticate with GitHub"
|
|
68798
|
-
}, undefined, false, undefined, this)
|
|
68799
|
-
]
|
|
68800
|
-
}, undefined, true, undefined, this);
|
|
68801
68853
|
case "not_found":
|
|
68802
68854
|
return /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
68803
68855
|
flexDirection: "column",
|
|
@@ -69071,71 +69123,58 @@ var options9 = exports_external.object({});
|
|
|
69071
69123
|
function RepoList(_props) {
|
|
69072
69124
|
const { exit } = use_app_default();
|
|
69073
69125
|
const [state, setState] = import_react39.useState({ phase: "checking" });
|
|
69126
|
+
const [outputItems, setOutputItems] = import_react39.useState([]);
|
|
69074
69127
|
import_react39.useEffect(() => {
|
|
69075
|
-
|
|
69076
|
-
|
|
69077
|
-
|
|
69078
|
-
|
|
69079
|
-
|
|
69080
|
-
|
|
69081
|
-
|
|
69082
|
-
|
|
69083
|
-
|
|
69084
|
-
|
|
69085
|
-
defaultRepo: config2.defaultRepo,
|
|
69086
|
-
repos: config2.repos
|
|
69087
|
-
});
|
|
69088
|
-
exit();
|
|
69128
|
+
const config2 = getConfig();
|
|
69129
|
+
setState({
|
|
69130
|
+
phase: "success",
|
|
69131
|
+
defaultRepo: config2.defaultRepo,
|
|
69132
|
+
repos: config2.repos
|
|
69133
|
+
});
|
|
69134
|
+
}, []);
|
|
69135
|
+
import_react39.useEffect(() => {
|
|
69136
|
+
if (state.phase !== "checking" && outputItems.length === 0) {
|
|
69137
|
+
setOutputItems([{ id: "output" }]);
|
|
69089
69138
|
}
|
|
69090
|
-
|
|
69091
|
-
|
|
69092
|
-
|
|
69093
|
-
|
|
69094
|
-
|
|
69095
|
-
|
|
69139
|
+
}, [state.phase, outputItems.length]);
|
|
69140
|
+
import_react39.useEffect(() => {
|
|
69141
|
+
if (outputItems.length > 0) {
|
|
69142
|
+
process.nextTick(() => exit());
|
|
69143
|
+
}
|
|
69144
|
+
}, [outputItems.length, exit]);
|
|
69145
|
+
const renderContent = () => {
|
|
69146
|
+
if (state.phase === "error") {
|
|
69147
|
+
return /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(StatusMessage, {
|
|
69148
|
+
type: "error",
|
|
69149
|
+
children: state.message
|
|
69096
69150
|
}, undefined, false, undefined, this);
|
|
69097
|
-
|
|
69098
|
-
|
|
69099
|
-
|
|
69151
|
+
}
|
|
69152
|
+
if (state.phase === "success" && state.repos.length === 0) {
|
|
69153
|
+
return /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(jsx_dev_runtime16.Fragment, {
|
|
69100
69154
|
children: [
|
|
69101
|
-
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(StatusMessage, {
|
|
69102
|
-
type: "error",
|
|
69103
|
-
children: "Not authenticated"
|
|
69104
|
-
}, undefined, false, undefined, this),
|
|
69105
69155
|
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
69106
|
-
|
|
69107
|
-
children: "
|
|
69156
|
+
bold: true,
|
|
69157
|
+
children: "Configured Repositories"
|
|
69158
|
+
}, undefined, false, undefined, this),
|
|
69159
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
69160
|
+
marginTop: 1,
|
|
69161
|
+
children: /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
69162
|
+
dimColor: true,
|
|
69163
|
+
children: "(no repositories configured)"
|
|
69164
|
+
}, undefined, false, undefined, this)
|
|
69165
|
+
}, undefined, false, undefined, this),
|
|
69166
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
69167
|
+
marginTop: 1,
|
|
69168
|
+
children: /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
69169
|
+
dimColor: true,
|
|
69170
|
+
children: "Run 'skilluse repo add owner/repo' to add one."
|
|
69171
|
+
}, undefined, false, undefined, this)
|
|
69108
69172
|
}, undefined, false, undefined, this)
|
|
69109
69173
|
]
|
|
69110
69174
|
}, undefined, true, undefined, this);
|
|
69111
|
-
|
|
69112
|
-
|
|
69113
|
-
|
|
69114
|
-
flexDirection: "column",
|
|
69115
|
-
children: [
|
|
69116
|
-
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
69117
|
-
bold: true,
|
|
69118
|
-
children: "Configured Repositories"
|
|
69119
|
-
}, undefined, false, undefined, this),
|
|
69120
|
-
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
69121
|
-
marginTop: 1,
|
|
69122
|
-
children: /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
69123
|
-
dimColor: true,
|
|
69124
|
-
children: "(no repositories configured)"
|
|
69125
|
-
}, undefined, false, undefined, this)
|
|
69126
|
-
}, undefined, false, undefined, this),
|
|
69127
|
-
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
69128
|
-
marginTop: 1,
|
|
69129
|
-
children: /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
69130
|
-
dimColor: true,
|
|
69131
|
-
children: "Run 'skilluse repo add owner/repo' to add one."
|
|
69132
|
-
}, undefined, false, undefined, this)
|
|
69133
|
-
}, undefined, false, undefined, this)
|
|
69134
|
-
]
|
|
69135
|
-
}, undefined, true, undefined, this);
|
|
69136
|
-
}
|
|
69137
|
-
return /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
69138
|
-
flexDirection: "column",
|
|
69175
|
+
}
|
|
69176
|
+
if (state.phase === "success") {
|
|
69177
|
+
return /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(jsx_dev_runtime16.Fragment, {
|
|
69139
69178
|
children: [
|
|
69140
69179
|
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
69141
69180
|
bold: true,
|
|
@@ -69185,12 +69224,23 @@ function RepoList(_props) {
|
|
|
69185
69224
|
})
|
|
69186
69225
|
]
|
|
69187
69226
|
}, undefined, true, undefined, this);
|
|
69188
|
-
|
|
69189
|
-
|
|
69190
|
-
|
|
69191
|
-
|
|
69192
|
-
|
|
69193
|
-
|
|
69227
|
+
}
|
|
69228
|
+
return null;
|
|
69229
|
+
};
|
|
69230
|
+
return /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(jsx_dev_runtime16.Fragment, {
|
|
69231
|
+
children: [
|
|
69232
|
+
state.phase === "checking" && /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Spinner2, {
|
|
69233
|
+
text: "Loading..."
|
|
69234
|
+
}, undefined, false, undefined, this),
|
|
69235
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Static, {
|
|
69236
|
+
items: outputItems,
|
|
69237
|
+
children: (item) => /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
69238
|
+
flexDirection: "column",
|
|
69239
|
+
children: renderContent()
|
|
69240
|
+
}, item.id, false, undefined, this)
|
|
69241
|
+
}, undefined, false, undefined, this)
|
|
69242
|
+
]
|
|
69243
|
+
}, undefined, true, undefined, this);
|
|
69194
69244
|
}
|
|
69195
69245
|
|
|
69196
69246
|
// src/commands/repo/remove.tsx
|
|
@@ -69206,13 +69256,7 @@ function RepoRemove({ args: [repoArg], options: opts }) {
|
|
|
69206
69256
|
const { exit } = use_app_default();
|
|
69207
69257
|
const [state, setState] = import_react40.useState({ phase: "checking" });
|
|
69208
69258
|
import_react40.useEffect(() => {
|
|
69209
|
-
|
|
69210
|
-
const credentials = await getCredentials();
|
|
69211
|
-
if (!credentials) {
|
|
69212
|
-
setState({ phase: "not_logged_in" });
|
|
69213
|
-
exit();
|
|
69214
|
-
return;
|
|
69215
|
-
}
|
|
69259
|
+
function checkAndRemove() {
|
|
69216
69260
|
const config2 = getConfig();
|
|
69217
69261
|
if (!config2.repos.find((r) => r.repo === repoArg)) {
|
|
69218
69262
|
setState({ phase: "not_found", repo: repoArg });
|
|
@@ -69249,20 +69293,6 @@ function RepoRemove({ args: [repoArg], options: opts }) {
|
|
|
69249
69293
|
return /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Spinner2, {
|
|
69250
69294
|
text: "Checking..."
|
|
69251
69295
|
}, undefined, false, undefined, this);
|
|
69252
|
-
case "not_logged_in":
|
|
69253
|
-
return /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
|
|
69254
|
-
flexDirection: "column",
|
|
69255
|
-
children: [
|
|
69256
|
-
/* @__PURE__ */ jsx_dev_runtime17.jsxDEV(StatusMessage, {
|
|
69257
|
-
type: "error",
|
|
69258
|
-
children: "Not authenticated"
|
|
69259
|
-
}, undefined, false, undefined, this),
|
|
69260
|
-
/* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Text, {
|
|
69261
|
-
dimColor: true,
|
|
69262
|
-
children: "Run 'skilluse login' to authenticate with GitHub"
|
|
69263
|
-
}, undefined, false, undefined, this)
|
|
69264
|
-
]
|
|
69265
|
-
}, undefined, true, undefined, this);
|
|
69266
69296
|
case "not_found":
|
|
69267
69297
|
return /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
|
|
69268
69298
|
flexDirection: "column",
|
|
@@ -69335,94 +69365,92 @@ var options11 = exports_external.object({});
|
|
|
69335
69365
|
function RepoUse({ args: [repoArg], options: _opts }) {
|
|
69336
69366
|
const { exit } = use_app_default();
|
|
69337
69367
|
const [state, setState] = import_react41.useState({ phase: "checking" });
|
|
69368
|
+
const [outputItems, setOutputItems] = import_react41.useState([]);
|
|
69338
69369
|
import_react41.useEffect(() => {
|
|
69339
|
-
|
|
69340
|
-
|
|
69341
|
-
|
|
69342
|
-
|
|
69343
|
-
exit();
|
|
69344
|
-
return;
|
|
69345
|
-
}
|
|
69346
|
-
const config2 = getConfig();
|
|
69347
|
-
if (!config2.repos.find((r) => r.repo === repoArg)) {
|
|
69348
|
-
setState({ phase: "not_found", repo: repoArg });
|
|
69349
|
-
exit();
|
|
69350
|
-
return;
|
|
69351
|
-
}
|
|
69352
|
-
if (config2.defaultRepo === repoArg) {
|
|
69353
|
-
setState({ phase: "already_default", repo: repoArg });
|
|
69354
|
-
exit();
|
|
69355
|
-
return;
|
|
69356
|
-
}
|
|
69357
|
-
setDefaultRepo(repoArg);
|
|
69358
|
-
setState({ phase: "success", repo: repoArg });
|
|
69359
|
-
exit();
|
|
69370
|
+
const config2 = getConfig();
|
|
69371
|
+
if (!config2.repos.find((r) => r.repo === repoArg)) {
|
|
69372
|
+
setState({ phase: "not_found", repo: repoArg });
|
|
69373
|
+
return;
|
|
69360
69374
|
}
|
|
69361
|
-
|
|
69362
|
-
|
|
69363
|
-
|
|
69364
|
-
|
|
69365
|
-
|
|
69375
|
+
if (config2.defaultRepo === repoArg) {
|
|
69376
|
+
setState({ phase: "already_default", repo: repoArg });
|
|
69377
|
+
return;
|
|
69378
|
+
}
|
|
69379
|
+
setDefaultRepo(repoArg);
|
|
69380
|
+
setState({ phase: "success", repo: repoArg });
|
|
69381
|
+
}, [repoArg]);
|
|
69382
|
+
import_react41.useEffect(() => {
|
|
69383
|
+
if (state.phase !== "checking" && outputItems.length === 0) {
|
|
69384
|
+
setOutputItems([{ id: "output" }]);
|
|
69385
|
+
}
|
|
69386
|
+
}, [state.phase, outputItems.length]);
|
|
69387
|
+
import_react41.useEffect(() => {
|
|
69388
|
+
if (outputItems.length > 0) {
|
|
69389
|
+
process.nextTick(() => exit());
|
|
69390
|
+
}
|
|
69391
|
+
}, [outputItems.length, exit]);
|
|
69392
|
+
const renderContent = () => {
|
|
69393
|
+
switch (state.phase) {
|
|
69394
|
+
case "not_found":
|
|
69395
|
+
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(jsx_dev_runtime18.Fragment, {
|
|
69396
|
+
children: [
|
|
69397
|
+
/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(StatusMessage, {
|
|
69398
|
+
type: "error",
|
|
69399
|
+
children: [
|
|
69400
|
+
"Repository ",
|
|
69401
|
+
state.repo,
|
|
69402
|
+
" not found in config"
|
|
69403
|
+
]
|
|
69404
|
+
}, undefined, true, undefined, this),
|
|
69405
|
+
/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Text, {
|
|
69406
|
+
dimColor: true,
|
|
69407
|
+
children: [
|
|
69408
|
+
"Run 'skilluse repo add ",
|
|
69409
|
+
state.repo,
|
|
69410
|
+
"' to add it first."
|
|
69411
|
+
]
|
|
69412
|
+
}, undefined, true, undefined, this)
|
|
69413
|
+
]
|
|
69414
|
+
}, undefined, true, undefined, this);
|
|
69415
|
+
case "already_default":
|
|
69416
|
+
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(StatusMessage, {
|
|
69417
|
+
type: "success",
|
|
69418
|
+
children: [
|
|
69419
|
+
state.repo,
|
|
69420
|
+
" is already the default"
|
|
69421
|
+
]
|
|
69422
|
+
}, undefined, true, undefined, this);
|
|
69423
|
+
case "success":
|
|
69424
|
+
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(StatusMessage, {
|
|
69425
|
+
type: "success",
|
|
69426
|
+
children: [
|
|
69427
|
+
"Default repo set to ",
|
|
69428
|
+
state.repo
|
|
69429
|
+
]
|
|
69430
|
+
}, undefined, true, undefined, this);
|
|
69431
|
+
case "error":
|
|
69432
|
+
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(StatusMessage, {
|
|
69433
|
+
type: "error",
|
|
69434
|
+
children: state.message
|
|
69435
|
+
}, undefined, false, undefined, this);
|
|
69436
|
+
default:
|
|
69437
|
+
return null;
|
|
69438
|
+
}
|
|
69439
|
+
};
|
|
69440
|
+
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(jsx_dev_runtime18.Fragment, {
|
|
69441
|
+
children: [
|
|
69442
|
+
state.phase === "checking" && /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Spinner2, {
|
|
69366
69443
|
text: "Setting default..."
|
|
69367
|
-
}, undefined, false, undefined, this)
|
|
69368
|
-
|
|
69369
|
-
|
|
69370
|
-
|
|
69371
|
-
|
|
69372
|
-
|
|
69373
|
-
|
|
69374
|
-
|
|
69375
|
-
|
|
69376
|
-
|
|
69377
|
-
dimColor: true,
|
|
69378
|
-
children: "Run 'skilluse login' to authenticate with GitHub"
|
|
69379
|
-
}, undefined, false, undefined, this)
|
|
69380
|
-
]
|
|
69381
|
-
}, undefined, true, undefined, this);
|
|
69382
|
-
case "not_found":
|
|
69383
|
-
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Box_default, {
|
|
69384
|
-
flexDirection: "column",
|
|
69385
|
-
children: [
|
|
69386
|
-
/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(StatusMessage, {
|
|
69387
|
-
type: "error",
|
|
69388
|
-
children: [
|
|
69389
|
-
"Repository ",
|
|
69390
|
-
state.repo,
|
|
69391
|
-
" not found in config"
|
|
69392
|
-
]
|
|
69393
|
-
}, undefined, true, undefined, this),
|
|
69394
|
-
/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Text, {
|
|
69395
|
-
dimColor: true,
|
|
69396
|
-
children: [
|
|
69397
|
-
"Run 'skilluse repo add ",
|
|
69398
|
-
state.repo,
|
|
69399
|
-
"' to add it first."
|
|
69400
|
-
]
|
|
69401
|
-
}, undefined, true, undefined, this)
|
|
69402
|
-
]
|
|
69403
|
-
}, undefined, true, undefined, this);
|
|
69404
|
-
case "already_default":
|
|
69405
|
-
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(StatusMessage, {
|
|
69406
|
-
type: "success",
|
|
69407
|
-
children: [
|
|
69408
|
-
state.repo,
|
|
69409
|
-
" is already the default"
|
|
69410
|
-
]
|
|
69411
|
-
}, undefined, true, undefined, this);
|
|
69412
|
-
case "success":
|
|
69413
|
-
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(StatusMessage, {
|
|
69414
|
-
type: "success",
|
|
69415
|
-
children: [
|
|
69416
|
-
"Default repo set to ",
|
|
69417
|
-
state.repo
|
|
69418
|
-
]
|
|
69419
|
-
}, undefined, true, undefined, this);
|
|
69420
|
-
case "error":
|
|
69421
|
-
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(StatusMessage, {
|
|
69422
|
-
type: "error",
|
|
69423
|
-
children: state.message
|
|
69424
|
-
}, undefined, false, undefined, this);
|
|
69425
|
-
}
|
|
69444
|
+
}, undefined, false, undefined, this),
|
|
69445
|
+
/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Static, {
|
|
69446
|
+
items: outputItems,
|
|
69447
|
+
children: (item) => /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Box_default, {
|
|
69448
|
+
flexDirection: "column",
|
|
69449
|
+
children: renderContent()
|
|
69450
|
+
}, item.id, false, undefined, this)
|
|
69451
|
+
}, undefined, false, undefined, this)
|
|
69452
|
+
]
|
|
69453
|
+
}, undefined, true, undefined, this);
|
|
69426
69454
|
}
|
|
69427
69455
|
|
|
69428
69456
|
// src/commands/agent/index.tsx
|
|
@@ -69633,13 +69661,15 @@ async function fetchSkillsFromRepo(token, repoConfig) {
|
|
|
69633
69661
|
try {
|
|
69634
69662
|
const apiPath = basePath ? `https://api.github.com/repos/${repo}/contents/${basePath}?ref=${branch}` : `https://api.github.com/repos/${repo}/contents?ref=${branch}`;
|
|
69635
69663
|
const response = await fetch(apiPath, {
|
|
69636
|
-
headers:
|
|
69637
|
-
Authorization: `Bearer ${token}`,
|
|
69638
|
-
Accept: "application/vnd.github+json",
|
|
69639
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
69640
|
-
}
|
|
69664
|
+
headers: buildGitHubHeaders(token)
|
|
69641
69665
|
});
|
|
69642
69666
|
if (!response.ok) {
|
|
69667
|
+
if (isAuthRequired(response)) {
|
|
69668
|
+
return {
|
|
69669
|
+
authRequired: true,
|
|
69670
|
+
message: getGitHubErrorMessage(response)
|
|
69671
|
+
};
|
|
69672
|
+
}
|
|
69643
69673
|
continue;
|
|
69644
69674
|
}
|
|
69645
69675
|
const contents = await response.json();
|
|
@@ -69647,11 +69677,7 @@ async function fetchSkillsFromRepo(token, repoConfig) {
|
|
|
69647
69677
|
for (const dir of dirs) {
|
|
69648
69678
|
const skillMdUrl = `https://api.github.com/repos/${repo}/contents/${dir.path}/SKILL.md?ref=${branch}`;
|
|
69649
69679
|
const skillResponse = await fetch(skillMdUrl, {
|
|
69650
|
-
headers:
|
|
69651
|
-
Authorization: `Bearer ${token}`,
|
|
69652
|
-
Accept: "application/vnd.github.raw+json",
|
|
69653
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
69654
|
-
}
|
|
69680
|
+
headers: buildGitHubRawHeaders(token)
|
|
69655
69681
|
});
|
|
69656
69682
|
if (skillResponse.ok) {
|
|
69657
69683
|
const content = await skillResponse.text();
|
|
@@ -69693,12 +69719,6 @@ function Search({ args: [keyword], options: opts }) {
|
|
|
69693
69719
|
const [state, setState] = import_react44.useState({ phase: "checking" });
|
|
69694
69720
|
import_react44.useEffect(() => {
|
|
69695
69721
|
async function search() {
|
|
69696
|
-
const credentials = await getCredentials();
|
|
69697
|
-
if (!credentials) {
|
|
69698
|
-
setState({ phase: "not_logged_in" });
|
|
69699
|
-
exit();
|
|
69700
|
-
return;
|
|
69701
|
-
}
|
|
69702
69722
|
const config2 = getConfig();
|
|
69703
69723
|
let reposToSearch = [];
|
|
69704
69724
|
if (opts.all) {
|
|
@@ -69716,11 +69736,18 @@ function Search({ args: [keyword], options: opts }) {
|
|
|
69716
69736
|
exit();
|
|
69717
69737
|
return;
|
|
69718
69738
|
}
|
|
69739
|
+
const credentials = await getCredentials();
|
|
69740
|
+
const token = credentials?.token;
|
|
69719
69741
|
const allSkills = [];
|
|
69720
69742
|
for (const repoConfig of reposToSearch) {
|
|
69721
69743
|
setState({ phase: "searching", repo: repoConfig.repo });
|
|
69722
|
-
const
|
|
69723
|
-
|
|
69744
|
+
const result = await fetchSkillsFromRepo(token, repoConfig);
|
|
69745
|
+
if ("authRequired" in result) {
|
|
69746
|
+
setState({ phase: "auth_required", message: result.message });
|
|
69747
|
+
exit();
|
|
69748
|
+
return;
|
|
69749
|
+
}
|
|
69750
|
+
allSkills.push(...result);
|
|
69724
69751
|
}
|
|
69725
69752
|
const matchingSkills = filterSkills(allSkills, keyword);
|
|
69726
69753
|
setState({ phase: "success", skills: matchingSkills, keyword });
|
|
@@ -69739,20 +69766,14 @@ function Search({ args: [keyword], options: opts }) {
|
|
|
69739
69766
|
return /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Spinner2, {
|
|
69740
69767
|
text: "Initializing..."
|
|
69741
69768
|
}, undefined, false, undefined, this);
|
|
69742
|
-
case "
|
|
69769
|
+
case "auth_required":
|
|
69743
69770
|
return /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Box_default, {
|
|
69744
69771
|
flexDirection: "column",
|
|
69745
|
-
children:
|
|
69746
|
-
|
|
69747
|
-
|
|
69748
|
-
|
|
69749
|
-
|
|
69750
|
-
/* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Text, {
|
|
69751
|
-
dimColor: true,
|
|
69752
|
-
children: "Run 'skilluse login' to authenticate with GitHub"
|
|
69753
|
-
}, undefined, false, undefined, this)
|
|
69754
|
-
]
|
|
69755
|
-
}, undefined, true, undefined, this);
|
|
69772
|
+
children: /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(StatusMessage, {
|
|
69773
|
+
type: "error",
|
|
69774
|
+
children: state.message
|
|
69775
|
+
}, undefined, false, undefined, this)
|
|
69776
|
+
}, undefined, false, undefined, this);
|
|
69756
69777
|
case "no_repos":
|
|
69757
69778
|
return /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Box_default, {
|
|
69758
69779
|
flexDirection: "column",
|
|
@@ -70104,14 +70125,17 @@ async function checkForUpdate2(token, skill, repoConfig) {
|
|
|
70104
70125
|
try {
|
|
70105
70126
|
const refUrl = `https://api.github.com/repos/${repo}/commits/${branch}`;
|
|
70106
70127
|
const refResponse = await fetch(refUrl, {
|
|
70107
|
-
headers:
|
|
70108
|
-
Authorization: `Bearer ${token}`,
|
|
70109
|
-
Accept: "application/vnd.github+json",
|
|
70110
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
70111
|
-
}
|
|
70128
|
+
headers: buildGitHubHeaders(token)
|
|
70112
70129
|
});
|
|
70113
|
-
if (!refResponse.ok)
|
|
70130
|
+
if (!refResponse.ok) {
|
|
70131
|
+
if (isAuthRequired(refResponse)) {
|
|
70132
|
+
return {
|
|
70133
|
+
authRequired: true,
|
|
70134
|
+
message: getGitHubErrorMessage(refResponse)
|
|
70135
|
+
};
|
|
70136
|
+
}
|
|
70114
70137
|
return null;
|
|
70138
|
+
}
|
|
70115
70139
|
const refData = await refResponse.json();
|
|
70116
70140
|
const latestSha = refData.sha;
|
|
70117
70141
|
if (latestSha === skill.commitSha) {
|
|
@@ -70119,11 +70143,7 @@ async function checkForUpdate2(token, skill, repoConfig) {
|
|
|
70119
70143
|
}
|
|
70120
70144
|
const skillMdUrl = `https://api.github.com/repos/${repo}/contents/${skill.repoPath}/SKILL.md?ref=${branch}`;
|
|
70121
70145
|
const skillResponse = await fetch(skillMdUrl, {
|
|
70122
|
-
headers:
|
|
70123
|
-
Authorization: `Bearer ${token}`,
|
|
70124
|
-
Accept: "application/vnd.github.raw+json",
|
|
70125
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
70126
|
-
}
|
|
70146
|
+
headers: buildGitHubRawHeaders(token)
|
|
70127
70147
|
});
|
|
70128
70148
|
let latestVersion = skill.version;
|
|
70129
70149
|
if (skillResponse.ok) {
|
|
@@ -70146,13 +70166,15 @@ async function checkForUpdate2(token, skill, repoConfig) {
|
|
|
70146
70166
|
async function downloadSkillFiles2(token, repo, skillPath, branch, targetDir) {
|
|
70147
70167
|
const treeUrl = `https://api.github.com/repos/${repo}/git/trees/${branch}?recursive=1`;
|
|
70148
70168
|
const treeResponse = await fetch(treeUrl, {
|
|
70149
|
-
headers:
|
|
70150
|
-
Authorization: `Bearer ${token}`,
|
|
70151
|
-
Accept: "application/vnd.github+json",
|
|
70152
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
70153
|
-
}
|
|
70169
|
+
headers: buildGitHubHeaders(token)
|
|
70154
70170
|
});
|
|
70155
70171
|
if (!treeResponse.ok) {
|
|
70172
|
+
if (isAuthRequired(treeResponse)) {
|
|
70173
|
+
return {
|
|
70174
|
+
authRequired: true,
|
|
70175
|
+
message: getGitHubErrorMessage(treeResponse)
|
|
70176
|
+
};
|
|
70177
|
+
}
|
|
70156
70178
|
throw new Error(`Failed to fetch repository tree: ${treeResponse.status}`);
|
|
70157
70179
|
}
|
|
70158
70180
|
const treeData = await treeResponse.json();
|
|
@@ -70171,13 +70193,15 @@ async function downloadSkillFiles2(token, repo, skillPath, branch, targetDir) {
|
|
|
70171
70193
|
}
|
|
70172
70194
|
const fileUrl = `https://api.github.com/repos/${repo}/contents/${file2.path}?ref=${branch}`;
|
|
70173
70195
|
const fileResponse = await fetch(fileUrl, {
|
|
70174
|
-
headers:
|
|
70175
|
-
Authorization: `Bearer ${token}`,
|
|
70176
|
-
Accept: "application/vnd.github.raw+json",
|
|
70177
|
-
"X-GitHub-Api-Version": "2022-11-28"
|
|
70178
|
-
}
|
|
70196
|
+
headers: buildGitHubRawHeaders(token)
|
|
70179
70197
|
});
|
|
70180
70198
|
if (!fileResponse.ok) {
|
|
70199
|
+
if (isAuthRequired(fileResponse)) {
|
|
70200
|
+
return {
|
|
70201
|
+
authRequired: true,
|
|
70202
|
+
message: getGitHubErrorMessage(fileResponse)
|
|
70203
|
+
};
|
|
70204
|
+
}
|
|
70181
70205
|
throw new Error(`Failed to download file: ${file2.path}`);
|
|
70182
70206
|
}
|
|
70183
70207
|
const content = await fileResponse.text();
|
|
@@ -70189,12 +70213,6 @@ function Upgrade({ args: [skillName] }) {
|
|
|
70189
70213
|
const [state, setState] = import_react46.useState({ phase: "checking" });
|
|
70190
70214
|
import_react46.useEffect(() => {
|
|
70191
70215
|
async function upgrade() {
|
|
70192
|
-
const credentials = await getCredentials();
|
|
70193
|
-
if (!credentials) {
|
|
70194
|
-
setState({ phase: "not_logged_in" });
|
|
70195
|
-
exit();
|
|
70196
|
-
return;
|
|
70197
|
-
}
|
|
70198
70216
|
const config2 = getConfig();
|
|
70199
70217
|
let skillsToCheck = [];
|
|
70200
70218
|
if (skillName) {
|
|
@@ -70213,6 +70231,8 @@ function Upgrade({ args: [skillName] }) {
|
|
|
70213
70231
|
exit();
|
|
70214
70232
|
return;
|
|
70215
70233
|
}
|
|
70234
|
+
const credentials = await getCredentials();
|
|
70235
|
+
const token = credentials?.token;
|
|
70216
70236
|
const upgrades = [];
|
|
70217
70237
|
for (let i = 0;i < skillsToCheck.length; i++) {
|
|
70218
70238
|
setState({
|
|
@@ -70224,9 +70244,14 @@ function Upgrade({ args: [skillName] }) {
|
|
|
70224
70244
|
const repoConfig = config2.repos.find((r) => r.repo === skill.repo);
|
|
70225
70245
|
if (!repoConfig)
|
|
70226
70246
|
continue;
|
|
70227
|
-
const
|
|
70228
|
-
if (
|
|
70229
|
-
|
|
70247
|
+
const result = await checkForUpdate2(token, skill, repoConfig);
|
|
70248
|
+
if (result && "authRequired" in result) {
|
|
70249
|
+
setState({ phase: "auth_required", message: result.message });
|
|
70250
|
+
exit();
|
|
70251
|
+
return;
|
|
70252
|
+
}
|
|
70253
|
+
if (result) {
|
|
70254
|
+
upgrades.push(result);
|
|
70230
70255
|
}
|
|
70231
70256
|
}
|
|
70232
70257
|
if (upgrades.length === 0) {
|
|
@@ -70247,7 +70272,15 @@ function Upgrade({ args: [skillName] }) {
|
|
|
70247
70272
|
const repoConfig = config2.repos.find((r) => r.repo === skill.repo);
|
|
70248
70273
|
if (!repoConfig)
|
|
70249
70274
|
continue;
|
|
70250
|
-
await downloadSkillFiles2(
|
|
70275
|
+
const downloadResult = await downloadSkillFiles2(token, skill.repo, skill.repoPath, repoConfig.branch, skill.installedPath);
|
|
70276
|
+
if (downloadResult && "authRequired" in downloadResult) {
|
|
70277
|
+
setState({
|
|
70278
|
+
phase: "auth_required",
|
|
70279
|
+
message: downloadResult.message
|
|
70280
|
+
});
|
|
70281
|
+
exit();
|
|
70282
|
+
return;
|
|
70283
|
+
}
|
|
70251
70284
|
const updatedSkill = {
|
|
70252
70285
|
...skill,
|
|
70253
70286
|
commitSha: latestSha,
|
|
@@ -70277,20 +70310,14 @@ function Upgrade({ args: [skillName] }) {
|
|
|
70277
70310
|
return /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Spinner2, {
|
|
70278
70311
|
text: "Initializing..."
|
|
70279
70312
|
}, undefined, false, undefined, this);
|
|
70280
|
-
case "
|
|
70313
|
+
case "auth_required":
|
|
70281
70314
|
return /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Box_default, {
|
|
70282
70315
|
flexDirection: "column",
|
|
70283
|
-
children:
|
|
70284
|
-
|
|
70285
|
-
|
|
70286
|
-
|
|
70287
|
-
|
|
70288
|
-
/* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Text, {
|
|
70289
|
-
dimColor: true,
|
|
70290
|
-
children: "Run 'skilluse login' to authenticate with GitHub"
|
|
70291
|
-
}, undefined, false, undefined, this)
|
|
70292
|
-
]
|
|
70293
|
-
}, undefined, true, undefined, this);
|
|
70316
|
+
children: /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(StatusMessage, {
|
|
70317
|
+
type: "error",
|
|
70318
|
+
children: state.message
|
|
70319
|
+
}, undefined, false, undefined, this)
|
|
70320
|
+
}, undefined, false, undefined, this);
|
|
70294
70321
|
case "not_found":
|
|
70295
70322
|
return /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Box_default, {
|
|
70296
70323
|
flexDirection: "column",
|
|
@@ -70409,7 +70436,7 @@ function Upgrade({ args: [skillName] }) {
|
|
|
70409
70436
|
// package.json
|
|
70410
70437
|
var package_default = {
|
|
70411
70438
|
name: "skilluse",
|
|
70412
|
-
version: "0.1
|
|
70439
|
+
version: "0.2.1",
|
|
70413
70440
|
description: "CLI tool for managing and installing AI Coding Agent Skills",
|
|
70414
70441
|
main: "dist/cli.js",
|
|
70415
70442
|
bin: {
|