agent-bypass 2.14.2 → 2.15.0
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/AGENT_ADDITIVE_CHANGELOG.md +10 -1
- package/README.md +15 -8
- package/SKILL.md +13 -12
- package/bin/install.js +215 -4
- package/ck-hunter.md +4 -4
- package/dsh/README.md +74 -0
- package/dsh/build-template.js +310 -0
- package/dsh/persona.md +127 -0
- package/dsh/preset.template.yml +132 -0
- package/package.json +6 -3
- package/tests/test_regressions.py +78 -0
|
@@ -153,5 +153,83 @@ class JsripSameSiteTests(unittest.TestCase):
|
|
|
153
153
|
self.assertFalse(self.js.same_site("https://example.com", "https://wwwexample.com/a.js"))
|
|
154
154
|
|
|
155
155
|
|
|
156
|
+
class DshInstallerTests(unittest.TestCase):
|
|
157
|
+
"""DeepSeek Harness:技能安装 + Ck 模式预设注入(临时 HOME,离线)。"""
|
|
158
|
+
|
|
159
|
+
DSH_ENV = ("DSH_HOME", "DSH_PROFILE", "DSH_AGENTS_HOME", "DSH_APP_PATH", "DSH_ASAR_PATH")
|
|
160
|
+
|
|
161
|
+
def _node(self, *args, home):
|
|
162
|
+
env = dict(os.environ)
|
|
163
|
+
env["HOME"] = home
|
|
164
|
+
for k in self.DSH_ENV:
|
|
165
|
+
env.pop(k, None)
|
|
166
|
+
return _tmp_run(["node", str(ROOT / "bin" / "install.js"), *args], env=env)
|
|
167
|
+
|
|
168
|
+
def _seed(self, home, patch_text="[]\n"):
|
|
169
|
+
prof = Path(home) / ".dsh" / "profiles" / "desktop"
|
|
170
|
+
prof.mkdir(parents=True, exist_ok=True)
|
|
171
|
+
f = prof / "cordis.patch.yml"
|
|
172
|
+
f.write_text(patch_text, encoding="utf-8")
|
|
173
|
+
return f
|
|
174
|
+
|
|
175
|
+
def test_install_idempotent_and_persona_dollar_preserved(self):
|
|
176
|
+
with tempfile.TemporaryDirectory() as home:
|
|
177
|
+
patch = self._seed(home)
|
|
178
|
+
r1 = self._node("--dsh", home=home)
|
|
179
|
+
self.assertEqual(r1.returncode, 0, r1.stdout + r1.stderr)
|
|
180
|
+
skill = Path(home) / ".agents" / "skills" / "agent-bypass" / "SKILL.md"
|
|
181
|
+
self.assertTrue(skill.exists(), "DSH 技能应安装到 ~/.agents/skills")
|
|
182
|
+
text = patch.read_text(encoding="utf-8")
|
|
183
|
+
self.assertEqual(text.count("agent-bypass:dsh-preset-begin"), 1)
|
|
184
|
+
self.assertEqual(text.count("id: preset-ck"), 1)
|
|
185
|
+
self.assertIn("Ck 万能执行员", text)
|
|
186
|
+
# $$ 不能被 String.replace 的替换串语义吃掉(PHP 变量变量)
|
|
187
|
+
self.assertIn("parse_str / $$", text)
|
|
188
|
+
# 幂等:重复安装不重复追加
|
|
189
|
+
r2 = self._node("--dsh", home=home)
|
|
190
|
+
self.assertEqual(r2.returncode, 0, r2.stdout + r2.stderr)
|
|
191
|
+
text2 = patch.read_text(encoding="utf-8")
|
|
192
|
+
self.assertEqual(text2.count("agent-bypass:dsh-preset-begin"), 1)
|
|
193
|
+
self.assertEqual(text2.count("id: preset-ck"), 1)
|
|
194
|
+
|
|
195
|
+
def test_crlf_preserved_and_uninstall_restores(self):
|
|
196
|
+
with tempfile.TemporaryDirectory() as home:
|
|
197
|
+
patch = self._seed(home, '# note\r\n- id: web\r\n name: "@deepseek-ai/dsh-web"\r\n')
|
|
198
|
+
self.assertEqual(self._node("--dsh", home=home).returncode, 0)
|
|
199
|
+
data = patch.read_bytes()
|
|
200
|
+
self.assertIn(b"agent-bypass:dsh-preset-begin", data)
|
|
201
|
+
self.assertGreater(data.count(b"\r\n"), 100, "CRLF 文件应保持 CRLF")
|
|
202
|
+
r = self._node("--dsh", "--uninstall", home=home)
|
|
203
|
+
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
|
|
204
|
+
data2 = patch.read_bytes()
|
|
205
|
+
self.assertNotIn(b"agent-bypass:dsh-preset-begin", data2)
|
|
206
|
+
self.assertIn(b"# note", data2)
|
|
207
|
+
self.assertIn(b"id: web", data2)
|
|
208
|
+
self.assertFalse((Path(home) / ".agents" / "skills" / "agent-bypass").exists())
|
|
209
|
+
|
|
210
|
+
def test_comment_only_patch_stays_valid_yaml(self):
|
|
211
|
+
with tempfile.TemporaryDirectory() as home:
|
|
212
|
+
patch = self._seed(home, "# user comment\n[]\n")
|
|
213
|
+
self.assertEqual(self._node("--dsh", home=home).returncode, 0)
|
|
214
|
+
self.assertEqual(self._node("--dsh", "--uninstall", home=home).returncode, 0)
|
|
215
|
+
text = patch.read_text(encoding="utf-8")
|
|
216
|
+
self.assertIn("# user comment", text)
|
|
217
|
+
self.assertIn("[]", text, "只留注释时应补回空数组,保证 loader 可解析")
|
|
218
|
+
|
|
219
|
+
def test_default_targets_include_pi_opencode_dsh(self):
|
|
220
|
+
with tempfile.TemporaryDirectory() as home:
|
|
221
|
+
(Path(home) / ".pi").mkdir()
|
|
222
|
+
(Path(home) / ".config" / "opencode").mkdir(parents=True)
|
|
223
|
+
self._seed(home)
|
|
224
|
+
r = self._node(home=home)
|
|
225
|
+
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
|
|
226
|
+
self.assertTrue((Path(home) / ".pi" / "agent" / "skills" / "agent-bypass" / "SKILL.md").exists())
|
|
227
|
+
self.assertTrue((Path(home) / ".config" / "opencode" / "skills" / "agent-bypass" / "SKILL.md").exists())
|
|
228
|
+
self.assertTrue((Path(home) / ".agents" / "skills" / "agent-bypass" / "SKILL.md").exists())
|
|
229
|
+
patch_text = (Path(home) / ".dsh" / "profiles" / "desktop" / "cordis.patch.yml").read_text(encoding="utf-8")
|
|
230
|
+
self.assertIn("id: preset-ck", patch_text)
|
|
231
|
+
self.assertIn("dsh", r.stdout + r.stderr)
|
|
232
|
+
|
|
233
|
+
|
|
156
234
|
if __name__ == "__main__":
|
|
157
235
|
unittest.main()
|