A PowerShell module for architecture-aware, file-based retrieval over local project documentation, backed by a locally running Ollama instance.
llamarc42 walks your ai/projects/<project> workspace, applies a declarative retrieval policy, and sends *grounded- prompts to Ollama for either:
- persistent, resumable chat sessions, or
- programmatic session-based queries
llamarc42 does *not- fine-tune or train the model. It retrieves documentation artifacts at runtime and sends only the selected context to Ollama for each request.
- llamarc42 PowerShell Module
llamarc42 solves a common problem when working with local AI models:
How do you reliably feed the model the *right- subset of project documentation without copying and pasting files by hand?
The module provides:
| Capability | Description |
|---|---|
| *Path resolution- | Automatically discovers the ai/ workspace root by walking upward from the current directory. |
| *Context file scanning- | Recursively collects documentation files from ai/global and ai/projects/<project>. |
| *Retrieval policy- | A declarative YAML policy controls *which- artifacts are selected per intent (planning, coding, review, general). |
| *Grounded prompts- | Builds a structured request payload from retrieved artifacts, session state, and user input, then sends it to Ollama. |
| *Persistent sessions- | Stores resumable, multi-turn chat sessions on disk using session.json and messages.jsonl. |
| *Conversation scaling- | Summarizes older turns into a rolling summary so long-running chats remain usable. |
| *Diagnostics- | Lets you inspect selected files and fully constructed prompts before sending anything to Ollama. |
Local models are powerful, but without context they do not know your:
- architecture
- ADRs
- constraints
- glossary
- project-specific rules
llamarc42 makes local conversations more reliable by ensuring the model sees:
- your global documents
- your project documents
- the *right subset- of those documents for the current intent
- the *relevant conversation history- for the current session
This is especially useful for:
- architecture discussions
- ADR review
- design validation
- implementation planning
- long-running, project-scoped conversations
At a high level, each request follows this flow:
- Resolve the current project from your location under
ai/projects/<project>. - Load the retrieval policy from
ai/tooling/config/retrieval.yaml. - Select the appropriate files for the chosen intent.
- Load the selected artifacts.
- Load the current session’s rolling summary and recent message history.
- Build a structured message payload.
- Send the payload to Ollama.
- Persist the user message and assistant response back to disk.
This makes the system:
- local-first
- inspectable
- repeatable
- grounded in documentation
The module expects an ai/ workspace above your working directory:
<repo-root>/
└── ai/
├── global/ # Cross-project context shared by all projects
│ ├── constitution.md
│ ├── principles.md
│ └── glossary.md
├── projects/
│ └── <project-name>/ # Per-project documentation artifacts
│ ├── project.md
│ ├── context.md
│ ├── constraints.md
│ ├── architecture/
│ ├── decisions/
│ ├── domain/
│ ├── quality/
│ └── .sessions/ # Auto-created; persisted session data
└── tooling/
└── config/
└── retrieval.yaml # Retrieval policy
Resolve-Llamarc42Path walks upward from your current directory until it finds a folder whose parent is projects/, then derives both the project root and the ai/global sibling automatically.
That means you can run the module from:
ai/projects/llamarc42
or from a nested folder such as:
ai/projects/llamarc42/architecture
and it will still resolve the correct project and global paths.
| Requirement | Version |
|---|---|
| PowerShell | 7.0+ |
| Ollama | Running locally (default: http://localhost:11434) |
| powershell-yaml | Required for retrieval policy loading |
Install the YAML module if you plan to use retrieval policies:
Install-Module -Name powershell-yaml -Scope CurrentUserNote: long-running session summarization also uses the configured Ollama model through the local
/api/chatendpoint.
Clone or copy the llamarc42/ folder to a location on your $env:PSModulePath, then import it:
Import-Module ./llamarc42/llamarc42.psd1Or import directly by path:
Import-Module /path/to/powershell/llamarc42/llamarc42.psd1Set-Location ai/projects/llamarc42
Start-Llamarc42ProjectChat -Name 'architecture-review' -Intent planningThis will:
- resolve the current project
- load the retrieval policy
- select planning-relevant artifacts
- create or resume a session
- start a persistent multi-turn conversation loop
Type exit, quit, or :q to end the session.
$session = Resume-Llamarc42ProjectSession -Name 'architecture'
Send-Llamarc42ProjectSessionMessage `
-Session $session `
-Prompt 'What open questions remain from this discussion?' `
-Intent planningThis is useful for continuing a project conversation over hours or days.
Get-Llamarc42ProjectContextDebug -Intent planning |
Select-Object -ExpandProperty Files |
Format-Table Scope, RelativePath, Reason, Priority, OrderRankThis shows:
- which files will be included
- why each file was selected
- how they were ranked
$session = New-Llamarc42ProjectSession -Name 'prompt-inspection'
Send-Llamarc42ProjectSessionMessage `
-Session $session `
-Prompt 'What risks are documented for this project?' `
-Intent review `
-InspectPromptThis returns the fully constructed request payload without:
- writing the user message to the transcript
- calling the Ollama endpoint
It is useful for debugging and demos.
llamarc42 uses a YAML retrieval policy at:
ai/tooling/config/retrieval.yaml
Required top-level sections:
versionglobalprojectretrieval
Example:
version: 1
global:
always_include:
- constitution.md
- principles.md
- glossary.md
project:
include:
- project.md
- context.md
- constraints.md
folders:
architecture:
priority: high
decisions:
priority: high
domain:
priority: medium
quality:
priority: medium
retrieval:
strategies:
planning:
include:
- architecture/**
- decisions/**
- constraints.md
max_files: 10
coding:
include:
- domain/**
- constraints.md
max_files: 8
review:
include:
- decisions/**
- architecture/**
- quality/**
max_files: 12
general:
include:
- project.md
- context.md
max_files: 6
history:
max_messages: 50
summarize_after: 30For each request, llamarc42 selects files in this order:
global.always_includeproject.include- intent-specific strategy matches from
retrieval.strategies.<intent>.include
Intent-specific matches are then:
- ranked by configured folder priority (
high→medium→low) - deduplicated
- capped by
max_files
Current retrieval is policy-driven and file-based. llamarc42 does *not- yet use embeddings or semantic vector search; instead it selects artifacts using explicit YAML rules, folder priorities, and per-intent file limits.
Start an architecture-focused session:
Set-Location ai/projects/llamarc42
Start-Llamarc42ProjectChat -Name 'csharp-core' -Intent planningThen ask:
What constraints and ADRs should govern the move from PowerShell to a C# core?
Why this is a good demo:
- it exercises planning retrieval
- it should pull in architecture, decisions, and constraints
- it reflects a real project question
Start a review-oriented session:
Start-Llamarc42ProjectChat -Name 'api-boundary-review' -Intent reviewThen ask:
Given the current architecture and ADRs, what risks do you see in introducing an API before the C# core is stable?
Why this is a good demo:
- it shows architecture-aware reasoning
- it demonstrates policy-driven review context
- it surfaces tradeoffs instead of generic advice
List recent sessions:
Get-Llamarc42ProjectSessionList -First 10Resume one:
$session = Resume-Llamarc42ProjectSession -Name 'csharp-core'Continue the discussion:
Send-Llamarc42ProjectSessionMessage `
-Session $session `
-Prompt 'Summarize the decisions we have already made and the main open questions.' `
-Intent planningView the most recent transcript entries:
Get-Llamarc42ProjectSessionMessage -Session $session -Tail 10Why this is a good demo:
- it proves sessions are durable
- it makes persistence tangible
- it shows continuity across days
Use llamarc42 from a script without launching the interactive loop:
$session = New-Llamarc42ProjectSession -Name 'scripted-review'
$result = Send-Llamarc42ProjectSessionMessage `
-Session $session `
-Prompt 'What project risks are currently documented?' `
-Intent review `
-RawResponse
$result.ResponseWhy this is useful:
- shows automation-friendly usage
- makes it clear the module is not just a REPL
- useful for pipelines, reports, and tooling
Each session lives under:
ai/projects/<project>/.sessions/<timestamp-name>/
Example:
ai/projects/llamarc42/.sessions/2026-04-01_101500-architecture-review/
Each session contains:
session.json— metadata such as model, timestamps, tracked files, and rolling summarymessages.jsonl— append-only transcript, one JSON object per line
This makes sessions:
- easy to inspect
- easy to debug
- easy to parse from external tools
| Function | Description |
|---|---|
Resolve-Llamarc42Path |
Walks upward from -ProjectFolder to locate the ai/projects/<project> root and resolve the matching ai/global folder. |
Get-Llamarc42Files |
Recursively scans a path and returns FileInfo objects for all files matching the requested extensions. |
Get-Llamarc42Content |
Reads a set of files and concatenates them into a single string, optionally wrapping each with BEGIN/END FILE markers. |
Get-Llamarc42ProjectContext |
Combines global and project file scans and content into one object with a CombinedContent string. Mainly useful for full-context inspection and earlier workflows. |
| Function | Description |
|---|---|
Get-Llamarc42RetrievalPolicy |
Loads and validates retrieval.yaml. Requires the powershell-yaml module. Returns a Llamarc42.RetrievalPolicy object. |
Resolve-Llamarc42RetrievalContext |
Applies a retrieval policy for a given intent, ranks and deduplicates artifacts, and returns a Llamarc42.RetrievalContext with an ordered Items list. |
| Function | Description |
|---|---|
New-Llamarc42ProjectSession |
Creates a session folder under .sessions/, writes session.json and an empty messages.jsonl. Returns an Llamarc42.ProjectSession object. |
Get-Llamarc42ProjectSession |
Loads a session by id, folder path, or most-recent default. |
Get-Llamarc42ProjectSessionList |
Returns summary info (Llamarc42.ProjectSessionInfo) for all sessions in the project, with optional name filter and result cap. |
Select-Llamarc42ProjectSession |
Interactive prompt that lets the user pick a session from a numbered list. |
Resume-Llamarc42ProjectSession |
Returns the most-recent session or resolves a specific one by partial name/title/id match. |
Add-Llamarc42ProjectSessionMessage |
Appends a user, assistant, or system message to messages.jsonl and updates session metadata. |
Get-Llamarc42ProjectSessionMessage |
Reads messages from messages.jsonl, with optional -Tail and -Raw flags. |
| Function | Description |
|---|---|
Get-Llamarc42ProjectSessionConversationWindow |
Builds the active conversation window for a session: returns recent messages to include in the next request, identifies older messages that should be folded into the rolling summary, and surfaces the current RollingSummary. |
Update-Llamarc42ProjectSessionSummary |
Produces and persists a condensed rolling summary when older messages exceed the configured threshold. |
| Function | Description |
|---|---|
Send-Llamarc42ProjectSessionMessage |
Full retrieval + session pipeline: resolves retrieval context for the intent, updates the rolling summary when needed, builds the request payload, calls /api/chat, and persists both the user prompt and assistant reply. Accepts either -Session or -Path. |
Start-Llamarc42ProjectChat |
Entry-point REPL: resolves paths, lets the user resume or create a session, then loops on Read-Host until exit/quit/:q. |
| Function | Description |
|---|---|
Get-Llamarc42ProjectContextDebug |
Resolves project/global paths, loads the retrieval policy, builds the retrieval context for the requested intent, and returns a debug object showing selected artifact files and history thresholds. |
Send-Llamarc42ProjectSessionMessage -InspectPrompt |
Returns the fully constructed request payload without writing to the transcript or calling Ollama. Useful for debugging and demos. |
powershell/
├── llamarc42/
│ ├── llamarc42.psd1
│ ├── llamarc42.psm1
│ ├── private/
│ │ ├── ConvertTo-Slug.ps1
│ │ ├── Find-ArtifactMatches.ps1
│ │ ├── Get-ArtifactRelativePath.ps1
│ │ ├── Get-RetrievalContextContent.ps1
│ │ ├── Get-SessionTimestamp.ps1
│ │ ├── Invoke-Llamarc42ProjectChat.ps1
│ │ ├── New-InteractiveLlamarc42ProjectSession.ps1
│ │ ├── New-SessionObject.ps1
│ │ ├── Resolve-Llamarc42ProjectSessionByName.ps1
│ │ ├── Resolve-SessionObject.ps1
│ │ └── Save-SessionMetadata.ps1
│ └── public/
│ ├── Add-Llamarc42ProjectSessionMessage.ps1
│ ├── Get-Llamarc42Content.ps1
│ ├── Get-Llamarc42Files.ps1
│ ├── Get-Llamarc42ProjectContext.ps1
│ ├── Get-Llamarc42ProjectContextDebug.ps1
│ ├── Get-Llamarc42ProjectSession.ps1
│ ├── Get-Llamarc42ProjectSessionConversationWindow.ps1
│ ├── Get-Llamarc42ProjectSessionList.ps1
│ ├── Get-Llamarc42ProjectSessionMessage.ps1
│ ├── Get-Llamarc42RetrievalPolicy.ps1
│ ├── New-Llamarc42ProjectSession.ps1
│ ├── Resolve-Llamarc42Path.ps1
│ ├── Resolve-Llamarc42RetrievalContext.ps1
│ ├── Resume-Llamarc42ProjectSession.ps1
│ ├── Select-Llamarc42ProjectSession.ps1
│ ├── Send-Llamarc42ProjectSessionMessage.ps1
│ ├── Start-Llamarc42ProjectChat.ps1
│ └── Update-Llamarc42ProjectSessionSummary.ps1
├── .gitignore
└── LICENSE
- Strict mode:
Set-StrictMode -Version Latestand$ErrorActionPreference = 'Stop'are set at module load time to surface errors early. - Typed objects: returned objects carry
PSTypeNamevalues such asLlamarc42.ProjectSessionandLlamarc42.RetrievalContext. - JSONL transcripts: session messages are stored one JSON object per line in
messages.jsonl, making them easy to tail, grep, and parse. - No cloud dependency: all LLM calls go to a local Ollama instance.
- Deterministic artifact ordering: retrieved artifacts are sorted by rank and relative path, ensuring reproducible prompts.
- Policy-driven retrieval: current retrieval is file- and rule-based, not embeddings-based semantic search.
Install the YAML module:
Install-Module -Name powershell-yaml -Scope CurrentUserEnsure Ollama is running locally and reachable:
ollama listDefault endpoint:
http://localhost:11434
Run the module from somewhere inside:
ai/projects/<project>
or pass -ProjectFolder explicitly where supported.
Ensure this file exists:
ai/tooling/config/retrieval.yaml
Use prompt inspection to verify the constructed request:
Send-Llamarc42ProjectSessionMessage `
-Session $session `
-Prompt 'Test prompt' `
-InspectPromptThen verify:
- selected files
- request structure
- Ollama model availability
See LICENSE.