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