@manturhub/cli 0.9.8 → 0.9.9
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/lib/skill-install.js
CHANGED
|
@@ -27,13 +27,18 @@ import {
|
|
|
27
27
|
skillDestination,
|
|
28
28
|
} from "./skill-state.js";
|
|
29
29
|
|
|
30
|
+
const CLI_SKILL_HEADERS = { "X-ManturHub-Client": "cli" };
|
|
31
|
+
|
|
30
32
|
function fail(message) {
|
|
31
33
|
console.error(message);
|
|
32
34
|
process.exit(1);
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
async function fetchOnlineSkills() {
|
|
36
|
-
const response = await apiFetch("/api/v1/skills", {
|
|
38
|
+
const response = await apiFetch("/api/v1/skills", {
|
|
39
|
+
auth: "optional",
|
|
40
|
+
headers: CLI_SKILL_HEADERS,
|
|
41
|
+
});
|
|
37
42
|
if (!response.ok) throw new Error(`Skill 列表获取失败(HTTP ${response.status})`);
|
|
38
43
|
return (response.json.skills || response.json || []).filter((item) => item.kind !== "suite");
|
|
39
44
|
}
|
|
@@ -41,6 +46,7 @@ async function fetchOnlineSkills() {
|
|
|
41
46
|
async function fetchSkillDetail(slug) {
|
|
42
47
|
const response = await apiFetch(`/api/v1/skills/${encodeURIComponent(slug)}`, {
|
|
43
48
|
auth: "optional",
|
|
49
|
+
headers: CLI_SKILL_HEADERS,
|
|
44
50
|
});
|
|
45
51
|
if (response.status === 404) {
|
|
46
52
|
throw new Error(`Skill 不存在: ${slug}(用 \`manturhub skill ls\` 看可用列表)`);
|
|
@@ -103,7 +109,7 @@ async function downloadSkillBundle(slug, target) {
|
|
|
103
109
|
}
|
|
104
110
|
const url = `${getBaseUrl()}/api/v1/skills/${encodeURIComponent(slug)}/download`;
|
|
105
111
|
const response = await fetch(url, {
|
|
106
|
-
headers: { "x-api-key": key },
|
|
112
|
+
headers: { "x-api-key": key, ...CLI_SKILL_HEADERS },
|
|
107
113
|
redirect: "manual",
|
|
108
114
|
signal: AbortSignal.timeout(30000),
|
|
109
115
|
});
|
|
@@ -19,7 +19,10 @@ try {
|
|
|
19
19
|
const url = new URL("/api/v1/skills", `${baseUrl}/`);
|
|
20
20
|
const response = await fetch(url, {
|
|
21
21
|
signal: AbortSignal.timeout(8000),
|
|
22
|
-
headers: {
|
|
22
|
+
headers: {
|
|
23
|
+
Accept: "application/json",
|
|
24
|
+
"X-ManturHub-Client": "cli",
|
|
25
|
+
},
|
|
23
26
|
});
|
|
24
27
|
mkdirSync(DIR, { recursive: true });
|
|
25
28
|
if (response.ok) {
|
package/lib/suite-install.js
CHANGED
|
@@ -6,6 +6,8 @@ import { extractZipSafely, validateSlug } from "./archive.js";
|
|
|
6
6
|
import { apiFetch } from "./api.js";
|
|
7
7
|
import { assertSecureDownloadUrl, downloadResponseToFile } from "./download.js";
|
|
8
8
|
|
|
9
|
+
const CLI_SKILL_HEADERS = { "X-ManturHub-Client": "cli" };
|
|
10
|
+
|
|
9
11
|
// #456 Agent 套件(团队版 Skill):与 skill 共用 /api/v1/skills 元数据与下载端点,
|
|
10
12
|
// 区别在安装形态——解压为当前目录下的工作目录(非用户级 skills)。API Key 继续由
|
|
11
13
|
// CLI 从 ~/.manturhub/config.json 读取,绝不复制进可能被提交的项目目录。
|
|
@@ -14,7 +16,10 @@ import { assertSecureDownloadUrl, downloadResponseToFile } from "./download.js";
|
|
|
14
16
|
export async function suiteLs({ json = false } = {}) {
|
|
15
17
|
let res;
|
|
16
18
|
try {
|
|
17
|
-
res = await apiFetch("/api/v1/skills", {
|
|
19
|
+
res = await apiFetch("/api/v1/skills", {
|
|
20
|
+
auth: "optional",
|
|
21
|
+
headers: CLI_SKILL_HEADERS,
|
|
22
|
+
});
|
|
18
23
|
} catch (e) {
|
|
19
24
|
console.error(`套件列表获取失败: ${e.message}`);
|
|
20
25
|
process.exit(1);
|
|
@@ -66,7 +71,7 @@ export async function suiteInstall(slug, dirArg) {
|
|
|
66
71
|
let res;
|
|
67
72
|
try {
|
|
68
73
|
res = await fetch(url, {
|
|
69
|
-
headers: { "x-api-key": key },
|
|
74
|
+
headers: { "x-api-key": key, ...CLI_SKILL_HEADERS },
|
|
70
75
|
redirect: "manual",
|
|
71
76
|
signal: AbortSignal.timeout(30000),
|
|
72
77
|
});
|