@mushi-mushi/mcp-ci 0.6.4 → 0.6.5
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
CHANGED
|
@@ -53,13 +53,13 @@ jobs:
|
|
|
53
53
|
classify:
|
|
54
54
|
runs-on: ubuntu-latest
|
|
55
55
|
steps:
|
|
56
|
-
- uses:
|
|
56
|
+
- uses: kensaurus/mushi-mushi/packages/mcp-ci@master
|
|
57
57
|
with:
|
|
58
58
|
api-key: ${{ secrets.MUSHI_API_KEY }}
|
|
59
59
|
project-id: ${{ secrets.MUSHI_PROJECT_ID }}
|
|
60
60
|
command: trigger-judge
|
|
61
61
|
|
|
62
|
-
- uses:
|
|
62
|
+
- uses: kensaurus/mushi-mushi/packages/mcp-ci@master
|
|
63
63
|
with:
|
|
64
64
|
api-key: ${{ secrets.MUSHI_API_KEY }}
|
|
65
65
|
project-id: ${{ secrets.MUSHI_PROJECT_ID }}
|
|
@@ -79,7 +79,7 @@ jobs:
|
|
|
79
79
|
if: github.event.label.name == 'mushi:auto-fix'
|
|
80
80
|
runs-on: ubuntu-latest
|
|
81
81
|
steps:
|
|
82
|
-
- uses:
|
|
82
|
+
- uses: kensaurus/mushi-mushi/packages/mcp-ci@master
|
|
83
83
|
with:
|
|
84
84
|
api-key: ${{ secrets.MUSHI_API_KEY }}
|
|
85
85
|
project-id: ${{ secrets.MUSHI_PROJECT_ID }}
|
|
@@ -101,7 +101,7 @@ jobs:
|
|
|
101
101
|
- uses: actions/checkout@v4
|
|
102
102
|
|
|
103
103
|
# Refresh the crawler cookie so Gate 4 can hit auth-gated routes.
|
|
104
|
-
- uses:
|
|
104
|
+
- uses: kensaurus/mushi-mushi/packages/mcp-ci@master
|
|
105
105
|
with:
|
|
106
106
|
api-key: ${{ secrets.MUSHI_API_KEY }}
|
|
107
107
|
project-id: ${{ secrets.MUSHI_PROJECT_ID }}
|
|
@@ -111,14 +111,14 @@ jobs:
|
|
|
111
111
|
TEST_USER_PASSWORD: ${{ secrets.MUSHI_TEST_USER_PASSWORD }}
|
|
112
112
|
|
|
113
113
|
# Feed Gate 3 (api_contract) the current commit's API surface.
|
|
114
|
-
- uses:
|
|
114
|
+
- uses: kensaurus/mushi-mushi/packages/mcp-ci@master
|
|
115
115
|
with:
|
|
116
116
|
api-key: ${{ secrets.MUSHI_API_KEY }}
|
|
117
117
|
project-id: ${{ secrets.MUSHI_PROJECT_ID }}
|
|
118
118
|
command: discover-api
|
|
119
119
|
|
|
120
120
|
# Run Gates 1–5 server-side and gate the PR on the composite status.
|
|
121
|
-
- uses:
|
|
121
|
+
- uses: kensaurus/mushi-mushi/packages/mcp-ci@master
|
|
122
122
|
with:
|
|
123
123
|
api-key: ${{ secrets.MUSHI_API_KEY }}
|
|
124
124
|
project-id: ${{ secrets.MUSHI_PROJECT_ID }}
|
|
@@ -139,14 +139,14 @@ jobs:
|
|
|
139
139
|
runs-on: ubuntu-latest
|
|
140
140
|
steps:
|
|
141
141
|
- id: status
|
|
142
|
-
uses:
|
|
142
|
+
uses: kensaurus/mushi-mushi/packages/mcp-ci@master
|
|
143
143
|
with:
|
|
144
144
|
api-key: ${{ secrets.MUSHI_API_KEY }}
|
|
145
145
|
project-id: ${{ secrets.MUSHI_PROJECT_ID }}
|
|
146
146
|
command: discovery-status
|
|
147
147
|
|
|
148
148
|
- if: steps.status.outputs.ready_to_propose == 'true'
|
|
149
|
-
uses:
|
|
149
|
+
uses: kensaurus/mushi-mushi/packages/mcp-ci@master
|
|
150
150
|
with:
|
|
151
151
|
api-key: ${{ secrets.MUSHI_API_KEY }}
|
|
152
152
|
project-id: ${{ secrets.MUSHI_PROJECT_ID }}
|
|
@@ -192,4 +192,4 @@ MIT
|
|
|
192
192
|
<!-- mushi-readme-stats-footer -->
|
|
193
193
|
---
|
|
194
194
|
|
|
195
|
-
<sub>Monorepo scale (July 2026):
|
|
195
|
+
<sub>Monorepo scale (July 2026): 65 edge functions · 469 SQL migrations · 13 outbound plugins · 11 inbound adapters · 19 pipeline agents. Canonical counts: <a href="https://github.com/kensaurus/mushi-mushi/blob/master/docs/stats.md">docs/stats.md</a> · <code>pnpm docs-stats</code></sub>
|
package/dist/cli.js
CHANGED
|
@@ -123,7 +123,7 @@ async function main() {
|
|
|
123
123
|
const failOnBreaking = core.getInput("fail-on-breaking") !== "false";
|
|
124
124
|
const commitSha = core.getInput("commit-sha") || process.env.GITHUB_SHA || void 0;
|
|
125
125
|
const prNumber = core.getInput("pr-number") ? Number(core.getInput("pr-number")) : void 0;
|
|
126
|
-
const { runSpecDrift } = await import("./spec-drift-
|
|
126
|
+
const { runSpecDrift } = await import("./spec-drift-AHA6YMEE.js");
|
|
127
127
|
const diffFindings = await runSpecDrift({ baseSpec, headSpec });
|
|
128
128
|
core.info(`oasdiff found ${diffFindings.length} change(s)`);
|
|
129
129
|
core.setOutput("findings", JSON.stringify(diffFindings));
|
|
@@ -21,7 +21,8 @@ function getOasdiffUrl() {
|
|
|
21
21
|
}
|
|
22
22
|
async function downloadOasdiff() {
|
|
23
23
|
const cacheDir = join(homedir(), ".mushi", "tools");
|
|
24
|
-
mkdirSync(cacheDir, { recursive: true });
|
|
24
|
+
mkdirSync(cacheDir, { recursive: true, mode: 448 });
|
|
25
|
+
if (process.platform !== "win32") chmodSync(cacheDir, 448);
|
|
25
26
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
26
27
|
const binPath = join(cacheDir, `oasdiff-${OASDIFF_VERSION}${ext}`);
|
|
27
28
|
if (existsSync(binPath)) return binPath;
|
|
@@ -98,4 +99,4 @@ async function runSpecDrift(opts) {
|
|
|
98
99
|
export {
|
|
99
100
|
runSpecDrift
|
|
100
101
|
};
|
|
101
|
-
//# sourceMappingURL=spec-drift-
|
|
102
|
+
//# sourceMappingURL=spec-drift-AHA6YMEE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/spec-drift.ts"],"sourcesContent":["/**\n * spec-drift.ts — Gate 6 oasdiff-based OpenAPI spec drift detection.\n *\n * Downloads the oasdiff Go binary (static, no runtime deps) and runs\n * `oasdiff breaking <base> <head>` to find breaking API changes between\n * two OpenAPI spec versions.\n *\n * The binary is cached under ~/.mushi/tools/oasdiff-<version> after first download.\n * Version can be pinned via the OASDIFF_VERSION env var; defaults to latest.\n */\n\nimport { execFileSync } from 'node:child_process'\nimport { existsSync, mkdirSync, chmodSync, writeFileSync, mkdtempSync, rmSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport { createHash } from 'node:crypto'\n\nconst OASDIFF_VERSION = process.env.OASDIFF_VERSION ?? '1.10.18'\n\nconst PLATFORM_MAP: Record<string, string> = {\n 'linux-x64': 'linux-amd64',\n 'linux-arm64': 'linux-arm64',\n 'darwin-x64': 'darwin-amd64',\n 'darwin-arm64': 'darwin-arm64',\n 'win32-x64': 'windows-amd64',\n}\n\nfunction getOasdiffUrl(): string {\n const platformKey = `${process.platform}-${process.arch}`\n const platform = PLATFORM_MAP[platformKey]\n if (!platform) throw new Error(`Unsupported platform for oasdiff: ${platformKey}`)\n const ext = process.platform === 'win32' ? '.exe' : ''\n return (\n `https://github.com/Tufin/oasdiff/releases/download/v${OASDIFF_VERSION}/` +\n `oasdiff_${OASDIFF_VERSION}_${platform}${ext}.tar.gz`\n )\n}\n\nasync function downloadOasdiff(): Promise<string> {\n const cacheDir = join(homedir(), '.mushi', 'tools')\n // 0700: the download and extract dir stay private to this user. `mode` only\n // applies to directories mkdir creates, so tighten an existing one too.\n mkdirSync(cacheDir, { recursive: true, mode: 0o700 })\n if (process.platform !== 'win32') chmodSync(cacheDir, 0o700)\n const ext = process.platform === 'win32' ? '.exe' : ''\n const binPath = join(cacheDir, `oasdiff-${OASDIFF_VERSION}${ext}`)\n if (existsSync(binPath)) return binPath\n\n const url = getOasdiffUrl()\n const res = await fetch(url)\n if (!res.ok) throw new Error(`Failed to download oasdiff: HTTP ${res.status} from ${url}`)\n\n const buf = Buffer.from(await res.arrayBuffer())\n const maxBytes = 64 * 1024 * 1024\n if (buf.length > maxBytes) {\n throw new Error(`oasdiff download too large (${buf.length} bytes) — aborting`)\n }\n\n // Store under ~/.mushi/tools (mode 0700 dir) instead of the world-readable\n // system temp dir — avoids CodeQL insecure-temp-file + keeps cache reusable.\n const tgzPath = join(cacheDir, `oasdiff-${createHash('md5').update(url).digest('hex')}.tar.gz`)\n writeFileSync(tgzPath, buf)\n\n const extractDir = mkdtempSync(join(cacheDir, 'oasdiff-extract-'))\n try {\n execFileSync('tar', ['-xzf', tgzPath, '-C', extractDir])\n\n const { readdirSync, copyFileSync } = await import('node:fs')\n const files = readdirSync(extractDir)\n const binName = process.platform === 'win32' ? 'oasdiff.exe' : 'oasdiff'\n const found = files.find((f) => f === binName || f.startsWith('oasdiff'))\n if (!found) throw new Error(`oasdiff binary not found in archive. Files: ${files.join(', ')}`)\n copyFileSync(join(extractDir, found), binPath)\n if (process.platform !== 'win32') chmodSync(binPath, 0o755)\n } finally {\n rmSync(extractDir, { recursive: true, force: true })\n rmSync(tgzPath, { force: true })\n }\n return binPath\n}\n\nexport interface SpecDriftFinding {\n severity: 'error' | 'warn' | 'info'\n rule_id: string\n message: string\n path?: string\n method?: string\n}\n\nexport async function runSpecDrift(opts: {\n baseSpec: string\n headSpec: string\n}): Promise<SpecDriftFinding[]> {\n let binPath: string\n try {\n binPath = await downloadOasdiff()\n } catch (err) {\n throw new Error(`oasdiff download failed: ${err instanceof Error ? err.message : String(err)}`)\n }\n\n let output = ''\n try {\n output = execFileSync(binPath, ['breaking', opts.baseSpec, opts.headSpec, '--format', 'json'], {\n encoding: 'utf-8',\n timeout: 30_000,\n // oasdiff exits 1 when breaking changes are found — that's expected.\n // We catch the error and still parse stdout.\n })\n } catch (err) {\n // execFileSync throws on non-zero exit. Capture stdout from the error object.\n const execErr = err as { stdout?: string; stderr?: string; status?: number }\n output = execErr.stdout ?? ''\n // If no stdout and non-zero exit, it's a real failure (e.g. binary crash).\n if (!output && execErr.status !== 1) {\n throw new Error(\n `oasdiff failed: ${execErr.stderr ?? String(err)}`,\n )\n }\n }\n\n if (!output.trim()) return []\n\n let parsed: unknown\n try {\n parsed = JSON.parse(output)\n } catch {\n // oasdiff may output plain text in some versions — wrap as a single warning.\n return [{ severity: 'warn', rule_id: 'spec-drift-parse-error', message: output.slice(0, 500) }]\n }\n\n // oasdiff JSON output: array of { id, text, level, operation, operationId, path, source }\n const items = Array.isArray(parsed) ? parsed : []\n return items.map((item: Record<string, unknown>) => {\n const level = String(item.level ?? 'error').toLowerCase()\n const severity: SpecDriftFinding['severity'] =\n level === 'error' || level === 'breaking' ? 'error'\n : level === 'warn' || level === 'warning' ? 'warn'\n : 'info'\n return {\n severity,\n rule_id: String(item.id ?? 'spec-drift'),\n message: String(item.text ?? item.message ?? JSON.stringify(item)),\n path: item.path ? String(item.path) : undefined,\n method: item.operation ? String(item.operation) : undefined,\n }\n })\n}\n"],"mappings":";AAWA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,WAAW,WAAW,eAAe,aAAa,cAAc;AACrF,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAE3B,IAAM,kBAAkB,QAAQ,IAAI,mBAAmB;AAEvD,IAAM,eAAuC;AAAA,EAC3C,aAAa;AAAA,EACb,eAAe;AAAA,EACf,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,aAAa;AACf;AAEA,SAAS,gBAAwB;AAC/B,QAAM,cAAc,GAAG,QAAQ,QAAQ,IAAI,QAAQ,IAAI;AACvD,QAAM,WAAW,aAAa,WAAW;AACzC,MAAI,CAAC,SAAU,OAAM,IAAI,MAAM,qCAAqC,WAAW,EAAE;AACjF,QAAM,MAAM,QAAQ,aAAa,UAAU,SAAS;AACpD,SACE,uDAAuD,eAAe,YAC3D,eAAe,IAAI,QAAQ,GAAG,GAAG;AAEhD;AAEA,eAAe,kBAAmC;AAChD,QAAM,WAAW,KAAK,QAAQ,GAAG,UAAU,OAAO;AAGlD,YAAU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,KAAK,QAAQ,KAAK,WAAW,KAAK,UAAU,IAAI,CAAC;AAAA,MACjE,MAAM,KAAK,OAAO,OAAO,KAAK,IAAI,IAAI;AAAA,MACtC,QAAQ,KAAK,YAAY,OAAO,KAAK,SAAS,IAAI;AAAA,IACpD;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mushi-mushi/mcp-ci",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "GitHub Action entrypoint for running Mushi Mushi MCP tools in CI — trigger judge, dispatch fixes, gate merges on classification coverage.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/spec-drift.ts"],"sourcesContent":["/**\n * spec-drift.ts — Gate 6 oasdiff-based OpenAPI spec drift detection.\n *\n * Downloads the oasdiff Go binary (static, no runtime deps) and runs\n * `oasdiff breaking <base> <head>` to find breaking API changes between\n * two OpenAPI spec versions.\n *\n * The binary is cached under ~/.mushi/oasdiff-<version> after first download.\n * Version can be pinned via the OASDIFF_VERSION env var; defaults to latest.\n */\n\nimport { execFileSync } from 'node:child_process'\nimport { existsSync, mkdirSync, chmodSync, writeFileSync, mkdtempSync, rmSync } from 'node:fs'\nimport { homedir } from 'node:os'\nimport { join } from 'node:path'\nimport { createHash } from 'node:crypto'\n\nconst OASDIFF_VERSION = process.env.OASDIFF_VERSION ?? '1.10.18'\n\nconst PLATFORM_MAP: Record<string, string> = {\n 'linux-x64': 'linux-amd64',\n 'linux-arm64': 'linux-arm64',\n 'darwin-x64': 'darwin-amd64',\n 'darwin-arm64': 'darwin-arm64',\n 'win32-x64': 'windows-amd64',\n}\n\nfunction getOasdiffUrl(): string {\n const platformKey = `${process.platform}-${process.arch}`\n const platform = PLATFORM_MAP[platformKey]\n if (!platform) throw new Error(`Unsupported platform for oasdiff: ${platformKey}`)\n const ext = process.platform === 'win32' ? '.exe' : ''\n return (\n `https://github.com/Tufin/oasdiff/releases/download/v${OASDIFF_VERSION}/` +\n `oasdiff_${OASDIFF_VERSION}_${platform}${ext}.tar.gz`\n )\n}\n\nasync function downloadOasdiff(): Promise<string> {\n const cacheDir = join(homedir(), '.mushi', 'tools')\n mkdirSync(cacheDir, { recursive: true })\n const ext = process.platform === 'win32' ? '.exe' : ''\n const binPath = join(cacheDir, `oasdiff-${OASDIFF_VERSION}${ext}`)\n if (existsSync(binPath)) return binPath\n\n const url = getOasdiffUrl()\n const res = await fetch(url)\n if (!res.ok) throw new Error(`Failed to download oasdiff: HTTP ${res.status} from ${url}`)\n\n const buf = Buffer.from(await res.arrayBuffer())\n const maxBytes = 64 * 1024 * 1024\n if (buf.length > maxBytes) {\n throw new Error(`oasdiff download too large (${buf.length} bytes) — aborting`)\n }\n\n // Store under ~/.mushi/tools (mode 0700 dir) instead of the world-readable\n // system temp dir — avoids CodeQL insecure-temp-file + keeps cache reusable.\n const tgzPath = join(cacheDir, `oasdiff-${createHash('md5').update(url).digest('hex')}.tar.gz`)\n writeFileSync(tgzPath, buf)\n\n const extractDir = mkdtempSync(join(cacheDir, 'oasdiff-extract-'))\n try {\n execFileSync('tar', ['-xzf', tgzPath, '-C', extractDir])\n\n const { readdirSync, copyFileSync } = await import('node:fs')\n const files = readdirSync(extractDir)\n const binName = process.platform === 'win32' ? 'oasdiff.exe' : 'oasdiff'\n const found = files.find((f) => f === binName || f.startsWith('oasdiff'))\n if (!found) throw new Error(`oasdiff binary not found in archive. Files: ${files.join(', ')}`)\n copyFileSync(join(extractDir, found), binPath)\n if (process.platform !== 'win32') chmodSync(binPath, 0o755)\n } finally {\n rmSync(extractDir, { recursive: true, force: true })\n rmSync(tgzPath, { force: true })\n }\n return binPath\n}\n\nexport interface SpecDriftFinding {\n severity: 'error' | 'warn' | 'info'\n rule_id: string\n message: string\n path?: string\n method?: string\n}\n\nexport async function runSpecDrift(opts: {\n baseSpec: string\n headSpec: string\n}): Promise<SpecDriftFinding[]> {\n let binPath: string\n try {\n binPath = await downloadOasdiff()\n } catch (err) {\n throw new Error(`oasdiff download failed: ${err instanceof Error ? err.message : String(err)}`)\n }\n\n let output = ''\n try {\n output = execFileSync(binPath, ['breaking', opts.baseSpec, opts.headSpec, '--format', 'json'], {\n encoding: 'utf-8',\n timeout: 30_000,\n // oasdiff exits 1 when breaking changes are found — that's expected.\n // We catch the error and still parse stdout.\n })\n } catch (err) {\n // execFileSync throws on non-zero exit. Capture stdout from the error object.\n const execErr = err as { stdout?: string; stderr?: string; status?: number }\n output = execErr.stdout ?? ''\n // If no stdout and non-zero exit, it's a real failure (e.g. binary crash).\n if (!output && execErr.status !== 1) {\n throw new Error(\n `oasdiff failed: ${execErr.stderr ?? String(err)}`,\n )\n }\n }\n\n if (!output.trim()) return []\n\n let parsed: unknown\n try {\n parsed = JSON.parse(output)\n } catch {\n // oasdiff may output plain text in some versions — wrap as a single warning.\n return [{ severity: 'warn', rule_id: 'spec-drift-parse-error', message: output.slice(0, 500) }]\n }\n\n // oasdiff JSON output: array of { id, text, level, operation, operationId, path, source }\n const items = Array.isArray(parsed) ? parsed : []\n return items.map((item: Record<string, unknown>) => {\n const level = String(item.level ?? 'error').toLowerCase()\n const severity: SpecDriftFinding['severity'] =\n level === 'error' || level === 'breaking' ? 'error'\n : level === 'warn' || level === 'warning' ? 'warn'\n : 'info'\n return {\n severity,\n rule_id: String(item.id ?? 'spec-drift'),\n message: String(item.text ?? item.message ?? JSON.stringify(item)),\n path: item.path ? String(item.path) : undefined,\n method: item.operation ? String(item.operation) : undefined,\n }\n })\n}\n"],"mappings":";AAWA,SAAS,oBAAoB;AAC7B,SAAS,YAAY,WAAW,WAAW,eAAe,aAAa,cAAc;AACrF,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAE3B,IAAM,kBAAkB,QAAQ,IAAI,mBAAmB;AAEvD,IAAM,eAAuC;AA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