agent-purge 0.2.10 → 0.2.12
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/CONTRIBUTING.md +64 -0
- package/LICENSE +21 -21
- package/README.md +169 -138
- package/backends/index.mjs +204 -244
- package/bench/bench-armor.mjs +844 -832
- package/bench/capture-hot.mjs +58 -0
- package/bench/capture-provider.mjs +66 -0
- package/bench/capture-report.mjs +15 -0
- package/bench/capture-server-hot.mjs +55 -0
- package/bench/capture-system.mjs +36 -0
- package/bench/judge-armor.mjs +119 -119
- package/bin/agent-purge.mjs +956 -780
- package/docs/LEGAL.md +27 -0
- package/docs/architecture.md +39 -0
- package/docs/compatibility.md +78 -0
- package/docs/images/console-desktop.png +0 -0
- package/docs/images/console-mobile.png +0 -0
- package/docs/releasing.md +87 -0
- package/docs/usage.md +158 -0
- package/lib/activation.mjs +38 -0
- package/lib/apply.mjs +227 -0
- package/lib/armed.mjs +38 -38
- package/lib/armor.mjs +225 -222
- package/lib/caps.mjs +182 -173
- package/lib/capture.mjs +324 -0
- package/lib/clean.mjs +124 -0
- package/lib/control.mjs +60 -0
- package/lib/detect.mjs +74 -70
- package/lib/doctor.mjs +7 -7
- package/lib/dsh.mjs +495 -453
- package/lib/environment.mjs +36 -0
- package/lib/evidence.mjs +41 -0
- package/lib/extension.mjs +140 -0
- package/lib/footprints.mjs +59 -0
- package/lib/home.mjs +47 -47
- package/lib/launch-conflicts.mjs +24 -0
- package/lib/launch.mjs +57 -0
- package/lib/opencode.mjs +62 -0
- package/lib/paths.mjs +25 -0
- package/lib/persist.mjs +439 -280
- package/lib/persona-import.mjs +351 -0
- package/lib/personas.mjs +17 -7
- package/lib/private-server.mjs +54 -0
- package/lib/project.mjs +134 -0
- package/lib/restore.mjs +131 -114
- package/lib/rewrite.mjs +124 -0
- package/lib/root.mjs +37 -0
- package/lib/shim.mjs +203 -160
- package/lib/slashes.mjs +227 -628
- package/lib/spawn.mjs +182 -126
- package/lib/state.mjs +85 -137
- package/lib/templates/personas/neutral.md +30 -30
- package/lib/update.mjs +137 -0
- package/lib/verification.mjs +23 -0
- package/lib/window.mjs +58 -0
- package/lib/wrappers.mjs +49 -0
- package/magpie-plugin/README.md +44 -0
- package/matrix.json +325 -341
- package/package.json +30 -4
- package/web/app.js +590 -0
- package/web/assets/agent-purge.ico +0 -0
- package/web/assets/claude.ico +0 -0
- package/web/assets/codebuddy.png +0 -0
- package/web/assets/codex.webp +0 -0
- package/web/assets/dsh.ico +0 -0
- package/web/assets/grok.ico +0 -0
- package/web/assets/hermes.ico +0 -0
- package/web/assets/omp.png +0 -0
- package/web/assets/opencode.ico +0 -0
- package/web/assets/opencode2.ico +0 -0
- package/web/assets/pi.png +0 -0
- package/web/assets/zcode.png +0 -0
- package/web/model.mjs +49 -0
- package/web/server.mjs +330 -191
- package/web/styles.css +1072 -0
- package/web/ui.html +76 -1163
package/web/model.mjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const MODE_LABELS = { strict: '只留人设', replace: '换身份', append: '追加', off: '暂停' };
|
|
2
|
+
export const CAPTURE_LABELS = { captured: '已捕获', passed: '已验证', partial: '部分完成', blocked: '受阻', missing: '未找到入口', unavailable: '未找到入口', error: '出错', mismatch: '不符合预期', 'no-request': '未捕获请求', 'not-tested': '未实测' };
|
|
3
|
+
export const CHANNEL_LABELS = { install: '常驻配置(全局)', shim: '命令入口(进程接管)', slash: '会话内切换(热切)', project: '本项目(项目规则文件)' };
|
|
4
|
+
export const escapeHtml = value => String(value ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
5
|
+
export const personaName = persona => persona?.meta?.name || persona?.id || '未选择';
|
|
6
|
+
export function configurationOf(state) {
|
|
7
|
+
return { persona: state.active ?? '', mode: state.paused ? state.prevMode || 'replace' : state.defaults?.mode || 'replace' };
|
|
8
|
+
}
|
|
9
|
+
export const changed = (draft, base) => JSON.stringify(draft) !== JSON.stringify(base);
|
|
10
|
+
export const needsApply = (state, draft, base) => state.defaultsSet === false || changed(draft, base);
|
|
11
|
+
export function sortedHarnesses(state, showAll = false) {
|
|
12
|
+
const selected = h => (h.armed?.length ?? 0) > 0;
|
|
13
|
+
// 不可注入的(antigravity:只有二进制补丁,没有可用通道)不进接管列表;「显示本机未装的」也不放它进来
|
|
14
|
+
return [...(state.harnesses ?? [])]
|
|
15
|
+
.filter(h => h.caps?.injectable !== false)
|
|
16
|
+
.filter(h => showAll || selected(h) || h.found || h.homeExists)
|
|
17
|
+
.sort((a, b) => Number(selected(b)) - Number(selected(a)) || Number(b.found) - Number(a.found) || a.id.localeCompare(b.id));
|
|
18
|
+
}
|
|
19
|
+
export function effectLabel(harness, paused = false, dshRuntime = null) {
|
|
20
|
+
const name = harness.id ?? '这个执行器';
|
|
21
|
+
const on = (harness.armed?.length ?? 0) > 0;
|
|
22
|
+
if (on && paused) return '总电源已暂停:配置保留,恢复后按原范围应用';
|
|
23
|
+
if (on && (harness.mode === 'off' || ['harness-off', 'harness-disabled'].includes(harness.activation?.blockedBy))) return '这家已关闭:全局恢复也不会自动启用';
|
|
24
|
+
if (!on) return harness.found || harness.homeExists ? '' : '本机没装,装好后再回来开';
|
|
25
|
+
// dsh 的 /purge off|mode 是 profile 级的(dshRuntime.<profile>),总开关开着也可能某形态被暂停
|
|
26
|
+
if (harness.id === 'dsh' && dshRuntime) {
|
|
27
|
+
const states = Object.entries(dshRuntime).filter(([, v]) => v && typeof v === 'object');
|
|
28
|
+
const off = states.filter(([, v]) => v.enabled === false);
|
|
29
|
+
const profiles = harness.profiles || ['desktop', 'web', 'headless', 'sdk'];
|
|
30
|
+
if (profiles.length && profiles.every(p => dshRuntime[p]?.enabled === false)) return 'dsh 已选形态均被 /purge off 暂停;在对应形态执行 /purge on 恢复';
|
|
31
|
+
if (off.length) return `dsh 这些形态被 /purge off 暂停:${off.map(([p]) => p).join('、')};未列出的形态尚未确认`;
|
|
32
|
+
}
|
|
33
|
+
const dynamic = harness.caps?.hot;
|
|
34
|
+
if (dynamic?.ok && harness.armed.includes(dynamic.needs)) {
|
|
35
|
+
if (dynamic.needs === 'slash' && harness.auto !== true) return `扩展已选择:重新加载 ${name} 后执行 /purge on;当前会话尚未确认`;
|
|
36
|
+
return '动态通道已选择:已加载插件下一轮读取,首次安装或代码更新需重启;当前会话尚未确认';
|
|
37
|
+
}
|
|
38
|
+
if (harness.projectOn && harness.armed.includes('project')) return '项目规则已登记:其他原生执行器也可能读取同名文件;对应目录的新会话读取';
|
|
39
|
+
if (harness.armed.includes('install')) return `配置已选择:新开的 ${name} 读取;现有会话尚未确认`;
|
|
40
|
+
if (harness.armed.includes('slash')) return `在 ${name} 里执行 /purge on 后启用;当前会话尚未确认`;
|
|
41
|
+
return `已接管命令:在终端敲 ${name} 时自动注入`;
|
|
42
|
+
}
|
|
43
|
+
/** 标题下那一行:说清谁在被接管,而不是只报个数。 */
|
|
44
|
+
export function scopeSummary(state) {
|
|
45
|
+
const ids = Object.entries(state.armed ?? {}).filter(([, channels]) => channels?.length).map(([id]) => id);
|
|
46
|
+
if (state.paused) return ids.length ? `已暂停,这些执行器的配置还留着:${ids.join('、')}` : '已暂停,暂时没有执行器在用这份人设';
|
|
47
|
+
if (!ids.length) return '选择要管理的执行器;写入通道后,按详情提示检查生效时机。';
|
|
48
|
+
return `已选择 ${ids.length} 个执行器:${ids.join('、')};实际生效看各自状态`;
|
|
49
|
+
}
|