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
2 changes: 2 additions & 0 deletions logs/activity.log.jsonl
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
{"log_id": "02407acd-2c50-4745-9e46-ba1f330169a2", "session_id": "d88cea14-f3c5-45d0-a13e-c714ff9bfa36", "timestamp": "2025-10-14T22:52:17.442544+00:00", "phase": "Phase 5", "task": {"id": "task-2bc79ace-1a93-4354-a01d-b6d728d6d7bd", "plan_step": -1}, "action": {"type": "POST_MORTEM", "details": {"path": "postmortems/2025-10-14-task-2bc79ace-1a93-4354-a01d-b6d728d6d7bd.md", "content": "# Post-Mortem Report for Task: task-2bc79ace-1a93-4354-a01d-b6d728d6d7bd\n\n## Agent Analysis\n\nThe task was a test run to verify the new logging and artifact generation. It completed successfully.\n"}}, "outcome": {"status": "SUCCESS", "message": ""}, "evidence_citation": ""}
{"log_id": "f36c37b1-964f-4f40-86c8-cf5816f260db", "session_id": "unknown", "timestamp": "2025-10-14T23:55:36.088914+00:00", "phase": "Phase 6", "task": {"id": "automated-logic-construction", "plan_step": -1}, "action": {"type": "TASK_START", "details": {"summary": "AORP cascade completed for FDC task 'automated-logic-construction'."}}, "outcome": {"status": "SUCCESS", "message": "FDC CLI: TASK_START for task automated-logic-construction."}}
{"log_id": "f4f3951d-7d75-4977-89ea-cfc6e4e41c40", "session_id": "unknown", "timestamp": "2025-10-14T23:56:10.573982+00:00", "phase": "Phase 6", "task": {"id": "automated-logic-construction", "plan_step": -1}, "action": {"type": "TASK_START", "details": {"summary": "AORP cascade completed for FDC task 'automated-logic-construction'."}}, "outcome": {"status": "SUCCESS", "message": "FDC CLI: TASK_START for task automated-logic-construction."}}
{"timestamp": "2025-10-15T19:21:37.430236+00:00", "event_type": "planning_started", "details": {"task_id": "test_task"}}
{"timestamp": "2025-10-15T19:21:37.430500+00:00", "event_type": "planning_failed", "details": {"task_id": "test_task", "error": "CRITICAL: Use of the forbidden tool `reset_all` was detected in the plan."}}
16 changes: 4 additions & 12 deletions tooling/dependency_graph_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,15 @@
import glob
import re

from utils.filesystem import find_files

# --- Finder Functions ---


def find_dependency_files(root_dir):
"""Finds all package.json and requirements.txt files, excluding node_modules."""
package_json_files = []
requirements_txt_files = []
for root, dirs, files in os.walk(root_dir):
# Exclude node_modules directories from the search
if "node_modules" in dirs:
dirs.remove("node_modules")

for file in files:
if file == "package.json":
package_json_files.append(os.path.join(root, file))
elif file == "requirements.txt":
requirements_txt_files.append(os.path.join(root, file))
package_json_files = find_files(root_dir, extensions=["package.json"], ignore_dirs=["node_modules"])
requirements_txt_files = find_files(root_dir, extensions=["requirements.txt"], ignore_dirs=["node_modules"])
return package_json_files, requirements_txt_files


Expand Down
1 change: 0 additions & 1 deletion tooling/master_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ def do_finalizing(
"POST_MORTEM",
{"path": final_path, "content": report_content},
"SUCCESS",
context=_get_log_context(agent_state),
)

# 4. Append lessons to knowledge_core/lessons.jsonl
Expand Down
2 changes: 1 addition & 1 deletion tooling/test_agent_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}

with patch.dict('sys.modules', {'__main__': MagicMock(**mock_main_imports)}):
from tooling.agent_shell import main
from tooling.agent_shell import main, run_agent_loop

class TestAgentShell(unittest.TestCase):

Expand Down
6 changes: 3 additions & 3 deletions tooling/test_dependency_graph_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ def test_find_files(self):
"""Test finding both package.json and requirements.txt files."""
js_files, py_files = find_dependency_files(self.test_dir)
self.assertEqual(len(js_files), 1)
self.assertIn(self.pkg_json_path, js_files)
self.assertIn(os.path.abspath(self.pkg_json_path), js_files)
self.assertEqual(len(py_files), 2)
self.assertIn(self.req_txt_path, py_files)
self.assertIn(self.root_req_txt_path, py_files)
self.assertIn(os.path.abspath(self.req_txt_path), py_files)
self.assertIn(os.path.abspath(self.root_req_txt_path), py_files)

def test_parse_package_json(self):
"""Test parsing a single package.json file."""
Expand Down
2 changes: 2 additions & 0 deletions tooling/test_master_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def setUp(self):
f.write(" ")
with open("tooling/self_correction_orchestrator.py", "w") as f:
f.write(" ")
with open("postmortems/structured_postmortem.md", "w") as f:
f.write("# Post-Mortem Report for Task: test-redesigned-workflow\n\n## Agent Analysis\n\nThe task was completed successfully.\n")

self.fsm_path = "tooling/fsm.json"
self.task_id = "test-redesigned-workflow"
Expand Down
55 changes: 55 additions & 0 deletions utils/filesystem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
This module provides a centralized, robust, and platform-agnostic interface for
all filesystem operations within the agent's toolkit.

It is designed to address the following systemic issues:
- **Inconsistent Path Handling:** All path manipulations are performed using
`os.path`, ensuring cross-platform compatibility.
- **Lack of Centralized File Discovery:** This module provides a single,
authoritative source for file and directory discovery.
- **Ad-Hoc Filtering and Ignoring:** A centralized ignore mechanism, similar to
`.gitignore`, is used to exclude irrelevant files and directories.
- **Insufficient Error Handling:** All traversal logic includes robust error
handling for common filesystem issues.
"""

import os

# --- Configuration ---

# A list of directories to ignore during file discovery.
IGNORE_DIRS = [".git", "archive", "reports", "postmortems", "logs"]


def find_files(root_dir=".", extensions=None, ignore_dirs=None):
"""
Recursively finds all files in a directory that match the given extensions,
excluding specified directories.

Args:
root_dir (str): The root directory to start the search from.
extensions (list, optional): A list of file extensions to include. If
None, all files are included. Defaults to None.
ignore_dirs (list, optional): A list of directory names to ignore. If
None, the default IGNORE_DIRS list is used. Defaults to None.

Returns:
list: A list of absolute paths to the found files.
"""
if ignore_dirs is None:
ignore_dirs = IGNORE_DIRS

found_files = []
try:
for root, dirs, files in os.walk(os.path.abspath(root_dir), topdown=True):
# Exclude ignored directories
dirs[:] = [d for d in dirs if d not in ignore_dirs]

for file in files:
if extensions is None or any(file.endswith(ext) for ext in extensions):
found_files.append(os.path.join(root, file))
except OSError as e:
# In a real application, you'd want to use a proper logger
print(f"Error during file discovery in '{root_dir}': {e}")

return found_files