huaweicloud-devkit 1.0.2-dev.4 → 1.0.2-dev.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "1.0.2-dev.4",
3
+ "version": "1.0.2-dev.5",
4
4
  "description": "Agent toolkit that helps coding agents use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities safely and accurately.",
5
5
  "type": "module",
6
6
  "files": [
@@ -20,7 +20,7 @@
20
20
  "mcpServers": "./.mcp.json",
21
21
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
22
22
  "skills": "./skills/",
23
- "version": "1.0.2-dev.4",
23
+ "version": "1.0.2-dev.5",
24
24
  "author": {
25
25
  "name": "HuaweiCloud Mate",
26
26
  "url": "https://github.com/huaweicloud"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-core",
3
- "version": "1.0.2-dev.4",
3
+ "version": "1.0.2-dev.5",
4
4
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
5
5
  "author": {
6
6
  "name": "HuaweiCloud Mate",
@@ -20,7 +20,7 @@
20
20
  "mcpServers": "./.mcp.json",
21
21
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
22
22
  "skills": "./skills/",
23
- "version": "1.0.2-dev.4",
23
+ "version": "1.0.2-dev.5",
24
24
  "author": {
25
25
  "name": "HuaweiCloud Mate",
26
26
  "url": "https://github.com/huaweicloud"
@@ -908,6 +908,19 @@ async function cmdUninstall() {
908
908
  }
909
909
  }
910
910
  }
911
+ if (target === 'all') {
912
+ const vaultPath = globalCredentialsPath();
913
+ if (removeIfExists(vaultPath)) {
914
+ console.log(' Removed credential vault');
915
+ }
916
+ const vaultDir = dirname(vaultPath);
917
+ try {
918
+ if (existsSync(vaultDir) && readdirSync(vaultDir).length === 0) {
919
+ rmSync(vaultDir, { recursive: true, force: true });
920
+ console.log(` Removed empty directory: ${vaultDir}`);
921
+ }
922
+ } catch {}
923
+ }
911
924
  console.log(`\n\x1b[32mUninstall complete.\x1b[0m`);
912
925
  }
913
926
 
@@ -1325,7 +1338,9 @@ function readLineQuestion(prompt) {
1325
1338
 
1326
1339
  async function readSecret(prompt) {
1327
1340
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
1328
- return readLineQuestion(prompt);
1341
+ throw new Error(
1342
+ `Cannot read "${prompt.trim()}" securely in a non-interactive session. Set HW_ACCESS_KEY/HW_SECRET_KEY environment variables instead, or run "npx huaweicloud-devkit auth init" in a real terminal.`
1343
+ );
1329
1344
  }
1330
1345
 
1331
1346
  process.stdout.write(prompt);
@@ -1408,21 +1423,26 @@ async function cmdAuthInit() {
1408
1423
  let securityToken = process.env.HW_SECURITY_TOKEN || '';
1409
1424
  let region = process.env.HW_REGION || process.env.HUAWEICLOUD_REGION || '';
1410
1425
 
1411
- if (!ak) ak = await readSecret('Access Key ID (AK): ');
1426
+ const interactive = process.stdin.isTTY && process.stdout.isTTY;
1427
+ if (!interactive && (!ak || !sk)) {
1428
+ console.error('\x1b[31mNon-interactive session detected. Provide credentials via environment variables instead:\x1b[0m');
1429
+ console.error(' HW_ACCESS_KEY, HW_SECRET_KEY');
1430
+ console.error(' (Or run "npx huaweicloud-devkit auth init" in a real terminal.)');
1431
+ process.exitCode = 1;
1432
+ return;
1433
+ }
1434
+
1435
+ if (!ak) ak = await readLineQuestion('Access Key ID (AK): ');
1412
1436
  if (!sk) sk = await readSecret('Secret Access Key (SK): ');
1413
- if (!securityToken) securityToken = await readLineQuestion('Security Token (optional, press Enter to skip): ');
1414
- if (!region) region = await readLineQuestion('Region (e.g. cn-north-4): ');
1437
+ if (interactive && !securityToken) securityToken = await readLineQuestion('Security Token (optional, press Enter to skip): ');
1438
+ if (!region) region = 'cn-north-4';
1415
1439
 
1416
1440
  if (!ak || !sk) {
1417
1441
  console.error('\nAK and SK are required.');
1418
1442
  process.exitCode = 1;
1419
1443
  return;
1420
1444
  }
1421
- if (!region) {
1422
- console.error('\nRegion is required to generate the OBS endpoint.');
1423
- process.exitCode = 1;
1424
- return;
1425
- }
1445
+
1426
1446
 
1427
1447
  const vaultPath = writeGlobalCredentials({ ak, sk, securityToken, region });
1428
1448
  console.log(`\nCredentials stored: ${vaultPath}`);