Skip to content

Improve alias-like import reachability from agent repo lab #8

@EgemennSahin

Description

@EgemennSahin

Problem

The latest agent-repo lab shows that unresolved import counts are now split into useful buckets, but alias-like imports still block some project-local reachability evidence in real JS/TS agent repos.

This is not a security finding and not a claim that any external repository is unsafe. The issue is only about agentdiff understanding repo-local alias imports well enough to explain agent-to-tool reachability.

Evidence from the lab

Latest secondary lab summary:

  • 20/20 public JS/TS agent repos scanned
  • 0 crashes
  • 55 useful findings
  • 2 noisy findings
  • 3/3 useful synthetic PR tests

Alias-like unresolved samples that look agent/tool-relevant:

  • vercel/ai: 147 alias-like unresolved imports
    • @/tool/weather-tool from examples/ai-e2e-next/agent/anthropic/tools-agent.ts
    • @/tool/sandbox-shell-tool from examples/ai-e2e-next/agent/openai/sandbox-agent.ts
    • @/agent/anthropic/advisor-20260301-agent from examples/ai-e2e-next/app/api/chat/anthropic-advisor-20260301/route.ts
  • i-am-bee/beeai-framework: 117 alias-like unresolved imports
    • @/agents/base.js from typescript/src/adapters/a2a/agents/agent.ts
    • @/memory/base.js from typescript/src/adapters/a2a/agents/agent.ts
    • @/backend/message.js from typescript/src/adapters/a2a/agents/agent.ts
  • VoltAgent/voltagent: 56 alias-like unresolved imports
    • @/voltagent from examples/next-js-chatbot-starter-template/app/api/chat/route.ts
    • @/lib/ai/config from examples/next-js-chatbot-starter-template/app/api/chat/route.ts

These samples suggest the remaining blind spot is high-confidence project-local alias reachability, not external packages like zod, provider SDKs, or framework dependencies.

Proposed fix

Add narrow alias-like import reachability handling for project-local imports when there is strong evidence, for example:

  • @/ or ~/ conventions that can be mapped to a nearby app/package src, app root, or configured root without leaving the scan root.
  • Alias resolution only when the target is an obvious local file using existing extension and index fallback logic.
  • Explanations that record resolved_via, the alias convention, importing file, and target file.

Keep the existing unresolved bucket reporting so unsupported imports remain visible.

Acceptance criteria

  • npm test passes.
  • Secondary agent-repo lab remains 20/20 scanned with 0 crashes.
  • At least one cited alias-like sample resolves or is explicitly documented as intentionally unsupported.
  • External dependency-like imports are still not treated as product blind spots by default.
  • Reports continue to cap samples so map/report output does not explode.

Non-goals

  • Do not build a full TypeScript compiler resolver.
  • Do not install dependencies in external repos.
  • Do not shell out to tsc.
  • Do not run live model calls.
  • Do not classify external repos as vulnerable or unsafe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions