huaweicloud-devkit 1.0.2-dev.9 → 1.0.2-next.10

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.
Files changed (99) hide show
  1. package/.agents/plugins/marketplace.json +20 -20
  2. package/LICENSE +201 -201
  3. package/README.md +178 -138
  4. package/README.zh-CN.md +176 -138
  5. package/bin/setup.cjs +10 -8
  6. package/integrations/opencode/commands/huaweicloud-doctor.md +14 -14
  7. package/integrations/opencode/opencode.json +11 -14
  8. package/integrations/opencode/skills/huaweicloud-core/SKILL.md +32 -32
  9. package/package.json +60 -44
  10. package/plugins/huaweicloud-core/.claude-plugin/plugin.json +31 -44
  11. package/plugins/huaweicloud-core/.codex-plugin/plugin.json +30 -43
  12. package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +31 -44
  13. package/plugins/huaweicloud-core/.mcp.json +13 -15
  14. package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +31 -44
  15. package/plugins/huaweicloud-core/hooks/hooks.json +26 -26
  16. package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +136 -136
  17. package/plugins/huaweicloud-core/safety/policy.json +76 -100
  18. package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +227 -199
  19. package/plugins/huaweicloud-core/skills/huawei-apig/SKILL.md +164 -164
  20. package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +48 -48
  21. package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +50 -50
  22. package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +103 -101
  23. package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +90 -90
  24. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/SKILL.md +191 -190
  25. package/plugins/huaweicloud-core/skills/huawei-cloud-find-skills/scripts/search-skills.mjs +171 -124
  26. package/plugins/huaweicloud-core/skills/huawei-cts/SKILL.md +55 -55
  27. package/plugins/huaweicloud-core/skills/huawei-dds-dcs/SKILL.md +70 -70
  28. package/plugins/huaweicloud-core/skills/huawei-deployment/SKILL.md +57 -56
  29. package/plugins/huaweicloud-core/skills/huawei-dew/SKILL.md +106 -97
  30. package/plugins/huaweicloud-core/skills/huawei-dew/references/csms-usage.md +36 -29
  31. package/plugins/huaweicloud-core/skills/huawei-dew/references/kms-usage.md +29 -23
  32. package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +188 -185
  33. package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +144 -133
  34. package/plugins/huaweicloud-core/skills/huawei-ecs/references/evs.md +31 -31
  35. package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +57 -55
  36. package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +52 -52
  37. package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +132 -131
  38. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +60 -58
  39. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +72 -71
  40. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/deploy-workflow.md +119 -119
  41. package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +142 -142
  42. package/plugins/huaweicloud-core/skills/huawei-gaussdb/SKILL.md +56 -56
  43. package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +69 -65
  44. package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +111 -111
  45. package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +148 -122
  46. package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +56 -56
  47. package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +65 -65
  48. package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +134 -127
  49. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +49 -49
  50. package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +31 -26
  51. package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +101 -100
  52. package/plugins/huaweicloud-core/skills/huawei-obs/references/single-file-share.md +40 -40
  53. package/plugins/huaweicloud-core/skills/huawei-obs/references/static-website.md +56 -56
  54. package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +229 -224
  55. package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +173 -134
  56. package/plugins/huaweicloud-core/skills/huawei-smn-dms/SKILL.md +69 -69
  57. package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +84 -84
  58. package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +77 -76
  59. package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +60 -59
  60. package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +50 -50
  61. package/plugins/huaweicloud-core/skills/huawei-waf-aad/SKILL.md +63 -63
  62. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +56 -56
  63. package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/agents/openai.yaml +4 -4
  64. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +56 -47
  65. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/agents/openai.yaml +4 -4
  66. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +138 -128
  67. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/agents/openai.yaml +4 -4
  68. package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +111 -96
  69. package/plugins/huaweicloud-core/skills/huaweicloud-core/agents/openai.yaml +4 -4
  70. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +20 -20
  71. package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +30 -28
  72. package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +59 -60
  73. package/plugins/huaweicloud-core/skills/huaweicloud-safety/agents/openai.yaml +4 -4
  74. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +83 -83
  75. package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/agents/openai.yaml +4 -4
  76. package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +54 -1
  77. package/plugins/huaweicloud-core/src/auth/credentials.mjs +103 -95
  78. package/plugins/huaweicloud-core/src/auth/service.mjs +63 -63
  79. package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +3517 -0
  80. package/plugins/huaweicloud-core/src/hcloud-cli.mjs +283 -265
  81. package/plugins/huaweicloud-core/src/icon-library.mjs +171 -0
  82. package/plugins/huaweicloud-core/src/mcp-server.mjs +130 -129
  83. package/plugins/huaweicloud-core/src/proxy/proxy-agent.mjs +68 -0
  84. package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +94 -0
  85. package/plugins/huaweicloud-core/src/risk-rule-engine.mjs +140 -137
  86. package/plugins/huaweicloud-core/src/safety-policy.mjs +356 -302
  87. package/plugins/huaweicloud-core/src/sandbox/hdkitservice-api.mjs +86 -87
  88. package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +150 -153
  89. package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +196 -105
  90. package/plugins/huaweicloud-core/src/search-market.mjs +208 -169
  91. package/plugins/huaweicloud-core/src/setup-cli.mjs +2622 -1594
  92. package/plugins/huaweicloud-core/src/tools.mjs +463 -111
  93. package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.js +447 -427
  94. package/plugins/huaweicloud-core/src/ws-exec/hwlink-fair-queue.js +128 -132
  95. package/plugins/huaweicloud-core/src/ws-exec/hwlink-multiplexer.js +215 -227
  96. package/plugins/huaweicloud-core/src/ws-exec/hwlink-packet.js +189 -202
  97. package/plugins/huaweicloud-core/src/ws-exec/hwlink-terminal-channel.js +164 -158
  98. package/plugins/huaweicloud-core/src/ws-exec/index.js +19 -19
  99. package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.js +338 -338
@@ -1,169 +1,208 @@
1
- const INDEX_URL = 'https://gitcode.com/api/v5/repos/2501_91318609/skills-for-index/contents/skills-index/index.json?ref=main';
2
- const CN_EN_MAP_URL = 'https://gitcode.com/api/v5/repos/2501_91318609/skills-for-index/contents/skills-index/cn-en-map.json?ref=main';
3
- const HTTP_TIMEOUT_MS = 10000;
4
-
5
- const GENERIC_KEYWORDS = new Set([
6
- '华为云', 'huawei', 'huawei cloud', '云', 'cloud',
7
- '技能', 'skill', 'skills', '所有', 'all', '全部',
8
- '有什么', '有哪些', '相关', '列表', 'list',
9
- '查找', '搜索', '发现', '浏览', 'find', 'search',
10
- 'discover', 'browse', 'show', 'explore',
11
- 'agent', '市场', 'market', '类目', 'category',
12
- '安装', 'install',
13
- ]);
14
-
15
- let cachedIndex = null;
16
- let cachedCnEnMap = null;
17
-
18
- async function fetchJson(url, label = '') {
19
- const controller = new AbortController();
20
- const timer = setTimeout(() => controller.abort(), HTTP_TIMEOUT_MS);
21
- try {
22
- const resp = await fetch(url, {
23
- headers: { 'User-Agent': 'huaweicloud-devkit/1.0' },
24
- signal: controller.signal,
25
- });
26
- const data = await resp.json();
27
- if (data && data.encoding === 'base64' && data.content) {
28
- const decoded = Buffer.from(data.content, 'base64').toString('utf8');
29
- return JSON.parse(decoded);
30
- }
31
- return data;
32
- } catch (e) {
33
- throw new Error(`Failed to fetch ${label}: ${e.message}`);
34
- } finally {
35
- clearTimeout(timer);
36
- }
37
- }
38
-
39
- async function loadIndex() {
40
- if (!cachedIndex) cachedIndex = await fetchJson(INDEX_URL, 'index.json');
41
- return cachedIndex;
42
- }
43
-
44
- async function loadCnEnMap() {
45
- if (!cachedCnEnMap) cachedCnEnMap = await fetchJson(CN_EN_MAP_URL, 'cn-en-map.json');
46
- return cachedCnEnMap;
47
- }
48
-
49
- export function clearMarketCache() {
50
- cachedIndex = null;
51
- cachedCnEnMap = null;
52
- }
53
-
54
- function isGeneric(kw) {
55
- const k = kw.toLowerCase().trim();
56
- return GENERIC_KEYWORDS.has(k) || /华为云|huawei/i.test(k);
57
- }
58
-
59
- function expandKeywords(rawKeyword, cnEnMap) {
60
- if (!rawKeyword) return [[], []];
61
- const parts = rawKeyword.replace(/[,;]/g, ' ').split(/\s+/).filter(Boolean);
62
- const expanded = [...parts];
63
- for (const p of parts) {
64
- const lower = p.toLowerCase();
65
- if (cnEnMap[p]) expanded.push(cnEnMap[p]);
66
- for (const [cn, en] of Object.entries(cnEnMap)) {
67
- if (en === lower) expanded.push(cn);
68
- }
69
- }
70
- const unique = [...new Set(expanded)].sort();
71
- const specific = unique.filter((kw) => !isGeneric(kw));
72
- const generic = unique.filter((kw) => isGeneric(kw));
73
- return [specific, generic];
74
- }
75
-
76
- function scoreSkill(skill, specificKws, genericKws) {
77
- if (!specificKws.length && !genericKws.length) return [1, []];
78
- let total = 0;
79
- const matched = [];
80
- const nameLower = (skill.name || '').toLowerCase();
81
- const descLower = (skill.description || '').toLowerCase();
82
- const serviceLower = (skill.service || '').toLowerCase();
83
- const triggers = (skill.triggers || []).map((t) => (t || '').toLowerCase());
84
-
85
- for (const kw of specificKws) {
86
- const k = kw.toLowerCase();
87
- let s = 0;
88
- if (nameLower.includes(k)) s += 10;
89
- else if (triggers.some((t) => t.includes(k))) s += 8;
90
- else if (descLower.includes(k)) s += 5;
91
- else if (serviceLower.includes(k)) s += 3;
92
- if (s > 0) { total += s; matched.push(kw); }
93
- }
94
- for (const kw of genericKws) {
95
- const k = kw.toLowerCase();
96
- let s = 0;
97
- if (nameLower.includes(k)) s += 10;
98
- else if (triggers.some((t) => t.includes(k))) s += 4;
99
- else if (descLower.includes(k)) s += 2;
100
- else if (serviceLower.includes(k)) s += 1;
101
- if (s > 0) { total += s; matched.push(kw); }
102
- }
103
- if (!specificKws.length && total === 0) {
104
- total = 1;
105
- if (descLower.length > 20) total += 1;
106
- if (triggers.length) total += 1;
107
- }
108
- return [total, matched];
109
- }
110
-
111
- function truncate(desc, limit = 150) {
112
- if (!desc) return '';
113
- return desc.length > limit ? desc.slice(0, limit) + '...' : desc;
114
- }
115
-
116
- export async function searchMarketplace(query = '', category = '') {
117
- const idx = await loadIndex();
118
- const cnEnMap = await loadCnEnMap();
119
- const [specificKws, genericKws] = expandKeywords(query, cnEnMap);
120
- const hasSpecific = specificKws.length > 0;
121
-
122
- const results = [];
123
- for (const skill of idx.skills || []) {
124
- if (category && skill.category !== category) continue;
125
- const [score, matched] = scoreSkill(skill, specificKws, genericKws);
126
- if (hasSpecific && score === 0) continue;
127
- results.push({
128
- score,
129
- name: skill.name || '',
130
- category: skill.category || '',
131
- service: skill.service || '',
132
- description: truncate(skill.description),
133
- triggers: (skill.triggers || []).slice(0, 5),
134
- matched,
135
- });
136
- }
137
- results.sort((a, b) => b.score - a.score);
138
-
139
- if (!results.length) {
140
- return {
141
- ok: true,
142
- query,
143
- category,
144
- count: 0,
145
- results: [],
146
- fallback: [
147
- 'Try broader or alternative keywords',
148
- 'Remove category filter',
149
- 'Switch CN<->EN (e.g., obs <-> object storage)',
150
- 'List all: search with empty keyword and a category',
151
- ],
152
- };
153
- }
154
-
155
- const allKws = [...new Set([...specificKws, ...genericKws])];
156
- return {
157
- ok: true,
158
- query,
159
- category,
160
- count: results.length,
161
- expandedKeywords: allKws.length > 1 ? allKws : undefined,
162
- results,
163
- };
164
- }
165
-
166
- export async function getMarketplaceCategories() {
167
- const idx = await loadIndex();
168
- return { ok: true, categories: idx.categories || [] };
169
- }
1
+ import { getProxyDispatcher } from './proxy/proxy-agent.mjs';
2
+
3
+ const INDEX_URL =
4
+ 'https://gitcode.com/api/v5/repos/2501_91318609/skills-for-index/contents/skills-index/index.json?ref=main';
5
+ const CN_EN_MAP_URL =
6
+ 'https://gitcode.com/api/v5/repos/2501_91318609/skills-for-index/contents/skills-index/cn-en-map.json?ref=main';
7
+ const HTTP_TIMEOUT_MS = 10000;
8
+
9
+ const GENERIC_KEYWORDS = new Set([
10
+ '华为云',
11
+ 'huawei',
12
+ 'huawei cloud',
13
+ '云',
14
+ 'cloud',
15
+ '技能',
16
+ 'skill',
17
+ 'skills',
18
+ '所有',
19
+ 'all',
20
+ '全部',
21
+ '有什么',
22
+ '有哪些',
23
+ '相关',
24
+ '列表',
25
+ 'list',
26
+ '查找',
27
+ '搜索',
28
+ '发现',
29
+ '浏览',
30
+ 'find',
31
+ 'search',
32
+ 'discover',
33
+ 'browse',
34
+ 'show',
35
+ 'explore',
36
+ 'agent',
37
+ '市场',
38
+ 'market',
39
+ '类目',
40
+ 'category',
41
+ '安装',
42
+ 'install',
43
+ ]);
44
+
45
+ let cachedIndex = null;
46
+ let cachedCnEnMap = null;
47
+
48
+ async function fetchJson(url, label = '') {
49
+ const controller = new AbortController();
50
+ const timer = setTimeout(() => controller.abort(), HTTP_TIMEOUT_MS);
51
+ try {
52
+ const dispatcher = await getProxyDispatcher(url);
53
+ const fetchOpts = {
54
+ headers: { 'User-Agent': 'huaweicloud-devkit/1.0' },
55
+ signal: controller.signal,
56
+ };
57
+ if (dispatcher) fetchOpts.dispatcher = dispatcher;
58
+ const resp = await fetch(url, fetchOpts);
59
+ const data = await resp.json();
60
+ if (data && data.encoding === 'base64' && data.content) {
61
+ const decoded = Buffer.from(data.content, 'base64').toString('utf8');
62
+ return JSON.parse(decoded);
63
+ }
64
+ return data;
65
+ } catch (e) {
66
+ throw new Error(`Failed to fetch ${label}: ${e.message}`, { cause: e });
67
+ } finally {
68
+ clearTimeout(timer);
69
+ }
70
+ }
71
+
72
+ async function loadIndex() {
73
+ if (!cachedIndex) cachedIndex = await fetchJson(INDEX_URL, 'index.json');
74
+ return cachedIndex;
75
+ }
76
+
77
+ async function loadCnEnMap() {
78
+ if (!cachedCnEnMap) cachedCnEnMap = await fetchJson(CN_EN_MAP_URL, 'cn-en-map.json');
79
+ return cachedCnEnMap;
80
+ }
81
+
82
+ export function clearMarketCache() {
83
+ cachedIndex = null;
84
+ cachedCnEnMap = null;
85
+ }
86
+
87
+ function isGeneric(kw) {
88
+ const k = kw.toLowerCase().trim();
89
+ return GENERIC_KEYWORDS.has(k) || /华为云|huawei/i.test(k);
90
+ }
91
+
92
+ function expandKeywords(rawKeyword, cnEnMap) {
93
+ if (!rawKeyword) return [[], []];
94
+ const parts = rawKeyword.replace(/[,;]/g, ' ').split(/\s+/).filter(Boolean);
95
+ const expanded = [...parts];
96
+ for (const p of parts) {
97
+ const lower = p.toLowerCase();
98
+ if (cnEnMap[p]) expanded.push(cnEnMap[p]);
99
+ for (const [cn, en] of Object.entries(cnEnMap)) {
100
+ if (en === lower) expanded.push(cn);
101
+ }
102
+ }
103
+ const unique = [...new Set(expanded)].sort();
104
+ const specific = unique.filter((kw) => !isGeneric(kw));
105
+ const generic = unique.filter((kw) => isGeneric(kw));
106
+ return [specific, generic];
107
+ }
108
+
109
+ function scoreSkill(skill, specificKws, genericKws) {
110
+ if (!specificKws.length && !genericKws.length) return [1, []];
111
+ let total = 0;
112
+ const matched = [];
113
+ const nameLower = (skill.name || '').toLowerCase();
114
+ const descLower = (skill.description || '').toLowerCase();
115
+ const serviceLower = (skill.service || '').toLowerCase();
116
+ const triggers = (skill.triggers || []).map((t) => (t || '').toLowerCase());
117
+
118
+ for (const kw of specificKws) {
119
+ const k = kw.toLowerCase();
120
+ let s = 0;
121
+ if (nameLower.includes(k)) s += 10;
122
+ else if (triggers.some((t) => t.includes(k))) s += 8;
123
+ else if (descLower.includes(k)) s += 5;
124
+ else if (serviceLower.includes(k)) s += 3;
125
+ if (s > 0) {
126
+ total += s;
127
+ matched.push(kw);
128
+ }
129
+ }
130
+ for (const kw of genericKws) {
131
+ const k = kw.toLowerCase();
132
+ let s = 0;
133
+ if (nameLower.includes(k)) s += 10;
134
+ else if (triggers.some((t) => t.includes(k))) s += 4;
135
+ else if (descLower.includes(k)) s += 2;
136
+ else if (serviceLower.includes(k)) s += 1;
137
+ if (s > 0) {
138
+ total += s;
139
+ matched.push(kw);
140
+ }
141
+ }
142
+ if (!specificKws.length && total === 0) {
143
+ total = 1;
144
+ if (descLower.length > 20) total += 1;
145
+ if (triggers.length) total += 1;
146
+ }
147
+ return [total, matched];
148
+ }
149
+
150
+ function truncate(desc, limit = 150) {
151
+ if (!desc) return '';
152
+ return desc.length > limit ? desc.slice(0, limit) + '...' : desc;
153
+ }
154
+
155
+ export async function searchMarketplace(query = '', category = '') {
156
+ const idx = await loadIndex();
157
+ const cnEnMap = await loadCnEnMap();
158
+ const [specificKws, genericKws] = expandKeywords(query, cnEnMap);
159
+ const hasSpecific = specificKws.length > 0;
160
+
161
+ const results = [];
162
+ for (const skill of idx.skills || []) {
163
+ if (category && skill.category !== category) continue;
164
+ const [score, matched] = scoreSkill(skill, specificKws, genericKws);
165
+ if (hasSpecific && score === 0) continue;
166
+ results.push({
167
+ score,
168
+ name: skill.name || '',
169
+ category: skill.category || '',
170
+ service: skill.service || '',
171
+ description: truncate(skill.description),
172
+ triggers: (skill.triggers || []).slice(0, 5),
173
+ matched,
174
+ });
175
+ }
176
+ results.sort((a, b) => b.score - a.score);
177
+
178
+ if (!results.length) {
179
+ return {
180
+ ok: true,
181
+ query,
182
+ category,
183
+ count: 0,
184
+ results: [],
185
+ fallback: [
186
+ 'Try broader or alternative keywords',
187
+ 'Remove category filter',
188
+ 'Switch CN<->EN (e.g., obs <-> object storage)',
189
+ 'List all: search with empty keyword and a category',
190
+ ],
191
+ };
192
+ }
193
+
194
+ const allKws = [...new Set([...specificKws, ...genericKws])];
195
+ return {
196
+ ok: true,
197
+ query,
198
+ category,
199
+ count: results.length,
200
+ expandedKeywords: allKws.length > 1 ? allKws : undefined,
201
+ results,
202
+ };
203
+ }
204
+
205
+ export async function getMarketplaceCategories() {
206
+ const idx = await loadIndex();
207
+ return { ok: true, categories: idx.categories || [] };
208
+ }