rulemux 0.2.2 → 0.2.4
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 +9 -4
- package/README.zh-CN.md +5 -4
- package/dist/rulemux-darwin-amd64 +0 -0
- package/dist/rulemux-darwin-arm64 +0 -0
- package/dist/rulemux-linux-amd64 +0 -0
- package/dist/rulemux-linux-arm64 +0 -0
- package/dist/rulemux-windows-amd64.exe +0 -0
- package/package.json +1 -2
- package/bin/postinstall.js +0 -87
package/README.md
CHANGED
|
@@ -75,9 +75,14 @@ There is **no auto-update**. Upgrades are manual and handled by your package man
|
|
|
75
75
|
(`go install …@latest`, Homebrew/Scoop/apt later on). This is a deliberate decision — see
|
|
76
76
|
[design/requirements.md](docs/design/requirements.md) §五.
|
|
77
77
|
|
|
78
|
-
**An upgrade keeps your hooks current.** A hook command can
|
|
79
|
-
`--hook`), so
|
|
80
|
-
|
|
78
|
+
**An upgrade keeps your hooks current — by itself, with no npm install scripts.** A hook command can
|
|
79
|
+
change between releases (0.2.0 added `--hook`), so rulemux fixes its own stale hook the next time an
|
|
80
|
+
agent runs it: the first `rulemux sync` after an upgrade rewrites rulemux's own SessionStart entry
|
|
81
|
+
into the current format. Nothing else is touched — other tools' hooks and every other key stay as they
|
|
82
|
+
were, and nothing is ever created. Because this lives in the binary, it works no matter how rulemux was
|
|
83
|
+
installed and needs no `postinstall` allow-list from npm.
|
|
84
|
+
|
|
85
|
+
You can also do it on demand:
|
|
81
86
|
|
|
82
87
|
```bash
|
|
83
88
|
rulemux init --refresh # rewrite rulemux's OWN hooks only: never installs, never creates files
|
|
@@ -224,7 +229,7 @@ shown the list of workspaces before anything is deleted.
|
|
|
224
229
|
| `rulemux sync --all [--config <path>]` | Manually re-align every workspace recorded in the ledger (never reads cwd, never creates dirs, prunes ledger entries whose directory is gone). Mutually exclusive with `--hook` / `--agent` / `--workspace` |
|
|
225
230
|
| `rulemux inject --agent <id> [--config <path>]` | Tier-2: print rules to stdout for hook injection |
|
|
226
231
|
| `rulemux init --agent <id[,id...]> [--config <path>] [--workspace <dir>]` | Write a sample config and install the SessionStart hook |
|
|
227
|
-
| `rulemux init --refresh [--agent <id[,id...]>] [--workspace <dir>]` | Refresh **only** the hooks rulemux already installed
|
|
232
|
+
| `rulemux init --refresh [--agent <id[,id...]>] [--workspace <dir>]` | Refresh **only** the hooks rulemux already installed. This also happens by itself on the first sync after an upgrade; use this to force it. Never adds a hook, never creates a file or directory, preserves every other entry and key in the host config |
|
|
228
233
|
| `rulemux doctor [--config <path>] [--workspace <dir>]` | Environment self-check |
|
|
229
234
|
| `rulemux verify --agent <id> [--clean] [--workspace <dir>]` | Canary acceptance test |
|
|
230
235
|
| `rulemux uninstall --agent <id[,id...]> \| --off \| --all [--yes]` | Remove hooks and delivered files |
|
package/README.zh-CN.md
CHANGED
|
@@ -67,9 +67,10 @@ npm i -g rulemux
|
|
|
67
67
|
**没有自动更新**。升级手动、交给包管理器(`go install …@latest`,将来 Homebrew / Scoop / apt)。
|
|
68
68
|
这是刻意决策,见 [`docs/design/requirements.md`](docs/design/requirements.md) §五。
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
**升级后钩子会自己跟上当前格式——不依赖 npm 的安装脚本。** 钩子命令会随版本变化(0.2.0 起加了
|
|
71
|
+
`--hook`),所以升级后**首次**有 Agent 调起 `rulemux sync` 时,它会**只重写 rulemux 自己装过的那条**
|
|
72
|
+
SessionStart 钩子为当前格式 —— 别的条目、别的键一个字节都不动,也绝不创建任何文件。这段逻辑在二进制
|
|
73
|
+
里,因此**任何安装方式都生效**,也不需要 npm 放行任何安装脚本。想立刻手动做一次:
|
|
73
74
|
|
|
74
75
|
```bash
|
|
75
76
|
rulemux init --refresh # 只刷新「我们自己装过的」钩子:不新增、不创建任何文件或目录
|
|
@@ -209,7 +210,7 @@ rulemux uninstall --agent codebuddy --yes # 跳过交互确认
|
|
|
209
210
|
| `rulemux sync --all [--config <path>]` | 手动把账本里记录过的所有工作区重新对齐(不读 cwd、绝不创建目录、顺手 GC 掉目录已不在的条目)。与 `--hook` / `--agent` / `--workspace` 互斥 |
|
|
210
211
|
| `rulemux inject --agent <id> [--config <path>]` | Tier-2:把规则输出到 stdout 供钩子注入 |
|
|
211
212
|
| `rulemux init --agent <id[,id...]> [--config <path>] [--workspace <dir>]` | 生成示例配置并安装 SessionStart 钩子 |
|
|
212
|
-
| `rulemux init --refresh [--agent <id[,id...]>] [--workspace <dir>]` | **只刷新** rulemux
|
|
213
|
+
| `rulemux init --refresh [--agent <id[,id...]>] [--workspace <dir>]` | **只刷新** rulemux 自己装过的钩子(升级后首次 `sync` 会自动做一次,这条用于手动强制):不新增、不创建任何文件或目录、文件里其它条目与其它键一律原样保留 |
|
|
213
214
|
| `rulemux doctor [--config <path>] [--workspace <dir>]` | 环境自检 |
|
|
214
215
|
| `rulemux verify --agent <id> [--clean] [--workspace <dir>]` | canary 验收 |
|
|
215
216
|
| `rulemux uninstall --agent <id[,id...]> \| --off \| --all [--yes]` | 移除钩子与已投递文件 |
|
|
Binary file
|
|
Binary file
|
package/dist/rulemux-linux-amd64
CHANGED
|
Binary file
|
package/dist/rulemux-linux-arm64
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rulemux",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "One set of rules, delivered to every AI coding agent: copies the rule files you declare into each agent's native workspace rules directory, with the same effect and token cost as writing AGENTS.md by hand.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build:dist": "bash scripts/build-dist.sh",
|
|
26
|
-
"postinstall": "node bin/postinstall.js",
|
|
27
26
|
"prepublishOnly": "npm run build:dist"
|
|
28
27
|
},
|
|
29
28
|
"engines": {
|
package/bin/postinstall.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
// npm postinstall: bring rulemux's own SessionStart hooks up to date after a
|
|
5
|
-
// global install/upgrade.
|
|
6
|
-
//
|
|
7
|
-
// Why: a hook command can change between releases (0.2.0 added `--hook`). Users
|
|
8
|
-
// who upgraded but never re-ran `init` would silently keep the old behaviour,
|
|
9
|
-
// so the upgrade itself refreshes what it previously wrote.
|
|
10
|
-
//
|
|
11
|
-
// Deliberate limits — this script must never surprise anyone:
|
|
12
|
-
// - global installs only: a project-local `npm i rulemux` must not touch the
|
|
13
|
-
// user's host config;
|
|
14
|
-
// - skipped under CI, sudo and --ignore-scripts: $HOME would point at the
|
|
15
|
-
// wrong user, or the run is not a real user's machine;
|
|
16
|
-
// - it never installs anything new: only hooks rulemux itself already wrote;
|
|
17
|
-
// - it never fails the install: every error path exits 0, silently.
|
|
18
|
-
//
|
|
19
|
-
// Non-npm installs (go install, a binary from GitHub Releases) have no
|
|
20
|
-
// postinstall. Those users run `rulemux init --refresh` themselves, and
|
|
21
|
-
// `rulemux doctor` reports hooks that are installed but outdated.
|
|
22
|
-
|
|
23
|
-
const fs = require("fs");
|
|
24
|
-
const path = require("path");
|
|
25
|
-
const { spawnSync } = require("child_process");
|
|
26
|
-
|
|
27
|
-
function platformKey() {
|
|
28
|
-
const plat = process.platform === "win32" ? "windows" : process.platform;
|
|
29
|
-
let arch = process.arch;
|
|
30
|
-
if (arch === "x64") arch = "amd64";
|
|
31
|
-
else if (arch === "ia32") arch = "386";
|
|
32
|
-
return `${plat}-${arch}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Same resolution order as bin/rulemux.js: a bundled binary first, then a
|
|
36
|
-
// `rulemux` already on PATH.
|
|
37
|
-
function resolveBinary() {
|
|
38
|
-
const ext = process.platform === "win32" ? ".exe" : "";
|
|
39
|
-
const key = platformKey();
|
|
40
|
-
const candidates = [
|
|
41
|
-
path.join(__dirname, "..", "dist", `rulemux-${key}${ext}`),
|
|
42
|
-
path.join(__dirname, "..", "dist", `rulemux-${process.platform}-${process.arch}${ext}`),
|
|
43
|
-
];
|
|
44
|
-
for (const c of candidates) {
|
|
45
|
-
if (fs.existsSync(c)) return c;
|
|
46
|
-
}
|
|
47
|
-
const which = process.platform === "win32" ? "where" : "which";
|
|
48
|
-
const r = spawnSync(which, ["rulemux"], { stdio: "ignore" });
|
|
49
|
-
return r.status === 0 ? "rulemux" : null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function shouldRun() {
|
|
53
|
-
if (process.env.npm_config_global !== "true") return false;
|
|
54
|
-
if (process.env.npm_config_ignore_scripts === "true") return false;
|
|
55
|
-
if (process.env.CI) return false;
|
|
56
|
-
if (process.env.SUDO_USER) return false;
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function main() {
|
|
61
|
-
if (!shouldRun()) return;
|
|
62
|
-
|
|
63
|
-
const bin = resolveBinary();
|
|
64
|
-
if (!bin) return;
|
|
65
|
-
|
|
66
|
-
const r = spawnSync(bin, ["init", "--refresh"], { encoding: "utf8" });
|
|
67
|
-
if (r.error || r.status !== 0 || !r.stdout) return;
|
|
68
|
-
|
|
69
|
-
// Stay quiet unless something actually changed: "refreshed:" marks a rewrite.
|
|
70
|
-
const changed = r.stdout
|
|
71
|
-
.split("\n")
|
|
72
|
-
.map((line) => line.trim())
|
|
73
|
-
.filter((line) => line.includes("refreshed:"));
|
|
74
|
-
if (changed.length === 0) return;
|
|
75
|
-
|
|
76
|
-
process.stdout.write(
|
|
77
|
-
"rulemux: upgraded the SessionStart hook(s) rulemux had already installed\n" +
|
|
78
|
-
changed.map((line) => " " + line).join("\n") +
|
|
79
|
-
"\n"
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
main();
|
|
85
|
-
} catch (_) {
|
|
86
|
-
// Never let a hook refresh break `npm install`.
|
|
87
|
-
}
|