Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / Source

Render with citations

Markdown with path and line citations, cut to a character budget.

PINNED SOURCE Copied from the repository at this commit. Source, not an execution.

PHAROS at 975a38dMIT license

_renderbackend/app/codeintel/context.py, lines 321–360Open source
def _render(query: str, chunks: list[dict], related: list[dict], rules: list[dict], budget: _Budget,            memory: dict | None = None) -> str:    parts: list[str] = []    header = budget.take(f"# Code context for: {query}\n")    if header:        parts.append(header)    if memory and (memory.get("briefs") or memory.get("items") or memory.get("skills")):        block = budget.take(_render_memory(memory, min(MEMORY_CHARS, max(0, budget.limit // 3))))        if block:            parts.append(block)    for c in chunks:        cite = f"{c['repository']['name']}:{c['path']}:{c['start_line']}-{c['end_line']}"        title = f"\n## [{c['rank']}] {c['symbol'] or c['path']} ({c['kind']}) — {cite}\n"        body = title        if c.get("code"):            body += f"```{c['language'] or ''}\n{c['code']}\n```\n"        else:            body += f"{c['summary']}\n"        taken = budget.take(body)        if taken is None:            break        parts.append(taken)    if related:        lines = ["\n## Related code (call graph)\n"]        for r in related:            lines.append(f"- {r['relation']}: {r['symbol']} — {r['path']}:{r['start_line']}-{r['end_line']}\n")        taken = budget.take("".join(lines))        if taken:            parts.append(taken)    if rules:        profile = rules[0].get("profile_id")        lines = [f"\n## Coding rules (profile {profile})\n" if profile else "\n## Coding rules for this repository\n"]        for r in rules:            lines.append(f"- **{r['name']}**: {r['description']}\n")            if r.get("example"):                lines.append(f"  Example: `{r['example']}`\n")        taken = budget.take("".join(lines))        if taken:            parts.append(taken)    return "".join(parts)

Where this comes from

Commit
975a38d5d17839c26ee219295a5be6ac66b6d910
File
backend/app/codeintel/context.py
Lines
321–360
Git blob
0c4a7dd4639651a5c13142d168630e344439f22a
License
MIT, © 2024–2026 Pharos Contributors. Notice

Read it on GitHub at this commit

Check it yourself

From a clone of the repository, the first command prints the blob above and the second prints these lines.

git rev-parse 975a38d:backend/app/codeintel/context.py
git show 975a38d:backend/app/codeintel/context.py | sed -n '321,360p'