Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 1 addition & 32 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,4 @@ This repository uses a hierarchical, decentralized protocol system. Each of the

## Root Protocols

General protocols are defined in the [root protocol module](./protocols/AGENTS.md).
# --- Child Protocol Modules ---

This repository uses a hierarchical protocol system. Each of the following directories contains a self-contained set of protocols in its own `AGENTS.md` file.
- [Compliance](protocols/compliance/AGENTS.md)
- [Core](protocols/core/AGENTS.md)
- [Critic](protocols/critic/AGENTS.md)
- [Security](protocols/security/AGENTS.md)
- [Self-improvement](protocols/self-improvement/AGENTS.md)
- [Testing](protocols/testing/AGENTS.md)
- [Self_improvement](protocols/self_improvement/AGENTS.md)


# Jules' Plan

1. *Create a `jules_agent` directory in `tooling`.* This will house the logic for my agent's operations.
2. *Implement a `plan_manager.py` in `tooling/jules_agent`.* This module will be responsible for creating, updating, and storing the plan in the correct `AGENTS.md` file based on the current working directory.
3. *Implement an `action_logger.py` in `tooling/jules_agent`.* This module will be responsible for logging actions to the correct `AGENTS.md` file.
4. *Integrate the `plan_manager` and `action_logger` into my workflow.* I will call these tools to update the `AGENTS.md` files as I work.
5. *Complete pre commit steps*
- Complete pre commit steps to make sure proper testing, verifications, reviews and reflections are done.
6. *Submit the change.*
- Once the new `AGENTS.md` is generated and integrated, I will submit the change.



# Jules' Action Log

- 2025-10-18 22:04:02: Created `tooling/jules_agent` directory.
- 2025-10-18 22:04:02: Implemented `plan_manager.py`.
- 2025-10-18 22:04:02: Implemented `action_logger.py`.
- 2025-10-18 22:04:02: Injected the current plan into the root AGENTS.md.
General protocols are defined in the [root protocol module](./protocols/AGENTS.md).
2 changes: 1 addition & 1 deletion knowledge_core/dependency_graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
"target": "ply"
},
{
"source": "root-python-.project",
"source": "root-python-project",
"target": "black"
},
{
Expand Down
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ markdown
ply
black
flake8
jsonschema
rdflib
markdown
pypdf
requests
watchdog
ply
11 changes: 0 additions & 11 deletions tooling/agent_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import uuid
import os
import sys
import subprocess

# Add the root directory to the path to allow for absolute imports
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
Expand All @@ -38,16 +37,6 @@ def run_agent_loop(task_description: str, tools: dict, model: str = None):
"""
The main loop that drives the agent's lifecycle via the FSM.
"""
# Install dependencies from requirements.txt
try:
print("[AgentShell] Installing dependencies from requirements.txt...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
print("[AgentShell] Dependencies installed successfully.")
except subprocess.CalledProcessError as e:
print(f"[AgentShell] Error installing dependencies: {e}")
# Depending on the desired behavior, you might want to exit or handle the error
# For now, we'll just print the error and continue.

# 1. Initialize State and Logger
task_id = f"task-{uuid.uuid4()}"
agent_state = AgentState(task=task_id)
Expand Down
48 changes: 20 additions & 28 deletions tooling/capability_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
import argparse
import subprocess
import sys
import os
import tempfile
import shutil
import json

def main():
"""
Expand Down Expand Up @@ -62,33 +58,29 @@ def main():

# Step 2: Create a lesson and invoke the self-correction orchestrator
print("\n--- Step 2: Invoking self-correction ---")
temp_dir = tempfile.mkdtemp()
try:
lesson_content = {
"lesson_id": "verify-fibonacci-capability",
"status": "pending",
"failure": {
"test_file": args.test_file,
"error_message": initial_result.stderr
},
"action": {
"type": "PROPOSE_CODE_CHANGE",
"parameters": {
"filepath": "self_improvement_project/main.py",
"diff": "No-op for this test, as the fix is already applied."
}
lesson_content = {
"lesson_id": "verify-fibonacci-capability",
"status": "pending",
"failure": {
"test_file": args.test_file,
"error_message": initial_result.stderr
},
"action": {
"type": "PROPOSE_CODE_CHANGE",
"parameters": {
"filepath": "self_improvement_project/main.py",
"diff": "No-op for this test, as the fix is already applied."
}
}
lesson_file_path = os.path.join(temp_dir, "lessons.jsonl")
with open(lesson_file_path, "w") as f:
f.write(json.dumps(lesson_content) + "\n")
}
import json
with open("knowledge_core/lessons.jsonl", "w") as f:
f.write(json.dumps(lesson_content) + "\n")

orchestrator_result = subprocess.run(
[sys.executable, "tooling/self_correction_orchestrator.py", f"--lesson-file={lesson_file_path}"],
capture_output=True, text=True
)
finally:
shutil.rmtree(temp_dir)
orchestrator_result = subprocess.run(
[sys.executable, "tooling/self_correction_orchestrator.py"],
capture_output=True, text=True
)
if orchestrator_result.returncode != 0:
print("Error: Self-correction orchestrator failed.")
print(orchestrator_result.stderr)
Expand Down
39 changes: 0 additions & 39 deletions tooling/jules_agent/action_logger.py

This file was deleted.

35 changes: 0 additions & 35 deletions tooling/jules_agent/plan_manager.py

This file was deleted.

24 changes: 24 additions & 0 deletions tooling/protocol_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from tooling.protocol_manager import create_protocol, update_version
from tooling.protocol_oracle import get_applicable_protocols, get_rules_for_protocols
from rdflib import Graph
import os

class ProtocolAPI:
def __init__(self, protocols_dir="protocols", knowledge_graph_path="knowledge_core/protocols.ttl"):
self.protocols_dir = protocols_dir
self.knowledge_graph_path = knowledge_graph_path
self.graph = Graph()
if os.path.exists(self.knowledge_graph_path):
self.graph.parse(self.knowledge_graph_path, format="turtle")

def create_protocol(self, name, directory=None):
if directory is None:
directory = self.protocols_dir
create_protocol(name, directory)

def update_protocol_version(self, protocol_id, new_version):
update_version(protocol_id, new_version)

def get_applicable_rules(self, context):
applicable_protocols = get_applicable_protocols(self.graph, context)
return get_rules_for_protocols(self.graph, applicable_protocols)
33 changes: 21 additions & 12 deletions tooling/protocol_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ def compile_single_module(source_dir, target_file, schema_file, knowledge_graph=
os.rename(temp_target_file, target_file)

def compile_module_wrapper(path_to_protocol_dir):
"""Wrapper to execute the local build script in a given protocol directory."""
local_builder = os.path.join(path_to_protocol_dir, LOCAL_BUILD_SCRIPT_NAME)
if not os.path.exists(local_builder):
# This is not an error, it just means it's a directory with no build script.
# It might just contain other protocol modules.
return path_to_protocol_dir, True # Return True as there was no failure.
try:
print(f"--- Executing local builder: {local_builder} ---")
subprocess.check_call([sys.executable, local_builder], cwd=path_to_protocol_dir, stdout=sys.stdout, stderr=sys.stderr)
Expand Down Expand Up @@ -246,28 +251,32 @@ def main_orchestrator():
print("--- Starting Parallel Protocol Build Orchestration ---")
start_time = time.time()

# find_protocol_dirs should be adapted to find dirs containing 'build.py'
all_dirs = find_protocol_dirs(ROOT_PROTOCOLS_DIR)

build_script_dirs = [d for d in all_dirs if os.path.exists(os.path.join(d, LOCAL_BUILD_SCRIPT_NAME))]

if not build_script_dirs:
print("No protocol directories with a 'build.py' script found. Exiting.", file=sys.stderr)
all_protocol_dirs = find_protocol_dirs(ROOT_PROTOCOLS_DIR)
if not all_protocol_dirs:
print("No protocol directories found. Exiting.")
return

successful_compilations = []
failed_compilations = []

with ThreadPoolExecutor() as executor:
future_to_dir = {executor.submit(compile_module_wrapper, dir_path): dir_path for dir_path in build_script_dirs}
future_to_dir = {executor.submit(compile_module_wrapper, dir_path): dir_path for dir_path in all_protocol_dirs}
for future in as_completed(future_to_dir):
path, success = future.result()
if not success:
print(f"\n--- Compilation failed for: {get_protocol_dir_name(path)} ---")
sys.exit(1)
if success:
successful_compilations.append(path)
else:
failed_compilations.append(path)

if failed_compilations:
print("\n--- Compilation Summary: Failures Detected ---")
for path in failed_compilations:
print(f"- {get_protocol_dir_name(path)}")
sys.exit(1)

print("\n--- All protocol modules compiled successfully. ---")

generate_root_agents_md(build_script_dirs)
generate_root_agents_md(successful_compilations)

print("\n--- Parallel Protocol Build Orchestration Finished ---")

Expand Down
7 changes: 0 additions & 7 deletions tooling/requirements.txt

This file was deleted.

26 changes: 10 additions & 16 deletions tooling/self_correction_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@
import json
import os
import subprocess
import argparse

LESSONS_FILE = "knowledge_core/lessons.jsonl"
UPDATER_SCRIPT = "tooling/protocol_updater.py"
CODE_SUGGESTER_SCRIPT = "tooling/code_suggester.py"


def load_lessons(lesson_file):
def load_lessons():
"""Loads all lessons from the JSONL file."""
if not os.path.exists(lesson_file):
if not os.path.exists(LESSONS_FILE):
return []

with open(lesson_file, "r") as f:
with open(LESSONS_FILE, "r") as f:
return [json.loads(line) for line in f]


def save_lessons(lessons, lesson_file):
def save_lessons(lessons):
"""Saves a list of lessons back to the JSONL file, overwriting it."""
with open(lesson_file, "w") as f:
with open(LESSONS_FILE, "w") as f:
for lesson in lessons:
f.write(json.dumps(lesson) + "\n")

Expand Down Expand Up @@ -161,18 +160,13 @@ def main():
"""
Main function to run the self-correction workflow.
"""
parser = argparse.ArgumentParser(description="Orchestrate the Protocol-Driven Self-Correction (PDSC) workflow.")
parser.add_argument(
"--lesson-file",
default=LESSONS_FILE,
help="Path to the lessons JSONL file."
)
args = parser.parse_args()

# This script is intended to be called from a controlled environment
# like a test or a dedicated plan, so we don't use argparse here.
# The search for protocols should start from the repository root.
protocols_directory = "."

print("--- Starting Protocol-Driven Self-Correction Cycle ---")
lessons = load_lessons(args.lesson_file)
lessons = load_lessons()

if not any(lesson.get("status") == "pending" for lesson in lessons):
print("No pending lessons to process. Exiting.")
Expand All @@ -181,7 +175,7 @@ def main():
changes_were_applied = process_lessons(lessons, protocols_directory)

print("\n--- Saving updated lesson statuses ---")
save_lessons(lessons, args.lesson_file)
save_lessons(lessons)

if changes_were_applied:
print("\n--- Protocol sources updated. Rebuilding AGENTS.md... ---")
Expand Down
Loading