Skip to content

akiiwa-games/AgentCompass / skills/dot-subagent

dot-subagent

Verified

Leaf-only runner for the local OpenAI Dot through dot2api. Use only after agent-compass has chosen Dot. Covers the runner, packets, code written and run on Dot's own computer, and how data reaches it (public re-fetch, text packets, the private GitHub repository) and how results come back. No routing and no spawning children.

scripts/test_pack_chunks.py

View on GitHub
import base64
import hashlib
import json
from pathlib import Path
import random
import re
import tempfile
import unittest
import zlib

import pack_chunks


def simulate_dot(out):
    """Rebuild the file the way the part and assemble packets tell Dot to, from the packet texts alone."""
    payload = b""
    for packet in sorted(Path(out).glob("part_*.md")):
        text = packet.read_text(encoding="utf-8")
        b64 = text.split("BEGIN_B64\n", 1)[1].rsplit("END_B64", 1)[0]
        payload += base64.b64decode(b64)
    return payload


class PackTests(unittest.TestCase):
    def setUp(self):
        self.directory = tempfile.TemporaryDirectory()
        self.addCleanup(self.directory.cleanup)
        self.base = Path(self.directory.name)
        rng = random.Random(7)
        self.data = bytes(rng.randrange(256) for _ in range(5000)) + b"abc" * 40000
        self.source = self.base / "table.bin"
        self.source.write_bytes(self.data)

    def test_parts_rejoin_to_the_payload_and_unpack_to_the_original_for_every_codec(self):
        for codec in pack_chunks.CODECS:
            out = self.base / f"out_{codec}"
            manifest = pack_chunks.pack(self.source, out, chunk_bytes=3000, codec=codec)
            payload = simulate_dot(out)
            for packet in out.glob("part_*.md"):
                body = packet.read_text(encoding="utf-8").split("BEGIN_B64\n", 1)[1].rsplit("END_B64", 1)[0]
                self.assertTrue(all(len(line) <= 76 for line in body.splitlines()))
                self.assertTrue(re.fullmatch(r"[A-Za-z0-9+/=\n]*", body))
            self.assertEqual(hashlib.sha256(payload).hexdigest(), manifest["payload_sha256"], codec)
            self.assertEqual(len(payload), manifest["payload_bytes"], codec)
            if codec == "zlib":
                self.assertEqual(zlib.decompress(payload), self.data)
            if codec == "none":
                self.assertEqual(payload, self.data)
                self.assertGreater(len(manifest["parts"]), 1)

    def test_each_packet_is_self_contained_and_names_its_own_directory_and_part(self):
        out = self.base / "out"
        manifest = pack_chunks.pack(self.source, out, chunk_bytes=3000, codec="none", xfer="job1")
        first = (out / "part_001.md").read_text(encoding="utf-8")
        self.assertIn("$ROOT/rm-xfer-job1/part_001.b64", first)
        self.assertIn("DOT_WORK_ROOT", first)
        self.assertIn("TemporaryFile", (out / "assemble.md").read_text(encoding="utf-8"))
        self.assertIn(f"PART: 1/{len(manifest['parts'])}", first)
        assemble = (out / "assemble.md").read_text(encoding="utf-8")
        self.assertIn(manifest["original_sha256"], assemble)
        self.assertIn("rm -rf", assemble)
        kept = pack_chunks.pack(self.source, self.base / "kept", chunk_bytes=3000, codec="none", delete_after=False)
        self.assertNotIn("rm -rf", (self.base / "kept" / "assemble.md").read_text(encoding="utf-8"))
        self.assertEqual(kept["original_sha256"], manifest["original_sha256"])

    def test_unsafe_names_a_busy_directory_and_bad_options_are_refused(self):
        bad = self.base / "my file.bin"
        bad.write_bytes(b"x")
        with self.assertRaises(ValueError):
            pack_chunks.pack(bad, self.base / "o1")
        with self.assertRaises(ValueError):
            pack_chunks.pack(self.source, self.base / "o2", xfer="a/b")
        with self.assertRaises(ValueError):
            pack_chunks.pack(self.source, self.base / "o3", codec="gzip")
        busy = self.base / "o4"
        busy.mkdir()
        (busy / "x").write_text("mine")
        with self.assertRaises(ValueError):
            pack_chunks.pack(self.source, busy)

    def test_check_accepts_matching_replies_and_flags_missing_or_wrong_ones(self):
        out = self.base / "out"
        manifest = pack_chunks.pack(self.source, out, chunk_bytes=20000, codec="zlib")
        replies = self.base / "replies"
        replies.mkdir()
        for part in manifest["parts"]:
            (replies / f"reply_part_{part['n']:03d}.md").write_text(
                f"EXECUTED: yes\r\nPART: {part['n']}/{len(manifest['parts'])}\r\nBIN_BYTES: {part['bytes']}\r\nBIN_SHA256: {part['sha256']}\r\n", encoding="utf-8")
        self.assertFalse(all(ok for _, ok, _ in pack_chunks.check(out, replies)))   # no assemble reply yet
        (replies / "reply_assemble.md").write_text(
            f"EXECUTED: yes\nPAYLOAD_SHA256: {manifest['payload_sha256']}\nFILE_BYTES: {manifest['original_bytes']}\n"
            f"FILE_SHA256: {manifest['original_sha256']}\n", encoding="utf-8")
        self.assertTrue(all(ok for _, ok, _ in pack_chunks.check(out, replies)))
        (replies / "reply_part_001.md").write_text("EXECUTED: yes\nBIN_BYTES: 1\nBIN_SHA256: " + "0" * 64 + "\n", encoding="utf-8")
        results = dict((what, ok) for what, ok, _ in pack_chunks.check(out, replies))
        self.assertFalse(results["part 1"])
        self.assertEqual(pack_chunks.main(["check", str(out), str(replies)]), 1)



if __name__ == "__main__":
    unittest.main()
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall