@house365/comate 0.9.20 → 0.9.22

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 (2) hide show
  1. package/bin/cli.mjs +14 -4
  2. package/package.json +1 -1
package/bin/cli.mjs CHANGED
@@ -8,10 +8,13 @@ import { dirname } from 'node:path';
8
8
  import { readFileSync } from 'node:fs';
9
9
  import { get } from 'node:https';
10
10
 
11
- import { run, skillsInvocation, SKILLS_TIMEOUT_MS } from './init.mjs';
11
+ import { run, skillsInvocation, SKILLS_TIMEOUT_MS, atLeast } from './init.mjs';
12
12
 
13
13
  // Check npm registry for the latest version and notify if an update is available.
14
14
  async function checkForUpdates(currentVersion) {
15
+ // Escape hatch: skip the network round-trip entirely. Keeps `--version`
16
+ // deterministic and offline-safe in tests and CI.
17
+ if (process.env.COMATE_NO_UPDATE_CHECK) return;
15
18
  return new Promise((resolve) => {
16
19
  const req = get('https://registry.npmjs.org/@house365/comate/latest', { timeout: 3000 }, (res) => {
17
20
  if (res.statusCode !== 200) {
@@ -24,7 +27,11 @@ async function checkForUpdates(currentVersion) {
24
27
  try {
25
28
  const pkg = JSON.parse(data);
26
29
  const latestVersion = pkg.version;
27
- if (latestVersion && latestVersion !== currentVersion) {
30
+ // Notify only when the registry is strictly newer. A plain `!==` also
31
+ // fired when local was ahead of the registry (e.g. mid-release, before
32
+ // publish lands), printing a bogus "update available" for an older
33
+ // version and polluting `--version` stdout.
34
+ if (latestVersion && atLeast(latestVersion, currentVersion) && latestVersion !== currentVersion) {
28
35
  console.log('');
29
36
  console.log(`\x1b[33m🔔 有新版本可用:${latestVersion} (当前版本:${currentVersion})\x1b[0m`);
30
37
  console.log(`\x1b[36m更新命令:npm install -g @house365/comate@latest\x1b[0m`);
@@ -90,8 +97,11 @@ const packageVersion = JSON.parse(readFileSync(`${pkgRoot}/package.json`, 'utf8'
90
97
 
91
98
  if (args[0] === '--version' || args[0] === '-v') {
92
99
  console.log(packageVersion);
93
- // Check for updates in the background, non-blocking
94
- checkForUpdates(packageVersion).catch(() => {
100
+ // Await the check: without it, process.exit(0) fires synchronously and the
101
+ // process dies before the registry request resolves, so the update notice
102
+ // never prints. The check has its own 3s timeout, so a dead network stalls
103
+ // this by at most 3s.
104
+ await checkForUpdates(packageVersion).catch(() => {
95
105
  // Silently ignore network errors
96
106
  });
97
107
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@house365/comate",
3
- "version": "0.9.20",
3
+ "version": "0.9.22",
4
4
  "description": "comate —— SDD (规约驱动开发) 的 AI 开发编排器(Agent Skills)",
5
5
  "type": "module",
6
6
  "license": "MIT",