@davidorex/pi-jit-agents
Agent spec compilation and in-process dispatch runtime — the package that owns everything between 'I have a spec' and 'I have a typed result'
Package details
Install @davidorex/pi-jit-agents from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@davidorex/pi-jit-agents- Package
@davidorex/pi-jit-agents- Version
0.14.6- Published
- Apr 27, 2026
- Downloads
- 181/mo · 181/wk
- Author
- davidorex
- License
- MIT
- Types
- package
- Size
- 150.1 KB
- Dependencies
- 5 dependencies · 0 peers
Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
@davidorex/pi-jit-agents
Agent spec compilation and in-process dispatch runtime. Owns everything between "I have a spec" and "I have a typed result."
Purpose
JIT agents are named callable units with typed input contracts, typed output contracts, and context-parametric implementations materialized at runtime from project state. This package provides:
- Spec loading with full path resolution and tier-aware discovery
- Template compilation with project block context injection
- In-process LLM dispatch with phantom-tool structured output enforcement
- Agent contract introspection for SDK queries
There is one concept of "agent" regardless of whether a workflow step or a monitor classify call invokes it. Classification is agent execution with a verdict-shaped output schema; it is not a separate primitive.
Boundary
The package owns four public surfaces:
loadAgent(name, ctx) → AgentSpec— resolves spec from discovery tiers, fully resolves all path fields to absolutecompileAgent(spec, ctx) → CompiledAgent— renders templates, injectscontextBlocksfrom.project/, composes final promptsexecuteAgent(compiled, dispatch) → JitAgentResult— in-process LLM dispatch with phantom tool enforcementagentContract(spec) → AgentContract— projection for introspection, no execution
Subprocess dispatch stays in pi-workflows. The package never reads from .pi/ — that directory is Pi platform territory.
Discovery tiers
Agent specs are searched in this order:
{cwd}/.project/agents/{name}.agent.yaml— project-level overrides{userDir ?? ~/.pi/agent/agents/}/{name}.agent.yaml— user-global overrides{builtinDir}/{name}.agent.yaml— consumer-supplied builtins
The framework package itself ships no bundled agent specs. Consumer packages supply their own builtin directory at loader construction time.
Exports
.— main barrel./types— type definitions./agent-spec—parseAgentYaml,createAgentLoader./template—createTemplateEnv,renderTemplate,renderTemplateFile./compile—compileAgent./runtime—executeAgent,buildPhantomTool./introspect—agentContract