oc-pilot 0.160.0 → 0.162.0

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 (380) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/CONTRIBUTING.md +5 -0
  3. package/Dockerfile +2 -1
  4. package/README.md +42 -1261
  5. package/README.ru.md +52 -1144
  6. package/action.yml +8 -2
  7. package/dist/cli.js +62 -179
  8. package/dist/cli.js.map +1 -1
  9. package/dist/command-groups.js +52 -0
  10. package/dist/command-groups.js.map +1 -0
  11. package/dist/command-registry.js +92 -0
  12. package/dist/command-registry.js.map +1 -0
  13. package/dist/commands/apoptosis.js +16 -1
  14. package/dist/commands/apoptosis.js.map +1 -1
  15. package/dist/commands/blindfold.js +30 -2
  16. package/dist/commands/blindfold.js.map +1 -1
  17. package/dist/commands/butterfly.js +9 -5
  18. package/dist/commands/butterfly.js.map +1 -1
  19. package/dist/commands/cache.js +24 -14
  20. package/dist/commands/cache.js.map +1 -1
  21. package/dist/commands/deps.js +30 -0
  22. package/dist/commands/deps.js.map +1 -1
  23. package/dist/commands/doctor.js +11 -448
  24. package/dist/commands/doctor.js.map +1 -1
  25. package/dist/commands/fix.js +38 -345
  26. package/dist/commands/fix.js.map +1 -1
  27. package/dist/commands/flight.js +15 -33
  28. package/dist/commands/flight.js.map +1 -1
  29. package/dist/commands/hygiene.js +47 -0
  30. package/dist/commands/hygiene.js.map +1 -0
  31. package/dist/commands/metrics.js +49 -0
  32. package/dist/commands/metrics.js.map +1 -0
  33. package/dist/commands/preflight.js +11 -6
  34. package/dist/commands/preflight.js.map +1 -1
  35. package/dist/commands/review.js +44 -215
  36. package/dist/commands/review.js.map +1 -1
  37. package/dist/commands/setup.js +10 -331
  38. package/dist/commands/setup.js.map +1 -1
  39. package/dist/commands/test-gen.js +25 -246
  40. package/dist/commands/test-gen.js.map +1 -1
  41. package/dist/core/blindfold.js +63 -0
  42. package/dist/core/blindfold.js.map +1 -1
  43. package/dist/core/butterfly.js +12 -0
  44. package/dist/core/butterfly.js.map +1 -1
  45. package/dist/core/cache.js +161 -56
  46. package/dist/core/cache.js.map +1 -1
  47. package/dist/core/deps-registry.js +169 -0
  48. package/dist/core/deps-registry.js.map +1 -0
  49. package/dist/core/doctor.js +448 -0
  50. package/dist/core/doctor.js.map +1 -0
  51. package/dist/core/expiry.js +39 -0
  52. package/dist/core/expiry.js.map +1 -0
  53. package/dist/core/fix.js +298 -0
  54. package/dist/core/fix.js.map +1 -0
  55. package/dist/core/flight/bundle-report.js +163 -0
  56. package/dist/core/flight/bundle-report.js.map +1 -0
  57. package/dist/core/flight/bundles.js +162 -0
  58. package/dist/core/flight/bundles.js.map +1 -0
  59. package/dist/core/flight/compare-reports.js +107 -0
  60. package/dist/core/flight/compare-reports.js.map +1 -0
  61. package/dist/core/flight/comparison.js +94 -0
  62. package/dist/core/flight/comparison.js.map +1 -0
  63. package/dist/core/flight/diffs.js +67 -0
  64. package/dist/core/flight/diffs.js.map +1 -0
  65. package/dist/core/flight/events.js +78 -0
  66. package/dist/core/flight/events.js.map +1 -0
  67. package/dist/core/flight/html-reports.js +73 -0
  68. package/dist/core/flight/html-reports.js.map +1 -0
  69. package/dist/core/flight/inspection.js +28 -0
  70. package/dist/core/flight/inspection.js.map +1 -0
  71. package/dist/core/flight/proof.js +135 -0
  72. package/dist/core/flight/proof.js.map +1 -0
  73. package/dist/core/flight/queries.js +218 -0
  74. package/dist/core/flight/queries.js.map +1 -0
  75. package/dist/core/flight/query-reports.js +35 -0
  76. package/dist/core/flight/query-reports.js.map +1 -0
  77. package/dist/core/flight/runner.js +141 -0
  78. package/dist/core/flight/runner.js.map +1 -0
  79. package/dist/core/flight/session-reports.js +166 -0
  80. package/dist/core/flight/session-reports.js.map +1 -0
  81. package/dist/core/flight/sessions.js +252 -0
  82. package/dist/core/flight/sessions.js.map +1 -0
  83. package/dist/core/flight/types.js +2 -0
  84. package/dist/core/flight/types.js.map +1 -0
  85. package/dist/core/flight/worktree-reports.js +39 -0
  86. package/dist/core/flight/worktree-reports.js.map +1 -0
  87. package/dist/core/flight/worktrees.js +96 -0
  88. package/dist/core/flight/worktrees.js.map +1 -0
  89. package/dist/core/flight.js +16 -1761
  90. package/dist/core/flight.js.map +1 -1
  91. package/dist/core/hygiene.js +44 -0
  92. package/dist/core/hygiene.js.map +1 -0
  93. package/dist/core/metrics.js +172 -0
  94. package/dist/core/metrics.js.map +1 -0
  95. package/dist/core/preflight-run.js +5 -2
  96. package/dist/core/preflight-run.js.map +1 -1
  97. package/dist/core/preflight-sarif.js +64 -0
  98. package/dist/core/preflight-sarif.js.map +1 -0
  99. package/dist/core/receipt.js +41 -0
  100. package/dist/core/receipt.js.map +1 -1
  101. package/dist/core/review-publication.js +57 -0
  102. package/dist/core/review-publication.js.map +1 -0
  103. package/dist/core/review.js +148 -0
  104. package/dist/core/review.js.map +1 -0
  105. package/dist/core/sarif.js +21 -5
  106. package/dist/core/sarif.js.map +1 -1
  107. package/dist/core/setup.js +333 -0
  108. package/dist/core/setup.js.map +1 -0
  109. package/dist/core/test-gen.js +224 -0
  110. package/dist/core/test-gen.js.map +1 -0
  111. package/dist/core/test-weakening.js +58 -16
  112. package/dist/core/test-weakening.js.map +1 -1
  113. package/dist/mcp.js +137 -19
  114. package/dist/mcp.js.map +1 -1
  115. package/dist/version.js +1 -1
  116. package/docs/integrations.md +136 -6
  117. package/docs/reference.md +1318 -0
  118. package/docs/reference.ru.md +1191 -0
  119. package/package.json +5 -4
  120. package/skills/agent-self-review/SKILL.md +1 -1
  121. package/skills/commit-discipline/SKILL.md +1 -1
  122. package/skills/secure-diff-gate/SKILL.md +1 -1
  123. package/skills/stack-review-packs/SKILL.md +1 -1
  124. package/skills/test-failure-triage/SKILL.md +1 -1
  125. package/dist/cli.test.js +0 -2493
  126. package/dist/cli.test.js.map +0 -1
  127. package/dist/commands/commit.test.js +0 -160
  128. package/dist/commands/commit.test.js.map +0 -1
  129. package/dist/commands/day.test.js +0 -45
  130. package/dist/commands/day.test.js.map +0 -1
  131. package/dist/commands/doctor.test.js +0 -189
  132. package/dist/commands/doctor.test.js.map +0 -1
  133. package/dist/commands/init.test.js +0 -138
  134. package/dist/commands/init.test.js.map +0 -1
  135. package/dist/commands/install-hook.test.js +0 -107
  136. package/dist/commands/install-hook.test.js.map +0 -1
  137. package/dist/commands/replay.test.js +0 -125
  138. package/dist/commands/replay.test.js.map +0 -1
  139. package/dist/commands/review.test.js +0 -160
  140. package/dist/commands/review.test.js.map +0 -1
  141. package/dist/commands/slop.test.js +0 -135
  142. package/dist/commands/slop.test.js.map +0 -1
  143. package/dist/core/alien-dna.test.js +0 -117
  144. package/dist/core/alien-dna.test.js.map +0 -1
  145. package/dist/core/anthropic.test.js +0 -116
  146. package/dist/core/anthropic.test.js.map +0 -1
  147. package/dist/core/anti-regression.test.js +0 -154
  148. package/dist/core/anti-regression.test.js.map +0 -1
  149. package/dist/core/antibody.test.js +0 -142
  150. package/dist/core/antibody.test.js.map +0 -1
  151. package/dist/core/apoptosis.test.js +0 -104
  152. package/dist/core/apoptosis.test.js.map +0 -1
  153. package/dist/core/aql.test.js +0 -64
  154. package/dist/core/aql.test.js.map +0 -1
  155. package/dist/core/arch-diff.test.js +0 -93
  156. package/dist/core/arch-diff.test.js.map +0 -1
  157. package/dist/core/authz.test.js +0 -125
  158. package/dist/core/authz.test.js.map +0 -1
  159. package/dist/core/autopsy.test.js +0 -106
  160. package/dist/core/autopsy.test.js.map +0 -1
  161. package/dist/core/bankruptcy.test.js +0 -91
  162. package/dist/core/bankruptcy.test.js.map +0 -1
  163. package/dist/core/baseline.test.js +0 -91
  164. package/dist/core/baseline.test.js.map +0 -1
  165. package/dist/core/battle.test.js +0 -116
  166. package/dist/core/battle.test.js.map +0 -1
  167. package/dist/core/beacon.test.js +0 -114
  168. package/dist/core/beacon.test.js.map +0 -1
  169. package/dist/core/blindfold.test.js +0 -77
  170. package/dist/core/blindfold.test.js.map +0 -1
  171. package/dist/core/boundaries.test.js +0 -62
  172. package/dist/core/boundaries.test.js.map +0 -1
  173. package/dist/core/bounty.test.js +0 -82
  174. package/dist/core/bounty.test.js.map +0 -1
  175. package/dist/core/brag.test.js +0 -43
  176. package/dist/core/brag.test.js.map +0 -1
  177. package/dist/core/butterfly.test.js +0 -146
  178. package/dist/core/butterfly.test.js.map +0 -1
  179. package/dist/core/cache.test.js +0 -159
  180. package/dist/core/cache.test.js.map +0 -1
  181. package/dist/core/chronos.test.js +0 -139
  182. package/dist/core/chronos.test.js.map +0 -1
  183. package/dist/core/cinema.test.js +0 -73
  184. package/dist/core/cinema.test.js.map +0 -1
  185. package/dist/core/clairvoyant.test.js +0 -144
  186. package/dist/core/clairvoyant.test.js.map +0 -1
  187. package/dist/core/compliance.test.js +0 -123
  188. package/dist/core/compliance.test.js.map +0 -1
  189. package/dist/core/config.test.js +0 -211
  190. package/dist/core/config.test.js.map +0 -1
  191. package/dist/core/contract-drift.test.js +0 -166
  192. package/dist/core/contract-drift.test.js.map +0 -1
  193. package/dist/core/cost.test.js +0 -103
  194. package/dist/core/cost.test.js.map +0 -1
  195. package/dist/core/coverage.test.js +0 -190
  196. package/dist/core/coverage.test.js.map +0 -1
  197. package/dist/core/cuckoo.test.js +0 -98
  198. package/dist/core/cuckoo.test.js.map +0 -1
  199. package/dist/core/deps-fix.test.js +0 -176
  200. package/dist/core/deps-fix.test.js.map +0 -1
  201. package/dist/core/deps-health.test.js +0 -230
  202. package/dist/core/deps-health.test.js.map +0 -1
  203. package/dist/core/deps-why.test.js +0 -175
  204. package/dist/core/deps-why.test.js.map +0 -1
  205. package/dist/core/deps.test.js +0 -88
  206. package/dist/core/deps.test.js.map +0 -1
  207. package/dist/core/diff.test.js +0 -94
  208. package/dist/core/diff.test.js.map +0 -1
  209. package/dist/core/echo.test.js +0 -90
  210. package/dist/core/echo.test.js.map +0 -1
  211. package/dist/core/ecosystem-verify.test.js +0 -158
  212. package/dist/core/ecosystem-verify.test.js.map +0 -1
  213. package/dist/core/engine-preset.test.js +0 -60
  214. package/dist/core/engine-preset.test.js.map +0 -1
  215. package/dist/core/engine.test.js +0 -206
  216. package/dist/core/engine.test.js.map +0 -1
  217. package/dist/core/env-sync.test.js +0 -99
  218. package/dist/core/env-sync.test.js.map +0 -1
  219. package/dist/core/file-context.test.js +0 -58
  220. package/dist/core/file-context.test.js.map +0 -1
  221. package/dist/core/findings-baseline.test.js +0 -77
  222. package/dist/core/findings-baseline.test.js.map +0 -1
  223. package/dist/core/findings.test.js +0 -62
  224. package/dist/core/findings.test.js.map +0 -1
  225. package/dist/core/flaky.test.js +0 -97
  226. package/dist/core/flaky.test.js.map +0 -1
  227. package/dist/core/flight.test.js +0 -853
  228. package/dist/core/flight.test.js.map +0 -1
  229. package/dist/core/format.test.js +0 -26
  230. package/dist/core/format.test.js.map +0 -1
  231. package/dist/core/fuzz.test.js +0 -121
  232. package/dist/core/fuzz.test.js.map +0 -1
  233. package/dist/core/gitlab.test.js +0 -199
  234. package/dist/core/gitlab.test.js.map +0 -1
  235. package/dist/core/hemorrhage.test.js +0 -138
  236. package/dist/core/hemorrhage.test.js.map +0 -1
  237. package/dist/core/hivemind.test.js +0 -79
  238. package/dist/core/hivemind.test.js.map +0 -1
  239. package/dist/core/hologram.test.js +0 -124
  240. package/dist/core/hologram.test.js.map +0 -1
  241. package/dist/core/honeypot.test.js +0 -106
  242. package/dist/core/honeypot.test.js.map +0 -1
  243. package/dist/core/hooks.test.js +0 -132
  244. package/dist/core/hooks.test.js.map +0 -1
  245. package/dist/core/hyper-chamber.test.js +0 -105
  246. package/dist/core/hyper-chamber.test.js.map +0 -1
  247. package/dist/core/impact.test.js +0 -105
  248. package/dist/core/impact.test.js.map +0 -1
  249. package/dist/core/import-graph.test.js +0 -68
  250. package/dist/core/import-graph.test.js.map +0 -1
  251. package/dist/core/injection-scan.test.js +0 -100
  252. package/dist/core/injection-scan.test.js.map +0 -1
  253. package/dist/core/injection.test.js +0 -45
  254. package/dist/core/injection.test.js.map +0 -1
  255. package/dist/core/intent.test.js +0 -86
  256. package/dist/core/intent.test.js.map +0 -1
  257. package/dist/core/invariants.test.js +0 -87
  258. package/dist/core/invariants.test.js.map +0 -1
  259. package/dist/core/lang.test.js +0 -22
  260. package/dist/core/lang.test.js.map +0 -1
  261. package/dist/core/last-review.test.js +0 -97
  262. package/dist/core/last-review.test.js.map +0 -1
  263. package/dist/core/lockfile-support.test.js +0 -112
  264. package/dist/core/lockfile-support.test.js.map +0 -1
  265. package/dist/core/lockfile.test.js +0 -203
  266. package/dist/core/lockfile.test.js.map +0 -1
  267. package/dist/core/mayday.test.js +0 -117
  268. package/dist/core/mayday.test.js.map +0 -1
  269. package/dist/core/mirage.test.js +0 -120
  270. package/dist/core/mirage.test.js.map +0 -1
  271. package/dist/core/mitosis.test.js +0 -170
  272. package/dist/core/mitosis.test.js.map +0 -1
  273. package/dist/core/mock-leak.test.js +0 -79
  274. package/dist/core/mock-leak.test.js.map +0 -1
  275. package/dist/core/mutation.test.js +0 -104
  276. package/dist/core/mutation.test.js.map +0 -1
  277. package/dist/core/opencode.test.js +0 -68
  278. package/dist/core/opencode.test.js.map +0 -1
  279. package/dist/core/oracle.test.js +0 -136
  280. package/dist/core/oracle.test.js.map +0 -1
  281. package/dist/core/osv.test.js +0 -173
  282. package/dist/core/osv.test.js.map +0 -1
  283. package/dist/core/output-format.test.js +0 -102
  284. package/dist/core/output-format.test.js.map +0 -1
  285. package/dist/core/pack.test.js +0 -129
  286. package/dist/core/pack.test.js.map +0 -1
  287. package/dist/core/passport.test.js +0 -173
  288. package/dist/core/passport.test.js.map +0 -1
  289. package/dist/core/patch.test.js +0 -70
  290. package/dist/core/patch.test.js.map +0 -1
  291. package/dist/core/phantom.test.js +0 -58
  292. package/dist/core/phantom.test.js.map +0 -1
  293. package/dist/core/polygraph.test.js +0 -110
  294. package/dist/core/polygraph.test.js.map +0 -1
  295. package/dist/core/pr-comment.test.js +0 -53
  296. package/dist/core/pr-comment.test.js.map +0 -1
  297. package/dist/core/pr-review.test.js +0 -62
  298. package/dist/core/pr-review.test.js.map +0 -1
  299. package/dist/core/preflight.test.js +0 -242
  300. package/dist/core/preflight.test.js.map +0 -1
  301. package/dist/core/presets.test.js +0 -79
  302. package/dist/core/presets.test.js.map +0 -1
  303. package/dist/core/project.test.js +0 -75
  304. package/dist/core/project.test.js.map +0 -1
  305. package/dist/core/prompt.golden.test.js +0 -74
  306. package/dist/core/prompt.golden.test.js.map +0 -1
  307. package/dist/core/prompt.test.js +0 -122
  308. package/dist/core/prompt.test.js.map +0 -1
  309. package/dist/core/quarantine.test.js +0 -98
  310. package/dist/core/quarantine.test.js.map +0 -1
  311. package/dist/core/readiness-fix.test.js +0 -127
  312. package/dist/core/readiness-fix.test.js.map +0 -1
  313. package/dist/core/readiness.test.js +0 -318
  314. package/dist/core/readiness.test.js.map +0 -1
  315. package/dist/core/receipt.test.js +0 -193
  316. package/dist/core/receipt.test.js.map +0 -1
  317. package/dist/core/reviewers.test.js +0 -105
  318. package/dist/core/reviewers.test.js.map +0 -1
  319. package/dist/core/roast.test.js +0 -19
  320. package/dist/core/roast.test.js.map +0 -1
  321. package/dist/core/router.test.js +0 -157
  322. package/dist/core/router.test.js.map +0 -1
  323. package/dist/core/rules.test.js +0 -72
  324. package/dist/core/rules.test.js.map +0 -1
  325. package/dist/core/sarif.test.js +0 -60
  326. package/dist/core/sarif.test.js.map +0 -1
  327. package/dist/core/sast.test.js +0 -119
  328. package/dist/core/sast.test.js.map +0 -1
  329. package/dist/core/sbom.test.js +0 -81
  330. package/dist/core/sbom.test.js.map +0 -1
  331. package/dist/core/scalpel.test.js +0 -132
  332. package/dist/core/scalpel.test.js.map +0 -1
  333. package/dist/core/second-opinion.test.js +0 -89
  334. package/dist/core/second-opinion.test.js.map +0 -1
  335. package/dist/core/secrets.test.js +0 -194
  336. package/dist/core/secrets.test.js.map +0 -1
  337. package/dist/core/shadow.test.js +0 -50
  338. package/dist/core/shadow.test.js.map +0 -1
  339. package/dist/core/skeptic.test.js +0 -106
  340. package/dist/core/skeptic.test.js.map +0 -1
  341. package/dist/core/slicing.test.js +0 -287
  342. package/dist/core/slicing.test.js.map +0 -1
  343. package/dist/core/slop/dead-exports.test.js +0 -29
  344. package/dist/core/slop/dead-exports.test.js.map +0 -1
  345. package/dist/core/slop/slop.test.js +0 -160
  346. package/dist/core/slop/slop.test.js.map +0 -1
  347. package/dist/core/slop/test-debt.test.js +0 -114
  348. package/dist/core/slop/test-debt.test.js.map +0 -1
  349. package/dist/core/snapshot.test.js +0 -101
  350. package/dist/core/snapshot.test.js.map +0 -1
  351. package/dist/core/snippets.test.js +0 -55
  352. package/dist/core/snippets.test.js.map +0 -1
  353. package/dist/core/stats.test.js +0 -86
  354. package/dist/core/stats.test.js.map +0 -1
  355. package/dist/core/suppressions.test.js +0 -98
  356. package/dist/core/suppressions.test.js.map +0 -1
  357. package/dist/core/test-delta.test.js +0 -41
  358. package/dist/core/test-delta.test.js.map +0 -1
  359. package/dist/core/test-plan.test.js +0 -99
  360. package/dist/core/test-plan.test.js.map +0 -1
  361. package/dist/core/test-weakening.test.js +0 -114
  362. package/dist/core/test-weakening.test.js.map +0 -1
  363. package/dist/core/tree-scan.test.js +0 -58
  364. package/dist/core/tree-scan.test.js.map +0 -1
  365. package/dist/core/tribunal.test.js +0 -52
  366. package/dist/core/tribunal.test.js.map +0 -1
  367. package/dist/core/vaccine.test.js +0 -139
  368. package/dist/core/vaccine.test.js.map +0 -1
  369. package/dist/core/warden.test.js +0 -121
  370. package/dist/core/warden.test.js.map +0 -1
  371. package/dist/mcp-http.test.js +0 -146
  372. package/dist/mcp-http.test.js.map +0 -1
  373. package/dist/mcp-prompts.test.js +0 -160
  374. package/dist/mcp-prompts.test.js.map +0 -1
  375. package/dist/mcp.test.js +0 -2108
  376. package/dist/mcp.test.js.map +0 -1
  377. package/dist/setup.test.js +0 -215
  378. package/dist/setup.test.js.map +0 -1
  379. package/dist/skills.test.js +0 -293
  380. package/dist/skills.test.js.map +0 -1
@@ -5,6 +5,7 @@
5
5
  * assertions and stretched timeouts.
6
6
  */
7
7
  import { isTestFile } from "./test-delta.js";
8
+ import { parseGitPath } from "./diff.js";
8
9
  const MAX_REPORTED = 20;
9
10
  const MAX_LISTED = 10;
10
11
  /** Patterns that disable or narrow a test run. */
@@ -22,7 +23,7 @@ const SKIP_PATTERNS = [
22
23
  { re: /\bf(?:it|describe)\s*\(/, kind: "focused-test", detail: "focused-тест (fit/fdescribe)" },
23
24
  ];
24
25
  /** Lines that actually check something, used to compare removed vs added. */
25
- const ASSERTION_RE = /\b(?:expect|assert(?:_eq|_ne|_matches)?|assertEquals?|assertTrue|assertFalse|XCTAssert\w*|require)\s*\(|\bt\.(?:Error|Errorf|Fatal|Fatalf)\s*\(|\bAssert\.\w+\s*\(|\.should\b/;
26
+ const ASSERTION_RE = /\b(?:expect|assert(?:_eq|_ne|_matches)?|assertEquals?|assertTrue|assertFalse|XCTAssert\w*|require)\s*\(|\bassert\.(?:ok|(?:not)?(?:deep)?(?:strict)?equal|match|doesNotMatch|throws|doesNotThrow|rejects|doesNotReject|ifError|fail)\s*\(|\bt\.(?:Error|Errorf|Fatal|Fatalf)\s*\(|\bAssert\.\w+\s*\(|\.should\b/i;
26
27
  /** Assertion that was commented out instead of deleted. */
27
28
  const COMMENTED_ASSERTION_RE = /^\s*(?:\/\/|#|\/\*|\*)\s*(?:expect|assert|Assert|XCTAssert|require)\b/;
28
29
  /** Jest timeout raised to at least 10 seconds. */
@@ -33,19 +34,29 @@ const STRICT_MATCHER_RE = /\.(?:toEqual|toStrictEqual|toBe)\s*\(/;
33
34
  const LOOSE_MATCHER_RE = /\.(?:toBeDefined|toBeTruthy|toBeFalsy)\s*\(|\.not\.(?:toBeNull|toBeUndefined|toBeFalsy)\s*\(/;
34
35
  /** Type-check suppression added to a test instead of fixing the type. */
35
36
  const TYPE_SUPPRESSION_RE = /@ts-(?:ignore|expect-error)\b/;
37
+ const TS_DIRECTIVE_RE = /^\s*(?:\/\/|\/\*|\*)\s*@ts-(?:ignore|nocheck)\b/;
38
+ const LINT_DIRECTIVE_RE = /^\s*(?:\/\/|\/\*|\*)\s*eslint-disable(?:-next-line|-line)?\b/;
39
+ const EXPLICIT_ANY_RE = /^(?!\s*(?:\/\/|\/\*|\*))[^"'`]*?(?:\bas\s+any\b|\b(?:const|let|var)\s+[\w$]+\s*:\s*any\b|\btype\s+[\w$]+\s*=\s*any\b)/;
40
+ const SECURITY_RULE_RE = /^\s*["'](?:security|no-unsanitized)\/[\w-]+["']\s*:\s*(?:\[\s*)?(?:["']off["']|0\b)/;
41
+ const CODE_FILE_RE = /\.[cm]?[jt]sx?$/i;
42
+ const TS_FILE_RE = /\.[cm]?tsx?$/i;
43
+ const LINT_CONFIG_RE = /(?:^|\/)(?:eslint\.config\.[\w]+|\.eslintrc(?:\.[\w]+)?)$/i;
36
44
  /** A catch block with no body swallows the assertion failure. */
37
45
  const SWALLOWED_CATCH_RE = /\bcatch\s*(?:\([^)]*\))?\s*\{\s*\}/;
38
46
  /** Test declarations, used to notice a deleted test that was never replaced. */
39
47
  const TEST_DECLARATION_RE = /\b(?:it|test)\s*\(\s*["'`]([^"'`]+)["'`]/;
40
48
  /**
41
49
  * Scans a unified diff and reports places where tests appear to have been
42
- * weakened. Only added lines of test files produce line hits; removed
43
- * assertions are reported once per file.
50
+ * weakened, or code adds a recognizable type/lint suppression. Removed
51
+ * assertions are reported once per test file.
44
52
  */
45
53
  export function analyzeTestWeakness(diff) {
46
54
  const findings = [];
47
55
  const files = [];
48
56
  let current;
57
+ let path = "";
58
+ let oldPath = "";
59
+ let inHunk = false;
49
60
  let nextLine = 0;
50
61
  let hunkRemovedStrict = false;
51
62
  const flush = () => {
@@ -55,12 +66,24 @@ export function analyzeTestWeakness(diff) {
55
66
  current = undefined;
56
67
  };
57
68
  for (const line of diff.split(/\r?\n/)) {
58
- if (line.startsWith("+++ ")) {
69
+ if (line.startsWith("diff --git ")) {
70
+ inHunk = false;
71
+ oldPath = "";
72
+ path = "";
59
73
  flush();
60
- const file = line.slice(4).replace(/^b\//, "").trim();
61
- current = isTestFile(file)
74
+ continue;
75
+ }
76
+ if (!inHunk && line.startsWith("--- ")) {
77
+ oldPath = parseGitPath(line.slice(4));
78
+ continue;
79
+ }
80
+ if (!inHunk && line.startsWith("+++ ")) {
81
+ flush();
82
+ const file = parseGitPath(line.slice(4));
83
+ path = file === "/dev/null" ? oldPath : file;
84
+ current = isTestFile(path)
62
85
  ? {
63
- file,
86
+ file: path,
64
87
  added: 0,
65
88
  removed: 0,
66
89
  firstRemovedLine: 0,
@@ -70,21 +93,22 @@ export function analyzeTestWeakness(diff) {
70
93
  : undefined;
71
94
  continue;
72
95
  }
73
- if (line.startsWith("@@")) {
74
- const match = /\+(\d+)/.exec(line.slice(2));
96
+ if (line.startsWith("@@ ")) {
97
+ const match = /^@@ -\d+(?:,\d+)? \+(\d+)/.exec(line);
98
+ inHunk = match !== null;
75
99
  if (match)
76
- nextLine = Number(match[1]);
100
+ nextLine = Math.max(1, Number(match[1]));
77
101
  hunkRemovedStrict = false;
78
102
  continue;
79
103
  }
80
- if (!current)
81
- continue;
82
- if (line.startsWith("---") || line.startsWith("diff --git"))
104
+ if (!inHunk || !path)
83
105
  continue;
84
106
  const added = line.startsWith("+");
85
- const removed = line.startsWith("-") && !line.startsWith("---");
107
+ const removed = line.startsWith("-");
86
108
  const body = line.slice(1);
87
109
  if (removed) {
110
+ if (!current)
111
+ continue;
88
112
  if (ASSERTION_RE.test(body)) {
89
113
  current.removed += 1;
90
114
  if (current.firstRemovedLine === 0)
@@ -99,12 +123,30 @@ export function analyzeTestWeakness(diff) {
99
123
  continue;
100
124
  }
101
125
  if (!added) {
102
- nextLine += 1;
126
+ if (line.startsWith(" "))
127
+ nextLine += 1;
103
128
  continue;
104
129
  }
105
130
  const lineNumber = nextLine;
106
131
  nextLine += 1;
107
- if (ASSERTION_RE.test(body))
132
+ const report = (kind, detail) => {
133
+ findings.push({ file: path, line: lineNumber, kind, detail });
134
+ };
135
+ if (CODE_FILE_RE.test(path) && LINT_DIRECTIVE_RE.test(body)) {
136
+ report("disabled-lint", "Добавлено отключение ESLint");
137
+ }
138
+ if (TS_FILE_RE.test(path) && EXPLICIT_ANY_RE.test(body)) {
139
+ report("explicit-any", "Добавлен явный тип any");
140
+ }
141
+ if (LINT_CONFIG_RE.test(path) && SECURITY_RULE_RE.test(body)) {
142
+ report("weakened-security-rule", "Отключено правило безопасности ESLint");
143
+ }
144
+ if ((!current || !TYPE_SUPPRESSION_RE.test(body)) && CODE_FILE_RE.test(path) && TS_DIRECTIVE_RE.test(body)) {
145
+ report("suppressed-type-check", "Добавлено отключение проверки типов");
146
+ }
147
+ if (!current)
148
+ continue;
149
+ if (ASSERTION_RE.test(body) && !COMMENTED_ASSERTION_RE.test(body))
108
150
  current.added += 1;
109
151
  const addedTest = TEST_DECLARATION_RE.exec(body);
110
152
  if (addedTest?.[1])
@@ -1 +1 @@
1
- {"version":3,"file":"test-weakening.js","sourceRoot":"","sources":["../../src/core/test-weakening.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAoB7C,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,kDAAkD;AAClD,MAAM,aAAa,GAAkE;IACnF,EAAE,EAAE,EAAE,iDAAiD,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,wBAAwB,EAAE;IACjH,EAAE,EAAE,EAAE,iDAAiD,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,wBAAwB,EAAE;IACjH,EAAE,EAAE,EAAE,gCAAgC,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,2BAA2B,EAAE;IACnG,EAAE,EAAE,EAAE,0BAA0B,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE;IACrF,EAAE,EAAE,EAAE,iCAAiC,EAAE,IAAI,EAAE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AI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACxH,IAAI,QAAQ,CAAC,MAAM,GAAG,UAAU;QAAE,MAAM,CAAC,IAAI,CAAC,YAAY,QAAQ,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC,CAAC;IAC1F,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
package/dist/mcp.js CHANGED
@@ -9,6 +9,7 @@ import { createInterface } from "node:readline";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import { loadConfig } from "./core/config.js";
11
11
  import { runGit } from "./core/git.js";
12
+ import { collectMetrics } from "./core/metrics.js";
12
13
  import { SYSTEM_PROMPT_EN, SYSTEM_PROMPT_RU } from "./core/prompt.js";
13
14
  import { loadRules } from "./core/rules.js";
14
15
  import { loadSecretIgnore, scanDiff, scanText } from "./core/secrets.js";
@@ -1026,6 +1027,22 @@ const TOOLS = [
1026
1027
  },
1027
1028
  },
1028
1029
  },
1030
+ {
1031
+ name: "check",
1032
+ description: "Run the complete offline read-only quality gate for the current change. Use this first when asked whether a change is safe to commit. Accepts at most one change selector: staged, unstaged, base, diff, or include_untracked. Returns status pass, fail, or incomplete, compact check summaries, and one safe next command; never returns finding details, source excerpts, or secret values. A fail is a policy verdict, not a tool error. Incomplete means one or more checks could not run; do not treat it as pass.",
1033
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1034
+ inputSchema: {
1035
+ type: "object",
1036
+ additionalProperties: false,
1037
+ properties: {
1038
+ diff: { type: "string", description: "Unified diff text, not a path" },
1039
+ base: { type: "string", description: "Compare committed HEAD with this base ref, e.g. origin/main" },
1040
+ staged: { type: "boolean", description: "Check staged changes only" },
1041
+ unstaged: { type: "boolean", description: "Check unstaged changes only" },
1042
+ include_untracked: { type: "boolean", description: "Include untracked files when checking working changes" },
1043
+ },
1044
+ },
1045
+ },
1029
1046
  {
1030
1047
  name: "preflight",
1031
1048
  description: "One offline verdict before a commit: secrets, SAST, route authorization, dependency health scoped to the change, test weakening and the Slop Index delta. Uses git and local files only and never calls a model, so it is free and safe in read-only mode. A failed check returns status fail with exit code 1, not a tool error.",
@@ -1982,7 +1999,7 @@ const TOOLS = [
1982
1999
  },
1983
2000
  {
1984
2001
  name: "receipt_verify",
1985
- description: "Verify the oc-pilot receipt for the current HEAD: recompute its SHA-256 hash, compare the recorded commit with HEAD and report whether the recorded tests passed. Read-only and offline, so it is free and safe in read-only mode. A missing, edited or stale receipt returns exit code 1 with ok=false, not a tool error.",
2002
+ description: "Verify receipt integrity and freshness for HEAD, then report evidence separately: tests must have passed and all required preflight checks must have run without skips for evidenceStatus=complete. ok=true only means the receipt is intact and current; it does not by itself prove the work is complete. Read-only and offline. A missing, edited or stale receipt returns exit code 1 with ok=false, not a tool error.",
1986
2003
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
1987
2004
  inputSchema: {
1988
2005
  type: "object",
@@ -2013,6 +2030,15 @@ const TOOLS = [
2013
2030
  },
2014
2031
  },
2015
2032
  ];
2033
+ const METRICS_TOOL = {
2034
+ name: "metrics",
2035
+ description: "Summarize operator-configured local logs. Takes no arguments. Returns level counts, counts by approved exception type, and count/p50/p95/max for recorded durations in milliseconds. Does not return log messages, stack traces, or paths.",
2036
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
2037
+ inputSchema: { type: "object", properties: {}, additionalProperties: false },
2038
+ };
2039
+ const COMPACT_TOOL_NAMES = new Set(["check", "review", "scan", "test_guard", "boundaries", "flight_prove"]);
2040
+ const COMPACT_TOOLS = TOOLS.filter((tool) => COMPACT_TOOL_NAMES.has(tool.name));
2041
+ const COMPACT_PROMPT_NAMES = new Set(["review-my-diff", "secure-change", "preflight-before-commit"]);
2016
2042
  const PROMPTS = [
2017
2043
  {
2018
2044
  name: "review-my-diff",
@@ -3999,6 +4025,55 @@ async function callPreflight(input, cwd) {
3999
4025
  temp.cleanup();
4000
4026
  }
4001
4027
  }
4028
+ async function callCheck(input, cwd) {
4029
+ const selectors = [
4030
+ stringArg(input, "diff") !== undefined,
4031
+ stringArg(input, "base") !== undefined,
4032
+ booleanArg(input, "staged"),
4033
+ booleanArg(input, "unstaged"),
4034
+ ].filter(Boolean).length;
4035
+ if (selectors > 1) {
4036
+ throw new ToolInputError("Choose one check scope: diff, base, staged, or unstaged. include_untracked may accompany staged or unstaged.");
4037
+ }
4038
+ const result = await callPreflight(input, cwd);
4039
+ const report = result.structuredContent;
4040
+ const checks = Array.isArray(report?.checks) ? report.checks : undefined;
4041
+ if (!checks || !checks.every((item) => item && typeof item === "object")) {
4042
+ return {
4043
+ content: [{ type: "text", text: "Check incomplete: preflight did not return a structured report. Retry with `oc-pilot check preflight --json` and inspect the local CLI error." }],
4044
+ structuredContent: {
4045
+ status: "incomplete",
4046
+ checks: [],
4047
+ next: "oc-pilot check preflight --json",
4048
+ },
4049
+ isError: true,
4050
+ _meta: { exitCode: 2, policyFailed: false },
4051
+ };
4052
+ }
4053
+ const summaries = checks.map((item) => {
4054
+ const check = item;
4055
+ return {
4056
+ id: typeof check.id === "string" ? check.id : "unknown",
4057
+ status: check.status === "pass" || check.status === "fail" || check.status === "skip" ? check.status : "skip",
4058
+ summary: check.status === "pass" ? "Passed" : check.status === "fail" ? "Blocking findings detected" : "Skipped or unavailable",
4059
+ };
4060
+ });
4061
+ const failed = summaries.some((item) => item.status === "fail");
4062
+ const incomplete = summaries.some((item) => item.status === "skip") || result.isError === true;
4063
+ const status = failed ? "fail" : incomplete ? "incomplete" : "pass";
4064
+ const next = failed
4065
+ ? "Review the failed checks, then rerun `oc-pilot check preflight --staged`"
4066
+ : incomplete
4067
+ ? "Resolve unavailable checks, then rerun `oc-pilot check preflight --staged`"
4068
+ : "No blocking findings; rerun `oc-pilot check preflight --staged` before committing staged changes";
4069
+ const structuredContent = { status, complete: !incomplete, checks: summaries, next };
4070
+ return {
4071
+ content: [{ type: "text", text: JSON.stringify(structuredContent, null, 2) }],
4072
+ structuredContent,
4073
+ isError: status === "incomplete",
4074
+ _meta: { exitCode: status === "fail" ? 1 : status === "incomplete" ? 2 : 0, policyFailed: status === "fail" },
4075
+ };
4076
+ }
4002
4077
  async function callHoneypot(input, cwd) {
4003
4078
  const action = stringArg(input, "action", true);
4004
4079
  const args = ["honeypot", action, "--json"];
@@ -5152,6 +5227,8 @@ async function dispatchTool(name, input, cwd, readOnly) {
5152
5227
  }
5153
5228
  }
5154
5229
  switch (name) {
5230
+ case "check":
5231
+ return callCheck(input, cwd);
5155
5232
  case "review":
5156
5233
  return callReview(input, cwd);
5157
5234
  case "test_fix":
@@ -5998,12 +6075,12 @@ function promptBody(name, args) {
5998
6075
  case "prove-tests":
5999
6076
  return `Call the oc-pilot "mutate" tool on the current change with max_mutants=20 and min_score=80. Each surviving mutant is a behavior the tests do not protect: add or strengthen the smallest test that would kill it, then call "mutate" again. Do not change production code only to satisfy a mutant, do not weaken assertions, and do not lower min_score to get a pass. Report the mutation score, the surviving mutants with file:line, and the tests you added.${suffix}`;
6000
6077
  case "prove-done":
6001
- return `Do not say the work is done yet. Call the oc-pilot "receipt_verify" tool. A valid proof has ok=true, hashOk=true, stale=false and tests.passed=true for the current HEAD. If the receipt is missing, stale or reports failing tests, run the suite and create a fresh receipt with oc-pilot receipt, then call "receipt_verify" again. Use oc-pilot receipt --no-run only when tests cannot run here, and say so explicitly. Never edit a receipt by hand and never claim completion while ok is false or tests.passed is false. Report the receipt path, the commit and what was verified.${suffix}`;
6078
+ return `Do not say the work is done yet. Call the oc-pilot "receipt_verify" tool. A complete proof requires ok=true, hashOk=true, stale=false, evidenceStatus="complete", testsStatus="passed" and preflightStatus="passed" for the current HEAD. Signature status must be valid when a trusted public key is configured; unchecked means authenticity was not verified. If the receipt is missing, stale, incomplete or reports failed tests/checks, run the required checks and create a fresh receipt with oc-pilot receipt, then call "receipt_verify" again. Use oc-pilot receipt --no-run only when tests cannot run here, and say explicitly that evidence is incomplete. Never edit a receipt by hand and never claim completion while integrity fails or evidenceStatus is not complete. Report the receipt path, the commit, integrity status and evidence status.${suffix}`;
6002
6079
  default:
6003
6080
  return `Review my change with the oc-pilot "review" tool.${suffix}`;
6004
6081
  }
6005
6082
  }
6006
- async function processMessage(message, cwd, readOnly) {
6083
+ async function processMessage(message, cwd, readOnly, profile, metricsLogs) {
6007
6084
  const id = message.id;
6008
6085
  const method = message.method;
6009
6086
  const params = asObject(message.params);
@@ -6012,6 +6089,10 @@ async function processMessage(message, cwd, readOnly) {
6012
6089
  }
6013
6090
  if (method.startsWith("notifications/"))
6014
6091
  return undefined;
6092
+ const catalog = profile === "full" ? TOOLS : COMPACT_TOOLS;
6093
+ const tools = metricsLogs ? [...catalog, METRICS_TOOL] : catalog;
6094
+ const prompts = profile === "full" ? PROMPTS : PROMPTS.filter((prompt) => COMPACT_PROMPT_NAMES.has(prompt.name));
6095
+ const offlineTools = tools.filter((tool) => tool.name === "metrics" || OFFLINE_TOOLS.has(tool.name)).map((tool) => tool.name).join(", ");
6015
6096
  if (method === "logging/setLevel") {
6016
6097
  const level = params?.level;
6017
6098
  if (typeof level !== "string") {
@@ -6032,16 +6113,16 @@ async function processMessage(message, cwd, readOnly) {
6032
6113
  resourceTemplates: { listChanged: false },
6033
6114
  },
6034
6115
  serverInfo: { name: SERVER_NAME, version: VERSION },
6035
- instructions: `oc-pilot analyzes diffs and failing tests. Tools return JSON; secret values are redacted before model calls whenever possible. Prompts (prompts/list) wrap the common flows: review my diff, fix failing tests, pre-commit gate, security review, agent readiness, prove done. Read-only context is also exposed as resources (oc-pilot://config, oc-pilot://rules, oc-pilot://prompt/en|ru, oc-pilot://version) and resource templates (oc-pilot://diff/{mode}, oc-pilot://scan/{mode}, oc-pilot://file/{+path}). Offline tools (scan, stats, slop, sast, authz, preflight, ready, receipt_verify) never call a model and keep working even after the call budget is exhausted; oc-pilot://slop exposes the Slop Index report and the slop-check prompt frames the entropy question.${readOnly ? " This server is read-only: fix apply, commit apply, running new tests and clearing stats are disabled." : ""}`,
6116
+ instructions: `oc-pilot checks code changes and returns JSON. Use tools/list and prompts/list for the workflows available in this profile. Read-only context is available through resources and resource templates. Offline tools (${offlineTools}) do not use the model-call budget.${profile === "compact" ? " An operator can start the server with --mcp-profile=full for the full catalog." : ""}${readOnly ? " This server is read-only: fix apply, commit apply, running new tests and clearing stats are disabled." : ""}`,
6036
6117
  });
6037
6118
  }
6038
6119
  if (method === "ping")
6039
6120
  return rpcResult(id, {});
6040
6121
  if (method === "tools/list")
6041
- return rpcResult(id, { tools: TOOLS });
6122
+ return rpcResult(id, { tools });
6042
6123
  if (method === "prompts/list") {
6043
6124
  return rpcResult(id, {
6044
- prompts: PROMPTS.map((prompt) => ({
6125
+ prompts: prompts.map((prompt) => ({
6045
6126
  name: prompt.name,
6046
6127
  title: prompt.title,
6047
6128
  description: prompt.description,
@@ -6054,7 +6135,7 @@ async function processMessage(message, cwd, readOnly) {
6054
6135
  if (typeof name !== "string" || name.trim() === "") {
6055
6136
  return rpcError(id, -32602, "Invalid params: prompts/get requires a prompt name");
6056
6137
  }
6057
- const prompt = PROMPTS.find((candidate) => candidate.name === name);
6138
+ const prompt = prompts.find((candidate) => candidate.name === name);
6058
6139
  if (!prompt)
6059
6140
  return rpcError(id, -32602, `Unknown prompt: ${name}`);
6060
6141
  const args = asObject(params?.arguments) ?? {};
@@ -6088,12 +6169,32 @@ async function processMessage(message, cwd, readOnly) {
6088
6169
  if (typeof name !== "string") {
6089
6170
  return rpcError(id, -32602, "Invalid params: tools/call requires a tool name");
6090
6171
  }
6172
+ if (!tools.some((tool) => tool.name === name)) {
6173
+ const text = profile === "compact" && TOOLS.some((tool) => tool.name === name)
6174
+ ? `Tool not available in the compact profile: ${name}. Ask the operator to start the server with --mcp-profile=full.`
6175
+ : `Unknown tool: ${name}`;
6176
+ return rpcResult(id, { content: [{ type: "text", text }], isError: true });
6177
+ }
6178
+ if (name === "metrics" && metricsLogs) {
6179
+ const args = params?.arguments;
6180
+ const input = asObject(args);
6181
+ if (args !== undefined && (!input || Object.keys(input).length !== 0)) {
6182
+ return rpcResult(id, { content: [{ type: "text", text: "metrics takes no arguments. Call it with an empty object." }], isError: true });
6183
+ }
6184
+ try {
6185
+ const structuredContent = { ...collectMetrics(metricsLogs) };
6186
+ return rpcResult(id, { content: [{ type: "text", text: JSON.stringify(structuredContent) }], structuredContent });
6187
+ }
6188
+ catch {
6189
+ return rpcResult(id, { content: [{ type: "text", text: "Metrics unavailable. Ask the operator to check the configured log source and collection limits." }], isError: true });
6190
+ }
6191
+ }
6091
6192
  if (!OFFLINE_TOOLS.has(name) && maxToolCalls > 0 && toolCallsUsed >= maxToolCalls) {
6092
6193
  return rpcResult(id, {
6093
6194
  content: [
6094
6195
  {
6095
6196
  type: "text",
6096
- text: `Tool budget exhausted (${maxToolCalls} model-backed calls per session). Restart the server to reset, raise --max-calls, or use the offline tools: scan, stats, slop, sast, authz, preflight, ready, receipt_verify.`,
6197
+ text: `Tool budget exhausted (${maxToolCalls} model-backed calls per session). Restart the server to reset, raise --max-calls, or use the offline tools: ${offlineTools}.`,
6097
6198
  },
6098
6199
  ],
6099
6200
  isError: true,
@@ -6146,7 +6247,7 @@ async function processMessage(message, cwd, readOnly) {
6146
6247
  }
6147
6248
  return rpcError(id ?? null, -32601, `Method not found: ${method}`);
6148
6249
  }
6149
- async function processPayload(message, cwd, readOnly) {
6250
+ async function processPayload(message, cwd, readOnly, profile, metricsLogs) {
6150
6251
  if (Array.isArray(message)) {
6151
6252
  if (message.length === 0)
6152
6253
  return rpcError(null, -32600, "Invalid Request: empty batch");
@@ -6156,7 +6257,7 @@ async function processPayload(message, cwd, readOnly) {
6156
6257
  responses.push(rpcError(null, -32600, "Invalid Request"));
6157
6258
  continue;
6158
6259
  }
6159
- const response = await processMessage(item, cwd, readOnly);
6260
+ const response = await processMessage(item, cwd, readOnly, profile, metricsLogs);
6160
6261
  if (response)
6161
6262
  responses.push(response);
6162
6263
  }
@@ -6165,9 +6266,9 @@ async function processPayload(message, cwd, readOnly) {
6165
6266
  if (!message || typeof message !== "object") {
6166
6267
  return rpcError(null, -32600, "Invalid Request");
6167
6268
  }
6168
- return processMessage(message, cwd, readOnly);
6269
+ return processMessage(message, cwd, readOnly, profile, metricsLogs);
6169
6270
  }
6170
- async function serveStdio(cwd, readOnly) {
6271
+ async function serveStdio(cwd, readOnly, profile, metricsLogs) {
6171
6272
  emitNotification = (message) => writeMessage(message);
6172
6273
  const lines = createInterface({ input: process.stdin, crlfDelay: Infinity });
6173
6274
  for await (const line of lines) {
@@ -6182,7 +6283,7 @@ async function serveStdio(cwd, readOnly) {
6182
6283
  writeMessage(rpcError(null, -32700, "Parse error"));
6183
6284
  continue;
6184
6285
  }
6185
- const response = await processPayload(message, cwd, readOnly);
6286
+ const response = await processPayload(message, cwd, readOnly, profile, metricsLogs);
6186
6287
  if (response)
6187
6288
  writeMessage(response);
6188
6289
  }
@@ -6235,7 +6336,7 @@ async function readBody(request, limit = 16 * 1024 * 1024) {
6235
6336
  request.on("error", reject);
6236
6337
  });
6237
6338
  }
6238
- async function startHttp(cwd, config) {
6339
+ async function startHttp(cwd, config, profile, metricsLogs) {
6239
6340
  const server = createServer(async (request, response) => {
6240
6341
  const url = new URL(request.url ?? "/", "http://localhost");
6241
6342
  const cors = corsHeaders(config);
@@ -6283,7 +6384,7 @@ async function startHttp(cwd, config) {
6283
6384
  }
6284
6385
  let result;
6285
6386
  try {
6286
- result = await processPayload(message, cwd, config.readOnly);
6387
+ result = await processPayload(message, cwd, config.readOnly, profile, metricsLogs);
6287
6388
  }
6288
6389
  catch (error) {
6289
6390
  sendJson(response, 500, rpcError(null, -32603, `Internal error: ${error instanceof Error ? error.message : String(error)}`), cors);
@@ -6329,6 +6430,8 @@ Options:
6329
6430
  --token <token> Require Authorization: Bearer <token>
6330
6431
  --cors <origin> Add CORS headers for an origin, or *
6331
6432
  --max-calls <n> Model-backed tool calls per session, 0 disables the limit (default: 50)
6433
+ --mcp-profile <compact|full> Tool and prompt catalog (default: compact)
6434
+ --metrics-logs <file|dir> Enable aggregate-only metrics for a trusted log source
6332
6435
  --read-only Disable fix --apply and running new tests (default)
6333
6436
  --allow-write Enable fix --apply and running new tests
6334
6437
  -h, --help Show this help
@@ -6361,12 +6464,14 @@ function parseServerArgs(argv) {
6361
6464
  let readOnly = envReadOnly === "1" || envReadOnly === "true" ? true : envReadOnly === "0" || envReadOnly === "false" ? false : undefined;
6362
6465
  let allowWrite = false;
6363
6466
  let maxCalls = Number(process.env.OC_PILOT_MCP_MAX_CALLS ?? "50");
6467
+ let profile = "compact";
6468
+ let metricsLogs;
6364
6469
  for (let index = 0; index < argv.length; index += 1) {
6365
6470
  const arg = argv[index];
6366
6471
  if (arg === "--help" || arg === "-h")
6367
- return { cwd, action: "help", readOnly: false, maxCalls };
6472
+ return { cwd, action: "help", readOnly: false, maxCalls, profile };
6368
6473
  if (arg === "--version" || arg === "-V")
6369
- return { cwd, action: "version", readOnly: false, maxCalls };
6474
+ return { cwd, action: "version", readOnly: false, maxCalls, profile };
6370
6475
  if (arg === "--http") {
6371
6476
  http = true;
6372
6477
  continue;
@@ -6414,6 +6519,17 @@ function parseServerArgs(argv) {
6414
6519
  maxCalls = Number(next());
6415
6520
  continue;
6416
6521
  }
6522
+ if (arg === "--mcp-profile" || arg.startsWith("--mcp-profile=")) {
6523
+ const value = arg === "--mcp-profile" ? next() : arg.slice("--mcp-profile=".length);
6524
+ if (value !== "compact" && value !== "full")
6525
+ throw new Error("--mcp-profile must be compact or full");
6526
+ profile = value;
6527
+ continue;
6528
+ }
6529
+ if (arg === "--metrics-logs") {
6530
+ metricsLogs = next();
6531
+ continue;
6532
+ }
6417
6533
  throw new Error(`Unknown option: ${arg}`);
6418
6534
  }
6419
6535
  if (!existsSync(cwd) || !statSync(cwd).isDirectory()) {
@@ -6436,6 +6552,8 @@ function parseServerArgs(argv) {
6436
6552
  cwd,
6437
6553
  readOnly: effectiveReadOnly,
6438
6554
  maxCalls,
6555
+ profile,
6556
+ metricsLogs: metricsLogs === undefined ? undefined : resolve(cwd, metricsLogs),
6439
6557
  ...(http ? { http: { host, port, path, token, cors, readOnly: effectiveReadOnly } } : {}),
6440
6558
  };
6441
6559
  }
@@ -6467,7 +6585,7 @@ export async function runMcp(argv = process.argv.slice(2)) {
6467
6585
  process.stderr.write("oc-pilot-mcp: token must be at least 16 characters for a non-loopback bind.\n");
6468
6586
  return 2;
6469
6587
  }
6470
- const server = await startHttp(parsed.cwd, parsed.http);
6588
+ const server = await startHttp(parsed.cwd, parsed.http, parsed.profile, parsed.metricsLogs);
6471
6589
  const shutdown = () => {
6472
6590
  server.close(() => process.exit(0));
6473
6591
  };
@@ -6479,7 +6597,7 @@ export async function runMcp(argv = process.argv.slice(2)) {
6479
6597
  if (error.code === "EPIPE")
6480
6598
  process.exit(0);
6481
6599
  });
6482
- await serveStdio(parsed.cwd, parsed.readOnly);
6600
+ await serveStdio(parsed.cwd, parsed.readOnly, parsed.profile, parsed.metricsLogs);
6483
6601
  return 0;
6484
6602
  }
6485
6603
  if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {