-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add line-specific comments functionality #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
26d2c40
to
3e180b0
Compare
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Très cool si ça fonctionne ça !
J'ai fait pas mal de commentaires mais dans l'ensemble je suis aligné. Merci !
- A comprehensive overall summary of the PR in the "summary" field | ||
- Multiple specific comments targeting different issues with accurate file paths and line numbers | ||
- Detailed explanations in each comment's body | ||
- Code suggestions where appropriate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il faut peut-être lui fournir un exemple de "code suggestion" parce que c'est dépendant de la plateforme où est faite la PR. Pas sûr que gitlab et github utilisent le même format en gros.
Là comme on lui dit pas que c'est du github en plus, il va pas forcément savoir quoi faire.
content: prompt | ||
} | ||
], | ||
tools: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je me dis que ça pourrait être bien d'avoir un tool utils capable de construire un objet JSON "anthropicToolDefinition" (ou openAI, Mistral, LLaMa plus tard) automatiquement. Sinon on va devoir réécrire et maintenir cet objet dans chaque sender qui communique avec anthropic et dès qu'un tool va changer un peu ça risque de devenir embêtant à maintenir et source d'erreurs.
On peut commencer simple avec une fonction qui renvoie simplement :
{
name: 'provide_code_review',
description:
'Provide structured code review with line-specific comments',
[Reste de l'objet...]
}
interface CodeReviewResponse { | ||
summary: string | ||
comments: Array<{ | ||
path: string | ||
line: number | ||
body: string | ||
suggestion?: string | ||
}> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je pense que j'aurais plutôt mis ça dans le même fichier que le tool "provide_code_review" vu que c'est lié à ça plutôt qu'au lineCommentsSender
, non ?
* @param prompt - The prompt to send to Anthropic | ||
* @returns The text response from Anthropic | ||
*/ | ||
export async function defaultSender(prompt: string): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai fait un commentaire plus bas qui permettrait d'éliminer ce defaultSender
et de le remplacer par un "anthropicSender" avec les "tools" en paramètre optionnel.
// Schémas de validation pour garantir le bon format de la réponse | ||
const CommentSchema = z.object({ | ||
path: z.string(), | ||
line: z.number().int().positive(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je flag ça juste une fois maintenant : Là on bosse sur une seule ligne mais est-ce qu'on voudra mettre le temps nécessaire à la gestion d'un interval de lignes plutôt qu'une seule ?
Si oui, ça peut valoir le coup de prévoir des maintenant une "startLine" et une "endLine" peut-être ?
Pull Request AnalysisOverviewThis PR implements a new "line-comments" strategy for the Revu code review tool. The main goal is to enhance the review experience by allowing the AI to provide specific comments on individual lines of code rather than just a single global comment on the entire PR. The implementation includes:
The changes effectively solve the intended problem by creating a complete pipeline from prompt generation to structured response handling, with appropriate fallbacks when things go wrong. Code Quality ReviewStrengths
Areas for Improvement
try {
// ...parsing logic...
} catch {
// Silent catch - continue to next content block or error
} Consider logging the error or adding more specific error handling.
// Schémas de validation pour garantir le bon format de la réponse These should be translated to English for consistency.
Security Assessment
return `${path}:${line}`.replace(/[^a-zA-Z0-9-_:.]/g, '_'); This prevents potential injection issues in comment markers.
console.log('Input:', content.input)
console.log('Tool name:', content.name) Consider limiting the information exposed in logs. Best Practices Evaluation
Recommendations
// config/ai-models.ts
export const CLAUDE_MODEL = 'claude-3-7-sonnet-latest';
try {
// ...parsing logic...
} catch (error) {
console.error('Failed to parse JSON response:', error);
// Continue to next content block or error
}
// utils/anthropic-client.ts
export function createAnthropicClient() {
return new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY
});
}
Additional Notes
|
…support des tools
…l'utilisation du tool
226617b
to
caaf365
Compare
|
🎉 This PR is included in version 1.5.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
No description provided.