codenib.wiki
¶
Index-derived wiki generation for the DeepWiki-style demo.
Produces a per-repo page tree and source-grounded page content from the already-loaded BM25 / vector indexes — no LLM required. When an LLM is configured it can later refine the prose, but every code anchor here resolves to a real symbol span pulled from the indexes (no fabricated lines).
Modules:
| Name | Description |
|---|---|
agent_wiki |
Agent wiki pipeline: a DeepWiki-style, high-level conceptual wiki. |
builder |
Build a repo wiki (page tree + source-grounded page content) from indexes. |
cache_audit |
Read-only coverage and quality audit for persisted AgentWiki pages. |
evidence |
Grounding primitives for generated repository Wiki pages. |
media_artifacts |
Discovery manifest for repository-native multimodal artifacts. |
media_eval |
Evaluation helpers for multimodal repository knowledge views. |
media_evidence |
Server-side evidence packs for VLM-ready wiki media generation. |
media_facts |
Structured visual facts extracted from repository media artifacts. |
media_generation |
Provider-neutral materialization for planned wiki media slots. |
media_grounding |
Ground structured visual facts to repository files and symbols. |
media_incremental |
Incremental update planning for multimodal repository knowledge. |
media_knowledge |
Queryable multimodal repository knowledge view for wiki media. |
media_pipeline |
End-to-end construction for multimodal repository knowledge. |
media_storage |
Stable storage helpers for multimodal repository knowledge bundles. |
media_tools |
MCP-compatible query surface for multimodal repository knowledge. |
media_vlm |
OpenAI-compatible VLM extraction for repository media artifacts. |
multimodal |
Deterministic multimodal planning hooks for wiki pages. |
narrator |
LLM-authored narrative layer for the wiki (DeepWiki-style prose). |
outline |
Stage 1 of the agent wiki pipeline: a high-level conceptual outline. |
prewarm |
Bounded Wiki cache prewarming with machine-readable results. |
quality |
Deterministic quality reports for generated repository Wiki pages. |
sqlite_store |
SQLite WAL implementation of the narrow Wiki store contract. |
store |
Domain contract for persisted AgentWiki cache entries. |
Classes:
| Name | Description |
|---|---|
WikiBuilder |
Build wiki structure + content for one loaded repo bundle. |
MultimodalKnowledgeToolRouter |
Small tool router that mirrors the future MCP surface. |
OpenAICompatibleVisualFactExtractor |
Extract structured visual facts through an OpenAI-compatible chat API. |
Functions:
| Name | Description |
|---|---|
discover_media_manifest |
Discover repository-native visual artifacts and return a stable manifest. |
evaluate_mmwiki_predictions |
Evaluate visual fact extraction and visual-code grounding together. |
evaluate_visual_code_grounding |
Evaluate visual entity to source binding accuracy. |
evaluate_visual_fact_extraction |
Evaluate extracted visual entities against an MMWiki-style gold file. |
build_media_evidence_pack |
Build a bounded, provider-neutral evidence pack for one media slot. |
build_visual_facts_manifest |
Extract visual fact packs for every artifact in a media manifest. |
deterministic_visual_facts |
Return a conservative local fact pack from artifact metadata only. |
discover_source_symbol_candidates |
Return a bounded, deterministic source-symbol inventory for grounding. |
ground_visual_facts_to_sources |
Ground visual entities to a source inventory. |
diff_media_manifests |
Return a stable path/hash diff between two media manifests. |
merge_incremental_visual_facts |
Merge reused and newly extracted fact packs for the current media manifest. |
plan_incremental_visual_fact_update |
Plan reusable facts for the explicitly selected extraction policy. |
build_multimodal_knowledge_view |
Join media artifacts, visual facts, and source bindings into one view. |
find_visual_code_links |
Return visual entries that ground to a file, optionally a symbol. |
get_visual_evidence |
Return one visual knowledge entry by artifact path. |
search_visual_context |
Search multimodal entries using a deterministic lexical scorer. |
build_multimodal_repository_knowledge |
Build the deterministic multimodal repository knowledge bundle. |
build_multimodal_knowledge_bundle |
Wrap multimodal pipeline outputs in a versioned, hashable bundle. |
load_multimodal_knowledge_bundle |
Load and validate a persisted multimodal knowledge bundle. |
save_multimodal_knowledge_bundle |
Atomically write a multimodal knowledge bundle as stable JSON. |
validate_multimodal_knowledge_bundle |
Return a normalized bundle or raise |
multimodal_tool_schemas |
Return independent mutable copies of the stable tool schemas. |
visual_fact_extractor_from_config |
Build a visual-fact extractor from |
WikiBuilder
¶
WikiBuilder(
bundle,
narrator: Narrator | None = None,
*,
source_reader: RepositorySourceReader | None = None
)
Build wiki structure + content for one loaded repo bundle.
Source code in codenib/wiki/builder.py
MultimodalKnowledgeToolRouter
dataclass
¶
Small tool router that mirrors the future MCP surface.
OpenAICompatibleVisualFactExtractor
¶
OpenAICompatibleVisualFactExtractor(
*,
model: str,
api_base: str,
api_key: str | None = None,
timeout: float = 120.0,
urlopen: Callable[..., Any] | None = None,
provider: str = "openai-compatible",
repo_path: str | Path | None = None
)
Extract structured visual facts through an OpenAI-compatible chat API.
Methods:
| Name | Description |
|---|---|
extract |
Extract one canonical visual fact pack for artifact. |
Source code in codenib/wiki/media_vlm.py
extract
¶
Extract one canonical visual fact pack for artifact.
Source code in codenib/wiki/media_vlm.py
discover_media_manifest
¶
discover_media_manifest(
repo_path: str | Path,
*,
commit: str | None = None,
exclude_roots: Iterable[str | Path] = (),
selection: RepositorySourceSelection = DEFAULT_REPOSITORY_SOURCE_SELECTION,
max_artifacts: int = _MAX_MEDIA_ARTIFACTS
) -> dict[str, Any]
Discover repository-native visual artifacts and return a stable manifest.
Source code in codenib/wiki/media_artifacts.py
evaluate_mmwiki_predictions
¶
evaluate_mmwiki_predictions(
visual_facts_manifest: Mapping[str, Any],
grounding_manifest: Mapping[str, Any],
gold: Mapping[str, Any],
*,
k: int = 5
) -> dict[str, Any]
Evaluate visual fact extraction and visual-code grounding together.
Source code in codenib/wiki/media_eval.py
evaluate_visual_code_grounding
¶
evaluate_visual_code_grounding(
grounding_manifest: Mapping[str, Any], gold: Mapping[str, Any], *, k: int = 5
) -> dict[str, Any]
Evaluate visual entity to source binding accuracy.
Source code in codenib/wiki/media_eval.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
evaluate_visual_fact_extraction
¶
evaluate_visual_fact_extraction(
visual_facts_manifest: Mapping[str, Any], gold: Mapping[str, Any]
) -> dict[str, Any]
Evaluate extracted visual entities against an MMWiki-style gold file.
Source code in codenib/wiki/media_eval.py
build_media_evidence_pack
¶
build_media_evidence_pack(
slot: Mapping[str, Any],
*,
page_id: str = "",
page_title: str = "",
page_markdown: str = "",
citations: Iterable[Mapping[str, Any]] = (),
relations: Iterable[Mapping[str, Any]] = (),
source_reader: SourceReader | None = None,
max_sources: int = _DEFAULT_MAX_SOURCES,
max_relations: int = _DEFAULT_MAX_RELATIONS,
max_snippet_bytes: int = _DEFAULT_MAX_SNIPPET_BYTES
) -> dict[str, Any]
Build a bounded, provider-neutral evidence pack for one media slot.
This helper does not read repository files by itself. Callers may pass a
source_reader that returns small snippets for already-selected
citations, which keeps source exposure explicitly server-side and bounded.
Source code in codenib/wiki/media_evidence.py
build_visual_facts_manifest
¶
build_visual_facts_manifest(
media_manifest: Mapping[str, Any],
*,
extractor: VisualFactExtractor = deterministic_visual_facts
) -> dict[str, Any]
Extract visual fact packs for every artifact in a media manifest.
Source code in codenib/wiki/media_facts.py
deterministic_visual_facts
¶
Return a conservative local fact pack from artifact metadata only.
Source code in codenib/wiki/media_facts.py
discover_source_symbol_candidates
¶
discover_source_symbol_candidates(
repo_path: str | Path,
*,
exclude_roots: Iterable[str | Path] = (),
selection: RepositorySourceSelection = DEFAULT_REPOSITORY_SOURCE_SELECTION,
max_candidates: int = _MAX_CANDIDATES
) -> list[dict[str, Any]]
Return a bounded, deterministic source-symbol inventory for grounding.
Source code in codenib/wiki/media_grounding.py
ground_visual_facts_to_sources
¶
ground_visual_facts_to_sources(
visual_facts_manifest: Mapping[str, Any],
source_candidates: Iterable[Mapping[str, Any]],
*,
max_bindings_per_entity: int = _MAX_BINDINGS_PER_ENTITY,
scorer: VisualGroundingScorer | None = None
) -> dict[str, Any]
Ground visual entities to a source inventory.
The default scorer is deterministic and lexical. Callers can pass a scorer backed by BM25, embeddings, CodeGraph, LSP facts, or FactQueryIndex without changing the visual-code binding manifest schema.
Source code in codenib/wiki/media_grounding.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
diff_media_manifests
¶
Return a stable path/hash diff between two media manifests.
Source code in codenib/wiki/media_incremental.py
merge_incremental_visual_facts
¶
merge_incremental_visual_facts(
current_media_manifest: Mapping[str, Any],
reusable_fact_packs: Iterable[Mapping[str, Any]],
new_fact_packs: Iterable[Mapping[str, Any]],
) -> dict[str, Any]
Merge reused and newly extracted fact packs for the current media manifest.
Source code in codenib/wiki/media_incremental.py
plan_incremental_visual_fact_update
¶
plan_incremental_visual_fact_update(
previous_media_manifest: Mapping[str, Any],
current_media_manifest: Mapping[str, Any],
previous_visual_facts_manifest: Mapping[str, Any],
*,
expected_extractor: str | None = None
) -> dict[str, Any]
Plan reusable facts for the explicitly selected extraction policy.
Reuse is disabled unless expected_extractor names the extractor that
will be used for new work. Callers should change that identifier whenever
their model or extraction policy changes.
Source code in codenib/wiki/media_incremental.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
build_multimodal_knowledge_view
¶
build_multimodal_knowledge_view(
media_manifest: Mapping[str, Any],
visual_facts_manifest: Mapping[str, Any],
grounding_manifest: Mapping[str, Any],
) -> dict[str, Any]
Join media artifacts, visual facts, and source bindings into one view.
Source code in codenib/wiki/media_knowledge.py
find_visual_code_links
¶
find_visual_code_links(
view: Mapping[str, Any], source_path: str, *, symbol: str = ""
) -> list[dict[str, Any]]
Return visual entries that ground to a file, optionally a symbol.
Source code in codenib/wiki/media_knowledge.py
get_visual_evidence
¶
Return one visual knowledge entry by artifact path.
Source code in codenib/wiki/media_knowledge.py
search_visual_context
¶
search_visual_context(
view: Mapping[str, Any], query: str, *, limit: int = 5
) -> list[dict[str, Any]]
Search multimodal entries using a deterministic lexical scorer.
Source code in codenib/wiki/media_knowledge.py
build_multimodal_repository_knowledge
¶
build_multimodal_repository_knowledge(
repo_path: str | Path,
*,
commit: str | None = None,
exclude_roots: Iterable[str | Path] = (),
selection: RepositorySourceSelection = DEFAULT_REPOSITORY_SOURCE_SELECTION,
extractor: VisualFactExtractor | None = None,
scorer: VisualGroundingScorer | None = None,
max_artifacts: int = 4096,
max_source_candidates: int = 8192
) -> dict[str, Any]
Build the deterministic multimodal repository knowledge bundle.
Source code in codenib/wiki/media_pipeline.py
build_multimodal_knowledge_bundle
¶
build_multimodal_knowledge_bundle(
*,
media_manifest: Mapping[str, Any],
visual_facts_manifest: Mapping[str, Any],
source_candidate_count: int,
grounding_manifest: Mapping[str, Any],
knowledge_view: Mapping[str, Any]
) -> dict[str, Any]
Wrap multimodal pipeline outputs in a versioned, hashable bundle.
Source code in codenib/wiki/media_storage.py
load_multimodal_knowledge_bundle
¶
Load and validate a persisted multimodal knowledge bundle.
Source code in codenib/wiki/media_storage.py
save_multimodal_knowledge_bundle
¶
Atomically write a multimodal knowledge bundle as stable JSON.
Source code in codenib/wiki/media_storage.py
validate_multimodal_knowledge_bundle
¶
Return a normalized bundle or raise ValueError for invalid input.
Source code in codenib/wiki/media_storage.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
multimodal_tool_schemas
¶
visual_fact_extractor_from_config
¶
visual_fact_extractor_from_config(
config: Any, *, repo_path: str | Path | None = None
) -> OpenAICompatibleVisualFactExtractor | None
Build a visual-fact extractor from QAConfig-shaped settings.