Skip to main content

Module resources

Module resources 

Source
Expand description

Context files, skills, prompt templates and system prompt files.

Ports of the discovery parts of resource-loader.ts, skills.ts and prompt-templates.ts in pi v1.0.0. Project .yapi/ resources load only for a trusted project. AGENTS.md and CLAUDE.md files always load.

Structs§

ContextFile
A context file and its text.
PromptTemplate
A prompt template, expanded by /name args.
Skill
A skill: instructions the model reads on demand. A handler may add one with only the fields the prompt shows, and the others take their empty value.
SourceInfo
Where a resource was found, as pi’s SourceInfo: source is auto for discovered files, cli for command-line paths and the package for package resources. scope is user, project or temporary.

Enums§

Diagnostic
A problem found while loading skills, prompt templates or themes: pi’s ResourceDiagnostic, listed under the startup [... conflicts] sections.

Functions§

cli_source
A path given on the command line, as pi records it: source cli, scope temporary.
context_files
The global context file from the agent directory, then those of project_dir and its ancestors, outermost first. In a linked worktree nested in its main checkout, the main checkout’s file is left out when the worktree has its own.
expand_prompt_template
Expands /name args when name is a template. Other text is unchanged.
format_skills
The skills section of the prompt, read with read or bash.
merge_sources
pi’s mergePaths: sources in order, each path once, compared after resolving symlinks.
parse_command_args
Splits arguments on whitespace, honoring single and double quotes.
parse_frontmatter
pi’s parseFrontmatter: the frontmatter and the body, or the YAML error.
skills_from
pi’s loadSkills over sources, in order, each with its source: skill files, or directories searched for skills. The first skill of a name wins, and later ones are reported as collisions.
split_frontmatter
pi’s extractFrontmatter: the YAML between --- lines, when there is any, and the trimmed markdown body after it.
substitute_args
pi’s substituteArgs: replaces $1, $@, $ARGUMENTS, ${N:-default} and ${@:start:length}.
system_prompt_file
SYSTEM.md replacing the default prompt: the trusted project’s in project_dir, else the global one.
templates_from
pi’s prompt template loading over sources, in order, each with its source: markdown files, or directories of them. The first template of a name wins, and later ones are reported as collisions. Missing paths are skipped, and the caller reports the command line’s.

Type Aliases§

Frontmatter
Frontmatter as pi’s yaml parser gives it to JavaScript: the top-level mapping, in document order.