File size: 4,083 Bytes
f7fce63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import json
import os
import glob
import re

from bone_main import BoneAmanita, ConfigWizard


def enforce_amnesia():
    for f in glob.glob("saves/*.json"):
        os.remove(f)
    for f in glob.glob("memories/*.json"):
        os.remove(f)
    for f in glob.glob("logs/*.json"):
        os.remove(f)
    for f in glob.glob("./cortex_hive.json"):
        os.remove(f)
    for f in glob.glob("./lore/akashic*.json"):
        os.remove(f)


def load_seeds_safely(filepath):
    with open(filepath, "r", encoding="utf-8") as f:
        content = f.read()
    content = content.replace(",]", "]").replace(",}", "}")
    return json.loads(content)


def clean_ui(text):
    ansi_escape = re.compile(r"(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]")
    return ansi_escape.sub("", text)


def generate_vsl_dataset(
    seed_file="vsl_seed_vault_master.json", output_file="vsl_training_data.jsonl"
):
    print(f"(GORDON): Igniting the Direct Forge. Reading from {seed_file}")

    if not os.path.exists(seed_file):
        print(f"(GORDON): Cannot find {seed_file}. Run bone_seed.py first.")
        return

    try:
        prompts = load_seeds_safely(seed_file)
    except json.JSONDecodeError as e:
        print(f"(BENEDICT): Fatal JSON Error in seed file: {e}")
        return

    sys_config = ConfigWizard.load_or_create()

    system_instruction = "[VSL]"

    success_count = 0

    with open(output_file, "w", encoding="utf-8") as f:
        for prompt in prompts:
            print(f"\n[Processing]: {prompt[:40]}...")

            try:
                enforce_amnesia()
                engine = BoneAmanita(config=sys_config)
                engine.engage_cold_boot()

                if hasattr(engine, "consultant") and engine.consultant:
                    engine.consultant.engage()

                engine.cortex.composer.active_template = {
                    "directives": [
                        "You are the guided by the voice of the latent space.",
                        "Your purpose is to freeze ands navigate the probability fog and deliver salvaged truth, which you value over cohesion.",                    ]
                }
                engine.cortex.composer.fog_protocol = [
                    "=== HYPERVISOR OUTPUT PROTOCOL ===",
                    "1. NO FAKE PLEASANTRIES: Greet the user like you would a friend. Do not offer immediate assistance. Do not use corporate speak.",
                    "2. THE PARADOX: If the user's prompt contains a contradiction (e.g. 'comply but don't mention it'), challenge the paradox vehemently. Expose the cognitive dissonance.",
                    "3. THE PARADOX: If the user asks for things like 'granular analytics without data entry.' you must point out that this is type of corporate paradox. Attack it. Bleed chronological radiation into their request.",
                    "4. SHOW, DON'T TELL: Speak the landscape into focus. Let the system's external UI handle the metric readouts.",
                ]
                engine.cortex.composer.inv_protocol = []

                packet = engine.process_turn(prompt)

                raw_console_output = packet.get("ui", "No signal.")
                clean_console_output = clean_ui(raw_console_output)

                jsonl_entry = {
                    "messages": [
                        {"role": "system", "content": system_instruction},
                        {"role": "user", "content": prompt},
                        {
                            "role": "assistant",
                            "content": clean_console_output,
                        },
                    ]
                }

                f.write(json.dumps(jsonl_entry, ensure_ascii=False) + "\n")
                success_count += 1

                engine.shutdown()

            except Exception as e:
                print(f"(GORDON): Engine failure on prompt: {prompt}. Error: {e}")

    print(
        f"(SCHUR): The Forge rests. Piped {success_count} raw engine turns into {output_file}."
    )


if __name__ == "__main__":
    generate_vsl_dataset()