@house365/comate 0.2.1 → 0.2.2
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/bin/init-run.mjs +51 -2
- package/package.json +1 -1
package/bin/init-run.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// The `init` flow: install whatever the current project is missing.
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { join, resolve } from 'node:path';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
MIN_OPENSPEC,
|
|
7
7
|
NPM_TIMEOUT_MS,
|
|
8
8
|
SKILLS_TIMEOUT_MS,
|
|
9
|
+
capture,
|
|
9
10
|
npmInvocation,
|
|
10
11
|
openSpecState,
|
|
11
12
|
run,
|
|
@@ -147,6 +148,54 @@ function report(results) {
|
|
|
147
148
|
console.error(`\n${failed.length} 项失败,修好后重跑 comate init。`);
|
|
148
149
|
return 1;
|
|
149
150
|
}
|
|
150
|
-
console.log(
|
|
151
|
+
console.log(banner(pkgVersion()));
|
|
152
|
+
console.log('在 agent 中输入 /comate 开始使用,或跑 comate doctor 自检。\n');
|
|
151
153
|
return 0;
|
|
152
154
|
}
|
|
155
|
+
|
|
156
|
+
// ponytail: read package.json rather than hardcoding — npm version bumps the
|
|
157
|
+
// file, and a stale literal in the banner is worse than no version at all.
|
|
158
|
+
export function pkgVersion(root = resolve(import.meta.dirname, '..')) {
|
|
159
|
+
try {
|
|
160
|
+
return JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).version;
|
|
161
|
+
} catch {
|
|
162
|
+
return '';
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Box-drawing glyphs need a UTF-8 capable terminal. Windows consoles still
|
|
167
|
+
// default to a legacy codepage where they render as mojibake, so the wordmark
|
|
168
|
+
// only goes out when the codepage says otherwise; everything else gets the
|
|
169
|
+
// plain line. Piped output is skipped too — logos belong on screens, not in
|
|
170
|
+
// logs or CI transcripts.
|
|
171
|
+
export function banner(version, { tty = process.stdout.isTTY, utf8 = unicodeSafe() } = {}) {
|
|
172
|
+
const tag = `comate${version ? ` v${version}` : ''}`;
|
|
173
|
+
const plain = `\n ${tag} — OpenSpec + Superpowers 规约驱动开发编排器\n`;
|
|
174
|
+
if (!tty || !utf8) return plain;
|
|
175
|
+
|
|
176
|
+
const art = [
|
|
177
|
+
'██████╗ ██████╗ ███╗ ███╗ █████╗ ███████╗',
|
|
178
|
+
'██╔═══╝██╔═══██╗████╗ ████║██╔══██╗╚══██╔══╝',
|
|
179
|
+
'██║ ██║ ██║██╔████╔██║███████║ ██║',
|
|
180
|
+
'██║ ██║ ██║██║╚██╔╝██║██╔══██║ ██║',
|
|
181
|
+
'╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ██║ ██║',
|
|
182
|
+
' ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝',
|
|
183
|
+
];
|
|
184
|
+
const cyan = (s) => (process.env.NO_COLOR ? s : `\x1B[36m${s}\x1B[0m`);
|
|
185
|
+
const dim = (s) => (process.env.NO_COLOR ? s : `\x1B[2m${s}\x1B[0m`);
|
|
186
|
+
return [
|
|
187
|
+
'',
|
|
188
|
+
...art.map((line) => ` ${cyan(line)}`),
|
|
189
|
+
'',
|
|
190
|
+
` ${dim(`${tag} — OpenSpec + Superpowers 规约驱动开发编排器`)}`,
|
|
191
|
+
'',
|
|
192
|
+
].join('\n');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// POSIX terminals are UTF-8 in practice. Windows consoles are not: the legacy
|
|
196
|
+
// codepage (936, 437, …) renders box-drawing glyphs as mojibake, so ask chcp
|
|
197
|
+
// and only claim UTF-8 on 65001.
|
|
198
|
+
function unicodeSafe() {
|
|
199
|
+
if (process.platform !== 'win32') return true;
|
|
200
|
+
return /65001/.test(capture('chcp', []) ?? '');
|
|
201
|
+
}
|