@routerhub/agent-rules 1.4.3 → 1.4.5
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 +7 -0
- package/package.json +1 -1
- package/postinstall.js +29 -27
package/AGENTS.base.md
CHANGED
|
@@ -39,6 +39,12 @@
|
|
|
39
39
|
- 时间相关处理统一使用 `dayjs`。
|
|
40
40
|
- 数据回显优先使用对象展开运算符(`...`)。
|
|
41
41
|
|
|
42
|
+
## 前端 API 生成规范
|
|
43
|
+
|
|
44
|
+
- 前端 API 请求必须严格使用 OpenAPI 生成的 API 方法,禁止手写请求方法或绕过生成层直接调用接口。
|
|
45
|
+
- 新增或变更接口后,必须先更新 OpenAPI 定义并重新生成 API 代码,再进行业务开发与联调。
|
|
46
|
+
- 禁止在业务代码中直接拼接接口路径、手动声明重复请求类型或复制粘贴旧请求实现。
|
|
47
|
+
|
|
42
48
|
## 生产环境操作安全规则
|
|
43
49
|
|
|
44
50
|
- **严禁在未明确授权时操作线上/生产服务器**:只有当用户的指令中明确包含"生产环境"、"线上"、"prod"、"production"等关键词时,才允许在生产服务器上执行任何操作(如部署、重启、修改配置、执行脚本等)。
|
|
@@ -58,6 +64,7 @@
|
|
|
58
64
|
- 分支名称使用英文,单词间用中划线(-)分隔,全小写,简洁明了。
|
|
59
65
|
- 禁止使用下划线、大写字母、中文或特殊字符。
|
|
60
66
|
- 当用户要求提交本次修改时,git commit 提交信息必须使用中文描述,禁止使用英文。
|
|
67
|
+
- **严禁使用 `git push --force` 或 `git push -f`**:AI 在任何情况下都不得执行 force push 操作,避免覆盖远程提交历史、丢失他人代码。如确需强制推送,必须由用户手动执行。
|
|
61
68
|
|
|
62
69
|
## 代码风格与结构
|
|
63
70
|
|
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -1,53 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { spawn } = require(
|
|
4
|
-
const path = require(
|
|
5
|
-
const fs = require(
|
|
3
|
+
const { spawn } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const fs = require("fs");
|
|
6
6
|
|
|
7
7
|
// 获取当前工作目录(下游项目根目录)
|
|
8
8
|
const projectRoot = process.cwd();
|
|
9
9
|
const packageRoot = __dirname;
|
|
10
|
-
const mergeScriptPath = path.join(packageRoot,
|
|
10
|
+
const mergeScriptPath = path.join(packageRoot, "merge.js");
|
|
11
11
|
|
|
12
|
-
console.log(
|
|
13
|
-
console.log(
|
|
14
|
-
console.log(
|
|
12
|
+
console.log("");
|
|
13
|
+
console.log("[agent-rules] 安装完成");
|
|
14
|
+
console.log("[agent-rules] 正在初始化规则文件...");
|
|
15
15
|
|
|
16
16
|
// 第一步:执行初始化,生成 AGENTS.md 和 .github/copilot-instructions.md
|
|
17
|
-
const initProcess = spawn(
|
|
17
|
+
const initProcess = spawn("node", [mergeScriptPath, "init"], {
|
|
18
18
|
cwd: projectRoot,
|
|
19
|
-
stdio:
|
|
19
|
+
stdio: "inherit",
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
initProcess.on(
|
|
22
|
+
initProcess.on("close", (code) => {
|
|
23
23
|
if (code === 0) {
|
|
24
|
-
console.log(
|
|
25
|
-
console.log(
|
|
24
|
+
console.log("[agent-rules] 规则文件初始化完成");
|
|
25
|
+
console.log("[agent-rules] 正在启动后台监听进程...");
|
|
26
26
|
|
|
27
27
|
// 第二步:在后台启动 watch 模式
|
|
28
|
-
const watchProcess = spawn(
|
|
28
|
+
const watchProcess = spawn("node", [mergeScriptPath, "watch"], {
|
|
29
29
|
cwd: projectRoot,
|
|
30
30
|
detached: true,
|
|
31
|
-
stdio:
|
|
31
|
+
stdio: "ignore",
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
// 将 watch 进程从父进程分离,允许其独立运行
|
|
35
35
|
watchProcess.unref();
|
|
36
36
|
|
|
37
|
-
console.log(
|
|
38
|
-
console.log(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
console.log(
|
|
42
|
-
console.log(
|
|
43
|
-
console.log(
|
|
44
|
-
console.log(
|
|
45
|
-
console.log(
|
|
37
|
+
console.log("[agent-rules] 后台监听进程已启动");
|
|
38
|
+
console.log(
|
|
39
|
+
"[agent-rules] AGENTS.private.md 的变更将自动同步到 AGENTS.md 和 .github/copilot-instructions.md",
|
|
40
|
+
);
|
|
41
|
+
console.log("");
|
|
42
|
+
console.log("[agent-rules] 手动命令:");
|
|
43
|
+
console.log(" - 初始化: npx agent-rules init");
|
|
44
|
+
console.log(" - 同步规则: npx agent-rules sync");
|
|
45
|
+
console.log(" - 启动监听: npx agent-rules watch");
|
|
46
|
+
console.log(" - 查看帮助: npx agent-rules help");
|
|
47
|
+
console.log("");
|
|
46
48
|
} else {
|
|
47
|
-
console.error(
|
|
49
|
+
console.error("[agent-rules] 初始化失败,退出码:", code);
|
|
48
50
|
}
|
|
49
51
|
});
|
|
50
52
|
|
|
51
|
-
initProcess.on(
|
|
52
|
-
console.error(
|
|
53
|
-
});
|
|
53
|
+
initProcess.on("error", (err) => {
|
|
54
|
+
console.error("[agent-rules] 初始化过程出错:", err.message);
|
|
55
|
+
});
|