@house365/comate 0.1.1 → 0.1.3
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/README.md +10 -2
- package/bin/cli.mjs +3 -1
- package/bin/init-run.mjs +62 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,12 +25,20 @@ open → design → build → verify → archive
|
|
|
25
25
|
## 安装
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
|
|
29
|
-
npx @house365/comate init
|
|
28
|
+
cd <你的项目目录>
|
|
29
|
+
npx @house365/comate init # 装到 ./.agents/skills/
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
装到用户全局,所有项目可用(此时在哪个目录执行都一样):
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx @house365/comate init -g # 装到 ~/.agents/skills/
|
|
30
36
|
```
|
|
31
37
|
|
|
32
38
|
`init` 会一并装齐两个依赖(OpenSpec CLI、Superpowers),已装的自动跳过,可重复执行。
|
|
33
39
|
|
|
40
|
+
项目安装的目标目录就是**你执行命令时所在的目录**。init 会先打印完整路径,并在目录看起来不像项目(没有 `.git`、`package.json` 等标志)或就是你的主目录时中止,避免装错地方——确实要装在当前目录就加 `--force`。
|
|
41
|
+
|
|
34
42
|
只装 comate 本身、不碰依赖:
|
|
35
43
|
|
|
36
44
|
```bash
|
package/bin/cli.mjs
CHANGED
|
@@ -20,10 +20,12 @@ if (args[0] === '--help' || args[0] === '-h') {
|
|
|
20
20
|
console.log(`comate — OpenSpec + Superpowers 规约驱动的开发编排器
|
|
21
21
|
|
|
22
22
|
用法:
|
|
23
|
-
comate-skills init [-g] [--openspec-init]
|
|
23
|
+
comate-skills init [-g] [--openspec-init] [--force]
|
|
24
24
|
安装 comate 及依赖 (OpenSpec CLI、Superpowers)。已装的自动跳过,可重复执行。
|
|
25
|
+
项目安装装到当前目录,执行前会打印完整路径并确认这像个项目目录。
|
|
25
26
|
-g, --global 安装到用户全局目录 (默认: 当前项目)
|
|
26
27
|
--openspec-init 同时运行 openspec init 创建项目结构
|
|
28
|
+
-f, --force 跳过目录检查,就装在当前目录
|
|
27
29
|
|
|
28
30
|
comate-skills [add|list|remove|update ...]
|
|
29
31
|
直接透传给 skills CLI。不带子命令时安装本包全部 skill。
|
package/bin/init-run.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// The `init` flow: pick a scope, then install what's missing.
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
MIN_OPENSPEC,
|
|
@@ -18,12 +19,67 @@ export function resolveScope(argv) {
|
|
|
18
19
|
return argv.includes('-g') || argv.includes('--global') ? 'global' : 'project';
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
// A project install lands in cwd, and `npx` runs wherever the user happens to
|
|
23
|
+
// be — so cwd is a guess, not a decision. Report it, and refuse the two cases
|
|
24
|
+
// that are almost certainly a mistake: the home directory (that's what -g is
|
|
25
|
+
// for) and a directory with no project marker at all.
|
|
26
|
+
const PROJECT_MARKERS = [
|
|
27
|
+
'.git',
|
|
28
|
+
'package.json',
|
|
29
|
+
'pyproject.toml',
|
|
30
|
+
'Cargo.toml',
|
|
31
|
+
'go.mod',
|
|
32
|
+
'pom.xml',
|
|
33
|
+
'build.gradle',
|
|
34
|
+
'composer.json',
|
|
35
|
+
'Gemfile',
|
|
36
|
+
'openspec',
|
|
37
|
+
'.agents',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export function inspectTarget(dir, home) {
|
|
41
|
+
const normalise = (p) => resolve(p).replace(/[\\/]+$/, '').toLowerCase();
|
|
42
|
+
if (home && normalise(dir) === normalise(home)) return { kind: 'home' };
|
|
43
|
+
const marker = PROJECT_MARKERS.find((m) => existsSync(join(dir, m)));
|
|
44
|
+
return marker ? { kind: 'project', marker } : { kind: 'bare' };
|
|
45
|
+
}
|
|
46
|
+
|
|
21
47
|
export async function init(pkgRoot, argv) {
|
|
22
48
|
const scope = resolveScope(argv);
|
|
23
49
|
const withOpenSpecInit = argv.includes('--openspec-init');
|
|
50
|
+
const force = argv.includes('-f') || argv.includes('--force');
|
|
24
51
|
const results = [];
|
|
25
52
|
|
|
26
|
-
|
|
53
|
+
const home = process.env.HOME ?? process.env.USERPROFILE ?? '';
|
|
54
|
+
if (scope === 'global') {
|
|
55
|
+
console.log(`\n安装范围: 全局 -> ${join(home, '.agents', 'skills')}\n`);
|
|
56
|
+
} else {
|
|
57
|
+
const cwd = process.cwd();
|
|
58
|
+
const target = inspectTarget(cwd, home);
|
|
59
|
+
console.log(`\n安装范围: 项目 -> ${join(cwd, '.agents', 'skills')}`);
|
|
60
|
+
|
|
61
|
+
if (target.kind === 'home' && !force) {
|
|
62
|
+
console.error(`
|
|
63
|
+
这是你的用户主目录。装到这里通常不是你想要的——想让所有项目都能用,请加 -g:
|
|
64
|
+
|
|
65
|
+
comate-skills init -g
|
|
66
|
+
|
|
67
|
+
确实要装在这里,加 --force。`);
|
|
68
|
+
return 1;
|
|
69
|
+
}
|
|
70
|
+
if (target.kind === 'bare' && !force) {
|
|
71
|
+
console.error(`
|
|
72
|
+
当前目录看不出是个项目(没有 .git / package.json / pyproject.toml 等标志)。
|
|
73
|
+
comate 会把 skill 装进上面这个路径,先确认这是你要的目录:
|
|
74
|
+
|
|
75
|
+
cd <你的项目目录> && npx @house365/comate init # 换个目录
|
|
76
|
+
npx @house365/comate init -g # 装到全局,所有项目可用
|
|
77
|
+
npx @house365/comate init --force # 就装在这里`);
|
|
78
|
+
return 1;
|
|
79
|
+
}
|
|
80
|
+
if (target.kind === 'project') console.log(`检测到项目标志: ${target.marker}`);
|
|
81
|
+
console.log('');
|
|
82
|
+
}
|
|
27
83
|
|
|
28
84
|
// 1. OpenSpec CLI — a PATH command, so global regardless of skill scope.
|
|
29
85
|
const os = openSpecState();
|
|
@@ -91,9 +147,11 @@ function report(results, scope) {
|
|
|
91
147
|
console.error(`\n${failed.length} 项失败。修复后可重跑 comate-skills init(已安装的会自动跳过)。`);
|
|
92
148
|
return 1;
|
|
93
149
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
150
|
+
// Absolute path: the user should not have to work out which directory this
|
|
151
|
+
// landed in, which is the whole problem with a cwd-relative install.
|
|
152
|
+
const root = scope === 'global' ? (process.env.HOME ?? process.env.USERPROFILE ?? '~') : process.cwd();
|
|
153
|
+
const doctorPath = join(root, '.agents', 'skills', 'comate', 'scripts', 'comate.sh');
|
|
154
|
+
console.log(`\n完成。健康检查: bash "${doctorPath}" doctor`);
|
|
97
155
|
console.log('在 agent 中输入 /comate 开始使用。');
|
|
98
156
|
return 0;
|
|
99
157
|
}
|