@imenam/mcp-feature-analyzer 1.0.29 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -4
- package/dist/shared/file-levels.d.ts +11 -0
- package/dist/shared/file-levels.js +46 -0
- package/dist/shared/labels.d.ts +8 -1
- package/dist/shared/labels.js +8 -0
- package/dist/shared/schemas/analysis.schema.d.ts +81 -0
- package/dist/shared/schemas/analysis.schema.js +29 -0
- package/dist/shared/schemas/api.schema.d.ts +39 -1
- package/dist/shared/schemas/api.schema.js +19 -2
- package/dist/shared/schemas/ipc.schema.d.ts +1 -1
- package/dist/shared/schemas/ipc.schema.js +2 -0
- package/dist/src/core/analysis-store.d.ts +4 -0
- package/dist/src/core/analysis-store.js +10 -6
- package/dist/src/core/git.d.ts +1 -1
- package/dist/src/core/git.js +2 -1
- package/dist/src/core/invariants.d.ts +2 -1
- package/dist/src/core/invariants.js +16 -2
- package/dist/src/core/migrate.d.ts +4 -0
- package/dist/src/core/migrate.js +22 -0
- package/dist/src/core/notifications.d.ts +67 -0
- package/dist/src/core/notifications.js +273 -0
- package/dist/src/core/refresh.d.ts +3 -0
- package/dist/src/core/refresh.js +8 -4
- package/dist/src/core/review-actions.d.ts +17 -3
- package/dist/src/core/review-actions.js +65 -4
- package/dist/src/gui-worker.js +86 -2
- package/dist/src/index.js +147 -10
- package/dist/src/tools/classify-files.d.ts +9 -0
- package/dist/src/tools/classify-files.js +71 -0
- package/dist/src/tools/create-analysis.js +1 -1
- package/dist/src/tools/format.d.ts +5 -0
- package/dist/src/tools/format.js +11 -0
- package/dist/src/tools/get-analysis.js +13 -3
- package/dist/src/tools/get-review-feedback.js +14 -1
- package/dist/src/tools/notifications.d.ts +27 -0
- package/dist/src/tools/notifications.js +137 -0
- package/dist/src/tools/refresh-analysis.js +2 -1
- package/gui/dist/assets/{angular-html-5NhKn_t-.js → angular-html-CCsi6pU-.js} +1 -1
- package/gui/dist/assets/{angular-ts-DhsMT4Rz.js → angular-ts-D3b0p2ec.js} +1 -1
- package/gui/dist/assets/{apl-BQY6aoi5.js → apl-B_lcYoHG.js} +1 -1
- package/gui/dist/assets/{astro-D2uooUSE.js → astro-C8m0ax-G.js} +1 -1
- package/gui/dist/assets/{blade-CCqBQx9x.js → blade-BTaoP0KJ.js} +1 -1
- package/gui/dist/assets/{c-Dr5lpVW7.js → c-SDXfbR0a.js} +1 -1
- package/gui/dist/assets/{chapel-BHsANtTA.js → chapel-CvA97ZeU.js} +1 -1
- package/gui/dist/assets/{cobol-CqwhBifS.js → cobol-CVtUeO01.js} +1 -1
- package/gui/dist/assets/{coffee-Wiu8SLC2.js → coffee-hRo5RQ8B.js} +1 -1
- package/gui/dist/assets/{cpp-CJ_ODeXR.js → cpp-BxoU2Hxs.js} +1 -1
- package/gui/dist/assets/{crystal-B_FnmDRX.js → crystal-CcX36hHQ.js} +1 -1
- package/gui/dist/assets/{css-BX2hCl8Q.js → css-CxWhmvIC.js} +1 -1
- package/gui/dist/assets/{edge-l0IQj2gt.js → edge-QJOy4xlO.js} +1 -1
- package/gui/dist/assets/{elixir-BnXfG85X.js → elixir-C9LrWwAh.js} +1 -1
- package/gui/dist/assets/{elm-DkiIxCka.js → elm-BR3U0yD_.js} +1 -1
- package/gui/dist/assets/{erb-Cd7Dui37.js → erb-CiOJpaDo.js} +1 -1
- package/gui/dist/assets/{git-rebase-DKKMrbhR.js → git-rebase-BYl4P3ox.js} +1 -1
- package/gui/dist/assets/{glimmer-js-ClmFS94t.js → glimmer-js-Blh2OVv1.js} +1 -1
- package/gui/dist/assets/{glimmer-ts-BcBFTQWM.js → glimmer-ts-DXr9mcSj.js} +1 -1
- package/gui/dist/assets/{glsl-C3thj0jg.js → glsl-CnZQZULb.js} +1 -1
- package/gui/dist/assets/{graphql-B6mMAjvE.js → graphql-8Rdi2_E3.js} +1 -1
- package/gui/dist/assets/{hack-0LBOyGxt.js → hack-CKSTrDJQ.js} +1 -1
- package/gui/dist/assets/{haml-uOaDaMcM.js → haml-BXUwL6Gi.js} +1 -1
- package/gui/dist/assets/{handlebars-CYsq3lyR.js → handlebars-CoB9_4Wu.js} +1 -1
- package/gui/dist/assets/{html-LQMPiuEI.js → html-B6C5qCrz.js} +1 -1
- package/gui/dist/assets/{html-derivative-CzLV5NtN.js → html-derivative-Bk9jovvn.js} +1 -1
- package/gui/dist/assets/{http-BUUATjp1.js → http-BjGXUZ-r.js} +1 -1
- package/gui/dist/assets/{hurl-DfUfCgyH.js → hurl-DTlVMspc.js} +1 -1
- package/gui/dist/assets/index-Cr9HJaGX.css +1 -0
- package/gui/dist/assets/index-dM30WmvE.js +87 -0
- package/gui/dist/assets/{java-DFQBBMEz.js → java-Bh1jVWfi.js} +1 -1
- package/gui/dist/assets/{javascript-tFDB_Ucv.js → javascript-CAp5Mnzl.js} +1 -1
- package/gui/dist/assets/{jinja-B7dQLu57.js → jinja-rB-QNUyu.js} +1 -1
- package/gui/dist/assets/{jison-10iK85Cg.js → jison-VA6AlkMv.js} +1 -1
- package/gui/dist/assets/{json-CNNin8Qj.js → json-D_3nkZlx.js} +1 -1
- package/gui/dist/assets/{jsx-BmoTM54L.js → jsx-vCtnSopd.js} +1 -1
- package/gui/dist/assets/{julia-CfU24q-y.js → julia-DzWcxIlS.js} +1 -1
- package/gui/dist/assets/{just-BaBindpQ.js → just-Cib470fM.js} +1 -1
- package/gui/dist/assets/{latex-BI4Nwj84.js → latex-B9Rt9Nm7.js} +1 -1
- package/gui/dist/assets/{liquid-DdRKxxNE.js → liquid-CpUpBdB-.js} +1 -1
- package/gui/dist/assets/{lua-BRLUOT5F.js → lua-ABZXQo7L.js} +1 -1
- package/gui/dist/assets/{marko-DNv4_LKP.js → marko-BqS1ITvl.js} +1 -1
- package/gui/dist/assets/{mdc-D8izFv08.js → mdc-BU5NTqUw.js} +1 -1
- package/gui/dist/assets/{nginx-DUUt3koj.js → nginx-CPJvj-oD.js} +1 -1
- package/gui/dist/assets/{nim-CysKZwP3.js → nim-DP5c8JP-.js} +1 -1
- package/gui/dist/assets/{org-DRbqnSGz.js → org-z8oygnoy.js} +1 -1
- package/gui/dist/assets/{perl-BFeXyBX8.js → perl-BOKTfCaa.js} +1 -1
- package/gui/dist/assets/{php-CUoskUzm.js → php-Bxp7SLwc.js} +1 -1
- package/gui/dist/assets/{pug-C6Wb4WSu.js → pug-YbOie-Gt.js} +1 -1
- package/gui/dist/assets/{qml-BLxZs3E-.js → qml-BoW83Fyx.js} +1 -1
- package/gui/dist/assets/{r-BVy3lwjs.js → r-BOTGEI5j.js} +1 -1
- package/gui/dist/assets/{razor-BP53EMWu.js → razor-Ci4nB3jF.js} +1 -1
- package/gui/dist/assets/{regexp-C4DXj1is.js → regexp-BumEaKrn.js} +1 -1
- package/gui/dist/assets/{rst-OdGdDU13.js → rst-DtqBiJDu.js} +1 -1
- package/gui/dist/assets/{ruby-BMnClzBa.js → ruby-D1kPpSHI.js} +1 -1
- package/gui/dist/assets/{sas-Cfl9isPl.js → sas-14YEmckC.js} +1 -1
- package/gui/dist/assets/{scss-Dhg-JzbO.js → scss-DFjEDCH3.js} +1 -1
- package/gui/dist/assets/{shellscript-DTieiA63.js → shellscript-DPod_v0w.js} +1 -1
- package/gui/dist/assets/{shellsession-BWx2rqf_.js → shellsession-tu7P7CZw.js} +1 -1
- package/gui/dist/assets/{soy-DEOBlMFT.js → soy-CGE1c2SC.js} +1 -1
- package/gui/dist/assets/{sql-CcIgwCBd.js → sql-CaS7isii.js} +1 -1
- package/gui/dist/assets/{stata-Bx19F1yU.js → stata-Q1HKOyRT.js} +1 -1
- package/gui/dist/assets/{surrealql-Cql6Lb-6.js → surrealql-BtSPewz7.js} +1 -1
- package/gui/dist/assets/{svelte-lFXZ4EZb.js → svelte-U6EZswjv.js} +1 -1
- package/gui/dist/assets/{templ-D_Pn1_WV.js → templ-Dv6Hh6ZK.js} +1 -1
- package/gui/dist/assets/{tex-DFT7E4ng.js → tex-FNxy8pwc.js} +1 -1
- package/gui/dist/assets/{ts-tags-BfzRLZHd.js → ts-tags-QwSPCwFk.js} +1 -1
- package/gui/dist/assets/{tsx-BOIZx2wx.js → tsx-DD4r3epl.js} +1 -1
- package/gui/dist/assets/{twig-D0n8mooJ.js → twig-CF2Q5rKi.js} +1 -1
- package/gui/dist/assets/{typescript-Cn81Mlip.js → typescript-BH94Wa6R.js} +1 -1
- package/gui/dist/assets/{typst-DMsZD3Vh.js → typst-FVLFkJ8V.js} +1 -1
- package/gui/dist/assets/{vue-C78oMXhn.js → vue-CgIy39RZ.js} +1 -1
- package/gui/dist/assets/{vue-html-Cn2mX7R9.js → vue-html-BK18RzGS.js} +1 -1
- package/gui/dist/assets/{vue-vine-Ceuq9sdM.js → vue-vine-Ca-3XU_O.js} +1 -1
- package/gui/dist/assets/{xml-BP7iQh4O.js → xml-CrlmnYy6.js} +1 -1
- package/gui/dist/assets/{xsl-Bc9-jqg1.js → xsl-CTdshCNA.js} +1 -1
- package/gui/dist/assets/{yaml-yTwqxcXx.js → yaml-DVKeB6J_.js} +1 -1
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/gui/dist/assets/index-BKUr4xoh.js +0 -87
- package/gui/dist/assets/index-DSRZjXsH.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Analysis, Editor } from "../../shared/schemas/analysis.schema.js";
|
|
2
|
-
import type { AddNoteBody, DeleteNoteBody, MarkProcessedBody, SetFileReviewedBody, SetFindingStatusBody, SubmitReviewBody, UpdateNoteBody } from "../../shared/schemas/api.schema.js";
|
|
2
|
+
import type { AddNoteBody, DeleteNoteBody, MarkAnswerSeenBody, MarkProcessedBody, SetFileLevelBody, SetFileReviewedBody, SetFindingStatusBody, SubmitReviewBody, UpdateNoteBody } from "../../shared/schemas/api.schema.js";
|
|
3
3
|
import type { AnalysisStore, MutateOptions } from "./analysis-store.js";
|
|
4
4
|
/**
|
|
5
5
|
* Modifications faites par le relecteur depuis la GUI. Chacune passe par
|
|
@@ -10,6 +10,11 @@ import type { AnalysisStore, MutateOptions } from "./analysis-store.js";
|
|
|
10
10
|
*/
|
|
11
11
|
/** Marque un fichier de l'analyse comme revu, ou le repasse à revoir. */
|
|
12
12
|
export declare function setFileReviewed(store: AnalysisStore, analysisId: string, body: SetFileReviewedBody): Analysis;
|
|
13
|
+
/**
|
|
14
|
+
* Change le niveau d'un fichier classé par l'agent. Choisir le niveau de
|
|
15
|
+
* l'agent efface le choix du relecteur.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setFileLevel(store: AnalysisStore, analysisId: string, body: SetFileLevelBody): Analysis;
|
|
13
18
|
/**
|
|
14
19
|
* Ignore ou rouvre un constat. `outdated` est posé uniquement par le recalcul
|
|
15
20
|
* du snapshot, et un constat obsolète ne change de statut que lorsque l'agent
|
|
@@ -18,10 +23,19 @@ export declare function setFileReviewed(store: AnalysisStore, analysisId: string
|
|
|
18
23
|
export declare function setFindingStatus(store: AnalysisStore, analysisId: string, findingId: string, body: SetFindingStatusBody): Analysis;
|
|
19
24
|
/**
|
|
20
25
|
* Ajoute une remarque du relecteur sur une ligne du côté « nouveau » ou sur un fichier entier,
|
|
21
|
-
* liée au constat `findingId` quand elle y répond.
|
|
26
|
+
* liée au constat `findingId` quand elle y répond. Avec `askAgent`, la remarque est une
|
|
27
|
+
* question envoyée tout de suite à l'agent : elle ne fait pas partie du retour de fin de
|
|
28
|
+
* revue et ne repasse donc pas une revue soumise en attente.
|
|
22
29
|
*/
|
|
23
30
|
export declare function addNote(store: AnalysisStore, analysisId: string, body: AddNoteBody): Analysis;
|
|
24
|
-
/**
|
|
31
|
+
/** Enregistre que le relecteur a lu la réponse de l'agent à une question. */
|
|
32
|
+
export declare function markAnswerSeen(store: AnalysisStore, analysisId: string, noteId: string, body: MarkAnswerSeenBody): Analysis;
|
|
33
|
+
/**
|
|
34
|
+
* Enregistre la réponse de l'agent à une question du relecteur. Refusé pour une
|
|
35
|
+
* remarque qui n'est pas une question ou une question déjà répondue.
|
|
36
|
+
*/
|
|
37
|
+
export declare function answerQuestion(store: AnalysisStore, analysisId: string, noteId: string, answer: string): Analysis;
|
|
38
|
+
/** Remplace le texte d'une remarque ; une question déjà envoyée à l'agent ne change plus. */
|
|
25
39
|
export declare function updateNote(store: AnalysisStore, analysisId: string, noteId: string, body: UpdateNoteBody): Analysis;
|
|
26
40
|
/** Supprime une remarque et la retire de la sélection de la revue. */
|
|
27
41
|
export declare function deleteNote(store: AnalysisStore, analysisId: string, noteId: string, body: DeleteNoteBody): Analysis;
|
|
@@ -19,6 +19,21 @@ export function setFileReviewed(store, analysisId, body) {
|
|
|
19
19
|
file.reviewed = body.reviewed;
|
|
20
20
|
}, { baseRevision: body.baseRevision });
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Change le niveau d'un fichier classé par l'agent. Choisir le niveau de
|
|
24
|
+
* l'agent efface le choix du relecteur.
|
|
25
|
+
*/
|
|
26
|
+
export function setFileLevel(store, analysisId, body) {
|
|
27
|
+
return store.mutate(analysisId, "user", (draft) => {
|
|
28
|
+
const file = draft.files.find((entry) => entry.path === body.path);
|
|
29
|
+
if (!file)
|
|
30
|
+
throw new NotFoundError(`File "${body.path}" is not part of analysis "${analysisId}".`);
|
|
31
|
+
if (file.classification === null) {
|
|
32
|
+
throw new AnalysisError(`File "${body.path}" is not classified yet: the agent classifies it first, with its reason.`);
|
|
33
|
+
}
|
|
34
|
+
file.classification.reviewerLevel = body.level === file.classification.level ? null : body.level;
|
|
35
|
+
}, { baseRevision: body.baseRevision });
|
|
36
|
+
}
|
|
22
37
|
/**
|
|
23
38
|
* Ignore ou rouvre un constat. `outdated` est posé uniquement par le recalcul
|
|
24
39
|
* du snapshot, et un constat obsolète ne change de statut que lorsque l'agent
|
|
@@ -43,7 +58,9 @@ export function setFindingStatus(store, analysisId, findingId, body) {
|
|
|
43
58
|
}
|
|
44
59
|
/**
|
|
45
60
|
* Ajoute une remarque du relecteur sur une ligne du côté « nouveau » ou sur un fichier entier,
|
|
46
|
-
* liée au constat `findingId` quand elle y répond.
|
|
61
|
+
* liée au constat `findingId` quand elle y répond. Avec `askAgent`, la remarque est une
|
|
62
|
+
* question envoyée tout de suite à l'agent : elle ne fait pas partie du retour de fin de
|
|
63
|
+
* revue et ne repasse donc pas une revue soumise en attente.
|
|
47
64
|
*/
|
|
48
65
|
export function addNote(store, analysisId, body) {
|
|
49
66
|
return store.mutate(analysisId, "user", (draft) => {
|
|
@@ -53,22 +70,62 @@ export function addNote(store, analysisId, body) {
|
|
|
53
70
|
if (findingId !== null && !draft.findings.some((finding) => finding.id === findingId)) {
|
|
54
71
|
throw new NotFoundError(`Finding "${findingId}" not found in analysis "${analysisId}".`);
|
|
55
72
|
}
|
|
56
|
-
|
|
73
|
+
const now = new Date().toISOString();
|
|
74
|
+
const question = body.askAgent ? { askedAt: now, answer: null, answerSeenAt: null } : null;
|
|
75
|
+
if (question === null)
|
|
76
|
+
reopenSubmittedReview(draft);
|
|
57
77
|
draft.notes.push({
|
|
58
78
|
id: itemId("note", new Set(draft.notes.map((note) => note.id))),
|
|
59
79
|
location,
|
|
60
80
|
findingId,
|
|
61
81
|
text: body.text,
|
|
62
|
-
createdAt:
|
|
82
|
+
createdAt: now,
|
|
83
|
+
question,
|
|
63
84
|
});
|
|
64
85
|
}, { baseRevision: body.baseRevision });
|
|
65
86
|
}
|
|
66
|
-
/**
|
|
87
|
+
/** Enregistre que le relecteur a lu la réponse de l'agent à une question. */
|
|
88
|
+
export function markAnswerSeen(store, analysisId, noteId, body) {
|
|
89
|
+
return store.mutate(analysisId, "user", (draft) => {
|
|
90
|
+
const note = draft.notes.find((entry) => entry.id === noteId);
|
|
91
|
+
if (!note)
|
|
92
|
+
throw new NotFoundError(`Note "${noteId}" not found in analysis "${analysisId}".`);
|
|
93
|
+
if (note.question === null)
|
|
94
|
+
throw new AnalysisError(`Note "${noteId}" is not a question sent to the agent.`);
|
|
95
|
+
if (note.question.answer === null)
|
|
96
|
+
throw new AnalysisError(`The agent has not answered question "${noteId}" yet.`);
|
|
97
|
+
if (note.question.answerSeenAt !== null)
|
|
98
|
+
return;
|
|
99
|
+
note.question.answerSeenAt = new Date().toISOString();
|
|
100
|
+
}, { baseRevision: body.baseRevision });
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Enregistre la réponse de l'agent à une question du relecteur. Refusé pour une
|
|
104
|
+
* remarque qui n'est pas une question ou une question déjà répondue.
|
|
105
|
+
*/
|
|
106
|
+
export function answerQuestion(store, analysisId, noteId, answer) {
|
|
107
|
+
return store.mutate(analysisId, "agent", (draft) => {
|
|
108
|
+
const note = draft.notes.find((entry) => entry.id === noteId);
|
|
109
|
+
if (!note) {
|
|
110
|
+
throw new NotFoundError(`Question "${noteId}" not found in analysis "${analysisId}". get_analysis lists the reviewer notes and questions.`);
|
|
111
|
+
}
|
|
112
|
+
if (note.question === null) {
|
|
113
|
+
throw new AnalysisError(`Note "${noteId}" is not a question: the reviewer keeps it for the end of the review, and get_review_feedback hands it to you once the review is submitted.`);
|
|
114
|
+
}
|
|
115
|
+
if (note.question.answer !== null) {
|
|
116
|
+
throw new AnalysisError(`Question "${noteId}" was already answered at ${note.question.answer.at}.`);
|
|
117
|
+
}
|
|
118
|
+
note.question.answer = { text: answer, at: new Date().toISOString() };
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/** Remplace le texte d'une remarque ; une question déjà envoyée à l'agent ne change plus. */
|
|
67
122
|
export function updateNote(store, analysisId, noteId, body) {
|
|
68
123
|
return store.mutate(analysisId, "user", (draft) => {
|
|
69
124
|
const note = draft.notes.find((entry) => entry.id === noteId);
|
|
70
125
|
if (!note)
|
|
71
126
|
throw new NotFoundError(`Note "${noteId}" not found in analysis "${analysisId}".`);
|
|
127
|
+
if (note.question !== null)
|
|
128
|
+
throw new AnalysisError(`Note "${noteId}" was sent to the agent as a question: its text cannot change.`);
|
|
72
129
|
if (note.text === body.text)
|
|
73
130
|
return;
|
|
74
131
|
reopenSubmittedReview(draft);
|
|
@@ -130,6 +187,10 @@ export function submitReview(store, analysisId, body) {
|
|
|
130
187
|
return store.mutate(analysisId, "user", (draft) => {
|
|
131
188
|
assertKnownIds("finding", body.findingIds, draft.findings.map((finding) => finding.id));
|
|
132
189
|
assertKnownIds("note", body.noteIds, draft.notes.map((note) => note.id));
|
|
190
|
+
const questions = body.noteIds.filter((id) => draft.notes.find((note) => note.id === id)?.question !== null);
|
|
191
|
+
if (questions.length > 0) {
|
|
192
|
+
throw new AnalysisError(`Questions already sent to the agent cannot be selected in the review: ${questions.join(", ")}.`);
|
|
193
|
+
}
|
|
133
194
|
const previousSubmission = draft.review.state === "submitted" ? recordSubmission(draft) : draft.review.previousSubmission;
|
|
134
195
|
draft.review = {
|
|
135
196
|
state: "submitted",
|
package/dist/src/gui-worker.js
CHANGED
|
@@ -7,9 +7,10 @@ import fs from "fs";
|
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
8
|
import { randomUUID } from "crypto";
|
|
9
9
|
import { IPCMessageSchema, PUSHED_EVENT_TYPES } from "../shared/schemas/ipc.schema.js";
|
|
10
|
-
import { AddNoteBodySchema, DeleteNoteBodySchema, MarkProcessedBodySchema, SetFileReviewedBodySchema, SetFindingStatusBodySchema, SubmitReviewBodySchema, UpdateNoteBodySchema, } from "../shared/schemas/api.schema.js";
|
|
10
|
+
import { AddNoteBodySchema, DeleteNoteBodySchema, MarkAnswerSeenBodySchema, MarkProcessedBodySchema, SetFileLevelBodySchema, SetFileReviewedBodySchema, SetFindingStatusBodySchema, SubmitReviewBodySchema, UpdateNoteBodySchema, } from "../shared/schemas/api.schema.js";
|
|
11
11
|
import { resolveDataDir } from "./core/data-dir.js";
|
|
12
12
|
import { resolveLogDir } from "./core/log-dir.js";
|
|
13
|
+
import { watchedAnalyses } from "./core/notifications.js";
|
|
13
14
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
15
|
function findProjectRoot(startDir) {
|
|
15
16
|
let current = startDir;
|
|
@@ -45,7 +46,8 @@ function resolveGuiMode() {
|
|
|
45
46
|
}
|
|
46
47
|
const guiMode = resolveGuiMode();
|
|
47
48
|
const isStandalone = guiMode.kind === "standalone";
|
|
48
|
-
|
|
49
|
+
const dataDir = resolveDataDir();
|
|
50
|
+
setupLogging({ processLabel: "mcp-feature-analyzer:GUI", logDir: resolveLogDir(dataDir) });
|
|
49
51
|
const logger = createLogger("mcp-feature-analyzer:GUI");
|
|
50
52
|
process.on("uncaughtException", (err) => {
|
|
51
53
|
logger.error(`Uncaught Exception: ${err.message}`);
|
|
@@ -148,7 +150,73 @@ function changesSince(since, clientEpoch) {
|
|
|
148
150
|
events: changesJournal.filter((entry) => entry.seq > since).map((entry) => entry.event),
|
|
149
151
|
};
|
|
150
152
|
}
|
|
153
|
+
/** Intervalle de la recherche des analyses écrites par un autre processus. */
|
|
154
|
+
const EXTERNAL_SCAN_MS = 2000;
|
|
155
|
+
/** Signature (date et taille) de chaque fichier d'analyse, à la recherche précédente. */
|
|
156
|
+
let analysisStamps = null;
|
|
157
|
+
function readAnalysisStamps() {
|
|
158
|
+
const stamps = new Map();
|
|
159
|
+
const dir = path.join(dataDir, "analyses");
|
|
160
|
+
for (const file of fs.readdirSync(dir)) {
|
|
161
|
+
if (!file.endsWith(".json"))
|
|
162
|
+
continue;
|
|
163
|
+
try {
|
|
164
|
+
const stat = fs.statSync(path.join(dir, file));
|
|
165
|
+
stamps.set(file.slice(0, -".json".length), `${stat.mtimeMs}:${stat.size}`);
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
// Fichier supprimé entre la lecture du dossier et sa date : il compte comme absent.
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return stamps;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Journalise un évènement pour chaque analyse créée, modifiée ou supprimée sur
|
|
175
|
+
* disque depuis la recherche précédente, quel que soit le processus qui l'a écrite :
|
|
176
|
+
* une autre session de l'agent sert les mêmes analyses sans passer par ce worker.
|
|
177
|
+
*/
|
|
178
|
+
function scanExternalChanges() {
|
|
179
|
+
let stamps;
|
|
180
|
+
try {
|
|
181
|
+
stamps = readAnalysisStamps();
|
|
182
|
+
}
|
|
183
|
+
catch (err) {
|
|
184
|
+
logger.error(`Scanning the analyses folder failed: ${err.message}`);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const previous = analysisStamps;
|
|
188
|
+
analysisStamps = stamps;
|
|
189
|
+
if (previous === null)
|
|
190
|
+
return;
|
|
191
|
+
const changed = [...new Set([...stamps.keys(), ...previous.keys()])].filter((id) => stamps.get(id) !== previous.get(id));
|
|
192
|
+
if (changed.length === 0)
|
|
193
|
+
return;
|
|
194
|
+
const timestamp = new Date().toISOString();
|
|
195
|
+
for (const analysisId of changed)
|
|
196
|
+
recordChange({ type: "ANALYSIS_UPDATED", data: { analysisId }, timestamp });
|
|
197
|
+
recordChange({ type: "ANALYSES_UPDATED", data: {}, timestamp });
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Prend l'état du disque de l'analyse annoncée par le master comme référence : ce
|
|
201
|
+
* changement n'est pas annoncé une seconde fois par la recherche suivante.
|
|
202
|
+
*/
|
|
203
|
+
function acknowledgeOnDisk(analysisId) {
|
|
204
|
+
if (analysisStamps === null)
|
|
205
|
+
return;
|
|
206
|
+
try {
|
|
207
|
+
const stat = fs.statSync(path.join(dataDir, "analyses", `${analysisId}.json`));
|
|
208
|
+
analysisStamps.set(analysisId, `${stat.mtimeMs}:${stat.size}`);
|
|
209
|
+
}
|
|
210
|
+
catch (err) {
|
|
211
|
+
if (err.code === "ENOENT")
|
|
212
|
+
analysisStamps.delete(analysisId);
|
|
213
|
+
else
|
|
214
|
+
logger.error(`Reading the analysis file of ${analysisId} failed: ${err.message}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
151
217
|
function setupIpcHandlers() {
|
|
218
|
+
scanExternalChanges();
|
|
219
|
+
setInterval(scanExternalChanges, EXTERNAL_SCAN_MS);
|
|
152
220
|
process.on("error", (err) => {
|
|
153
221
|
if (err.code === "ERR_IPC_CHANNEL_CLOSED")
|
|
154
222
|
return;
|
|
@@ -173,6 +241,8 @@ function setupIpcHandlers() {
|
|
|
173
241
|
}
|
|
174
242
|
if (PUSHED_EVENTS.has(msg.type)) {
|
|
175
243
|
recordChange(msg);
|
|
244
|
+
if (msg.type === "ANALYSIS_UPDATED" && typeof msg.data?.analysisId === "string")
|
|
245
|
+
acknowledgeOnDisk(msg.data.analysisId);
|
|
176
246
|
return;
|
|
177
247
|
}
|
|
178
248
|
logger.debug(`Unhandled IPC message type: ${msg.type}`);
|
|
@@ -247,6 +317,12 @@ app.post("/api/analyses/:id/files/reviewed", async (c) => {
|
|
|
247
317
|
return read.response;
|
|
248
318
|
return forward(c, "SET_FILE_REVIEWED", { analysisId: c.req.param("id"), body: read.body });
|
|
249
319
|
});
|
|
320
|
+
app.post("/api/analyses/:id/files/level", async (c) => {
|
|
321
|
+
const read = await readBody(c, SetFileLevelBodySchema);
|
|
322
|
+
if ("response" in read)
|
|
323
|
+
return read.response;
|
|
324
|
+
return forward(c, "SET_FILE_LEVEL", { analysisId: c.req.param("id"), body: read.body });
|
|
325
|
+
});
|
|
250
326
|
app.post("/api/analyses/:id/findings/:findingId/status", async (c) => {
|
|
251
327
|
const read = await readBody(c, SetFindingStatusBodySchema);
|
|
252
328
|
if ("response" in read)
|
|
@@ -271,6 +347,14 @@ app.delete("/api/analyses/:id/notes/:noteId", async (c) => {
|
|
|
271
347
|
return read.response;
|
|
272
348
|
return forward(c, "DELETE_NOTE", { analysisId: c.req.param("id"), noteId: c.req.param("noteId"), body: read.body });
|
|
273
349
|
});
|
|
350
|
+
app.post("/api/analyses/:id/notes/:noteId/answer-seen", async (c) => {
|
|
351
|
+
const read = await readBody(c, MarkAnswerSeenBodySchema);
|
|
352
|
+
if ("response" in read)
|
|
353
|
+
return read.response;
|
|
354
|
+
return forward(c, "MARK_ANSWER_SEEN", { analysisId: c.req.param("id"), noteId: c.req.param("noteId"), body: read.body });
|
|
355
|
+
});
|
|
356
|
+
/** Analyses suivies par un veilleur de notifications vivant ; chacune couvre aussi ses revues de suivi. */
|
|
357
|
+
app.get("/api/watchers", (c) => c.json({ analysisIds: watchedAnalyses(dataDir) }));
|
|
274
358
|
app.post("/api/analyses/:id/review", async (c) => {
|
|
275
359
|
const read = await readBody(c, SubmitReviewBodySchema);
|
|
276
360
|
if ("response" in read)
|
package/dist/src/index.js
CHANGED
|
@@ -16,10 +16,10 @@ import { DEFAULT_HEAD_REF, localRepo } from "./core/git.js";
|
|
|
16
16
|
import { agentRepo } from "./core/agent-repo.js";
|
|
17
17
|
import { EXEC_ARG, handleAgentExec } from "./core/gateway-exec.js";
|
|
18
18
|
import { resolveRole } from "./core/role.js";
|
|
19
|
-
import { addNote, deleteNote, markProcessedByReviewer, setFileReviewed, setFindingStatus, submitReview, updateNote, } from "./core/review-actions.js";
|
|
19
|
+
import { addNote, deleteNote, markAnswerSeen, markProcessedByReviewer, setFileLevel, setFileReviewed, setFindingStatus, submitReview, updateNote, } from "./core/review-actions.js";
|
|
20
20
|
import { GUI_REQUEST_TYPES, IPCMessageSchema } from "../shared/schemas/ipc.schema.js";
|
|
21
|
-
import { AddNoteRequestSchema, AnalysisRequestSchema, DeleteNoteRequestSchema, SetFileReviewedRequestSchema, SetFindingStatusRequestSchema, SubmitReviewRequestSchema, MarkProcessedRequestSchema, UpdateNoteRequestSchema, } from "../shared/schemas/api.schema.js";
|
|
22
|
-
import { ANALYSIS_MODES, DIAGRAM_KINDS, EXPLANATION_SIDES, FINDING_KINDS, NODE_SHAPES, NODE_STATUSES, SEVERITIES, } from "../shared/schemas/analysis.schema.js";
|
|
21
|
+
import { AddNoteRequestSchema, AnalysisRequestSchema, DeleteNoteRequestSchema, MarkAnswerSeenRequestSchema, SetFileLevelRequestSchema, SetFileReviewedRequestSchema, SetFindingStatusRequestSchema, SubmitReviewRequestSchema, MarkProcessedRequestSchema, UpdateNoteRequestSchema, } from "../shared/schemas/api.schema.js";
|
|
22
|
+
import { ANALYSIS_MODES, DIAGRAM_KINDS, EXPLANATION_SIDES, FILE_LEVELS, FINDING_KINDS, NODE_SHAPES, NODE_STATUSES, SEVERITIES, } from "../shared/schemas/analysis.schema.js";
|
|
23
23
|
import { errorResult, textResult } from "./tools/types.js";
|
|
24
24
|
import { createAnalysis } from "./tools/create-analysis.js";
|
|
25
25
|
import { DEFAULT_LIST_LIMIT, listAnalyses, REVIEW_STATE_FILTERS } from "./tools/list-analyses.js";
|
|
@@ -28,6 +28,7 @@ import { getDiff } from "./tools/get-diff.js";
|
|
|
28
28
|
import { refreshAnalysis } from "./tools/refresh-analysis.js";
|
|
29
29
|
import { updateAnalysis } from "./tools/update-analysis.js";
|
|
30
30
|
import { addFindings } from "./tools/add-findings.js";
|
|
31
|
+
import { classifyFiles } from "./tools/classify-files.js";
|
|
31
32
|
import { updateFinding } from "./tools/update-finding.js";
|
|
32
33
|
import { deleteFindings } from "./tools/delete-findings.js";
|
|
33
34
|
import { addExplanations } from "./tools/add-explanations.js";
|
|
@@ -39,6 +40,8 @@ import { getReviewFeedback } from "./tools/get-review-feedback.js";
|
|
|
39
40
|
import { markFeedbackProcessed } from "./tools/mark-feedback-processed.js";
|
|
40
41
|
import { analysisLinks } from "./core/follow-ups.js";
|
|
41
42
|
import { deleteAnalysis } from "./tools/delete-analysis.js";
|
|
43
|
+
import { removeOwnHandoffs } from "./core/notifications.js";
|
|
44
|
+
import { DEFAULT_NOTIFICATION_WAIT_SECONDS, MAX_NOTIFICATION_WAIT_SECONDS, WATCH_ARG, answerQuestion, enableNotifications, waitForNotifications, } from "./tools/notifications.js";
|
|
42
45
|
const __filename = fileURLToPath(import.meta.url);
|
|
43
46
|
const __dirname = path.dirname(__filename);
|
|
44
47
|
// Les flags CLI sont traités avant toute initialisation : ils s'exécutent dans le
|
|
@@ -53,6 +56,20 @@ if (process.argv.slice(2).includes("--claude-setup-mcp")) {
|
|
|
53
56
|
}
|
|
54
57
|
process.exit(runSetupMcp({ cwd: process.cwd(), force: argv.includes("--force"), exposure: parsed.exposure }));
|
|
55
58
|
}
|
|
59
|
+
// Veilleur de notifications lancé par l'outil Monitor : il lit son relais, pas l'environnement du MCP.
|
|
60
|
+
const watchIndex = process.argv.indexOf("--watch");
|
|
61
|
+
if (watchIndex !== -1) {
|
|
62
|
+
const key = process.argv[watchIndex + 1];
|
|
63
|
+
const { runWatchMode } = await import("./core/notifications.js");
|
|
64
|
+
try {
|
|
65
|
+
await runWatchMode(key && !key.startsWith("-") ? key : null);
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
process.stderr.write(`[feature-analyzer] ${err.message}\n`);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
56
73
|
function findProjectRoot(startDir) {
|
|
57
74
|
let current = startDir;
|
|
58
75
|
while (current !== path.dirname(current)) {
|
|
@@ -85,6 +102,13 @@ catch (err) {
|
|
|
85
102
|
process.exit(1);
|
|
86
103
|
}
|
|
87
104
|
const store = new AnalysisStore(dataDir);
|
|
105
|
+
const entryScript = fileURLToPath(import.meta.url).replace(/\\/g, "/");
|
|
106
|
+
const notificationContext = {
|
|
107
|
+
store,
|
|
108
|
+
dataDir,
|
|
109
|
+
watchCommand: (analysisId) => `node "${entryScript}" --watch ${analysisId}`,
|
|
110
|
+
};
|
|
111
|
+
process.on("exit", removeOwnHandoffs);
|
|
88
112
|
/** Présentation du serveur transmise au client MCP : concepts, déroulé et règles. */
|
|
89
113
|
const INSTRUCTIONS = `mcp-feature-analyzer helps a human review a feature you developed. You write the analysis through these tools; the user reviews it in a web GUI and records feedback that you read back.
|
|
90
114
|
|
|
@@ -92,22 +116,26 @@ Concepts:
|
|
|
92
116
|
- An **analysis** is one feature under review. It freezes the git diff of a repository (branch mode: base...head; working_tree mode: uncommitted changes, index included, against HEAD) together with your overview, summary, findings and diagrams.
|
|
93
117
|
- A **project** groups the analyses of one product or feature; the GUI files analyses by project.
|
|
94
118
|
- The **overview** is your global analysis of the feature: its objective (what it lets users do), its approach (architecture choices, main flow) and the attention points the reviewer should check first. The **summary** lists the functional changes of the feature, one bullet per change, not one bullet per file.
|
|
119
|
+
- A **file level** tells the reviewer how much attention each changed file deserves: central (it carries a business rule or a computation), check (a caller or a screen that wires such a rule), skim (mechanical code: tests, deletions, imports, routes). Each level comes with a one-sentence reason, so the reviewer can disagree without opening the file; the reviewer may move a file to another level, and get_review_feedback reports it. Migrations, SQL, configuration, CI and container files are never skimmed: classify them central or check. A skimmed file that carries an open finding is still pointed out to the reviewer.
|
|
95
120
|
- A **finding** is a point for the reviewer: an issue anchored on changed lines, or a requirement_gap for requested behaviour that is missing (location optional). Severity: ${SEVERITIES.join(", ")}.
|
|
96
121
|
- An **explanation** describes what a block of added or removed code does and how it works, so that the reviewer understands it before judging it. It is not a finding: it judges nothing and asks for nothing. It is anchored on new-side lines (added code) or old-side lines (removed code), and shown in the diff above the lines it describes.
|
|
97
122
|
- A **diagram** is a flow, layers or mindmap picture of the feature. You give nodes and links only; the GUI lays them out.
|
|
98
123
|
- The **review** belongs to the reviewer: files marked reviewed, findings ignored, notes, and a submitted decision with a prompt for you.
|
|
124
|
+
- A **question** is a note the reviewer sends you right away instead of keeping it for the end of the review. It stays in the review with your answer, but is never part of the submitted feedback: answer it with answer_question as soon as it reaches you.
|
|
125
|
+
- **Notifications**: enable_notifications hands you a watcher to arm with the Monitor tool; it announces the reviewer's questions and the submitted review of one analysis and of its follow-up reviews, and nothing of the other analyses.
|
|
99
126
|
- A **follow-up review** is a new analysis created with follow_up_of: it reviews the fixes for the submitted feedback of an earlier analysis. Each analysis has at most one follow-up, so the rounds form a chain.
|
|
100
127
|
|
|
101
128
|
Workflow:
|
|
102
129
|
1. list_analyses (with project) to find an analysis of the same feature: reuse it with update_analysis and refresh_analysis instead of creating a duplicate. Otherwise create_analysis with its project once the feature is developed.
|
|
103
130
|
2. get_diff to read the frozen diff.
|
|
104
131
|
3. update_analysis with the overview (objective, approach, attention_points) and the summary (the functional changes).
|
|
105
|
-
4.
|
|
106
|
-
5.
|
|
107
|
-
6.
|
|
108
|
-
7.
|
|
109
|
-
8.
|
|
110
|
-
9.
|
|
132
|
+
4. classify_files for every changed file: level and reason.
|
|
133
|
+
5. add_explanations for the long or complex blocks of added or removed code (see Explanation rules).
|
|
134
|
+
6. add_findings for every problem, including requirement_gap findings for requested behaviour that is missing.
|
|
135
|
+
7. set_diagram when a picture helps (impacted layers, process flow, concept tree).
|
|
136
|
+
8. Tell the user to review the analysis in the GUI (the link is in the tool results), and call enable_notifications for that analysis, once per conversation, then arm the Monitor watcher it returns: the reviewer's questions and the submitted review then reach you on their own. Answer each question with answer_question.
|
|
137
|
+
9. get_review_feedback to read the decision, the selected points and the prompt. list_analyses with review_state "to_process" lists the submitted reviews you have not handled yet; an approved review has nothing to process.
|
|
138
|
+
10. Fix the code, then refresh_analysis to recompute the diff for a new review round; re-anchor or rewrite the outdated findings and explanations. When the fixes are in other commits (typically an analysis of one commit), create their follow-up review instead: create_analysis on the fix commits with follow_up_of set to the analysis you fixed; it marks that feedback processed and shows its points to the reviewer. When nothing needs a new review (answers given in the conversation), call mark_feedback_processed with a note saying how the feedback was handled.
|
|
111
139
|
|
|
112
140
|
Explanation rules:
|
|
113
141
|
- Write one for every added or removed block that is long (a function or a block of about 30 lines or more) or complex (non-trivial algorithm, state machine, concurrency, recursion, tricky regular expression or data transformation). A 100-line function always gets one.
|
|
@@ -197,6 +225,12 @@ function handleGuiRequest(msg) {
|
|
|
197
225
|
afterUserMutation(analysis.id);
|
|
198
226
|
return { analysis };
|
|
199
227
|
}
|
|
228
|
+
case "SET_FILE_LEVEL": {
|
|
229
|
+
const request = parseRequest(SetFileLevelRequestSchema, msg.data);
|
|
230
|
+
const analysis = setFileLevel(store, request.analysisId, request.body);
|
|
231
|
+
afterUserMutation(analysis.id);
|
|
232
|
+
return { analysis };
|
|
233
|
+
}
|
|
200
234
|
case "SET_FINDING_STATUS": {
|
|
201
235
|
const request = parseRequest(SetFindingStatusRequestSchema, msg.data);
|
|
202
236
|
const analysis = setFindingStatus(store, request.analysisId, request.findingId, request.body);
|
|
@@ -221,6 +255,12 @@ function handleGuiRequest(msg) {
|
|
|
221
255
|
afterUserMutation(analysis.id);
|
|
222
256
|
return { analysis };
|
|
223
257
|
}
|
|
258
|
+
case "MARK_ANSWER_SEEN": {
|
|
259
|
+
const request = parseRequest(MarkAnswerSeenRequestSchema, msg.data);
|
|
260
|
+
const analysis = markAnswerSeen(store, request.analysisId, request.noteId, request.body);
|
|
261
|
+
afterUserMutation(analysis.id);
|
|
262
|
+
return { analysis };
|
|
263
|
+
}
|
|
224
264
|
case "SUBMIT_REVIEW": {
|
|
225
265
|
const request = parseRequest(SubmitReviewRequestSchema, msg.data);
|
|
226
266
|
const analysis = submitReview(store, request.analysisId, request.body);
|
|
@@ -488,6 +528,37 @@ const TOOLS = [
|
|
|
488
528
|
required: ["analysis_id"],
|
|
489
529
|
},
|
|
490
530
|
},
|
|
531
|
+
{
|
|
532
|
+
name: "classify_files",
|
|
533
|
+
description: "Classify changed files by review level, as a batch, each with a one-sentence reason the reviewer reads in the GUI: " +
|
|
534
|
+
"central (carries a business rule or a computation: read in detail), check (a caller or a screen that wires such a rule), " +
|
|
535
|
+
"skim (mechanical code: tests, deletions, imports, routes, renames). Classify every file right after the overview. " +
|
|
536
|
+
"Migrations, SQL, configuration, CI and container files cannot be skimmed. A file the reviewer moved to another level keeps " +
|
|
537
|
+
"the reviewer's level unless you now choose the same. If any item is invalid, nothing is written and every problem is reported.",
|
|
538
|
+
inputSchema: {
|
|
539
|
+
type: "object",
|
|
540
|
+
properties: {
|
|
541
|
+
analysis_id: { type: "string", description: ANALYSIS_ID_DOC },
|
|
542
|
+
files: {
|
|
543
|
+
type: "array",
|
|
544
|
+
minItems: 1,
|
|
545
|
+
items: {
|
|
546
|
+
type: "object",
|
|
547
|
+
properties: {
|
|
548
|
+
path: { type: "string", description: "Path of a changed file, as listed by get_analysis." },
|
|
549
|
+
level: { type: "string", enum: [...FILE_LEVELS], description: "Review level: central, check or skim." },
|
|
550
|
+
reason: {
|
|
551
|
+
type: "string",
|
|
552
|
+
description: 'One sentence saying what the file does in the feature, e.g. "Replaces one class name with another" or "Computes the token expiry".',
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
required: ["path", "level", "reason"],
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
required: ["analysis_id", "files"],
|
|
560
|
+
},
|
|
561
|
+
},
|
|
491
562
|
{
|
|
492
563
|
name: "add_findings",
|
|
493
564
|
description: "Record findings for the reviewer, as a batch. Each location is checked against the frozen diff and its lines are copied; " +
|
|
@@ -711,6 +782,64 @@ const TOOLS = [
|
|
|
711
782
|
required: ["analysis_id"],
|
|
712
783
|
},
|
|
713
784
|
},
|
|
785
|
+
{
|
|
786
|
+
name: "enable_notifications",
|
|
787
|
+
description: "Get notified of what the reviewer does on one analysis and on its follow-up reviews, including the ones created later, and on nothing else: " +
|
|
788
|
+
"a question the reviewer sends you right away from the GUI, and a review the reviewer submits. " +
|
|
789
|
+
"Returns immediately and hands you the exact Monitor call to make right after: arming that watcher is what delivers the notifications. " +
|
|
790
|
+
"Call it once per conversation, after create_analysis, for the analysis you are working on: its follow-up reviews are covered, never arm a second watcher for them; the host stops the watcher after 30 minutes at most, " +
|
|
791
|
+
"re-arm it with the same Monitor call each time it expires. Works locally and behind mcp-http-gateway.",
|
|
792
|
+
inputSchema: {
|
|
793
|
+
type: "object",
|
|
794
|
+
properties: {
|
|
795
|
+
analysis_id: { type: "string", description: `${ANALYSIS_ID_DOC} Its follow-up reviews are watched too.` },
|
|
796
|
+
[WATCH_ARG]: {
|
|
797
|
+
type: "object",
|
|
798
|
+
description: "Filled in by the mcp-http-gateway relay, never by the agent: the relay will run the watcher and needs a watch specification instead of a local command",
|
|
799
|
+
},
|
|
800
|
+
},
|
|
801
|
+
required: ["analysis_id"],
|
|
802
|
+
},
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
name: "wait_for_notifications",
|
|
806
|
+
description: "Reserved for the notification watcher that the mcp-http-gateway relay runs on the agent's machine: do not call it yourself. " +
|
|
807
|
+
"To be notified, call enable_notifications. " +
|
|
808
|
+
"Blocks until an event of the analysis or of its follow-up reviews happens after the cursor (a question from the reviewer, a submitted review), or until the timeout, " +
|
|
809
|
+
"and returns one line per event with the next cursor.",
|
|
810
|
+
inputSchema: {
|
|
811
|
+
type: "object",
|
|
812
|
+
properties: {
|
|
813
|
+
analysis_id: { type: "string", description: ANALYSIS_ID_DOC },
|
|
814
|
+
cursor: {
|
|
815
|
+
type: "string",
|
|
816
|
+
pattern: "^[0-9]+$",
|
|
817
|
+
description: "Cursor returned by the previous call. Omit to wait for events from now on.",
|
|
818
|
+
},
|
|
819
|
+
timeout_seconds: {
|
|
820
|
+
type: "integer",
|
|
821
|
+
minimum: 1,
|
|
822
|
+
maximum: MAX_NOTIFICATION_WAIT_SECONDS,
|
|
823
|
+
description: `Maximum wait in seconds (default ${DEFAULT_NOTIFICATION_WAIT_SECONDS}).`,
|
|
824
|
+
},
|
|
825
|
+
},
|
|
826
|
+
required: ["analysis_id"],
|
|
827
|
+
},
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
name: "answer_question",
|
|
831
|
+
description: "Answer a question the reviewer sent you right away from the GUI (announced by the notification watcher, listed by get_analysis among the reviewer notes). " +
|
|
832
|
+
"The reviewer reads the answer next to the question in the GUI. A question is answered once; it is never part of the submitted feedback.",
|
|
833
|
+
inputSchema: {
|
|
834
|
+
type: "object",
|
|
835
|
+
properties: {
|
|
836
|
+
analysis_id: { type: "string", description: ANALYSIS_ID_DOC },
|
|
837
|
+
question_id: { type: "string", description: "Id of the question, as given by the notification or get_analysis." },
|
|
838
|
+
answer: { type: "string", description: "Your answer, in the reviewer's language. Plain text; line breaks are kept." },
|
|
839
|
+
},
|
|
840
|
+
required: ["analysis_id", "question_id", "answer"],
|
|
841
|
+
},
|
|
842
|
+
},
|
|
714
843
|
{
|
|
715
844
|
name: "refresh_analysis",
|
|
716
845
|
description: "Recompute the frozen diff with the same repository, mode and refs, after fixing the code. " +
|
|
@@ -749,7 +878,7 @@ function withRepoAccess(exec, fn) {
|
|
|
749
878
|
return fn(localRepo);
|
|
750
879
|
return handleAgentExec(exec, (run) => fn((repoPath) => agentRepo(repoPath, run)));
|
|
751
880
|
}
|
|
752
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
881
|
+
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
753
882
|
const { name, arguments: args } = request.params;
|
|
754
883
|
// L'argument réservé du relais agent accompagne tous les appels d'une route listée dans GATEWAY_EXEC_ROUTES.
|
|
755
884
|
const { [EXEC_ARG]: exec, ...params } = (args ?? {});
|
|
@@ -773,6 +902,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
773
902
|
});
|
|
774
903
|
case "update_analysis":
|
|
775
904
|
return afterMutation(updateAnalysis(store, params));
|
|
905
|
+
case "classify_files":
|
|
906
|
+
return afterMutation(classifyFiles(store, params));
|
|
776
907
|
case "add_findings":
|
|
777
908
|
return afterMutation(addFindings(store, params));
|
|
778
909
|
case "update_finding":
|
|
@@ -791,6 +922,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
791
922
|
return afterMutation(deleteDiagram(store, params));
|
|
792
923
|
case "mark_feedback_processed":
|
|
793
924
|
return afterMutation(markFeedbackProcessed(store, params));
|
|
925
|
+
case "answer_question":
|
|
926
|
+
return afterMutation(answerQuestion(store, params));
|
|
927
|
+
case "enable_notifications":
|
|
928
|
+
return enableNotifications(notificationContext, params);
|
|
929
|
+
case "wait_for_notifications":
|
|
930
|
+
return await waitForNotifications(notificationContext, params, extra.signal);
|
|
794
931
|
case "refresh_analysis":
|
|
795
932
|
return await withRepoAccess(exec, async (repoFor) => afterMutation(await refreshAnalysis(store, params, repoFor)));
|
|
796
933
|
case "delete_analysis": {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AnalysisStore } from "../core/analysis-store.js";
|
|
2
|
+
import { type Args, type MutationResult } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Classe un lot de fichiers par niveau de relecture, chacun avec sa raison.
|
|
5
|
+
* Tout le lot est validé avant l'écriture : un fichier inconnu, un doublon ou un
|
|
6
|
+
* fichier sensible classé en survol, et rien n'est écrit. Le niveau choisi par
|
|
7
|
+
* le relecteur est conservé, sauf quand l'agent choisit désormais le même.
|
|
8
|
+
*/
|
|
9
|
+
export declare function classifyFiles(store: AnalysisStore, args: Args): MutationResult;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { AnalysisError } from "../core/errors.js";
|
|
2
|
+
import { sensitiveFileKind } from "../../shared/file-levels.js";
|
|
3
|
+
import { FILE_LEVELS } from "../../shared/schemas/analysis.schema.js";
|
|
4
|
+
import { classificationLabel } from "./format.js";
|
|
5
|
+
import { rejectUnknownFields, requireArray, requireEnum, requireObject, requireString, textResult, } from "./types.js";
|
|
6
|
+
const FILE_INPUT_FIELDS = ["path", "level", "reason"];
|
|
7
|
+
/**
|
|
8
|
+
* Classe un lot de fichiers par niveau de relecture, chacun avec sa raison.
|
|
9
|
+
* Tout le lot est validé avant l'écriture : un fichier inconnu, un doublon ou un
|
|
10
|
+
* fichier sensible classé en survol, et rien n'est écrit. Le niveau choisi par
|
|
11
|
+
* le relecteur est conservé, sauf quand l'agent choisit désormais le même.
|
|
12
|
+
*/
|
|
13
|
+
export function classifyFiles(store, args) {
|
|
14
|
+
rejectUnknownFields(args, ["analysis_id", "files"]);
|
|
15
|
+
const id = requireString(args, "analysis_id");
|
|
16
|
+
const items = requireArray(args, "files", 1);
|
|
17
|
+
const analysis = store.get(id);
|
|
18
|
+
const known = new Set(analysis.files.map((file) => file.path));
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
const prepared = [];
|
|
21
|
+
const errors = [];
|
|
22
|
+
items.forEach((raw, index) => {
|
|
23
|
+
try {
|
|
24
|
+
const item = requireObject(raw, `files[${index}]`);
|
|
25
|
+
rejectUnknownFields(item, FILE_INPUT_FIELDS);
|
|
26
|
+
const path = requireString(item, "path");
|
|
27
|
+
const level = requireEnum(item, "level", FILE_LEVELS);
|
|
28
|
+
const reason = requireString(item, "reason");
|
|
29
|
+
if (!known.has(path))
|
|
30
|
+
throw new Error(`"${path}" is not a changed file of this analysis (see get_analysis).`);
|
|
31
|
+
if (seen.has(path))
|
|
32
|
+
throw new Error(`"${path}" appears twice in this batch.`);
|
|
33
|
+
seen.add(path);
|
|
34
|
+
const sensitive = sensitiveFileKind(path);
|
|
35
|
+
if (level === "skim" && sensitive !== null) {
|
|
36
|
+
throw new Error(`"${path}" is a ${sensitive}: short but heavy with consequences, it is never skimmed. Classify it central or check.`);
|
|
37
|
+
}
|
|
38
|
+
prepared.push({ path, level, reason });
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
errors.push(`- files[${index}]: ${err.message}`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (errors.length > 0) {
|
|
45
|
+
throw new AnalysisError(`No file was classified: ${errors.length} of ${items.length} item(s) are invalid. Fix them and send the whole batch again.\n` +
|
|
46
|
+
errors.join("\n"));
|
|
47
|
+
}
|
|
48
|
+
const updated = store.mutate(id, "agent", (draft) => {
|
|
49
|
+
for (const { path, level, reason } of prepared) {
|
|
50
|
+
const file = draft.files.find((entry) => entry.path === path);
|
|
51
|
+
if (!file)
|
|
52
|
+
throw new AnalysisError(`The diff of analysis "${id}" was recomputed while the files were validated. Send the batch again.`);
|
|
53
|
+
const reviewerLevel = file.classification?.reviewerLevel ?? null;
|
|
54
|
+
file.classification = { level, reason, reviewerLevel: reviewerLevel === level ? null : reviewerLevel };
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const classified = new Set(prepared.map((item) => item.path));
|
|
58
|
+
const lines = [
|
|
59
|
+
`Classified ${prepared.length} file(s) of "${updated.title}" (${updated.id}):`,
|
|
60
|
+
...updated.files.filter((file) => classified.has(file.path)).map((file) => ` ${file.path} — ${classificationLabel(file)}`),
|
|
61
|
+
];
|
|
62
|
+
const kept = updated.files.filter((file) => classified.has(file.path) && file.classification?.reviewerLevel != null);
|
|
63
|
+
if (kept.length > 0) {
|
|
64
|
+
lines.push(`The reviewer's own level is kept for ${kept.length} file(s); the GUI shows theirs.`);
|
|
65
|
+
}
|
|
66
|
+
const unclassified = updated.files.filter((file) => file.classification === null);
|
|
67
|
+
lines.push(unclassified.length === 0
|
|
68
|
+
? "Every file is classified."
|
|
69
|
+
: `Still unclassified (${unclassified.length}): ${unclassified.map((file) => file.path).join(", ")}. Classify them too: the GUI groups them apart.`);
|
|
70
|
+
return { result: textResult(lines.join("\n")), analysisId: updated.id };
|
|
71
|
+
}
|
|
@@ -49,6 +49,6 @@ export async function createAnalysis(store, args, repoFor = localRepo) {
|
|
|
49
49
|
else {
|
|
50
50
|
lines.push(`Changed files (${fileTotals(analysis.files)}):`, ...analysis.files.map((file) => ` ${fileLine(file)}`));
|
|
51
51
|
}
|
|
52
|
-
lines.push("", "Next steps:", `1. Read the frozen diff with get_diff (analysis_id "${analysis.id}"); anchor findings on its new-side line numbers.`, "2. Write the overview (objective, approach, attention_points) and the summary (the functional changes of the feature) with update_analysis.", "3. Explain every long (about 30 lines or more) or complex block of added or removed code with add_explanations: what it does and how it works.", "
|
|
52
|
+
lines.push("", "Next steps:", `1. Read the frozen diff with get_diff (analysis_id "${analysis.id}"); anchor findings on its new-side line numbers.`, "2. Write the overview (objective, approach, attention_points) and the summary (the functional changes of the feature) with update_analysis.", "3. Classify every changed file with classify_files (central, check or skim, with a one-sentence reason) so the reviewer spends time where it matters.", "4. Explain every long (about 30 lines or more) or complex block of added or removed code with add_explanations: what it does and how it works.", "5. Record problems with add_findings, including requirement_gap findings for requested behaviour that is missing.", "6. Add diagrams with set_diagram when a picture helps the reviewer: one subject each, 5 to 12 nodes, no crossing.", "7. Ask the user to review the analysis in the GUI, then read the outcome with get_review_feedback.");
|
|
53
53
|
return { result: textResult(lines.join("\n")), analysisId: analysis.id };
|
|
54
54
|
}
|