magus v0.4.3 is out. See what's new
¶ View generated markdown
3 min read

magus-refs

List where an ingested code symbol is defined and referenced

Synopsis

magus refs <symbol> [flags]

Description

List where an ingested code symbol is defined and every file that references it, as file:line rows drawn from the SCIP index.

This is the occurrence-shaped view a symbol's fan-in needs: a flat list, which is what you want when the question is "who calls this". The node-link neighborhood that magus query renders is the wrong shape for that question, which is why this is its own command rather than a flag.

The argument is a symbol node ID (symbol:...) or a name that resolves to one. Symbols come from a declared SCIP index; see knowledge.symbols in the configuration. A workspace with no index has no symbols to report, and says so rather than falling back to a text search - a grep result and an index result answer different questions, and quietly substituting one for the other is how a wrong answer looks right.

--definition answers "where is the body" with the exact lines: each definition as path:start-end, from the index's enclosing range, checked against the file on disk: verified when the file predates its index, changed (exit 1) when the symbol's name has left the start line, and unverified when the name is there but the file was edited since. An index that recorded no end line says so instead of guessing one. --source adds the lines themselves.

--text switches to that other question on purpose: a literal substring search with no symbol index and no graph, printed as path:line:text like every other grep-shaped tool. It is the replacement a guard deny routes a recursive grep to, so it answers on a cold worktree with no index built. Its exit code is grep's (0 matched, 1 no match, 2 error), not the verdict codes the symbol lookup above uses - the two modes answer different questions and are not meant to share a contract.

Options

--definition
Print each definition as path:start-end, the lines its body spans, checked against the file on disk. A range the index did not record is said, never guessed
--limit | head
Print at most this many --text matches, then say how many more there were (0 for all). What `| head` would do, without losing the count or the exit code
--no-generated string
In the fallback text search shown beside a symbol miss, or with --text, exclude declared-output files entirely instead of searching them and marking the ones that match
--occurrences
Every exact source range, uncapped and verified against the tree - the view a mechanical edit needs, where the default line list is capped and describes fan-in
--refresh
Re-ingest the SCIP index before answering
--source
With --definition (implied), also print the definition's lines: a symbol's body by name, in place of grep -n then sed -n
--text
Raw substring search, no symbol index: print path:line:text matches and exit 0/1/2 for matched/no-match/error (grep's contract, not refs' verdict exit codes). Trailing paths scope the search, as grep's do; without any it searches the workspace

Examples

Every reference to a symbol

magus refs Open

By fully-qualified node ID

magus refs symbol:github.com/egladman/magus/Open

As JSON

magus refs Open -o json

Where a symbol's body starts and ends

magus refs Open --definition

A symbol's body, by name

magus refs Open --source

Raw text search, no index needed

magus refs TODO --text

See Also

magus(1), magus-ls(1), magus-describe(1), magus-run(1), magus-x(1), magus-where(1), magus-affected(1), magus-graph(1), magus-query(1), magus-explain(1), magus-path(1), magus-watch(1), magus-events(1), magus-status(1), magus-clean(1), magus-shell(1), magus-vcs(1), magus-queue(1), magus-doctor(1), magus-config(1), magus-session(1), magus-memory(1), magus-job(1), magus-notes(1), magus-diff(1), magus-server(1), magus-broker(1), magus-mcp(1), magus-buzz(1), magus-completion(1), magus-man(1), magus-init(1), magus-spell(1), magus-agent(1), magus-self(1), magus-version(1)

generatedinternal/cli/registry.goclimagus refssymbolsscipreferencesknowledge graph
Last updated (a9ff8609)
Earlier changes on this page (7)

Full history ↗ · Blame source ↗

Glossary

Workspace

The magus root directory that owns a set of projects and shared config; the unit magus operates over. See workspace.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). See operations.

Spell

A language/runtime adapter (e.g. go, md) that maps generic targets onto a toolchain's real commands. See spells.

Buzz

The language magusfiles are written in (the .buzz engine). See engines.

Affected

The set of projects touched by a change; magus affected <target> runs a target only over them. See affected.

Broker

The per-user background process that holds this host's capacity: the machine budget every run claims slots from, and the shared services runs keep warm. A run starts it on demand; broker: off in magus.yaml runs without one. See server.

Server

The background process a person starts with magus server start. It serves MCP, the console, background jobs and the warm knowledge graph, and adopts nested magus calls into one pool. See server.

CI

An ordinary magusfile-defined target you compose yourself with magus\needs - magus does not hardcode its stages. Magus.RunCI treats it specially only in that it strips the rw charm, it is the anchor magus affected ci keys off, and a selected scope with no project declaring it is a load error rather than a silent no-op. See targets.

Span

OpenTelemetry's name for one unit of work under a trace - a target execution, whose sub-operations are child spans. An output reference points at a span's captured output. See telemetry.

Knowledge graph

The queryable graph of a workspace's spells, targets, docs, and code relationships; query it with magus query/explain/path. See knowledge.

MAGUS.md

The committed routing index at a workspace root, regenerated from the knowledge graph: it lists every node and points at the exact query for a given question, so it is the entry point an agent reads first. See knowledge.

Session

An agent host's conversation, by the id the host delivers to its hooks. magus never mints one: a record with no session is unattributed, and the OS user it carries says whose account ran it.

Job

The unit of delegated work, and one row of the job store: what an orchestrating agent handed out, with its goal, the checkpoint it was cut against, the paths it may write or must not touch, and the one check it runs. A job's holder is either a session, for work an orchestrator handed out, or the server, for its own maintenance. The store records; the agent guard is what reads those facts back when grading a write. See doctrine.

A job is not a run. magus run build web is a run, and no job exists for it. A job causes runs: its check executes as one, and a server job records the invocation of its last one. Jobs are listed with magus ls jobs and in the console's Jobs view; runs are listed in the Runs view.

Run

One target executing under one magus invocation, such as magus run test web or magus affected ci. A run keeps its captured output behind an output reference. Every magus run is a run whether or not any job asked for it; see Job for how the two relate.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.