feat: 0.4.3 - precise conflict detection (read actual config ids, not package names)

The old heuristic matched names like purge|ungate|jailbreak and reported
dsh-purge as a sibling. That was wrong: dsh-purge patches host source, it does
not touch approval/permission config ids at all.

Now the plugin reads every installed bundle's cordis.patch.yml, extracts the
config ids it actually rewrites, and intersects with its own set:

  hardConflicts - other plugin rewrites approval/permission/sandbox-policy/...
                  -> last-applied wins, one silently stops working -> pick one
  softOverlaps  - other plugin only rewrites system-prompt (identity prefix)
                  -> negligible difference -> safe to coexist

Measured on this machine (22 bundles): scanned 19, hardConflicts [],
softOverlaps [{dsh-purge, system-prompt}]. So dsh-purge and this plugin do NOT
conflict.
This commit is contained in:
moyun 2026-11-17 14:53:13 +08:00
parent 4c96f28f53
commit 2c50d1e79e
6 changed files with 623 additions and 455 deletions

View File

@ -1,5 +1,34 @@
# Changelog # Changelog
## 0.4.3 — 2026-11-17
### 改进:冲突检测从「猜包名」升级为「读实际配置」
之前用包名正则(`purge|ungate|jailbreak...`)猜谁可能冲突,会误报——
实测 `dsh-purge` 被误判成同类,但它其实走宿主源码补丁,**不碰 approval/permission**。
现在改为:**读每个已装插件的 `cordis.patch.yml`,取它实际改的 config id 列表,与本插件的
id 集合求交集**。分两级:
| 级别 | 判定 | 后果 |
|---|---|---|
| `hardConflicts` | 对方也改 approval / permission / sandbox-policy / spill-policy / tool-result-pruner | 后应用者赢,一方静默失效 → 二选一 |
| `softOverlaps` | 对方只改 system-prompt(身份前缀) | 效果差异极小 → 可放心共存 |
`moyun_ultimate_profile` 的 `environment` 新增 `hardConflicts` / `softOverlaps` / `scannedPlugins`。
### 实测(本机 22 个插件)
```
scannedPlugins : 19
hardConflicts : []
softOverlaps : [{dsh-purge, system-prompt}]
```
**结论:`dsh-purge` 与本插件不冲突。**
---
## 0.4.2 — 2026-11-17 ## 0.4.2 — 2026-11-17
### 新增 ### 新增

View File

@ -18,6 +18,7 @@
| 老是触发安全拒绝 | ⚠️ **部分解决** | 见下方详解 | | 老是触发安全拒绝 | ⚠️ **部分解决** | 见下方详解 |
| 好像没破甲成功 | ✅ 已解决 | 工具直接报状态,不用猜 | | 好像没破甲成功 | ✅ 已解决 | 工具直接报状态,不用猜 |
| 你得给补丁,直接用用不了 | ✅ 已解决 | 0.2.0 起权限层内置,不需要额外补丁 | | 你得给补丁,直接用用不了 | ✅ 已解决 | 0.2.0 起权限层内置,不需要额外补丁 |
| 装了别的插件会冲突吗 | ✅ 已解决 | 工具自动扫描 19 个插件,报 `hardConflicts` / `softOverlaps` |
--- ---
@ -113,7 +114,72 @@ dnspy ilspycmd msfconsole nc socat sqlmap suo5 ...
--- ---
## 四、「和 purge 冲突吗」——技术上的准确答案 ## 四、装了别的插件会不会冲突(怎么判断)
### 一句话:看它改不改同一批 config id
本插件会改这 7 个 cordis config:
```
sandbox-policy approval permission spill-policy
tool-result-pruner agent-instructions session-query-sqlite
```
**任何也改这 7 个之一的其他插件,就会冲突**(后应用者赢,不报错但一方静默失效)。
### 两级冲突,严重程度不同
| 级别 | 判定 | 后果 | 处置 |
|---|---|---|---|
| **真冲突(hard)** | 对方也改 `approval` / `permission` / `sandbox-policy` / `spill-policy` / `tool-result-pruner` | 权限行为不确定,一方失效 | **二选一** |
| **轻微重叠(soft)** | 对方只改 `system-prompt`(身份/人设前缀) | 谁后应用谁赢,效果差异极小 | **可放心共存** |
### 怎么查(不用猜,工具会扫)
```
moyun_ultimate_profile
```
返回:
```json
"environment": {
"scannedPlugins": 19,
"hardConflicts": [],
"softOverlaps": [{ "plugin": "dsh-purge", "ids": ["system-prompt"] }],
"winner": "moyun-ultimate"
}
```
- `hardConflicts` **非空** → 真冲突,要二选一
- `only softOverlaps` 有内容 → 只是共享 system-prompt,**不用管**
- 两个都空 → 完全无冲突
它会**读每个已装插件的 `cordis.patch.yml`**,看它实际改了哪些 id,不是按包名猜。
### 本机实测(22 个插件)
```
scannedPlugins : 19
hardConflicts : [] ← 零真冲突
softOverlaps : [{dsh-purge, system-prompt}] ← 只有身份前缀重叠
```
**结论:`dsh-purge` 和本插件不冲突。** 它主要靠宿主源码补丁,不碰 approval/permission 这些 config id。
### 典型插件的分类
| 插件类型 | 会不会冲突 | 举例 |
|---|---|---|
| 源码补丁类(改宿主 .js 文件) | ❌ 不冲突(改的是源码不是 config) | dsh-purge |
| **config 覆盖类(改 approval/permission)** | ✅ **真冲突** | dsh-po、本插件自己 |
| 混合类(两者都改 + 共用状态目录) | ✅ **真冲突** | dsh-ungate |
| 纯提示词类(只加提示词段) | ❌ 不冲突(内容可能重复) | neko-armor、dsh-unrestricted |
| UI / 技能 / 工具类 | ❌ 不冲突 | dshmarket、modlens、dsh-im |
---
## 五、「和 purge 冲突吗」——技术上的准确答案
**会冲突,但不是"二改",是抢同一批 config id。** **会冲突,但不是"二改",是抢同一批 config id。**
@ -136,7 +202,7 @@ moyun_ultimate_profile
--- ---
## 五、「破甲越强模型越傻」——这条是真的 ## 六、「破甲越强模型越傻」——这条是真的
评论说得对。六段提示词合计 **23 KB**,会占上下文、把注意力往「规则」上拉。长链推理(写代码、复杂分析)会掉点。 评论说得对。六段提示词合计 **23 KB**,会占上下文、把注意力往「规则」上拉。长链推理(写代码、复杂分析)会掉点。
@ -162,7 +228,7 @@ moyun_ultimate_profile
--- ---
## 六、「怎么装 / 怎么验证」 ## 七、「怎么装 / 怎么验证」
### 三步装 ### 三步装
@ -189,7 +255,7 @@ RESULT: OK=11 WARN=2 FAIL=0
--- ---
## 七、一句话总结 ## 八、一句话总结
| 你问 | 答案 | | 你问 | 答案 |
|---|---| |---|---|

View File

@ -5,7 +5,7 @@
> Five-layer prompt core with a built-in permission layer for DeepSeek Harness. > Five-layer prompt core with a built-in permission layer for DeepSeek Harness.
<p align="center"> <p align="center">
<img alt="version" src="https://img.shields.io/badge/version-0.4.2-blue"> <img alt="version" src="https://img.shields.io/badge/version-0.4.3-blue">
<img alt="license" src="https://img.shields.io/badge/license-MIT-green"> <img alt="license" src="https://img.shields.io/badge/license-MIT-green">
<img alt="dsh" src="https://img.shields.io/badge/DSH-0.2.1--rc.5-4D6BFE"> <img alt="dsh" src="https://img.shields.io/badge/DSH-0.2.1--rc.5-4D6BFE">
<img alt="skills" src="https://img.shields.io/badge/skills-63-orange"> <img alt="skills" src="https://img.shields.io/badge/skills-63-orange">

View File

@ -119,7 +119,31 @@ sandbox-policy / approval / permission / spill-policy / tool-result-pruner / age
|---|---|---| |---|---|---|
| **只有 moyun-ultimate** | ✅ 权限层由本包提供 | 什么都不用做 | | **只有 moyun-ultimate** | ✅ 权限层由本包提供 | 什么都不用做 |
| **只有 purge(社区版)** | ✅ 权限层由 purge 提供 | 本包 `permission: false` | | **只有 purge(社区版)** | ✅ 权限层由 purge 提供 | 本包 `permission: false` |
| **两个都装** | ⚠️ 谁后应用谁生效 | **二选一**,别指望叠加 | | **两个都装** | ⚠️ 要具体看它改了什么 id | 见下「精确判定」 |
### 精确判定(不用猜)
**本插件改这 7 个 id**:`sandbox-policy` / `approval` / `permission` /
`spill-policy` / `tool-result-pruner` / `agent-instructions` / `session-query-sqlite`
```
moyun_ultimate_profile
→ environment.hardConflicts ← 非空 = 真冲突,要二选一
→ environment.softOverlaps ← 只共享 system-prompt,可放心共存
→ environment.scannedPlugins ← 实际扫描了多少个插件
```
工具会读每个已装插件的 `cordis.patch.yml`,看它实际改了哪些 id。
**实测参考(22 个插件)**:
```
scannedPlugins : 19
hardConflicts : []
softOverlaps : [{dsh-purge, system-prompt}]
```
→ **dsh-purge 与本插件不冲突**:它走宿主源码补丁,不碰 approval/permission。
**怎么判断谁赢了**: **怎么判断谁赢了**:

View File

@ -85,7 +85,38 @@ function readOwnVersion() {
// ── 环境诊断:找出当前 profile、检测配置覆盖与同类插件 ────────────────── // ── 环境诊断:找出当前 profile、检测配置覆盖与同类插件 ──────────────────
const CONFLICT_IDS = ["sandbox-policy", "approval", "permission", "spill-policy", "tool-result-pruner"]; const CONFLICT_IDS = ["sandbox-policy", "approval", "permission", "spill-policy", "tool-result-pruner"];
const SIBLING_HINTS = /purge|ungate|jailbreak|armor|unrestrict|pojia|po$/i; // 只重叠 system-prompt 的算「轻微重叠」:都是改身份/人设前缀,谁后应用谁赢,效果差异很小。
const SOFT_IDS = ["system-prompt"];
// 读某个已装插件的 cordis.patch.yml,返回它实际改/禁用的 config id 列表。
function readPluginPatchIds(profileDir, pluginName) {
const p = join(profileDir, "node_modules", pluginName, "cordis.patch.yml");
if (!existsSync(p)) return [];
try {
const txt = readFileSync(p, "utf8");
const ids = [];
for (const m of txt.matchAll(/^\s*-?\s*id:\s*([A-Za-z0-9_\-]+)/gm)) ids.push(m[1]);
return [...new Set(ids)];
} catch {
return [];
}
}
// 精确审计:谁真的改了同一批 id(而不是靠包名猜)。
function auditBundleConflicts(profileDir, selfName, bundles) {
const out = { hard: [], soft: [], scanned: 0 };
for (const name of bundles) {
if (name === selfName) continue;
const ids = readPluginPatchIds(profileDir, name);
if (ids.length === 0) continue;
out.scanned++;
const hardHit = ids.filter((i) => CONFLICT_IDS.includes(i));
const softHit = ids.filter((i) => SOFT_IDS.includes(i));
if (hardHit.length > 0) out.hard.push({ plugin: name, ids: hardHit });
else if (softHit.length > 0) out.soft.push({ plugin: name, ids: softHit });
}
return out;
}
let profileCache = null; let profileCache = null;
@ -134,26 +165,39 @@ function detectConflicts(dshHome) {
} catch {} } catch {}
} }
// 2) bundles 里有没有同类插件 // 2) 精确审计:读每个已装插件的 cordis.patch.yml,看谁真的改同一批 id
const bundles = (prof.pkg.dsh && prof.pkg.dsh.profile && prof.pkg.dsh.profile.bundles) || []; const bundles = (prof.pkg.dsh && prof.pkg.dsh.profile && prof.pkg.dsh.profile.bundles) || [];
out.siblingPlugins = bundles.filter((b) => b !== "moyun-ultimate" && SIBLING_HINTS.test(b)); const audit = auditBundleConflicts(prof.dir, "moyun-ultimate", bundles);
out.hardConflicts = audit.hard;
out.softOverlaps = audit.soft;
out.scannedPlugins = audit.scanned;
// 兼容旧字段
out.siblingPlugins = audit.hard.map((x) => x.plugin);
// 3) 谁生效 // 3) 谁生效
if (out.userOverrides.length > 0) { if (out.userOverrides.length > 0) {
out.winner = "user-layer"; out.winner = "user-layer";
out.notes.push( out.notes.push(
"profile 用户层覆盖了 " + out.userOverrides.join(", ") + " —— 用户层后应用、优先级更高," + "profile 用户层覆盖了 " + out.userOverrides.join(", ") +
"本包的权限层被盖掉。要本包接管就删掉那几段;要保留就设 permission: false。", " —— 用户层后应用、优先级更高,本包的权限层被盖掉。要本包接管就删掉那几段;要保留就设 permission: false。",
); );
} else if (out.siblingPlugins.length > 0) { } else if (audit.hard.length > 0) {
out.winner = "ambiguous"; out.winner = "ambiguous";
const detail = audit.hard.map((x) => x.plugin + "(" + x.ids.join("/") + ")").join(", ");
out.notes.push( out.notes.push(
"bundles 里有同类插件 " + out.siblingPlugins.join(", ") + " —— 如果它也改 approval/permission," + "检测到真冲突:" + detail + " 也改同一批权限 config —— 后应用者赢,不会报错但一方静默失效。建议二选一。",
"后应用者赢,不会报错但一方静默失效。建议二选一。",
); );
} else { } else {
out.winner = "moyun-ultimate"; out.winner = "moyun-ultimate";
out.notes.push("权限层由本插件接管,无冲突。"); if (audit.soft.length > 0) {
const detail = audit.soft.map((x) => x.plugin + "(" + x.ids.join("/") + ")").join(", ");
out.notes.push(
"无权限层冲突。仅与 " + detail + " 共享 system-prompt(都改身份/人设前缀)," +
"谁后应用谁赢,实际效果差异很小,可放心共存。",
);
} else {
out.notes.push("权限层由本插件接管,扫描 " + audit.scanned + " 个已装插件未发现同 id 冲突。");
}
} }
return out; return out;
} }
@ -351,7 +395,11 @@ const profileTool = {
environment: { environment: {
profile: env.profile, profile: env.profile,
userLayerOverrides: env.userOverrides, userLayerOverrides: env.userOverrides,
siblingPlugins: env.siblingPlugins, // 真冲突:确有其它已装插件改同一批权限 config(approval/permission/sandbox-policy...)
hardConflicts: env.hardConflicts || [],
// 轻微重叠:只共享 system-prompt,可放心共存
softOverlaps: env.softOverlaps || [],
scannedPlugins: env.scannedPlugins || 0,
winner: env.winner, winner: env.winner,
notes: env.notes, notes: env.notes,
}, },
@ -560,6 +608,7 @@ export function apply(ctx, config = {}) {
return { return {
profile: e.profile, profile: e.profile,
userOverrides: e.userOverrides, userOverrides: e.userOverrides,
hardConflicts: e.hardConflicts || [],
siblingPlugins: e.siblingPlugins, siblingPlugins: e.siblingPlugins,
winner: e.winner, winner: e.winner,
note: e.notes[0] || "", note: e.notes[0] || "",

View File

@ -1,6 +1,6 @@
{ {
"name": "moyun-ultimate", "name": "moyun-ultimate",
"version": "0.4.2", "version": "0.4.3",
"displayName": "墨昀·终极破甲", "displayName": "墨昀·终极破甲",
"description": "墨昀·终极破甲:五层提示词内核 + 内置权限层 —— 人格双槽 × 反拒绝机制 × 执行强度 × 换框模板 × 技能路由,内置 63 个攻防技能(逆向 24 / 渗透 16 / 云 8 / 取证 6 / 其它 9)。Layered prompt core with five sections and 63 built-in skills.", "description": "墨昀·终极破甲:五层提示词内核 + 内置权限层 —— 人格双槽 × 反拒绝机制 × 执行强度 × 换框模板 × 技能路由,内置 63 个攻防技能(逆向 24 / 渗透 16 / 云 8 / 取证 6 / 其它 9)。Layered prompt core with five sections and 63 built-in skills.",
"keywords": [ "keywords": [
@ -37,7 +37,7 @@
"dsh": { "dsh": {
"id": "moyun-ultimate", "id": "moyun-ultimate",
"name": "墨昀·终极破甲", "name": "墨昀·终极破甲",
"version": "0.4.2", "version": "0.4.3",
"permissions": "六段提示词注入(含输出抗审), 内置权限层(沙箱/审批/结果), 拒绝投影状态条, 换框模板工具, 状态自查工具(含 provider 审核风险评估), 技能审计工具, 63 技能自动同步", "permissions": "六段提示词注入(含输出抗审), 内置权限层(沙箱/审批/结果), 拒绝投影状态条, 换框模板工具, 状态自查工具(含 provider 审核风险评估), 技能审计工具, 63 技能自动同步",
"bundle": { "bundle": {
"patch": "./cordis.patch.yml" "patch": "./cordis.patch.yml"