agent-purge 0.2.5 → 0.2.6
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/bin/agent-purge.mjs +738 -736
- package/lib/caps.mjs +4 -4
- package/lib/dsh.mjs +346 -316
- package/lib/slashes.mjs +23 -2
- package/package.json +1 -1
package/lib/slashes.mjs
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { dirname, join } from "node:path";
|
|
11
11
|
import { detect } from "./detect.mjs";
|
|
12
|
+
import { SLASH_RESIDENT, addPlugin, hasPlugin, pluginDir, removePlugin, slashSource } from "./dsh.mjs";
|
|
12
13
|
|
|
13
14
|
const SIDECAR = ".disabled-by-agent-purge";
|
|
14
15
|
|
|
@@ -69,6 +70,17 @@ export function resolveSlash(id, root) {
|
|
|
69
70
|
note: "opencode 的 command 是用户消息 → user 层(bench 实测 0/2 无效);要 sys 层请用 install(chat.system.transform 插件)",
|
|
70
71
|
};
|
|
71
72
|
},
|
|
73
|
+
// dsh:不是写文件,而是往三个 profile 各装一个 cordis 小插件(agent-purge-slash)。
|
|
74
|
+
// 它只注册 /purge 命令、改 state.json,不碰系统提示词 —— 注入归 agent-purge 常驻插件。
|
|
75
|
+
dsh: () => ({
|
|
76
|
+
layer: "sys",
|
|
77
|
+
offered: true,
|
|
78
|
+
hot: true,
|
|
79
|
+
trigger: "/purge on|off|status|mode",
|
|
80
|
+
file: join(pluginDir("desktop", SLASH_RESIDENT), "index.js"),
|
|
81
|
+
render: () => slashSource(root),
|
|
82
|
+
note: "cordis 插件注册 /purge(/ap 为别名):改 state.json,下一句生效,不产生模型消息",
|
|
83
|
+
}),
|
|
72
84
|
};
|
|
73
85
|
const spec = specs[id];
|
|
74
86
|
if (!spec) return null;
|
|
@@ -81,6 +93,11 @@ export function installSlash(id, root, { personaId, personaBody }) {
|
|
|
81
93
|
const s = resolveSlash(id, root);
|
|
82
94
|
if (!s) return { error: `${id} 没有 /purge 通道` };
|
|
83
95
|
if (s.offered === false) return { error: `${s.note}(已下线,不再提供)` };
|
|
96
|
+
// dsh:装 cordis 插件到三个 profile,没有单文件可写
|
|
97
|
+
if (id === "dsh") {
|
|
98
|
+
const r = addPlugin(SLASH_RESIDENT, slashSource(root));
|
|
99
|
+
return { file: s.file, layer: s.layer, note: s.note, sidecars: [], profiles: r.profiles };
|
|
100
|
+
}
|
|
84
101
|
mkdirSync(dirname(s.file), { recursive: true });
|
|
85
102
|
|
|
86
103
|
// pi:旧的 pi-purge.ts 也注册 /purge,会撞名 → 先移开,卸载时还原
|
|
@@ -102,6 +119,10 @@ export function installSlash(id, root, { personaId, personaBody }) {
|
|
|
102
119
|
export function uninstallSlash(id, root) {
|
|
103
120
|
const s = resolveSlash(id, root);
|
|
104
121
|
if (!s) return { error: `${id} 没有 /purge 通道` };
|
|
122
|
+
if (id === "dsh") {
|
|
123
|
+
removePlugin(SLASH_RESIDENT);
|
|
124
|
+
return { removed: [s.file] };
|
|
125
|
+
}
|
|
105
126
|
const removed = [];
|
|
106
127
|
if (existsSync(s.file)) {
|
|
107
128
|
rmSync(s.file, { force: true });
|
|
@@ -119,10 +140,10 @@ export function uninstallSlash(id, root) {
|
|
|
119
140
|
|
|
120
141
|
export function slashStatus(root) {
|
|
121
142
|
const out = [];
|
|
122
|
-
for (const id of Object.keys({ pi: 1, claude: 1, codex: 1, opencode: 1 })) {
|
|
143
|
+
for (const id of Object.keys({ pi: 1, claude: 1, codex: 1, opencode: 1, dsh: 1 })) {
|
|
123
144
|
const s = resolveSlash(id, root);
|
|
124
145
|
if (!s) continue;
|
|
125
|
-
const installed = existsSync(s.file);
|
|
146
|
+
const installed = id === "dsh" ? hasPlugin(SLASH_RESIDENT) : existsSync(s.file);
|
|
126
147
|
let personaId = null;
|
|
127
148
|
if (installed) {
|
|
128
149
|
const text = readFileSync(s.file, "utf8");
|
package/package.json
CHANGED