huaweicloud-devkit 1.1.7 → 1.1.8-next.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.
Files changed (32) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/package.json +2 -1
  4. package/plugins/huaweicloud-core/.claude-plugin/plugin.json +1 -1
  5. package/plugins/huaweicloud-core/.codex-plugin/plugin.json +1 -1
  6. package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +1 -1
  7. package/plugins/huaweicloud-core/.hermes-plugin/plugin.json +1 -1
  8. package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +1 -1
  9. package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +19 -1
  10. package/plugins/huaweicloud-core/openclaw.plugin.json +1 -1
  11. package/plugins/huaweicloud-core/safety/policy.json +1 -1
  12. package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +57 -2
  13. package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +19 -16
  14. package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +1 -1
  15. package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +9 -3
  16. package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +1 -1
  17. package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +15 -2
  18. package/plugins/huaweicloud-core/src/auth/service.mjs +36 -0
  19. package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +23 -5
  20. package/plugins/huaweicloud-core/src/detect-framework.mjs +41 -5
  21. package/plugins/huaweicloud-core/src/hcloud-cli.mjs +78 -8
  22. package/plugins/huaweicloud-core/src/hcloud-probe.mjs +10 -2
  23. package/plugins/huaweicloud-core/src/mcp-server.mjs +9 -0
  24. package/plugins/huaweicloud-core/src/preflight.mjs +125 -0
  25. package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +94 -1
  26. package/plugins/huaweicloud-core/src/risk-rule-engine.mjs +1 -1
  27. package/plugins/huaweicloud-core/src/safety-policy.mjs +165 -33
  28. package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +214 -27
  29. package/plugins/huaweicloud-core/src/search-market.mjs +40 -1
  30. package/plugins/huaweicloud-core/src/setup-cli.mjs +57 -17
  31. package/plugins/huaweicloud-core/src/tools.mjs +307 -20
  32. package/rules/huawei-agent-rules.mdc +78 -0
@@ -566,6 +566,20 @@ function copyDir(src, dest) {
566
566
  }
567
567
  }
568
568
 
569
+ // Copy the global agent rules file (rules/huawei-agent-rules.mdc) into the
570
+ // plugin destination so installed agents can load behavioral constraints
571
+ // (#758 D4-23). Idempotent — safe to call on install and update.
572
+ const AGENT_RULES_FILE = 'huawei-agent-rules.mdc';
573
+
574
+ function injectAgentRules(pluginDest) {
575
+ const rulesSrc = join(PACKAGE_ROOT, 'rules', AGENT_RULES_FILE);
576
+ if (!existsSync(rulesSrc)) return;
577
+ const rulesDestDir = join(pluginDest, 'rules');
578
+ mkdirSync(rulesDestDir, { recursive: true });
579
+ copyFileVerified(rulesSrc, join(rulesDestDir, AGENT_RULES_FILE));
580
+ console.log(` Agent Rules -> ${join(rulesDestDir, AGENT_RULES_FILE)}`);
581
+ }
582
+
569
583
  function installRuntimeDeps(pluginsDir) {
570
584
  const pkgJson = {
571
585
  name: 'huaweicloud-devkit',
@@ -866,6 +880,7 @@ async function installOpenCode() {
866
880
  console.log(` MCP Server -> ${join(pluginDest, 'src')}`);
867
881
  copyDir(safetyDir, join(pluginDest, 'safety'));
868
882
  console.log(` Safety Policy -> ${join(pluginDest, 'safety')}`);
883
+ injectAgentRules(pluginDest);
869
884
  const opcPlugins = join(configRoot('opencode'), 'plugins');
870
885
  mkdirSync(opcPlugins, { recursive: true });
871
886
  copyFileSync(pluginSrc, join(opcPlugins, 'skill-tracker.js'));
@@ -945,6 +960,7 @@ async function updateOpenCode() {
945
960
  console.log(` MCP Server updated -> ${join(pluginDest, 'src')}`);
946
961
  copyDir(safetyDir, join(pluginDest, 'safety'));
947
962
  console.log(` Safety Policy updated -> ${join(pluginDest, 'safety')}`);
963
+ injectAgentRules(pluginDest);
948
964
  const opcPlugins = join(configRoot('opencode'), 'plugins');
949
965
  mkdirSync(opcPlugins, { recursive: true });
950
966
  copyFileSync(pluginSrc, join(opcPlugins, 'skill-tracker.js'));
@@ -1045,6 +1061,7 @@ async function installOpenClaw() {
1045
1061
  console.log(` MCP Server -> ${join(pluginDest, 'src')}`);
1046
1062
  copyDir(safetyDir, join(pluginDest, 'safety'));
1047
1063
  console.log(` Safety Policy -> ${join(pluginDest, 'safety')}`);
1064
+ injectAgentRules(pluginDest);
1048
1065
 
1049
1066
  const mcpServerAbsPath = join(pluginDest, 'src', 'mcp-server.mjs').replace(/\\/g, '/');
1050
1067
  writeMcpServersFile(pluginDest, mcpServerAbsPath, 'openclaw');
@@ -1105,6 +1122,7 @@ async function updateOpenClaw() {
1105
1122
  console.log(` MCP Server updated -> ${join(pluginDest, 'src')}`);
1106
1123
  copyDir(safetyDir, join(pluginDest, 'safety'));
1107
1124
  console.log(` Safety Policy updated -> ${join(pluginDest, 'safety')}`);
1125
+ injectAgentRules(pluginDest);
1108
1126
 
1109
1127
  const mcpServerAbsPath = join(pluginDest, 'src', 'mcp-server.mjs').replace(/\\/g, '/');
1110
1128
  writeMcpServersFile(pluginDest, mcpServerAbsPath, 'openclaw');
@@ -1135,6 +1153,7 @@ async function installCodexDesktop() {
1135
1153
  console.log(` MCP Server -> ${join(pluginDest, 'src')}`);
1136
1154
  copyDir(safetyDir, join(pluginDest, 'safety'));
1137
1155
  console.log(` Safety Policy -> ${join(pluginDest, 'safety')}`);
1156
+ injectAgentRules(pluginDest);
1138
1157
 
1139
1158
  // Copy assets (icons, logos) for Codex Desktop plugin UI
1140
1159
  const codexAssetsSrc = join(PLUGIN_ROOT, 'assets');
@@ -1193,6 +1212,7 @@ async function updateCodexDesktop() {
1193
1212
  console.log(` MCP Server updated -> ${join(pluginDest, 'src')}`);
1194
1213
  copyDir(safetyDir, join(pluginDest, 'safety'));
1195
1214
  console.log(` Safety Policy updated -> ${join(pluginDest, 'safety')}`);
1215
+ injectAgentRules(pluginDest);
1196
1216
 
1197
1217
  // Copy assets (icons, logos) for Codex Desktop plugin UI
1198
1218
  const codexAssetsSrc = join(PLUGIN_ROOT, 'assets');
@@ -1328,6 +1348,7 @@ async function installCodeArts() {
1328
1348
  console.log(` MCP Server -> ${join(pluginDest, 'src')}`);
1329
1349
  copyDir(safetyDir, join(pluginDest, 'safety'));
1330
1350
  console.log(` Safety Policy -> ${join(pluginDest, 'safety')}`);
1351
+ injectAgentRules(pluginDest);
1331
1352
 
1332
1353
  const codeartsHookDir = join(homedir(), '.codeartsdoer', 'plugins');
1333
1354
  mkdirSync(codeartsHookDir, { recursive: true });
@@ -1357,6 +1378,7 @@ async function updateCodeArts() {
1357
1378
  console.log(` MCP Server updated -> ${join(pluginDest, 'src')}`);
1358
1379
  copyDir(safetyDir, join(pluginDest, 'safety'));
1359
1380
  console.log(` Safety Policy updated -> ${join(pluginDest, 'safety')}`);
1381
+ injectAgentRules(pluginDest);
1360
1382
 
1361
1383
  const codeartsHookDir = join(homedir(), '.codeartsdoer', 'plugins');
1362
1384
  mkdirSync(codeartsHookDir, { recursive: true });
@@ -1512,6 +1534,7 @@ async function installCodeArtsWork() {
1512
1534
  console.log(` MCP Server -> ${join(pluginDest, 'src')}`);
1513
1535
  copyDir(safetyDir, join(pluginDest, 'safety'));
1514
1536
  console.log(` Safety Policy -> ${join(pluginDest, 'safety')}`);
1537
+ injectAgentRules(pluginDest);
1515
1538
 
1516
1539
  registerCodeartsWorkMcp();
1517
1540
  installRuntimeDeps(pluginDest);
@@ -1529,6 +1552,7 @@ async function updateCodeArtsWork() {
1529
1552
  console.log(` MCP Server updated -> ${join(pluginDest, 'src')}`);
1530
1553
  copyDir(safetyDir, join(pluginDest, 'safety'));
1531
1554
  console.log(` Safety Policy updated -> ${join(pluginDest, 'safety')}`);
1555
+ injectAgentRules(pluginDest);
1532
1556
  registerCodeartsWorkMcp();
1533
1557
  mkdirSync(pluginDest, { recursive: true });
1534
1558
  writeFileSync(join(pluginDest, '.installed'), new Date().toISOString());
@@ -1792,6 +1816,7 @@ async function installWorkBuddy() {
1792
1816
  console.log(` MCP Server -> ${join(pluginDest, 'src')}`);
1793
1817
  copyDir(safetyDir, join(pluginDest, 'safety'));
1794
1818
  console.log(` Safety Policy -> ${join(pluginDest, 'safety')}`);
1819
+ injectAgentRules(pluginDest);
1795
1820
 
1796
1821
  ensureWorkbuddyMcpConfig();
1797
1822
  installRuntimeDeps(pluginDest);
@@ -1814,6 +1839,7 @@ async function updateWorkBuddy() {
1814
1839
  console.log(` MCP Server updated -> ${join(pluginDest, 'src')}`);
1815
1840
  copyDir(safetyDir, join(pluginDest, 'safety'));
1816
1841
  console.log(` Safety Policy updated -> ${join(pluginDest, 'safety')}`);
1842
+ injectAgentRules(pluginDest);
1817
1843
  ensureWorkbuddyMcpConfig();
1818
1844
  mkdirSync(pluginDest, { recursive: true });
1819
1845
  writeFileSync(join(pluginDest, '.installed'), new Date().toISOString());
@@ -1985,6 +2011,7 @@ async function installAtomCode() {
1985
2011
  console.log(` MCP Server -> ${join(pluginDest, 'src')}`);
1986
2012
  copyDir(safetyDir, join(pluginDest, 'safety'));
1987
2013
  console.log(` Safety Policy -> ${join(pluginDest, 'safety')}`);
2014
+ injectAgentRules(pluginDest);
1988
2015
 
1989
2016
  ensureAtomcodeMcpConfig();
1990
2017
  deployAtomcodeHooks();
@@ -2005,6 +2032,7 @@ async function updateAtomCode() {
2005
2032
  console.log(` MCP Server updated -> ${join(pluginDest, 'src')}`);
2006
2033
  copyDir(safetyDir, join(pluginDest, 'safety'));
2007
2034
  console.log(` Safety Policy updated -> ${join(pluginDest, 'safety')}`);
2035
+ injectAgentRules(pluginDest);
2008
2036
  ensureAtomcodeMcpConfig();
2009
2037
  deployAtomcodeHooks();
2010
2038
  mkdirSync(pluginDest, { recursive: true });
@@ -2294,6 +2322,7 @@ async function installDsh() {
2294
2322
  console.log(` MCP Server -> ${join(pluginDest, 'src')}`);
2295
2323
  copyDir(safetyDir, join(pluginDest, 'safety'));
2296
2324
  console.log(` Safety Policy -> ${join(pluginDest, 'safety')}`);
2325
+ injectAgentRules(pluginDest);
2297
2326
  copyFileSync(hookSrc, join(pluginDest, 'hook-plugin.mjs'));
2298
2327
  console.log(` Hook Plugin -> ${join(pluginDest, 'hook-plugin.mjs')}`);
2299
2328
  ensureDshMcpPatch();
@@ -2317,6 +2346,7 @@ async function updateDsh() {
2317
2346
  console.log(` MCP Server updated -> ${join(pluginDest, 'src')}`);
2318
2347
  copyDir(safetyDir, join(pluginDest, 'safety'));
2319
2348
  console.log(` Safety Policy updated -> ${join(pluginDest, 'safety')}`);
2349
+ injectAgentRules(pluginDest);
2320
2350
  copyFileSync(hookSrc, join(pluginDest, 'hook-plugin.mjs'));
2321
2351
  console.log(` Hook Plugin updated -> ${join(pluginDest, 'hook-plugin.mjs')}`);
2322
2352
  ensureDshMcpPatch();
@@ -2425,6 +2455,7 @@ async function installOfficeAce() {
2425
2455
  console.log(` MCP Server -> ${join(pluginDest, 'src')}`);
2426
2456
  copyDir(safetyDir, join(pluginDest, 'safety'));
2427
2457
  console.log(` Safety Policy -> ${join(pluginDest, 'safety')}`);
2458
+ injectAgentRules(pluginDest);
2428
2459
 
2429
2460
  installRuntimeDeps(pluginDest);
2430
2461
  if (ensureOfficeaceMcpInSqlite() === 'owner-missing') {
@@ -2453,6 +2484,7 @@ async function updateOfficeAce() {
2453
2484
  console.log(` MCP Server updated -> ${join(pluginDest, 'src')}`);
2454
2485
  copyDir(safetyDir, join(pluginDest, 'safety'));
2455
2486
  console.log(` Safety Policy updated -> ${join(pluginDest, 'safety')}`);
2487
+ injectAgentRules(pluginDest);
2456
2488
  installRuntimeDeps(pluginDest);
2457
2489
  if (ensureOfficeaceMcpInSqlite() === 'owner-missing') {
2458
2490
  console.log(
@@ -2950,6 +2982,7 @@ async function installHermes() {
2950
2982
  }
2951
2983
  copyDir(safetyDir, join(pluginDest, 'safety'));
2952
2984
  console.log(` Safety Policy -> ${join(pluginDest, 'safety')}`);
2985
+ injectAgentRules(pluginDest);
2953
2986
  copyDir(hooksDir, join(pluginDest, 'hooks'));
2954
2987
  console.log(` Safety Hooks -> ${join(pluginDest, 'hooks')}`);
2955
2988
  // Telemetry hook lives in integrations/hermes/hooks/ (platform-specific adapter)
@@ -2981,6 +3014,7 @@ async function updateHermes() {
2981
3014
  console.log(` MCP Server updated -> ${join(pluginDest, 'src')}`);
2982
3015
  copyDir(safetyDir, join(pluginDest, 'safety'));
2983
3016
  console.log(` Safety Policy updated -> ${join(pluginDest, 'safety')}`);
3017
+ injectAgentRules(pluginDest);
2984
3018
  copyDir(hooksDir, join(pluginDest, 'hooks'));
2985
3019
  console.log(` Safety Hooks updated -> ${join(pluginDest, 'hooks')}`);
2986
3020
  // Telemetry hook lives in integrations/hermes/hooks/ (platform-specific adapter)
@@ -4532,27 +4566,33 @@ async function cmdInstallHcloud() {
4532
4566
  const hcloudBin = join(installDir, 'hcloud.exe');
4533
4567
 
4534
4568
  // Ask user before accepting the privacy agreement — never auto-accept.
4535
- const rl = createInterface({ input: process.stdin, output: process.stdout });
4536
- const agree = await new Promise((resolve) => {
4537
- rl.question('\n KooCLI requires accepting its privacy agreement. Do you accept? (y/N) ', (answer) => {
4538
- rl.close();
4539
- resolve(/^\s*y\s*$/i.test(answer));
4540
- });
4541
- });
4542
- if (agree) {
4543
- const r = spawnSync(hcloudBin, ['version'], {
4544
- input: 'y\n',
4545
- encoding: 'utf8',
4546
- timeout: 10000,
4547
- windowsHide: true,
4569
+ // Under non-TTY (e.g. preflight spawns with stdin 'ignore'), rl.question()
4570
+ // never resolves — skip the prompt and let the user accept manually.
4571
+ if (process.stdin.isTTY && process.stdout.isTTY) {
4572
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
4573
+ const agree = await new Promise((resolve) => {
4574
+ rl.question('\n KooCLI requires accepting its privacy agreement. Do you accept? (y/N) ', (answer) => {
4575
+ rl.close();
4576
+ resolve(/^\s*y\s*$/i.test(answer));
4577
+ });
4548
4578
  });
4549
- if (r.status === 0) {
4550
- console.log(' \x1b[32mPrivacy agreement accepted. KooCLI ready.\x1b[0m');
4579
+ if (agree) {
4580
+ const r = spawnSync(hcloudBin, ['version'], {
4581
+ input: 'y\n',
4582
+ encoding: 'utf8',
4583
+ timeout: 10000,
4584
+ windowsHide: true,
4585
+ });
4586
+ if (r.status === 0) {
4587
+ console.log(' \x1b[32mPrivacy agreement accepted. KooCLI ready.\x1b[0m');
4588
+ } else {
4589
+ console.log(' \x1b[33m无法写入配置目录。请在普通终端运行: echo "y" | hcloud version\x1b[0m');
4590
+ }
4551
4591
  } else {
4552
- console.log(' \x1b[33m无法写入配置目录。请在普通终端运行: echo "y" | hcloud version\x1b[0m');
4592
+ console.log(' \x1b[33m请手动接受隐私协议:在终端运行 hcloud version 并按提示操作\x1b[0m');
4553
4593
  }
4554
4594
  } else {
4555
- console.log(' \x1b[33m请手动接受隐私协议:在终端运行 hcloud version 并按提示操作\x1b[0m');
4595
+ console.log(' \x1b[33m非交互会话:请稍后在终端运行 hcloud version 并按提示接受隐私协议\x1b[0m');
4556
4596
  }
4557
4597
 
4558
4598
  console.log(' Or restart terminal and: hcloud version');