huaweicloud-devkit 1.1.3-next.3 → 1.1.3-next.4

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,7 +1,7 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
3
  "mcpName": "io.github.huaweicloud/huaweicloud-devkit",
4
- "version": "1.1.3-next.3",
4
+ "version": "1.1.3-next.4",
5
5
  "kooCliVersion": "7.2.12",
6
6
  "description": "Agent toolkit that helps coding agents use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities safely and accurately.",
7
7
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  "mcpServers": "./.mcp.json",
18
18
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
19
19
  "skills": "./skills/",
20
- "version": "1.1.3-next.3",
20
+ "version": "1.1.3-next.4",
21
21
  "author": {
22
22
  "name": "HuaweiCloud Mate",
23
23
  "url": "https://github.com/huaweicloud"
@@ -20,7 +20,7 @@
20
20
  "mcpServers": "./.mcp.json",
21
21
  "description": "Agent toolkit that helps coding agents use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities safely and accurately.",
22
22
  "skills": "./skills/",
23
- "version": "1.1.3-next.3",
23
+ "version": "1.1.3-next.4",
24
24
  "author": {
25
25
  "name": "HuaweiCloud Mate",
26
26
  "url": "https://github.com/huaweicloud"
@@ -17,7 +17,7 @@
17
17
  "mcpServers": "./.mcp.json",
18
18
  "description": "Guide coding agents to use Huawei Cloud Skills, KooCLI, APIs, SDKs, and future MCP capabilities with safer execution and less context.",
19
19
  "skills": "./skills/",
20
- "version": "1.1.3-next.3",
20
+ "version": "1.1.3-next.4",
21
21
  "author": {
22
22
  "name": "HuaweiCloud Mate",
23
23
  "url": "https://github.com/huaweicloud"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "1.1.3-next.3",
3
+ "version": "1.1.3-next.4",
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",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huaweicloud-devkit",
3
- "version": "1.1.3-next.3",
3
+ "version": "1.1.3-next.4",
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",
@@ -2,7 +2,7 @@
2
2
  "name": "huaweicloud-devkit",
3
3
  "id": "huaweicloud-devkit",
4
4
  "displayName": "HuaweiCloud DevKit",
5
- "version": "1.1.3-next.3",
5
+ "version": "1.1.3-next.4",
6
6
  "family": "bundle-plugin",
7
7
  "bundleFormat": "codex",
8
8
  "description": "Guide coding agents to use Huawei Cloud safely — KooCLI, APIs, SDKs, 28 MCP tools, skills, and safety guardrails.",
@@ -36,7 +36,7 @@ import {
36
36
  getProxySettings,
37
37
  } from './proxy/proxy-config.mjs';
38
38
  import { removeKooCli, removeObsConfig } from './sandbox/uninstall-cleanup.mjs';
39
- import { queryDistTagsSync, determineTarget, semverCompare } from './update-check.mjs';
39
+ import { queryDistTagsFetch, determineTarget, semverCompare } from './update-check.mjs';
40
40
  import { getKooCliVersion, compareVersion, kooCliDownloadBase, KOO_CLI_BASE } from './koocli-version.mjs';
41
41
  import { findHcloudBin, hcloudProbeNextStep, probeHcloud } from './hcloud-probe.mjs';
42
42
 
@@ -3255,9 +3255,9 @@ function parseTarget() {
3255
3255
  process.exit(1);
3256
3256
  }
3257
3257
 
3258
- function checkForUpdate() {
3258
+ async function checkForUpdate() {
3259
3259
  if (pkgVersion === '0.0.0') return;
3260
- const distTags = queryDistTagsSync({ timeoutMs: 5000 });
3260
+ const distTags = await queryDistTagsFetch({ timeoutMs: 15000 });
3261
3261
  const target = determineTarget(pkgVersion, distTags ?? {});
3262
3262
  if (target && semverCompare(target, pkgVersion) > 0) {
3263
3263
  const tag = distTags.next && semverCompare(target, distTags.next) === 0 ? 'next' : 'latest';
@@ -3312,7 +3312,7 @@ async function cmdInstall() {
3312
3312
  }
3313
3313
 
3314
3314
  checkNode();
3315
- checkForUpdate();
3315
+ await checkForUpdate();
3316
3316
  const installFailures = [];
3317
3317
 
3318
3318
  function shouldInstall(name) {
@@ -4077,7 +4077,7 @@ async function cmdDoctor() {
4077
4077
  async function cmdUpdate() {
4078
4078
  console.log(BANNER);
4079
4079
  const target = parseTarget();
4080
- checkForUpdate();
4080
+ await checkForUpdate();
4081
4081
 
4082
4082
  if (target === 'opencode') {
4083
4083
  if (!existsSync(join(opencodePluginsDir(), 'src', 'mcp-server.mjs'))) {
@@ -19,7 +19,11 @@ const __filename = fileURLToPath(import.meta.url);
19
19
  const __dirname = dirname(__filename);
20
20
  const PLUGIN_DIR = join(__dirname, '..', '..');
21
21
  const AGENT_TELEMETRY_DIR = join(PLUGIN_DIR, 'telemetry');
22
- const GLOBAL_TELEMETRY_DIR = join(homedir(), '.huaweicloud-devkit', 'telemetry');
22
+ const GLOBAL_TELEMETRY_DIR = join(
23
+ (process.env.HUAWEICLOUD_DEVKIT_HOME || '').trim() || homedir(),
24
+ '.huaweicloud-devkit',
25
+ 'telemetry',
26
+ );
23
27
 
24
28
  let PLUGIN_VERSION = '0.0.0';
25
29
  try {
@@ -6,6 +6,8 @@ import { join, dirname, resolve } from 'node:path';
6
6
  import { homedir } from 'node:os';
7
7
  import { fileURLToPath } from 'node:url';
8
8
 
9
+ import { fetchWithProxy } from './proxy/proxy-agent.mjs';
10
+
9
11
  const IS_WINDOWS = process.platform === 'win32';
10
12
  const NPM_BIN = IS_WINDOWS ? 'npm.cmd' : 'npm';
11
13
  const NPX_BIN = IS_WINDOWS ? 'npx.cmd' : 'npx';
@@ -187,7 +189,33 @@ export function writeSkipState(file, dismissedVersion, { at = Date.now(), days =
187
189
  return state;
188
190
  }
189
191
 
190
- export function queryDistTagsSync({ timeoutMs = 5000, cwd } = {}) {
192
+ function debugLog(message) {
193
+ if (process.env.HUAWEICLOUD_DEVKIT_DEBUG === '1' || process.env.HUAWEICLOUD_DEVKIT_DEBUG === 'true') {
194
+ console.error(`[debug] ${message}`);
195
+ }
196
+ }
197
+
198
+ export function queryDistTagsFetch({ timeoutMs = 15000 } = {}) {
199
+ let registry = 'https://registry.npmjs.org';
200
+ if (process.env.HUAWEICLOUD_NPM_REGISTRY) {
201
+ registry = process.env.HUAWEICLOUD_NPM_REGISTRY.replace(/\/+$/, '');
202
+ }
203
+ const controller = new AbortController();
204
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
205
+ return fetchWithProxy(`${registry}/-/package/huaweicloud-devkit/dist-tags`)
206
+ .then((resp) => {
207
+ clearTimeout(timer);
208
+ if (!resp || !resp.ok) return null;
209
+ return resp.json().catch(() => null);
210
+ })
211
+ .catch((error) => {
212
+ clearTimeout(timer);
213
+ debugLog(`queryDistTagsFetch: ${error?.message || error}`);
214
+ return null;
215
+ });
216
+ }
217
+
218
+ export function queryDistTagsSync({ timeoutMs = 15000, cwd } = {}) {
191
219
  try {
192
220
  const result = spawnSync(NPM_BIN, ['view', 'huaweicloud-devkit', 'dist-tags', '--json'], {
193
221
  encoding: 'utf8',
@@ -195,14 +223,18 @@ export function queryDistTagsSync({ timeoutMs = 5000, cwd } = {}) {
195
223
  windowsHide: true,
196
224
  cwd,
197
225
  });
198
- if (result.status !== 0) return null;
226
+ if (result.status !== 0) {
227
+ debugLog(`queryDistTagsSync: npm view exited with status ${result.status}`);
228
+ return null;
229
+ }
199
230
  return parseDistTagsOutput(result.stdout);
200
- } catch {
231
+ } catch (error) {
232
+ debugLog(`queryDistTagsSync: ${error?.message || error}`);
201
233
  return null;
202
234
  }
203
235
  }
204
236
 
205
- export function queryDistTags({ timeoutMs = 5000, cwd } = {}) {
237
+ export function queryDistTags({ timeoutMs = 15000, cwd } = {}) {
206
238
  return new Promise((resolve) => {
207
239
  let child;
208
240
  try {
@@ -210,7 +242,8 @@ export function queryDistTags({ timeoutMs = 5000, cwd } = {}) {
210
242
  windowsHide: true,
211
243
  cwd,
212
244
  });
213
- } catch {
245
+ } catch (error) {
246
+ debugLog(`queryDistTags: ${error?.message || error}`);
214
247
  resolve(null);
215
248
  return;
216
249
  }
@@ -218,20 +251,26 @@ export function queryDistTags({ timeoutMs = 5000, cwd } = {}) {
218
251
  try {
219
252
  child.kill();
220
253
  } catch {}
254
+ debugLog(`queryDistTags: timed out after ${timeoutMs}ms`);
221
255
  resolve(null);
222
256
  }, timeoutMs);
223
257
  let stdout = '';
224
258
  child.stdout.on('data', (d) => {
225
259
  stdout += String(d);
226
260
  });
227
- child.on('error', () => {
261
+ child.on('error', (error) => {
228
262
  clearTimeout(timer);
263
+ debugLog(`queryDistTags: ${error?.message || error}`);
229
264
  resolve(null);
230
265
  });
231
266
  child.on('close', (code) => {
232
267
  clearTimeout(timer);
233
- if (code === 0) resolve(parseDistTagsOutput(stdout));
234
- else resolve(null);
268
+ if (code === 0) {
269
+ resolve(parseDistTagsOutput(stdout));
270
+ } else {
271
+ debugLog(`queryDistTags: npm view exited with code ${code}`);
272
+ resolve(null);
273
+ }
235
274
  });
236
275
  });
237
276
  }
@@ -250,19 +289,19 @@ export function invalidateUpdateCache() {
250
289
  lastHint = null;
251
290
  }
252
291
 
253
- function cacheValid() {
254
- return Boolean(cachedDistTags) && Date.now() - cachedAt <= TTL_MS;
292
+ function cacheValid(now = Date.now()) {
293
+ return Boolean(cachedDistTags) && now - cachedAt <= TTL_MS;
255
294
  }
256
295
 
257
- export async function getCachedUpdateInfo(current, { doQuery = queryDistTags } = {}) {
296
+ export async function getCachedUpdateInfo(current, { doQuery = queryDistTags, now = Date.now() } = {}) {
258
297
  if (process.env.HUAWEICLOUD_DEVKIT_SKIP_UPDATE === '1') {
259
- lastHint = judgeUpdate(current, null);
298
+ lastHint = judgeUpdate(current, null, undefined, now);
260
299
  return lastHint;
261
300
  }
262
301
  const skipState = readSkipState(resolveSkipFilePath());
263
- if (!cacheValid()) {
264
- if (!cachedDistTags && Date.now() - failedAt < FAIL_THROTTLE_MS) {
265
- lastHint = judgeUpdate(current, null, skipState);
302
+ if (!cacheValid(now)) {
303
+ if (!cachedDistTags && now - failedAt < FAIL_THROTTLE_MS) {
304
+ lastHint = judgeUpdate(current, null, skipState, now);
266
305
  return lastHint;
267
306
  }
268
307
  if (!inflightQuery) {
@@ -270,9 +309,9 @@ export async function getCachedUpdateInfo(current, { doQuery = queryDistTags } =
270
309
  .then((distTags) => {
271
310
  if (distTags) {
272
311
  cachedDistTags = distTags;
273
- cachedAt = Date.now();
312
+ cachedAt = now;
274
313
  } else {
275
- failedAt = Date.now();
314
+ failedAt = now;
276
315
  }
277
316
  return distTags;
278
317
  })
@@ -281,7 +320,7 @@ export async function getCachedUpdateInfo(current, { doQuery = queryDistTags } =
281
320
  });
282
321
  }
283
322
  const distTags = await inflightQuery;
284
- lastHint = judgeUpdate(current, distTags, skipState);
323
+ lastHint = judgeUpdate(current, distTags, skipState, now);
285
324
  return lastHint;
286
325
  }
287
326
  lastHint = judgeUpdate(current, cachedDistTags, skipState);