contribbot-mcp 0.1.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.
- package/dist/index.d.ts +219 -0
- package/dist/index.js +5 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +48 -0
- package/dist/repo-config-C0SUu1Lx.js +4 -0
- package/dist/repo-config-D-7B7yP_.js +53 -0
- package/dist/server-BUY4k2DS.js +3240 -0
- package/package.json +39 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
|
|
4
|
+
//#region src/core/enums.d.ts
|
|
5
|
+
declare const TodoStatus: {
|
|
6
|
+
readonly Idea: "idea";
|
|
7
|
+
readonly Backlog: "backlog";
|
|
8
|
+
readonly Active: "active";
|
|
9
|
+
readonly PrSubmitted: "pr_submitted";
|
|
10
|
+
readonly Done: "done";
|
|
11
|
+
};
|
|
12
|
+
type TodoStatus = typeof TodoStatus[keyof typeof TodoStatus];
|
|
13
|
+
declare const TODO_STATUSES: [TodoStatus, ...TodoStatus[]];
|
|
14
|
+
declare const TodoType: {
|
|
15
|
+
readonly Bug: "bug";
|
|
16
|
+
readonly Feature: "feature";
|
|
17
|
+
readonly Docs: "docs";
|
|
18
|
+
readonly Chore: "chore";
|
|
19
|
+
};
|
|
20
|
+
type TodoType = typeof TodoType[keyof typeof TodoType];
|
|
21
|
+
declare const TODO_TYPES: [TodoType, ...TodoType[]];
|
|
22
|
+
declare const TodoDifficulty: {
|
|
23
|
+
readonly Easy: "easy";
|
|
24
|
+
readonly Medium: "medium";
|
|
25
|
+
readonly Hard: "hard";
|
|
26
|
+
};
|
|
27
|
+
type TodoDifficulty = typeof TodoDifficulty[keyof typeof TodoDifficulty];
|
|
28
|
+
declare const TODO_DIFFICULTIES: [TodoDifficulty, ...TodoDifficulty[]];
|
|
29
|
+
declare const UpstreamItemStatus: {
|
|
30
|
+
readonly Active: "active";
|
|
31
|
+
readonly PrSubmitted: "pr_submitted";
|
|
32
|
+
readonly Done: "done";
|
|
33
|
+
};
|
|
34
|
+
type UpstreamItemStatus = typeof UpstreamItemStatus[keyof typeof UpstreamItemStatus];
|
|
35
|
+
declare const UPSTREAM_ITEM_STATUSES: [UpstreamItemStatus, ...UpstreamItemStatus[]];
|
|
36
|
+
declare const UpstreamVersionStatus: {
|
|
37
|
+
readonly Active: "active";
|
|
38
|
+
readonly Done: "done";
|
|
39
|
+
};
|
|
40
|
+
type UpstreamVersionStatus = typeof UpstreamVersionStatus[keyof typeof UpstreamVersionStatus];
|
|
41
|
+
declare const DailyCommitAction: {
|
|
42
|
+
readonly Skip: "skip";
|
|
43
|
+
readonly Todo: "todo";
|
|
44
|
+
readonly Issue: "issue";
|
|
45
|
+
readonly Pr: "pr";
|
|
46
|
+
readonly Synced: "synced";
|
|
47
|
+
};
|
|
48
|
+
type DailyCommitAction = typeof DailyCommitAction[keyof typeof DailyCommitAction];
|
|
49
|
+
declare const DAILY_COMMIT_ACTIONS: [DailyCommitAction, ...DailyCommitAction[]];
|
|
50
|
+
declare const RepoRole: {
|
|
51
|
+
readonly Admin: "admin";
|
|
52
|
+
readonly Maintain: "maintain";
|
|
53
|
+
readonly Write: "write";
|
|
54
|
+
readonly Triage: "triage";
|
|
55
|
+
readonly Read: "read";
|
|
56
|
+
};
|
|
57
|
+
type RepoRole = typeof RepoRole[keyof typeof RepoRole];
|
|
58
|
+
declare const PRType: {
|
|
59
|
+
readonly Feat: "feat";
|
|
60
|
+
readonly Fix: "fix";
|
|
61
|
+
readonly Other: "other";
|
|
62
|
+
};
|
|
63
|
+
type PRType = typeof PRType[keyof typeof PRType];
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/core/tools/issue-detail.d.ts
|
|
66
|
+
declare function issueDetail(issueNumber: number, repo?: string): Promise<string>;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/core/tools/pr-summary.d.ts
|
|
69
|
+
declare function prSummary(prNumber: number, repo?: string): Promise<string>;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/core/tools/project-dashboard.d.ts
|
|
72
|
+
declare function projectDashboard(repo?: string): Promise<string>;
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/core/tools/upstream-sync-check.d.ts
|
|
75
|
+
declare function upstreamSyncCheck(version?: string, upstreamRepo?: string, targetRepo?: string, save?: boolean, targetBranch?: string): Promise<string>;
|
|
76
|
+
declare function syncHistory(targetRepo?: string): Promise<string>;
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/core/tools/todos.d.ts
|
|
79
|
+
declare function todoList(repo?: string, status?: string): Promise<string>;
|
|
80
|
+
declare function todoAdd(text: string, ref?: string, repo?: string): Promise<string>;
|
|
81
|
+
declare function todoDelete(indexOrText: string, repo?: string): Promise<string>;
|
|
82
|
+
declare function todoDone(indexOrText: string, repo?: string): Promise<string>;
|
|
83
|
+
declare function todoArchive(repo?: string): Promise<string>;
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/core/tools/todo-activate.d.ts
|
|
86
|
+
declare function todoActivate(item: string, repo?: string): Promise<string>;
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/core/tools/todo-detail.d.ts
|
|
89
|
+
declare function todoDetail(item: string, repo?: string): Promise<string>;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/core/tools/todo-update.d.ts
|
|
92
|
+
declare function todoUpdate(item: string, fields: {
|
|
93
|
+
status?: string;
|
|
94
|
+
pr?: number;
|
|
95
|
+
branch?: string;
|
|
96
|
+
note?: string;
|
|
97
|
+
}, repo?: string): Promise<string>;
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/core/tools/comment-create.d.ts
|
|
100
|
+
declare function commentCreate(number: number, body: string, repo?: string): Promise<string>;
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/core/tools/issue-close.d.ts
|
|
103
|
+
declare function issueClose(issueNumber: number, comment?: string, todoItem?: string, repo?: string): Promise<string>;
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/core/tools/issue-create.d.ts
|
|
106
|
+
declare function issueCreate(title: string, body?: string, labels?: string, upstreamSha?: string, upstreamRepo?: string, autoTodo?: boolean, repo?: string): Promise<string>;
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/core/tools/pr-update.d.ts
|
|
109
|
+
declare function prUpdate(prNumber: number, fields: {
|
|
110
|
+
title?: string;
|
|
111
|
+
body?: string;
|
|
112
|
+
state?: string;
|
|
113
|
+
draft?: boolean;
|
|
114
|
+
}, repo?: string): Promise<string>;
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/core/tools/pr-create.d.ts
|
|
117
|
+
declare function prCreate(title: string, head?: string, base?: string, body?: string, draft?: boolean, todoItem?: string, repo?: string): Promise<string>;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/core/tools/pr-review-comments.d.ts
|
|
120
|
+
declare function prReviewComments(prNumber: number, repo?: string): Promise<string>;
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region src/core/tools/pr-review-reply.d.ts
|
|
123
|
+
declare function prReviewReply(prNumber: number, commentId: number, body: string, repo?: string): Promise<string>;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/core/tools/upstream-manage.d.ts
|
|
126
|
+
declare function upstreamList(repo?: string, upstreamRepo?: string): Promise<string>;
|
|
127
|
+
declare function upstreamDetail(upstreamRepo: string, version: string, repo?: string): Promise<string>;
|
|
128
|
+
declare function upstreamUpdate(upstreamRepo: string, version: string, itemIndex: number, fields: {
|
|
129
|
+
status?: string;
|
|
130
|
+
pr?: number;
|
|
131
|
+
difficulty?: string;
|
|
132
|
+
}, repo?: string): Promise<string>;
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/core/tools/upstream-daily.d.ts
|
|
135
|
+
declare function upstreamDaily(upstreamRepo: string, repo?: string, sinceTag?: string): Promise<string>;
|
|
136
|
+
declare function upstreamDailyAct(upstreamRepo: string, sha: string, action: string, ref?: string, repo?: string): Promise<string>;
|
|
137
|
+
/**
|
|
138
|
+
* Batch skip all commits that are suggested as noise.
|
|
139
|
+
*/
|
|
140
|
+
declare function upstreamDailySkipNoise(upstreamRepo: string, repo?: string): Promise<string>;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/core/tools/project-list.d.ts
|
|
143
|
+
declare function projectList(): string;
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/core/tools/contribution-stats.d.ts
|
|
146
|
+
declare function contributionStats(days?: number, author?: string, repo?: string): Promise<string>;
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/core/tools/issue-list.d.ts
|
|
149
|
+
declare function issueList(repo?: string, state?: string, labels?: string, query?: string): Promise<string>;
|
|
150
|
+
declare function prList(repo?: string, state?: string, query?: string): Promise<string>;
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/core/storage/repo-config.d.ts
|
|
153
|
+
interface RepoConfigData {
|
|
154
|
+
role: RepoRole;
|
|
155
|
+
org: string | null;
|
|
156
|
+
fork: string | null;
|
|
157
|
+
upstream: string | null;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* ProjectMode — 项目的上下游对齐关系,和 role(权限)正交。
|
|
161
|
+
* 由 config.yaml 的 fork + upstream 字段自动推断。
|
|
162
|
+
*/
|
|
163
|
+
type ProjectMode = 'none' | 'fork' | 'upstream' | 'fork+upstream';
|
|
164
|
+
declare function inferMode(config: RepoConfigData): ProjectMode;
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/core/tools/repo-config-tool.d.ts
|
|
167
|
+
/**
|
|
168
|
+
* View or update repo config.
|
|
169
|
+
*/
|
|
170
|
+
declare function repoConfig(repo?: string, upstream?: string): Promise<string>;
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/core/tools/skills.d.ts
|
|
173
|
+
declare function skillList(repo?: string): Promise<string>;
|
|
174
|
+
declare function skillRead(skillName: string, repo?: string): Promise<string>;
|
|
175
|
+
declare function skillWrite(skillName: string, content: string, repo?: string): Promise<string>;
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/core/tools/skill-resources.d.ts
|
|
178
|
+
interface SkillEntry {
|
|
179
|
+
repo: string;
|
|
180
|
+
name: string;
|
|
181
|
+
description: string;
|
|
182
|
+
}
|
|
183
|
+
declare function listAllSkills(): SkillEntry[];
|
|
184
|
+
declare function readSkill(repo: string, skillName: string): string | null;
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/core/utils/fs.d.ts
|
|
187
|
+
declare function safeWriteFileSync(filePath: string, content: string): void;
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/core/utils/resolve-repo.d.ts
|
|
190
|
+
/**
|
|
191
|
+
* If the given repo is a fork, resolve to its parent repo.
|
|
192
|
+
* This ensures data is always stored under the upstream/parent owner.
|
|
193
|
+
*/
|
|
194
|
+
declare function resolveToParent(owner: string, name: string): Promise<{
|
|
195
|
+
owner: string;
|
|
196
|
+
name: string;
|
|
197
|
+
fork: string | null;
|
|
198
|
+
}>;
|
|
199
|
+
/**
|
|
200
|
+
* Resolve a repo string to the canonical owner/name for data storage.
|
|
201
|
+
*
|
|
202
|
+
* Resolution order (fast to slow):
|
|
203
|
+
* 1. In-memory cache hit
|
|
204
|
+
* 2. Config already exists at the given owner/name path (it IS the parent)
|
|
205
|
+
* 3. Scan existing configs to find one that lists this repo as its fork
|
|
206
|
+
* 4. GitHub API call to check if it's a fork and resolve to parent
|
|
207
|
+
*
|
|
208
|
+
* This ensures all data for a project lives in ONE directory,
|
|
209
|
+
* regardless of whether the user passes their fork name or the parent name.
|
|
210
|
+
*/
|
|
211
|
+
declare function resolveRepo(repo?: string): Promise<{
|
|
212
|
+
owner: string;
|
|
213
|
+
name: string;
|
|
214
|
+
}>;
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/mcp/server.d.ts
|
|
217
|
+
declare function createServer(): McpServer;
|
|
218
|
+
//#endregion
|
|
219
|
+
export { DAILY_COMMIT_ACTIONS, DailyCommitAction, PRType, type ProjectMode, type RepoRole, TODO_DIFFICULTIES, TODO_STATUSES, TODO_TYPES, TodoDifficulty, TodoStatus, TodoType, UPSTREAM_ITEM_STATUSES, UpstreamItemStatus, UpstreamVersionStatus, commentCreate, contributionStats, createServer, inferMode, issueClose, issueCreate, issueDetail, issueList, listAllSkills, prCreate, prList, prReviewComments, prReviewReply, prSummary, prUpdate, projectDashboard, projectList, readSkill, repoConfig, resolveRepo, resolveToParent, safeWriteFileSync, skillList, skillRead, skillWrite, syncHistory, todoActivate, todoAdd, todoArchive, todoDelete, todoDetail, todoDone, todoList, todoUpdate, upstreamDaily, upstreamDailyAct, upstreamDailySkipNoise, upstreamDetail, upstreamList, upstreamSyncCheck, upstreamUpdate };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { A as todoList, B as DAILY_COMMIT_ACTIONS, C as todoUpdate, D as todoArchive, E as todoAdd, F as projectDashboard, G as TODO_STATUSES, H as PRType, I as listAllSkills, J as TodoStatus, K as TODO_TYPES, L as readSkill, M as upstreamSyncCheck, N as resolveRepo, O as todoDelete, P as resolveToParent, Q as UpstreamVersionStatus, R as prSummary, S as commentCreate, T as todoActivate, U as RepoRole, V as DailyCommitAction, W as TODO_DIFFICULTIES, X as UPSTREAM_ITEM_STATUSES, Y as TodoType, Z as UpstreamItemStatus, _ as prReviewComments, a as repoConfig, b as issueCreate, c as contributionStats, d as upstreamDailyAct, f as upstreamDailySkipNoise, g as prReviewReply, h as upstreamUpdate, i as skillWrite, j as syncHistory, k as todoDone, l as projectList, m as upstreamList, n as skillList, o as issueList, p as upstreamDetail, q as TodoDifficulty, r as skillRead, s as prList, t as createServer, u as upstreamDaily, v as prCreate, w as todoDetail, x as issueClose, y as prUpdate, z as issueDetail } from "./server-BUY4k2DS.js";
|
|
3
|
+
import { n as inferMode, r as safeWriteFileSync } from "./repo-config-D-7B7yP_.js";
|
|
4
|
+
|
|
5
|
+
export { DAILY_COMMIT_ACTIONS, DailyCommitAction, PRType, RepoRole, TODO_DIFFICULTIES, TODO_STATUSES, TODO_TYPES, TodoDifficulty, TodoStatus, TodoType, UPSTREAM_ITEM_STATUSES, UpstreamItemStatus, UpstreamVersionStatus, commentCreate, contributionStats, createServer, inferMode, issueClose, issueCreate, issueDetail, issueList, listAllSkills, prCreate, prList, prReviewComments, prReviewReply, prSummary, prUpdate, projectDashboard, projectList, readSkill, repoConfig, resolveRepo, resolveToParent, safeWriteFileSync, skillList, skillRead, skillWrite, syncHistory, todoActivate, todoAdd, todoArchive, todoDelete, todoDetail, todoDone, todoList, todoUpdate, upstreamDaily, upstreamDailyAct, upstreamDailySkipNoise, upstreamDetail, upstreamList, upstreamSyncCheck, upstreamUpdate };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { t as createServer } from "../server-BUY4k2DS.js";
|
|
3
|
+
import "../repo-config-D-7B7yP_.js";
|
|
4
|
+
import { execFileSync } from "node:child_process";
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
|
|
7
|
+
//#region src/mcp/index.ts
|
|
8
|
+
function checkAuth() {
|
|
9
|
+
if (process.env.GITHUB_TOKEN) return "token";
|
|
10
|
+
try {
|
|
11
|
+
execFileSync("gh", ["auth", "status"], { stdio: "ignore" });
|
|
12
|
+
return "gh-cli";
|
|
13
|
+
} catch {
|
|
14
|
+
console.error(`
|
|
15
|
+
[contribbot] GitHub auth not configured. Please set up one of:
|
|
16
|
+
|
|
17
|
+
Option A - gh CLI (recommended):
|
|
18
|
+
gh auth login
|
|
19
|
+
|
|
20
|
+
Option B - GitHub Token:
|
|
21
|
+
Set GITHUB_TOKEN environment variable in .mcp.json:
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"contribbot": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["tsx", "packages/contribbot/src/mcp/index.ts"],
|
|
27
|
+
"env": { "GITHUB_TOKEN": "<your-token>" }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function main() {
|
|
36
|
+
const authMode = checkAuth();
|
|
37
|
+
const server = createServer();
|
|
38
|
+
const transport = new StdioServerTransport();
|
|
39
|
+
await server.connect(transport);
|
|
40
|
+
console.error(`contribbot MCP server running (auth: ${authMode})`);
|
|
41
|
+
}
|
|
42
|
+
main().catch((error) => {
|
|
43
|
+
console.error("Fatal error:", error);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { parse, stringify } from "yaml";
|
|
5
|
+
|
|
6
|
+
//#region src/core/utils/fs.ts
|
|
7
|
+
function safeWriteFileSync(filePath, content) {
|
|
8
|
+
const tmp = `${filePath}.tmp`;
|
|
9
|
+
writeFileSync(tmp, content, "utf-8");
|
|
10
|
+
renameSync(tmp, filePath);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/core/storage/repo-config.ts
|
|
15
|
+
function inferMode(config) {
|
|
16
|
+
const hasFork = config.fork !== null;
|
|
17
|
+
const hasUpstream = config.upstream !== null;
|
|
18
|
+
if (hasFork && hasUpstream) return "fork+upstream";
|
|
19
|
+
if (hasFork) return "fork";
|
|
20
|
+
if (hasUpstream) return "upstream";
|
|
21
|
+
return "none";
|
|
22
|
+
}
|
|
23
|
+
var RepoConfig = class {
|
|
24
|
+
configPath;
|
|
25
|
+
constructor(baseDir) {
|
|
26
|
+
this.baseDir = baseDir;
|
|
27
|
+
this.configPath = join(baseDir, "config.yaml");
|
|
28
|
+
}
|
|
29
|
+
exists() {
|
|
30
|
+
return existsSync(this.configPath);
|
|
31
|
+
}
|
|
32
|
+
load() {
|
|
33
|
+
if (!this.exists()) return null;
|
|
34
|
+
return parse(readFileSync(this.configPath, "utf-8")) ?? null;
|
|
35
|
+
}
|
|
36
|
+
save(config) {
|
|
37
|
+
if (!existsSync(this.baseDir)) mkdirSync(this.baseDir, { recursive: true });
|
|
38
|
+
safeWriteFileSync(this.configPath, stringify(config));
|
|
39
|
+
}
|
|
40
|
+
update(fields) {
|
|
41
|
+
const config = this.load();
|
|
42
|
+
if (!config) return null;
|
|
43
|
+
if (fields.role !== void 0) config.role = fields.role;
|
|
44
|
+
if (fields.org !== void 0) config.org = fields.org;
|
|
45
|
+
if (fields.fork !== void 0) config.fork = fields.fork;
|
|
46
|
+
if (fields.upstream !== void 0) config.upstream = fields.upstream;
|
|
47
|
+
this.save(config);
|
|
48
|
+
return config;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { inferMode as n, safeWriteFileSync as r, RepoConfig as t };
|