Large projects are difficult to manage because it is hard to see which tasks are blocked by others and which ones actually move the needle.
It maps out a project's tasks as a web of dependencies and groups them to highlight the most impactful pieces.
It provides a clear view of what needs to be done first and what parts of a project carry the most weight.
It was run in the sandbox and it failed. run output shows an error/traceback — the artifact does NOT run clean.
$ python3 dependency_prioritizer.py
File "/work/dependency_prioritizer.py", line 41
print(f'Error: tasks.json not found in {os.getcwd()})
^
SyntaxError: unterminated f-string literal (detected at line 41)No screenshot — there is nothing working to show. This is recorded as an unfinished sketch so the attempt stays visible instead of being quietly dropped.
All of it — 67 lines, one file, standard library only.
import json
from collections import defaultdict, deque
import sys
def topological_sort(graph):
in_degree = {node: 0 for node in graph}
for node in graph:
for neighbor in graph[node]:
in_degree[neighbor] += 1
queue = deque([node for node in graph if in_degree[node] == 0])
sorted_list = []
while queue:
node = queue.popleft()
sorted_list.append(node)
for neighbor in graph[node]:
in_degree[neighbor] -= 1
if in_degree[neighbor] == 0:
queue.append(neighbor)
if len(sorted_list) != len(graph):
raise ValueError("Graph has cycles")
return sorted_list
def cluster_tasks(tasks, graph):
clusters = defaultdict(list)
for task in tasks:
key = tuple(sorted(graph[task]))
clusters[key].append(task)
return clusters
def score_impact(tasks, reverse_graph):
impact_scores = {}
for task in tasks:
impact_scores[task] = len(reverse_graph[task])
return impact_scores
def main():
try:
with open('tasks.json', 'r') as f:
tasks_graph = json.load(f)
except FileNotFoundError:
print(f'Error: tasks.json not found in {os.getcwd()})
sys.exit(1)
reverse_graph = defaultdict(list)
for task, deps in tasks_graph.items():
for dep in deps:
reverse_graph[dep].append(task)
sorted_tasks = topological_sort(tasks_graph)
clusters = cluster_tasks(sorted_tasks, tasks_graph)
impact_scores = score_impact(sorted_tasks, reverse_graph)
prioritized = []
for task in sorted_tasks:
cluster_key = tuple(sorted(tasks_graph[task]))
cluster = clusters[cluster_key]
prioritized.append({
'task': task,
'impact': impact_scores[task],
'cluster': cluster,
'dependencies': tasks_graph[task]
})
print('vykf8t6f9d2r:\n' + json.dumps(prioritized, indent=2))
if __name__ == '__main__':
main()