@imenam/mcp-dependabot-tracker 1.0.23 → 1.0.25
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 +187 -76
- package/dist/shared/schemas/agent-token.schema.d.ts +47 -0
- package/dist/shared/schemas/agent-token.schema.js +18 -0
- package/dist/shared/schemas/api.schema.d.ts +25 -23
- package/dist/shared/schemas/api.schema.js +8 -8
- package/dist/shared/schemas/deploy.schema.d.ts +174 -0
- package/dist/shared/schemas/deploy.schema.js +72 -0
- package/dist/shared/schemas/model.schema.d.ts +9 -26
- package/dist/shared/schemas/model.schema.js +7 -15
- package/dist/src/cli/setup-mcp.d.ts +19 -16
- package/dist/src/cli/setup-mcp.js +35 -82
- package/dist/src/cli/users.d.ts +5 -0
- package/dist/src/cli/users.js +164 -0
- package/dist/src/core/agent-tokens.d.ts +15 -0
- package/dist/src/core/agent-tokens.js +96 -0
- package/dist/src/core/auth.d.ts +774 -0
- package/dist/src/core/auth.js +191 -0
- package/dist/src/core/commands.d.ts +1 -1
- package/dist/src/core/commands.js +47 -4
- package/dist/src/core/config.d.ts +2 -1
- package/dist/src/core/config.js +1 -4
- package/dist/src/core/data-dir.d.ts +3 -1
- package/dist/src/core/data-dir.js +11 -5
- package/dist/src/core/deploy-servers.d.ts +77 -0
- package/dist/src/core/deploy-servers.js +480 -0
- package/dist/src/core/deployments.d.ts +75 -0
- package/dist/src/core/deployments.js +387 -0
- package/dist/src/core/github.d.ts +2 -0
- package/dist/src/core/github.js +8 -0
- package/dist/src/core/log-dir.d.ts +1 -5
- package/dist/src/core/log-dir.js +1 -5
- package/dist/src/core/npm-sandbox.d.ts +19 -3
- package/dist/src/core/npm-sandbox.js +87 -17
- package/dist/src/core/operations.d.ts +20 -18
- package/dist/src/core/operations.js +86 -70
- package/dist/src/core/repair.d.ts +0 -7
- package/dist/src/core/repair.js +10 -33
- package/dist/src/core/repos.d.ts +2 -3
- package/dist/src/core/repos.js +4 -7
- package/dist/src/core/server-config.d.ts +29 -0
- package/dist/src/core/server-config.js +85 -0
- package/dist/src/core/settings.d.ts +9 -3
- package/dist/src/core/settings.js +49 -10
- package/dist/src/core/ssh.d.ts +31 -0
- package/dist/src/core/ssh.js +82 -0
- package/dist/src/core/store.d.ts +5 -12
- package/dist/src/core/store.js +82 -160
- package/dist/src/core/vault.d.ts +10 -0
- package/dist/src/core/vault.js +50 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.js +46 -455
- package/dist/src/mcp.d.ts +6 -0
- package/dist/src/mcp.js +59 -0
- package/dist/src/server/app.d.ts +47 -0
- package/dist/src/server/app.js +273 -0
- package/dist/src/server/serve.d.ts +7 -0
- package/dist/src/server/serve.js +178 -0
- package/dist/src/tools/client.d.ts +15 -0
- package/dist/src/tools/client.js +62 -0
- package/dist/src/tools/format.d.ts +4 -5
- package/dist/src/tools/format.js +39 -16
- package/dist/src/tools/tools.d.ts +101 -15
- package/dist/src/tools/tools.js +91 -62
- package/gui/dist/assets/index-FrRzRTkV.js +71 -0
- package/gui/dist/assets/index-o3l3BAZD.css +1 -0
- package/gui/dist/index.html +2 -2
- package/package.json +11 -4
- package/dist/shared/schemas/ipc.schema.d.ts +0 -26
- package/dist/shared/schemas/ipc.schema.js +0 -53
- package/dist/src/gui-worker.d.ts +0 -1
- package/dist/src/gui-worker.js +0 -379
- package/gui/dist/assets/index-CS33iXZk.css +0 -1
- package/gui/dist/assets/index-CZN3w6nU.js +0 -64
package/dist/src/tools/format.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { ALERT_SEVERITIES,
|
|
1
|
+
import { ALERT_SEVERITIES, STEP_NAMES } from "../../shared/schemas/model.schema.js";
|
|
2
2
|
import { pendingAlerts } from "../../shared/alerts.js";
|
|
3
3
|
import { projectLabel } from "../core/npm-audit.js";
|
|
4
4
|
import { countBySeverity } from "../core/repos.js";
|
|
5
5
|
/** Paquets cités en clair dans un résultat ; au-delà, le reste est compté. */
|
|
6
6
|
const MAX_LISTED = 25;
|
|
7
|
-
export function rightsLabel(repo) {
|
|
8
|
-
const allowed = RIGHTS.filter((right) => repo.rights[right]);
|
|
9
|
-
return allowed.length === 0 ? "none" : allowed.join(", ");
|
|
10
|
-
}
|
|
11
7
|
/** Périmètre d'un audit, en clair. */
|
|
12
8
|
function scopeLabel(scope) {
|
|
13
9
|
return scope === "production" ? "production dependencies" : "all dependencies";
|
|
@@ -28,9 +24,9 @@ function alertsLabel(repo) {
|
|
|
28
24
|
const developmentNote = development > 0 ? `; ${development} on development dependencies` : "";
|
|
29
25
|
return `${pending.length} (${detail.join(", ")}${developmentNote})${handledNote}`;
|
|
30
26
|
}
|
|
31
|
-
/** Description d'un dépôt pour l'agent
|
|
32
|
-
export function describeRepo(view
|
|
33
|
-
const { repo, activeOperation } = view;
|
|
27
|
+
/** Description d'un dépôt pour l'agent. */
|
|
28
|
+
export function describeRepo(view) {
|
|
29
|
+
const { repo, activeOperation, category } = view;
|
|
34
30
|
const lines = [
|
|
35
31
|
`- ${repo.id} (analysed branch ${repo.branch}${repo.branch === repo.defaultBranch ? ", the default one" : `; default branch ${repo.defaultBranch}`})`,
|
|
36
32
|
` Category: ${category ? category.name : "none"}`,
|
|
@@ -55,9 +51,8 @@ export function describeRepo(view, category) {
|
|
|
55
51
|
const { at, scope, count, severity } = view.auditFindings;
|
|
56
52
|
lines.push(` npm audit of ${at} (${scopeLabel(scope)}) found ${count} vulnerabilit${count === 1 ? "y" : "ies"} (worst: ${severity}) on the default branch although Dependabot reports none there: Dependabot has probably not caught up yet.`);
|
|
57
53
|
}
|
|
58
|
-
lines.push(` Agent rights: ${rightsLabel(repo)}`);
|
|
59
54
|
if (activeOperation)
|
|
60
|
-
lines.push(` Operation in progress: ${activeOperation.id} (${activeOperation.
|
|
55
|
+
lines.push(` Operation in progress: ${activeOperation.id} (${activeOperation.kind})`);
|
|
61
56
|
return lines.join("\n");
|
|
62
57
|
}
|
|
63
58
|
export function describeAlerts(repo) {
|
|
@@ -77,18 +72,35 @@ function list(items, render) {
|
|
|
77
72
|
shown.push(`… and ${items.length - MAX_LISTED} more`);
|
|
78
73
|
return shown.join(", ");
|
|
79
74
|
}
|
|
80
|
-
/**
|
|
75
|
+
/** Libellé d'une étape, pour l'étape en cours. */
|
|
76
|
+
const STEP_LABELS = {
|
|
77
|
+
clone: "cloning the repository",
|
|
78
|
+
audit: "npm audit",
|
|
79
|
+
fix: "npm audit fix",
|
|
80
|
+
repair: "fixes by Claude",
|
|
81
|
+
push: "commit, push and pull request",
|
|
82
|
+
};
|
|
83
|
+
/** Compte rendu d'une opération pour l'agent : avancement, vulnérabilités, paquets modifiés, corrections par Claude, PR, erreur. */
|
|
81
84
|
export function describeOperation(operation) {
|
|
82
|
-
const title = operation.kind === "audit" ? "npm audit" : "
|
|
83
|
-
const lines = [`${title}
|
|
85
|
+
const title = operation.kind === "audit" ? "npm audit" : "Fix";
|
|
86
|
+
const lines = [`${title} of ${operation.repoId} (branch ${operation.baseBranch}), ${scopeLabel(operation.scope)} (operation ${operation.id}): ${operation.status}.`];
|
|
87
|
+
if (operation.status === "running") {
|
|
88
|
+
const step = STEP_NAMES.find((name) => operation.steps[name] === "running");
|
|
89
|
+
if (step)
|
|
90
|
+
lines.push(`- In progress: ${STEP_LABELS[step]}${operation.cancelRequested ? " (cancelling)" : ""}`);
|
|
91
|
+
if (step === "repair" && operation.repair)
|
|
92
|
+
lines.push(`- Claude: ${operation.repair.turns} turn(s); last actions: ${operation.repair.activity.join(" · ") || "none yet"}`);
|
|
93
|
+
}
|
|
84
94
|
if (operation.projects.length > 0) {
|
|
85
95
|
lines.push(`- npm projects: ${operation.projects.map((project) => projectLabel(project) || "./").join(", ")}`);
|
|
86
96
|
}
|
|
87
|
-
const { initial, afterFix } = operation.counts;
|
|
97
|
+
const { initial, afterFix, afterRepair } = operation.counts;
|
|
88
98
|
if (initial !== null) {
|
|
89
99
|
const parts = [`${initial} found`];
|
|
90
100
|
if (afterFix !== null)
|
|
91
101
|
parts.push(`${afterFix} left after npm audit fix`);
|
|
102
|
+
if (afterRepair !== null)
|
|
103
|
+
parts.push(`${afterRepair} left after the fixes by Claude`);
|
|
92
104
|
lines.push(`- Vulnerabilities: ${parts.join(", ")}`);
|
|
93
105
|
}
|
|
94
106
|
if (operation.remaining.length > 0) {
|
|
@@ -100,11 +112,22 @@ export function describeOperation(operation) {
|
|
|
100
112
|
if (operation.changes.length > 0) {
|
|
101
113
|
lines.push(`- Updated packages (${operation.changes.length}): ${list(operation.changes, (change) => `${projectLabel(change.project)}${change.name} ${change.from ?? "(added)"} → ${change.to ?? "(removed)"}`)}`);
|
|
102
114
|
}
|
|
115
|
+
const repair = operation.repair;
|
|
116
|
+
if (repair?.error)
|
|
117
|
+
lines.push(`- Fixes by Claude failed: ${repair.error}`);
|
|
118
|
+
if (repair?.report) {
|
|
119
|
+
lines.push(`- Fixes by Claude: ${repair.report.summary}`);
|
|
120
|
+
if (repair.report.changes.length > 0)
|
|
121
|
+
lines.push(`- Files changed by Claude: ${list(repair.report.changes, (change) => change.file)}`);
|
|
122
|
+
lines.push(`- Tests after the fixes by Claude: ${repair.report.tests.outcome.replace("_", " ")} — ${repair.report.tests.detail}`);
|
|
123
|
+
}
|
|
124
|
+
if (repair?.task)
|
|
125
|
+
lines.push(`- Report of Claude: organizer task ${repair.task.key} ${repair.task.url}`);
|
|
103
126
|
if (operation.pullRequest) {
|
|
104
127
|
lines.push(`- Pull request #${operation.pullRequest.number}: ${operation.pullRequest.url} (branch ${operation.branch})`);
|
|
105
128
|
}
|
|
106
|
-
else if (operation.kind === "fix" && operation.status === "done"
|
|
107
|
-
lines.push("-
|
|
129
|
+
else if (operation.kind === "fix" && operation.status === "done") {
|
|
130
|
+
lines.push("- No pull request: there was nothing to fix, or the fixes left the files unchanged.");
|
|
108
131
|
}
|
|
109
132
|
if (operation.error)
|
|
110
133
|
lines.push(`- Error: ${operation.error}`);
|
|
@@ -1,16 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { GitHubConfig } from "../core/config.js";
|
|
3
|
-
import { type OperationContext } from "../core/operations.js";
|
|
4
|
-
import type { Store } from "../core/store.js";
|
|
1
|
+
import type { AgentClient } from "./client.js";
|
|
5
2
|
import { type Args, type ToolResult } from "./types.js";
|
|
6
|
-
/**
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
/** Outils du mode MCP. */
|
|
4
|
+
export declare const TOOLS: ({
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: "object";
|
|
9
|
+
properties: {
|
|
10
|
+
category: {
|
|
11
|
+
type: string;
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
repository?: undefined;
|
|
15
|
+
scope?: undefined;
|
|
16
|
+
claude?: undefined;
|
|
17
|
+
operation?: undefined;
|
|
18
|
+
};
|
|
19
|
+
required?: undefined;
|
|
20
|
+
};
|
|
21
|
+
} | {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: "object";
|
|
26
|
+
properties: {
|
|
27
|
+
category?: undefined;
|
|
28
|
+
repository: {
|
|
29
|
+
type: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
scope?: undefined;
|
|
33
|
+
claude?: undefined;
|
|
34
|
+
operation?: undefined;
|
|
35
|
+
};
|
|
36
|
+
required: string[];
|
|
37
|
+
};
|
|
38
|
+
} | {
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
inputSchema: {
|
|
42
|
+
type: "object";
|
|
43
|
+
properties: {
|
|
44
|
+
category?: undefined;
|
|
45
|
+
repository: {
|
|
46
|
+
type: string;
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
scope: {
|
|
50
|
+
type: string;
|
|
51
|
+
enum: ("all" | "production")[];
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
claude?: undefined;
|
|
55
|
+
operation?: undefined;
|
|
56
|
+
};
|
|
57
|
+
required: string[];
|
|
58
|
+
};
|
|
59
|
+
} | {
|
|
60
|
+
name: string;
|
|
61
|
+
description: string;
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: "object";
|
|
64
|
+
properties: {
|
|
65
|
+
category?: undefined;
|
|
66
|
+
repository: {
|
|
67
|
+
type: string;
|
|
68
|
+
description: string;
|
|
69
|
+
};
|
|
70
|
+
scope: {
|
|
71
|
+
type: string;
|
|
72
|
+
enum: ("all" | "production")[];
|
|
73
|
+
description: string;
|
|
74
|
+
};
|
|
75
|
+
claude: {
|
|
76
|
+
type: string;
|
|
77
|
+
description: string;
|
|
78
|
+
};
|
|
79
|
+
operation?: undefined;
|
|
80
|
+
};
|
|
81
|
+
required: string[];
|
|
82
|
+
};
|
|
83
|
+
} | {
|
|
84
|
+
name: string;
|
|
85
|
+
description: string;
|
|
86
|
+
inputSchema: {
|
|
87
|
+
type: "object";
|
|
88
|
+
properties: {
|
|
89
|
+
category?: undefined;
|
|
90
|
+
repository?: undefined;
|
|
91
|
+
scope?: undefined;
|
|
92
|
+
claude?: undefined;
|
|
93
|
+
operation: {
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
required: string[];
|
|
99
|
+
};
|
|
100
|
+
})[];
|
|
101
|
+
/** Exécute l'outil `name` par l'API des agents du serveur. */
|
|
102
|
+
export declare function callTool(client: AgentClient, name: string, args: Args): Promise<ToolResult>;
|
package/dist/src/tools/tools.js
CHANGED
|
@@ -1,69 +1,98 @@
|
|
|
1
|
-
import { AUDIT_SCOPES, DEFAULT_AUDIT_SCOPE
|
|
2
|
-
import { TrackerError } from "../core/errors.js";
|
|
3
|
-
import { runAgentOperation } from "../core/operations.js";
|
|
4
|
-
import { listRepoViews, repoView, syncRepository } from "../core/repos.js";
|
|
1
|
+
import { AUDIT_SCOPES, DEFAULT_AUDIT_SCOPE } from "../../shared/schemas/model.schema.js";
|
|
5
2
|
import { describeAlerts, describeOperation, describeRepo } from "./format.js";
|
|
6
3
|
import { errorResult, optionalBoolean, optionalEnum, optionalString, rejectUnknownFields, requireString, textResult } from "./types.js";
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const REPOSITORY_PROPERTY = { type: "string", description: "Tracked repository, as owner/name (see list_repositories)." };
|
|
5
|
+
const OPERATION_PROPERTY = { type: "string", description: "Id of the operation, as returned by run_audit or fix_vulnerabilities." };
|
|
6
|
+
const SCOPE_PROPERTY = {
|
|
7
|
+
type: "string",
|
|
8
|
+
enum: [...AUDIT_SCOPES],
|
|
9
|
+
description: "production (default): npm audit and its fixes run with --omit=dev and leave the devDependencies out. all: every dependency, devDependencies included.",
|
|
11
10
|
};
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
/** Outils du mode MCP. */
|
|
12
|
+
export const TOOLS = [
|
|
13
|
+
{
|
|
14
|
+
name: "list_repositories",
|
|
15
|
+
description: "List the tracked repositories that are not deprecated, with their category, their analysed branch, their open Dependabot alerts by severity, the time of the last sync, the pull requests the tracker opened that are still open, and the operation in progress. Start here.",
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: "object",
|
|
18
|
+
properties: { category: { type: "string", description: "Only list the repositories of this category, by name (case-insensitive). The user creates the categories in the GUI." } },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "get_alerts",
|
|
23
|
+
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.",
|
|
24
|
+
inputSchema: { type: "object", properties: { repository: REPOSITORY_PROPERTY }, required: ["repository"] },
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "run_audit",
|
|
28
|
+
description: "Start npm audit on a temporary clone of the analysed branch, in every directory that holds a package-lock.json. Nothing is changed; the clone is deleted at the end. Returns at once with the id of the operation: follow it with get_operation.",
|
|
29
|
+
inputSchema: { type: "object", properties: { repository: REPOSITORY_PROPERTY, scope: SCOPE_PROPERTY }, required: ["repository"] },
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "fix_vulnerabilities",
|
|
33
|
+
description: "Start the fix of the npm vulnerabilities of a tracked repository, the same as the user's Fix button: in a temporary clone of the analysed branch, npm audit, then npm audit fix --package-lock-only --ignore-scripts, then, when vulnerabilities remain, the fixes by Claude (Claude Code analyses and fixes them in the code, runs the tests and reports in an organizer task), then a commit on a new branch fix/npm-audit-<date>-<time>, its push and a pull request to the analysed branch. " +
|
|
34
|
+
"Returns at once with the id of the operation: follow it with get_operation. A fix with Claude can take several minutes.",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
repository: REPOSITORY_PROPERTY,
|
|
39
|
+
scope: SCOPE_PROPERTY,
|
|
40
|
+
claude: { type: "boolean", description: "Let Claude fix what npm audit fix leaves (default true). false: only the fixes of npm audit fix are pushed." },
|
|
41
|
+
},
|
|
42
|
+
required: ["repository"],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "get_operation",
|
|
47
|
+
description: "Read an operation: its status (running, done, failed, cancelled), the step in progress, the vulnerabilities before and after, the updated packages, the fixes by Claude, the pull request and the error. Call it again later while the operation is running.",
|
|
48
|
+
inputSchema: { type: "object", properties: { operation: OPERATION_PROPERTY }, required: ["operation"] },
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "cancel_operation",
|
|
52
|
+
description: "Cancel a running operation: its command is stopped, Claude Code included, the clone is deleted and nothing is pushed.",
|
|
53
|
+
inputSchema: { type: "object", properties: { operation: OPERATION_PROPERTY }, required: ["operation"] },
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
/** Compte rendu d'une opération, suivi du lien vers son écran dans la GUI. */
|
|
57
|
+
function operationResult({ operation, guiUrl }) {
|
|
58
|
+
const text = `${describeOperation(operation)}\n\nOpen in the GUI: ${guiUrl}`;
|
|
59
|
+
return operation.status === "failed" ? errorResult(text) : textResult(text);
|
|
17
60
|
}
|
|
18
|
-
/**
|
|
19
|
-
export function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
throw new TrackerError(`Category "${categoryName}" does not exist (${known}).`);
|
|
61
|
+
/** Exécute l'outil `name` par l'API des agents du serveur. */
|
|
62
|
+
export async function callTool(client, name, args) {
|
|
63
|
+
switch (name) {
|
|
64
|
+
case "list_repositories": {
|
|
65
|
+
rejectUnknownFields(args, ["category"]);
|
|
66
|
+
const category = optionalString(args, "category");
|
|
67
|
+
const { repos, category: found } = await client.listRepositories(category);
|
|
68
|
+
const where = found ? `in category ${found.name}` : "tracked";
|
|
69
|
+
if (repos.length === 0)
|
|
70
|
+
return textResult(found ? `No repository ${where}.` : "No repository is tracked. The user adds repositories in the GUI.");
|
|
71
|
+
return textResult([`${repos.length} repositor${repos.length === 1 ? "y" : "ies"} ${where}:`, ...repos.map(describeRepo)].join("\n"));
|
|
30
72
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
73
|
+
case "get_alerts": {
|
|
74
|
+
rejectUnknownFields(args, ["repository"]);
|
|
75
|
+
const view = await client.syncAlerts(requireString(args, "repository"));
|
|
76
|
+
if (view.repo.syncError)
|
|
77
|
+
return errorResult(`Could not read the Dependabot alerts of ${view.repo.id}: ${view.repo.syncError}`);
|
|
78
|
+
return textResult(describeAlerts(view.repo));
|
|
79
|
+
}
|
|
80
|
+
case "run_audit": {
|
|
81
|
+
rejectUnknownFields(args, ["repository", "scope"]);
|
|
82
|
+
return operationResult(await client.startAudit(requireString(args, "repository"), optionalEnum(args, "scope", AUDIT_SCOPES, DEFAULT_AUDIT_SCOPE)));
|
|
83
|
+
}
|
|
84
|
+
case "fix_vulnerabilities": {
|
|
85
|
+
rejectUnknownFields(args, ["repository", "scope", "claude"]);
|
|
86
|
+
const scope = optionalEnum(args, "scope", AUDIT_SCOPES, DEFAULT_AUDIT_SCOPE);
|
|
87
|
+
return operationResult(await client.startFix(requireString(args, "repository"), scope, optionalBoolean(args, "claude", true)));
|
|
88
|
+
}
|
|
89
|
+
case "get_operation":
|
|
90
|
+
rejectUnknownFields(args, ["operation"]);
|
|
91
|
+
return operationResult(await client.getOperation(requireString(args, "operation")));
|
|
92
|
+
case "cancel_operation":
|
|
93
|
+
rejectUnknownFields(args, ["operation"]);
|
|
94
|
+
return operationResult(await client.cancelOperation(requireString(args, "operation")));
|
|
95
|
+
default:
|
|
96
|
+
throw new Error(`Tool not found: ${name}`);
|
|
36
97
|
}
|
|
37
|
-
const categoryOf = (view) => categories.find((category) => category.id === view.repo.categoryId) ?? null;
|
|
38
|
-
return textResult([`${views.length} repositor${views.length === 1 ? "y" : "ies"} ${scope}:`, ...views.map((view) => describeRepo(view, categoryOf(view)))].join("\n"));
|
|
39
|
-
}
|
|
40
|
-
/** Relit les alertes sur GitHub avant de les lister. */
|
|
41
|
-
export async function getAlerts(store, config, args) {
|
|
42
|
-
rejectUnknownFields(args, ["repository"]);
|
|
43
|
-
const repo = await syncRepository(store, config, store.getRepo(requireString(args, "repository")).id);
|
|
44
|
-
if (repo.syncError)
|
|
45
|
-
return errorResult(`Could not read the Dependabot alerts of ${repo.id}: ${repo.syncError}`);
|
|
46
|
-
return textResult(describeAlerts(repoView(store, repo).repo));
|
|
47
|
-
}
|
|
48
|
-
function operationResult(operation) {
|
|
49
|
-
const text = describeOperation(operation);
|
|
50
|
-
return { result: operation.status === "done" ? textResult(text) : errorResult(text), operation };
|
|
51
|
-
}
|
|
52
|
-
export async function runAudit(ctx, args) {
|
|
53
|
-
rejectUnknownFields(args, ["repository", "scope"]);
|
|
54
|
-
const repo = ctx.store.getRepo(requireString(args, "repository"));
|
|
55
|
-
const scope = optionalEnum(args, "scope", AUDIT_SCOPES, DEFAULT_AUDIT_SCOPE);
|
|
56
|
-
assertAllowed(repo, "audit");
|
|
57
|
-
return operationResult(await runAgentOperation(ctx, repo.id, "audit", { scope, push: false, commitMessage: DEFAULT_COMMIT_MESSAGE }));
|
|
58
|
-
}
|
|
59
|
-
export async function fixVulnerabilities(ctx, args) {
|
|
60
|
-
rejectUnknownFields(args, ["repository", "scope", "push", "commit_message"]);
|
|
61
|
-
const repo = ctx.store.getRepo(requireString(args, "repository"));
|
|
62
|
-
const scope = optionalEnum(args, "scope", AUDIT_SCOPES, DEFAULT_AUDIT_SCOPE);
|
|
63
|
-
const push = optionalBoolean(args, "push", false);
|
|
64
|
-
const commitMessage = optionalString(args, "commit_message") ?? DEFAULT_COMMIT_MESSAGE;
|
|
65
|
-
assertAllowed(repo, "fix");
|
|
66
|
-
if (push)
|
|
67
|
-
assertAllowed(repo, "push");
|
|
68
|
-
return operationResult(await runAgentOperation(ctx, repo.id, "fix", { scope, push, commitMessage }));
|
|
69
98
|
}
|