@house365/comate 0.9.20 → 0.9.23

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 +42 -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`);
@@ -61,6 +68,23 @@ const SKILLS_PASSTHROUGH = new Set([
61
68
  'experimental_sync',
62
69
  ]);
63
70
 
71
+ // Flags accepted on a bare `comate [flags]` invocation — these forward to the
72
+ // implicit `skills add`. Anything else starting with `-` is a typo (e.g.
73
+ // `--vasdasd`) and must hit help instead of silently installing everything.
74
+ // --version/-v and --help/-h are intercepted earlier, so they need not be here.
75
+ const ADD_FLAGS = new Set([
76
+ '-g', '--global',
77
+ '-a', '--agent',
78
+ '-s', '--skill',
79
+ '-l', '--list',
80
+ '-y', '--yes',
81
+ '--copy',
82
+ '--metadata',
83
+ '--subagent',
84
+ '--all',
85
+ '--full-depth',
86
+ ]);
87
+
64
88
  const HELP_TEXT = `comate — SDD (规约驱动开发) 的 AI 开发编排器
65
89
 
66
90
  用法:
@@ -90,8 +114,11 @@ const packageVersion = JSON.parse(readFileSync(`${pkgRoot}/package.json`, 'utf8'
90
114
 
91
115
  if (args[0] === '--version' || args[0] === '-v') {
92
116
  console.log(packageVersion);
93
- // Check for updates in the background, non-blocking
94
- checkForUpdates(packageVersion).catch(() => {
117
+ // Await the check: without it, process.exit(0) fires synchronously and the
118
+ // process dies before the registry request resolves, so the update notice
119
+ // never prints. The check has its own 3s timeout, so a dead network stalls
120
+ // this by at most 3s.
121
+ await checkForUpdates(packageVersion).catch(() => {
95
122
  // Silently ignore network errors
96
123
  });
97
124
  process.exit(0);
@@ -132,6 +159,17 @@ if (args.length && !args[0].startsWith('-')) {
132
159
  printHelp(console.error);
133
160
  process.exit(1);
134
161
  }
162
+ } else if (args[0]?.startsWith('-')) {
163
+ // Bare-flags mode: every arg is forwarded to the implicit `skills add`. Any
164
+ // dash-prefixed arg that isn't a known install flag is a typo (e.g.
165
+ // --vasdasd). Without this it fell through and silently installed everything.
166
+ // Flag values (e.g. `-a claude-code`) don't start with `-`, so they're safe.
167
+ const bad = args.find((a) => a.startsWith('-') && !ADD_FLAGS.has(a));
168
+ if (bad) {
169
+ console.error(`comate: 未知选项 '${bad}'\n`);
170
+ printHelp(console.error);
171
+ process.exit(1);
172
+ }
135
173
  }
136
174
 
137
175
  // No args, or only flags (-g, --list, …) = install every comate skill from this
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@house365/comate",
3
- "version": "0.9.20",
3
+ "version": "0.9.23",
4
4
  "description": "comate —— SDD (规约驱动开发) 的 AI 开发编排器(Agent Skills)",
5
5
  "type": "module",
6
6
  "license": "MIT",