|
128 | 128 | config (#'agents/md->agent-config parsed)] |
129 | 129 | (is (= "A primary agent" (:description config))) |
130 | 130 | (is (= "Do work." (:systemPrompt config))) |
131 | | - (is (nil? (:mode config)))))) |
| 131 | + (is (nil? (:mode config))))) |
| 132 | + |
| 133 | + (testing "tools as a YAML list normalizes to byDefault=ask + allow map (Claude form)" |
| 134 | + (let [md (str "---\n" |
| 135 | + "description: Reviewer\n" |
| 136 | + "tools:\n" |
| 137 | + " - read\n" |
| 138 | + " - search\n" |
| 139 | + " - agent\n" |
| 140 | + "---\n\n" |
| 141 | + "Body.") |
| 142 | + parsed (shared/parse-md md) |
| 143 | + config (#'agents/md->agent-config parsed)] |
| 144 | + (is (match? {:description "Reviewer" |
| 145 | + :systemPrompt "Body." |
| 146 | + :toolCall {:approval {:byDefault "ask" |
| 147 | + :allow {"read" {} |
| 148 | + "search" {} |
| 149 | + "agent" {}}}}} |
| 150 | + config)))) |
| 151 | + |
| 152 | + (testing "tools as a malformed string is ignored without crashing the agent" |
| 153 | + (let [config (#'agents/md->agent-config {:description "no tools" :tools "read"})] |
| 154 | + (is (= "no tools" (:description config))) |
| 155 | + (is (nil? (:toolCall config))))) |
| 156 | + |
| 157 | + (testing "tools as a number is ignored without crashing the agent" |
| 158 | + (let [config (#'agents/md->agent-config {:description "no tools" :tools 42})] |
| 159 | + (is (= "no tools" (:description config))) |
| 160 | + (is (nil? (:toolCall config)))))) |
| 161 | + |
| 162 | +(deftest normalize-tools-test |
| 163 | + (testing "map form passes through unchanged" |
| 164 | + (is (= {"byDefault" "ask" "allow" ["read"]} |
| 165 | + (#'agents/normalize-tools {"byDefault" "ask" "allow" ["read"]})))) |
| 166 | + (testing "vector form is wrapped as byDefault=ask + allow" |
| 167 | + (is (= {"byDefault" "ask" "allow" ["read" "search"]} |
| 168 | + (#'agents/normalize-tools ["read" "search"])))) |
| 169 | + (testing "list form (clojure list) is also accepted" |
| 170 | + (is (= {"byDefault" "ask" "allow" ["read" "search"]} |
| 171 | + (#'agents/normalize-tools '("read" "search"))))) |
| 172 | + (testing "nil returns nil" |
| 173 | + (is (nil? (#'agents/normalize-tools nil)))) |
| 174 | + (testing "string returns nil (treated as malformed)" |
| 175 | + (is (nil? (#'agents/normalize-tools "read")))) |
| 176 | + (testing "number returns nil (treated as malformed)" |
| 177 | + (is (nil? (#'agents/normalize-tools 42))))) |
132 | 178 |
|
133 | 179 | (deftest md-agents-from-directory-test |
134 | 180 | (let [tmp-dir (fs/create-temp-dir) |
|
310 | 356 | (testing "handles filenames with multiple dots" |
311 | 357 | (is (= "foo" (#'agents/agent-name-from-filename (fs/file "foo.bar.baz.md")))))) |
312 | 358 |
|
| 359 | +(deftest claude-tools-list-loads-agent-test |
| 360 | + (let [tmp-dir (fs/create-temp-dir) |
| 361 | + agents-dir (fs/file tmp-dir "agents")] |
| 362 | + (try |
| 363 | + (fs/create-dirs agents-dir) |
| 364 | + ;; Lucas's exact reproducer: tools as a YAML list (Claude convention). |
| 365 | + (spit (fs/file agents-dir "glp-engineer.agent.md") |
| 366 | + (str "---\n" |
| 367 | + "name: GLP-Reviewer\n" |
| 368 | + "description: \"Review any design document with DRC-style structured feedback and rubric scoring\"\n" |
| 369 | + "tools:\n" |
| 370 | + " - read\n" |
| 371 | + " - search\n" |
| 372 | + " - agent\n" |
| 373 | + "---\n\n" |
| 374 | + "You are a reviewer.")) |
| 375 | + (let [result (#'agents/agent-md-file->agent (fs/file agents-dir "glp-engineer.agent.md"))] |
| 376 | + (testing "agent is loaded (not silently dropped by tools-list parse error)" |
| 377 | + (is (some? result))) |
| 378 | + (testing "agent id comes from YAML name" |
| 379 | + (is (= "glp-reviewer" (first result)))) |
| 380 | + (testing "description is preserved" |
| 381 | + (is (= "Review any design document with DRC-style structured feedback and rubric scoring" |
| 382 | + (get-in (second result) [:description]))))) |
| 383 | + (finally |
| 384 | + (fs/delete-tree tmp-dir))))) |
| 385 | + |
313 | 386 | (deftest agent-id-precedence-test |
314 | 387 | (let [tmp-dir (fs/create-temp-dir) |
315 | 388 | agents-dir (fs/file tmp-dir "agents")] |
|
0 commit comments