This document describes the externally observable retrieval behavior of the scriptorium runtime.
For the general runtime surface, see Runtime Contract. For artifact build/load rules, see Artifacts.
- Search text is normalized before matching.
- Full-text tokenization keeps CJK-friendly behavior and mixed ASCII/CJK queries.
- Path and label boosts use the normalized phrase plus token matches.
search returns ranked docs and code references.
- Empty or whitespace-only queries return no results.
topKandsnippetLinesare clamped to bounded ranges.extensionscontrols whether docs, code, or both are searched.- results are deduplicated and sorted by score, then path and range tiebreaks
- If docs index artifacts are available and valid, the runtime searches them first.
- Otherwise it falls back to Markdown filesystem scanning.
- Docs matches are produced from heading blocks rather than arbitrary line slices.
- Heading text and file path receive stronger boosts than body-only matches.
- Snapshot-backed code sources search the prebuilt snapshot first.
- Filesystem-backed code sources scan configured roots when no snapshot result path is available.
- Matching code lines produce
code_rangerefs centered around the matched line. - Nearby hits in the same file are clustered so the best local result survives.
- When no matching line exists but the path or source label strongly matches, the runtime can return a file-level fallback anchored at line 1.
mode=implementation is additive. It does not change the tool contract, but it does change ranking:
- startup / entrypoint files are boosted
- DI / service registration hints are boosted
- route / endpoint material is boosted
- attribute / decorator patterns are boosted
- config-oriented material is boosted
- the runtime prefers returning at least one docs result and one code result when both corpora have useful matches
- docs snippets come from the start of the matched heading block
- code snippets center around the matched line when possible
- snippet length is controlled by
snippetLines
get_content resolves a single refId.
snippet: focused range around the anchorfull: full block or full file, subject tomaxLinesmulti_range: highlighted ranges around important lines
- Markdown refs resolve to heading blocks.
- The slug identifies the heading block inside the file.
snippetandfulloperate on that block.multi_rangemarks ordered lists, bullet lists, nested headings, or other flow-relevant lines inside the block.
- Code refs resolve to a logical code path and line anchor.
snippetcenters around the requested line.fullreturns the whole file, subject to truncation.multi_rangemarks the anchor line, nearby signatures, route handlers, and other interesting implementation lines.
- File refs resolve the whole file path without a line anchor.
- In docs-only mode, code/file refs are unavailable for code sources.
expand_related starts from one or more seed refs and finds supporting refs.
- seeds are loaded as Markdown or code contexts
- overlap tokens, import-like tokens, path proximity, and framework tags all contribute to score
- results include scored reasons rather than a single opaque score
- docs and code candidates can both appear in the same response
mode=implementation enables additional framework-aware relations such as startup wiring, DI, route, attribute/decorator, and config links.
summarize_flow turns refs into a deterministic step list.
For Markdown:
- numbered steps
- labeled steps such as
手順1 - bullet lists
- nested headings
- paragraph fallback
For code:
- route handlers, function/class signatures, and recognizable operations contribute candidate steps
- style selection affects how compactly the steps are rendered
flow: ordered steps with titles, descriptions, and refsassumptions: explicit fallback notesconfidence: qualitative confidence derived from source quality and merge stability
If there are no usable refs, the runtime falls back to the requested topic rather than returning a protocol error.
guide_implementation composes retrieval tools into a single grounded guide.
- builds a query from
topic,framework, andlanguage - runs implementation-mode docs and code search
- expands supporting refs from the best initial seeds
- summarizes the combined refs into a short implementation flow
- returns separate
docsandsampleCodesupport lists, plusassumptionsandconfidence
The guide intentionally stays grounded in the current corpus. If supporting refs are missing, the response records that limitation instead of inventing missing sources.