@routerhub/agent-rules 1.5.28 → 1.5.29
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/package.json +1 -1
- package/postinstall.js +8 -60
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -1,63 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// 安全检查:如果项目根目录在 node_modules 内,说明 INIT_CWD 未正确设置,跳过初始化
|
|
13
|
-
if (projectRoot.includes("node_modules")) {
|
|
14
|
-
console.log("[agent-rules] 检测到在 node_modules 内运行,跳过自动初始化");
|
|
15
|
-
console.log("[agent-rules] 请手动执行: npx agent-rules init");
|
|
16
|
-
process.exit(0);
|
|
17
|
-
}
|
|
18
|
-
|
|
3
|
+
// 安装完成后仅打印提示,不再自动初始化规则文件
|
|
4
|
+
// 如需生成规则文件,请手动执行对应命令
|
|
5
|
+
console.log("");
|
|
6
|
+
console.log("[agent-rules] 安装完成,如需手动操作:");
|
|
7
|
+
console.log(" - 初始化规则: npx agent-rules init");
|
|
8
|
+
console.log(" - 同步规则: npx agent-rules sync");
|
|
9
|
+
console.log(" - 启动监听: npx agent-rules watch");
|
|
10
|
+
console.log(" - 查看帮助: npx agent-rules help");
|
|
19
11
|
console.log("");
|
|
20
|
-
console.log("[agent-rules] 安装完成");
|
|
21
|
-
console.log(`[agent-rules] 项目根目录: ${projectRoot}`);
|
|
22
|
-
console.log("[agent-rules] 正在初始化规则文件...");
|
|
23
|
-
|
|
24
|
-
// 第一步:执行初始化,生成 AGENTS.md 和 .github/copilot-instructions.md
|
|
25
|
-
const initProcess = spawn("node", [mergeScriptPath, "init"], {
|
|
26
|
-
cwd: projectRoot,
|
|
27
|
-
stdio: "inherit",
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
initProcess.on("close", (code) => {
|
|
31
|
-
if (code === 0) {
|
|
32
|
-
console.log("[agent-rules] 规则文件初始化完成");
|
|
33
|
-
console.log("[agent-rules] 正在启动后台监听进程...");
|
|
34
|
-
|
|
35
|
-
// 第二步:在后台启动 watch 模式
|
|
36
|
-
const watchProcess = spawn("node", [mergeScriptPath, "watch"], {
|
|
37
|
-
cwd: projectRoot,
|
|
38
|
-
detached: true,
|
|
39
|
-
stdio: "ignore",
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// 将 watch 进程从父进程分离,允许其独立运行
|
|
43
|
-
watchProcess.unref();
|
|
44
|
-
|
|
45
|
-
console.log("[agent-rules] 后台监听进程已启动");
|
|
46
|
-
console.log(
|
|
47
|
-
"[agent-rules] AGENTS.private.md 的变更将自动同步到 AGENTS.md、.github/copilot-instructions.md 和 .github/instructions/*.instructions.md",
|
|
48
|
-
);
|
|
49
|
-
console.log("");
|
|
50
|
-
console.log("[agent-rules] 手动命令:");
|
|
51
|
-
console.log(" - 初始化: npx agent-rules init");
|
|
52
|
-
console.log(" - 同步规则: npx agent-rules sync");
|
|
53
|
-
console.log(" - 启动监听: npx agent-rules watch");
|
|
54
|
-
console.log(" - 查看帮助: npx agent-rules help");
|
|
55
|
-
console.log("");
|
|
56
|
-
} else {
|
|
57
|
-
console.error("[agent-rules] 初始化失败,退出码:", code);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
initProcess.on("error", (err) => {
|
|
62
|
-
console.error("[agent-rules] 初始化过程出错:", err.message);
|
|
63
|
-
});
|