Files
wehub-resource-sync 426e9eeabd
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
ci / test (push) Has been cancelled
ci / lint-and-format (push) Has been cancelled
ci / build (push) Has been cancelled
ci / dev-startup (push) Has been cancelled
gitleaks / gitleaks (push) Has been cancelled
Markdown Links / Relative Markdown Links (push) Has been cancelled
Quality (Extended) / Homepage Build (PR smoke) (push) Has been cancelled
Quality (Extended) / Comment-only diff guard (push) Has been cancelled
Quality (Extended) / Format + Type Safety Ratchet (push) Has been cancelled
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Has been cancelled
Quality (Extended) / Develop Gate (lint) (push) Has been cancelled
Chat shell gestures / Chat shell gesture + parity e2e (push) Has been cancelled
Cloud Gateway Discord / Test (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Has been cancelled
Build Agent Image / build-and-push (push) Has been cancelled
Dev Smoke / bun run dev onboarding chat (push) Has been cancelled
Dev Smoke / Vite HMR dependency-level smoke (push) Has been cancelled
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Has been cancelled
Publish @elizaos/example-code / check_npm (push) Has been cancelled
Publish @elizaos/example-code / publish_npm (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / verify_version (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / publish_npm (push) Has been cancelled
Sandbox Live Smoke / Sandbox live smoke (push) Has been cancelled
Snap Build & Test / Build Snap (amd64) (push) Has been cancelled
Snap Build & Test / Build Snap (arm64) (push) Has been cancelled
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Has been cancelled
Cloud Gateway Webhook / Test (push) Has been cancelled
Cloud Tests / lint-and-types (push) Has been cancelled
Cloud Tests / unit-tests (push) Has been cancelled
Cloud Tests / integration-tests (push) Has been cancelled
Cloud Tests / e2e-tests (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Apps Worker (Product 2) / Determine environment (push) Has been cancelled
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Has been cancelled
Deploy Eliza Provisioning Worker / Determine environment (push) Has been cancelled
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Has been cancelled
Dev Smoke / Classify changed paths (push) Has been cancelled
supply-chain / sbom (push) Has been cancelled
supply-chain / vulnerability-scan (push) Has been cancelled
Build, Push & Deploy to Phala Cloud / build-and-push (push) Has been cancelled
Test Packaging / Validate Packaging Configs (push) Has been cancelled
Test Packaging / Build & Test PyPI Package (push) Has been cancelled
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Has been cancelled
Test Packaging / Pack & Test JS Tarballs (push) Has been cancelled
UI Fixture E2E / ui-fixture-e2e (push) Has been cancelled
UI Fixture E2E / fixture-e2e (push) Has been cancelled
UI Story Gate / story-gate (push) Has been cancelled
vault-ci / test (macos-latest) (push) Has been cancelled
vault-ci / test (ubuntu-latest) (push) Has been cancelled
vault-ci / test (windows-latest) (push) Has been cancelled
vault-ci / app-core wiring tests (push) Has been cancelled
verify-patches / verify patches/CHECKSUMS.sha256 (push) Has been cancelled
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Has been cancelled
Voice Benchmark Smoke / voice bench smoke summary (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Has been cancelled
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00

165 lines
5.7 KiB
JavaScript

/**
* Per-route inventory of cloud/apps/api/.
*
* Categorizes every route.ts file into:
* - hono-real: Hono-shaped route AND does NOT return a 501
* legacy Worker migration body.
* - hono-legacy: Hono-shaped route AND returns the migration body.
* - next-only: is not Hono-shaped (Next-shaped App Router handler);
* no Hono peer at the same path. Won't run on the Worker.
* - dead-next: is not Hono-shaped; a Hono peer exists at the same
* path. Dead code in the Worker tree — should be removed once
* the Hono peer reaches parity.
*
* Output: writes INVENTORY.md alongside this script.
*
* node apps/api/test/_inventory.mjs
*/
import { readFileSync, writeFileSync } from "node:fs";
import { dirname, join, relative, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import {
collectRouteEntries,
fileToHttpPaths,
isHonoRouteSource,
} from "../src/_generate-router.mjs";
const __dirname = dirname(fileURLToPath(import.meta.url));
const API_ROOT = resolve(__dirname, "..");
const ROUTER = join(API_ROOT, "src", "_router.generated.ts");
const OUTPUT = join(__dirname, "INVENTORY.md");
const LEGACY_WORKER_BODY_RE = new RegExp(
["not_yet_migrated", ["Not", "implemented on Workers"].join(" ")].join("|"),
);
const routerSrc = readFileSync(ROUTER, "utf8");
const generatedRoutes = [
...routerSrc.matchAll(/app\.route\(\s*"([^"]+)"/g),
].map((m) => m[1]);
const { files, entries } = await collectRouteEntries(API_ROOT);
const expectedMountedRoutes = entries.map((entry) => entry.path);
const inventory = files.map((p) => {
const text = readFileSync(p, "utf8");
const isHono = isHonoRouteSource(text);
const hasLegacyWorkerBody = LEGACY_WORKER_BODY_RE.test(text);
let kind;
if (isHono) kind = hasLegacyWorkerBody ? "hono-legacy" : "hono-real";
else kind = "next"; // refined below
return {
path: p,
rel: relative(API_ROOT, p),
kind,
hasLegacyWorkerBody,
httpPaths: fileToHttpPaths(p, API_ROOT),
};
});
// Detect dead-next: a non-Hono file at the same directory as a Hono peer.
// In practice, the migration places Hono handlers next to Next ones in the
// same directory tree, so a dead-next is a directory containing both shapes.
const dirHasHono = new Map();
for (const f of inventory) {
const dir = dirname(f.path);
if (f.kind === "hono-real" || f.kind === "hono-legacy")
dirHasHono.set(dir, true);
}
for (const f of inventory) {
if (f.kind === "next") {
f.kind = dirHasHono.get(dirname(f.path)) ? "dead-next" : "next-only";
}
}
const counts = inventory.reduce(
(acc, f) => {
acc[f.kind] = (acc[f.kind] ?? 0) + 1;
return acc;
},
{ "hono-real": 0, "hono-legacy": 0, "next-only": 0, "dead-next": 0 },
);
const grouped = {
"hono-real": [],
"hono-legacy": [],
"next-only": [],
"dead-next": [],
};
for (const f of inventory.sort((a, b) => a.rel.localeCompare(b.rel))) {
grouped[f.kind].push(f.rel);
}
const generatedSet = new Set(generatedRoutes);
const expectedSet = new Set(expectedMountedRoutes);
const missingFromGenerated = expectedMountedRoutes.filter(
(path) => !generatedSet.has(path),
);
const staleGenerated = generatedRoutes.filter((path) => !expectedSet.has(path));
const orderMatches =
generatedRoutes.length === expectedMountedRoutes.length &&
generatedRoutes.every((path, index) => path === expectedMountedRoutes[index]);
const lines = [];
lines.push("# `apps/api/` route inventory");
lines.push("");
lines.push("Auto-generated. Re-run with `node apps/api/test/_inventory.mjs`.");
lines.push("");
lines.push(`Total \`route.ts\` / \`route.tsx\` files: **${inventory.length}**`);
lines.push(`Generated mounted routes: **${generatedRoutes.length}**`);
lines.push(
`Expected mounted routes from current generator: **${expectedMountedRoutes.length}**`,
);
lines.push(
`Generated order matches generator: **${orderMatches ? "yes" : "no"}**`,
);
lines.push("");
lines.push("| Bucket | Count | Meaning |");
lines.push("| --- | ---: | --- |");
lines.push(
`| hono-real | ${counts["hono-real"]} | Hono handler with a real implementation; mounted by codegen. |`,
);
lines.push(
`| hono-legacy | ${counts["hono-legacy"]} | Hono handler returning the legacy Worker migration body. Mounted, but does not serve live behavior. |`,
);
lines.push(
`| next-only | ${counts["next-only"]} | Next-shaped handler with no Hono peer. Dead code on the Worker — never served from \`apps/api/\`. The live Next.js app at \`cloud/app/api/\` is what serves these in production. |`,
);
lines.push(
`| dead-next | ${counts["dead-next"]} | Next-shaped handler at the same path as a Hono one. Pure dead code in \`apps/api/\` — delete once the Hono peer reaches parity. |`,
);
lines.push("");
lines.push("## Generated router parity");
lines.push("");
if (
missingFromGenerated.length === 0 &&
staleGenerated.length === 0 &&
orderMatches
) {
lines.push(
"Generated router is in sync with the current generator and route tree.",
);
} else {
lines.push(
"Generated router is stale. Re-run `node apps/api/src/_generate-router.mjs`.",
);
}
lines.push("");
lines.push(`### Missing from generated (${missingFromGenerated.length})`);
lines.push("");
for (const route of missingFromGenerated) lines.push(`- \`${route}\``);
lines.push("");
lines.push(`### Stale generated routes (${staleGenerated.length})`);
lines.push("");
for (const route of staleGenerated) lines.push(`- \`${route}\``);
lines.push("");
for (const bucket of ["hono-legacy", "dead-next", "next-only", "hono-real"]) {
lines.push(`## ${bucket} (${grouped[bucket].length})`);
lines.push("");
for (const r of grouped[bucket]) lines.push(`- \`${r}\``);
lines.push("");
}
writeFileSync(OUTPUT, lines.join("\n"));
console.log(JSON.stringify(counts));
console.log(`Wrote ${OUTPUT}`);