Skip to main content

harn_stdlib/
lib.rs

1//! Canonical embedded Harn standard library source catalog.
2//!
3//! This crate intentionally contains only static source strings so runtime and
4//! static tooling crates can share the same stdlib modules without depending on
5//! each other.
6
7#[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
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub struct StdlibPublicFunction {
21    pub name: String,
22    pub signature: String,
23    pub required_params: usize,
24    pub total_params: usize,
25    pub variadic: bool,
26    pub doc: Option<String>,
27}
28
29#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct StdlibEntrypointModule {
31    pub import_path: String,
32    pub category: String,
33}
34
35pub const STDLIB_SOURCES: &[StdlibSource] = &[
36    StdlibSource {
37        module: "text",
38        source: include_str!("stdlib/stdlib_text.harn"),
39    },
40    StdlibSource {
41        module: "ansi",
42        source: include_str!("stdlib/stdlib_ansi.harn"),
43    },
44    StdlibSource {
45        module: "table",
46        source: include_str!("stdlib/stdlib_table.harn"),
47    },
48    StdlibSource {
49        module: "diff",
50        source: include_str!("stdlib/stdlib_diff.harn"),
51    },
52    StdlibSource {
53        module: "edit",
54        source: include_str!("stdlib/stdlib_edit.harn"),
55    },
56    StdlibSource {
57        module: "artifact/web",
58        source: include_str!("stdlib/artifact/web.harn"),
59    },
60    StdlibSource {
61        module: "collections",
62        source: include_str!("stdlib/stdlib_collections.harn"),
63    },
64    StdlibSource {
65        module: "math",
66        source: include_str!("stdlib/stdlib_math.harn"),
67    },
68    StdlibSource {
69        module: "path",
70        source: include_str!("stdlib/stdlib_path.harn"),
71    },
72    StdlibSource {
73        module: "fs",
74        source: include_str!("stdlib/stdlib_fs.harn"),
75    },
76    StdlibSource {
77        module: "run_artifacts",
78        source: include_str!("stdlib/stdlib_run_artifacts.harn"),
79    },
80    StdlibSource {
81        module: "os",
82        source: include_str!("stdlib/stdlib_os.harn"),
83    },
84    StdlibSource {
85        module: "json",
86        source: include_str!("stdlib/stdlib_json.harn"),
87    },
88    StdlibSource {
89        module: "json/stream",
90        source: include_str!("stdlib/stdlib_json_stream.harn"),
91    },
92    StdlibSource {
93        module: "cache",
94        source: include_str!("stdlib/stdlib_cache.harn"),
95    },
96    StdlibSource {
97        module: "observability",
98        source: include_str!("stdlib/stdlib_observability.harn"),
99    },
100    StdlibSource {
101        module: "timing",
102        source: include_str!("stdlib/stdlib_timing.harn"),
103    },
104    StdlibSource {
105        module: "tools",
106        source: include_str!("stdlib/stdlib_tools.harn"),
107    },
108    StdlibSource {
109        module: "composition",
110        source: include_str!("stdlib/stdlib_composition.harn"),
111    },
112    StdlibSource {
113        module: "web",
114        source: include_str!("stdlib/stdlib_web.harn"),
115    },
116    StdlibSource {
117        module: "graphql",
118        source: include_str!("stdlib/stdlib_graphql.harn"),
119    },
120    StdlibSource {
121        module: "schema",
122        source: include_str!("stdlib/stdlib_schema.harn"),
123    },
124    StdlibSource {
125        module: "testing",
126        source: include_str!("stdlib/stdlib_testing.harn"),
127    },
128    StdlibSource {
129        module: "files",
130        source: include_str!("stdlib/stdlib_files.harn"),
131    },
132    StdlibSource {
133        module: "mcp",
134        source: include_str!("stdlib/stdlib_mcp.harn"),
135    },
136    StdlibSource {
137        module: "vision",
138        source: include_str!("stdlib/stdlib_vision.harn"),
139    },
140    StdlibSource {
141        module: "context",
142        source: include_str!("stdlib/stdlib_context.harn"),
143    },
144    StdlibSource {
145        module: "context/maintenance",
146        source: include_str!("stdlib/context/maintenance.harn"),
147    },
148    StdlibSource {
149        module: "context/eval",
150        source: include_str!("stdlib/context/eval.harn"),
151    },
152    StdlibSource {
153        module: "runtime",
154        source: include_str!("stdlib/stdlib_runtime.harn"),
155    },
156    StdlibSource {
157        module: "io",
158        source: include_str!("stdlib/stdlib_io.harn"),
159    },
160    StdlibSource {
161        module: "command",
162        source: include_str!("stdlib/stdlib_command.harn"),
163    },
164    StdlibSource {
165        module: "signal",
166        source: include_str!("stdlib/stdlib_signal.harn"),
167    },
168    StdlibSource {
169        module: "net_policy",
170        source: include_str!("stdlib/stdlib_net_policy.harn"),
171    },
172    StdlibSource {
173        module: "review",
174        source: include_str!("stdlib/stdlib_review.harn"),
175    },
176    StdlibSource {
177        module: "experiments",
178        source: include_str!("stdlib/stdlib_experiments.harn"),
179    },
180    StdlibSource {
181        module: "project",
182        source: include_str!("stdlib/stdlib_project.harn"),
183    },
184    StdlibSource {
185        module: "prompt_library",
186        source: include_str!("stdlib/stdlib_prompt_library.harn"),
187    },
188    StdlibSource {
189        module: "async",
190        source: include_str!("stdlib/stdlib_async.harn"),
191    },
192    StdlibSource {
193        module: "poll",
194        source: include_str!("stdlib/stdlib_poll.harn"),
195    },
196    StdlibSource {
197        module: "coerce",
198        source: include_str!("stdlib/stdlib_coerce.harn"),
199    },
200    StdlibSource {
201        module: "settled",
202        source: include_str!("stdlib/stdlib_settled.harn"),
203    },
204    StdlibSource {
205        module: "cli",
206        source: include_str!("stdlib/stdlib_cli.harn"),
207    },
208    StdlibSource {
209        module: "cli/argparse",
210        source: include_str!("stdlib/cli/argparse.harn"),
211    },
212    StdlibSource {
213        module: "cli/render",
214        source: include_str!("stdlib/cli/render.harn"),
215    },
216    StdlibSource {
217        module: "cli/paths",
218        source: include_str!("stdlib/cli/paths.harn"),
219    },
220    StdlibSource {
221        module: "gha",
222        source: include_str!("stdlib/stdlib_gha.harn"),
223    },
224    StdlibSource {
225        module: "tui",
226        source: include_str!("stdlib/stdlib_tui.harn"),
227    },
228    StdlibSource {
229        module: "jsonl",
230        source: include_str!("stdlib/stdlib_jsonl.harn"),
231    },
232    StdlibSource {
233        module: "config",
234        source: include_str!("stdlib/stdlib_config.harn"),
235    },
236    StdlibSource {
237        module: "calendar",
238        source: include_str!("stdlib/stdlib_calendar.harn"),
239    },
240    StdlibSource {
241        module: "agents",
242        source: include_str!("stdlib/stdlib_agents.harn"),
243    },
244    StdlibSource {
245        module: "lifecycle/pool",
246        source: include_str!("stdlib/lifecycle/pool.harn"),
247    },
248    StdlibSource {
249        module: "lifecycle/combinators",
250        source: include_str!("stdlib/lifecycle/combinators.harn"),
251    },
252    StdlibSource {
253        module: "lifecycle/on_budget",
254        source: include_str!("stdlib/lifecycle/on_budget.harn"),
255    },
256    StdlibSource {
257        module: "agent/prompts",
258        source: include_str!("stdlib/agent/prompts.harn"),
259    },
260    StdlibSource {
261        module: "llm/media",
262        source: include_str!("stdlib/llm/media.harn"),
263    },
264    StdlibSource {
265        module: "llm/options",
266        source: include_str!("stdlib/llm/options.harn"),
267    },
268    StdlibSource {
269        module: "llm/catalog",
270        source: include_str!("stdlib/llm/catalog.harn"),
271    },
272    StdlibSource {
273        module: "llm/safe",
274        source: include_str!("stdlib/llm/safe.harn"),
275    },
276    StdlibSource {
277        module: "llm/budget",
278        source: include_str!("stdlib/llm/budget.harn"),
279    },
280    StdlibSource {
281        module: "llm/economics",
282        source: include_str!("stdlib/llm/economics.harn"),
283    },
284    StdlibSource {
285        module: "llm/prompts",
286        source: include_str!("stdlib/llm/prompts.harn"),
287    },
288    StdlibSource {
289        module: "llm/defaults",
290        source: include_str!("stdlib/llm/defaults.harn"),
291    },
292    StdlibSource {
293        module: "llm/handlers",
294        source: include_str!("stdlib/llm/handlers.harn"),
295    },
296    StdlibSource {
297        module: "llm/tool_telemetry",
298        source: include_str!("stdlib/llm/tool_telemetry.harn"),
299    },
300    StdlibSource {
301        module: "llm/tool_middleware",
302        source: include_str!("stdlib/llm/tool_middleware.harn"),
303    },
304    StdlibSource {
305        module: "llm/tool_binder",
306        source: include_str!("stdlib/llm/tool_binder.harn"),
307    },
308    StdlibSource {
309        module: "llm/structural_validator",
310        source: include_str!("stdlib/llm/structural_validator.harn"),
311    },
312    StdlibSource {
313        module: "llm/scope_classifier",
314        source: include_str!("stdlib/llm/scope_classifier.harn"),
315    },
316    StdlibSource {
317        module: "llm/refine",
318        source: include_str!("stdlib/llm/refine.harn"),
319    },
320    StdlibSource {
321        module: "llm/ensemble",
322        source: include_str!("stdlib/llm/ensemble.harn"),
323    },
324    StdlibSource {
325        module: "llm/rerank",
326        source: include_str!("stdlib/llm/rerank.harn"),
327    },
328    StdlibSource {
329        module: "agent/reasoning",
330        source: include_str!("stdlib/agent/reasoning.harn"),
331    },
332    StdlibSource {
333        module: "agent/options",
334        source: include_str!("stdlib/agent/options.harn"),
335    },
336    StdlibSource {
337        module: "llm/judge",
338        source: include_str!("stdlib/llm/judge.harn"),
339    },
340    StdlibSource {
341        module: "llm/optimize",
342        source: include_str!("stdlib/llm/optimize.harn"),
343    },
344    StdlibSource {
345        module: "agent/events",
346        source: include_str!("stdlib/agent/events.harn"),
347    },
348    StdlibSource {
349        module: "agent/primitives",
350        source: include_str!("stdlib/agent/primitives.harn"),
351    },
352    StdlibSource {
353        module: "agent/progress",
354        source: include_str!("stdlib/agent/progress.harn"),
355    },
356    StdlibSource {
357        module: "agent/required_tools",
358        source: include_str!("stdlib/agent/required_tools.harn"),
359    },
360    StdlibSource {
361        module: "agent/stall",
362        source: include_str!("stdlib/agent/stall.harn"),
363    },
364    StdlibSource {
365        module: "agent/control",
366        source: include_str!("stdlib/agent/control.harn"),
367    },
368    StdlibSource {
369        module: "agent/loop",
370        source: include_str!("stdlib/agent/loop.harn"),
371    },
372    StdlibSource {
373        module: "agent/chat",
374        source: include_str!("stdlib/agent/chat.harn"),
375    },
376    StdlibSource {
377        module: "agent/user",
378        source: include_str!("stdlib/agent/user.harn"),
379    },
380    StdlibSource {
381        module: "agent/tool_search",
382        source: include_str!("stdlib/agent/tool_search.harn"),
383    },
384    StdlibSource {
385        module: "agent/turn",
386        source: include_str!("stdlib/agent/turn.harn"),
387    },
388    StdlibSource {
389        module: "agent/workers",
390        source: include_str!("stdlib/agent/workers.harn"),
391    },
392    StdlibSource {
393        module: "agent/introspection",
394        source: include_str!("stdlib/agent/introspection.harn"),
395    },
396    StdlibSource {
397        module: "agent/resume_by",
398        source: include_str!("stdlib/agent/resume_by.harn"),
399    },
400    StdlibSource {
401        module: "agent/state",
402        source: include_str!("stdlib/agent/state.harn"),
403    },
404    StdlibSource {
405        module: "agent/skills",
406        source: include_str!("stdlib/agent/skills.harn"),
407    },
408    StdlibSource {
409        module: "agent/autocompact",
410        source: include_str!("stdlib/agent/autocompact.harn"),
411    },
412    StdlibSource {
413        module: "agent/mcp",
414        source: include_str!("stdlib/agent/mcp.harn"),
415    },
416    StdlibSource {
417        module: "agent/host_tools",
418        source: include_str!("stdlib/agent/host_tools.harn"),
419    },
420    StdlibSource {
421        module: "agent/budget",
422        source: include_str!("stdlib/agent/budget.harn"),
423    },
424    StdlibSource {
425        module: "agent/daemon",
426        source: include_str!("stdlib/agent/daemon.harn"),
427    },
428    StdlibSource {
429        module: "agent/preflight",
430        source: include_str!("stdlib/agent/preflight.harn"),
431    },
432    StdlibSource {
433        module: "agent/postturn",
434        source: include_str!("stdlib/agent/postturn.harn"),
435    },
436    StdlibSource {
437        module: "agent/judge",
438        source: include_str!("stdlib/agent/judge.harn"),
439    },
440    StdlibSource {
441        module: "agent/step_judge",
442        source: include_str!("stdlib/agent/step_judge.harn"),
443    },
444    StdlibSource {
445        module: "agent/fact",
446        source: include_str!("stdlib/agent/fact.harn"),
447    },
448    StdlibSource {
449        module: "agent/probe",
450        source: include_str!("stdlib/agent/probe.harn"),
451    },
452    StdlibSource {
453        module: "agent/presets",
454        source: include_str!("stdlib/agent/presets.harn"),
455    },
456    StdlibSource {
457        module: "agent/task_plan",
458        source: include_str!("stdlib/agent/task_plan.harn"),
459    },
460    StdlibSource {
461        module: "agent_state",
462        source: include_str!("stdlib/stdlib_agent_state.harn"),
463    },
464    StdlibSource {
465        module: "memory",
466        source: include_str!("stdlib/stdlib_memory.harn"),
467    },
468    StdlibSource {
469        module: "postgres",
470        source: include_str!("stdlib/stdlib_postgres.harn"),
471    },
472    StdlibSource {
473        module: "checkpoint",
474        source: include_str!("stdlib/stdlib_checkpoint.harn"),
475    },
476    StdlibSource {
477        module: "host",
478        source: include_str!("stdlib/stdlib_host.harn"),
479    },
480    StdlibSource {
481        module: "git",
482        source: include_str!("stdlib/stdlib_git.harn"),
483    },
484    StdlibSource {
485        module: "hitl",
486        source: include_str!("stdlib/stdlib_hitl.harn"),
487    },
488    StdlibSource {
489        module: "trust",
490        source: include_str!("stdlib/stdlib_trust.harn"),
491    },
492    StdlibSource {
493        module: "corrections",
494        source: include_str!("stdlib/stdlib_corrections.harn"),
495    },
496    StdlibSource {
497        module: "plan",
498        source: include_str!("stdlib/stdlib_plan.harn"),
499    },
500    StdlibSource {
501        module: "waitpoints",
502        source: include_str!("stdlib/stdlib_waitpoints.harn"),
503    },
504    StdlibSource {
505        module: "waitpoint",
506        source: include_str!("stdlib/stdlib_waitpoint.harn"),
507    },
508    StdlibSource {
509        module: "monitors",
510        source: include_str!("stdlib/stdlib_monitors.harn"),
511    },
512    StdlibSource {
513        module: "worktree",
514        source: include_str!("stdlib/stdlib_worktree.harn"),
515    },
516    StdlibSource {
517        module: "acp",
518        source: include_str!("stdlib/stdlib_acp.harn"),
519    },
520    StdlibSource {
521        module: "triggers",
522        source: include_str!("stdlib/stdlib_triggers.harn"),
523    },
524    StdlibSource {
525        module: "triage",
526        source: include_str!("stdlib/stdlib_triage.harn"),
527    },
528    StdlibSource {
529        module: "dashboard/jobs",
530        source: include_str!("stdlib/dashboard/jobs.harn"),
531    },
532    StdlibSource {
533        module: "ui_resource",
534        source: include_str!("stdlib/stdlib_ui_resource.harn"),
535    },
536    StdlibSource {
537        module: "handoffs",
538        source: include_str!("stdlib/stdlib_handoffs.harn"),
539    },
540    StdlibSource {
541        module: "lifecycle",
542        source: include_str!("stdlib/stdlib_lifecycle.harn"),
543    },
544    StdlibSource {
545        module: "tool_hooks_catalogues",
546        source: include_str!("stdlib/stdlib_tool_hooks_catalogues.harn"),
547    },
548    StdlibSource {
549        module: "tool_hooks",
550        source: include_str!("stdlib/stdlib_tool_hooks.harn"),
551    },
552    StdlibSource {
553        module: "channel_guardrails",
554        source: include_str!("stdlib/stdlib_channel_guardrails.harn"),
555    },
556    StdlibSource {
557        module: "personas/prelude",
558        source: include_str!("stdlib/stdlib_personas_prelude.harn"),
559    },
560    StdlibSource {
561        module: "personas/bulletins",
562        source: include_str!("stdlib/stdlib_personas_bulletins.harn"),
563    },
564    StdlibSource {
565        module: "connectors/shared",
566        source: include_str!("stdlib/stdlib_connectors_shared.harn"),
567    },
568    StdlibSource {
569        module: "oauth/providers",
570        source: include_str!("stdlib/oauth/providers.harn"),
571    },
572    StdlibSource {
573        module: "oauth/storage",
574        source: include_str!("stdlib/oauth/storage.harn"),
575    },
576    StdlibSource {
577        module: "oauth/client",
578        source: include_str!("stdlib/oauth/client.harn"),
579    },
580    StdlibSource {
581        module: "oauth/device_flow",
582        source: include_str!("stdlib/oauth/device_flow.harn"),
583    },
584    StdlibSource {
585        module: "oauth/redaction",
586        source: include_str!("stdlib/oauth/redaction.harn"),
587    },
588    StdlibSource {
589        module: "oauth/dynamic_registration",
590        source: include_str!("stdlib/oauth/dynamic_registration.harn"),
591    },
592    StdlibSource {
593        module: "connectors/github",
594        source: include_str!("stdlib/stdlib_connectors_github.harn"),
595    },
596    StdlibSource {
597        module: "connectors/linear",
598        source: include_str!("stdlib/stdlib_connectors_linear.harn"),
599    },
600    StdlibSource {
601        module: "connectors/notion",
602        source: include_str!("stdlib/stdlib_connectors_notion.harn"),
603    },
604    StdlibSource {
605        module: "connectors/slack",
606        source: include_str!("stdlib/stdlib_connectors_slack.harn"),
607    },
608    StdlibSource {
609        module: "workflow/prompts",
610        source: include_str!("stdlib/workflow/prompts.harn"),
611    },
612    StdlibSource {
613        module: "workflow/context",
614        source: include_str!("stdlib/workflow/context.harn"),
615    },
616    StdlibSource {
617        module: "workflow/options",
618        source: include_str!("stdlib/workflow/options.harn"),
619    },
620    StdlibSource {
621        module: "workflow/checkpoints",
622        source: include_str!("stdlib/workflow/checkpoints.harn"),
623    },
624    StdlibSource {
625        module: "workflow/stage",
626        source: include_str!("stdlib/workflow/stage.harn"),
627    },
628    StdlibSource {
629        module: "workflow/map",
630        source: include_str!("stdlib/workflow/map.harn"),
631    },
632    StdlibSource {
633        module: "workflow/schedule",
634        source: include_str!("stdlib/workflow/schedule.harn"),
635    },
636    StdlibSource {
637        module: "workflow/execute",
638        source: include_str!("stdlib/workflow/execute.harn"),
639    },
640];
641
642pub const STDLIB_PROMPT_ASSETS: &[StdlibPromptAsset] = &[
643    StdlibPromptAsset {
644        path: "agent/prompts/tool_contract_text.harn.prompt",
645        source: include_str!("stdlib/agent/prompts/tool_contract_text.harn.prompt"),
646    },
647    StdlibPromptAsset {
648        path: "agent/prompts/tool_contract_native.harn.prompt",
649        source: include_str!("stdlib/agent/prompts/tool_contract_native.harn.prompt"),
650    },
651    StdlibPromptAsset {
652        path: "agent/prompts/tool_contract_text_response_protocol.harn.prompt",
653        source: include_str!(
654            "stdlib/agent/prompts/tool_contract_text_response_protocol.harn.prompt"
655        ),
656    },
657    StdlibPromptAsset {
658        path: "agent/prompts/tool_contract_action_native.harn.prompt",
659        source: include_str!("stdlib/agent/prompts/tool_contract_action_native.harn.prompt"),
660    },
661    StdlibPromptAsset {
662        path: "agent/prompts/tool_contract_action_text.harn.prompt",
663        source: include_str!("stdlib/agent/prompts/tool_contract_action_text.harn.prompt"),
664    },
665    StdlibPromptAsset {
666        path: "agent/prompts/tool_contract_task_ledger.harn.prompt",
667        source: include_str!("stdlib/agent/prompts/tool_contract_task_ledger.harn.prompt"),
668    },
669    StdlibPromptAsset {
670        path: "agent/prompts/tool_contract_deferred_tools.harn.prompt",
671        source: include_str!("stdlib/agent/prompts/tool_contract_deferred_tools.harn.prompt"),
672    },
673    StdlibPromptAsset {
674        path: "agent/prompts/deferred_tool_listing.harn.prompt",
675        source: include_str!("stdlib/agent/prompts/deferred_tool_listing.harn.prompt"),
676    },
677    StdlibPromptAsset {
678        path: "agent/prompts/action_turn_nudge.harn.prompt",
679        source: include_str!("stdlib/agent/prompts/action_turn_nudge.harn.prompt"),
680    },
681    StdlibPromptAsset {
682        path: "agent/prompts/agent_turn_preamble.harn.prompt",
683        source: include_str!("stdlib/agent/prompts/agent_turn_preamble.harn.prompt"),
684    },
685    StdlibPromptAsset {
686        path: "agent/prompts/default_nudge.harn.prompt",
687        source: include_str!("stdlib/agent/prompts/default_nudge.harn.prompt"),
688    },
689    StdlibPromptAsset {
690        path: "agent/prompts/agentic_user_system.harn.prompt",
691        source: include_str!("stdlib/agent/prompts/agentic_user_system.harn.prompt"),
692    },
693    StdlibPromptAsset {
694        path: "agent/prompts/agentic_user_user.harn.prompt",
695        source: include_str!("stdlib/agent/prompts/agentic_user_user.harn.prompt"),
696    },
697    StdlibPromptAsset {
698        path: "agent/prompts/loop_until_done_system.harn.prompt",
699        source: include_str!("stdlib/agent/prompts/loop_until_done_system.harn.prompt"),
700    },
701    StdlibPromptAsset {
702        path: "agent/prompts/completion_judge_default.harn.prompt",
703        source: include_str!("stdlib/agent/prompts/completion_judge_default.harn.prompt"),
704    },
705    StdlibPromptAsset {
706        path: "agent/prompts/completion_judge_feedback_fallback.harn.prompt",
707        source: include_str!("stdlib/agent/prompts/completion_judge_feedback_fallback.harn.prompt"),
708    },
709    StdlibPromptAsset {
710        path: "agent/prompts/completion_judge_user.harn.prompt",
711        source: include_str!("stdlib/agent/prompts/completion_judge_user.harn.prompt"),
712    },
713    StdlibPromptAsset {
714        path: "agent/prompts/step_judge_system_default.harn.prompt",
715        source: include_str!("stdlib/agent/prompts/step_judge_system_default.harn.prompt"),
716    },
717    StdlibPromptAsset {
718        path: "agent/prompts/step_judge_system_adversarial.harn.prompt",
719        source: include_str!("stdlib/agent/prompts/step_judge_system_adversarial.harn.prompt"),
720    },
721    StdlibPromptAsset {
722        path: "agent/prompts/step_judge_user.harn.prompt",
723        source: include_str!("stdlib/agent/prompts/step_judge_user.harn.prompt"),
724    },
725    StdlibPromptAsset {
726        path: "agent/prompts/parse_guidance.harn.prompt",
727        source: include_str!("stdlib/agent/prompts/parse_guidance.harn.prompt"),
728    },
729    StdlibPromptAsset {
730        path: "agent/prompts/protocol_violation_feedback.harn.prompt",
731        source: include_str!("stdlib/agent/prompts/protocol_violation_feedback.harn.prompt"),
732    },
733    StdlibPromptAsset {
734        path: "agent/prompts/native_tool_contract_feedback.harn.prompt",
735        source: include_str!("stdlib/agent/prompts/native_tool_contract_feedback.harn.prompt"),
736    },
737    StdlibPromptAsset {
738        path: "agent/prompts/verification_gate_feedback.harn.prompt",
739        source: include_str!("stdlib/agent/prompts/verification_gate_feedback.harn.prompt"),
740    },
741    StdlibPromptAsset {
742        path: "agent/prompts/action_required_feedback.harn.prompt",
743        source: include_str!("stdlib/agent/prompts/action_required_feedback.harn.prompt"),
744    },
745    StdlibPromptAsset {
746        path: "agent/prompts/daemon_watch_feedback.harn.prompt",
747        source: include_str!("stdlib/agent/prompts/daemon_watch_feedback.harn.prompt"),
748    },
749    StdlibPromptAsset {
750        path: "agent/prompts/daemon_timer_feedback.harn.prompt",
751        source: include_str!("stdlib/agent/prompts/daemon_timer_feedback.harn.prompt"),
752    },
753    StdlibPromptAsset {
754        path: "llm/prompts/completion_fallback_system.harn.prompt",
755        source: include_str!("stdlib/llm/prompts/completion_fallback_system.harn.prompt"),
756    },
757    StdlibPromptAsset {
758        path: "llm/prompts/completion_fallback_user.harn.prompt",
759        source: include_str!("stdlib/llm/prompts/completion_fallback_user.harn.prompt"),
760    },
761    StdlibPromptAsset {
762        path: "llm/prompts/transcript_summarize_user.harn.prompt",
763        source: include_str!("stdlib/llm/prompts/transcript_summarize_user.harn.prompt"),
764    },
765    StdlibPromptAsset {
766        path: "llm/prompts/structural_chain_of_draft.harn.prompt",
767        source: include_str!("stdlib/llm/prompts/structural_chain_of_draft.harn.prompt"),
768    },
769    StdlibPromptAsset {
770        path: "llm/prompts/schema_recover_repair.harn.prompt",
771        source: include_str!("stdlib/llm/prompts/schema_recover_repair.harn.prompt"),
772    },
773    StdlibPromptAsset {
774        path: "llm/prompts/structured_envelope_schema_contract.harn.prompt",
775        source: include_str!("stdlib/llm/prompts/structured_envelope_schema_contract.harn.prompt"),
776    },
777    StdlibPromptAsset {
778        path: "llm/prompts/structured_envelope_repair.harn.prompt",
779        source: include_str!("stdlib/llm/prompts/structured_envelope_repair.harn.prompt"),
780    },
781    StdlibPromptAsset {
782        path: "llm/prompts/pairwise_rerank_user.harn.prompt",
783        source: include_str!("stdlib/llm/prompts/pairwise_rerank_user.harn.prompt"),
784    },
785    StdlibPromptAsset {
786        path: "llm/prompts/tool_binder_user.harn.prompt",
787        source: include_str!("stdlib/llm/prompts/tool_binder_user.harn.prompt"),
788    },
789    StdlibPromptAsset {
790        path: "workflow/prompts/stage.harn.prompt",
791        source: include_str!("stdlib/workflow/prompts/stage.harn.prompt"),
792    },
793    StdlibPromptAsset {
794        path: "workflow/prompts/verification_context_intro.harn.prompt",
795        source: include_str!("stdlib/workflow/prompts/verification_context_intro.harn.prompt"),
796    },
797    StdlibPromptAsset {
798        path: "orchestration/prompts/compaction_summary.harn.prompt",
799        source: include_str!("stdlib/orchestration/prompts/compaction_summary.harn.prompt"),
800    },
801    StdlibPromptAsset {
802        path: "orchestration/prompts/compaction_policy_replacement.harn.prompt",
803        source: include_str!(
804            "stdlib/orchestration/prompts/compaction_policy_replacement.harn.prompt"
805        ),
806    },
807];
808
809/// Embedded `.harn` script that backs a CLI subcommand. Looked up by
810/// the `harn-cli` dispatch wedge (see harn#2293 epic and harn#2294 G1)
811/// so subcommands can ship in Harn instead of Rust.
812#[derive(Debug, Clone, Copy, PartialEq, Eq)]
813pub struct StdlibCliScript {
814    /// Lookup name. For nested scripts this is the path under
815    /// `stdlib/cli/` without the `.harn` extension (e.g. `"eval/prompt"`
816    /// for `stdlib/cli/eval/prompt.harn`).
817    pub name: &'static str,
818    /// Embedded source. Run via the existing `harn run` codepath by the
819    /// dispatch wedge.
820    pub source: &'static str,
821}
822
823pub const STDLIB_CLI_SCRIPTS: &[StdlibCliScript] = &[
824    StdlibCliScript {
825        name: "doctor",
826        source: include_str!("stdlib/cli/doctor.harn"),
827    },
828    StdlibCliScript {
829        name: "echo",
830        source: include_str!("stdlib/cli/echo.harn"),
831    },
832    // Helper module for the embedded `eval/*` scripts. Has a stub `main`
833    // that exits non-zero — sibling scripts inline its helpers until the
834    // dispatch wedge gains a cross-script import surface (#2300 / G7).
835    StdlibCliScript {
836        name: "eval/_runner",
837        source: include_str!("stdlib/cli/eval/_runner.harn"),
838    },
839    StdlibCliScript {
840        name: "eval/context",
841        source: include_str!("stdlib/cli/eval/context.harn"),
842    },
843    StdlibCliScript {
844        name: "eval/model_selector",
845        source: include_str!("stdlib/cli/eval/model_selector.harn"),
846    },
847    StdlibCliScript {
848        name: "eval/tool_calls",
849        source: include_str!("stdlib/cli/eval/tool_calls.harn"),
850    },
851    StdlibCliScript {
852        name: "eval/coding_agent",
853        source: include_str!("stdlib/cli/eval/coding_agent.harn"),
854    },
855    StdlibCliScript {
856        name: "eval/scope_triage",
857        source: include_str!("stdlib/cli/eval/scope_triage.harn"),
858    },
859    StdlibCliScript {
860        name: "eval/prompt",
861        source: include_str!("stdlib/cli/eval/prompt.harn"),
862    },
863    StdlibCliScript {
864        name: "explain",
865        source: include_str!("stdlib/cli/explain.harn"),
866    },
867    StdlibCliScript {
868        name: "graph",
869        source: include_str!("stdlib/cli/graph.harn"),
870    },
871    StdlibCliScript {
872        name: "models/list",
873        source: include_str!("stdlib/cli/models/list.harn"),
874    },
875    StdlibCliScript {
876        name: "models/recommend",
877        source: include_str!("stdlib/cli/models/recommend.harn"),
878    },
879    StdlibCliScript {
880        name: "models/test",
881        source: include_str!("stdlib/cli/models/test.harn"),
882    },
883    StdlibCliScript {
884        name: "precompile",
885        source: include_str!("stdlib/cli/precompile.harn"),
886    },
887    StdlibCliScript {
888        name: "providers/catalog",
889        source: include_str!("stdlib/cli/providers/catalog.harn"),
890    },
891    StdlibCliScript {
892        name: "providers/probe",
893        source: include_str!("stdlib/cli/providers/probe.harn"),
894    },
895    StdlibCliScript {
896        name: "providers/recommend",
897        source: include_str!("stdlib/cli/providers/recommend.harn"),
898    },
899    StdlibCliScript {
900        name: "providers/tool_probe",
901        source: include_str!("stdlib/cli/providers/tool_probe.harn"),
902    },
903    StdlibCliScript {
904        name: "routes",
905        source: include_str!("stdlib/cli/routes.harn"),
906    },
907    StdlibCliScript {
908        name: "scaffold/init",
909        source: include_str!("stdlib/cli/scaffold/init.harn"),
910    },
911    StdlibCliScript {
912        name: "scaffold/tool_new",
913        source: include_str!("stdlib/cli/scaffold/tool_new.harn"),
914    },
915    StdlibCliScript {
916        name: "trace_import",
917        source: include_str!("stdlib/cli/trace_import.harn"),
918    },
919    StdlibCliScript {
920        name: "try",
921        source: include_str!("stdlib/cli/try.harn"),
922    },
923    StdlibCliScript {
924        name: "version",
925        source: include_str!("stdlib/cli/version.harn"),
926    },
927];
928
929pub fn get_stdlib_source(module: &str) -> Option<&'static str> {
930    STDLIB_SOURCES
931        .iter()
932        .find_map(|entry| (entry.module == module).then_some(entry.source))
933}
934
935/// Find an embedded CLI subcommand script by name. Returns the embedded
936/// source string when present, or `None` if no script with that name is
937/// registered in [`STDLIB_CLI_SCRIPTS`].
938pub fn find_cli_script(name: &str) -> Option<&'static str> {
939    STDLIB_CLI_SCRIPTS
940        .iter()
941        .find_map(|entry| (entry.name == name).then_some(entry.source))
942}
943
944pub fn get_stdlib_prompt_asset(path: &str) -> Option<&'static str> {
945    let path = path.strip_prefix("std/").unwrap_or(path);
946    STDLIB_PROMPT_ASSETS
947        .iter()
948        .find_map(|entry| (entry.path == path).then_some(entry.source))
949}
950
951pub fn public_functions_for_module(module: &str) -> Vec<StdlibPublicFunction> {
952    let Some(source) = get_stdlib_source(module) else {
953        return Vec::new();
954    };
955    public_functions_from_source(source)
956}
957
958pub fn entrypoint_modules() -> Vec<StdlibEntrypointModule> {
959    STDLIB_SOURCES
960        .iter()
961        .filter_map(|entry| {
962            entrypoint_category_from_source(entry.source).map(|category| StdlibEntrypointModule {
963                import_path: format!("std/{}", entry.module),
964                category,
965            })
966        })
967        .collect()
968}
969
970fn entrypoint_category_from_source(source: &str) -> Option<String> {
971    for line in source.lines() {
972        let line = line.trim();
973        if line.is_empty() {
974            continue;
975        }
976        if let Some(category) = line.strip_prefix("// @harn-entrypoint-category ") {
977            let category = category.trim();
978            return (!category.is_empty()).then(|| category.to_string());
979        }
980        if !line.starts_with("//") {
981            return None;
982        }
983    }
984    None
985}
986
987fn public_functions_from_source(source: &str) -> Vec<StdlibPublicFunction> {
988    let mut out = Vec::new();
989    let mut doc: Option<String> = None;
990    let lines = source.lines().collect::<Vec<_>>();
991    let mut index = 0usize;
992    while index < lines.len() {
993        let line = lines[index].trim();
994        if line.starts_with("/**") {
995            let (parsed, next) = parse_harndoc(&lines, index);
996            doc = parsed;
997            index = next;
998            continue;
999        }
1000        if line.starts_with("pub fn ") {
1001            let (signature_line, next) = collect_public_function_signature(&lines, index);
1002            if let Some(function) = parse_public_function_line(&signature_line, doc.take()) {
1003                out.push(function);
1004                index = next;
1005                continue;
1006            }
1007        }
1008        if let Some(function) = parse_public_function_line(line, doc.take()) {
1009            out.push(function);
1010        } else if !line.is_empty() && !line.starts_with("//") {
1011            doc = None;
1012        }
1013        index += 1;
1014    }
1015    out
1016}
1017
1018fn collect_public_function_signature(lines: &[&str], start: usize) -> (String, usize) {
1019    let mut parts = Vec::new();
1020    let mut index = start;
1021    while index < lines.len() {
1022        parts.push(lines[index].trim().to_string());
1023        let candidate = parts.join(" ");
1024        if public_function_signature_complete(&candidate) {
1025            return (candidate, index + 1);
1026        }
1027        index += 1;
1028    }
1029    (parts.join(" "), index)
1030}
1031
1032fn public_function_signature_complete(line: &str) -> bool {
1033    let Some(rest) = line.strip_prefix("pub fn ") else {
1034        return false;
1035    };
1036    let Some(name_end) = rest.find('(') else {
1037        return false;
1038    };
1039    matching_paren_len(&rest[name_end + 1..]).is_some()
1040}
1041
1042fn parse_harndoc(lines: &[&str], start: usize) -> (Option<String>, usize) {
1043    let mut parts = Vec::new();
1044    let mut index = start;
1045    while index < lines.len() {
1046        let mut line = lines[index].trim();
1047        if index == start {
1048            line = line.trim_start_matches("/**").trim();
1049        }
1050        let done = line.ends_with("*/");
1051        line = line.trim_end_matches("*/").trim();
1052        line = line.trim_start_matches('*').trim();
1053        if !line.is_empty() {
1054            parts.push(line.to_string());
1055        }
1056        index += 1;
1057        if done {
1058            break;
1059        }
1060    }
1061    let text = parts.join("\n").trim().to_string();
1062    ((!text.is_empty()).then_some(text), index)
1063}
1064
1065fn parse_public_function_line(line: &str, doc: Option<String>) -> Option<StdlibPublicFunction> {
1066    let rest = line.strip_prefix("pub fn ")?.trim();
1067    let name_end = rest.find('(')?;
1068    let name = rest[..name_end].trim();
1069    if name.is_empty() {
1070        return None;
1071    }
1072    let params_start = name_end + 1;
1073    let params_len = matching_paren_len(&rest[params_start..])?;
1074    let params = &rest[params_start..params_start + params_len];
1075    let after = rest[params_start + params_len + 1..].trim();
1076    let return_type = after
1077        .strip_prefix("->")
1078        .and_then(|tail| tail.split('{').next())
1079        .map(str::trim)
1080        .filter(|value| !value.is_empty());
1081    let signature = match return_type {
1082        Some(ret) => format!("{name}({params}) -> {ret}"),
1083        None => format!("{name}({params})"),
1084    };
1085    let param_parts = split_top_level_params(params);
1086    let total_params = param_parts
1087        .iter()
1088        .filter(|param| !param.trim().is_empty())
1089        .count();
1090    let variadic = param_parts
1091        .iter()
1092        .any(|param| param.trim_start().starts_with("..."));
1093    let required_params = param_parts
1094        .iter()
1095        .filter(|param| {
1096            let param = param.trim();
1097            !param.is_empty() && !param.contains('=') && !param.starts_with("...")
1098        })
1099        .count();
1100    Some(StdlibPublicFunction {
1101        name: name.to_string(),
1102        signature,
1103        required_params,
1104        total_params,
1105        variadic,
1106        doc,
1107    })
1108}
1109
1110fn matching_paren_len(input: &str) -> Option<usize> {
1111    let mut depth = 1usize;
1112    for (offset, ch) in input.char_indices() {
1113        match ch {
1114            '(' | '[' | '{' => depth += 1,
1115            ')' => {
1116                depth = depth.saturating_sub(1);
1117                if depth == 0 {
1118                    return Some(offset);
1119                }
1120            }
1121            ']' | '}' => depth = depth.saturating_sub(1),
1122            _ => {}
1123        }
1124    }
1125    None
1126}
1127
1128fn split_top_level_params(params: &str) -> Vec<&str> {
1129    let mut out = Vec::new();
1130    let mut depth = 0isize;
1131    let mut start = 0usize;
1132    for (offset, ch) in params.char_indices() {
1133        match ch {
1134            '(' | '[' | '{' => depth += 1,
1135            ')' | ']' | '}' => depth -= 1,
1136            ',' if depth == 0 => {
1137                out.push(&params[start..offset]);
1138                start = offset + 1;
1139            }
1140            _ => {}
1141        }
1142    }
1143    out.push(&params[start..]);
1144    out
1145}
1146
1147#[cfg(test)]
1148mod tests {
1149    use std::collections::BTreeSet;
1150
1151    use super::{
1152        entrypoint_modules, find_cli_script, get_stdlib_prompt_asset, get_stdlib_source,
1153        public_functions_for_module, STDLIB_CLI_SCRIPTS, STDLIB_PROMPT_ASSETS, STDLIB_SOURCES,
1154    };
1155
1156    #[test]
1157    fn stdlib_sources_are_non_empty() {
1158        for entry in STDLIB_SOURCES {
1159            assert!(
1160                !entry.source.trim().is_empty(),
1161                "{} should have non-empty source",
1162                entry.module
1163            );
1164        }
1165    }
1166
1167    #[test]
1168    fn cli_scripts_are_non_empty_and_uniquely_named() {
1169        let mut seen = BTreeSet::new();
1170        for entry in STDLIB_CLI_SCRIPTS {
1171            assert!(
1172                !entry.source.trim().is_empty(),
1173                "cli/{} should have non-empty source",
1174                entry.name
1175            );
1176            assert!(
1177                seen.insert(entry.name),
1178                "cli/{} is registered more than once in STDLIB_CLI_SCRIPTS",
1179                entry.name
1180            );
1181        }
1182    }
1183
1184    #[test]
1185    fn find_cli_script_round_trips() {
1186        for entry in STDLIB_CLI_SCRIPTS {
1187            assert_eq!(find_cli_script(entry.name), Some(entry.source));
1188        }
1189        assert!(find_cli_script("not-a-real-script").is_none());
1190    }
1191
1192    #[test]
1193    fn stdlib_source_names_are_unique() {
1194        let mut names = BTreeSet::new();
1195        for entry in STDLIB_SOURCES {
1196            assert!(names.insert(entry.module), "duplicate {}", entry.module);
1197        }
1198    }
1199
1200    #[test]
1201    fn stdlib_prompt_assets_are_non_empty() {
1202        for entry in STDLIB_PROMPT_ASSETS {
1203            assert!(
1204                !entry.source.trim().is_empty(),
1205                "{} should have non-empty prompt asset source",
1206                entry.path
1207            );
1208        }
1209    }
1210
1211    #[test]
1212    fn stdlib_prompt_asset_paths_are_unique() {
1213        let mut paths = BTreeSet::new();
1214        for entry in STDLIB_PROMPT_ASSETS {
1215            assert!(paths.insert(entry.path), "duplicate {}", entry.path);
1216        }
1217    }
1218
1219    #[test]
1220    fn key_stdlib_modules_resolve() {
1221        for module in [
1222            "context",
1223            "context/maintenance",
1224            "context/eval",
1225            "edit",
1226            "artifact/web",
1227            "command",
1228            "waitpoint",
1229            "llm/handlers",
1230            "llm/tool_middleware",
1231            "llm/tool_binder",
1232            "llm/ensemble",
1233            "llm/rerank",
1234            "personas/prelude",
1235            "personas/bulletins",
1236            "agent/host_tools",
1237            "agent/user",
1238            "llm/optimize",
1239            "llm/judge",
1240            "llm/refine",
1241            "connectors/shared",
1242            "connectors/github",
1243            "connectors/linear",
1244            "connectors/notion",
1245            "connectors/slack",
1246            "triage",
1247            "dashboard/jobs",
1248            "ui_resource",
1249        ] {
1250            assert!(
1251                get_stdlib_source(module).is_some(),
1252                "std/{module} should resolve"
1253            );
1254        }
1255    }
1256
1257    #[test]
1258    fn key_stdlib_prompt_assets_resolve() {
1259        for path in [
1260            "std/agent/prompts/tool_contract_text.harn.prompt",
1261            "std/agent/prompts/action_turn_nudge.harn.prompt",
1262            "std/agent/prompts/completion_judge_default.harn.prompt",
1263            "std/workflow/prompts/stage.harn.prompt",
1264            "std/orchestration/prompts/compaction_summary.harn.prompt",
1265            "std/orchestration/prompts/compaction_policy_replacement.harn.prompt",
1266        ] {
1267            assert!(
1268                get_stdlib_prompt_asset(path).is_some(),
1269                "{path} should resolve"
1270            );
1271        }
1272    }
1273
1274    #[test]
1275    fn public_function_catalog_derives_signatures_from_harn_source() {
1276        let exports = public_functions_for_module("workflow/execute");
1277        assert_eq!(exports.len(), 1);
1278        assert_eq!(exports[0].name, "workflow_execute");
1279        assert_eq!(
1280            exports[0].signature,
1281            "workflow_execute(task, graph, artifacts = nil, options = nil)"
1282        );
1283        assert_eq!(exports[0].required_params, 2);
1284        assert_eq!(exports[0].total_params, 4);
1285    }
1286
1287    #[test]
1288    fn command_stdlib_module_exports_step_helpers() {
1289        let exports = public_functions_for_module("command")
1290            .into_iter()
1291            .map(|function| function.name)
1292            .collect::<BTreeSet<_>>();
1293        for name in [
1294            "command_run",
1295            "command_output_tail",
1296            "command_json",
1297            "command_json_step",
1298            "command_try",
1299            "command_step",
1300            "command_steps_append",
1301            "command_last_failed_step",
1302            "command_step_ref",
1303        ] {
1304            assert!(exports.contains(name), "std/command should export {name}");
1305        }
1306    }
1307
1308    #[test]
1309    fn async_stdlib_exports_predicate_backoff_name_only() {
1310        let exports = public_functions_for_module("async")
1311            .into_iter()
1312            .map(|function| function.name)
1313            .collect::<BTreeSet<_>>();
1314        assert!(
1315            exports.contains("retry_predicate_with_backoff"),
1316            "std/async should export retry_predicate_with_backoff"
1317        );
1318        assert!(
1319            !exports.contains("retry_with_backoff"),
1320            "std/async should not retain the old retry_with_backoff export"
1321        );
1322    }
1323
1324    #[test]
1325    fn signal_stdlib_module_exports_interrupt_helpers() {
1326        let exports = public_functions_for_module("signal")
1327            .into_iter()
1328            .map(|function| function.name)
1329            .collect::<BTreeSet<_>>();
1330        for name in [
1331            "on_interrupt",
1332            "off_interrupt",
1333            "interrupted",
1334            "with_interrupt",
1335        ] {
1336            assert!(exports.contains(name), "std/signal should export {name}");
1337        }
1338    }
1339
1340    #[test]
1341    fn git_stdlib_module_exports_local_wrappers() {
1342        let exports = public_functions_for_module("git")
1343            .into_iter()
1344            .map(|function| function.name)
1345            .collect::<BTreeSet<_>>();
1346        for name in [
1347            "git_run",
1348            "git_status",
1349            "git_current_branch",
1350            "git_log",
1351            "git_switch",
1352            "git_pull_ff_only",
1353            "git_find_tool",
1354            "git_run_tool",
1355            "git_tools",
1356            "git_toolbox_tools",
1357        ] {
1358            assert!(exports.contains(name), "std/git should export {name}");
1359        }
1360    }
1361
1362    #[test]
1363    fn agent_workers_exports_suspend_resume_wrappers() {
1364        let exports = public_functions_for_module("agent/workers");
1365        let suspend = exports
1366            .iter()
1367            .find(|function| function.name == "suspend_agent")
1368            .expect("std/agent/workers should export suspend_agent");
1369        assert_eq!(
1370            suspend.signature,
1371            "suspend_agent(worker, reason = \"\", options = nil)"
1372        );
1373        assert_eq!(suspend.required_params, 1);
1374        assert_eq!(suspend.total_params, 3);
1375
1376        let resume = exports
1377            .iter()
1378            .find(|function| function.name == "resume_agent")
1379            .expect("std/agent/workers should export resume_agent");
1380        assert_eq!(
1381            resume.signature,
1382            "resume_agent(worker_or_snapshot, resume_input = nil, continue_transcript = true)"
1383        );
1384        assert_eq!(resume.required_params, 1);
1385        assert_eq!(resume.total_params, 3);
1386
1387        let parse_resume = exports
1388            .iter()
1389            .find(|function| function.name == "parse_resume_conditions")
1390            .expect("std/agent/workers should export parse_resume_conditions");
1391        assert_eq!(
1392            parse_resume.signature,
1393            "parse_resume_conditions(conditions = nil) -> ResumeConditions?"
1394        );
1395        assert_eq!(parse_resume.required_params, 0);
1396        assert_eq!(parse_resume.total_params, 1);
1397
1398        let lifecycle = exports
1399            .iter()
1400            .find(|function| function.name == "agent_lifecycle_tools")
1401            .expect("std/agent/workers should export agent_lifecycle_tools");
1402        assert_eq!(
1403            lifecycle.signature,
1404            "agent_lifecycle_tools(registry = nil, options = nil)"
1405        );
1406        assert_eq!(lifecycle.required_params, 0);
1407        assert_eq!(lifecycle.total_params, 2);
1408    }
1409
1410    #[test]
1411    fn tui_stdlib_module_exports_terminal_helpers() {
1412        let exports = public_functions_for_module("tui")
1413            .into_iter()
1414            .map(|function| function.name)
1415            .collect::<BTreeSet<_>>();
1416        for name in ["page", "terminal_width", "rule", "clear", "select_from"] {
1417            assert!(exports.contains(name), "std/tui should export {name}");
1418        }
1419    }
1420
1421    #[test]
1422    fn harn_entrypoint_catalog_is_declared_by_stdlib_sources() {
1423        let modules = entrypoint_modules();
1424        let entries = modules
1425            .iter()
1426            .map(|module| (module.import_path.as_str(), module.category.as_str()))
1427            .collect::<BTreeSet<_>>();
1428        for entry in [
1429            ("std/agent/loop", "agent.stdlib"),
1430            ("std/agent/turn", "agent.stdlib"),
1431            ("std/agent/primitives", "agent.stdlib"),
1432            ("std/workflow/execute", "workflow.stdlib"),
1433        ] {
1434            assert!(entries.contains(&entry), "{entry:?} should be declared");
1435        }
1436    }
1437}