@imenam/mcp-dependabot-tracker 1.0.10 → 1.0.12
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 +33 -14
- package/dist/shared/alerts.d.ts +6 -1
- package/dist/shared/alerts.js +7 -0
- package/dist/shared/schemas/api.schema.d.ts +41 -9
- package/dist/shared/schemas/api.schema.js +5 -1
- package/dist/shared/schemas/ipc.schema.d.ts +1 -1
- package/dist/shared/schemas/ipc.schema.js +2 -0
- package/dist/shared/schemas/model.schema.d.ts +159 -7
- package/dist/shared/schemas/model.schema.js +63 -8
- package/dist/src/core/analysis.d.ts +26 -1
- package/dist/src/core/analysis.js +6 -3
- package/dist/src/core/audit-all.d.ts +6 -6
- package/dist/src/core/audit-all.js +6 -6
- package/dist/src/core/claude.d.ts +2 -0
- package/dist/src/core/claude.js +8 -4
- package/dist/src/core/commands.d.ts +2 -2
- package/dist/src/core/commands.js +1 -1
- package/dist/src/core/github.js +2 -1
- package/dist/src/core/npm-sandbox.d.ts +17 -0
- package/dist/src/core/npm-sandbox.js +89 -0
- package/dist/src/core/operations.d.ts +22 -12
- package/dist/src/core/operations.js +239 -44
- package/dist/src/core/organizer.d.ts +14 -0
- package/dist/src/core/organizer.js +17 -2
- package/dist/src/core/repair.d.ts +38 -0
- package/dist/src/core/repair.js +191 -0
- package/dist/src/core/repos.d.ts +11 -8
- package/dist/src/core/repos.js +38 -20
- package/dist/src/core/store.d.ts +2 -0
- package/dist/src/core/store.js +14 -5
- package/dist/src/gui-worker.js +20 -3
- package/dist/src/index.js +23 -8
- package/dist/src/npm-tools.d.ts +10 -0
- package/dist/src/npm-tools.js +136 -0
- package/dist/src/tools/format.js +20 -8
- package/dist/src/tools/tools.js +8 -6
- package/dist/src/tools/types.d.ts +2 -0
- package/dist/src/tools/types.js +9 -0
- package/gui/dist/assets/index-D98CR3xl.js +64 -0
- package/gui/dist/assets/index-DETLqB3f.css +1 -0
- package/gui/dist/index.html +2 -2
- package/package.json +1 -1
- package/gui/dist/assets/index-C1Ml-XiM.css +0 -1
- package/gui/dist/assets/index-DQPqW5Uq.js +0 -64
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { RepairReportSchema, TEST_OUTCOMES } from "../../shared/schemas/model.schema.js";
|
|
7
|
+
import { ORGANIZER_SERVER, factsJson, organizerServer } from "./analysis.js";
|
|
8
|
+
import { runClaudeSession } from "./claude.js";
|
|
9
|
+
import { tail } from "./commands.js";
|
|
10
|
+
import { TrackerError } from "./errors.js";
|
|
11
|
+
import { OrganizerClient } from "./organizer.js";
|
|
12
|
+
import { organizerConnection } from "./settings.js";
|
|
13
|
+
/**
|
|
14
|
+
* Corrections par Claude des vulnérabilités que `npm audit fix` laisse dans un
|
|
15
|
+
* clone, d'après la tâche de l'analyse et les commentaires que l'utilisateur y
|
|
16
|
+
* a laissés. Claude modifie le clone (Read, Grep, Glob, Edit, Write), sans git
|
|
17
|
+
* ni écriture hors du clone, et lance les commandes npm (lockfile, audit,
|
|
18
|
+
* installation, tests) par les outils du serveur `npm-tools`, que le tracker
|
|
19
|
+
* exécute dans son propre bac à sable, sans aucun token. Il crée
|
|
20
|
+
* une sous-tâche « rapport de développement » de la tâche de l'analyse, ou met
|
|
21
|
+
* à jour celle d'un passage précédent, puis rend un rapport structuré. Le
|
|
22
|
+
* tracker relit la sous-tâche sur l'organizer : absente, rattachée à une autre
|
|
23
|
+
* tâche, mal assignée ou mal taguée, elle fait échouer les corrections.
|
|
24
|
+
*/
|
|
25
|
+
/** Outils organizer autorisés ; tout autre appel est refusé par `dontAsk`. */
|
|
26
|
+
const ORGANIZER_TOOLS = ["get_task", "create_task", "update_task", "set_assignees", "set_tags"];
|
|
27
|
+
/** Serveur MCP des commandes npm, dans la configuration de la session. */
|
|
28
|
+
const NPM_SERVER = "npm";
|
|
29
|
+
/** Outils du serveur `npm-tools`. */
|
|
30
|
+
const NPM_TOOLS = ["npm_install_lockfile", "npm_audit", "npm_ci", "npm_test", "npm_run", "npm_ls", "tsc"];
|
|
31
|
+
/** Réglages de la session : Edit et Write refusent tout chemin hors du clone. */
|
|
32
|
+
const SESSION_SETTINGS = { permissions: { blockWritesOutsideWorkingDirectories: true } };
|
|
33
|
+
/** Lancement du serveur `npm-tools` du tracker sur le clone et le cache npm de l'opération. */
|
|
34
|
+
function npmServer(input, cache) {
|
|
35
|
+
const entry = fileURLToPath(new URL("../npm-tools.js", import.meta.url));
|
|
36
|
+
return { command: process.execPath, args: [entry, "--root", input.cwd, "--cache", cache, "--scope", input.scope] };
|
|
37
|
+
}
|
|
38
|
+
/** Bac à sable minimal, du type de ceux où le tracker lance les commandes npm sous Linux. */
|
|
39
|
+
const BWRAP_PROBE = ["--ro-bind", "/", "/", "--dev", "/dev", "--proc", "/proc", "--unshare-user", "--unshare-pid", "--unshare-net", "true"];
|
|
40
|
+
/** Durée maximale du test de bubblewrap. */
|
|
41
|
+
const BWRAP_PROBE_TIMEOUT_MS = 10_000;
|
|
42
|
+
/**
|
|
43
|
+
* Vérifie, sous Linux, que bubblewrap crée un bac à sable pour le compte et
|
|
44
|
+
* avec les restrictions du serveur : le tracker s'en sert pour lancer les
|
|
45
|
+
* commandes npm de Claude, et Claude Code refuse de démarrer sans lui. Lève une erreur qui
|
|
46
|
+
* dit quoi installer ou régler ; sans effet sur les autres systèmes.
|
|
47
|
+
*/
|
|
48
|
+
export function assertSandboxAvailable(platform = process.platform, command = "bwrap") {
|
|
49
|
+
if (platform !== "linux")
|
|
50
|
+
return Promise.resolve();
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
const child = spawn(command, BWRAP_PROBE, { stdio: ["ignore", "ignore", "pipe"], timeout: BWRAP_PROBE_TIMEOUT_MS });
|
|
53
|
+
let stderr = "";
|
|
54
|
+
child.stderr.on("data", (chunk) => (stderr += String(chunk)));
|
|
55
|
+
child.on("error", (err) => reject(new TrackerError(err.code === "ENOENT"
|
|
56
|
+
? "The fixes by Claude need bubblewrap (bwrap), which isolates the npm commands of Claude on Linux, and it is not in the PATH of the MCP server. Install it on the server: sudo apt-get install -y bubblewrap socat"
|
|
57
|
+
: `The fixes by Claude need bubblewrap (bwrap), which could not be started: ${err.message}`)));
|
|
58
|
+
child.on("close", (code) => {
|
|
59
|
+
if (code === 0)
|
|
60
|
+
return resolve();
|
|
61
|
+
reject(new TrackerError(`bubblewrap (bwrap) is installed but cannot create a sandbox for the account of the MCP server${stderr.trim() ? `: ${tail(stderr, 3)}` : "."} ` +
|
|
62
|
+
"Check the AppArmor restriction on user namespaces (kernel.apparmor_restrict_unprivileged_userns on Ubuntu 24.04 and later) and the hardening of the service (RestrictNamespaces, PrivateUsers, SystemCallFilter)."));
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/** Résultat demandé à Claude : le rapport et la clé de la sous-tâche. */
|
|
67
|
+
const OutputSchema = RepairReportSchema.extend({ task: z.string().min(1), commitMessage: z.string().trim().min(1) });
|
|
68
|
+
const OUTPUT_JSON_SCHEMA = {
|
|
69
|
+
type: "object",
|
|
70
|
+
additionalProperties: false,
|
|
71
|
+
required: ["task", "summary", "changes", "commitMessage", "tests"],
|
|
72
|
+
properties: {
|
|
73
|
+
task: { type: "string", description: "Key of the development report sub-task, e.g. ORG-43." },
|
|
74
|
+
summary: { type: "string", description: "One or two sentences, in French." },
|
|
75
|
+
changes: {
|
|
76
|
+
type: "array",
|
|
77
|
+
description: "Every file you changed; empty when none.",
|
|
78
|
+
items: {
|
|
79
|
+
type: "object",
|
|
80
|
+
additionalProperties: false,
|
|
81
|
+
required: ["file", "change"],
|
|
82
|
+
properties: { file: { type: "string", description: "Path relative to the repository root." }, change: { type: "string", description: "A few words, in French." } },
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
commitMessage: { type: "string", description: "Conventional commit message in English, first line under 72 characters." },
|
|
86
|
+
tests: {
|
|
87
|
+
type: "object",
|
|
88
|
+
additionalProperties: false,
|
|
89
|
+
required: ["outcome", "detail"],
|
|
90
|
+
properties: { outcome: { type: "string", enum: [...TEST_OUTCOMES] }, detail: { type: "string", description: "One sentence, in French." } },
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
function prompt(input, space, owner, tag) {
|
|
95
|
+
const fixes = input.forceApplied ? "`npm audit fix` and `npm audit fix --force`" : "`npm audit fix`";
|
|
96
|
+
const omit = input.scope === "production" ? " --omit=dev" : "";
|
|
97
|
+
const report = input.reportTask
|
|
98
|
+
? `update the description of your previous report, task ${input.reportTask}, with update_task (keep it a sub-task of ${input.analysisTask}); do not create a new one.`
|
|
99
|
+
: `create one sub-task of ${input.analysisTask} with create_task (parent "${input.analysisTask}"), without request_id, titled in French "Rapport de développement — " followed by what you changed.`;
|
|
100
|
+
return [
|
|
101
|
+
`You fix the npm vulnerabilities that ${fixes} left in the GitHub repository ${input.repoId} (branch ${input.branch}).`,
|
|
102
|
+
input.scope === "production"
|
|
103
|
+
? "The audit covers the production dependencies only (`--omit=dev`): the vulnerabilities of the devDependencies are out of scope."
|
|
104
|
+
: "The audit covers all the dependencies, devDependencies included.",
|
|
105
|
+
`The current directory is a clone of that branch where ${fixes} already updated the lockfiles.`,
|
|
106
|
+
...(input.reportTask ? [`It also holds the changes of your previous pass, described in task ${input.reportTask}: build on them, and change or revert them where the remarks of the user ask for it.`] : []),
|
|
107
|
+
"",
|
|
108
|
+
"Remaining vulnerabilities, from `npm audit --json` (`project` is the folder of the package-lock.json):",
|
|
109
|
+
"```json",
|
|
110
|
+
factsJson(input.facts),
|
|
111
|
+
"```",
|
|
112
|
+
"",
|
|
113
|
+
"Your job:",
|
|
114
|
+
`1. Read the organizer task ${input.analysisTask} with get_task: its description is the analysis of these vulnerabilities, and its comments are the remarks of the user. Follow the remarks: they take precedence over the analysis.`,
|
|
115
|
+
`2. Fix what can be fixed, with minimal changes: upgrade a dependency in package.json, or pin a transitive one with an \`overrides\` entry, with Edit, then update the lockfile with the ${NPM_SERVER} tool npm_install_lockfile in the folder of the package-lock.json; adapt the code to the new versions.`,
|
|
116
|
+
`3. Check your work with the ${NPM_SERVER} tools, the only way to run npm here: npm_audit${omit ? " (it runs `npm audit" + omit + "`)" : ""} in each project; npm_ci to install the dependencies, then npm_test (or npm_run with the test script of package.json) when the project has some; npm_ls and tsc when useful. Their \`project\` argument is the folder of the package.json, "" for the root.`,
|
|
117
|
+
" You have no shell. Never write outside the current directory: the tracker commits your changes, node_modules aside.",
|
|
118
|
+
" If a command fails, quote its exact error, with the path it names, in your report.",
|
|
119
|
+
`4. Report in the organizer space "${space}": ${report} Its description, in French markdown, details every change file by file and why, how each remark of the user was taken into account, the result of the audit and of the tests, and what is left to check by hand.`,
|
|
120
|
+
` Assign it to ${owner.name} with set_assignees (member id ${owner.id}), and set its tags to exactly ["${tag}"] with set_tags.`,
|
|
121
|
+
"5. Finish with the structured report: the key of the sub-task, a summary in French, every changed file with its change in a few words in French, a conventional commit message in English for your changes, and the outcome of the tests with a one-sentence detail in French.",
|
|
122
|
+
].join("\n");
|
|
123
|
+
}
|
|
124
|
+
/** Tâche de l'analyse d'une opération et ses commentaires : les remarques que Claude prendra en compte. */
|
|
125
|
+
export async function analysisRemarks(settings, operation) {
|
|
126
|
+
const connection = organizerConnection(settings);
|
|
127
|
+
const task = operation.analysis?.task;
|
|
128
|
+
if (!connection)
|
|
129
|
+
throw new TrackerError("The organizer connection is not set: set it in the settings.");
|
|
130
|
+
if (!task)
|
|
131
|
+
throw new TrackerError(`Operation ${operation.id} has no organizer task from an analysis.`);
|
|
132
|
+
const { comments } = await new OrganizerClient(connection).taskWithComments(task.key);
|
|
133
|
+
return { task, remarks: comments };
|
|
134
|
+
}
|
|
135
|
+
/** Lance les corrections, puis vérifie sur l'organizer la sous-tâche que Claude dit avoir créée ou mise à jour. */
|
|
136
|
+
export async function repairVulnerabilities(input) {
|
|
137
|
+
const connection = organizerConnection(input.settings);
|
|
138
|
+
const token = input.settings.claude.token;
|
|
139
|
+
if (!connection || !token)
|
|
140
|
+
throw new TrackerError("The fixes by Claude need the organizer connection and the Claude token: set them in the settings.");
|
|
141
|
+
const organizer = new OrganizerClient(connection);
|
|
142
|
+
const { space, owner } = await organizer.space();
|
|
143
|
+
const tag = input.repoId.split("/")[1];
|
|
144
|
+
const configFile = path.join(input.workDir, "repair-mcp.json");
|
|
145
|
+
const servers = { [ORGANIZER_SERVER]: organizerServer(connection), [NPM_SERVER]: npmServer(input, path.join(input.workDir, "npm-cache")) };
|
|
146
|
+
fs.writeFileSync(configFile, JSON.stringify({ mcpServers: servers }), { encoding: "utf-8", mode: 0o600 });
|
|
147
|
+
let structured;
|
|
148
|
+
try {
|
|
149
|
+
({ structured } = await runClaudeSession(input.claude, {
|
|
150
|
+
cwd: input.cwd,
|
|
151
|
+
prompt: prompt(input, space.name, owner, tag),
|
|
152
|
+
args: [
|
|
153
|
+
"--tools",
|
|
154
|
+
"Read,Grep,Glob,Edit,Write",
|
|
155
|
+
"--allowedTools",
|
|
156
|
+
["Edit", "Write", ...NPM_TOOLS.map((tool) => `mcp__${NPM_SERVER}__${tool}`), ...ORGANIZER_TOOLS.map((tool) => `mcp__${ORGANIZER_SERVER}__${tool}`)].join(","),
|
|
157
|
+
"--settings",
|
|
158
|
+
JSON.stringify(SESSION_SETTINGS),
|
|
159
|
+
"--mcp-config",
|
|
160
|
+
configFile,
|
|
161
|
+
"--strict-mcp-config",
|
|
162
|
+
"--json-schema",
|
|
163
|
+
JSON.stringify(OUTPUT_JSON_SCHEMA),
|
|
164
|
+
],
|
|
165
|
+
env: { CLAUDE_CODE_SUBPROCESS_ENV_SCRUB: "1" },
|
|
166
|
+
token,
|
|
167
|
+
maxTurns: input.settings.analysis.maxTurns,
|
|
168
|
+
maxMinutes: input.settings.analysis.maxMinutes,
|
|
169
|
+
signal: input.signal,
|
|
170
|
+
onLine: input.onLine,
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
fs.rmSync(configFile, { force: true });
|
|
175
|
+
}
|
|
176
|
+
const output = OutputSchema.safeParse(structured);
|
|
177
|
+
if (!output.success)
|
|
178
|
+
throw new TrackerError("Claude Code ended without the structured report of its fixes.");
|
|
179
|
+
const task = await organizer.task(output.data.task);
|
|
180
|
+
if (task.parentKey?.toLowerCase() !== input.analysisTask.toLowerCase()) {
|
|
181
|
+
throw new TrackerError(`Task ${task.key} is not a sub-task of ${input.analysisTask}.`);
|
|
182
|
+
}
|
|
183
|
+
if (!task.tags.some((candidate) => candidate.toLowerCase() === tag.toLowerCase())) {
|
|
184
|
+
throw new TrackerError(`Task ${task.key} was created without the tag "${tag}".`);
|
|
185
|
+
}
|
|
186
|
+
if (!task.assigneeIds.includes(owner.id)) {
|
|
187
|
+
throw new TrackerError(`Task ${task.key} was created without being assigned to ${owner.name}.`);
|
|
188
|
+
}
|
|
189
|
+
const { task: _key, ...report } = output.data;
|
|
190
|
+
return { report, task: { key: task.key, title: task.title, url: organizer.taskUrl(task.id), status: task.status } };
|
|
191
|
+
}
|
package/dist/src/core/repos.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Alert, type AlertSeverity, type AnalysisTask, type HandledAlert, type Operation, type PullRequest, type Repo, type Rights } from "../../shared/schemas/model.schema.js";
|
|
2
|
-
import type { AuditFindings, RepoView } from "../../shared/schemas/api.schema.js";
|
|
2
|
+
import type { AuditFindings, CleanAudit, RepoView } from "../../shared/schemas/api.schema.js";
|
|
3
3
|
import type { GitHubConfig } from "./config.js";
|
|
4
4
|
import { type OpenPullRequest } from "./github.js";
|
|
5
5
|
import { type Store } from "./store.js";
|
|
@@ -20,16 +20,18 @@ export declare function sortRepos<T extends {
|
|
|
20
20
|
auditFindings?: AuditFindings | null;
|
|
21
21
|
}>(views: T[]): T[];
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* par défaut, la seule que Dependabot analyse, et dater d'après
|
|
26
|
-
* alertes. Null sinon. `operations` va de la plus récente à la
|
|
23
|
+
* Dernier audit, quand il n'a trouvé aucune vulnérabilité alors que Dependabot
|
|
24
|
+
* signale encore des alertes dans son périmètre : l'audit doit porter sur la
|
|
25
|
+
* branche par défaut, la seule que Dependabot analyse, et dater d'après
|
|
26
|
+
* chacune de ces alertes. Null sinon. `operations` va de la plus récente à la
|
|
27
|
+
* plus ancienne.
|
|
27
28
|
*/
|
|
28
|
-
export declare function
|
|
29
|
+
export declare function cleanAudit(repo: Repo, operations: Operation[]): CleanAudit | null;
|
|
29
30
|
/**
|
|
30
31
|
* Vulnérabilités trouvées par le dernier audit de la branche par défaut, la
|
|
31
|
-
* seule que Dependabot analyse, quand Dependabot ne signale aucune alerte
|
|
32
|
-
* Null sinon. `operations` va de la plus récente à
|
|
32
|
+
* seule que Dependabot analyse, quand Dependabot ne signale aucune alerte dans
|
|
33
|
+
* le périmètre de cet audit. Null sinon. `operations` va de la plus récente à
|
|
34
|
+
* la plus ancienne.
|
|
33
35
|
*/
|
|
34
36
|
export declare function auditFindings(repo: Repo, operations: Operation[]): AuditFindings | null;
|
|
35
37
|
/**
|
|
@@ -53,6 +55,7 @@ export declare function trackerPullRequests(repoId: string, pulls: OpenPullReque
|
|
|
53
55
|
export declare function repoView(store: Store, repo: Repo): RepoView;
|
|
54
56
|
/** Tâche organizer de la dernière analyse, tant qu'elle n'est pas terminée. `operations` va de la plus récente à la plus ancienne. */
|
|
55
57
|
export declare function openAnalysisTask(operations: Operation[]): AnalysisTask | null;
|
|
58
|
+
/** Vues de tous les dépôts suivis ; les dépôts, les catégories et les opérations sont lus une seule fois. */
|
|
56
59
|
export declare function listRepoViews(store: Store): RepoView[];
|
|
57
60
|
/**
|
|
58
61
|
* Relit les alertes Dependabot ouvertes du dépôt et ses pull requests ouvertes
|
package/dist/src/core/repos.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fromNpmSeverity, pendingAlerts, worstOf } from "../../shared/alerts.js";
|
|
1
|
+
import { alertsInScope, fromNpmSeverity, pendingAlerts, worstOf } from "../../shared/alerts.js";
|
|
2
2
|
import { ALERT_SEVERITIES, DEFAULT_RIGHTS } from "../../shared/schemas/model.schema.js";
|
|
3
3
|
import { latestAnalysed } from "./analysis.js";
|
|
4
4
|
import { ConflictError, NotFoundError } from "./errors.js";
|
|
@@ -44,33 +44,36 @@ export function sortRepos(views) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* par défaut, la seule que Dependabot analyse, et dater d'après
|
|
50
|
-
* alertes. Null sinon. `operations` va de la plus récente à la
|
|
47
|
+
* Dernier audit, quand il n'a trouvé aucune vulnérabilité alors que Dependabot
|
|
48
|
+
* signale encore des alertes dans son périmètre : l'audit doit porter sur la
|
|
49
|
+
* branche par défaut, la seule que Dependabot analyse, et dater d'après
|
|
50
|
+
* chacune de ces alertes. Null sinon. `operations` va de la plus récente à la
|
|
51
|
+
* plus ancienne.
|
|
51
52
|
*/
|
|
52
|
-
export function
|
|
53
|
-
if (repo.alerts.length === 0)
|
|
54
|
-
return null;
|
|
53
|
+
export function cleanAudit(repo, operations) {
|
|
55
54
|
const audited = operations.find((operation) => operation.steps.audit === "done");
|
|
56
55
|
if (!audited || audited.counts.initial !== 0 || audited.baseBranch !== repo.defaultBranch)
|
|
57
56
|
return null;
|
|
57
|
+
const alerts = alertsInScope(repo.alerts, audited.scope);
|
|
58
|
+
if (alerts.length === 0)
|
|
59
|
+
return null;
|
|
58
60
|
const auditedAt = Date.parse(audited.createdAt);
|
|
59
|
-
return
|
|
61
|
+
return alerts.every((alert) => Date.parse(alert.createdAt) <= auditedAt) ? { at: audited.createdAt, scope: audited.scope } : null;
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
64
|
* Vulnérabilités trouvées par le dernier audit de la branche par défaut, la
|
|
63
|
-
* seule que Dependabot analyse, quand Dependabot ne signale aucune alerte
|
|
64
|
-
* Null sinon. `operations` va de la plus récente à
|
|
65
|
+
* seule que Dependabot analyse, quand Dependabot ne signale aucune alerte dans
|
|
66
|
+
* le périmètre de cet audit. Null sinon. `operations` va de la plus récente à
|
|
67
|
+
* la plus ancienne.
|
|
65
68
|
*/
|
|
66
69
|
export function auditFindings(repo, operations) {
|
|
67
|
-
if (repo.alerts.length > 0)
|
|
68
|
-
return null;
|
|
69
70
|
const audited = operations.find((operation) => operation.steps.audit === "done" && operation.baseBranch === repo.defaultBranch);
|
|
70
|
-
|
|
71
|
-
if (!audited || severity === null)
|
|
71
|
+
if (!audited || alertsInScope(repo.alerts, audited.scope).length > 0)
|
|
72
72
|
return null;
|
|
73
|
-
|
|
73
|
+
const severity = worstOf(audited.found.map((vulnerability) => fromNpmSeverity(vulnerability.severity)));
|
|
74
|
+
if (severity === null)
|
|
75
|
+
return null;
|
|
76
|
+
return { at: audited.createdAt, scope: audited.scope, count: audited.found.length, severity };
|
|
74
77
|
}
|
|
75
78
|
/**
|
|
76
79
|
* Paquets pour lesquels le dernier audit n'a trouvé aucune version corrigée,
|
|
@@ -106,13 +109,16 @@ export function trackerPullRequests(repoId, pulls) {
|
|
|
106
109
|
.map(({ number, url, branch, createdAt }) => ({ number, url, branch, createdAt }));
|
|
107
110
|
}
|
|
108
111
|
export function repoView(store, repo) {
|
|
109
|
-
|
|
112
|
+
return buildRepoView(repo, store.listOperations(repo.id), repo.categoryId === null ? null : store.getCategory(repo.categoryId));
|
|
113
|
+
}
|
|
114
|
+
/** Vue d'un dépôt à partir de ses opérations, de la plus récente à la plus ancienne, et de sa catégorie. */
|
|
115
|
+
function buildRepoView(repo, operations, category) {
|
|
110
116
|
return {
|
|
111
117
|
repo: { ...repo, alerts: sortAlerts(repo.alerts) },
|
|
112
|
-
category
|
|
118
|
+
category,
|
|
113
119
|
activeOperation: operations.find(isActive) ?? null,
|
|
114
120
|
latestOperation: operations[0] ?? null,
|
|
115
|
-
|
|
121
|
+
cleanAudit: cleanAudit(repo, operations),
|
|
116
122
|
auditFindings: auditFindings(repo, operations),
|
|
117
123
|
unfixable: unfixablePackages(repo, operations),
|
|
118
124
|
analysisTask: openAnalysisTask(operations),
|
|
@@ -123,9 +129,21 @@ export function openAnalysisTask(operations) {
|
|
|
123
129
|
const task = latestAnalysed(operations)?.analysis?.task ?? null;
|
|
124
130
|
return task && task.status !== "done" ? task : null;
|
|
125
131
|
}
|
|
132
|
+
/** Vues de tous les dépôts suivis ; les dépôts, les catégories et les opérations sont lus une seule fois. */
|
|
126
133
|
export function listRepoViews(store) {
|
|
127
134
|
store.failOrphanedOperations();
|
|
128
|
-
|
|
135
|
+
const categories = new Map(store.listCategories().map((category) => [category.id, category]));
|
|
136
|
+
const operationsByRepo = new Map();
|
|
137
|
+
for (const operation of store.listAllOperations()) {
|
|
138
|
+
const key = operation.repoId.toLowerCase();
|
|
139
|
+
operationsByRepo.set(key, [...(operationsByRepo.get(key) ?? []), operation]);
|
|
140
|
+
}
|
|
141
|
+
return sortRepos(store.listRepos().map((repo) => {
|
|
142
|
+
const category = repo.categoryId === null ? null : categories.get(repo.categoryId);
|
|
143
|
+
if (category === undefined)
|
|
144
|
+
throw new NotFoundError(`Category "${repo.categoryId}" does not exist.`);
|
|
145
|
+
return buildRepoView(repo, operationsByRepo.get(repo.id.toLowerCase()) ?? [], category);
|
|
146
|
+
}));
|
|
129
147
|
}
|
|
130
148
|
/**
|
|
131
149
|
* Relit les alertes Dependabot ouvertes du dépôt et ses pull requests ouvertes
|
package/dist/src/core/store.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export declare class Store {
|
|
|
40
40
|
deleteCategory(categoryId: string): void;
|
|
41
41
|
private operationPath;
|
|
42
42
|
private readOperationFile;
|
|
43
|
+
/** Opérations de tous les dépôts, de la plus récente à la plus ancienne. */
|
|
44
|
+
listAllOperations(): Operation[];
|
|
43
45
|
private readAllOperations;
|
|
44
46
|
private readOperationsOf;
|
|
45
47
|
getOperation(id: string): Operation;
|
package/dist/src/core/store.js
CHANGED
|
@@ -42,8 +42,8 @@ export function processAlive(pid) {
|
|
|
42
42
|
* corrigée à la main n'en a aucune, un dépôt sans pull request en attente n'en
|
|
43
43
|
* a aucune jusqu'à sa lecture suivante, un dépôt sans date de dépréciation
|
|
44
44
|
* n'est pas déprécié. Une alerte sans date
|
|
45
|
-
* d'émission prend celle de la lecture qui l'a rapportée
|
|
46
|
-
* la remplace par
|
|
45
|
+
* d'émission prend celle de la lecture qui l'a rapportée, une alerte sans
|
|
46
|
+
* portée n'en a aucune ; la lecture suivante les remplace par les vraies.
|
|
47
47
|
*/
|
|
48
48
|
function normalizeReposFile(file) {
|
|
49
49
|
if (!Array.isArray(file?.repos))
|
|
@@ -59,7 +59,7 @@ function normalizeReposFile(file) {
|
|
|
59
59
|
pullRequests: repo?.pullRequests ?? [],
|
|
60
60
|
deprecatedAt: repo?.deprecatedAt ?? null,
|
|
61
61
|
alerts: Array.isArray(repo?.alerts)
|
|
62
|
-
? repo.alerts.map((alert) => ({ ...alert, createdAt: alert?.createdAt ?? repo.syncedAt ?? repo.addedAt }))
|
|
62
|
+
? repo.alerts.map((alert) => ({ ...alert, createdAt: alert?.createdAt ?? repo.syncedAt ?? repo.addedAt, scope: alert?.scope ?? null }))
|
|
63
63
|
: repo?.alerts,
|
|
64
64
|
})),
|
|
65
65
|
};
|
|
@@ -67,7 +67,9 @@ function normalizeReposFile(file) {
|
|
|
67
67
|
/**
|
|
68
68
|
* Complète une opération écrite par une version antérieure : sans `found`, les
|
|
69
69
|
* vulnérabilités du premier audit sont `remaining` tant qu'aucune correction
|
|
70
|
-
* n'a suivi, et inconnues sinon ; sans étape d'analyse
|
|
70
|
+
* n'a suivi, et inconnues sinon ; sans étape d'analyse ou de corrections par
|
|
71
|
+
* Claude, l'étape est passée ; sans périmètre, l'audit a couvert toutes les
|
|
72
|
+
* dépendances.
|
|
71
73
|
*/
|
|
72
74
|
function normalizeOperation(operation) {
|
|
73
75
|
if (operation === null || typeof operation !== "object")
|
|
@@ -75,8 +77,11 @@ function normalizeOperation(operation) {
|
|
|
75
77
|
return {
|
|
76
78
|
...operation,
|
|
77
79
|
found: operation.found ?? (operation.counts?.afterFix === null ? operation.remaining : []),
|
|
78
|
-
steps: operation.steps && typeof operation.steps === "object" ? { analysis: "skipped", ...operation.steps } : operation.steps,
|
|
80
|
+
steps: operation.steps && typeof operation.steps === "object" ? { analysis: "skipped", repair: "skipped", ...operation.steps } : operation.steps,
|
|
81
|
+
counts: operation.counts && typeof operation.counts === "object" ? { afterRepair: null, ...operation.counts } : operation.counts,
|
|
79
82
|
analysis: operation.analysis ?? null,
|
|
83
|
+
repair: operation.repair ?? null,
|
|
84
|
+
scope: operation.scope ?? "all",
|
|
80
85
|
};
|
|
81
86
|
}
|
|
82
87
|
function sameName(a, b) {
|
|
@@ -295,6 +300,10 @@ export class Store {
|
|
|
295
300
|
throw new TrackerError(`${file} is invalid: ${parsed.error.message}`);
|
|
296
301
|
return parsed.data;
|
|
297
302
|
}
|
|
303
|
+
/** Opérations de tous les dépôts, de la plus récente à la plus ancienne. */
|
|
304
|
+
listAllOperations() {
|
|
305
|
+
return this.readAllOperations();
|
|
306
|
+
}
|
|
298
307
|
readAllOperations() {
|
|
299
308
|
const operations = [];
|
|
300
309
|
for (const entry of fs.readdirSync(this.operationsDir)) {
|
package/dist/src/gui-worker.js
CHANGED
|
@@ -6,7 +6,7 @@ import path from "path";
|
|
|
6
6
|
import fs from "fs";
|
|
7
7
|
import { fileURLToPath } from "url";
|
|
8
8
|
import { IPCMessageSchema } from "../shared/schemas/ipc.schema.js";
|
|
9
|
-
import { AddRepoBodySchema, CategoryBodySchema, ForceBodySchema, PushBodySchema, SetBranchBodySchema, SetCategoryBodySchema, SetRightsBodySchema } from "../shared/schemas/api.schema.js";
|
|
9
|
+
import { AddRepoBodySchema, CategoryBodySchema, ForceBodySchema, PushBodySchema, RepairBodySchema, ScopeBodySchema, SetBranchBodySchema, SetCategoryBodySchema, SetRightsBodySchema } from "../shared/schemas/api.schema.js";
|
|
10
10
|
import { SaveSettingsBodySchema } from "../shared/schemas/settings.schema.js";
|
|
11
11
|
import { resolveLogDir } from "./core/log-dir.js";
|
|
12
12
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -198,7 +198,12 @@ app.post("/api/repos", async (c) => {
|
|
|
198
198
|
});
|
|
199
199
|
app.post("/api/sync", (c) => forward(c, "SYNC_REPOS"));
|
|
200
200
|
app.get("/api/audit-all", (c) => forward(c, "GET_AUDIT_ALL"));
|
|
201
|
-
app.post("/api/audit-all", (c) =>
|
|
201
|
+
app.post("/api/audit-all", async (c) => {
|
|
202
|
+
const read = await readBody(c, ScopeBodySchema);
|
|
203
|
+
if ("response" in read)
|
|
204
|
+
return read.response;
|
|
205
|
+
return forward(c, "START_AUDIT_ALL", { body: read.body });
|
|
206
|
+
});
|
|
202
207
|
app.get("/api/github/repos", (c) => forward(c, "LIST_ADDABLE_REPOS"));
|
|
203
208
|
app.get("/api/repos/:owner/:name", (c) => forward(c, "GET_REPO", { repoId: repoId(c) }));
|
|
204
209
|
app.delete("/api/repos/:owner/:name", (c) => forward(c, "REMOVE_REPO", { repoId: repoId(c) }));
|
|
@@ -239,7 +244,12 @@ app.put("/api/categories/:id", async (c) => {
|
|
|
239
244
|
return forward(c, "RENAME_CATEGORY", { categoryId: c.req.param("id"), body: read.body });
|
|
240
245
|
});
|
|
241
246
|
app.delete("/api/categories/:id", (c) => forward(c, "DELETE_CATEGORY", { categoryId: c.req.param("id") }));
|
|
242
|
-
app.post("/api/repos/:owner/:name/operations", (c) =>
|
|
247
|
+
app.post("/api/repos/:owner/:name/operations", async (c) => {
|
|
248
|
+
const read = await readBody(c, ScopeBodySchema);
|
|
249
|
+
if ("response" in read)
|
|
250
|
+
return read.response;
|
|
251
|
+
return forward(c, "START_FIX", { repoId: repoId(c), body: read.body });
|
|
252
|
+
});
|
|
243
253
|
app.get("/api/operations/:id", (c) => forward(c, "GET_OPERATION", { operationId: c.req.param("id") }));
|
|
244
254
|
app.post("/api/operations/:id/force", async (c) => {
|
|
245
255
|
const read = await readBody(c, ForceBodySchema);
|
|
@@ -247,6 +257,13 @@ app.post("/api/operations/:id/force", async (c) => {
|
|
|
247
257
|
return read.response;
|
|
248
258
|
return forward(c, "DECIDE_FORCE", { operationId: c.req.param("id"), body: read.body });
|
|
249
259
|
});
|
|
260
|
+
app.post("/api/operations/:id/repair", async (c) => {
|
|
261
|
+
const read = await readBody(c, RepairBodySchema);
|
|
262
|
+
if ("response" in read)
|
|
263
|
+
return read.response;
|
|
264
|
+
return forward(c, "DECIDE_REPAIR", { operationId: c.req.param("id"), body: read.body });
|
|
265
|
+
});
|
|
266
|
+
app.get("/api/operations/:id/remarks", (c) => forward(c, "GET_REMARKS", { operationId: c.req.param("id") }));
|
|
250
267
|
app.post("/api/operations/:id/push", async (c) => {
|
|
251
268
|
const read = await readBody(c, PushBodySchema);
|
|
252
269
|
if ("response" in read)
|
package/dist/src/index.js
CHANGED
|
@@ -13,16 +13,18 @@ import { resolveLogDir } from "./core/log-dir.js";
|
|
|
13
13
|
import { githubConfigured, readGitHubConfig } from "./core/config.js";
|
|
14
14
|
import { ConflictError, NotFoundError, TrackerError } from "./core/errors.js";
|
|
15
15
|
import { Store } from "./core/store.js";
|
|
16
|
-
import { cancelOperation, decideForce, pushOperation, runDefaultBranchAudit, startUserFix } from "./core/operations.js";
|
|
16
|
+
import { cancelOperation, decideForce, decideRepair, pushOperation, runDefaultBranchAudit, startUserFix } from "./core/operations.js";
|
|
17
17
|
import { AuditAll } from "./core/audit-all.js";
|
|
18
18
|
import { refreshAnalysisTask } from "./core/analysis.js";
|
|
19
|
+
import { analysisRemarks } from "./core/repair.js";
|
|
19
20
|
import { checkClaudeToken, packagedClaudeCommand } from "./core/claude.js";
|
|
20
21
|
import { OrganizerClient } from "./core/organizer.js";
|
|
21
22
|
import { readSettings, saveSettings, settingsView, testOrganizer } from "./core/settings.js";
|
|
22
23
|
import { SaveSettingsBodySchema } from "../shared/schemas/settings.schema.js";
|
|
24
|
+
import { AUDIT_SCOPES } from "../shared/schemas/model.schema.js";
|
|
23
25
|
import { SYNC_INTERVAL_MS, activeRepos, addRepository, deprecateRepository, listAddableRepositories, restoreRepository, listRepoBranches, listRepoViews, markAlertHandled, setBranch, setCategory, repoView, setRights, staleRepos, syncAllRepositories, syncRepository, unmarkAlertHandled } from "./core/repos.js";
|
|
24
26
|
import { GUI_REQUEST_TYPES, IPCMessageSchema } from "../shared/schemas/ipc.schema.js";
|
|
25
|
-
import { AddRepoBodySchema, AlertRequestSchema, CategoryBodySchema, CategoryRequestSchema, ForceBodySchema, OperationRequestSchema, PushBodySchema, RepoRequestSchema, SetBranchBodySchema, SetCategoryBodySchema, SetRightsBodySchema, } from "../shared/schemas/api.schema.js";
|
|
27
|
+
import { AddRepoBodySchema, AlertRequestSchema, CategoryBodySchema, CategoryRequestSchema, ForceBodySchema, OperationRequestSchema, PushBodySchema, RepairBodySchema, RepoRequestSchema, ScopeBodySchema, SetBranchBodySchema, SetCategoryBodySchema, SetRightsBodySchema, } from "../shared/schemas/api.schema.js";
|
|
26
28
|
import { errorResult, textResult } from "./tools/types.js";
|
|
27
29
|
import { fixVulnerabilities, getAlerts, listRepositories, runAudit } from "./tools/tools.js";
|
|
28
30
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -86,7 +88,7 @@ const operations = {
|
|
|
86
88
|
claude,
|
|
87
89
|
};
|
|
88
90
|
/** Série « Auditer tout » de la GUI servie par ce processus. */
|
|
89
|
-
const auditAll = new AuditAll((repoId) => runDefaultBranchAudit(operations, repoId), (message) => logger.error(message));
|
|
91
|
+
const auditAll = new AuditAll((repoId, scope) => runDefaultBranchAudit(operations, repoId, scope), (message) => logger.error(message));
|
|
90
92
|
/** Présentation du serveur transmise au client MCP : concepts, déroulé et règles. */
|
|
91
93
|
const INSTRUCTIONS = `mcp-dependabot-tracker follows the Dependabot alerts of GitHub repositories and fixes their npm vulnerabilities. The user tracks repositories and decides what you may do on each of them in a web GUI; you act only through these tools, never with git or npm yourself.
|
|
92
94
|
|
|
@@ -94,13 +96,14 @@ Concepts:
|
|
|
94
96
|
- A **tracked repository** is a GitHub repository the user added in the GUI. Its open Dependabot alerts, and the pull requests the tracker opened that are not merged or closed yet, are read from GitHub and refreshed every 10 minutes.
|
|
95
97
|
- A **deprecated repository** is one the user set aside in the GUI: it is neither synced nor audited, list_repositories leaves it out, and every tool refuses it until the user restores it.
|
|
96
98
|
- **Rights**: for each repository, the user allows you to run npm audit (audit), npm audit fix (fix), npm audit fix --force (force) and to push the fixes (push). A tool refuses an action you are not allowed to do; only the user can change the rights.
|
|
99
|
+
- The **scope** of an audit is chosen at each launch: production (the default) runs npm audit and npm audit fix with --omit=dev, so the devDependencies are left out; all covers every dependency. Each Dependabot alert says whether its dependency is a runtime or a development one.
|
|
97
100
|
- The **analysed branch** of a repository is chosen by the user in the GUI (the default branch unless changed). Dependabot alerts always describe the default branch; npm audit describes the analysed branch.
|
|
98
101
|
- An **operation** runs in a temporary clone of the analysed branch, deleted at the end: npm audit in every directory that holds a package-lock.json, then npm audit fix with --package-lock-only and --ignore-scripts (lockfiles only, no install, no scripts), optionally --force, then a commit on a new branch fix/npm-audit-<date>-<time> and a pull request to the analysed branch.
|
|
99
102
|
|
|
100
103
|
Workflow:
|
|
101
104
|
1. list_repositories to see the tracked repositories, their open alerts and your rights.
|
|
102
105
|
2. get_alerts for the detail of the alerts of one repository.
|
|
103
|
-
3. run_audit to see what npm audit reports, or fix_vulnerabilities to fix: without push, nothing leaves the temporary clone and the result shows what the fixes would change; with push, the fixes are pushed and the pull request is opened.
|
|
106
|
+
3. run_audit to see what npm audit reports, or fix_vulnerabilities to fix, on the production dependencies unless the user asks for all of them: without push, nothing leaves the temporary clone and the result shows what the fixes would change; with push, the fixes are pushed and the pull request is opened.
|
|
104
107
|
|
|
105
108
|
Rules:
|
|
106
109
|
- An operation runs until it ends; one operation at a time per repository.
|
|
@@ -157,7 +160,7 @@ async function handleGuiRequest(msg) {
|
|
|
157
160
|
case "START_AUDIT_ALL":
|
|
158
161
|
readGitHubConfig();
|
|
159
162
|
store.failOrphanedOperations();
|
|
160
|
-
return { auditAll: auditAll.start(activeRepos(store).map((repo) => repo.id)) };
|
|
163
|
+
return { auditAll: auditAll.start(activeRepos(store).map((repo) => repo.id), parseRequest(ScopeBodySchema, msg.data?.body).scope) };
|
|
161
164
|
case "LIST_ADDABLE_REPOS":
|
|
162
165
|
return { repositories: await listAddableRepositories(store, readGitHubConfig()) };
|
|
163
166
|
case "GET_REPO": {
|
|
@@ -214,7 +217,7 @@ async function handleGuiRequest(msg) {
|
|
|
214
217
|
store.deleteCategory(parseRequest(CategoryRequestSchema, msg.data).categoryId);
|
|
215
218
|
return { deleted: true };
|
|
216
219
|
case "START_FIX":
|
|
217
|
-
return { operation: startUserFix(operations, parseRequest(RepoRequestSchema, msg.data).repoId) };
|
|
220
|
+
return { operation: startUserFix(operations, parseRequest(RepoRequestSchema, msg.data).repoId, parseRequest(ScopeBodySchema, msg.data?.body).scope) };
|
|
218
221
|
case "GET_OPERATION": {
|
|
219
222
|
store.failOrphanedOperations();
|
|
220
223
|
return { operation: store.getOperation(parseRequest(OperationRequestSchema, msg.data).operationId) };
|
|
@@ -223,6 +226,12 @@ async function handleGuiRequest(msg) {
|
|
|
223
226
|
const { operationId } = parseRequest(OperationRequestSchema, msg.data);
|
|
224
227
|
return { operation: decideForce(operations, operationId, parseRequest(ForceBodySchema, msg.data?.body).apply) };
|
|
225
228
|
}
|
|
229
|
+
case "DECIDE_REPAIR": {
|
|
230
|
+
const { operationId } = parseRequest(OperationRequestSchema, msg.data);
|
|
231
|
+
return { operation: await decideRepair(operations, operationId, parseRequest(RepairBodySchema, msg.data?.body).run) };
|
|
232
|
+
}
|
|
233
|
+
case "GET_REMARKS":
|
|
234
|
+
return await analysisRemarks(readSettings(dataDir), store.getOperation(parseRequest(OperationRequestSchema, msg.data).operationId));
|
|
226
235
|
case "PUSH_OPERATION": {
|
|
227
236
|
const { operationId } = parseRequest(OperationRequestSchema, msg.data);
|
|
228
237
|
return { operation: pushOperation(operations, operationId, parseRequest(PushBodySchema, msg.data?.body).commitMessage) };
|
|
@@ -337,6 +346,11 @@ async function syncStaleRepos() {
|
|
|
337
346
|
}
|
|
338
347
|
// --- Outils -------------------------------------------------------------------
|
|
339
348
|
const REPOSITORY_DOC = "Tracked repository, as owner/name (see list_repositories).";
|
|
349
|
+
const SCOPE_PROPERTY = {
|
|
350
|
+
type: "string",
|
|
351
|
+
enum: [...AUDIT_SCOPES],
|
|
352
|
+
description: "production (default): npm audit and its fixes run with --omit=dev and leave the devDependencies out. all: every dependency, devDependencies included.",
|
|
353
|
+
};
|
|
340
354
|
const TOOLS = [
|
|
341
355
|
{
|
|
342
356
|
name: "list_repositories",
|
|
@@ -348,7 +362,7 @@ const TOOLS = [
|
|
|
348
362
|
},
|
|
349
363
|
{
|
|
350
364
|
name: "get_alerts",
|
|
351
|
-
description: "Read the open Dependabot alerts of a tracked repository from GitHub now, and list them from the most to the least severe: number, severity, package, ecosystem, manifest, summary, patched version and link.",
|
|
365
|
+
description: "Read the open Dependabot alerts of a tracked repository from GitHub now, and list them from the most to the least severe: number, severity, package, ecosystem, manifest, whether the dependency is a runtime or a development one, summary, patched version and link.",
|
|
352
366
|
inputSchema: {
|
|
353
367
|
type: "object",
|
|
354
368
|
properties: { repository: { type: "string", description: REPOSITORY_DOC } },
|
|
@@ -360,7 +374,7 @@ const TOOLS = [
|
|
|
360
374
|
description: "Run npm audit on a temporary clone of the analysed branch, in every directory that holds a package-lock.json, and report the vulnerabilities with the fix npm proposes (none, within the declared ranges, or a major upgrade that needs --force). Needs the audit right. Nothing is changed; the clone is deleted.",
|
|
361
375
|
inputSchema: {
|
|
362
376
|
type: "object",
|
|
363
|
-
properties: { repository: { type: "string", description: REPOSITORY_DOC } },
|
|
377
|
+
properties: { repository: { type: "string", description: REPOSITORY_DOC }, scope: SCOPE_PROPERTY },
|
|
364
378
|
required: ["repository"],
|
|
365
379
|
},
|
|
366
380
|
},
|
|
@@ -372,6 +386,7 @@ const TOOLS = [
|
|
|
372
386
|
type: "object",
|
|
373
387
|
properties: {
|
|
374
388
|
repository: { type: "string", description: REPOSITORY_DOC },
|
|
389
|
+
scope: SCOPE_PROPERTY,
|
|
375
390
|
force: {
|
|
376
391
|
type: "boolean",
|
|
377
392
|
description: "Also run npm audit fix --force when vulnerabilities remain that only a major upgrade fixes (default false). Breaking changes possible: only when the user asked for it.",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { type AuditScope } from "../shared/schemas/model.schema.js";
|
|
3
|
+
import { type NpmSandbox } from "./core/npm-sandbox.js";
|
|
4
|
+
import { type Args } from "./tools/types.js";
|
|
5
|
+
/** Arguments npm de l'outil appelé. */
|
|
6
|
+
export declare function npmArgs(tool: string, args: Args, scope: AuditScope): string[];
|
|
7
|
+
/** Lance l'outil et décrit le résultat : commande, code de sortie, fin des sorties. */
|
|
8
|
+
export declare function callNpmTool(sandbox: NpmSandbox, scope: AuditScope, tool: string, args: Args): Promise<CallToolResult>;
|
|
9
|
+
/** Lit `--root`, `--cache` et `--scope`, puis sert les outils sur stdio. */
|
|
10
|
+
export declare function serveNpmTools(argv: string[]): Promise<void>;
|