@routerhub/agent-rules 1.5.45 → 1.5.46

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 CHANGED
@@ -18,6 +18,14 @@ pnpm i -D @routerhub/agent-rules
18
18
 
19
19
  写完 `AGENTS.private.md` 后,工具会自动生成项目可用的 `AGENTS.md` 和 `.github/copilot-instructions.md`。
20
20
 
21
+ 首次执行 `pnpm i -D @routerhub/agent-rules` 时,会自动执行初始化:
22
+
23
+ - 自动生成 `AGENTS.md`
24
+ - 自动生成 `CLAUDE.md`
25
+ - 自动生成 `.github/copilot-instructions.md`
26
+ - 自动生成 `.github/instructions/*.instructions.md`
27
+ - 如果当前项目还没有 `AGENTS.private.md`,会自动创建模板文件
28
+
21
29
  ## 更新
22
30
 
23
31
  当 `@routerhub/agent-rules` 有新版本时,锁文件不会自动追最新,需要手动更新:
@@ -32,4 +40,10 @@ pnpm update @routerhub/agent-rules --latest
32
40
 
33
41
  ---
34
42
 
35
- 注意:pnpm i 的时候会启动一个watch函数自动帮你合并AGENTS.privite.md中的内容到AGENTS.md,所以建议给项目配置一键启动脚本来,一键启动脚本里加上先pnpm i然后再启动每个项目
43
+ 注意:`pnpm i` 只会自动执行一次初始化或同步,不会常驻启动 watch
44
+
45
+ 如果你希望修改 `AGENTS.private.md` 后自动重新生成规则文件,需要手动执行:
46
+
47
+ ```bash
48
+ pnpm exec agent-rules watch
49
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routerhub/agent-rules",
3
- "version": "1.5.45",
3
+ "version": "1.5.46",
4
4
  "description": "Shared Copilot agent rules and guidelines for RouterHub projects",
5
5
  "main": "AGENTS.base.md",
6
6
  "bin": {
@@ -19,6 +19,7 @@
19
19
  ],
20
20
  "scripts": {
21
21
  "build": "node --check merge.js && node --check postinstall.js",
22
+ "test:postinstall-init": "node tests/postinstall-init.test.js",
22
23
  "merge": "node merge.js",
23
24
  "sync": "node merge.js sync",
24
25
  "init": "node merge.js init",
package/postinstall.js CHANGED
@@ -72,23 +72,23 @@ if (!npmrcContent.includes("frozen-lockfile")) {
72
72
  }
73
73
 
74
74
  console.log("");
75
- console.log("[agent-rules] 安装完成,正在同步规则文件...");
75
+ console.log("[agent-rules] 安装完成,正在初始化规则文件...");
76
76
 
77
- // 执行 sync 生成所有规则输出文件
78
- const syncProcess = spawn("node", [mergeScriptPath, "sync"], {
77
+ // 执行 init,首次安装时自动补齐 AGENTS.private.md 模板并生成规则输出文件
78
+ const syncProcess = spawn("node", [mergeScriptPath, "init"], {
79
79
  cwd: projectRoot,
80
80
  stdio: "inherit",
81
81
  });
82
82
 
83
83
  syncProcess.on("close", (code) => {
84
84
  if (code === 0) {
85
- console.log("[agent-rules] 规则文件同步完成");
85
+ console.log("[agent-rules] 规则文件初始化完成");
86
86
  console.log("");
87
87
  } else {
88
- console.error("[agent-rules] 同步失败,退出码:", code);
88
+ console.error("[agent-rules] 初始化失败,退出码:", code);
89
89
  }
90
90
  });
91
91
 
92
92
  syncProcess.on("error", (err) => {
93
- console.error("[agent-rules] 同步过程出错:", err.message);
93
+ console.error("[agent-rules] 初始化过程出错:", err.message);
94
94
  });