const rules = [ { root: "packages/agent-core/src", forbidden: [ "hono", "vanjs-core", "openai", "bun:", "node:fs", "@great-agent/", ], }, { root: "apps/web/src", forbidden: [ "@great-agent/agent-core", "@great-agent/local-data", "@great-agent/local-files", "@great-agent/model-deepseek", ], }, ]; const violations: string[] = []; for (const rule of rules) { const glob = new Bun.Glob("**/*.ts"); for await (const relative of glob.scan({ cwd: rule.root, onlyFiles: true })) { if (relative.endsWith(".test.ts")) continue; const path = `${rule.root}/${relative}`; const source = await Bun.file(path).text(); for (const forbidden of rule.forbidden) { if ( source.includes(`from "${forbidden}`) || source.includes(`import("${forbidden}`) ) { violations.push(`${path}: 禁止依赖 ${forbidden}`); } } } } if (violations.length > 0) { console.error(violations.join("\n")); process.exit(1); } console.log("架构依赖检查通过。"); export {};