@house365/comate 0.9.19 → 0.9.20

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 +56 -12
  2. package/package.json +1 -1
package/bin/cli.mjs CHANGED
@@ -44,6 +44,46 @@ async function checkForUpdates(currentVersion) {
44
44
  });
45
45
  }
46
46
 
47
+ // comate 自身的子命令(在下方被先取处理,不会透传给 skills CLI)。
48
+ const COMATE_COMMANDS = ['init', 'doctor', 'update', 'usage'];
49
+
50
+ // 允许透传给 skills CLI 的子命令(含别名)。留在这里的都是 skills CLI 真实存在
51
+ // 的命令,未列入的一律视为未知命令并命中 --help。init/update 已被 comate 先取,
52
+ // 故不在此列。
53
+ const SKILLS_PASSTHROUGH = new Set([
54
+ 'add', 'a',
55
+ 'use',
56
+ 'remove', 'rm',
57
+ 'list', 'ls',
58
+ 'find',
59
+ 'upgrade',
60
+ 'experimental_install',
61
+ 'experimental_sync',
62
+ ]);
63
+
64
+ const HELP_TEXT = `comate — SDD (规约驱动开发) 的 AI 开发编排器
65
+
66
+ 用法:
67
+ comate 安装/更新本包全部 comate skill 到当前 agent
68
+ comate init 安装 comate 和依赖到用户级,并在当前项目创建 openspec/
69
+ comate doctor 健康检查
70
+ comate update 更新 comate 到最新版本
71
+ comate usage 查看本项目 token 用量(--global 看全部;参数透传给 ccusage)
72
+ comate --help, -h 显示本帮助
73
+ comate --version, -v 显示版本号
74
+
75
+ 管理 skill(透传给 skills CLI):
76
+ comate add <包> 添加 skill 包
77
+ comate remove [名] 移除已装 skill(别名 rm)
78
+ comate list 列出已装 skill(别名 ls)
79
+ comate find [关键词] 搜索 skill
80
+
81
+ 装好后在 agent 中输入 /comate 开始使用。`;
82
+
83
+ function printHelp(stream = console.log) {
84
+ stream(HELP_TEXT);
85
+ }
86
+
47
87
  const pkgRoot = dirname(dirname(fileURLToPath(import.meta.url)));
48
88
  const args = process.argv.slice(2);
49
89
  const packageVersion = JSON.parse(readFileSync(`${pkgRoot}/package.json`, 'utf8')).version;
@@ -77,22 +117,26 @@ if (args[0] === 'usage') {
77
117
  process.exit(await usage(args.slice(1), { pkgRoot }));
78
118
  }
79
119
 
80
- if (args[0] === '--help' || args[0] === '-h') {
81
- console.log(`comate — SDD (规约驱动开发) 的 AI 开发编排器
82
-
83
- 用法:
84
- comate init 安装 comate 和依赖到用户级,并在当前项目创建 openspec/
85
- comate doctor 健康检查
86
- comate update 更新 comate 到最新版本
87
- comate usage 查看本项目 token 用量(--global 看全部;参数透传给 ccusage)
88
-
89
- 装好后在 agent 中输入 /comate 开始使用。`);
120
+ if (args[0] === '--help' || args[0] === '-h' || args[0] === 'help') {
121
+ printHelp();
90
122
  process.exit(0);
91
123
  }
92
124
 
125
+ // A leading token that is neither a flag, a comate command, nor a known skills
126
+ // passthrough command is an unknown command. Print help to stderr and exit 1 so
127
+ // typos surface as usage guidance instead of an opaque skills CLI error.
128
+ if (args.length && !args[0].startsWith('-')) {
129
+ const cmd = args[0];
130
+ if (!COMATE_COMMANDS.includes(cmd) && !SKILLS_PASSTHROUGH.has(cmd)) {
131
+ console.error(`comate: 未知命令 '${cmd}'\n`);
132
+ printHelp(console.error);
133
+ process.exit(1);
134
+ }
135
+ }
136
+
93
137
  // No args, or only flags (-g, --list, …) = install every comate skill from this
94
- // package, forwarding the flags. A leading subcommand passes straight through,
95
- // so remove/list/update all still work.
138
+ // package, forwarding the flags. A leading passthrough subcommand goes straight
139
+ // through, so add/remove/list all still work.
96
140
  const argv =
97
141
  args.length && !args[0].startsWith('-') ? args : ['add', pkgRoot, '--skill', '*', ...args];
98
142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@house365/comate",
3
- "version": "0.9.19",
3
+ "version": "0.9.20",
4
4
  "description": "comate —— SDD (规约驱动开发) 的 AI 开发编排器(Agent Skills)",
5
5
  "type": "module",
6
6
  "license": "MIT",