Skip to content

feat(context): get a function's source by name (closes #316)#317

Merged
Wolfvin merged 1 commit into
mainfrom
feat/issue-316-get-source
Jul 18, 2026
Merged

feat(context): get a function's source by name (closes #316)#317
Wolfvin merged 1 commit into
mainfrom
feat/issue-316-get-source

Conversation

@Wolfvin

@Wolfvin Wolfvin commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Closes #316. Found by dogfooding CodeLens on itself (north-star #279 agent-ergonomics).

Yang dibangun

context --check source --name X mengembalikan source satu fungsi + range file:start-end — pengganti langsung "Read file utuh cuma untuk lihat satu fungsi", langkah manual paling sering tersisa di navigasiku.

## Source: `_fn_of`
**commands/flow_diff.py:33-35**
​```
def _fn_of(label: str) -> str:
    """The function part of an edge label (`Owner.fn` -> `fn`, `fn` -> `fn`)."""
    return label.rsplit(".", 1)[-1] if label else label
​```

Read-only compose

Locate X (via --file outline, atau graph find_nodes_by_name dari scan) → batas = deklarasi berikutnya di file (atau EOF) → trim blank → slice. Fungsi senama N file → N match; workspace belum di-scan tanpa --file → error no_graph eksplisit, bukan silent-empty (disiplin sama #315). Batas = heuristik next-declaration (bukan parser end-line) supaya tetap read-only — dokumentasikan.

Verifikasi (dijalankan — dogfood)

  • Ambil body 3-baris _fn_of dari file 105-baris tanpa membacanya.
  • 7 test: slice tepat, batas tak bocor ke fungsi berikutnya, fungsi terakhir → EOF, trim blank, not-found, missing-name → error, fungsi senama 2 file → 2 match, no-graph → error eksplisit.
  • markdown code-block; json/compact; ambiguity (add_args → 63 def).
  • 19 gagal = 19 di main — nol regresi. Design doc, allowlist, docs sync, count 12.

Ini north-star langsung: aku berhenti Read file utuh untuk satu fungsi. Berikutnya (beruntun): #315 (fix CLI silent-error).

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

context --check source --name X returns just function X's source plus its
file:start-end range — the direct replacement for "Read the whole file to
see one function", the most common manual step left in agent navigation
(north-star #279). Found by dogfooding CodeLens on itself.

Read-only compose, no new engine: locate X (via --file outline, or graph
find_nodes_by_name from a prior scan), bound it by the next declaration in
the file (or EOF), trim trailing blanks, slice. Same-name in N files returns
N matches; an unscanned workspace with no --file returns an explicit
no_graph error, never silent-empty (same discipline as #315).

Boundary is a next-declaration heuristic, not the parser's end line, to stay
read-only — exact for the common case, documented. Command count stays 12.

Verified by dogfooding: retrieved _fn_of's 3-line body from a 105-line file
without reading it. 7 tests (slice, boundary no-bleed, EOF, trim, not-found,
missing-name, same-name-two-files, no-graph error). Full suite 19 = 19 on main.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@Wolfvin
Wolfvin merged commit 2daba47 into main Jul 18, 2026
2 of 8 checks passed
@Wolfvin
Wolfvin deleted the feat/issue-316-get-source branch July 18, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(context): get a function's source by name — so the agent stops Read-ing whole files

1 participant