1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub struct StdlibSource {
9 pub module: &'static str,
10 pub source: &'static str,
11}
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub struct StdlibPromptAsset {
15 pub path: &'static str,
16 pub source: &'static str,
17}
18
19macro_rules! embedded_catalog {
20 ($entry:ident, $key:ident, [$($name:literal => $path:literal),* $(,)?]) => {
21 &[
22 $($entry {
23 $key: $name,
24 source: include_str!($path),
25 },)*
26 ]
27 };
28}
29
30#[derive(Debug, Clone, PartialEq, Eq)]
31pub struct StdlibPublicFunction {
32 pub name: String,
33 pub signature: String,
34 pub required_params: usize,
35 pub total_params: usize,
36 pub variadic: bool,
37 pub doc: Option<String>,
38}
39
40#[derive(Debug, Clone, PartialEq, Eq)]
41pub struct StdlibEntrypointModule {
42 pub import_path: String,
43 pub category: String,
44}
45
46pub const STDLIB_SOURCES: &[StdlibSource] = embedded_catalog!(StdlibSource, module, [
47 "text" => "stdlib/stdlib_text.harn",
48 "semver" => "stdlib/stdlib_semver.harn",
49 "changelog" => "stdlib/stdlib_changelog.harn",
50 "ansi" => "stdlib/stdlib_ansi.harn",
51 "table" => "stdlib/stdlib_table.harn",
52 "diff" => "stdlib/stdlib_diff.harn",
53 "edit" => "stdlib/stdlib_edit.harn",
54 "edit/capabilities" => "stdlib/edit/capabilities.harn",
55 "edit/internal" => "stdlib/edit/internal.harn",
56 "edit/patch" => "stdlib/edit/patch.harn",
57 "edit/safe_patch" => "stdlib/edit/safe_patch.harn",
58 "edit/fast_apply" => "stdlib/edit/fast_apply.harn",
59 "ast" => "stdlib/stdlib_ast.harn",
60 "rules" => "stdlib/stdlib_rules.harn",
61 "lint" => "stdlib/stdlib_lint.harn",
62 "artifact/web" => "stdlib/artifact/web.harn",
63 "collections" => "stdlib/stdlib_collections.harn",
64 "math" => "stdlib/stdlib_math.harn",
65 "slug" => "stdlib/stdlib_slug.harn",
66 "path" => "stdlib/stdlib_path.harn",
67 "fs" => "stdlib/stdlib_fs.harn",
68 "run_artifacts" => "stdlib/stdlib_run_artifacts.harn",
69 "artifacts/typed" => "stdlib/artifacts/typed.harn",
70 "os" => "stdlib/stdlib_os.harn",
71 "json" => "stdlib/stdlib_json.harn",
72 "json/stream" => "stdlib/stdlib_json_stream.harn",
73 "xml" => "stdlib/stdlib_xml.harn",
74 "cache" => "stdlib/stdlib_cache.harn",
75 "observability" => "stdlib/stdlib_observability.harn",
76 "timing" => "stdlib/stdlib_timing.harn",
77 "verification" => "stdlib/stdlib_verification.harn",
78 "tools" => "stdlib/stdlib_tools.harn",
79 "composition" => "stdlib/stdlib_composition.harn",
80 "web" => "stdlib/stdlib_web.harn",
81 "graphql" => "stdlib/stdlib_graphql.harn",
82 "code_librarian" => "stdlib/stdlib_code_librarian.harn",
83 "schema" => "stdlib/stdlib_schema.harn",
84 "schema/contracts" => "stdlib/schema/contracts.harn",
85 "identity" => "stdlib/stdlib_identity.harn",
86 "disclosure" => "stdlib/stdlib_disclosure.harn",
87 "testing" => "stdlib/stdlib_testing.harn",
88 "files" => "stdlib/stdlib_files.harn",
89 "document" => "stdlib/stdlib_document.harn",
90 "mcp" => "stdlib/stdlib_mcp.harn",
91 "vision" => "stdlib/stdlib_vision.harn",
92 "context" => "stdlib/stdlib_context.harn",
93 "context/maintenance" => "stdlib/context/maintenance.harn",
94 "context/eval" => "stdlib/context/eval.harn",
95 "eval/stats" => "stdlib/stdlib_eval_stats.harn",
96 "eval/sequential" => "stdlib/eval/sequential.harn",
97 "eval/experiment" => "stdlib/eval/experiment.harn",
98 "eval/experiment/contracts" => "stdlib/eval/experiment/contracts.harn",
99 "eval/experiment/assignment" => "stdlib/eval/experiment/assignment.harn",
100 "eval/experiment/decision" => "stdlib/eval/experiment/decision.harn",
101 "eval/agreement" => "stdlib/stdlib_eval_agreement.harn",
102 "runtime" => "stdlib/stdlib_runtime.harn",
103 "io" => "stdlib/stdlib_io.harn",
104 "net" => "stdlib/stdlib_net.harn",
105 "command" => "stdlib/stdlib_command.harn",
106 "verification_types" => "stdlib/verification_types.harn",
107 "verification_core" => "stdlib/verification_core.harn",
108 "verification_targets" => "stdlib/verification_targets.harn",
109 "verification_ladder" => "stdlib/verification_ladder.harn",
110 "verification_public" => "stdlib/verification_public.harn",
111 "signal" => "stdlib/stdlib_signal.harn",
112 "net_policy" => "stdlib/stdlib_net_policy.harn",
113 "review" => "stdlib/stdlib_review.harn",
114 "experiments" => "stdlib/stdlib_experiments.harn",
115 "project" => "stdlib/stdlib_project.harn",
116 "prompt_library" => "stdlib/stdlib_prompt_library.harn",
117 "async" => "stdlib/stdlib_async.harn",
118 "poll" => "stdlib/stdlib_poll.harn",
119 "coerce" => "stdlib/stdlib_coerce.harn",
120 "settled" => "stdlib/stdlib_settled.harn",
121 "abort" => "stdlib/stdlib_abort.harn",
122 "cli" => "stdlib/stdlib_cli.harn",
123 "cli/argparse" => "stdlib/cli/argparse.harn",
124 "cli/envelope" => "stdlib/cli/envelope.harn",
125 "cli/render" => "stdlib/cli/render.harn",
126 "cli/models/batch_artifacts" => "stdlib/cli/models/batch_artifacts.harn",
127 "cli/models/batch_cancel" => "stdlib/cli/models/batch_cancel.harn",
128 "cli/models/batch_download" => "stdlib/cli/models/batch_download.harn",
129 "cli/models/batch_lifecycle" => "stdlib/cli/models/batch_lifecycle.harn",
130 "cli/models/batch_rejoin" => "stdlib/cli/models/batch_rejoin.harn",
131 "cli/models/batch_status" => "stdlib/cli/models/batch_status.harn",
132 "cli/models/batch_submit" => "stdlib/cli/models/batch_submit.harn",
133 "cli/models/batch_transport" => "stdlib/cli/models/batch_transport.harn",
134 "cli/models/lora_render" => "stdlib/cli/models/lora_render.harn",
135 "cli/paths" => "stdlib/cli/paths.harn",
136 "gha" => "stdlib/stdlib_gha.harn",
137 "tui" => "stdlib/stdlib_tui.harn",
138 "jsonl" => "stdlib/stdlib_jsonl.harn",
139 "config" => "stdlib/stdlib_config.harn",
140 "calendar" => "stdlib/stdlib_calendar.harn",
141 "agents" => "stdlib/stdlib_agents.harn",
142 "lifecycle/pool" => "stdlib/lifecycle/pool.harn",
143 "lifecycle/combinators" => "stdlib/lifecycle/combinators.harn",
144 "lifecycle/on_budget" => "stdlib/lifecycle/on_budget.harn",
145 "agent/prompts" => "stdlib/agent/prompts.harn",
146 "llm/media" => "stdlib/llm/media.harn",
147 "llm/options" => "stdlib/llm/options.harn",
148 "llm/catalog" => "stdlib/llm/catalog.harn",
149 "llm/safe" => "stdlib/llm/safe.harn",
150 "llm/envelope" => "stdlib/llm/envelope.harn",
151 "llm/caller" => "stdlib/llm/caller.harn",
152 "harness/policy" => "stdlib/harness/policy.harn",
153 "llm/budget" => "stdlib/llm/budget.harn",
154 "llm/economics" => "stdlib/llm/economics.harn",
155 "llm/prompts" => "stdlib/llm/prompts.harn",
156 "llm/defaults" => "stdlib/llm/defaults.harn",
157 "llm/handlers" => "stdlib/llm/handlers.harn",
158 "llm/tool_telemetry" => "stdlib/llm/tool_telemetry.harn",
159 "llm/tool_middleware" => "stdlib/llm/tool_middleware.harn",
160 "llm/tool_binder" => "stdlib/llm/tool_binder.harn",
161 "llm/structural_validator" => "stdlib/llm/structural_validator.harn",
162 "llm/missing_tool_call" => "stdlib/llm/missing_tool_call.harn",
163 "llm/tool_shape" => "stdlib/llm/tool_shape.harn",
164 "llm/dialects" => "stdlib/llm/dialects.harn",
165 "llm/tool_parse" => "stdlib/llm/tool_parse.harn",
166 "llm/tool_parse_json_support" => "stdlib/llm/tool_parse_json_support.harn",
167 "llm/tool_parse_protocol" => "stdlib/llm/tool_parse_protocol.harn",
168 "llm/tool_parse_provider" => "stdlib/llm/tool_parse_provider.harn",
169 "llm/tool_parse_result" => "stdlib/llm/tool_parse_result.harn",
170 "llm/tool_parse_scan_spec" => "stdlib/llm/tool_parse_scan_spec.harn",
171 "llm/scope_classifier" => "stdlib/llm/scope_classifier.harn",
172 "llm/refine" => "stdlib/llm/refine.harn",
173 "llm/ensemble" => "stdlib/llm/ensemble.harn",
174 "llm/rerank" => "stdlib/llm/rerank.harn",
175 "agent/reasoning" => "stdlib/agent/reasoning.harn",
176 "agent/caller_transport" => "stdlib/agent/caller_transport.harn",
177 "agent/options" => "stdlib/agent/options.harn",
178 "agent/options_types" => "stdlib/agent/options_types.harn",
179 "agent/options_formats" => "stdlib/agent/options_formats.harn",
180 "agent/options_validation" => "stdlib/agent/options_validation.harn",
181 "agent/options_public" => "stdlib/agent/options_public.harn",
182 "agent/llm_dispatch" => "stdlib/agent/llm_dispatch.harn",
183 "agent/prefill" => "stdlib/agent/prefill.harn",
184 "agent/retry" => "stdlib/agent/retry.harn",
185 "llm/judge" => "stdlib/llm/judge.harn",
186 "llm/faithfulness" => "stdlib/llm/faithfulness.harn",
187 "llm/optimize" => "stdlib/llm/optimize.harn",
188 "agent/events" => "stdlib/agent/events.harn",
189 "agent/completions" => "stdlib/agent/completions.harn",
190 "agent/transcript" => "stdlib/agent/transcript.harn",
191 "agent/artifacts" => "stdlib/agent/artifacts.harn",
192 "agent/primitives" => "stdlib/agent/primitives.harn",
193 "agent/progress" => "stdlib/agent/progress.harn",
194 "agent/required_tools" => "stdlib/agent/required_tools.harn",
195 "agent/monologue_actuation" => "stdlib/agent/monologue_actuation.harn",
196 "agent/monologue_actuation_types" => "stdlib/agent/monologue_actuation_types.harn",
197 "agent/stall_types" => "stdlib/agent/stall_types.harn",
198 "agent/stall" => "stdlib/agent/stall.harn",
199 "agent/recurring_diagnostic" => "stdlib/agent/recurring_diagnostic.harn",
200 "agent/stall_config" => "stdlib/agent/stall_config.harn",
201 "agent/stall_feedback" => "stdlib/agent/stall_feedback.harn",
202 "agent/stall_observation" => "stdlib/agent/stall_observation.harn",
203 "agent/stall_verification" => "stdlib/agent/stall_verification.harn",
204 "agent/stall_detectors" => "stdlib/agent/stall_detectors.harn",
205 "agent/governors" => "stdlib/agent/governors.harn",
206 "agent/control" => "stdlib/agent/control.harn",
207 "agent/action_graph" => "stdlib/agent/action_graph.harn",
208 "agent/result_text" => "stdlib/agent/result_text.harn",
209 "agent/best_of_n" => "stdlib/agent/best_of_n.harn",
210 "agent/loop" => "stdlib/agent/loop.harn",
211 "agent/loop_support" => "stdlib/agent/loop_support.harn",
212 "agent/loop_call_resolution" => "stdlib/agent/loop_call_resolution.harn",
213 "agent/loop_result_status" => "stdlib/agent/loop_result_status.harn",
214 "agent/loop_foundation" => "stdlib/agent/loop_foundation.harn",
215 "agent/loop_tool_calls" => "stdlib/agent/loop_tool_calls.harn",
216 "agent/loop_resource_dispatch" => "stdlib/agent/loop_resource_dispatch.harn",
217 "agent/loop_turn_options" => "stdlib/agent/loop_turn_options.harn",
218 "agent/loop_turn_scope" => "stdlib/agent/loop_turn_scope.harn",
219 "agent/loop_internal" => "stdlib/agent/loop_internal.harn",
220 "agent/loop_run" => "stdlib/agent/loop_run.harn",
221 "agent/loop_finalize" => "stdlib/agent/loop_finalize.harn",
222 "agent/loop_terminal" => "stdlib/agent/loop_terminal.harn",
223 "agent/chat" => "stdlib/agent/chat.harn",
224 "agent/user" => "stdlib/agent/user.harn",
225 "agent/tool_search" => "stdlib/agent/tool_search.harn",
226 "agent/tool_annotations" => "stdlib/agent/tool_annotations.harn",
227 "agent/tool_lifecycle" => "stdlib/agent/tool_lifecycle.harn",
228 "agent/turn" => "stdlib/agent/turn.harn",
229 "agent/workers" => "stdlib/agent/workers.harn",
230 "agent/introspection" => "stdlib/agent/introspection.harn",
231 "agent/resume_by" => "stdlib/agent/resume_by.harn",
232 "agent/state" => "stdlib/agent/state.harn",
233 "agent/canon" => "stdlib/agent/canon.harn",
234 "agent/skills" => "stdlib/agent/skills.harn",
235 "agent/autocompact" => "stdlib/agent/autocompact.harn",
236 "agent/mcp" => "stdlib/agent/mcp.harn",
237 "agent/command_capture" => "stdlib/agent/command_capture.harn",
238 "agent/command_ledger" => "stdlib/agent/command_ledger.harn",
239 "agent/host_tools" => "stdlib/agent/host_tools.harn",
240 "agent/host_injection" => "stdlib/agent/host_injection.harn",
241 "agent/budget" => "stdlib/agent/budget.harn",
242 "agent/daemon" => "stdlib/agent/daemon.harn",
243 "agent/preflight" => "stdlib/agent/preflight.harn",
244 "agent/postturn" => "stdlib/agent/postturn.harn",
245 "agent/stance" => "stdlib/agent/stance.harn",
246 "agent/lanes" => "stdlib/agent/lanes.harn",
247 "agent/overlays" => "stdlib/agent/overlays.harn",
248 "agent/sitrep" => "stdlib/agent/sitrep.harn",
249 "agent/verdict" => "stdlib/agent/verdict.harn",
250 "agent/judge_internals" => "stdlib/agent/judge_internals.harn",
251 "agent/judge" => "stdlib/agent/judge.harn",
252 "agent/guardrails" => "stdlib/agent/guardrails.harn",
253 "agent/step_judge" => "stdlib/agent/step_judge.harn",
254 "agent/scratchpad" => "stdlib/agent/scratchpad.harn",
255 "agent/fact" => "stdlib/agent/fact.harn",
256 "agent/hypothesis" => "stdlib/agent/hypothesis.harn",
257 "agent/pattern_knowledge" => "stdlib/agent/pattern_knowledge.harn",
258 "agent/probe" => "stdlib/agent/probe.harn",
259 "agent/stream" => "stdlib/agent/stream.harn",
260 "agent/presets" => "stdlib/agent/presets.harn",
261 "agent/pins" => "stdlib/agent/pins.harn",
262 "agent/goal" => "stdlib/agent/goal.harn",
263 "agent/task_plan" => "stdlib/agent/task_plan.harn",
264 "personas/compiler" => "stdlib/personas/compiler.harn",
265 "personas/prompt_compiler" => "stdlib/personas/prompt_compiler.harn",
266 "agent_state" => "stdlib/stdlib_agent_state.harn",
267 "memory" => "stdlib/stdlib_memory.harn",
268 "session-store" => "stdlib/stdlib_session_store.harn",
269 "coordination" => "stdlib/stdlib_coordination.harn",
270 "fleet/coordination" => "stdlib/fleet/coordination.harn",
271 "postgres" => "stdlib/stdlib_postgres.harn",
272 "postgres/query" => "stdlib/postgres/query.harn",
273 "sqlite" => "stdlib/stdlib_sqlite.harn",
274 "checkpoint" => "stdlib/stdlib_checkpoint.harn",
275 "host" => "stdlib/stdlib_host.harn",
276 "host_lease" => "stdlib/stdlib_host_lease.harn",
277 "git" => "stdlib/stdlib_git.harn",
278 "git/checkout" => "stdlib/git/checkout.harn",
279 "git/contracts" => "stdlib/git/contracts.harn",
280 "hitl" => "stdlib/stdlib_hitl.harn",
281 "trust" => "stdlib/stdlib_trust.harn",
282 "corrections" => "stdlib/stdlib_corrections.harn",
283 "plan" => "stdlib/stdlib_plan.harn",
284 "waitpoints" => "stdlib/stdlib_waitpoints.harn",
285 "waitpoint" => "stdlib/stdlib_waitpoint.harn",
286 "monitors" => "stdlib/stdlib_monitors.harn",
287 "worktree" => "stdlib/stdlib_worktree.harn",
288 "acp" => "stdlib/stdlib_acp.harn",
289 "external_agent" => "stdlib/stdlib_external_agent.harn",
290 "triggers" => "stdlib/stdlib_triggers.harn",
291 "triage" => "stdlib/stdlib_triage.harn",
292 "dashboard/jobs" => "stdlib/dashboard/jobs.harn",
293 "ui_resource" => "stdlib/stdlib_ui_resource.harn",
294 "handoffs" => "stdlib/stdlib_handoffs.harn",
295 "lifecycle" => "stdlib/stdlib_lifecycle.harn",
296 "tool_hooks_catalogues" => "stdlib/stdlib_tool_hooks_catalogues.harn",
297 "tool_hooks" => "stdlib/stdlib_tool_hooks.harn",
298 "channel_guardrails" => "stdlib/stdlib_channel_guardrails.harn",
299 "personas/prelude" => "stdlib/stdlib_personas_prelude.harn",
300 "personas/bulletins" => "stdlib/stdlib_personas_bulletins.harn",
301 "connectors/shared" => "stdlib/stdlib_connectors_shared.harn",
302 "oauth/providers" => "stdlib/oauth/providers.harn",
303 "oauth/token_exchange_catalog" => "stdlib/oauth/token_exchange_catalog.harn",
304 "oauth/token_exchange" => "stdlib/oauth/token_exchange.harn",
305 "oauth/storage" => "stdlib/oauth/storage.harn",
306 "oauth/client" => "stdlib/oauth/client.harn",
307 "oauth/device_flow" => "stdlib/oauth/device_flow.harn",
308 "oauth/redaction" => "stdlib/oauth/redaction.harn",
309 "oauth/dynamic_registration" => "stdlib/oauth/dynamic_registration.harn",
310 "connectors/github" => "stdlib/stdlib_connectors_github.harn",
311 "connectors/linear" => "stdlib/stdlib_connectors_linear.harn",
312 "connectors/notion" => "stdlib/stdlib_connectors_notion.harn",
313 "connectors/slack" => "stdlib/stdlib_connectors_slack.harn",
314 "workflow/prompts" => "stdlib/workflow/prompts.harn",
315 "workflow/context" => "stdlib/workflow/context.harn",
316 "workflow/options" => "stdlib/workflow/options.harn",
317 "workflow/checkpoints" => "stdlib/workflow/checkpoints.harn",
318 "workflow/patterns" => "stdlib/workflow/patterns.harn",
319 "workflow/stage" => "stdlib/workflow/stage.harn",
320 "workflow/map" => "stdlib/workflow/map.harn",
321 "workflow/schedule" => "stdlib/workflow/schedule.harn",
322 "workflow/execute" => "stdlib/workflow/execute.harn",
323 "workflow/repair" => "stdlib/workflow/repair.harn",
324 "security" => "stdlib/stdlib_security.harn",
325 "pii" => "stdlib/stdlib_pii.harn",
326 "bump/runtime" => "stdlib/bump/runtime.harn",
327 "bump/live" => "stdlib/bump/live.harn",
328]);
329
330pub const CONNECTOR_EVENT_SCHEMAS_SOURCE: &str = include_str!("stdlib/stdlib_event_schemas.harn");
340
341pub const STDLIB_PROMPT_ASSETS: &[StdlibPromptAsset] = embedded_catalog!(StdlibPromptAsset, path, [
342 "agent/prompts/tool_contract_text.harn.prompt" => "stdlib/agent/prompts/tool_contract_text.harn.prompt",
343 "agent/prompts/tool_contract_json.harn.prompt" => "stdlib/agent/prompts/tool_contract_json.harn.prompt",
344 "agent/prompts/tool_contract_native.harn.prompt" => "stdlib/agent/prompts/tool_contract_native.harn.prompt",
345 "agent/prompts/tool_contract_text_response_protocol.harn.prompt" => "stdlib/agent/prompts/tool_contract_text_response_protocol.harn.prompt",
346 "agent/prompts/tool_contract_action_native.harn.prompt" => "stdlib/agent/prompts/tool_contract_action_native.harn.prompt",
347 "agent/prompts/tool_contract_action_text.harn.prompt" => "stdlib/agent/prompts/tool_contract_action_text.harn.prompt",
348 "agent/prompts/tool_contract_task_ledger.harn.prompt" => "stdlib/agent/prompts/tool_contract_task_ledger.harn.prompt",
349 "agent/prompts/tool_contract_deferred_tools.harn.prompt" => "stdlib/agent/prompts/tool_contract_deferred_tools.harn.prompt",
350 "agent/prompts/deferred_tool_listing.harn.prompt" => "stdlib/agent/prompts/deferred_tool_listing.harn.prompt",
351 "agent/prompts/agent_turn_preamble.harn.prompt" => "stdlib/agent/prompts/agent_turn_preamble.harn.prompt",
352 "agent/prompts/default_nudge.harn.prompt" => "stdlib/agent/prompts/default_nudge.harn.prompt",
353 "agent/prompts/agentic_user_system.harn.prompt" => "stdlib/agent/prompts/agentic_user_system.harn.prompt",
354 "agent/prompts/agentic_user_user.harn.prompt" => "stdlib/agent/prompts/agentic_user_user.harn.prompt",
355 "agent/prompts/loop_until_done_system.harn.prompt" => "stdlib/agent/prompts/loop_until_done_system.harn.prompt",
356 "agent/prompts/completion_judge_default.harn.prompt" => "stdlib/agent/prompts/completion_judge_default.harn.prompt",
357 "agent/prompts/completion_judge_feedback_fallback.harn.prompt" => "stdlib/agent/prompts/completion_judge_feedback_fallback.harn.prompt",
358 "agent/prompts/completion_judge_user.harn.prompt" => "stdlib/agent/prompts/completion_judge_user.harn.prompt",
359 "agent/prompts/step_judge_system_default.harn.prompt" => "stdlib/agent/prompts/step_judge_system_default.harn.prompt",
360 "agent/prompts/step_judge_system_adversarial.harn.prompt" => "stdlib/agent/prompts/step_judge_system_adversarial.harn.prompt",
361 "agent/prompts/step_judge_user.harn.prompt" => "stdlib/agent/prompts/step_judge_user.harn.prompt",
362 "agent/prompts/parse_guidance.harn.prompt" => "stdlib/agent/prompts/parse_guidance.harn.prompt",
363 "agent/prompts/native_tool_contract_feedback.harn.prompt" => "stdlib/agent/prompts/native_tool_contract_feedback.harn.prompt",
364 "agent/prompts/verification_gate_feedback.harn.prompt" => "stdlib/agent/prompts/verification_gate_feedback.harn.prompt",
365 "agent/prompts/daemon_watch_feedback.harn.prompt" => "stdlib/agent/prompts/daemon_watch_feedback.harn.prompt",
366 "agent/prompts/daemon_timer_feedback.harn.prompt" => "stdlib/agent/prompts/daemon_timer_feedback.harn.prompt",
367 "llm/prompts/completion_fallback_system.harn.prompt" => "stdlib/llm/prompts/completion_fallback_system.harn.prompt",
368 "llm/prompts/completion_fallback_user.harn.prompt" => "stdlib/llm/prompts/completion_fallback_user.harn.prompt",
369 "llm/prompts/transcript_summarize_user.harn.prompt" => "stdlib/llm/prompts/transcript_summarize_user.harn.prompt",
370 "llm/prompts/sitrep_user.harn.prompt" => "stdlib/llm/prompts/sitrep_user.harn.prompt",
371 "llm/prompts/structural_chain_of_draft.harn.prompt" => "stdlib/llm/prompts/structural_chain_of_draft.harn.prompt",
372 "llm/prompts/schema_recover_repair.harn.prompt" => "stdlib/llm/prompts/schema_recover_repair.harn.prompt",
373 "llm/prompts/structured_envelope_schema_contract.harn.prompt" => "stdlib/llm/prompts/structured_envelope_schema_contract.harn.prompt",
374 "llm/prompts/structured_envelope_repair.harn.prompt" => "stdlib/llm/prompts/structured_envelope_repair.harn.prompt",
375 "llm/prompts/pairwise_rerank_user.harn.prompt" => "stdlib/llm/prompts/pairwise_rerank_user.harn.prompt",
376 "llm/prompts/tool_binder_user.harn.prompt" => "stdlib/llm/prompts/tool_binder_user.harn.prompt",
377 "workflow/prompts/stage.harn.prompt" => "stdlib/workflow/prompts/stage.harn.prompt",
378 "workflow/prompts/verification_context_intro.harn.prompt" => "stdlib/workflow/prompts/verification_context_intro.harn.prompt",
379 "orchestration/prompts/compaction_summary.harn.prompt" => "stdlib/orchestration/prompts/compaction_summary.harn.prompt",
380 "orchestration/prompts/compaction_policy_replacement.harn.prompt" => "stdlib/orchestration/prompts/compaction_policy_replacement.harn.prompt",
381]);
382
383#[derive(Debug, Clone, Copy, PartialEq, Eq)]
387pub struct StdlibCliScript {
388 pub name: &'static str,
392 pub source: &'static str,
395}
396
397pub const STDLIB_CLI_SCRIPTS: &[StdlibCliScript] = embedded_catalog!(StdlibCliScript, name, [
398 "codemod" => "stdlib/cli/codemod.harn",
399 "canon/check" => "stdlib/cli/canon/check.harn",
400 "doctor" => "stdlib/cli/doctor.harn",
401 "echo" => "stdlib/cli/echo.harn",
402 "eval/_runner" => "stdlib/cli/eval/_runner.harn",
406 "eval/context" => "stdlib/cli/eval/context.harn",
407 "eval/model_selector" => "stdlib/cli/eval/model_selector.harn",
408 "eval/tool_calls" => "stdlib/cli/eval/tool_calls.harn",
409 "eval/coding_agent" => "stdlib/cli/eval/coding_agent.harn",
410 "eval/scope_triage" => "stdlib/cli/eval/scope_triage.harn",
411 "eval/prompt" => "stdlib/cli/eval/prompt.harn",
412 "explain" => "stdlib/cli/explain.harn",
413 "graph" => "stdlib/cli/graph.harn",
414 "personas/compile_prompt" => "stdlib/cli/personas/compile_prompt.harn",
415 "personas/materialize" => "stdlib/cli/personas/materialize.harn",
416 "models/batch_plan" => "stdlib/cli/models/batch_plan.harn",
417 "models/list" => "stdlib/cli/models/list.harn",
418 "models/lora_inspect" => "stdlib/cli/models/lora_inspect.harn",
419 "models/lora_export" => "stdlib/cli/models/lora_export.harn",
420 "models/lora_manifest" => "stdlib/cli/models/lora_manifest.harn",
421 "models/lora_preflight" => "stdlib/cli/models/lora_preflight.harn",
422 "models/lora_promote" => "stdlib/cli/models/lora_promote.harn",
423 "models/lora_plan" => "stdlib/cli/models/lora_plan.harn",
424 "models/lora_train" => "stdlib/cli/models/lora_train.harn",
425 "models/recommend" => "stdlib/cli/models/recommend.harn",
426 "models/test" => "stdlib/cli/models/test.harn",
427 "precompile" => "stdlib/cli/precompile.harn",
428 "providers/cache_probe" => "stdlib/cli/providers/cache_probe.harn",
429 "providers/catalog" => "stdlib/cli/providers/catalog.harn",
430 "providers/probe" => "stdlib/cli/providers/probe.harn",
431 "providers/recommend" => "stdlib/cli/providers/recommend.harn",
432 "providers/tool_probe" => "stdlib/cli/providers/tool_probe.harn",
433 "providers/tool_scorecard" => "stdlib/cli/providers/tool_scorecard.harn",
434 "routes" => "stdlib/cli/routes.harn",
435 "runs/export_training" => "stdlib/cli/runs/export_training.harn",
436 "scan" => "stdlib/cli/scan.harn",
437 "scaffold/init" => "stdlib/cli/scaffold/init.harn",
438 "scaffold/tool_new" => "stdlib/cli/scaffold/tool_new.harn",
439 "trace_import" => "stdlib/cli/trace_import.harn",
440 "try" => "stdlib/cli/try.harn",
441 "version" => "stdlib/cli/version.harn",
442]);
443
444pub fn get_stdlib_source(module: &str) -> Option<&'static str> {
445 STDLIB_SOURCES
446 .iter()
447 .find_map(|entry| (entry.module == module).then_some(entry.source))
448}
449
450pub fn builtin_reexports(module: &str) -> &'static [&'static str] {
470 match module {
471 "testing" => &[
472 "assert",
473 "assert_approx",
474 "assert_eq",
475 "assert_matches",
476 "assert_ne",
477 "value_diff",
478 ],
479 _ => &[],
480 }
481}
482
483pub fn find_cli_script(name: &str) -> Option<&'static str> {
487 STDLIB_CLI_SCRIPTS
488 .iter()
489 .find_map(|entry| (entry.name == name).then_some(entry.source))
490}
491
492pub fn get_stdlib_prompt_asset(path: &str) -> Option<&'static str> {
493 let path = path.strip_prefix("std/").unwrap_or(path);
494 STDLIB_PROMPT_ASSETS
495 .iter()
496 .find_map(|entry| (entry.path == path).then_some(entry.source))
497}
498
499pub fn public_functions_for_module(module: &str) -> Vec<StdlibPublicFunction> {
500 let Some(source) = get_stdlib_source(module) else {
501 return Vec::new();
502 };
503 public_functions_from_source(source)
504}
505
506pub fn entrypoint_modules() -> Vec<StdlibEntrypointModule> {
507 STDLIB_SOURCES
508 .iter()
509 .filter_map(|entry| {
510 entrypoint_category_from_source(entry.source).map(|category| StdlibEntrypointModule {
511 import_path: format!("std/{}", entry.module),
512 category,
513 })
514 })
515 .collect()
516}
517
518fn entrypoint_category_from_source(source: &str) -> Option<String> {
519 for line in source.lines() {
520 let line = line.trim();
521 if line.is_empty() {
522 continue;
523 }
524 if let Some(category) = line.strip_prefix("// @harn-entrypoint-category ") {
525 let category = category.trim();
526 return (!category.is_empty()).then(|| category.to_string());
527 }
528 if !line.starts_with("//") {
529 return None;
530 }
531 }
532 None
533}
534
535fn public_functions_from_source(source: &str) -> Vec<StdlibPublicFunction> {
536 let mut out = Vec::new();
537 let mut doc: Option<String> = None;
538 let lines = source.lines().collect::<Vec<_>>();
539 let mut index = 0usize;
540 while index < lines.len() {
541 let line = lines[index].trim();
542 if line.starts_with("/**") {
543 let (parsed, next) = parse_harndoc(&lines, index);
544 doc = parsed;
545 index = next;
546 continue;
547 }
548 if line.starts_with("pub fn ") {
549 let (signature_line, next) = collect_public_function_signature(&lines, index);
550 if let Some(function) = parse_public_function_line(&signature_line, doc.take()) {
551 out.push(function);
552 index = next;
553 continue;
554 }
555 }
556 if let Some(function) = parse_public_function_line(line, doc.take()) {
557 out.push(function);
558 } else if !line.is_empty() && !line.starts_with("//") {
559 doc = None;
560 }
561 index += 1;
562 }
563 out
564}
565
566fn collect_public_function_signature(lines: &[&str], start: usize) -> (String, usize) {
567 let mut parts = Vec::new();
568 let mut index = start;
569 while index < lines.len() {
570 parts.push(lines[index].trim().to_string());
571 let candidate = parts.join(" ");
572 if public_function_signature_complete(&candidate) {
573 return (candidate, index + 1);
574 }
575 index += 1;
576 }
577 (parts.join(" "), index)
578}
579
580fn public_function_signature_complete(line: &str) -> bool {
581 let Some(rest) = line.strip_prefix("pub fn ") else {
582 return false;
583 };
584 let Some(name_end) = rest.find('(') else {
585 return false;
586 };
587 matching_paren_len(&rest[name_end + 1..]).is_some()
588}
589
590fn parse_harndoc(lines: &[&str], start: usize) -> (Option<String>, usize) {
591 let mut parts = Vec::new();
592 let mut index = start;
593 while index < lines.len() {
594 let mut line = lines[index].trim();
595 if index == start {
596 line = line.trim_start_matches("/**").trim();
597 }
598 let done = line.ends_with("*/");
599 line = line.trim_end_matches("*/").trim();
600 line = line.trim_start_matches('*').trim();
601 if !line.is_empty() {
602 parts.push(line.to_string());
603 }
604 index += 1;
605 if done {
606 break;
607 }
608 }
609 let text = parts.join("\n").trim().to_string();
610 ((!text.is_empty()).then_some(text), index)
611}
612
613fn parse_public_function_line(line: &str, doc: Option<String>) -> Option<StdlibPublicFunction> {
614 let rest = line.strip_prefix("pub fn ")?.trim();
615 let name_end = rest.find('(')?;
616 let name = rest[..name_end].trim();
617 if name.is_empty() {
618 return None;
619 }
620 let params_start = name_end + 1;
621 let params_len = matching_paren_len(&rest[params_start..])?;
622 let params = &rest[params_start..params_start + params_len];
623 let after = rest[params_start + params_len + 1..].trim();
624 let return_type = after
625 .strip_prefix("->")
626 .and_then(|tail| tail.split('{').next())
627 .map(str::trim)
628 .filter(|value| !value.is_empty());
629 let signature = match return_type {
630 Some(ret) => format!("{name}({params}) -> {ret}"),
631 None => format!("{name}({params})"),
632 };
633 let param_parts = split_top_level_params(params);
634 let total_params = param_parts
635 .iter()
636 .filter(|param| !param.trim().is_empty())
637 .count();
638 let variadic = param_parts
639 .iter()
640 .any(|param| param.trim_start().starts_with("..."));
641 let required_params = param_parts
642 .iter()
643 .filter(|param| {
644 let param = param.trim();
645 !param.is_empty() && !param.contains('=') && !param.starts_with("...")
646 })
647 .count();
648 Some(StdlibPublicFunction {
649 name: name.to_string(),
650 signature,
651 required_params,
652 total_params,
653 variadic,
654 doc,
655 })
656}
657
658fn matching_paren_len(input: &str) -> Option<usize> {
659 let mut depth = 1usize;
660 for (offset, ch) in input.char_indices() {
661 match ch {
662 '(' | '[' | '{' => depth += 1,
663 ')' | ']' | '}' => {
664 depth = depth.saturating_sub(1);
665 if depth == 0 {
666 return Some(offset);
667 }
668 }
669 _ => {}
670 }
671 }
672 None
673}
674
675fn split_top_level_params(params: &str) -> Vec<&str> {
676 let mut out = Vec::new();
677 let mut depth = 0isize;
678 let mut start = 0usize;
679 for (offset, ch) in params.char_indices() {
680 match ch {
681 '(' | '[' | '{' => depth += 1,
682 ')' | ']' | '}' => depth -= 1,
683 ',' if depth == 0 => {
684 out.push(¶ms[start..offset]);
685 start = offset + 1;
686 }
687 _ => {}
688 }
689 }
690 out.push(¶ms[start..]);
691 out
692}
693
694#[cfg(test)]
695mod tests {
696 use std::collections::BTreeSet;
697
698 use super::{
699 entrypoint_modules, find_cli_script, get_stdlib_prompt_asset, get_stdlib_source,
700 matching_paren_len, parse_public_function_line, public_functions_for_module,
701 STDLIB_CLI_SCRIPTS, STDLIB_PROMPT_ASSETS, STDLIB_SOURCES,
702 };
703
704 #[test]
705 fn stdlib_sources_are_non_empty() {
706 for entry in STDLIB_SOURCES {
707 assert!(
708 !entry.source.trim().is_empty(),
709 "{} should have non-empty source",
710 entry.module
711 );
712 }
713 }
714
715 #[test]
716 fn cli_scripts_are_non_empty_and_uniquely_named() {
717 let mut seen = BTreeSet::new();
718 for entry in STDLIB_CLI_SCRIPTS {
719 assert!(
720 !entry.source.trim().is_empty(),
721 "cli/{} should have non-empty source",
722 entry.name
723 );
724 assert!(
725 seen.insert(entry.name),
726 "cli/{} is registered more than once in STDLIB_CLI_SCRIPTS",
727 entry.name
728 );
729 }
730 }
731
732 #[test]
733 fn find_cli_script_round_trips() {
734 for entry in STDLIB_CLI_SCRIPTS {
735 assert_eq!(find_cli_script(entry.name), Some(entry.source));
736 }
737 assert!(find_cli_script("not-a-real-script").is_none());
738 }
739
740 #[test]
741 fn stdlib_source_names_are_unique() {
742 let mut names = BTreeSet::new();
743 for entry in STDLIB_SOURCES {
744 assert!(names.insert(entry.module), "duplicate {}", entry.module);
745 }
746 }
747
748 #[test]
749 fn stdlib_prompt_assets_are_non_empty() {
750 for entry in STDLIB_PROMPT_ASSETS {
751 assert!(
752 !entry.source.trim().is_empty(),
753 "{} should have non-empty prompt asset source",
754 entry.path
755 );
756 }
757 }
758
759 #[test]
760 fn stdlib_prompt_asset_paths_are_unique() {
761 let mut paths = BTreeSet::new();
762 for entry in STDLIB_PROMPT_ASSETS {
763 assert!(paths.insert(entry.path), "duplicate {}", entry.path);
764 }
765 }
766
767 #[test]
768 fn key_stdlib_modules_resolve() {
769 for module in [
770 "context",
771 "context/maintenance",
772 "context/eval",
773 "eval/stats",
774 "eval/agreement",
775 "edit",
776 "verification",
777 "disclosure",
778 "artifact/web",
779 "command",
780 "waitpoint",
781 "llm/handlers",
782 "llm/tool_middleware",
783 "llm/tool_binder",
784 "llm/missing_tool_call",
785 "llm/tool_shape",
786 "llm/dialects",
787 "llm/ensemble",
788 "llm/rerank",
789 "personas/prelude",
790 "personas/bulletins",
791 "agent/host_tools",
792 "agent/host_injection",
793 "agent/tool_lifecycle",
794 "agent/user",
795 "agent/governors",
796 "agent/guardrails",
797 "cli",
798 "cli/envelope",
799 "cli/models/batch_artifacts",
800 "cli/models/batch_cancel",
801 "cli/models/batch_download",
802 "cli/models/batch_lifecycle",
803 "cli/models/batch_rejoin",
804 "cli/models/batch_status",
805 "cli/models/batch_submit",
806 "cli/models/batch_transport",
807 "cli/models/lora_render",
808 "llm/optimize",
809 "llm/judge",
810 "llm/faithfulness",
811 "llm/refine",
812 "connectors/shared",
813 "connectors/github",
814 "connectors/linear",
815 "connectors/notion",
816 "connectors/slack",
817 "triage",
818 "dashboard/jobs",
819 "ui_resource",
820 "host_lease",
821 ] {
822 assert!(
823 get_stdlib_source(module).is_some(),
824 "std/{module} should resolve"
825 );
826 }
827 }
828
829 #[test]
830 fn key_stdlib_prompt_assets_resolve() {
831 for path in [
832 "std/agent/prompts/tool_contract_text.harn.prompt",
833 "std/agent/prompts/default_nudge.harn.prompt",
834 "std/agent/prompts/completion_judge_default.harn.prompt",
835 "std/workflow/prompts/stage.harn.prompt",
836 "std/orchestration/prompts/compaction_summary.harn.prompt",
837 "std/orchestration/prompts/compaction_policy_replacement.harn.prompt",
838 ] {
839 assert!(
840 get_stdlib_prompt_asset(path).is_some(),
841 "{path} should resolve"
842 );
843 }
844 }
845
846 #[test]
847 fn public_function_catalog_derives_signatures_from_harn_source() {
848 let exports = public_functions_for_module("workflow/execute");
849 assert_eq!(exports.len(), 1);
850 assert_eq!(exports[0].name, "workflow_execute");
851 assert_eq!(
852 exports[0].signature,
853 "workflow_execute(task, graph, artifacts = nil, options = nil)"
854 );
855 assert_eq!(exports[0].required_params, 2);
856 assert_eq!(exports[0].total_params, 4);
857 }
858
859 #[test]
860 fn command_stdlib_module_exports_step_helpers() {
861 let exports = public_functions_for_module("command")
862 .into_iter()
863 .map(|function| function.name)
864 .collect::<BTreeSet<_>>();
865 for name in [
866 "command_run",
867 "command_wait",
868 "command_wait_for_output",
869 "command_cancel",
870 "command_run_streaming",
871 "command_output_tail",
872 "command_json",
873 "command_json_step",
874 "command_try",
875 "command_step",
876 "command_steps_append",
877 "command_last_failed_step",
878 "command_step_ref",
879 ] {
880 assert!(exports.contains(name), "std/command should export {name}");
881 }
882 }
883
884 #[test]
885 fn disclosure_stdlib_module_exports_render_helpers() {
886 let exports = public_functions_for_module("disclosure")
887 .into_iter()
888 .map(|function| function.name)
889 .collect::<BTreeSet<_>>();
890 assert!(
891 exports.contains("render"),
892 "std/disclosure should export render"
893 );
894 assert!(
895 exports.contains("git_trailers"),
896 "std/disclosure should export git_trailers"
897 );
898 assert!(
899 exports.contains("slack_message_disclosure"),
900 "std/disclosure should export slack_message_disclosure"
901 );
902 assert!(
903 exports.contains("append_git_trailers"),
904 "std/disclosure should export append_git_trailers"
905 );
906 }
907
908 #[test]
909 fn async_stdlib_exports_predicate_backoff_name_only() {
910 let exports = public_functions_for_module("async")
911 .into_iter()
912 .map(|function| function.name)
913 .collect::<BTreeSet<_>>();
914 assert!(
915 exports.contains("retry_predicate_with_backoff"),
916 "std/async should export retry_predicate_with_backoff"
917 );
918 assert!(
919 !exports.contains("retry_with_backoff"),
920 "std/async should not retain the old retry_with_backoff export"
921 );
922 }
923
924 #[test]
925 fn signal_stdlib_module_exports_interrupt_helpers() {
926 let exports = public_functions_for_module("signal")
927 .into_iter()
928 .map(|function| function.name)
929 .collect::<BTreeSet<_>>();
930 for name in [
931 "on_interrupt",
932 "off_interrupt",
933 "interrupted",
934 "with_interrupt",
935 ] {
936 assert!(exports.contains(name), "std/signal should export {name}");
937 }
938 }
939
940 #[test]
941 fn git_stdlib_module_exports_local_wrappers() {
942 let exports = public_functions_for_module("git")
943 .into_iter()
944 .map(|function| function.name)
945 .collect::<BTreeSet<_>>();
946 for name in [
947 "git_run",
948 "git_status",
949 "git_current_branch",
950 "git_log",
951 "git_switch",
952 "git_pull_ff_only",
953 "git_find_tool",
954 "git_run_tool",
955 "git_tools",
956 "git_toolbox_tools",
957 ] {
958 assert!(exports.contains(name), "std/git should export {name}");
959 }
960 }
961
962 #[test]
963 fn agent_workers_exports_suspend_resume_wrappers() {
964 let exports = public_functions_for_module("agent/workers");
965 let suspend = exports
966 .iter()
967 .find(|function| function.name == "suspend_agent")
968 .expect("std/agent/workers should export suspend_agent");
969 assert_eq!(
970 suspend.signature,
971 "suspend_agent(worker, reason = \"\", options = nil)"
972 );
973 assert_eq!(suspend.required_params, 1);
974 assert_eq!(suspend.total_params, 3);
975
976 let resume = exports
977 .iter()
978 .find(|function| function.name == "resume_agent")
979 .expect("std/agent/workers should export resume_agent");
980 assert_eq!(
981 resume.signature,
982 "resume_agent(worker_or_snapshot, resume_input = nil, continue_transcript = true)"
983 );
984 assert_eq!(resume.required_params, 1);
985 assert_eq!(resume.total_params, 3);
986
987 let stop = exports
988 .iter()
989 .find(|function| function.name == "agent_stop")
990 .expect("std/agent/workers should export agent_stop");
991 assert_eq!(
992 stop.signature,
993 "agent_stop(worker, options: AgentStopOptions = nil)"
994 );
995 assert_eq!(stop.required_params, 1);
996 assert_eq!(stop.total_params, 2);
997
998 let parse_resume = exports
999 .iter()
1000 .find(|function| function.name == "parse_resume_conditions")
1001 .expect("std/agent/workers should export parse_resume_conditions");
1002 assert_eq!(
1003 parse_resume.signature,
1004 "parse_resume_conditions(conditions = nil) -> ResumeConditions?"
1005 );
1006 assert_eq!(parse_resume.required_params, 0);
1007 assert_eq!(parse_resume.total_params, 1);
1008
1009 let lifecycle = exports
1010 .iter()
1011 .find(|function| function.name == "agent_lifecycle_tools")
1012 .expect("std/agent/workers should export agent_lifecycle_tools");
1013 assert_eq!(
1014 lifecycle.signature,
1015 "agent_lifecycle_tools(registry = nil, options = nil)"
1016 );
1017 assert_eq!(lifecycle.required_params, 0);
1018 assert_eq!(lifecycle.total_params, 2);
1019 }
1020
1021 #[test]
1022 fn tui_stdlib_module_exports_terminal_helpers() {
1023 let exports = public_functions_for_module("tui")
1024 .into_iter()
1025 .map(|function| function.name)
1026 .collect::<BTreeSet<_>>();
1027 for name in ["page", "terminal_width", "rule", "clear", "select_from"] {
1028 assert!(exports.contains(name), "std/tui should export {name}");
1029 }
1030 }
1031
1032 #[test]
1033 fn semver_stdlib_module_exports_release_helpers() {
1034 let exports = public_functions_for_module("semver")
1035 .into_iter()
1036 .map(|function| function.name)
1037 .collect::<BTreeSet<_>>();
1038 for name in [
1039 "strip_v",
1040 "add_v",
1041 "is_v_semver",
1042 "parse",
1043 "max_canonical_tag",
1044 "next",
1045 "bump_type",
1046 "version_from_release_branch",
1047 "version_from_tag",
1048 ] {
1049 assert!(exports.contains(name), "std/semver should export {name}");
1050 }
1051 }
1052
1053 #[test]
1054 fn changelog_stdlib_module_exports_typed_primitives() {
1055 let exports = public_functions_for_module("changelog")
1056 .into_iter()
1057 .map(|function| function.name)
1058 .collect::<BTreeSet<_>>();
1059 for name in [
1060 "changelog_validate_categories",
1061 "changelog_parse_fragment",
1062 "changelog_order_fragments",
1063 "changelog_normalize_fragment_body",
1064 "changelog_assemble_fragments",
1065 "changelog_parse_sections",
1066 "changelog_find_section",
1067 "changelog_merge_unreleased",
1068 ] {
1069 assert!(exports.contains(name), "std/changelog should export {name}");
1070 }
1071 }
1072
1073 #[test]
1074 fn text_stdlib_module_exports_regex_and_pad_helpers() {
1075 let exports = public_functions_for_module("text")
1076 .into_iter()
1077 .map(|function| function.name)
1078 .collect::<BTreeSet<_>>();
1079 for name in [
1080 "pad_left",
1081 "pad_right",
1082 "repeat_string",
1083 "regex_first_capture",
1084 "regex_capture_groups",
1085 "regex_all_first_captures",
1086 ] {
1087 assert!(exports.contains(name), "std/text should export {name}");
1088 }
1089 }
1090
1091 #[test]
1092 fn harn_entrypoint_catalog_is_declared_by_stdlib_sources() {
1093 let modules = entrypoint_modules();
1094 let entries = modules
1095 .iter()
1096 .map(|module| (module.import_path.as_str(), module.category.as_str()))
1097 .collect::<BTreeSet<_>>();
1098 for entry in [
1099 ("std/agent/loop", "agent.stdlib"),
1100 ("std/agent/turn", "agent.stdlib"),
1101 ("std/agent/primitives", "agent.stdlib"),
1102 ("std/workflow/execute", "workflow.stdlib"),
1103 ] {
1104 assert!(entries.contains(&entry), "{entry:?} should be declared");
1105 }
1106 }
1107
1108 #[test]
1109 fn matching_paren_len_closes_on_every_bracket_kind() {
1110 assert_eq!(matching_paren_len("a, b)"), Some(4));
1113 assert_eq!(matching_paren_len("x: [int])"), Some(8));
1114 assert_eq!(matching_paren_len("x: {a: int})"), Some(11));
1115 assert_eq!(matching_paren_len("x]"), Some(1));
1118 assert_eq!(matching_paren_len("x}"), Some(1));
1119 assert_eq!(matching_paren_len("unterminated"), None);
1120 }
1121
1122 #[test]
1123 fn parse_public_function_line_handles_record_typed_params() {
1124 let parsed =
1125 parse_public_function_line("pub fn configure(opts: {retries: int}) -> bool", None)
1126 .expect("signature with a record-typed parameter should parse");
1127 assert_eq!(parsed.name, "configure");
1128 assert_eq!(parsed.signature, "configure(opts: {retries: int}) -> bool");
1129 assert_eq!(parsed.total_params, 1);
1130 assert_eq!(parsed.required_params, 1);
1131 }
1132}