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
5 changes: 3 additions & 2 deletions tooling/dependency_graph_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@

def find_dependency_files(root_dir):
"""Finds all package.json and requirements.txt files, excluding node_modules."""
package_json_files = [os.path.join(root_dir, f) for f in find_files("package.json", root_dir)]
requirements_txt_files = [os.path.join(root_dir, f) for f in find_files("requirements.txt", root_dir)]
# find_files already returns paths relative to root_dir, so no join is needed.
package_json_files = find_files("package.json", root_dir)
requirements_txt_files = find_files("requirements.txt", root_dir)
return package_json_files, requirements_txt_files


Expand Down
15 changes: 7 additions & 8 deletions tooling/filesystem_lister.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,34 @@ def list_all_files_and_dirs(root_dir=".", use_gitignore=True):
item_list = []
gitignore_patterns = _get_gitignore_patterns(os.path.join(root_dir, ".gitignore")) if use_gitignore else []

# Always add the root directory representation.
item_list.append('./')

for root, dirs, files in os.walk(root_dir, topdown=True):
# Filter directories in-place to prevent os.walk from traversing them
if use_gitignore:
original_dirs = list(dirs)
dirs[:] = []
for d in original_dirs:
dir_path = os.path.join(root, d)
rel_dir_path = os.path.relpath(dir_path, root_dir) + "/"
rel_dir_path = os.path.normpath(os.path.relpath(dir_path, root_dir)) + "/"
if not any(fnmatch.fnmatch(rel_dir_path, p) for p in gitignore_patterns):
dirs.append(d)

# Add directories to the list
for d in dirs:
dir_path = os.path.join(root, d)
item_list.append(os.path.relpath(dir_path, root_dir) + "/")
item_list.append(os.path.normpath(os.path.relpath(dir_path, root_dir)) + "/")

# Add files to the list
for f in files:
file_path = os.path.join(root, f)
rel_file_path = os.path.relpath(file_path, root_dir)
rel_file_path = os.path.normpath(os.path.relpath(file_path, root_dir))
if use_gitignore:
if not any(fnmatch.fnmatch(rel_file_path, p) for p in gitignore_patterns):
item_list.append(rel_file_path)
else:
item_list.append(rel_file_path)

# Add the root directory itself if it's not ignored
if root_dir == ".":
if not use_gitignore or not any(fnmatch.fnmatch("./", p) for p in gitignore_patterns):
item_list.append("./")

# Use a set to remove potential duplicates and then sort for consistent output.
return sorted(list(set(item_list)))
55 changes: 0 additions & 55 deletions tooling/master_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,61 +254,6 @@ def _validate_plan_with_cli(self, plan_content: str) -> (bool, str):
if current_state not in self.fsm["final_states"] and current_state != "EXECUTING":
return False, f"Plan does not end in a valid state. Final state: '{current_state}'"

return True, ""

def validate_plan_for_model(self, plan_content: str, model: str) -> (bool, str):
"""
Validates a plan against a specific model's FSM.
"""
fsm_path = f"tooling/fsm_model_{model.lower()}.json"
if not os.path.exists(fsm_path):
return False, f"FSM for model '{model}' not found at '{fsm_path}'."
with open(fsm_path, "r") as f:
fsm = json.load(f)

ACTION_TYPE_MAP = {
"set_plan": "plan_op",
"message_user": "step_op",
"plan_step_complete": "step_op",
"submit": "submit_op",
"create_file_with_block": "write_op",
"overwrite_file_with_block": "write_op",
"replace_with_git_merge_diff": "write_op",
"read_file": "read_op",
"list_files": "read_op",
"grep": "read_op",
"delete_file": "delete_op",
"rename_file": "move_op",
"run_in_bash_session": "tool_exec",
"call_plan": "call_plan_op",
"research": "research_requested",
"define_set_of_names": "define_names_op",
"define_diagonalization_function": "define_diag_op",
}

commands = parse_plan(plan_content)
current_state = "PLANNING" # Validation always starts from the PLANNING state

for command in commands:
action_type = ACTION_TYPE_MAP.get(command.tool_name)
if not action_type:
return False, f"Unknown command '{command.tool_name}' in plan."

next_state = None
for transition in fsm["transitions"]:
if transition["source"] == current_state and transition["trigger"] == action_type:
next_state = transition["dest"]
break

if not next_state:
return False, f"Invalid FSM transition for model '{model}'. Cannot perform action '{action_type}' (from tool '{command.tool_name}') from state '{current_state}'."

current_state = next_state

if current_state not in fsm["final_states"] and current_state != "EXECUTING":
return False, f"Plan does not end in a valid state for model '{model}'. Final state: '{current_state}'"

return True, ""

def validate_plan_for_model(self, plan_content: str, model: str) -> (bool, str):
"""
Expand Down