- Default routing rule (user decision, 15 Oct 2026): repeating/scheduled work goes to the AITURK IDE bot as a cron job; coding stays in Codex (itself or its subagents); 'Codex' or 'sen yap' keeps everything in Codex. - Settings > Codex Bağlama: choice (recommended / send large work / never / custom text) with a text box and restore-default; written to bridge.json aiturk_hat. - Bridge re-reads aiturk_hat when bridge.json changes: no restart. IDE apply keeps aiturk_hat instead of wiping it. - Bridge version 20, IDE 1.0.0-beta.40. Jev untouched.
87 lines
4.6 KiB
Python
87 lines
4.6 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_scheduled_work_to_the_ide_bot_and_keeps_coding(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, None, zamanla=z)
|
|
self.assertIn("cron create", text)
|
|
self.assertIn("Kodlama işlerini AITURK'e verme", text)
|
|
self.assertIn("'Codex' ya da 'sen yap'", text)
|
|
self.assertNotIn("{", text)
|
|
self.assertIsNone(h.talimat(None, "C:/a.exe", zamanla=""))
|
|
self.assertEqual(h.talimat({"secim": "ozel", "talimat": "kendi kuralim"}, zamanla=""), "kendi kuralim")
|
|
self.assertIn("cron create", h.talimat({"secim": "ozel", "talimat": " "}, zamanla=z))
|
|
|
|
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()
|