Files
aiturk-hermes-ide/apps/desktop/assets/codex-bridge/test_is_hatti.py
T
yilsem 81ee2ca646
Server CI and Windows package / verify (push) Successful in 2m56s
Server CI and Windows package / windows-package (push) Successful in 7m27s
feat(codex-link): main model delegates every task to subagents by default
User decision (15 Oct 2026): repeating or scheduled work goes to AITURK; all other work, coding included, goes to one subagent (easy) or a subagent team or dynamic workflow (hard). The main model talks, dispatches and verifies.
2026-10-15 02:26:45 +03:00

89 lines
4.8 KiB
Python

"""The "send larger work to AITURK" instruction reaches only Codex Desktop, and only when a send command exists."""
import unittest
import is_hatti as h
class Hat(unittest.TestCase):
def test_only_the_desktop_app_is_recognised(self):
self.assertTrue(h.masaustu_mu("Codex Desktop"))
for other in ("codex-tui", "codex_exec", "codex_cli_rs", "", None, "Codex Desktop Helper"):
self.assertFalse(h.masaustu_mu(other), other)
def test_no_instruction_when_switched_off_or_without_a_send_command(self):
self.assertIsNone(h.talimat({"secim": "buyuk"}, zamanla=""))
self.assertIsNone(h.talimat({"secim": "buyuk", "komut": " "}, zamanla="z"))
self.assertIsNone(h.talimat({"secim": "kapali", "komut": "x"}, "C:/a.exe", zamanla="z"))
self.assertIsNone(h.talimat({"enabled": False, "komut": "aiturk gonder"}))
self.assertIsNone(h.talimat({"enabled": False}, "C:/a/aiturk.exe", "s1"))
text = h.talimat({"secim": "buyuk", "komut": "aiturk gonder --dosya is.md"})
self.assertIn("aiturk gonder --dosya is.md", text)
self.assertIn("sen yap", text)
self.assertEqual(h.talimat({"enabled": True, "komut": "x", "talimat": "ozel {komut}"}), "ozel x")
def test_on_by_default_once_a_send_command_exists_on_this_computer(self):
text = h.talimat({"secim": "buyuk"}, "C:/Program/aiturk.exe", "019a-bc_d")
self.assertIn('"C:/Program/aiturk.exe" is --sohbet 019a-bc_d --dosya', text)
self.assertIn('"C:/Program/aiturk.exe" is --dosya', h.talimat({"talimat": h.ESKI}, "C:/Program/aiturk.exe", ""))
# Sohbet kimligi komut satirina yazilir: kabuk karakteri tasiyamaz.
self.assertIn("--sohbet abrm-rf ", h.komut_satiri("x", 'a"b; rm -rf /'))
# Ayardaki komut bulunanin onune gecer.
self.assertIn("elle", h.talimat({"secim": "buyuk", "komut": "elle"}, "C:/Program/aiturk.exe"))
def test_default_sends_repeating_work_to_aiturk_and_delegates_the_rest(self):
z = h.zamanla_satiri({"HERMES_HOME": "C:/ide/agent"})
self.assertIn("cron create", z)
self.assertIn("$env:HERMES_HOME='C:/ide/agent'", z)
self.assertEqual(h.zamanla_satiri({}), "")
for ayar in (None, {}, {"secim": "onerilen"}, {"secim": "bilinmeyen"}):
text = h.talimat(ayar, "C:/a.exe", "s1", zamanla="")
self.assertIn('"C:/a.exe" is --sohbet s1', text)
self.assertIn("Kodlama ve diğer işleri AITURK'e verme", text)
self.assertIn("alt ajan", text)
self.assertNotIn("kendin yap", text)
self.assertNotIn("{", text)
self.assertIsNone(h.talimat(None, None, zamanla=z))
self.assertEqual(h.talimat({"secim": "ozel", "talimat": "kendi kuralim"}, zamanla=""), "kendi kuralim")
self.assertIn("ozel z", h.talimat({"secim": "ozel", "talimat": "ozel {zamanla}"}, zamanla="z"))
self.assertIn("alt ajan", h.talimat({"secim": "ozel", "talimat": " "}, "C:/a.exe"))
def test_the_first_candidate_that_knows_the_command_is_used(self):
import os
import tempfile
with tempfile.TemporaryDirectory() as d:
eski = os.path.join(d, "TurkServis", "AITURK", "program", "bin", "aiturk.cmd")
yeni = os.path.join(d, "TurkServis", "AITURK-is-hatti", "Scripts", "aiturk.exe")
for yol in (eski, yeni):
os.makedirs(os.path.dirname(yol))
open(yol, "w").close()
ortam = {"LOCALAPPDATA": d}
self.assertEqual(h.adaylar(ortam)[0], eski)
self.assertEqual(h.komut_bul(ortam, destek=lambda y: y == yeni), yeni)
self.assertEqual(h.komut_bul(ortam, destek=lambda y: True), eski)
self.assertIsNone(h.komut_bul(ortam, destek=lambda y: False))
class Sonuc:
returncode = 2
self.assertFalse(h.destekliyor(eski, calistir=lambda *a, **k: Sonuc()))
Sonuc.returncode = 0
self.assertTrue(h.destekliyor(eski, calistir=lambda *a, **k: Sonuc()))
self.assertFalse(h.destekliyor(os.path.join(d, "yok.exe"), calistir=lambda *a, **k: Sonuc()))
def patlar(*a, **k):
raise OSError("x")
self.assertFalse(h.destekliyor(eski, calistir=patlar))
def test_instruction_is_put_first_once_and_never_repeated(self):
req = {"input": [{"type": "message", "role": "user", "content": "selam"}]}
text = h.talimat({"secim": "buyuk", "komut": "aiturk gonder"})
self.assertTrue(h.ekle(req, text))
self.assertEqual((req["input"][0]["role"], len(req["input"])), ("developer", 2))
self.assertFalse(h.ekle(req, text))
self.assertEqual(len(req["input"]), 2)
self.assertFalse(h.ekle({"input": "duz metin"}, text))
self.assertFalse(h.ekle(req, None))
if __name__ == "__main__":
unittest.main()