MCPcopy Create free account
hub / github.com/OpenRaiser/NanoResearch / _normalize_code_plan

Method _normalize_code_plan

nanoresearch/agents/coding.py:55–121  ·  view source on GitHub ↗
(self, code_plan: dict[str, Any] | None)

Source from the content-addressed store, hash-verified

53 ]
54
55 def _normalize_code_plan(self, code_plan: dict[str, Any] | None) -> dict[str, Any]:
56 plan = dict(code_plan) if isinstance(code_plan, dict) else {}
57
58 normalized_files: list[dict[str, Any]] = []
59 seen_paths: set[str] = set()
60 for raw_spec in plan.get("files", []):
61 if not isinstance(raw_spec, dict):
62 continue
63 path = str(raw_spec.get("path") or "").strip().replace("\\", "/")
64 if not path or path in seen_paths:
65 continue
66 seen_paths.add(path)
67 normalized_files.append(
68 {
69 "path": path,
70 "description": str(raw_spec.get("description") or "").strip(),
71 "is_entrypoint": bool(raw_spec.get("is_entrypoint", False)),
72 }
73 )
74
75 for default_spec in self._default_code_plan_files():
76 if default_spec["path"] in seen_paths:
77 continue
78 normalized_files.append(dict(default_spec))
79 seen_paths.add(default_spec["path"])
80
81 dependencies: list[str] = []
82 seen_dependencies: set[str] = set()
83 for raw_dependency in plan.get("dependencies", []):
84 dependency = str(raw_dependency or "").strip()
85 if not dependency or dependency in seen_dependencies:
86 continue
87 seen_dependencies.add(dependency)
88 dependencies.append(dependency)
89 if not dependencies:
90 dependencies = [
91 "numpy>=1.24.0",
92 "pandas>=1.5.0",
93 "scikit-learn>=1.2.0",
94 "requests>=2.28.0",
95 ]
96
97 expected_output_files = [
98 str(item).strip()
99 for item in plan.get("expected_output_files", [])
100 if str(item).strip()
101 ]
102 if not expected_output_files:
103 expected_output_files = [
104 "configs/experiment_matrix.json",
105 "results/metrics.json",
106 "results/run_manifest.json",
107 "results/final_metrics.json",
108 "results/optimization_history.csv",
109 "results/pareto_front.json",
110 ]
111
112 normalized = {

Callers 1

_design_code_planMethod · 0.95

Calls 4

getMethod · 0.80
addMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected