@mushi-mushi/mcp-ci 0.4.0 → 0.5.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/CONTRIBUTING.md +27 -0
- package/README.md +6 -0
- package/dist/cli.js +37 -1
- package/dist/cli.js.map +1 -1
- package/dist/spec-drift-XRT7XUJU.js +93 -0
- package/dist/spec-drift-XRT7XUJU.js.map +1 -0
- package/package.json +9 -7
package/CONTRIBUTING.md
CHANGED
|
@@ -91,6 +91,33 @@ pnpm changeset
|
|
|
91
91
|
|
|
92
92
|
Select the affected packages, the semver bump type, and write a summary. The changeset file gets committed with your PR.
|
|
93
93
|
|
|
94
|
+
## Release flow
|
|
95
|
+
|
|
96
|
+
Releases are fully automated. Maintainers don't run `npm publish` by hand.
|
|
97
|
+
|
|
98
|
+
1. PRs land on `master` with one or more changeset files in `.changeset/`.
|
|
99
|
+
2. `release.yml` runs on every push to `master`. It opens (or updates) a `chore: version packages` PR that bumps every affected `package.json`, rolls up the changelogs, and deletes the consumed changesets.
|
|
100
|
+
3. Merging that "Version Packages" PR re-fires `release.yml`. The publish step authenticates to npm via **OpenID Connect (OIDC) Trusted Publishers** — no long-lived `NPM_TOKEN` is exchanged — and every tarball ships with a **Sigstore provenance attestation** uploaded to the public transparency log.
|
|
101
|
+
|
|
102
|
+
If GitHub's anti-loop protection suppresses the auto re-fire (the squash merge can be attributed to `github-actions[bot]`), trigger the workflow manually: **Actions → release → Run workflow → master**.
|
|
103
|
+
|
|
104
|
+
### Adding a brand-new publishable package
|
|
105
|
+
|
|
106
|
+
Trusted Publisher bindings are configured **per package** on `npmjs.com` and require the package to already exist on the registry. New packages therefore need a one-time bootstrap before OIDC can take over.
|
|
107
|
+
|
|
108
|
+
1. Add the package under `packages/<name>/` with a real `version`, `files`, `publishConfig.access: "public"`, `LICENSE`, and the standard fields enforced by `pnpm check:publish-readiness`.
|
|
109
|
+
2. Build it locally: `pnpm install && pnpm -r build`.
|
|
110
|
+
3. Mint a short-lived granular access token at `https://www.npmjs.com/settings/<your-user>/tokens/granular-access-tokens/new` — **Bypass 2FA: ON**, **Read and write: All packages**, **Expiration: 7 days**.
|
|
111
|
+
4. Bootstrap-publish:
|
|
112
|
+
```bash
|
|
113
|
+
NPM_TOKEN=npm_xxx pnpm bootstrap:new-package
|
|
114
|
+
```
|
|
115
|
+
The script auto-detects which workspace packages are missing on npm and publishes them via `pnpm publish --no-provenance` (so `workspace:^` specifiers get rewritten to real semver in the tarball).
|
|
116
|
+
5. The script prints one URL per freshly-published package. Open each, click **GitHub Actions** under "Trusted Publisher", confirm the auto-filled fields (`<owner>` / `<repo>` / `release.yml`), and tap your security key.
|
|
117
|
+
6. Revoke the bootstrap token at `https://www.npmjs.com/settings/<your-user>/tokens`.
|
|
118
|
+
|
|
119
|
+
From the next changeset bump onward, that package publishes through the normal `release.yml` flow with full OIDC provenance — same as the rest.
|
|
120
|
+
|
|
94
121
|
## Code Style
|
|
95
122
|
|
|
96
123
|
- **TypeScript strict mode** — no `any` unless absolutely necessary
|
package/README.md
CHANGED
|
@@ -182,3 +182,9 @@ jobs:
|
|
|
182
182
|
## License
|
|
183
183
|
|
|
184
184
|
MIT
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
<!-- mushi-readme-stats-footer -->
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
<sub>Monorepo scale (June 2026): 43 edge functions · 234 SQL migrations · 13 outbound plugins · 11 inbound adapters. 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
|
@@ -106,11 +106,47 @@ async function main() {
|
|
|
106
106
|
handleResult(persist, failOnQuota);
|
|
107
107
|
break;
|
|
108
108
|
}
|
|
109
|
+
case "spec-drift": {
|
|
110
|
+
const baseSpec = core.getInput("base-spec", { required: true });
|
|
111
|
+
const headSpec = core.getInput("head-spec", { required: true });
|
|
112
|
+
const failOnBreaking = core.getInput("fail-on-breaking") !== "false";
|
|
113
|
+
const commitSha = core.getInput("commit-sha") || process.env.GITHUB_SHA || void 0;
|
|
114
|
+
const prNumber = core.getInput("pr-number") ? Number(core.getInput("pr-number")) : void 0;
|
|
115
|
+
const { runSpecDrift } = await import("./spec-drift-XRT7XUJU.js");
|
|
116
|
+
const diffFindings = await runSpecDrift({ baseSpec, headSpec });
|
|
117
|
+
core.info(`oasdiff found ${diffFindings.length} change(s)`);
|
|
118
|
+
core.setOutput("findings", JSON.stringify(diffFindings));
|
|
119
|
+
const breaking = diffFindings.filter((f) => f.severity === "error");
|
|
120
|
+
const warnings = diffFindings.filter((f) => f.severity === "warn");
|
|
121
|
+
const gateBody = {
|
|
122
|
+
gates: ["spec_drift"],
|
|
123
|
+
spec_diff_findings: diffFindings,
|
|
124
|
+
commit_sha: commitSha,
|
|
125
|
+
pr_number: prNumber
|
|
126
|
+
};
|
|
127
|
+
await api(
|
|
128
|
+
endpoint,
|
|
129
|
+
apiKey,
|
|
130
|
+
projectId,
|
|
131
|
+
`/v1/admin/inventory/${projectId}/gates/run`,
|
|
132
|
+
{ method: "POST", body: JSON.stringify(gateBody) }
|
|
133
|
+
);
|
|
134
|
+
if (breaking.length > 0 && failOnBreaking) {
|
|
135
|
+
core.setFailed(
|
|
136
|
+
`Mushi Gate 6 (spec_drift): ${breaking.length} breaking change(s) detected. Review in the admin console \u2192 Inventory \u2192 Gates.`
|
|
137
|
+
);
|
|
138
|
+
} else if (warnings.length > 0) {
|
|
139
|
+
core.warning(`Mushi Gate 6 (spec_drift): ${warnings.length} potentially-breaking change(s).`);
|
|
140
|
+
} else {
|
|
141
|
+
core.info("Mushi Gate 6 (spec_drift): no breaking changes.");
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
109
145
|
case "gates": {
|
|
110
146
|
const commitSha = core.getInput("commit-sha") || process.env.GITHUB_SHA || "";
|
|
111
147
|
const prNumber = core.getInput("pr-number") || "";
|
|
112
148
|
const gatesArg = core.getInput("gates") || "all";
|
|
113
|
-
const gates = gatesArg === "all" ? ["dead_handler", "mock_leak", "api_contract", "crawl", "status_claim"] : gatesArg.split(",").map((g) => g.trim()).filter(Boolean);
|
|
149
|
+
const gates = gatesArg === "all" ? ["dead_handler", "mock_leak", "api_contract", "crawl", "status_claim", "orphan_endpoint", "unknown_call"] : gatesArg.split(",").map((g) => g.trim()).filter(Boolean);
|
|
114
150
|
const body = {
|
|
115
151
|
commit_sha: commitSha || void 0,
|
|
116
152
|
pr_number: prNumber ? Number(prNumber) : void 0,
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport * as core from '@actions/core'\n\n/**\n * Wave G2 — GitHub Action entrypoint.\n *\n * Intentionally NOT a full MCP client. The Action runs in a short-lived CI\n * job where spinning up an MCP server + stdio transport would add latency\n * for zero benefit. We hit the same REST endpoints the MCP tools call\n * (`/v1/admin/*`) directly, forward the result, and fail/pass the step.\n *\n * If a user wants the full MCP experience in CI, they install the\n * `@mushi-mushi/mcp` npm package and talk to it over stdio from their own\n * Claude Code / Codex CLI step. This Action is the 80% glue path: \"hey CI,\n * block merging until Mushi finishes triaging my reports\".\n */\n\ninterface ApiResp<T = unknown> { ok: boolean; data?: T; error?: { code: string; message: string } }\n\nasync function api<T>(endpoint: string, apiKey: string, projectId: string, path: string, init?: RequestInit): Promise<ApiResp<T>> {\n const res = await fetch(`${endpoint}${path}`, {\n ...init,\n headers: {\n 'Content-Type': 'application/json',\n 'X-Mushi-Api-Key': apiKey,\n 'X-Mushi-Project': projectId,\n ...(init?.headers ?? {}),\n },\n })\n const text = await res.text()\n let body: ApiResp<T>\n try { body = JSON.parse(text) as ApiResp<T> } catch { body = { ok: false, error: { code: `HTTP_${res.status}`, message: text.slice(0, 500) } } }\n return body\n}\n\nasync function main(): Promise<void> {\n const apiKey = core.getInput('api-key', { required: true })\n const projectId = core.getInput('project-id', { required: true })\n const endpoint = core.getInput('api-endpoint').replace(/\\/$/, '')\n const command = core.getInput('command', { required: true })\n const failOnQuota = core.getInput('fail-on-quota') !== 'false'\n\n switch (command) {\n case 'trigger-judge': {\n const res = await api(endpoint, apiKey, projectId, '/v1/admin/judge/run', {\n method: 'POST',\n body: JSON.stringify({ limit: 50, projectId }),\n })\n handleResult(res, failOnQuota)\n break\n }\n case 'dispatch-fix': {\n const reportId = core.getInput('report-id', { required: true })\n // Optional spec-traceability anchor (whitepaper §2.10). When provided\n // the worker skips the graph walk to recover the inventory Action and\n // includes its expected_outcome contract verbatim in the LLM prompt.\n const inventoryActionNodeId = core.getInput('inventory-action-node-id') || undefined\n const body: Record<string, unknown> = { reportId }\n if (inventoryActionNodeId) body.inventoryActionNodeId = inventoryActionNodeId\n const res = await api(endpoint, apiKey, projectId, '/v1/admin/fixes/dispatch', {\n method: 'POST',\n body: JSON.stringify(body),\n })\n handleResult(res, failOnQuota)\n break\n }\n case 'check-coverage': {\n const minCoverage = Number(core.getInput('min-coverage') || '0.8')\n const res = await api<{ total: number; classified: number }>(endpoint, apiKey, projectId, '/v1/admin/stats')\n if (!res.ok || !res.data) {\n core.setFailed(`stats query failed: ${res.error?.message ?? 'unknown'}`)\n return\n }\n const ratio = res.data.total === 0 ? 1 : res.data.classified / res.data.total\n core.setOutput('coverage', ratio.toFixed(3))\n core.setOutput('result', JSON.stringify(res.data))\n if (ratio < minCoverage) {\n core.setFailed(`classification coverage ${ratio.toFixed(3)} below threshold ${minCoverage}`)\n } else {\n core.info(`classification coverage ${ratio.toFixed(3)} >= ${minCoverage} ✓`)\n }\n break\n }\n case 'query': {\n const question = core.getInput('question', { required: true })\n const res = await api(endpoint, apiKey, projectId, '/v1/admin/query', {\n method: 'POST',\n body: JSON.stringify({ question }),\n })\n handleResult(res, failOnQuota)\n break\n }\n case 'discover-api': {\n // Mushi v2 Gate 3 helper — walk the customer repo for Next.js\n // route handlers + OpenAPI + (optionally) Supabase introspection\n // and POST the resulting `discovered_apis` to the inventory-gates\n // function. The next gates run consumes this blob to compute the\n // api_contract diff.\n const { discoverRoutes } = await import('./api-contract.js')\n const repoRoot = core.getInput('repo-root') || process.cwd()\n const openapiFile = core.getInput('openapi-file') || undefined\n const supabaseUrl = core.getInput('supabase-url') || undefined\n const supabaseAnonKey = core.getInput('supabase-anon-key') || undefined\n const routes = await discoverRoutes({\n repoRoot,\n openapiFile,\n supabaseUrl,\n supabaseAnonKey,\n })\n core.info(`Discovered ${routes.length} routes`)\n core.setOutput('result', JSON.stringify({ routes }))\n // Persist as a synthetic crawl summary so Gate 3 picks it up\n // without needing a real crawl run.\n const persist = await api(\n endpoint,\n apiKey,\n projectId,\n `/v1/admin/inventory/${projectId}/gates/run`,\n {\n method: 'POST',\n body: JSON.stringify({\n gates: ['api_contract'],\n findings: [],\n commit_sha: process.env.GITHUB_SHA,\n discovered_apis: routes,\n }),\n },\n )\n handleResult(persist, failOnQuota)\n break\n }\n case 'gates': {\n // Mushi v2: run all five pre-release gates against the current\n // commit and post a single composite GitHub status.\n //\n // Gates 1 + 2 (lint) run inside this Action's checkout; Gates 3\n // + 4 + 5 are server-side and reachable via /v1/admin/inventory.\n // The Action then reads back the consolidated gate_runs and\n // sets a single pass/fail on the calling workflow.\n const commitSha = core.getInput('commit-sha') || process.env.GITHUB_SHA || ''\n const prNumber = core.getInput('pr-number') || ''\n const gatesArg = core.getInput('gates') || 'all'\n const gates =\n gatesArg === 'all'\n ? ['dead_handler', 'mock_leak', 'api_contract', 'crawl', 'status_claim']\n : gatesArg.split(',').map((g) => g.trim()).filter(Boolean)\n\n const body = {\n commit_sha: commitSha || undefined,\n pr_number: prNumber ? Number(prNumber) : undefined,\n gates,\n }\n const res = await api<{\n runs: Array<{ gate: string; status: string; findings_count: number }>\n }>(\n endpoint,\n apiKey,\n projectId,\n `/v1/admin/inventory/${projectId}/gates/run`,\n { method: 'POST', body: JSON.stringify(body) },\n )\n core.setOutput('result', JSON.stringify(res))\n if (!res.ok) {\n if (res.error?.code === 'QUOTA_EXCEEDED' && !failOnQuota) {\n core.warning(`quota exceeded, skipping: ${res.error?.message}`)\n break\n }\n core.setFailed(`gates run failed: ${res.error?.code ?? 'unknown'} ${res.error?.message ?? ''}`)\n break\n }\n const runs = res.data?.runs ?? []\n const failed = runs.filter((r) => r.status === 'fail')\n const warned = runs.filter((r) => r.status === 'warn')\n const summary = runs\n .map((r) => `${gateGlyph(r.status)} ${r.gate} (${r.findings_count})`)\n .join(' · ')\n core.info(`Mushi gates: ${summary}`)\n if (failed.length > 0) {\n core.setFailed(\n `Mushi gate failures: ${failed.map((r) => r.gate).join(', ')}. ` +\n `View details on /inventory in the admin console.`,\n )\n } else if (warned.length > 0) {\n core.warning(`Mushi gate warnings: ${warned.map((r) => r.gate).join(', ')}.`)\n }\n break\n }\n case 'discovery-status': {\n // Mushi v2.1 — read out how much SDK passive-discovery data the\n // server has. Useful in CI to gate \"should we propose yet?\".\n const res = await api<{\n routes: unknown[]\n total_events: number\n ready_to_propose: boolean\n }>(endpoint, apiKey, projectId, `/v1/admin/inventory/${projectId}/discovery`)\n core.setOutput('result', JSON.stringify(res))\n if (!res.ok) {\n core.setFailed(`discovery-status failed: ${res.error?.code ?? 'unknown'}`)\n break\n }\n const ready = res.data?.ready_to_propose ?? false\n core.setOutput('ready_to_propose', String(ready))\n core.setOutput('total_events', String(res.data?.total_events ?? 0))\n core.setOutput('route_count', String((res.data?.routes ?? []).length))\n core.info(\n `Mushi discovery: ${res.data?.total_events ?? 0} events across ${(res.data?.routes ?? []).length} routes; ${ready ? 'ready to propose' : 'not yet ready'}.`,\n )\n break\n }\n case 'propose': {\n // Mushi v2.1 — kick off the LLM proposer. Synchronous: returns\n // the proposalId so a follow-up step can comment on the PR.\n const res = await api<{ proposalId: string; storyCount: number; pageCount: number }>(\n endpoint,\n apiKey,\n projectId,\n `/v1/admin/inventory/${projectId}/propose`,\n { method: 'POST', body: '{}' },\n )\n handleResult(res, failOnQuota)\n if (res.ok && res.data) {\n core.info(\n `Mushi proposed ${res.data.storyCount} stories / ${res.data.pageCount} pages — open /inventory ▸ Discovery to review.`,\n )\n core.setOutput('proposal_id', res.data.proposalId)\n }\n break\n }\n case 'auth-bootstrap': {\n // Mushi v2.1 — refresh the crawler cookie via the scripted-auth\n // runner. We don't run Playwright inside this Action's process\n // (browsers add ~600 MB to the image); instead we invoke the\n // published @mushi-mushi/inventory-auth-runner via `npx`. The\n // runner POSTs the cookie back to the settings endpoint we\n // expose; this Action just orchestrates.\n //\n // The bin name (`mushi-mushi-auth`) intentionally differs from\n // the unscoped package name (`inventory-auth-runner`), so we use\n // `-p <package> <bin>` instead of the bare `npx <package>` form\n // — the bare form would fail with `command not found` because\n // npx tries to invoke a bin that matches the unscoped name.\n const cmd = `npx --yes -p @mushi-mushi/inventory-auth-runner mushi-mushi-auth refresh`\n core.info(`mushi auth-bootstrap → ${cmd}`)\n const env = {\n ...process.env,\n MUSHI_API_KEY: apiKey,\n MUSHI_PROJECT: projectId,\n MUSHI_API_ENDPOINT: endpoint,\n }\n const { spawnSync } = await import('node:child_process')\n const res = spawnSync(cmd, { shell: true, env, stdio: 'inherit' })\n if ((res.status ?? 0) !== 0) {\n core.setFailed(`auth-bootstrap failed (exit ${res.status})`)\n } else {\n core.info('auth-bootstrap: cookie refreshed.')\n }\n break\n }\n default:\n core.setFailed(\n `unknown command: ${command}. Expected trigger-judge | dispatch-fix | check-coverage | query | gates | discover-api | discovery-status | propose | auth-bootstrap.`,\n )\n }\n}\n\nfunction gateGlyph(status: string): string {\n if (status === 'pass') return '✅'\n if (status === 'fail') return '❌'\n if (status === 'warn') return '⚠️'\n if (status === 'skipped') return '⏭️'\n return '⏺️'\n}\n\nfunction handleResult(res: ApiResp<unknown>, failOnQuota: boolean): void {\n core.setOutput('result', JSON.stringify(res))\n if (!res.ok) {\n if (res.error?.code === 'QUOTA_EXCEEDED' && !failOnQuota) {\n core.warning(`quota exceeded, skipping: ${res.error?.message}`)\n return\n }\n core.setFailed(`${res.error?.code ?? 'ERROR'}: ${res.error?.message ?? 'unknown'}`)\n return\n }\n core.info(`Mushi ok: ${JSON.stringify(res.data).slice(0, 500)}`)\n}\n\nmain().catch((err) => {\n core.setFailed((err as Error).message)\n})\n"],"mappings":";;;AACA,YAAY,UAAU;AAkBtB,eAAe,IAAO,UAAkB,QAAgB,WAAmB,MAAc,MAAyC;AAChI,QAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,IAAI,IAAI;AAAA,IAC5C,GAAG;AAAA,IACH,SAAS;AAAA,MACP,gBAAgB;AAAA,MAChB,mBAAmB;AAAA,MACnB,mBAAmB;AAAA,MACnB,GAAI,MAAM,WAAW,CAAC;AAAA,IACxB;AAAA,EACF,CAAC;AACD,QAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,MAAI;AACJ,MAAI;AAAE,WAAO,KAAK,MAAM,IAAI;AAAA,EAAgB,QAAQ;AAAE,WAAO,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,QAAQ,IAAI,MAAM,IAAI,SAAS,KAAK,MAAM,GAAG,GAAG,EAAE,EAAE;AAAA,EAAE;AAC/I,SAAO;AACT;AAEA,eAAe,OAAsB;AACnC,QAAM,SAAc,cAAS,WAAW,EAAE,UAAU,KAAK,CAAC;AAC1D,QAAM,YAAiB,cAAS,cAAc,EAAE,UAAU,KAAK,CAAC;AAChE,QAAM,WAAgB,cAAS,cAAc,EAAE,QAAQ,OAAO,EAAE;AAChE,QAAM,UAAe,cAAS,WAAW,EAAE,UAAU,KAAK,CAAC;AAC3D,QAAM,cAAmB,cAAS,eAAe,MAAM;AAEvD,UAAQ,SAAS;AAAA,IACf,KAAK,iBAAiB;AACpB,YAAM,MAAM,MAAM,IAAI,UAAU,QAAQ,WAAW,uBAAuB;AAAA,QACxE,QAAQ;AAAA,QACR,MAAM,KAAK,UAAU,EAAE,OAAO,IAAI,UAAU,CAAC;AAAA,MAC/C,CAAC;AACD,mBAAa,KAAK,WAAW;AAC7B;A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QAAK,eAAU,+BAA+B,IAAI,MAAM,GAAG;AAAA,MAC7D,OAAO;AACL,QAAK,UAAK,mCAAmC;AAAA,MAC/C;AACA;AAAA,IACF;AAAA,IACA;AACE,MAAK;AAAA,QACH,oBAAoB,OAAO;AAAA,MAC7B;AAAA,EACJ;AACF;AAEA,SAAS,UAAU,QAAwB;AACzC,MAAI,WAAW,OAAQ,QAAO;AAC9B,MAAI,WAAW,OAAQ,QAAO;AAC9B,MAAI,WAAW,OAAQ,QAAO;AAC9B,MAAI,WAAW,UAAW,QAAO;AACjC,SAAO;AACT;AAEA,SAAS,aAAa,KAAuB,aAA4B;AACvE,EAAK,eAAU,UAAU,KAAK,UAAU,GAAG,CAAC;AAC5C,MAAI,CAAC,IAAI,IAAI;AACX,QAAI,IAAI,OAAO,SAAS,oBAAoB,CAAC,aAAa;AACxD,MAAK,aAAQ,6BAA6B,IAAI,OAAO,OAAO,EAAE;AAC9D;AAAA,IACF;AACA,IAAK,eAAU,GAAG,IAAI,OAAO,QAAQ,OAAO,KAAK,IAAI,OAAO,WAAW,SAAS,EAAE;AAClF;AAAA,EACF;AACA,EAAK,UAAK,aAAa,KAAK,UAAU,IAAI,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,EAAE;AACjE;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,EAAK,eAAW,IAAc,OAAO;AACvC,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport * as core from '@actions/core'\n\n/**\n * Wave G2 — GitHub Action entrypoint.\n *\n * Intentionally NOT a full MCP client. The Action runs in a short-lived CI\n * job where spinning up an MCP server + stdio transport would add latency\n * for zero benefit. We hit the same REST endpoints the MCP tools call\n * (`/v1/admin/*`) directly, forward the result, and fail/pass the step.\n *\n * If a user wants the full MCP experience in CI, they install the\n * `@mushi-mushi/mcp` npm package and talk to it over stdio from their own\n * Claude Code / Codex CLI step. This Action is the 80% glue path: \"hey CI,\n * block merging until Mushi finishes triaging my reports\".\n */\n\ninterface ApiResp<T = unknown> { ok: boolean; data?: T; error?: { code: string; message: string } }\n\nasync function api<T>(endpoint: string, apiKey: string, projectId: string, path: string, init?: RequestInit): Promise<ApiResp<T>> {\n const res = await fetch(`${endpoint}${path}`, {\n ...init,\n headers: {\n 'Content-Type': 'application/json',\n 'X-Mushi-Api-Key': apiKey,\n 'X-Mushi-Project': projectId,\n ...(init?.headers ?? {}),\n },\n })\n const text = await res.text()\n let body: ApiResp<T>\n try { body = JSON.parse(text) as ApiResp<T> } catch { body = { ok: false, error: { code: `HTTP_${res.status}`, message: text.slice(0, 500) } } }\n return body\n}\n\nasync function main(): Promise<void> {\n const apiKey = core.getInput('api-key', { required: true })\n const projectId = core.getInput('project-id', { required: true })\n const endpoint = core.getInput('api-endpoint').replace(/\\/$/, '')\n const command = core.getInput('command', { required: true })\n const failOnQuota = core.getInput('fail-on-quota') !== 'false'\n\n switch (command) {\n case 'trigger-judge': {\n const res = await api(endpoint, apiKey, projectId, '/v1/admin/judge/run', {\n method: 'POST',\n body: JSON.stringify({ limit: 50, projectId }),\n })\n handleResult(res, failOnQuota)\n break\n }\n case 'dispatch-fix': {\n const reportId = core.getInput('report-id', { required: true })\n // Optional spec-traceability anchor (whitepaper §2.10). When provided\n // the worker skips the graph walk to recover the inventory Action and\n // includes its expected_outcome contract verbatim in the LLM prompt.\n const inventoryActionNodeId = core.getInput('inventory-action-node-id') || undefined\n const body: Record<string, unknown> = { reportId }\n if (inventoryActionNodeId) body.inventoryActionNodeId = inventoryActionNodeId\n const res = await api(endpoint, apiKey, projectId, '/v1/admin/fixes/dispatch', {\n method: 'POST',\n body: JSON.stringify(body),\n })\n handleResult(res, failOnQuota)\n break\n }\n case 'check-coverage': {\n const minCoverage = Number(core.getInput('min-coverage') || '0.8')\n const res = await api<{ total: number; classified: number }>(endpoint, apiKey, projectId, '/v1/admin/stats')\n if (!res.ok || !res.data) {\n core.setFailed(`stats query failed: ${res.error?.message ?? 'unknown'}`)\n return\n }\n const ratio = res.data.total === 0 ? 1 : res.data.classified / res.data.total\n core.setOutput('coverage', ratio.toFixed(3))\n core.setOutput('result', JSON.stringify(res.data))\n if (ratio < minCoverage) {\n core.setFailed(`classification coverage ${ratio.toFixed(3)} below threshold ${minCoverage}`)\n } else {\n core.info(`classification coverage ${ratio.toFixed(3)} >= ${minCoverage} ✓`)\n }\n break\n }\n case 'query': {\n const question = core.getInput('question', { required: true })\n const res = await api(endpoint, apiKey, projectId, '/v1/admin/query', {\n method: 'POST',\n body: JSON.stringify({ question }),\n })\n handleResult(res, failOnQuota)\n break\n }\n case 'discover-api': {\n // Mushi v2 Gate 3 helper — walk the customer repo for Next.js\n // route handlers + OpenAPI + (optionally) Supabase introspection\n // and POST the resulting `discovered_apis` to the inventory-gates\n // function. The next gates run consumes this blob to compute the\n // api_contract diff.\n const { discoverRoutes } = await import('./api-contract.js')\n const repoRoot = core.getInput('repo-root') || process.cwd()\n const openapiFile = core.getInput('openapi-file') || undefined\n const supabaseUrl = core.getInput('supabase-url') || undefined\n const supabaseAnonKey = core.getInput('supabase-anon-key') || undefined\n const routes = await discoverRoutes({\n repoRoot,\n openapiFile,\n supabaseUrl,\n supabaseAnonKey,\n })\n core.info(`Discovered ${routes.length} routes`)\n core.setOutput('result', JSON.stringify({ routes }))\n // Persist as a synthetic crawl summary so Gate 3 picks it up\n // without needing a real crawl run.\n const persist = await api(\n endpoint,\n apiKey,\n projectId,\n `/v1/admin/inventory/${projectId}/gates/run`,\n {\n method: 'POST',\n body: JSON.stringify({\n gates: ['api_contract'],\n findings: [],\n commit_sha: process.env.GITHUB_SHA,\n discovered_apis: routes,\n }),\n },\n )\n handleResult(persist, failOnQuota)\n break\n }\n case 'spec-drift': {\n // Mushi v2 Gate 6 — oasdiff spec drift detection.\n //\n // Downloads the oasdiff binary (Go static binary, cross-platform), runs\n // `oasdiff breaking <base> <head>` against two OpenAPI spec versions, and\n // POSTs the findings to the inventory-gates endpoint as a `spec_drift` gate run.\n //\n // Inputs:\n // base-spec — path or URL to the base OpenAPI spec (previous version).\n // head-spec — path or URL to the head OpenAPI spec (current PR version).\n // fail-on-breaking — whether breaking changes fail the build (default: true).\n const baseSpec = core.getInput('base-spec', { required: true })\n const headSpec = core.getInput('head-spec', { required: true })\n const failOnBreaking = core.getInput('fail-on-breaking') !== 'false'\n const commitSha = core.getInput('commit-sha') || process.env.GITHUB_SHA || undefined\n const prNumber = core.getInput('pr-number') ? Number(core.getInput('pr-number')) : undefined\n\n const { runSpecDrift } = await import('./spec-drift.js')\n const diffFindings = await runSpecDrift({ baseSpec, headSpec })\n\n core.info(`oasdiff found ${diffFindings.length} change(s)`)\n core.setOutput('findings', JSON.stringify(diffFindings))\n\n const breaking = diffFindings.filter((f) => f.severity === 'error')\n const warnings = diffFindings.filter((f) => f.severity === 'warn')\n\n // Post findings to the gates API.\n const gateBody = {\n gates: ['spec_drift'],\n spec_diff_findings: diffFindings,\n commit_sha: commitSha,\n pr_number: prNumber,\n }\n await api(\n endpoint,\n apiKey,\n projectId,\n `/v1/admin/inventory/${projectId}/gates/run`,\n { method: 'POST', body: JSON.stringify(gateBody) },\n )\n\n if (breaking.length > 0 && failOnBreaking) {\n core.setFailed(\n `Mushi Gate 6 (spec_drift): ${breaking.length} breaking change(s) detected. ` +\n `Review in the admin console → Inventory → Gates.`,\n )\n } else if (warnings.length > 0) {\n core.warning(`Mushi Gate 6 (spec_drift): ${warnings.length} potentially-breaking change(s).`)\n } else {\n core.info('Mushi Gate 6 (spec_drift): no breaking changes.')\n }\n break\n }\n case 'gates': {\n // Mushi v2: run all gates against the current commit and post a single\n // composite GitHub status.\n //\n // Gates 1 + 2 (lint) run inside this Action's checkout; Gates 3–8\n // are server-side and reachable via /v1/admin/inventory.\n // The Action then reads back the consolidated gate_runs and\n // sets a single pass/fail on the calling workflow.\n const commitSha = core.getInput('commit-sha') || process.env.GITHUB_SHA || ''\n const prNumber = core.getInput('pr-number') || ''\n const gatesArg = core.getInput('gates') || 'all'\n const gates =\n gatesArg === 'all'\n ? ['dead_handler', 'mock_leak', 'api_contract', 'crawl', 'status_claim', 'orphan_endpoint', 'unknown_call']\n : gatesArg.split(',').map((g) => g.trim()).filter(Boolean)\n\n const body = {\n commit_sha: commitSha || undefined,\n pr_number: prNumber ? Number(prNumber) : undefined,\n gates,\n }\n const res = await api<{\n runs: Array<{ gate: string; status: string; findings_count: number }>\n }>(\n endpoint,\n apiKey,\n projectId,\n `/v1/admin/inventory/${projectId}/gates/run`,\n { method: 'POST', body: JSON.stringify(body) },\n )\n core.setOutput('result', JSON.stringify(res))\n if (!res.ok) {\n if (res.error?.code === 'QUOTA_EXCEEDED' && !failOnQuota) {\n core.warning(`quota exceeded, skipping: ${res.error?.message}`)\n break\n }\n core.setFailed(`gates run failed: ${res.error?.code ?? 'unknown'} ${res.error?.message ?? ''}`)\n break\n }\n const runs = res.data?.runs ?? []\n const failed = runs.filter((r) => r.status === 'fail')\n const warned = runs.filter((r) => r.status === 'warn')\n const summary = runs\n .map((r) => `${gateGlyph(r.status)} ${r.gate} (${r.findings_count})`)\n .join(' · ')\n core.info(`Mushi gates: ${summary}`)\n if (failed.length > 0) {\n core.setFailed(\n `Mushi gate failures: ${failed.map((r) => r.gate).join(', ')}. ` +\n `View details on /inventory in the admin console.`,\n )\n } else if (warned.length > 0) {\n core.warning(`Mushi gate warnings: ${warned.map((r) => r.gate).join(', ')}.`)\n }\n break\n }\n case 'discovery-status': {\n // Mushi v2.1 — read out how much SDK passive-discovery data the\n // server has. Useful in CI to gate \"should we propose yet?\".\n const res = await api<{\n routes: unknown[]\n total_events: number\n ready_to_propose: boolean\n }>(endpoint, apiKey, projectId, `/v1/admin/inventory/${projectId}/discovery`)\n core.setOutput('result', JSON.stringify(res))\n if (!res.ok) {\n core.setFailed(`discovery-status failed: ${res.error?.code ?? 'unknown'}`)\n break\n }\n const ready = res.data?.ready_to_propose ?? false\n core.setOutput('ready_to_propose', String(ready))\n core.setOutput('total_events', String(res.data?.total_events ?? 0))\n core.setOutput('route_count', String((res.data?.routes ?? []).length))\n core.info(\n `Mushi discovery: ${res.data?.total_events ?? 0} events across ${(res.data?.routes ?? []).length} routes; ${ready ? 'ready to propose' : 'not yet ready'}.`,\n )\n break\n }\n case 'propose': {\n // Mushi v2.1 — kick off the LLM proposer. Synchronous: returns\n // the proposalId so a follow-up step can comment on the PR.\n const res = await api<{ proposalId: string; storyCount: number; pageCount: number }>(\n endpoint,\n apiKey,\n projectId,\n `/v1/admin/inventory/${projectId}/propose`,\n { method: 'POST', body: '{}' },\n )\n handleResult(res, failOnQuota)\n if (res.ok && res.data) {\n core.info(\n `Mushi proposed ${res.data.storyCount} stories / ${res.data.pageCount} pages — open /inventory ▸ Discovery to review.`,\n )\n core.setOutput('proposal_id', res.data.proposalId)\n }\n break\n }\n case 'auth-bootstrap': {\n // Mushi v2.1 — refresh the crawler cookie via the scripted-auth\n // runner. We don't run Playwright inside this Action's process\n // (browsers add ~600 MB to the image); instead we invoke the\n // published @mushi-mushi/inventory-auth-runner via `npx`. The\n // runner POSTs the cookie back to the settings endpoint we\n // expose; this Action just orchestrates.\n //\n // The bin name (`mushi-mushi-auth`) intentionally differs from\n // the unscoped package name (`inventory-auth-runner`), so we use\n // `-p <package> <bin>` instead of the bare `npx <package>` form\n // — the bare form would fail with `command not found` because\n // npx tries to invoke a bin that matches the unscoped name.\n const cmd = `npx --yes -p @mushi-mushi/inventory-auth-runner mushi-mushi-auth refresh`\n core.info(`mushi auth-bootstrap → ${cmd}`)\n const env = {\n ...process.env,\n MUSHI_API_KEY: apiKey,\n MUSHI_PROJECT: projectId,\n MUSHI_API_ENDPOINT: endpoint,\n }\n const { spawnSync } = await import('node:child_process')\n const res = spawnSync(cmd, { shell: true, env, stdio: 'inherit' })\n if ((res.status ?? 0) !== 0) {\n core.setFailed(`auth-bootstrap failed (exit ${res.status})`)\n } else {\n core.info('auth-bootstrap: cookie refreshed.')\n }\n break\n }\n default:\n core.setFailed(\n `unknown command: ${command}. Expected trigger-judge | dispatch-fix | check-coverage | query | gates | discover-api | discovery-status | propose | auth-bootstrap.`,\n )\n }\n}\n\nfunction gateGlyph(status: string): string {\n if (status === 'pass') return '✅'\n if (status === 'fail') return '❌'\n if (status === 'warn') return '⚠️'\n if (status === 'skipped') return '⏭️'\n return '⏺️'\n}\n\nfunction handleResult(res: ApiResp<unknown>, failOnQuota: boolean): void {\n core.setOutput('result', JSON.stringify(res))\n if (!res.ok) {\n if (res.error?.code === 'QUOTA_EXCEEDED' && !failOnQuota) {\n core.warning(`quota exceeded, skipping: ${res.error?.message}`)\n return\n }\n core.setFailed(`${res.error?.code ?? 'ERROR'}: ${res.error?.message ?? 'unknown'}`)\n return\n }\n core.info(`Mushi ok: ${JSON.stringify(res.data).slice(0, 500)}`)\n}\n\nmain().catch((err) => {\n core.setFailed((err as Error).message)\n})\n"],"mappings":";;;AACA,YAAY,UAAU;AAkBtB,eAAe,IAAO,UAAkB,QAAgB,WAAmB,MAAc,MAAyC;AAChI,QAAM,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,IAAI,IAAI;AAAA,IAC5C,GAAG;AAAA,IACH,SAAS;AAAA,MACP,gBAAgB;AAAA,MAChB,mBAAmB;AAAA,MACnB,mBAAmB;AAAA,MACnB,GAAI,MAAM,WAAW,CAAC;AAAA,IACxB;AAAA,EACF,CAAC;AACD,QAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,MAAI;AACJ,MAAI;AAAE,WAAO,KAAK,MAAM,IAAI;AAAA,EAAgB,QAAQ;AAAE,WAAO,EAAE,IAAI,OAAO,OAAO,EAAE,MAAM,QAAQ,IAAI,MAAM,IAAI,SAAS,KAAK,MAAM,GAAG,GAAG,EAAE,EAAE;AAAA,EAAE;AAC/I,SAAO;AACT;AAEA,eAAe,OAAsB;AACnC,QAAM,SAAc,cAAS,WAAW,EAAE,UAAU,KAAK,CAAC;AAC1D,QAAM,YAAiB,cAAS,cAAc,EAAE,UAAU,KAAK,CAAC;AACh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|
+
import { execFileSync } from "child_process";
|
|
3
|
+
import { existsSync, mkdirSync, chmodSync, writeFileSync } from "fs";
|
|
4
|
+
import { tmpdir, homedir } from "os";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import { createHash } from "crypto";
|
|
7
|
+
var OASDIFF_VERSION = process.env.OASDIFF_VERSION ?? "1.10.18";
|
|
8
|
+
var PLATFORM_MAP = {
|
|
9
|
+
"linux-x64": "linux-amd64",
|
|
10
|
+
"linux-arm64": "linux-arm64",
|
|
11
|
+
"darwin-x64": "darwin-amd64",
|
|
12
|
+
"darwin-arm64": "darwin-arm64",
|
|
13
|
+
"win32-x64": "windows-amd64"
|
|
14
|
+
};
|
|
15
|
+
function getOasdiffUrl() {
|
|
16
|
+
const platformKey = `${process.platform}-${process.arch}`;
|
|
17
|
+
const platform = PLATFORM_MAP[platformKey];
|
|
18
|
+
if (!platform) throw new Error(`Unsupported platform for oasdiff: ${platformKey}`);
|
|
19
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
20
|
+
return `https://github.com/Tufin/oasdiff/releases/download/v${OASDIFF_VERSION}/oasdiff_${OASDIFF_VERSION}_${platform}${ext}.tar.gz`;
|
|
21
|
+
}
|
|
22
|
+
async function downloadOasdiff() {
|
|
23
|
+
const cacheDir = join(homedir(), ".mushi", "tools");
|
|
24
|
+
mkdirSync(cacheDir, { recursive: true });
|
|
25
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
26
|
+
const binPath = join(cacheDir, `oasdiff-${OASDIFF_VERSION}${ext}`);
|
|
27
|
+
if (existsSync(binPath)) return binPath;
|
|
28
|
+
const url = getOasdiffUrl();
|
|
29
|
+
const res = await fetch(url);
|
|
30
|
+
if (!res.ok) throw new Error(`Failed to download oasdiff: HTTP ${res.status} from ${url}`);
|
|
31
|
+
const tgzPath = join(tmpdir(), `oasdiff-${createHash("md5").update(url).digest("hex")}.tar.gz`);
|
|
32
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
33
|
+
writeFileSync(tgzPath, buf);
|
|
34
|
+
const extractDir = join(tmpdir(), `oasdiff-extract-${Date.now()}`);
|
|
35
|
+
mkdirSync(extractDir, { recursive: true });
|
|
36
|
+
execFileSync("tar", ["-xzf", tgzPath, "-C", extractDir]);
|
|
37
|
+
const { readdirSync, copyFileSync } = await import("fs");
|
|
38
|
+
const files = readdirSync(extractDir);
|
|
39
|
+
const binName = process.platform === "win32" ? "oasdiff.exe" : "oasdiff";
|
|
40
|
+
const found = files.find((f) => f === binName || f.startsWith("oasdiff"));
|
|
41
|
+
if (!found) throw new Error(`oasdiff binary not found in archive. Files: ${files.join(", ")}`);
|
|
42
|
+
copyFileSync(join(extractDir, found), binPath);
|
|
43
|
+
if (process.platform !== "win32") chmodSync(binPath, 493);
|
|
44
|
+
return binPath;
|
|
45
|
+
}
|
|
46
|
+
async function runSpecDrift(opts) {
|
|
47
|
+
let binPath;
|
|
48
|
+
try {
|
|
49
|
+
binPath = await downloadOasdiff();
|
|
50
|
+
} catch (err) {
|
|
51
|
+
throw new Error(`oasdiff download failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
52
|
+
}
|
|
53
|
+
let output = "";
|
|
54
|
+
try {
|
|
55
|
+
output = execFileSync(binPath, ["breaking", opts.baseSpec, opts.headSpec, "--format", "json"], {
|
|
56
|
+
encoding: "utf-8",
|
|
57
|
+
timeout: 3e4
|
|
58
|
+
// oasdiff exits 1 when breaking changes are found — that's expected.
|
|
59
|
+
// We catch the error and still parse stdout.
|
|
60
|
+
});
|
|
61
|
+
} catch (err) {
|
|
62
|
+
const execErr = err;
|
|
63
|
+
output = execErr.stdout ?? "";
|
|
64
|
+
if (!output && execErr.status !== 1) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`oasdiff failed: ${execErr.stderr ?? String(err)}`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!output.trim()) return [];
|
|
71
|
+
let parsed;
|
|
72
|
+
try {
|
|
73
|
+
parsed = JSON.parse(output);
|
|
74
|
+
} catch {
|
|
75
|
+
return [{ severity: "warn", rule_id: "spec-drift-parse-error", message: output.slice(0, 500) }];
|
|
76
|
+
}
|
|
77
|
+
const items = Array.isArray(parsed) ? parsed : [];
|
|
78
|
+
return items.map((item) => {
|
|
79
|
+
const level = String(item.level ?? "error").toLowerCase();
|
|
80
|
+
const severity = level === "error" || level === "breaking" ? "error" : level === "warn" || level === "warning" ? "warn" : "info";
|
|
81
|
+
return {
|
|
82
|
+
severity,
|
|
83
|
+
rule_id: String(item.id ?? "spec-drift"),
|
|
84
|
+
message: String(item.text ?? item.message ?? JSON.stringify(item)),
|
|
85
|
+
path: item.path ? String(item.path) : void 0,
|
|
86
|
+
method: item.operation ? String(item.operation) : void 0
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
runSpecDrift
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=spec-drift-XRT7XUJU.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/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 } from 'node:fs'\nimport { tmpdir, 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 tgzPath = join(tmpdir(), `oasdiff-${createHash('md5').update(url).digest('hex')}.tar.gz`)\n const buf = Buffer.from(await res.arrayBuffer())\n writeFileSync(tgzPath, buf)\n\n // Extract the binary from the tarball using the system tar.\n const extractDir = join(tmpdir(), `oasdiff-extract-${Date.now()}`)\n mkdirSync(extractDir, { recursive: true })\n execFileSync('tar', ['-xzf', tgzPath, '-C', extractDir])\n\n // Find the binary inside the extracted dir.\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 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,qBAAqB;AAChE,SAAS,QAAQ,eAAe;AAChC,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAE3B,IAAM,kBAAkB,QAAQ,IAAI,mBAAmB;AAEvD,IAAM,eAAuC;AAAA,EAC3C,aAAa;AAAA,EACb,eAAe;AAAA,EACf,c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WACJ,UAAU,WAAW,UAAU,aAAa,UACxC,UAAU,UAAU,UAAU,YAAY,SAC1C;AACN,WAAO;AAAA,MACL;AAAA,MACA,SAAS,OAAO,KAAK,MAAM,YAAY;AAAA,MACvC,SAAS,OAAO,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.
|
|
3
|
+
"version": "0.5.0",
|
|
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",
|
|
@@ -42,13 +42,14 @@
|
|
|
42
42
|
"provenance": true
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@actions/core": "^1.11.
|
|
45
|
+
"@actions/core": "^1.11.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/node": "^22.
|
|
49
|
-
"eslint": "^10.
|
|
50
|
-
"tsup": "^8.5.
|
|
51
|
-
"typescript": "^6.0.
|
|
48
|
+
"@types/node": "^22.19.17",
|
|
49
|
+
"eslint": "^10.3.0",
|
|
50
|
+
"tsup": "^8.5.1",
|
|
51
|
+
"typescript": "^6.0.3",
|
|
52
|
+
"vitest": "^4.1.6",
|
|
52
53
|
"@mushi-mushi/eslint-config": "0.0.0",
|
|
53
54
|
"@mushi-mushi/tsconfig": "0.0.0"
|
|
54
55
|
},
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
"scripts": {
|
|
60
61
|
"build": "tsup",
|
|
61
62
|
"lint": "eslint src/",
|
|
62
|
-
"typecheck": "tsc --noEmit"
|
|
63
|
+
"typecheck": "tsc --noEmit",
|
|
64
|
+
"test": "vitest run"
|
|
63
65
|
}
|
|
64
66
|
}
|