Skip to content

Conversation

@fab-uleuh
Copy link

Summary

  • Add sourceAttribute prop to configure which data attribute to read source location from
  • Add sourceFile, sourceComponent, sourceUnavailableReason fields to Annotation type
  • Detect source via data-tsd-source attribute (TanStack Devtools compatible)
  • Fallback to React fiber _debugSource in dev mode

Configurable source attribute

The sourceAttribute prop allows customizing which HTML data attribute is used to read source file paths:

// Default: reads from data-tsd-source (TanStack Devtools)                                                                                                                               
<Agentation />                                                                                                                                                                           
                                                                                                                                                                                         
// Custom: reads from your own data attribute                                                                                                                                            
<Agentation sourceAttribute="data-my-source" />                                                                                                                                          
                                                                                                                                                                                         
This makes the feature compatible with any tooling that injects source location as data attributes, not just TanStack Devtools.                                                          
                                                                                                                                                                                         
Changes                                                                                                                                                                                  
                                                                                                                                                                                         
- types.ts - New optional source fields on Annotation                                                                                                                                    
- source-location.ts - Detection utilities with React 16-19 support                                                                                                                      
- index.tsx - New sourceAttribute prop (default: "data-tsd-source")                                                                                                                      
- README.md - Document new prop and fields                                                                                                                                               
- CLAUDE.md - API changelog for 1.4.0                                                                                                                                                    
                                                                                                                                                                                         
Use case                                                                                                                                                                                 
                                                                                                                                                                                         
When annotating elements in dev mode, annotations now include the source file path (e.g., src/components/Button.tsx:42), helping AI agents locate the exact code being referenced.       

- Added `sourceAttribute` prop for configurable source detection.
- Introduced `sourceFile` and `sourceComponent` fields in the Annotation type to capture source location details.
- Updated documentation to reflect new features and usage examples.
- Improved output formatting to include source information in generated annotations.
@vercel
Copy link

vercel bot commented Jan 27, 2026

@fab-uleuh is attempting to deploy a commit to the Benji Taylor's Projects Team on Vercel.

A member of the Team first needs to authorize it.

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