Skip to content

feat(cli): srcly refs lists every declaration of a name and its callers - #482

Merged
byronwall merged 1 commit into
harvest/unresolved-writesfrom
claude/refs-cli
Nov 28, 2026
Merged

byronwall merged 1 commit into
harvest/unresolved-writesfrom
claude/refs-cli

Conversation

@byronwall

@byronwall byronwall commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

srcly refs <name> lists every declaration of a name and what references each one. An agent can find every caller before it moves or deletes a symbol, and check afterwards that none is left. A bare name shows every copy side by side, so a type that three files each declare shows three times. file::symbol picks one declaration.

User impact: A new headless command. The app is unchanged.

Why

The symbol index already knows every declaration and reference, but only through /api/symbols/*. In the Visual Notes cleanup probe (byronwall/visual-notes#361), mapping the DocDetail copies needed a scratch Python script against the index. This command makes that step one call. It is step 1 of the cleanup loop in planning TASK-0017 (srcly-cleanup-loop.md).

Proof

Output from this branch on Visual Notes main (d59937fe, app/), before the cleanup:

$ srcly refs DocDetail app
DocDetail: 3 declarations

## src/services/docs.queries.ts:10 · type DocDetail (exported)
2 references from 2 symbols:
- src/services/docs.queries.ts:88 loadDocDetail · type exact
- src/services/docs.queries.ts:151 fetchDocLatest · type exact

## src/components/DocumentSidePanel.tsx:25 · type DocDetail (not exported)
3 references from 2 symbols:
- src/components/DocumentSidePanel.tsx:42 fetchDocDetail · type exact
- src/components/DocumentSidePanel.tsx:122, 137 DocumentSidePanel · type exact

## src/routes/docs/[id].tsx:28 · type DocDetail (not exported)
3 references from 2 symbols:
- src/routes/docs/[id].tsx:48 fetchDocDetail · type exact
- src/routes/docs/[id].tsx:81, 183 DocView · type exact

That is the whole map for the cleanup: two copies, the two cast wrappers (fetchDocDetail) and the components that read them. One declaration by id:

$ srcly refs "src/services/docs.queries.ts::fetchDoc" app
src/services/docs.queries.ts::fetchDoc: 1 declaration

## src/services/docs.queries.ts:143 · variable fetchDoc (exported)
6 references from 6 symbols:
- src/components/DocumentEditor.tsx:72 fetchDocData · call exact
- src/components/DocumentSidePanel.tsx:42 fetchDocDetail · call exact
- src/components/collections/RowPeekPanel.tsx:106 RowPeekPanel · call exact
- src/routes/docs/[id].tsx:48 fetchDocDetail · call exact
- src/services/doc-revisions.ts:53 restoreDocRevision · read exact
- src/services/docs.actions.ts:153 saveDocContent · read exact

--format json prints the same data for scripts. The startup banner goes to stderr, so stdout stays valid JSON. tests/test_symbol_refs.py covers a name with two copies (exported first), the file::symbol form, an unreferenced symbol, and a missing name. scripts/check.sh server passes (644 tests).

Survey moves: any server move comes from the new corpus module server/app/services/symbols/refs.py, whose exported functions join the survey's export sample. No analysis code changed. On the whole stack, the gate moved only server: traces +2, outcome partial +2, stop frontier: external-code +30.

Limits

  • References come from the name-based symbol index. Each row shows its resolution (exact, typed, name), as the Symbols view does.
  • A name matches exactly, not as a substring. A missing name prints suggestions only when a substring search finds some.

Stack: cleanup-loop helpers

What splits: Three srcly helpers for the cleanup loop: a command that maps a symbol's callers, a finding that names hand-copied types, and a command that lists findings by rule.
Why it splits: Each one is useful alone and can merge alone. The finding changes analysis output, so it gets its own Codex review and survey check.
Why this split: The alternative was one PR. It would mix a read-only CLI over existing data with a new analysis rule, and a reviewer would have to judge the rule's precision and the command's output together.

  1. feat(cli): srcly refs lists every declaration of a name and its callers #482: srcly refs.
  2. feat(findings): duplicate-type flags a local copy of an exported object type #483: the duplicate-type finding.
  3. feat(cli): srcly findings lists findings by rule with a count #485: srcly findings, the before and after count per rule.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@byronwall
byronwall removed this pull request from stack #484 November 28, 2026 05:05
@byronwall
byronwall changed the base branch from main to harvest/unresolved-writes November 28, 2026 05:05
@byronwall
byronwall added this pull request to stack #480 November 28, 2026 05:05
@byronwall
byronwall merged commit bb5c94c into main Nov 28, 2026
9 of 10 checks passed
@byronwall
byronwall deleted the claude/refs-cli branch November 28, 2026 05:12
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.

1 participant