@imenam/mcp-feature-analyzer 1.0.28 → 1.0.31

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.
Files changed (117) hide show
  1. package/README.md +15 -4
  2. package/dist/shared/file-levels.d.ts +11 -0
  3. package/dist/shared/file-levels.js +46 -0
  4. package/dist/shared/labels.d.ts +6 -1
  5. package/dist/shared/labels.js +6 -0
  6. package/dist/shared/schemas/analysis.schema.d.ts +47 -0
  7. package/dist/shared/schemas/analysis.schema.js +13 -0
  8. package/dist/shared/schemas/api.schema.d.ts +23 -0
  9. package/dist/shared/schemas/api.schema.js +8 -1
  10. package/dist/shared/schemas/ipc.schema.d.ts +1 -1
  11. package/dist/shared/schemas/ipc.schema.js +1 -0
  12. package/dist/src/cli/setup-mcp.js +2 -2
  13. package/dist/src/core/analysis-store.js +1 -1
  14. package/dist/src/core/data-dir.d.ts +2 -5
  15. package/dist/src/core/data-dir.js +10 -9
  16. package/dist/src/core/git.d.ts +1 -1
  17. package/dist/src/core/git.js +2 -1
  18. package/dist/src/core/invariants.d.ts +2 -1
  19. package/dist/src/core/invariants.js +9 -2
  20. package/dist/src/core/log-dir.d.ts +2 -6
  21. package/dist/src/core/log-dir.js +3 -8
  22. package/dist/src/core/migrate.d.ts +2 -0
  23. package/dist/src/core/migrate.js +11 -0
  24. package/dist/src/core/refresh.d.ts +3 -0
  25. package/dist/src/core/refresh.js +8 -4
  26. package/dist/src/core/review-actions.d.ts +6 -1
  27. package/dist/src/core/review-actions.js +15 -0
  28. package/dist/src/gui-worker.js +9 -2
  29. package/dist/src/index.js +54 -12
  30. package/dist/src/tools/classify-files.d.ts +9 -0
  31. package/dist/src/tools/classify-files.js +71 -0
  32. package/dist/src/tools/create-analysis.js +1 -1
  33. package/dist/src/tools/format.d.ts +5 -0
  34. package/dist/src/tools/format.js +11 -0
  35. package/dist/src/tools/get-analysis.js +6 -2
  36. package/dist/src/tools/get-review-feedback.js +14 -1
  37. package/dist/src/tools/refresh-analysis.js +2 -1
  38. package/gui/dist/assets/{angular-html-5NhKn_t-.js → angular-html-CmKD3qPJ.js} +1 -1
  39. package/gui/dist/assets/{angular-ts-DhsMT4Rz.js → angular-ts-CUV4f-7a.js} +1 -1
  40. package/gui/dist/assets/{apl-BQY6aoi5.js → apl-DCOueFDH.js} +1 -1
  41. package/gui/dist/assets/{astro-D2uooUSE.js → astro-BD_jikG2.js} +1 -1
  42. package/gui/dist/assets/{blade-CCqBQx9x.js → blade--LKfGpL_.js} +1 -1
  43. package/gui/dist/assets/{c-Dr5lpVW7.js → c-C64vu1wx.js} +1 -1
  44. package/gui/dist/assets/{chapel-BHsANtTA.js → chapel-CdXV9nyw.js} +1 -1
  45. package/gui/dist/assets/{cobol-CqwhBifS.js → cobol-CIeHGuXr.js} +1 -1
  46. package/gui/dist/assets/{coffee-Wiu8SLC2.js → coffee-Bkn2a3NA.js} +1 -1
  47. package/gui/dist/assets/{cpp-CJ_ODeXR.js → cpp-C3fB8Y2b.js} +1 -1
  48. package/gui/dist/assets/{crystal-B_FnmDRX.js → crystal-DAd9h7ft.js} +1 -1
  49. package/gui/dist/assets/{css-BX2hCl8Q.js → css-DBARcyqi.js} +1 -1
  50. package/gui/dist/assets/{edge-l0IQj2gt.js → edge-BNZ8haox.js} +1 -1
  51. package/gui/dist/assets/{elixir-BnXfG85X.js → elixir-D9JArLjY.js} +1 -1
  52. package/gui/dist/assets/{elm-DkiIxCka.js → elm-BdV8wsvX.js} +1 -1
  53. package/gui/dist/assets/{erb-Cd7Dui37.js → erb-C9NJWWn2.js} +1 -1
  54. package/gui/dist/assets/{git-rebase-DKKMrbhR.js → git-rebase-C7eVPIjR.js} +1 -1
  55. package/gui/dist/assets/{glimmer-js-ClmFS94t.js → glimmer-js-BYHDLB8h.js} +1 -1
  56. package/gui/dist/assets/{glimmer-ts-BcBFTQWM.js → glimmer-ts-2zbF0Evu.js} +1 -1
  57. package/gui/dist/assets/{glsl-C3thj0jg.js → glsl-DkVhwxyT.js} +1 -1
  58. package/gui/dist/assets/{graphql-B6mMAjvE.js → graphql-c5VbsYm4.js} +1 -1
  59. package/gui/dist/assets/{hack-0LBOyGxt.js → hack-ZGsLC-jN.js} +1 -1
  60. package/gui/dist/assets/{haml-uOaDaMcM.js → haml-CbXyCehf.js} +1 -1
  61. package/gui/dist/assets/{handlebars-CYsq3lyR.js → handlebars-C-NYLeBr.js} +1 -1
  62. package/gui/dist/assets/{html-LQMPiuEI.js → html-B0yhsy4d.js} +1 -1
  63. package/gui/dist/assets/{html-derivative-CzLV5NtN.js → html-derivative-VQyqZXW8.js} +1 -1
  64. package/gui/dist/assets/{http-BUUATjp1.js → http-C-aT1t0_.js} +1 -1
  65. package/gui/dist/assets/{hurl-DfUfCgyH.js → hurl-Dl1RZ9Gp.js} +1 -1
  66. package/gui/dist/assets/{index-BKUr4xoh.js → index-DnIoVeij.js} +18 -18
  67. package/gui/dist/assets/index-V1Ga6Ikg.css +1 -0
  68. package/gui/dist/assets/{java-DFQBBMEz.js → java-0vBBZHSu.js} +1 -1
  69. package/gui/dist/assets/{javascript-tFDB_Ucv.js → javascript-DeblizDv.js} +1 -1
  70. package/gui/dist/assets/{jinja-B7dQLu57.js → jinja-CvT6pZVi.js} +1 -1
  71. package/gui/dist/assets/{jison-10iK85Cg.js → jison-xhWB-hJt.js} +1 -1
  72. package/gui/dist/assets/{json-CNNin8Qj.js → json-lrbKMNAx.js} +1 -1
  73. package/gui/dist/assets/{jsx-BmoTM54L.js → jsx-AvOeMWx5.js} +1 -1
  74. package/gui/dist/assets/{julia-CfU24q-y.js → julia-CCVS_Afm.js} +1 -1
  75. package/gui/dist/assets/{just-BaBindpQ.js → just-D0rQgjf2.js} +1 -1
  76. package/gui/dist/assets/{latex-BI4Nwj84.js → latex-DgGx6yXU.js} +1 -1
  77. package/gui/dist/assets/{liquid-DdRKxxNE.js → liquid-D95OegEg.js} +1 -1
  78. package/gui/dist/assets/{lua-BRLUOT5F.js → lua-5KNos9qZ.js} +1 -1
  79. package/gui/dist/assets/{marko-DNv4_LKP.js → marko-BpMwNtg_.js} +1 -1
  80. package/gui/dist/assets/{mdc-D8izFv08.js → mdc-Dul0I4vt.js} +1 -1
  81. package/gui/dist/assets/{nginx-DUUt3koj.js → nginx-B2gDZimP.js} +1 -1
  82. package/gui/dist/assets/{nim-CysKZwP3.js → nim-D9V6BvZF.js} +1 -1
  83. package/gui/dist/assets/{org-DRbqnSGz.js → org-BDDVerq9.js} +1 -1
  84. package/gui/dist/assets/{perl-BFeXyBX8.js → perl-BeFJyiyg.js} +1 -1
  85. package/gui/dist/assets/{php-CUoskUzm.js → php-ClsyOlLU.js} +1 -1
  86. package/gui/dist/assets/{pug-C6Wb4WSu.js → pug-Bw7ZuWMB.js} +1 -1
  87. package/gui/dist/assets/{qml-BLxZs3E-.js → qml-VKAIx01f.js} +1 -1
  88. package/gui/dist/assets/{r-BVy3lwjs.js → r-BbmN2hL3.js} +1 -1
  89. package/gui/dist/assets/{razor-BP53EMWu.js → razor-x_jMVj8b.js} +1 -1
  90. package/gui/dist/assets/{regexp-C4DXj1is.js → regexp-COLYAzG8.js} +1 -1
  91. package/gui/dist/assets/{rst-OdGdDU13.js → rst-Cr40Lerq.js} +1 -1
  92. package/gui/dist/assets/{ruby-BMnClzBa.js → ruby-CLGGotZ-.js} +1 -1
  93. package/gui/dist/assets/{sas-Cfl9isPl.js → sas-DWBWO9Y5.js} +1 -1
  94. package/gui/dist/assets/{scss-Dhg-JzbO.js → scss-BzKAiQYV.js} +1 -1
  95. package/gui/dist/assets/{shellscript-DTieiA63.js → shellscript-D2u4cPDX.js} +1 -1
  96. package/gui/dist/assets/{shellsession-BWx2rqf_.js → shellsession-Ccl-2bAD.js} +1 -1
  97. package/gui/dist/assets/{soy-DEOBlMFT.js → soy-iOU5rhs2.js} +1 -1
  98. package/gui/dist/assets/{sql-CcIgwCBd.js → sql-BEWq1vME.js} +1 -1
  99. package/gui/dist/assets/{stata-Bx19F1yU.js → stata-yz3nZ7Wz.js} +1 -1
  100. package/gui/dist/assets/{surrealql-Cql6Lb-6.js → surrealql-DQG5rJ06.js} +1 -1
  101. package/gui/dist/assets/{svelte-lFXZ4EZb.js → svelte-CF3TXZKT.js} +1 -1
  102. package/gui/dist/assets/{templ-D_Pn1_WV.js → templ-C4GJOtRU.js} +1 -1
  103. package/gui/dist/assets/{tex-DFT7E4ng.js → tex-D2FpWKcl.js} +1 -1
  104. package/gui/dist/assets/{ts-tags-BfzRLZHd.js → ts-tags-CUP-vv3j.js} +1 -1
  105. package/gui/dist/assets/{tsx-BOIZx2wx.js → tsx-dMhwOSyy.js} +1 -1
  106. package/gui/dist/assets/{twig-D0n8mooJ.js → twig-BTWubnl3.js} +1 -1
  107. package/gui/dist/assets/{typescript-Cn81Mlip.js → typescript-C8UFvOTX.js} +1 -1
  108. package/gui/dist/assets/{typst-DMsZD3Vh.js → typst-CJXqwXsh.js} +1 -1
  109. package/gui/dist/assets/{vue-C78oMXhn.js → vue-X9Wwm2mD.js} +1 -1
  110. package/gui/dist/assets/{vue-html-Cn2mX7R9.js → vue-html-DRPxRQ6-.js} +1 -1
  111. package/gui/dist/assets/{vue-vine-Ceuq9sdM.js → vue-vine-Bt58w4aD.js} +1 -1
  112. package/gui/dist/assets/{xml-BP7iQh4O.js → xml-lUPi6MU7.js} +1 -1
  113. package/gui/dist/assets/{xsl-Bc9-jqg1.js → xsl-BieZRR5a.js} +1 -1
  114. package/gui/dist/assets/{yaml-yTwqxcXx.js → yaml-DAVBBHYU.js} +1 -1
  115. package/gui/dist/index.html +2 -2
  116. package/package.json +1 -1
  117. package/gui/dist/assets/index-DSRZjXsH.css +0 -1
@@ -46,6 +46,7 @@ function currentText(finding, diffs) {
46
46
  /**
47
47
  * Calcule les champs d'une analyse après recalcul de son snapshot :
48
48
  * - `reviewed` n'est conservé que pour les fichiers dont le diff est inchangé ;
49
+ * - le classement d'un fichier toujours présent est conservé ; un nouveau fichier n'est pas classé ;
49
50
  * - un constat `open` dont les lignes ne correspondent plus à `anchorText`, ou dont le
50
51
  * fichier a quitté le diff, passe à `outdated` ;
51
52
  * - un constat `outdated` dont les lignes correspondent de nouveau revient à `open` ;
@@ -66,6 +67,7 @@ export function applyRefresh(analysis, oldSnapshot, next) {
66
67
  filesRemoved: 0,
67
68
  reviewedKept: 0,
68
69
  reviewedReset: 0,
70
+ unclassified: 0,
69
71
  findingsOutdated: 0,
70
72
  findingsRestored: 0,
71
73
  explanationsOutdated: 0,
@@ -75,20 +77,22 @@ export function applyRefresh(analysis, oldSnapshot, next) {
75
77
  const previous = oldEntries.get(entry.path);
76
78
  if (!previous) {
77
79
  stats.filesAdded++;
78
- return { ...entry, reviewed: false };
80
+ return { ...entry, reviewed: false, classification: null };
79
81
  }
82
+ const classification = previous.classification;
80
83
  if (!previous.reviewed)
81
- return { ...entry, reviewed: false };
84
+ return { ...entry, reviewed: false, classification };
82
85
  const newDiff = newDiffs.get(entry.path);
83
86
  if (!newDiff)
84
87
  throw new AnalysisError(`The new snapshot has no diff for "${entry.path}".`);
85
88
  if (sameFileDiff(previous, oldDiffs.get(entry.path), entry, newDiff)) {
86
89
  stats.reviewedKept++;
87
- return { ...entry, reviewed: true };
90
+ return { ...entry, reviewed: true, classification };
88
91
  }
89
92
  stats.reviewedReset++;
90
- return { ...entry, reviewed: false };
93
+ return { ...entry, reviewed: false, classification };
91
94
  });
95
+ stats.unclassified = files.filter((file) => file.classification === null).length;
92
96
  const newPaths = new Set(next.files.map((file) => file.path));
93
97
  stats.filesRemoved = analysis.files.filter((file) => !newPaths.has(file.path)).length;
94
98
  const findings = analysis.findings.map((finding) => {
@@ -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, 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
@@ -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
@@ -7,7 +7,8 @@ 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, MarkProcessedBodySchema, SetFileLevelBodySchema, SetFileReviewedBodySchema, SetFindingStatusBodySchema, SubmitReviewBodySchema, UpdateNoteBodySchema, } from "../shared/schemas/api.schema.js";
11
+ import { resolveDataDir } from "./core/data-dir.js";
11
12
  import { resolveLogDir } from "./core/log-dir.js";
12
13
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
13
14
  function findProjectRoot(startDir) {
@@ -44,7 +45,7 @@ function resolveGuiMode() {
44
45
  }
45
46
  const guiMode = resolveGuiMode();
46
47
  const isStandalone = guiMode.kind === "standalone";
47
- setupLogging({ processLabel: "mcp-feature-analyzer:GUI", logDir: resolveLogDir(rootDir) });
48
+ setupLogging({ processLabel: "mcp-feature-analyzer:GUI", logDir: resolveLogDir(resolveDataDir()) });
48
49
  const logger = createLogger("mcp-feature-analyzer:GUI");
49
50
  process.on("uncaughtException", (err) => {
50
51
  logger.error(`Uncaught Exception: ${err.message}`);
@@ -246,6 +247,12 @@ app.post("/api/analyses/:id/files/reviewed", async (c) => {
246
247
  return read.response;
247
248
  return forward(c, "SET_FILE_REVIEWED", { analysisId: c.req.param("id"), body: read.body });
248
249
  });
250
+ app.post("/api/analyses/:id/files/level", async (c) => {
251
+ const read = await readBody(c, SetFileLevelBodySchema);
252
+ if ("response" in read)
253
+ return read.response;
254
+ return forward(c, "SET_FILE_LEVEL", { analysisId: c.req.param("id"), body: read.body });
255
+ });
249
256
  app.post("/api/analyses/:id/findings/:findingId/status", async (c) => {
250
257
  const read = await readBody(c, SetFindingStatusBodySchema);
251
258
  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, 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, 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";
@@ -64,8 +65,6 @@ function findProjectRoot(startDir) {
64
65
  }
65
66
  const rootDir = findProjectRoot(__dirname);
66
67
  const packageEnvPath = path.join(rootDir, ".env");
67
- setupLogging({ processLabel: "mcp-feature-analyzer", logDir: resolveLogDir(rootDir) });
68
- const logger = createLogger("mcp-feature-analyzer");
69
68
  // Rechargé à chaque appel, avec override : le .env local prime sur les
70
69
  // variables héritées de la déclaration du MCP.
71
70
  function getConfig() {
@@ -74,6 +73,9 @@ function getConfig() {
74
73
  return { proxyUrl: process.env.PROXY_URL, appPort: process.env.APP_PORT, version: APP_VERSION };
75
74
  }
76
75
  getConfig();
76
+ const dataDir = resolveDataDir();
77
+ setupLogging({ processLabel: "mcp-feature-analyzer", logDir: resolveLogDir(dataDir) });
78
+ const logger = createLogger("mcp-feature-analyzer");
77
79
  let role;
78
80
  try {
79
81
  role = resolveRole();
@@ -83,7 +85,6 @@ catch (err) {
83
85
  console.error(err.message);
84
86
  process.exit(1);
85
87
  }
86
- const dataDir = resolveDataDir(rootDir);
87
88
  const store = new AnalysisStore(dataDir);
88
89
  /** Présentation du serveur transmise au client MCP : concepts, déroulé et règles. */
89
90
  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.
@@ -92,6 +93,7 @@ Concepts:
92
93
  - 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
94
  - A **project** groups the analyses of one product or feature; the GUI files analyses by project.
94
95
  - 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.
96
+ - 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
97
  - 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
98
  - 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
99
  - A **diagram** is a flow, layers or mindmap picture of the feature. You give nodes and links only; the GUI lays them out.
@@ -102,12 +104,13 @@ Workflow:
102
104
  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
105
  2. get_diff to read the frozen diff.
104
106
  3. update_analysis with the overview (objective, approach, attention_points) and the summary (the functional changes).
105
- 4. add_explanations for the long or complex blocks of added or removed code (see Explanation rules).
106
- 5. add_findings for every problem, including requirement_gap findings for requested behaviour that is missing.
107
- 6. set_diagram when a picture helps (impacted layers, process flow, concept tree).
108
- 7. Tell the user to review the analysis in the GUI (the link is in the tool results).
109
- 8. 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.
110
- 9. 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.
107
+ 4. classify_files for every changed file: level and reason.
108
+ 5. add_explanations for the long or complex blocks of added or removed code (see Explanation rules).
109
+ 6. add_findings for every problem, including requirement_gap findings for requested behaviour that is missing.
110
+ 7. set_diagram when a picture helps (impacted layers, process flow, concept tree).
111
+ 8. Tell the user to review the analysis in the GUI (the link is in the tool results).
112
+ 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.
113
+ 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
114
 
112
115
  Explanation rules:
113
116
  - 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 +200,12 @@ function handleGuiRequest(msg) {
197
200
  afterUserMutation(analysis.id);
198
201
  return { analysis };
199
202
  }
203
+ case "SET_FILE_LEVEL": {
204
+ const request = parseRequest(SetFileLevelRequestSchema, msg.data);
205
+ const analysis = setFileLevel(store, request.analysisId, request.body);
206
+ afterUserMutation(analysis.id);
207
+ return { analysis };
208
+ }
200
209
  case "SET_FINDING_STATUS": {
201
210
  const request = parseRequest(SetFindingStatusRequestSchema, msg.data);
202
211
  const analysis = setFindingStatus(store, request.analysisId, request.findingId, request.body);
@@ -488,6 +497,37 @@ const TOOLS = [
488
497
  required: ["analysis_id"],
489
498
  },
490
499
  },
500
+ {
501
+ name: "classify_files",
502
+ description: "Classify changed files by review level, as a batch, each with a one-sentence reason the reviewer reads in the GUI: " +
503
+ "central (carries a business rule or a computation: read in detail), check (a caller or a screen that wires such a rule), " +
504
+ "skim (mechanical code: tests, deletions, imports, routes, renames). Classify every file right after the overview. " +
505
+ "Migrations, SQL, configuration, CI and container files cannot be skimmed. A file the reviewer moved to another level keeps " +
506
+ "the reviewer's level unless you now choose the same. If any item is invalid, nothing is written and every problem is reported.",
507
+ inputSchema: {
508
+ type: "object",
509
+ properties: {
510
+ analysis_id: { type: "string", description: ANALYSIS_ID_DOC },
511
+ files: {
512
+ type: "array",
513
+ minItems: 1,
514
+ items: {
515
+ type: "object",
516
+ properties: {
517
+ path: { type: "string", description: "Path of a changed file, as listed by get_analysis." },
518
+ level: { type: "string", enum: [...FILE_LEVELS], description: "Review level: central, check or skim." },
519
+ reason: {
520
+ type: "string",
521
+ description: 'One sentence saying what the file does in the feature, e.g. "Replaces one class name with another" or "Computes the token expiry".',
522
+ },
523
+ },
524
+ required: ["path", "level", "reason"],
525
+ },
526
+ },
527
+ },
528
+ required: ["analysis_id", "files"],
529
+ },
530
+ },
491
531
  {
492
532
  name: "add_findings",
493
533
  description: "Record findings for the reviewer, as a batch. Each location is checked against the frozen diff and its lines are copied; " +
@@ -773,6 +813,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
773
813
  });
774
814
  case "update_analysis":
775
815
  return afterMutation(updateAnalysis(store, params));
816
+ case "classify_files":
817
+ return afterMutation(classifyFiles(store, params));
776
818
  case "add_findings":
777
819
  return afterMutation(addFindings(store, params));
778
820
  case "update_finding":
@@ -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.", "4. Record problems with add_findings, including requirement_gap findings for requested behaviour that is missing.", "5. Add diagrams with set_diagram when a picture helps the reviewer: one subject each, 5 to 12 nodes, no crossing.", "6. Ask the user to review the analysis in the GUI, then read the outcome with get_review_feedback.");
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
  }
@@ -8,6 +8,11 @@ export declare function refsLabel(analysis: Pick<Analysis, "mode" | "base" | "he
8
8
  export declare function snapshotLabel(analysis: Analysis): string;
9
9
  /** Ligne d'un fichier modifié : statut, chemin (ancien chemin si renommé), +/-. */
10
10
  export declare function fileLine(file: FileEntry): string;
11
+ /**
12
+ * Classement d'un fichier : `central: <raison>`, `reviewer moved it to skim (agent: central: <raison>)`
13
+ * ou `unclassified`.
14
+ */
15
+ export declare function classificationLabel(file: FileEntry): string;
11
16
  /** Totaux +/- des fichiers. */
12
17
  export declare function fileTotals(files: FileEntry[]): string;
13
18
  /** `path:12` ou `path:12-14`, ou `no location`. */
@@ -25,6 +25,17 @@ export function fileLine(file) {
25
25
  const extra = !file.binary && !file.contentAvailable && file.status !== "deleted" ? ", content too large to anchor findings" : "";
26
26
  return `${FILE_STATUS_LETTERS[file.status]} ${name} ${counts}${extra}`;
27
27
  }
28
+ /**
29
+ * Classement d'un fichier : `central: <raison>`, `reviewer moved it to skim (agent: central: <raison>)`
30
+ * ou `unclassified`.
31
+ */
32
+ export function classificationLabel(file) {
33
+ const classification = file.classification;
34
+ if (classification === null)
35
+ return "unclassified";
36
+ const agent = `${classification.level}: ${classification.reason}`;
37
+ return classification.reviewerLevel === null ? agent : `reviewer moved it to ${classification.reviewerLevel} (agent: ${agent})`;
38
+ }
28
39
  /** Totaux +/- des fichiers. */
29
40
  export function fileTotals(files) {
30
41
  const additions = files.reduce((sum, file) => sum + file.additions, 0);
@@ -3,7 +3,7 @@ import { analysisLinks } from "../core/follow-ups.js";
3
3
  import { diagramQuality } from "../../shared/diagram-quality.js";
4
4
  import { reviewProgress } from "../../shared/review-state.js";
5
5
  import { sortBySeverity } from "../../shared/severity.js";
6
- import { fileLine, explanationLine, fileTotals, findingLine, followUpLines, noteLocationLabel, overviewLines, progressLabel, severityCountsLabel, snapshotLabel, } from "./format.js";
6
+ import { classificationLabel, fileLine, explanationLine, fileTotals, findingLine, followUpLines, noteLocationLabel, overviewLines, progressLabel, severityCountsLabel, snapshotLabel, } from "./format.js";
7
7
  import { rejectUnknownFields, requireString, textResult } from "./types.js";
8
8
  function noteLine(note) {
9
9
  return `${note.id} — ${noteLocationLabel(note)} — ${note.text.replace(/\n/g, " / ")}`;
@@ -67,7 +67,11 @@ export function getAnalysis(store, args) {
67
67
  }
68
68
  const reviewed = analysis.files.filter((file) => file.reviewed).length;
69
69
  lines.push(`Files (${fileTotals(analysis.files)}; reviewed ${reviewed}/${analysis.files.length}):`);
70
- lines.push(...analysis.files.map((file) => ` [${file.reviewed ? "x" : " "}] ${fileLine(file)}`), "");
70
+ lines.push(...analysis.files.map((file) => ` [${file.reviewed ? "x" : " "}] ${fileLine(file)} — ${classificationLabel(file)}`));
71
+ if (analysis.files.some((file) => file.classification === null)) {
72
+ lines.push(" Classify the unclassified files with classify_files: the reviewer starts with the central ones.");
73
+ }
74
+ lines.push("");
71
75
  const counts = { open: 0, ignored: 0, outdated: 0 };
72
76
  for (const finding of analysis.findings)
73
77
  counts[finding.status]++;
@@ -1,7 +1,8 @@
1
1
  import { analysisLinks } from "../core/follow-ups.js";
2
2
  import { hasNoChanges, needsProcessing, recordSubmission, reviewProgress, submissionChanges } from "../../shared/review-state.js";
3
3
  import { sortBySeverity } from "../../shared/severity.js";
4
- import { findingLine, indentBlock, noteLocationLabel, overviewLines, progressLabel } from "./format.js";
4
+ import { reclassifiedFiles } from "../../shared/file-levels.js";
5
+ import { classificationLabel, findingLine, indentBlock, noteLocationLabel, overviewLines, progressLabel } from "./format.js";
5
6
  import { rejectUnknownFields, requireString, textResult } from "./types.js";
6
7
  /** `processed at <date> by the agent (note: …)`, `nothing to process (approved)` ou `not processed`. */
7
8
  function processingLabel(decision, processed) {
@@ -39,6 +40,17 @@ function changeLines(previous, current) {
39
40
  lines.push(` - note ${recordedNoteLine(note)}`);
40
41
  return lines;
41
42
  }
43
+ /** Fichiers reclassés par le relecteur : son niveau, celui de l'agent et sa raison. */
44
+ function reclassificationLines(analysis) {
45
+ const files = reclassifiedFiles(analysis);
46
+ if (files.length === 0)
47
+ return [];
48
+ return [
49
+ `Files the reviewer reclassified (${files.length}) — compare with your levels to classify better next time:`,
50
+ ...files.map((file) => `- ${file.path}: ${classificationLabel(file)}`),
51
+ "",
52
+ ];
53
+ }
42
54
  function findingDetails(finding) {
43
55
  const lines = [`- ${findingLine(finding)}`];
44
56
  if (finding.body.trim() !== "")
@@ -92,6 +104,7 @@ export function getReviewFeedback(store, args) {
92
104
  lines.push(...(findings.length === 0 ? [" none"] : findings.flatMap(findingDetails)), "");
93
105
  lines.push(`Selected reviewer notes (${notes.length}):`);
94
106
  lines.push(...(notes.length === 0 ? [" none"] : notes.map(noteDetails)), "");
107
+ lines.push(...reclassificationLines(analysis));
95
108
  if (review.prompt === null) {
96
109
  lines.push("Prompt: none was recorded with this submission.");
97
110
  }
@@ -17,6 +17,7 @@ export async function refreshAnalysis(store, args, repoFor = localRepo) {
17
17
  `Diff: ${snapshotLabel(analysis)}`,
18
18
  `Files: ${stats.fileCount} (${stats.filesAdded} new in the diff, ${stats.filesRemoved} no longer in it).`,
19
19
  `Reviewed files: ${stats.reviewedKept} kept (diff unchanged), ${stats.reviewedReset} reset to unreviewed (diff changed).`,
20
+ `Classification: kept for the files still in the diff; ${stats.unclassified} file(s) unclassified.`,
20
21
  `Findings: ${stats.findingsOutdated} became outdated (their lines changed or left the diff), ` +
21
22
  `${stats.findingsRestored} back to open (their lines match again); ${outdated.length} outdated in total.`,
22
23
  `Explanations: ${stats.explanationsOutdated} became outdated (the code they describe changed or left the diff), ` +
@@ -28,7 +29,7 @@ export async function refreshAnalysis(store, args, repoFor = localRepo) {
28
29
  else {
29
30
  lines.push("Review: pending; the previous feedback, decision and selection in progress were discarded.");
30
31
  }
31
- lines.push("", "Next steps:", "- Re-read the changed files with get_diff.", "- For each outdated finding: re-anchor it with update_finding (a new location reopens it), or remove it with delete_findings if it is solved.", "- For each outdated explanation: re-anchor it and rewrite its body with update_explanation, or remove it with delete_explanations.", "- Explain the new long or complex blocks with add_explanations.", "- Ask the user to review the analysis again in the GUI.");
32
+ lines.push("", "Next steps:", "- Re-read the changed files with get_diff.", "- For each outdated finding: re-anchor it with update_finding (a new location reopens it), or remove it with delete_findings if it is solved.", "- For each outdated explanation: re-anchor it and rewrite its body with update_explanation, or remove it with delete_explanations.", "- Explain the new long or complex blocks with add_explanations.", "- Classify the unclassified files with classify_files.", "- Ask the user to review the analysis again in the GUI.");
32
33
  if (outdated.length > 0) {
33
34
  lines.push("", "Outdated findings:", ...outdated.map((finding) => ` ${finding.id} [${finding.severity}] ${finding.title}`));
34
35
  }