Commands
query
Retrieve indexed knowledge from a specific snapshot scope
What It Does
query searches indexed repository knowledge and returns matching hits for a question. It uses the shared retrieval planner/executor, but stays snapshot-scoped, so the answer is still tied to the chosen commit state.
When To Use / When Not To Use
When to use it
- You want direct retrieval hits for a question.
- You want to inspect what the snapshot knows at a specific commit.
- You want a lightweight agent call before building a larger context packet.
When not to use it
- You need a prompt-sized packet with token budgeting. Use
context pack. - You want to resume active work from working memory. Use
memory recall.
Syntax
pnpm ragit query [question] [--input <path|->] [--top-k <n>] \ [--scope durable|session|harness|evidence|all] \ [--at <sha>] [--view minimal|default|full] \ [--format text|json|both]
Arguments And Options
question: A direct search question.--input <path|->: Provide a JSON payload withquestion,topK, and optionalat.--top-k <n>: Control how many hits to return.--scope durable|session|harness|evidence|all: Choose whether to search the durable snapshot only, explicit artifact scopes, or both.--at <sha>: Query a specific snapshot SHA or prefix.--view minimal|default|full: Choose how much hit detail to project.--format text|json|both: Choose the output form.--cwd <path>: Run against another repository.
Input And Output Contract
- Positional input is fine for a quick human call.
- Agents should prefer
--input <path|->when they need reproducible payloads.
{
"question": "restore auth context",
"topK": 5,
"at": "HEAD"
}- JSON output returns
query,snapshotSha, andhits. - JSON output also returns
redactionSummary. - Each hit can carry artifact-aware metadata such as
scope,originType,artifactId,artifactKind,authority, andconfidencewhen the indexed chunk originated from reviewed artifact material inside the snapshot. - Output is always re-masked before printing or JSON projection.
--view minimalreturns the smallest useful hit shape.--view defaultreturns the standard readable hit projection.--view fullkeeps the richest text projection and is the most expensive for context windows.
Examples
Human terminal flow:
pnpm ragit query "restore auth context" --format both
Agent-oriented flow:
pnpm ragit query --input query.json --view minimal --format json
Failures And Cautions
- Do not mix
--inputwith positionalquestion,--top-k, or--at. - If
questionis empty, the command fails. querynever reads working memory.- With
--scope durable, it stays snapshot-only. - With
--scope session|harness|evidence|all, it can merge explicit artifact/evidence overlays, but still returns sanitized output.