@routerhub/agent-rules 1.5.98 → 1.5.99

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 +9 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routerhub/agent-rules",
3
- "version": "1.5.98",
3
+ "version": "1.5.99",
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
@@ -59,10 +59,14 @@ if (projectRoot.includes("node_modules")) {
59
59
  process.exit(0);
60
60
  }
61
61
 
62
- // 确保下游项目 .npmrc 中关闭 frozen-lockfile + 启用依赖 pre/post 脚本
62
+ // 确保下游项目 .npmrc 中关闭 frozen-lockfile + 启用依赖 pre/post 脚本 + 关闭副作用缓存
63
63
  // frozen-lockfile=false:让 pnpm install 能在版本更新后直接执行
64
64
  // enable-pre-post-scripts=true:让 pnpm 始终执行依赖包的 postinstall 生命周期脚本,
65
65
  // 否则 pnpm 默认不会运行依赖的 postinstall,导致 agent-rules 更新后规则文件不刷新
66
+ // side-effects-cache=false:pnpm 会按包内容哈希跨项目缓存"是否已执行过构建脚本",
67
+ // 一旦同一版本在本机任意项目装过一次,其他新项目直接装/更新该版本会被静默跳过 postinstall,
68
+ // 而 agent-rules 的 postinstall 恰恰是往下游项目根目录写文件(不是往自身 node_modules 写副作用),
69
+ // 关闭该缓存让 pnpm 每次都真正重新执行脚本
66
70
  const npmrcPath = path.join(projectRoot, ".npmrc");
67
71
  let npmrcContent = "";
68
72
  if (fs.existsSync(npmrcPath)) {
@@ -77,6 +81,10 @@ if (!npmrcContent.includes("enable-pre-post-scripts")) {
77
81
  npmrcEntries.push("# 确保依赖包的 postinstall 生命周期脚本始终执行(由 agent-rules 自动添加)");
78
82
  npmrcEntries.push("enable-pre-post-scripts=true");
79
83
  }
84
+ if (!npmrcContent.includes("side-effects-cache")) {
85
+ npmrcEntries.push("# 关闭 pnpm 跨项目构建缓存,确保 agent-rules 每次 install/update 都重新生成规则文件(由 agent-rules 自动添加)");
86
+ npmrcEntries.push("side-effects-cache=false");
87
+ }
80
88
  if (npmrcEntries.length > 0) {
81
89
  const newEntry = "\n" + npmrcEntries.join("\n") + "\n";
82
90
  fs.appendFileSync(npmrcPath, newEntry);