-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Use Case
Users frequently need to reference specific files when asking questions or requesting changes. Currently, users must either ask the AI to read files first or provide file paths manually. A more intuitive approach would be to reference files directly in messages using @filename
syntax, similar to modern IDEs and chat applications.
Proposed Solution
Add support for @
syntax to automatically include file contents as context when sending messages:
- Basic syntax:
@filename.ts
- includes entire file content - Line range syntax:
@filename.ts:10-20
- includes specific line range - Relative paths:
@src/components/Button.tsx
- support paths relative to working directory - Multiple files:
How do I connect @database.ts with @api/routes.ts?
- reference multiple files in one message - Auto-completion: Tab completion for file paths when typing
@
- Visual indication: Show included files in the message preview before sending
Example usage:
Fix the TypeScript errors in @src/utils/validation.ts and update @types/user.ts accordingly
This would automatically include the contents of both files as context, equivalent to:
[Contents of src/utils/validation.ts]
[Contents of types/user.ts]
Fix the TypeScript errors in src/utils/validation.ts and update types/user.ts accordingly
Alternatives Considered
- Manual file reading requests (current approach, requires extra steps)
- Drag-and-drop file inclusion (not suitable for CLI interface)
- Command-line arguments for file inclusion (less intuitive for conversational flow)
- IDE integration that automatically includes open files (limited to specific editors)
Additional Context
This feature would integrate naturally with the existing tool system and message handling in Nanocoder. Many modern AI coding tools and IDEs use similar @
syntax for file references, making this familiar to users.
The implementation could leverage:
- Existing file reading capabilities in
src/core/tools/
- Message preprocessing before sending to AI providers
- The command parser system for handling special syntax
- File system utilities already in the codebase
Implementation Notes
- Should integrate with the message preprocessing pipeline
- Could reuse existing file reading tools for content inclusion
- Should handle file not found errors gracefully
- Consider file size limits to avoid context overflow
- Should preserve original message intent while adding file context
- Could cache file contents for performance with large files
- Should support glob patterns (e.g.,
@src/**/*.ts
for multiple files) - Consider security implications of automatic file inclusion
Technical Considerations
- Performance: Large files could impact context window usage
- Security: Validate file paths to prevent directory traversal
- Error handling: Clear messages when files don't exist or can't be read
- Context management: Smart truncation for files that exceed token limits
- Caching: Avoid re-reading unchanged files in the same session
This feature would significantly improve the user experience by reducing friction when working with multiple files and make conversations more natural and efficient.