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,95 +1,103 @@
1
- import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
2
- import { dirname, join } from 'node:path';
3
- import { homedir } from 'node:os';
4
-
5
- // Verify a credential file ended up with 0600. On Windows-mounted drives inside WSL
6
- // (drvfs/9p) chmod is silently ignored, so the file can be world-readable (0777).
7
- // Native Windows has no POSIX modes (statSync always reports 0666), so skip the check there.
8
- function ensurePrivateMode(path) {
9
- if (process.platform === 'win32') return;
10
- try { chmodSync(path, 0o600); } catch {}
11
- try {
12
- const mode = statSync(path).mode & 0o777;
13
- if (mode !== 0o600) {
14
- console.warn(`\x1b[33m[WARN]\x1b[0m Could not set 0600 on ${path} (current mode ${mode.toString(8)}). Credentials may be readable by other users.`);
15
- console.warn(`\x1b[33m If running under WSL, move the credential home to the Linux filesystem:\x1b[0m`);
16
- console.warn(`\x1b[33m export HUAWEICLOUD_HOME=$HOME (then re-run auth init)\x1b[0m`);
17
- console.warn(`\x1b[33m Or skip file storage entirely with HW_ACCESS_KEY/HW_SECRET_KEY environment variables.\x1b[0m`);
18
- }
19
- } catch {}
20
- }
21
-
22
- function baseHome() {
23
- return process.env.HUAWEICLOUD_HOME || homedir();
24
- }
25
-
26
- export function globalCredentialsPath() {
27
- return join(baseHome(), '.config', 'huaweicloud', 'credentials.json');
28
- }
29
-
30
- export function obsConfigPath() {
31
- return join(baseHome(), '.obsutilconfig');
32
- }
33
-
34
- export function readGlobalCredentials() {
35
- const path = globalCredentialsPath();
36
- if (!existsSync(path)) return null;
37
- try {
38
- return JSON.parse(readFileSync(path, 'utf8'));
39
- } catch {
40
- return null;
41
- }
42
- }
43
-
44
- export function writeGlobalCredentials(credentials = {}) {
45
- const path = globalCredentialsPath();
46
- mkdirSync(dirname(path), { recursive: true });
47
- const payload = {
48
- ak: String(credentials.ak || ''),
49
- sk: String(credentials.sk || ''),
50
- securityToken: String(credentials.securityToken || ''),
51
- region: String(credentials.region || ''),
52
- };
53
- writeFileSync(path, JSON.stringify(payload, null, 2), { encoding: 'utf8', mode: 0o600 });
54
- ensurePrivateMode(path);
55
- return path;
56
- }
57
-
58
- export function writeObsConfig(credentials = {}) {
59
- const region = String(credentials.region || '');
60
- const ak = String(credentials.ak || '');
61
- const sk = String(credentials.sk || '');
62
- const securityToken = String(credentials.securityToken || '');
63
- if (!region || !ak || !sk) {
64
- throw new Error('region, ak, and sk are required to write OBS config');
65
- }
66
- const path = obsConfigPath();
67
- const endpoint = credentials.endpoint || `https://obs.${region}.myhuaweicloud.com`;
68
- // Flat key=value format (no [default] section) as written by KooCLI 7.x `hcloud OBS config`.
69
- const content = `endpoint=${endpoint}\nak=${ak}\nsk=${sk}${securityToken ? `\ntoken=${securityToken}` : ''}\n`;
70
- writeFileSync(path, content, { encoding: 'utf8', mode: 0o600 });
71
- ensurePrivateMode(path);
72
- return { path, endpoint };
73
- }
74
-
75
- export function resolveCredentials(options = {}) {
76
- let ak = process.env.HW_ACCESS_KEY;
77
- let sk = process.env.HW_SECRET_KEY;
78
- let securityToken = process.env.HW_SECURITY_TOKEN;
79
- let region = process.env.HW_REGION || process.env.HUAWEICLOUD_REGION || '';
80
-
81
- const stored = readGlobalCredentials();
82
- if (stored) {
83
- if (!ak && stored.ak) ak = stored.ak;
84
- if (!sk && stored.sk) sk = stored.sk;
85
- if (!securityToken && stored.securityToken) securityToken = stored.securityToken;
86
- if (!region && stored.region) region = stored.region;
87
- }
88
-
89
- if (!ak || !sk) {
90
- if (options.allowMissing) return null;
91
- throw new Error('Huawei Cloud credentials are not configured. Run "npx huaweicloud-devkit auth init" or set HW_ACCESS_KEY/HW_SECRET_KEY.');
92
- }
93
-
94
- return { ak, sk, securityToken, region };
95
- }
1
+ import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { homedir } from 'node:os';
4
+
5
+ // Verify a credential file ended up with 0600. On Windows-mounted drives inside WSL
6
+ // (drvfs/9p) chmod is silently ignored, so the file can be world-readable (0777).
7
+ // Native Windows has no POSIX modes (statSync always reports 0666), so skip the check there.
8
+ function ensurePrivateMode(path) {
9
+ if (process.platform === 'win32') return;
10
+ try {
11
+ chmodSync(path, 0o600);
12
+ } catch {}
13
+ try {
14
+ const mode = statSync(path).mode & 0o777;
15
+ if (mode !== 0o600) {
16
+ console.warn(
17
+ `\x1b[33m[WARN]\x1b[0m Could not set 0600 on ${path} (current mode ${mode.toString(8)}). Credentials may be readable by other users.`,
18
+ );
19
+ console.warn(`\x1b[33m If running under WSL, move the credential home to the Linux filesystem:\x1b[0m`);
20
+ console.warn(`\x1b[33m export HUAWEICLOUD_HOME=$HOME (then re-run auth init)\x1b[0m`);
21
+ console.warn(
22
+ `\x1b[33m Or skip file storage entirely with HW_ACCESS_KEY/HW_SECRET_KEY environment variables.\x1b[0m`,
23
+ );
24
+ }
25
+ } catch {}
26
+ }
27
+
28
+ function baseHome() {
29
+ return process.env.HUAWEICLOUD_HOME || homedir();
30
+ }
31
+
32
+ export function globalCredentialsPath() {
33
+ return join(baseHome(), '.config', 'huaweicloud', 'credentials.json');
34
+ }
35
+
36
+ export function obsConfigPath() {
37
+ return join(baseHome(), '.obsutilconfig');
38
+ }
39
+
40
+ export function readGlobalCredentials() {
41
+ const path = globalCredentialsPath();
42
+ if (!existsSync(path)) return null;
43
+ try {
44
+ return JSON.parse(readFileSync(path, 'utf8'));
45
+ } catch {
46
+ return null;
47
+ }
48
+ }
49
+
50
+ export function writeGlobalCredentials(credentials = {}) {
51
+ const path = globalCredentialsPath();
52
+ mkdirSync(dirname(path), { recursive: true });
53
+ const payload = {
54
+ ak: String(credentials.ak || ''),
55
+ sk: String(credentials.sk || ''),
56
+ securityToken: String(credentials.securityToken || ''),
57
+ region: String(credentials.region || ''),
58
+ };
59
+ writeFileSync(path, JSON.stringify(payload, null, 2), { encoding: 'utf8', mode: 0o600 });
60
+ ensurePrivateMode(path);
61
+ return path;
62
+ }
63
+
64
+ export function writeObsConfig(credentials = {}) {
65
+ const region = String(credentials.region || '');
66
+ const ak = String(credentials.ak || '');
67
+ const sk = String(credentials.sk || '');
68
+ const securityToken = String(credentials.securityToken || '');
69
+ if (!region || !ak || !sk) {
70
+ throw new Error('region, ak, and sk are required to write OBS config');
71
+ }
72
+ const path = obsConfigPath();
73
+ const endpoint = credentials.endpoint || `https://obs.${region}.myhuaweicloud.com`;
74
+ // Flat key=value format (no [default] section) as written by KooCLI 7.x `hcloud OBS config`.
75
+ const content = `endpoint=${endpoint}\nak=${ak}\nsk=${sk}${securityToken ? `\ntoken=${securityToken}` : ''}\n`;
76
+ writeFileSync(path, content, { encoding: 'utf8', mode: 0o600 });
77
+ ensurePrivateMode(path);
78
+ return { path, endpoint };
79
+ }
80
+
81
+ export function resolveCredentials(options = {}) {
82
+ let ak = process.env.HW_ACCESS_KEY;
83
+ let sk = process.env.HW_SECRET_KEY;
84
+ let securityToken = process.env.HW_SECURITY_TOKEN;
85
+ let region = process.env.HW_REGION || process.env.HUAWEICLOUD_REGION || '';
86
+
87
+ const stored = readGlobalCredentials();
88
+ if (stored) {
89
+ if (!ak && stored.ak) ak = stored.ak;
90
+ if (!sk && stored.sk) sk = stored.sk;
91
+ if (!securityToken && stored.securityToken) securityToken = stored.securityToken;
92
+ if (!region && stored.region) region = stored.region;
93
+ }
94
+
95
+ if (!ak || !sk) {
96
+ if (options.allowMissing) return null;
97
+ throw new Error(
98
+ 'Huawei Cloud credentials are not configured. Run "npx huaweicloud-devkit auth init" or set HW_ACCESS_KEY/HW_SECRET_KEY.',
99
+ );
100
+ }
101
+
102
+ return { ak, sk, securityToken, region };
103
+ }
@@ -1,63 +1,63 @@
1
- import { existsSync } from 'node:fs';
2
- import { spawnSync } from 'node:child_process';
3
- import { getAgentRegistrationStatuses } from './agent-registration.mjs';
4
- import { globalCredentialsPath, obsConfigPath, readGlobalCredentials, writeObsConfig } from './credentials.mjs';
5
-
6
- function hcloudInstalled() {
7
- const bin = process.env.HCLOUD_BIN || 'hcloud';
8
- try {
9
- const r = spawnSync(`"${bin}" version`, [], {
10
- shell: true,
11
- windowsHide: true,
12
- stdio: 'pipe',
13
- timeout: 5000,
14
- });
15
- const out = `${r.stdout || ''}${r.stderr || ''}`;
16
- return r.status === 0 && /KooCLI|Current.*version|当前KooCLI/i.test(out);
17
- } catch {
18
- return false;
19
- }
20
- }
21
-
22
- export function getAuthStatus(target = 'all') {
23
- const credentials = readGlobalCredentials();
24
- return {
25
- target,
26
- credentialsConfigured: Boolean(credentials?.ak && credentials?.sk),
27
- credentialsPath: globalCredentialsPath(),
28
- obsConfigured: existsSync(obsConfigPath()),
29
- obsConfigPath: obsConfigPath(),
30
- kooCliInstalled: hcloudInstalled(),
31
- agents: getAgentRegistrationStatuses(target).agents,
32
- };
33
- }
34
-
35
- export function syncAuth(target = 'all') {
36
- const credentials = readGlobalCredentials();
37
- if (!credentials?.ak || !credentials?.sk) {
38
- return {
39
- ok: false,
40
- error: 'Global credentials are not configured.',
41
- nextStep: 'Run "npx huaweicloud-devkit auth init" first.',
42
- };
43
- }
44
-
45
- let obs = null;
46
- try {
47
- obs = writeObsConfig(credentials);
48
- } catch (error) {
49
- return {
50
- ok: false,
51
- error: error.message,
52
- nextStep: 'Run "npx huaweicloud-devkit auth init" to refresh credentials and region.',
53
- };
54
- }
55
-
56
- return {
57
- ok: true,
58
- obs: { configured: true, path: obs.path, endpoint: obs.endpoint },
59
- credentialsConfigured: true,
60
- agents: getAgentRegistrationStatuses(target).agents,
61
- note: 'OBS credentials were synced from the global credential vault. Agent MCP registration is managed by "npx huaweicloud-devkit install --target <agent>".',
62
- };
63
- }
1
+ import { existsSync } from 'node:fs';
2
+ import { spawnSync } from 'node:child_process';
3
+ import { getAgentRegistrationStatuses } from './agent-registration.mjs';
4
+ import { globalCredentialsPath, obsConfigPath, readGlobalCredentials, writeObsConfig } from './credentials.mjs';
5
+
6
+ function hcloudInstalled() {
7
+ const bin = process.env.HCLOUD_BIN || 'hcloud';
8
+ try {
9
+ const r = spawnSync(`"${bin}" version`, [], {
10
+ shell: true,
11
+ windowsHide: true,
12
+ stdio: 'pipe',
13
+ timeout: 5000,
14
+ });
15
+ const out = `${r.stdout || ''}${r.stderr || ''}`;
16
+ return r.status === 0 && /KooCLI|Current.*version|当前KooCLI/i.test(out);
17
+ } catch {
18
+ return false;
19
+ }
20
+ }
21
+
22
+ export function getAuthStatus(target = 'all') {
23
+ const credentials = readGlobalCredentials();
24
+ return {
25
+ target,
26
+ credentialsConfigured: Boolean(credentials?.ak && credentials?.sk),
27
+ credentialsPath: globalCredentialsPath(),
28
+ obsConfigured: existsSync(obsConfigPath()),
29
+ obsConfigPath: obsConfigPath(),
30
+ kooCliInstalled: hcloudInstalled(),
31
+ agents: getAgentRegistrationStatuses(target).agents,
32
+ };
33
+ }
34
+
35
+ export function syncAuth(target = 'all') {
36
+ const credentials = readGlobalCredentials();
37
+ if (!credentials?.ak || !credentials?.sk) {
38
+ return {
39
+ ok: false,
40
+ error: 'Global credentials are not configured.',
41
+ nextStep: 'Run "npx huaweicloud-devkit auth init" first.',
42
+ };
43
+ }
44
+
45
+ let obs;
46
+ try {
47
+ obs = writeObsConfig(credentials);
48
+ } catch (error) {
49
+ return {
50
+ ok: false,
51
+ error: error.message,
52
+ nextStep: 'Run "npx huaweicloud-devkit auth init" to refresh credentials and region.',
53
+ };
54
+ }
55
+
56
+ return {
57
+ ok: true,
58
+ obs: { configured: true, path: obs.path, endpoint: obs.endpoint },
59
+ credentialsConfigured: true,
60
+ agents: getAgentRegistrationStatuses(target).agents,
61
+ note: 'OBS credentials were synced from the global credential vault. Agent MCP registration is managed by "npx huaweicloud-devkit install --target <agent>".',
62
+ };
63
+ }