PtcRunner.Lisp.Prelude.PromptInventory (PtcRunner v0.13.0)

Copy Markdown View Source

Deterministic, bounded prompt-inventory renderer for a compiled prelude (Capability Prelude V1, plan §9).

The renderer is fed by the SAME %PtcRunner.Lisp.Prelude.Export{} records the analyzer, evaluator, and discovery forms consult — there is no separate prompt/discovery registry. It produces a compact, domain-blind-at-the-core block that a deployment-specific prelude fills with its own namespace and export names. The block is inserted into the SubAgent system prompt through dynamic context assembly, NOT by editing static core prompt templates.

What it renders

  • a per-namespace summary (namespace name + docstring) for namespaces that have at least one :prompt-visible export;
  • for each such namespace, up to per_namespace_cap/0 prompt-visible exports, each with its signature, short doc, and — only for an inferred :read/:write backing — an effect hint (:unknown is omitted as noise, but stays available via (meta ...) / (ns-publics ...));
  • a "more via (ns-publics 'ns)" line when a namespace has more prompt-visible exports than the cap;
  • a discovery hint noting that additional :discoverable exports (omitted from the inventory by design) can be found through doc/dir/apropos/ ns-publics, and that source renders an export's defining form;
  • a compact existing-ledger summary (Tool calls made / Tool call errors) when ledger data is supplied.

Determinism + bounds

Output is fully determined by the export records and the supplied ledger counts: namespaces and exports are sorted, and per-namespace export rendering is capped at per_namespace_cap/0. render/2 returns nil when there is no prelude or no :prompt-visible export, so callers can filter the section out of prompt assembly.

Summary

Types

Ledger summary input. Either a precomputed %{tool_calls: n, tool_errors: m} map or the raw tool_calls list (records carrying an :error field that is nil on success), from which counts are derived.

Functions

The per-namespace cap on rendered prompt-visible exports.

Renders the prompt inventory for prelude.

Types

ledger()

@type ledger() ::
  %{tool_calls: non_neg_integer(), tool_errors: non_neg_integer()} | [map()]

Ledger summary input. Either a precomputed %{tool_calls: n, tool_errors: m} map or the raw tool_calls list (records carrying an :error field that is nil on success), from which counts are derived.

Functions

per_namespace_cap()

@spec per_namespace_cap() :: pos_integer()

The per-namespace cap on rendered prompt-visible exports.

render(prelude, opts \\ [])

@spec render(
  PtcRunner.Lisp.Prelude.t() | nil,
  keyword()
) :: String.t() | nil

Renders the prompt inventory for prelude.

Options

  • :ledger — a %{tool_calls: n, tool_errors: m} map or a raw tool_calls list; when present, a compact ledger summary is appended.

Returns the rendered block string, or nil when there is no prelude or no :prompt-visible export to show.