@routerhub/agent-rules 1.4.1 → 1.4.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/AGENTS.base.md +12 -3
- package/package.json +1 -1
- package/postinstall.js +51 -7
package/AGENTS.base.md
CHANGED
|
@@ -45,9 +45,18 @@
|
|
|
45
45
|
- 若用户指令中没有上述关键词,默认只在本地或测试/开发环境中执行操作,不得擅自连接或操作生产服务器。
|
|
46
46
|
- 执行生产环境操作前,必须再次向用户确认目标环境,确认无误后方可执行。
|
|
47
47
|
|
|
48
|
-
##
|
|
49
|
-
|
|
50
|
-
-
|
|
48
|
+
## 分支管理规范(Git Flow)
|
|
49
|
+
|
|
50
|
+
- 所有新建分支必须遵循 Git Flow 命名规范,使用以下前缀:
|
|
51
|
+
- `feature/` - 新功能开发(如 `feature/user-authentication`)
|
|
52
|
+
- `refactor/` - 代码重构(如 `refactor/payment-module`)
|
|
53
|
+
- `bugfix/` - 缺陷修复(如 `bugfix/order-calculation`)
|
|
54
|
+
- `hotfix/` - 紧急生产修复(如 `hotfix/critical-security-issue`)
|
|
55
|
+
- `chore/` - 杂项维护(如 `chore/upgrade-dependencies`)
|
|
56
|
+
- `docs/` - 文档更新(如 `docs/api-reference`)
|
|
57
|
+
- `test/` - 测试相关(如 `test/add-unit-tests`)
|
|
58
|
+
- 分支名称使用英文,单词间用中划线(-)分隔,全小写,简洁明了。
|
|
59
|
+
- 禁止使用下划线、大写字母、中文或特殊字符。
|
|
51
60
|
- 当用户要求提交本次修改时,git commit 提交信息必须使用中文描述,禁止使用英文。
|
|
52
61
|
|
|
53
62
|
## 代码风格与结构
|
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -1,9 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
|
|
7
|
+
// 获取当前工作目录(下游项目根目录)
|
|
8
|
+
const projectRoot = process.cwd();
|
|
9
|
+
const packageRoot = __dirname;
|
|
10
|
+
const mergeScriptPath = path.join(packageRoot, 'merge.js');
|
|
11
|
+
|
|
12
|
+
console.log('');
|
|
13
|
+
console.log('[agent-rules] 安装完成');
|
|
14
|
+
console.log('[agent-rules] 正在初始化规则文件...');
|
|
15
|
+
|
|
16
|
+
// 第一步:执行初始化,生成 AGENTS.md 和 .github/copilot-instructions.md
|
|
17
|
+
const initProcess = spawn('node', [mergeScriptPath, 'init'], {
|
|
18
|
+
cwd: projectRoot,
|
|
19
|
+
stdio: 'inherit',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
initProcess.on('close', (code) => {
|
|
23
|
+
if (code === 0) {
|
|
24
|
+
console.log('[agent-rules] 规则文件初始化完成');
|
|
25
|
+
console.log('[agent-rules] 正在启动后台监听进程...');
|
|
26
|
+
|
|
27
|
+
// 第二步:在后台启动 watch 模式
|
|
28
|
+
const watchProcess = spawn('node', [mergeScriptPath, 'watch'], {
|
|
29
|
+
cwd: projectRoot,
|
|
30
|
+
detached: true,
|
|
31
|
+
stdio: 'ignore',
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// 将 watch 进程从父进程分离,允许其独立运行
|
|
35
|
+
watchProcess.unref();
|
|
36
|
+
|
|
37
|
+
console.log('[agent-rules] 后台监听进程已启动');
|
|
38
|
+
console.log('[agent-rules] AGENTS.private.md 的变更将自动同步到 AGENTS.md 和 .github/copilot-instructions.md');
|
|
39
|
+
console.log('');
|
|
40
|
+
console.log('[agent-rules] 手动命令:');
|
|
41
|
+
console.log(' - 初始化: npx agent-rules init');
|
|
42
|
+
console.log(' - 同步规则: npx agent-rules sync');
|
|
43
|
+
console.log(' - 启动监听: npx agent-rules watch');
|
|
44
|
+
console.log(' - 查看帮助: npx agent-rules help');
|
|
45
|
+
console.log('');
|
|
46
|
+
} else {
|
|
47
|
+
console.error('[agent-rules] 初始化失败,退出码:', code);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
initProcess.on('error', (err) => {
|
|
52
|
+
console.error('[agent-rules] 初始化过程出错:', err.message);
|
|
53
|
+
});
|