pi-template-kit

Shared LiquidJS prompt-template engine, filters, XML tag, and file loader for Pi packages.

Packages

Package details

prompt

Install pi-template-kit from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-template-kit
Package
pi-template-kit
Version
0.3.0
Published
Jul 30, 2026
Downloads
3,829/mo · 2,313/wk
Author
any-victor
License
MIT
Types
prompt
Size
30 KB
Dependencies
2 dependencies · 0 peers

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-template-kit

Shared LiquidJS prompt-template toolkit for Pi packages.

Why

grounded-compaction and pi-prompt-composer both grew local Liquid engines:

  • same engine defaults
  • overlapping filters
  • incompatible {% xml %} implementations
  • duplicated frontmatter/template loading logic

pi-template-kit is the small library that owns that shared layer. It does not own pi-loom host orchestration, system prompt graph policy, reminders, provider payloads, or custom-message registries.

Package surfaces

Import Purpose
pi-template-kit/liquid createEngine, filters, native {% xml %} tag
pi-template-kit/template loadTemplate, loadTemplateFromString, frontmatter + partial/layout roots
pi-template-kit re-exports both surfaces

Example

import { loadTemplate } from 'pi-template-kit/template';

const template = await loadTemplate('compaction-prompt.md');
const out = template.render({ focus: 'ship it' });

The {% xml %} tag

Wraps a block in an XML element, and emits nothing when the body is empty — so an optional prompt section needs no surrounding {% if %}.

{% xml "focus" %}{{ focus }}{% endxml %}
<focus>
ship it
</focus>

Attributes

Optional key:value pairs after the tag name. Values are Liquid expressions or quoted literals, parsed by Liquid's own Hash — the same grammar {% for %} uses.

{% xml "files-touched" cwd:cwd mode:"strict" %}{{ manifest }}{% endxml %}
<files-touched cwd="/Users/v/project" mode="strict">
…manifest…
</files-touched>
  • key:value, not key=value. The equals form is Liquid's bare-flag spelling and binds true, so cwd=cwd emits cwd="true" — a wrong value rather than an error. Use the colon.
  • Nil and empty values are omitted, so passing an optional variable unguarded yields <files-touched> rather than cwd="".
  • Values are XML-escaped (&, <, >, ").
  • An empty body still emits nothing, attributes notwithstanding.

Ownership split

Package Owns
pi-template-kit Liquid engine, shared filters, {% xml %} tag, file template loader
pi-loom prompt graph, system reminders, host coordinator, provider handoff metadata
pi-prompt-composer grouped prompt discovery, arg collection, shell block policy
grounded-compaction compaction render variables, summary workflow, examples
pi-prompt-core legacy messages registry until consumers migrate; no new template/system-prompt work

Development

pnpm install
pnpm run check

License

MIT