@routerhub/agent-rules 1.5.2 → 1.5.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/postinstall.js +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routerhub/agent-rules",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Shared Copilot agent rules and guidelines for RouterHub projects",
5
5
  "main": "AGENTS.base.md",
6
6
  "bin": {
package/postinstall.js CHANGED
@@ -4,13 +4,21 @@ const { spawn } = require("child_process");
4
4
  const path = require("path");
5
5
  const fs = require("fs");
6
6
 
7
- // 获取当前工作目录(下游项目根目录)
8
- const projectRoot = process.cwd();
7
+ // 获取下游项目根目录(INIT_CWD 是 npm/pnpm 执行 install 时的原始目录)
8
+ const projectRoot = process.env.INIT_CWD || process.cwd();
9
9
  const packageRoot = __dirname;
10
10
  const mergeScriptPath = path.join(packageRoot, "merge.js");
11
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
+
12
19
  console.log("");
13
20
  console.log("[agent-rules] 安装完成");
21
+ console.log(`[agent-rules] 项目根目录: ${projectRoot}`);
14
22
  console.log("[agent-rules] 正在初始化规则文件...");
15
23
 
16
24
  // 第一步:执行初始化,生成 AGENTS.md 和 .github/copilot-instructions.md