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