agent-purge 0.2.9 → 0.2.10

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
@@ -99,6 +99,33 @@ agent-purge uninstall <h> # 摘掉,按字节还原
99
99
 
100
100
  dsh 是唯一有多个形态的:desktop / web / headless 共用一套 cordis 插件,装在各自 profile 的 `node_modules/agent-purge/`,并在 `cordis.patch.yml` 里 `- insert` 挂上,不改 `app.asar`。装完重启一次,之后热生效;三个形态还能在 Web 面板分别勾选。
101
101
 
102
+ ### 三个通道与总电源(arm / disarm)
103
+
104
+ 一家 harness 有三条能注入的入口,`arm` 默认三条全开:
105
+
106
+ | 通道 | 管什么 | 只想做这一项 |
107
+ |---|---|---|
108
+ | `shim` | PATH 最前放同名壳,**裸敲** `codex` / `dsh` 也经 agent-purge 启动 | `arm <h> --shim` |
109
+ | `install` | 写 harness 自己的配置/插件,**别人启动的、GUI 里点开的**也生效 | `arm <h> --install` |
110
+ | `slash` | 会话内 `/purge` 热切换(只有 pi / omp / dsh 有 sys 层热切) | `arm <h> --slash` |
111
+
112
+ ```bash
113
+ agent-purge arm <h> # 三条全开(= 注册)
114
+ agent-purge disarm <h> # 撤掉这一家的三条通道
115
+ agent-purge arm --all # 所有支持的 harness 全开 + 总电源打开
116
+ agent-purge disarm --all # 所有 harness 全撤 + 总电源关掉("别管我")
117
+ ```
118
+
119
+ **`--all` 是总电源,不是"全部通道"。** 它改的是 `state.json` 里的 `default.mode`:
120
+
121
+ - `default.mode = off` 时,**所有**入口都不注入——包括裸敲 `agent-purge`、`agent-purge <h>`、PATH 壳;
122
+ - `disarm <h>` 只撤那家的三个通道,**不动总电源**,所以撤完 `agent-purge dsh` 仍然注入——
123
+ 这就是"明明 disarm 了却还在改提示词"的来源;
124
+ - 只想彻底关掉某一家:`agent-purge disarm dsh --all`(撤 dsh 三条通道 + 关总电源,别的 harness 不动);
125
+ `arm` 会把上次的 mode 还回去。
126
+
127
+ 改完用 `agent-purge status` 复核:每家的 `shim / slash / install` 三个格子 + 当前 mode 一张表。
128
+
102
129
  ## magpie 网关插件(可选)
103
130
 
104
131
  [magpie](https://github.com/yetone/magpie) 把各家 agent 的请求收进本地网关。挂上这个插件后,**凡是经过网关的请求**(Claude Code、Codex、OpenCode、pi…)的 system 段都按 agent-purge 的当前人设改写——不用逐个 harness 装,换人设也不用重启 magpie。
@@ -379,21 +379,25 @@ async function armCmd(verb, rest) {
379
379
 
380
380
  const supported = Object.keys(matrix.harnesses).filter((h) => matrix.harnesses[h].class !== "unsupported");
381
381
  const namedTarget = rest.filter((x) => !x.startsWith("-"));
382
- const targets = rest.includes("--all") || !namedTarget.length ? supported : namedTarget;
382
+ // 点了名的只动那家:`--all` 只管总电源,不再悄悄把别的 harness 一起撤(issue #5)
383
+ const targets = namedTarget.length ? namedTarget : supported;
383
384
 
384
385
  // 全局 --all 就是总电源:撤的时候必须把 default.mode 置 off,
385
386
  // 否则 `agent-purge <h>` 这条入口照样注入(实测:关了总开关还能接管,就是这里漏的)。
386
387
  // 开的时候把上次的 mode 还回去。单家操作不动 mode。
388
+ // 没设过默认 harness 时也要能关:launch() 在 default 为空时会回落成 replace。
387
389
  if (rest.includes("--all")) {
388
390
  const { state: cur } = loadState(DATA);
389
- const m = cur.default?.mode ?? "off";
390
- if (verb === "disarm" && m !== "off" && cur.default?.harness) {
391
- setDefault(DATA, { harness: cur.default.harness, mode: "off" });
392
- patchState(DATA, { prevMode: m });
391
+ const m = cur.default?.mode ?? null; // null = 从没设过,launch() 会回落成 replace
392
+ const h = cur.default?.harness ?? null;
393
+ if (verb === "disarm" && m !== "off") {
394
+ patchState(DATA, { default: { harness: h, mode: "off" }, prevMode: m ?? "replace" });
395
+ console.log(`总电源:mode ${m ?? "(未设,实际按 replace)"} → off(裸敲 agent-purge / agent-purge <h> 都不再注入;arm --all 还回去)`);
393
396
  }
394
- if (verb === "arm" && m === "off" && cur.default?.harness) {
397
+ if (verb === "arm" && cur.default && m === "off") {
395
398
  const back = MODES.includes(cur.prevMode) && cur.prevMode !== "off" ? cur.prevMode : "replace";
396
- setDefault(DATA, { harness: cur.default.harness, mode: back });
399
+ patchState(DATA, { default: { harness: h, mode: back } });
400
+ console.log(`总电源:mode off → ${back}`);
397
401
  }
398
402
  }
399
403
 
@@ -540,7 +544,7 @@ async function statusCmd() {
540
544
  const slashes = slashMod.slashStatus(DATA);
541
545
 
542
546
  console.log(`persona ${state.persona ?? "(未设置)"}`);
543
- console.log(`default ${state.default ? `${state.default.harness} · ${state.default.mode}` : "(未设置)"} 裸敲 agent-purge 用它`);
547
+ console.log(`default ${state.default ? `${state.default.harness ?? "(未选默认)"} · ${state.default.mode}` : "(未设置)"} 裸敲 agent-purge 用它`);
544
548
  console.log(`state ${join(DATA, "state.json")}`);
545
549
  console.log("");
546
550
  console.log("harness shim slash install /purge层 常驻落点");
@@ -744,7 +748,11 @@ function help() {
744
748
  agent-purge arm <h> --shim 只做裸命令接管(写 PATH 最前)
745
749
  agent-purge arm <h> --install 只做配置文件常驻
746
750
  agent-purge arm <h> --slash 只做会话内 /purge
747
- agent-purge disarm <h>|--all 以上全部撤掉
751
+ agent-purge disarm <h>|--all 以上全部撤掉;不带 <h> 就是所有 harness
752
+
753
+ 注:--all 是总电源(state.json 的 default.mode)。带 <h> 时只撤那家,
754
+ 但同样把总电源关掉——不然裸敲 agent-purge、agent-purge <h> 照样注入。
755
+ 彻底别管我:agent-purge disarm --all
748
756
 
749
757
  ④ 看
750
758
  agent-purge status 一张表:每家的 shim / slash / install / 能做什么
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-purge",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "One persona, many coding agents: replace or inject system prompts across codex, claude, opencode (v1/v2), grok, omp, hermes, pi, zcode, dsh.",
5
5
  "type": "module",
6
6
  "bin": {