|
16 | 16 |
|
17 | 17 | from cecli import urls, utils |
18 | 18 | from cecli.change_tracker import ChangeTracker |
| 19 | +from cecli.helpers import nested |
19 | 20 | from cecli.helpers.similarity import ( |
20 | 21 | cosine_similarity, |
21 | 22 | create_bigram_vector, |
@@ -105,50 +106,61 @@ def _get_agent_config(self): |
105 | 106 | self.io.tool_warning(f"Failed to parse agent-config JSON: {e}") |
106 | 107 | return {} |
107 | 108 |
|
108 | | - if "large_file_token_threshold" not in config: |
109 | | - config["large_file_token_threshold"] = 25000 |
110 | | - |
111 | | - if "tools_paths" not in config: |
112 | | - config["tools_paths"] = [] |
113 | | - if "tools_includelist" not in config: |
114 | | - config["tools_includelist"] = [] |
115 | | - if "tools_excludelist" not in config: |
116 | | - config["tools_excludelist"] = [] |
| 109 | + config["large_file_token_threshold"] = nested.getter( |
| 110 | + config, "large_file_token_threshold", 25000 |
| 111 | + ) |
| 112 | + config["skip_cli_confirmations"] = nested.getter( |
| 113 | + config, "skip_cli_confirmations", nested.getter(config, "yolo", []) |
| 114 | + ) |
117 | 115 |
|
118 | | - if "include_context_blocks" in config: |
119 | | - self.allowed_context_blocks = set(config["include_context_blocks"]) |
120 | | - else: |
121 | | - self.allowed_context_blocks = { |
122 | | - "context_summary", |
123 | | - "directory_structure", |
124 | | - "environment_info", |
125 | | - "git_status", |
126 | | - "symbol_outline", |
127 | | - "todo_list", |
128 | | - "skills", |
129 | | - } |
| 116 | + config["tools_paths"] = nested.getter(config, "tools_paths", []) |
| 117 | + config["tools_includelist"] = nested.getter( |
| 118 | + config, ["tools_includelist", "tools_whitelist"], [] |
| 119 | + ) |
| 120 | + config["tools_excludelist"] = nested.getter( |
| 121 | + config, ["tools_excludelist", "tools_blacklist"], [] |
| 122 | + ) |
130 | 123 |
|
131 | | - if "exclude_context_blocks" in config: |
132 | | - for context_block in config["exclude_context_blocks"]: |
133 | | - try: |
134 | | - self.allowed_context_blocks.remove(context_block) |
135 | | - except KeyError: |
136 | | - pass |
| 124 | + config["include_context_blocks"] = set( |
| 125 | + nested.getter( |
| 126 | + config, |
| 127 | + "include_context_blocks", |
| 128 | + { |
| 129 | + "context_summary", |
| 130 | + "directory_structure", |
| 131 | + "environment_info", |
| 132 | + "git_status", |
| 133 | + "symbol_outline", |
| 134 | + "todo_list", |
| 135 | + "skills", |
| 136 | + }, |
| 137 | + ) |
| 138 | + ) |
| 139 | + config["exclude_context_blocks"] = set(nested.getter(config, "exclude_context_blocks", [])) |
137 | 140 |
|
138 | 141 | self.large_file_token_threshold = config["large_file_token_threshold"] |
139 | | - self.skip_cli_confirmations = config.get( |
140 | | - "skip_cli_confirmations", config.get("yolo", False) |
141 | | - ) |
| 142 | + self.skip_cli_confirmations = config["skip_cli_confirmations"] |
| 143 | + |
| 144 | + self.allowed_context_blocks = config["include_context_blocks"] |
| 145 | + |
| 146 | + for context_block in config["exclude_context_blocks"]: |
| 147 | + try: |
| 148 | + self.allowed_context_blocks.remove(context_block) |
| 149 | + except KeyError: |
| 150 | + pass |
142 | 151 |
|
143 | 152 | if "skills" in self.allowed_context_blocks: |
144 | | - if "skills_paths" not in config: |
145 | | - config["skills_paths"] = [] |
146 | | - if "skills_includelist" not in config: |
147 | | - config["skills_includelist"] = [] |
148 | | - if "skills_excludelist" not in config: |
149 | | - config["skills_excludelist"] = [] |
150 | | - |
151 | | - if "skills" not in self.allowed_context_blocks or not config.get("skills_paths", []): |
| 153 | + config["skills_paths"] = nested.getter(config, "skills_paths", []) |
| 154 | + config["skills_includelist"] = nested.getter( |
| 155 | + config, ["skills_includelist", "skills_whitelist"], [] |
| 156 | + ) |
| 157 | + config["skills_excludelist"] = nested.getter( |
| 158 | + config, ["skills_excludelist", "skills_blacklist"], [] |
| 159 | + ) |
| 160 | + |
| 161 | + if "skills" not in self.allowed_context_blocks or not nested.getter( |
| 162 | + config, "skills_paths", [] |
| 163 | + ): |
152 | 164 | config["tools_excludelist"].append("loadskill") |
153 | 165 | config["tools_excludelist"].append("removeskill") |
154 | 166 |
|
|
0 commit comments