@fre4x/github 1.0.44 → 1.0.45
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.js +94 -13
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -31698,9 +31698,9 @@ var handler = {
|
|
|
31698
31698
|
set(target, methodName, value) {
|
|
31699
31699
|
return target.cache[methodName] = value;
|
|
31700
31700
|
},
|
|
31701
|
-
get({ octokit, scope, cache }, methodName) {
|
|
31702
|
-
if (
|
|
31703
|
-
return
|
|
31701
|
+
get({ octokit, scope, cache: cache2 }, methodName) {
|
|
31702
|
+
if (cache2[methodName]) {
|
|
31703
|
+
return cache2[methodName];
|
|
31704
31704
|
}
|
|
31705
31705
|
const method = endpointMethodsMap.get(scope).get(methodName);
|
|
31706
31706
|
if (!method) {
|
|
@@ -31708,7 +31708,7 @@ var handler = {
|
|
|
31708
31708
|
}
|
|
31709
31709
|
const { endpointDefaults, decorations } = method;
|
|
31710
31710
|
if (decorations) {
|
|
31711
|
-
|
|
31711
|
+
cache2[methodName] = decorate(
|
|
31712
31712
|
octokit,
|
|
31713
31713
|
scope,
|
|
31714
31714
|
methodName,
|
|
@@ -31716,9 +31716,9 @@ var handler = {
|
|
|
31716
31716
|
decorations
|
|
31717
31717
|
);
|
|
31718
31718
|
} else {
|
|
31719
|
-
|
|
31719
|
+
cache2[methodName] = octokit.request.defaults(endpointDefaults);
|
|
31720
31720
|
}
|
|
31721
|
-
return
|
|
31721
|
+
return cache2[methodName];
|
|
31722
31722
|
}
|
|
31723
31723
|
};
|
|
31724
31724
|
function endpointsToMethods(octokit) {
|
|
@@ -31839,6 +31839,36 @@ var getOctokit = () => {
|
|
|
31839
31839
|
}
|
|
31840
31840
|
return _octokitInstance;
|
|
31841
31841
|
};
|
|
31842
|
+
var MAX_CACHE_SIZE = 1e3;
|
|
31843
|
+
var cache = /* @__PURE__ */ new Map();
|
|
31844
|
+
var CACHE_TTL_MS = 60 * 1e3;
|
|
31845
|
+
function sweepExpiredFromCache() {
|
|
31846
|
+
const now = Date.now();
|
|
31847
|
+
for (const [key, value] of cache) {
|
|
31848
|
+
if (now - value.timestamp >= CACHE_TTL_MS) {
|
|
31849
|
+
cache.delete(key);
|
|
31850
|
+
}
|
|
31851
|
+
}
|
|
31852
|
+
}
|
|
31853
|
+
async function withCache(key, fetchFn) {
|
|
31854
|
+
const now = Date.now();
|
|
31855
|
+
const cached2 = cache.get(key);
|
|
31856
|
+
if (cached2) {
|
|
31857
|
+
if (now - cached2.timestamp < CACHE_TTL_MS) {
|
|
31858
|
+
return cached2.data;
|
|
31859
|
+
}
|
|
31860
|
+
cache.delete(key);
|
|
31861
|
+
}
|
|
31862
|
+
cache.delete(key);
|
|
31863
|
+
if (cache.size >= MAX_CACHE_SIZE) sweepExpiredFromCache();
|
|
31864
|
+
if (cache.size >= MAX_CACHE_SIZE) {
|
|
31865
|
+
const oldestKey = cache.keys().next().value;
|
|
31866
|
+
if (oldestKey !== void 0) cache.delete(oldestKey);
|
|
31867
|
+
}
|
|
31868
|
+
const data = await fetchFn();
|
|
31869
|
+
cache.set(key, { data, timestamp: Date.now() });
|
|
31870
|
+
return data;
|
|
31871
|
+
}
|
|
31842
31872
|
async function searchRepositories(params) {
|
|
31843
31873
|
if (IS_MOCK) return MOCK_FIXTURES.searchRepositories;
|
|
31844
31874
|
const limit = Math.max(1, params.limit ?? 10);
|
|
@@ -31848,11 +31878,20 @@ async function searchRepositories(params) {
|
|
|
31848
31878
|
const offsetInPage = offset % per_page;
|
|
31849
31879
|
try {
|
|
31850
31880
|
const octokit = getOctokit();
|
|
31851
|
-
const
|
|
31881
|
+
const cacheKey = JSON.stringify({
|
|
31882
|
+
fn: "searchRepositories",
|
|
31852
31883
|
q: params.query,
|
|
31853
31884
|
per_page,
|
|
31854
31885
|
page
|
|
31855
31886
|
});
|
|
31887
|
+
const response = await withCache(
|
|
31888
|
+
cacheKey,
|
|
31889
|
+
() => octokit.rest.search.repos({
|
|
31890
|
+
q: params.query,
|
|
31891
|
+
per_page,
|
|
31892
|
+
page
|
|
31893
|
+
})
|
|
31894
|
+
);
|
|
31856
31895
|
const items = response.data.items.slice(offsetInPage, offsetInPage + limit).map((item) => ({
|
|
31857
31896
|
full_name: item.full_name,
|
|
31858
31897
|
description: item.description,
|
|
@@ -31878,11 +31917,20 @@ async function searchCode(params) {
|
|
|
31878
31917
|
const offsetInPage = offset % per_page;
|
|
31879
31918
|
try {
|
|
31880
31919
|
const octokit = getOctokit();
|
|
31881
|
-
const
|
|
31920
|
+
const cacheKey = JSON.stringify({
|
|
31921
|
+
fn: "searchCode",
|
|
31882
31922
|
q: params.query,
|
|
31883
31923
|
per_page,
|
|
31884
31924
|
page
|
|
31885
31925
|
});
|
|
31926
|
+
const response = await withCache(
|
|
31927
|
+
cacheKey,
|
|
31928
|
+
() => octokit.rest.search.code({
|
|
31929
|
+
q: params.query,
|
|
31930
|
+
per_page,
|
|
31931
|
+
page
|
|
31932
|
+
})
|
|
31933
|
+
);
|
|
31886
31934
|
const items = response.data.items.slice(offsetInPage, offsetInPage + limit).map((item) => ({
|
|
31887
31935
|
name: item.name,
|
|
31888
31936
|
path: item.path,
|
|
@@ -31908,11 +31956,20 @@ async function searchIssuesAndPrs(params) {
|
|
|
31908
31956
|
const offsetInPage = offset % per_page;
|
|
31909
31957
|
try {
|
|
31910
31958
|
const octokit = getOctokit();
|
|
31911
|
-
const
|
|
31959
|
+
const cacheKey = JSON.stringify({
|
|
31960
|
+
fn: "searchIssuesAndPrs",
|
|
31912
31961
|
q: params.query,
|
|
31913
31962
|
per_page,
|
|
31914
31963
|
page
|
|
31915
31964
|
});
|
|
31965
|
+
const response = await withCache(
|
|
31966
|
+
cacheKey,
|
|
31967
|
+
() => octokit.rest.search.issuesAndPullRequests({
|
|
31968
|
+
q: params.query,
|
|
31969
|
+
per_page,
|
|
31970
|
+
page
|
|
31971
|
+
})
|
|
31972
|
+
);
|
|
31916
31973
|
const items = response.data.items.slice(offsetInPage, offsetInPage + limit).map((item) => ({
|
|
31917
31974
|
title: item.title,
|
|
31918
31975
|
number: item.number,
|
|
@@ -31966,13 +32023,25 @@ async function listIssues(params) {
|
|
|
31966
32023
|
const offsetInPage = offset % per_page;
|
|
31967
32024
|
try {
|
|
31968
32025
|
const octokit = getOctokit();
|
|
31969
|
-
const
|
|
32026
|
+
const state = params.state || "all";
|
|
32027
|
+
const cacheKey = JSON.stringify({
|
|
32028
|
+
fn: "listIssues",
|
|
31970
32029
|
owner: params.owner,
|
|
31971
32030
|
repo: params.repo,
|
|
31972
|
-
state
|
|
32031
|
+
state,
|
|
31973
32032
|
per_page,
|
|
31974
32033
|
page
|
|
31975
32034
|
});
|
|
32035
|
+
const response = await withCache(
|
|
32036
|
+
cacheKey,
|
|
32037
|
+
() => octokit.rest.issues.listForRepo({
|
|
32038
|
+
owner: params.owner,
|
|
32039
|
+
repo: params.repo,
|
|
32040
|
+
state,
|
|
32041
|
+
per_page,
|
|
32042
|
+
page
|
|
32043
|
+
})
|
|
32044
|
+
);
|
|
31976
32045
|
const items = response.data.slice(offsetInPage, offsetInPage + limit).map((item) => ({
|
|
31977
32046
|
title: item.title,
|
|
31978
32047
|
number: item.number,
|
|
@@ -32049,13 +32118,25 @@ async function listPullRequests(params) {
|
|
|
32049
32118
|
const offsetInPage = offset % per_page;
|
|
32050
32119
|
try {
|
|
32051
32120
|
const octokit = getOctokit();
|
|
32052
|
-
const
|
|
32121
|
+
const state = params.state || "all";
|
|
32122
|
+
const cacheKey = JSON.stringify({
|
|
32123
|
+
fn: "listPullRequests",
|
|
32053
32124
|
owner: params.owner,
|
|
32054
32125
|
repo: params.repo,
|
|
32055
|
-
state
|
|
32126
|
+
state,
|
|
32056
32127
|
per_page,
|
|
32057
32128
|
page
|
|
32058
32129
|
});
|
|
32130
|
+
const response = await withCache(
|
|
32131
|
+
cacheKey,
|
|
32132
|
+
() => octokit.rest.pulls.list({
|
|
32133
|
+
owner: params.owner,
|
|
32134
|
+
repo: params.repo,
|
|
32135
|
+
state,
|
|
32136
|
+
per_page,
|
|
32137
|
+
page
|
|
32138
|
+
})
|
|
32139
|
+
);
|
|
32059
32140
|
const items = response.data.slice(offsetInPage, offsetInPage + limit).map((item) => ({
|
|
32060
32141
|
title: item.title,
|
|
32061
32142
|
number: item.number,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fre4x/github",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.45",
|
|
4
4
|
"description": "GitHub MCP server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && npx esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --format=esm --banner:js=\"#!/usr/bin/env node\"",
|
|
15
15
|
"typecheck": "cross-env NODE_OPTIONS=--max-old-space-size=4096 tsc --noEmit",
|
|
16
16
|
"dev": "tsx src/index.ts",
|
|
17
|
-
"inspector": "MOCK=true npx @modelcontextprotocol/inspector dist/index.js",
|
|
17
|
+
"inspector": "cross-env MOCK=true npx @modelcontextprotocol/inspector node dist/index.js",
|
|
18
18
|
"test": "vitest run --exclude dist",
|
|
19
19
|
"test:watch": "vitest"
|
|
20
20
|
},
|