{"_id":"@caoguo/maplibre-ai","_rev":"5-de12db29e95b8ac0440d1b0478eea1cd","name":"@caoguo/maplibre-ai","dist-tags":{"latest":"0.0.6"},"versions":{"0.0.1":{"name":"@caoguo/maplibre-ai","version":"0.0.1","_id":"@caoguo/maplibre-ai@0.0.1","maintainers":[{"name":"uutan","email":"uutan@qq.com"}],"dist":{"shasum":"5ff8577d4165fd4530770d6c90915badfbcbc38b","tarball":"https://registry.npmjs.org/@caoguo/maplibre-ai/-/maplibre-ai-0.0.1.tgz","fileCount":23,"integrity":"sha512-X3VpqE1wTVuDlhc3XVCoGBQ8DgxiSqOu177CSQ8klj+CKoru3BEzMZl0X+Dwkvfj5Z6sP6kFmRw7jIu2DZWdaA==","signatures":[{"sig":"MEUCIExjY4VBSwQpZUBRkuV7yt59Eo5RtKR3pIXdKYc8W75qAiEAxuEj6+jIafOTAy10pVxH0UTLa1EHUCtdSNjC+7LWg1E=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":113650},"main":"./dist/index.cjs","type":"module","_from":"file:caoguo-maplibre-ai-0.0.1.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./debug":{"types":"./dist/debug/index.d.ts","import":"./dist/debug/index.js","require":"./dist/debug/index.cjs"},"./stylegen":{"types":"./dist/stylegen/index.d.ts","import":"./dist/stylegen/index.js","require":"./dist/stylegen/index.cjs"}},"scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest"},"_npmUser":{"name":"uutan","email":"uutan@qq.com"},"_resolved":"/private/var/folders/br/f3pl5_3d7m5b9qz4ym4d_plw0000gn/T/7509d2397115e990ddebaafb0ca277cc/caoguo-maplibre-ai-0.0.1.tgz","_integrity":"sha512-X3VpqE1wTVuDlhc3XVCoGBQ8DgxiSqOu177CSQ8klj+CKoru3BEzMZl0X+Dwkvfj5Z6sP6kFmRw7jIu2DZWdaA==","_npmVersion":"10.9.7","description":"草果地图 AI 工具链 - AI Debug 诊断 + 样式生成器 v2","directories":{},"_nodeVersion":"22.22.2","dependencies":{"@caoguo/theme":"0.0.1"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","jsdom":"^25.0.1","vitest":"^2.1.8","typescript":"^5.6.3"},"_npmOperationalInternal":{"tmp":"tmp/maplibre-ai_0.0.1_1787276573406_0.3566482353260263","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@caoguo/maplibre-ai","version":"0.0.2","keywords":["maplibre","caoguo","gis","ai","performance-profiler","tile-monitor","memory-leak","style-generator","palette-extraction","industry-template"],"author":{"name":"caoguo","email":"caoguo@hb.cn"},"license":"Apache-2.0","_id":"@caoguo/maplibre-ai@0.0.2","maintainers":[{"name":"uutan","email":"uutan@qq.com"}],"homepage":"https://github.com/caoguo/map/blob/main/packages/ai/README.md","bugs":{"url":"https://github.com/caoguo/map/issues"},"dist":{"shasum":"9fe8603d8e46cd892413d983efdb79bc3ca9c97b","tarball":"https://registry.npmjs.org/@caoguo/maplibre-ai/-/maplibre-ai-0.0.2.tgz","fileCount":24,"integrity":"sha512-q8BjOdxG73qDRiY1eXilFtfhgItC9lXP5oqjAosbJ8QNqJ3xttXo2oKM2whbxCfHAoAHCokDzHjeNqq8dQXjmw==","signatures":[{"sig":"MEQCIGGcKDpMiyDyNL91WHiub225MhhQ5+VdTlP0wFiu2MNeAiBsJWS24W7DSVpLB1ROXsw9V0i9Qc9TVWu0kiFaWrfU8A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":116666},"main":"./dist/index.cjs","type":"module","_from":"file:caoguo-maplibre-ai-0.0.2.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./debug":{"types":"./dist/debug/index.d.ts","import":"./dist/debug/index.js","require":"./dist/debug/index.cjs"},"./stylegen":{"types":"./dist/stylegen/index.d.ts","import":"./dist/stylegen/index.js","require":"./dist/stylegen/index.cjs"}},"scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest"},"_npmUser":{"name":"uutan","email":"uutan@qq.com"},"_resolved":"/private/var/folders/br/f3pl5_3d7m5b9qz4ym4d_plw0000gn/T/c1e471753fd94925530b763804a0bd7f/caoguo-maplibre-ai-0.0.2.tgz","_integrity":"sha512-q8BjOdxG73qDRiY1eXilFtfhgItC9lXP5oqjAosbJ8QNqJ3xttXo2oKM2whbxCfHAoAHCokDzHjeNqq8dQXjmw==","repository":{"url":"git+https://github.com/caoguo/map.git","type":"git","directory":"packages/ai"},"_npmVersion":"10.9.7","description":"草果地图 AI 工具链 - 性能诊断 / 样式生成器 v2","directories":{},"_nodeVersion":"22.22.2","dependencies":{"@caoguo/theme":"0.0.2"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","jsdom":"^25.0.1","vitest":"^2.1.8","typescript":"^5.6.3"},"_npmOperationalInternal":{"tmp":"tmp/maplibre-ai_0.0.2_1787276978866_0.4996689711449005","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@caoguo/maplibre-ai","version":"0.0.4","keywords":["maplibre","caoguo","gis","ai","copilot","code-generation","geoai","geocoding","address-parsing","crs-conversion","nlpg","natural-language","postgis","sql-generator","sql-validator","performance-profiler","tile-monitor","memory-leak","style-generator","palette-extraction","industry-template","china"],"author":{"name":"caoguo","email":"caoguo@hb.cn"},"license":"Apache-2.0","_id":"@caoguo/maplibre-ai@0.0.4","maintainers":[{"name":"uutan","email":"uutan@qq.com"}],"homepage":"https://github.com/caoguo/map/blob/main/packages/ai/README.md","bugs":{"url":"https://github.com/caoguo/map/issues"},"dist":{"shasum":"376f986346018ae6685adbe7e984a7887edc5ece","tarball":"https://registry.npmjs.org/@caoguo/maplibre-ai/-/maplibre-ai-0.0.4.tgz","fileCount":56,"integrity":"sha512-xc7MLTXUsg6q07thCZLbGxDdEsT327v9usvecaNC950OpoM16c1J0rBDm8rvxKrKGCqu6mWHFapMH+Hff4Lo3g==","signatures":[{"sig":"MEUCIG/VTSV947uFYI5X7GMvjbQUc3pftlX8ODaugAjvcoXZAiEAxQ4G2nZ4URsia00QHlVawxfe2zTwaH9kZBzco0JZuWM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":626758},"main":"./dist/index.cjs","type":"module","_from":"file:caoguo-maplibre-ai-0.0.4.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./llm":{"types":"./dist/llm/index.d.ts","import":"./dist/llm/index.js","require":"./dist/llm/index.cjs"},"./nlpg":{"types":"./dist/nlpg/index.d.ts","import":"./dist/nlpg/index.js","require":"./dist/nlpg/index.cjs"},"./debug":{"types":"./dist/debug/index.d.ts","import":"./dist/debug/index.js","require":"./dist/debug/index.cjs"},"./geoai":{"types":"./dist/geoai/index.d.ts","import":"./dist/geoai/index.js","require":"./dist/geoai/index.cjs"},"./copilot":{"types":"./dist/copilot/index.d.ts","import":"./dist/copilot/index.js","require":"./dist/copilot/index.cjs"},"./stylegen":{"types":"./dist/stylegen/index.d.ts","import":"./dist/stylegen/index.js","require":"./dist/stylegen/index.cjs"}},"scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest"},"_npmUser":{"name":"uutan","email":"uutan@qq.com"},"_resolved":"/private/var/folders/br/f3pl5_3d7m5b9qz4ym4d_plw0000gn/T/bf0d4f36cd7bbbed36d298f601f41b3c/caoguo-maplibre-ai-0.0.4.tgz","_integrity":"sha512-xc7MLTXUsg6q07thCZLbGxDdEsT327v9usvecaNC950OpoM16c1J0rBDm8rvxKrKGCqu6mWHFapMH+Hff4Lo3g==","repository":{"url":"git+https://github.com/caoguo/map.git","type":"git","directory":"packages/ai"},"_npmVersion":"10.9.7","description":"草果地图 AI 工具链 - MapCopilot 代码生成 / GeoAI 数据入图 / NLPG 自然语言查询 / DeepSeek LLM 接入 / 性能诊断 / 样式生成器 v2","directories":{},"_nodeVersion":"22.22.2","dependencies":{"@caoguo/theme":"0.0.4"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","jsdom":"^25.0.1","vitest":"^2.1.8","typescript":"^5.6.3"},"_npmOperationalInternal":{"tmp":"tmp/maplibre-ai_0.0.4_1787367049847_0.1401277427898706","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@caoguo/maplibre-ai","version":"0.0.5","keywords":["maplibre","caoguo","gis","ai","copilot","code-generation","geoai","geocoding","address-parsing","crs-conversion","nlpg","natural-language","postgis","sql-generator","sql-validator","performance-profiler","tile-monitor","memory-leak","style-generator","palette-extraction","industry-template","china"],"author":{"name":"caoguo","email":"caoguo@hb.cn"},"license":"Apache-2.0","_id":"@caoguo/maplibre-ai@0.0.5","maintainers":[{"name":"uutan","email":"uutan@qq.com"}],"homepage":"https://github.com/caoguo-map/maplibre-ai/blob/main/packages/ai/README.md","bugs":{"url":"https://github.com/caoguo-map/maplibre-ai/issues"},"dist":{"shasum":"2f5ed2e9310cb2653950d84f7fc1517e19971fc9","tarball":"https://registry.npmjs.org/@caoguo/maplibre-ai/-/maplibre-ai-0.0.5.tgz","fileCount":58,"integrity":"sha512-aCNEUslKPxpemcJWj6mg4m3oGQoWhm1XrLiihBaSHCC80dkabjer0iAySLLLSvnmU9skgsgPz8tfZL6yGMLz0A==","signatures":[{"sig":"MEYCIQDqlK6g3tX9647SGH759kOQ0CVCg3IDX7koxqU4DvYUmwIhALEDRchED+aROAKNVvE9bzGfJ+HFd9Qu34jbICCj60Tz","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":684965},"main":"./dist/index.cjs","type":"module","_from":"file:caoguo-maplibre-ai-0.0.5.tgz","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./llm":{"types":"./dist/llm/index.d.ts","import":"./dist/llm/index.js","require":"./dist/llm/index.cjs"},"./nlpg":{"types":"./dist/nlpg/index.d.ts","import":"./dist/nlpg/index.js","require":"./dist/nlpg/index.cjs"},"./debug":{"types":"./dist/debug/index.d.ts","import":"./dist/debug/index.js","require":"./dist/debug/index.cjs"},"./geoai":{"types":"./dist/geoai/index.d.ts","import":"./dist/geoai/index.js","require":"./dist/geoai/index.cjs"},"./copilot":{"types":"./dist/copilot/index.d.ts","import":"./dist/copilot/index.js","require":"./dist/copilot/index.cjs"},"./stylegen":{"types":"./dist/stylegen/index.d.ts","import":"./dist/stylegen/index.js","require":"./dist/stylegen/index.cjs"}},"scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest"},"_npmUser":{"name":"uutan","email":"uutan@qq.com"},"_resolved":"/private/var/folders/br/f3pl5_3d7m5b9qz4ym4d_plw0000gn/T/1902761c1e191589b1d2036697b95b0f/caoguo-maplibre-ai-0.0.5.tgz","_integrity":"sha512-aCNEUslKPxpemcJWj6mg4m3oGQoWhm1XrLiihBaSHCC80dkabjer0iAySLLLSvnmU9skgsgPz8tfZL6yGMLz0A==","repository":{"url":"git+https://github.com/caoguo-map/maplibre-ai.git","type":"git","directory":"packages/ai"},"_npmVersion":"10.9.7","description":"草果地图 AI 工具链 - MapCopilot 代码生成 / GeoAI 数据入图 / NLPG 自然语言查询 / DeepSeek LLM 接入 / 性能诊断 / 样式生成器 v2","directories":{},"_nodeVersion":"22.22.2","dependencies":{"@caoguo/theme":"0.0.11"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.5","jsdom":"^25.0.1","vitest":"^2.1.8","typescript":"^5.6.3"},"_npmOperationalInternal":{"tmp":"tmp/maplibre-ai_0.0.5_1787382612792_0.3159969951510253","host":"s3://npm-registry-packages-npm-production"}},"0.0.6":{"name":"@caoguo/maplibre-ai","version":"0.0.6","description":"草果地图 AI 工具链 - MapCopilot 代码生成 / GeoAI 数据入图 / NLPG 自然语言查询 / DeepSeek LLM 接入 / 性能诊断 / 样式生成器 v2","license":"Apache-2.0","author":{"name":"caoguo","email":"caoguo@hb.cn"},"homepage":"https://github.com/caoguo-map/maplibre-ai/blob/main/packages/ai/README.md","repository":{"type":"git","url":"git+https://github.com/caoguo-map/maplibre-ai.git","directory":"packages/ai"},"bugs":{"url":"https://github.com/caoguo-map/maplibre-ai/issues"},"keywords":["maplibre","caoguo","gis","ai","copilot","code-generation","geoai","geocoding","address-parsing","crs-conversion","nlpg","natural-language","postgis","sql-generator","sql-validator","performance-profiler","tile-monitor","memory-leak","style-generator","palette-extraction","industry-template","china"],"type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./debug":{"types":"./dist/debug/index.d.ts","import":"./dist/debug/index.js","require":"./dist/debug/index.cjs"},"./stylegen":{"types":"./dist/stylegen/index.d.ts","import":"./dist/stylegen/index.js","require":"./dist/stylegen/index.cjs"},"./copilot":{"types":"./dist/copilot/index.d.ts","import":"./dist/copilot/index.js","require":"./dist/copilot/index.cjs"},"./geoai":{"types":"./dist/geoai/index.d.ts","import":"./dist/geoai/index.js","require":"./dist/geoai/index.cjs"},"./nlpg":{"types":"./dist/nlpg/index.d.ts","import":"./dist/nlpg/index.js","require":"./dist/nlpg/index.cjs"},"./llm":{"types":"./dist/llm/index.d.ts","import":"./dist/llm/index.js","require":"./dist/llm/index.cjs"}},"scripts":{"build":"tsup","test":"vitest run","test:watch":"vitest"},"dependencies":{"@caoguo/theme":"workspace:*"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"devDependencies":{"jsdom":"^25.0.1","tsup":"^8.3.5","typescript":"^5.6.3","vitest":"^2.1.8"},"_id":"@caoguo/maplibre-ai@0.0.6","gitHead":"5ca608c96eafe866fc7390b4a66e72ed78211b34","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-eWXvrLM1QhH4Z8E5QD7Y+/kfL/yR50ggVtQeyhFSnCqQX3B/epLdhmHp5SrZKD2aLDwydebvHvFq57WB5nBrFg==","shasum":"c632d625042d4df3aba7d15a24c1ddcb20c43992","tarball":"https://registry.npmjs.org/@caoguo/maplibre-ai/-/maplibre-ai-0.0.6.tgz","fileCount":58,"unpackedSize":705032,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFcppYTyB4WKsgwgKz8x8AbU1uYHPxrjIK7pH5lRLTWmAiEAq6DNMikONS71jCX1SE/32XQP0GhASCv0Q6TRoLxXPjs="}]},"_npmUser":{"name":"uutan","email":"uutan@qq.com"},"directories":{},"maintainers":[{"name":"uutan","email":"uutan@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/maplibre-ai_0.0.6_1787389214421_0.30076215811562457"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-21T01:42:53.230Z","modified":"2026-08-22T09:00:14.772Z","0.0.1":"2026-08-21T01:42:53.537Z","0.0.2":"2026-08-21T01:49:39.042Z","0.0.4":"2026-08-22T02:50:49.993Z","0.0.5":"2026-08-22T07:10:12.939Z","0.0.6":"2026-08-22T09:00:14.574Z"},"bugs":{"url":"https://github.com/caoguo-map/maplibre-ai/issues"},"author":{"name":"caoguo","email":"caoguo@hb.cn"},"license":"Apache-2.0","homepage":"https://github.com/caoguo-map/maplibre-ai/blob/main/packages/ai/README.md","keywords":["maplibre","caoguo","gis","ai","copilot","code-generation","geoai","geocoding","address-parsing","crs-conversion","nlpg","natural-language","postgis","sql-generator","sql-validator","performance-profiler","tile-monitor","memory-leak","style-generator","palette-extraction","industry-template","china"],"repository":{"type":"git","url":"git+https://github.com/caoguo-map/maplibre-ai.git","directory":"packages/ai"},"description":"草果地图 AI 工具链 - MapCopilot 代码生成 / GeoAI 数据入图 / NLPG 自然语言查询 / DeepSeek LLM 接入 / 性能诊断 / 样式生成器 v2","maintainers":[{"name":"uutan","email":"uutan@qq.com"}],"readme":"# @caoguo/maplibre-ai\n\n> 草果地图 AI 工具链 — MapCopilot 代码生成 / GeoAI 数据入图 / NLPG 自然语言查询 / DeepSeek LLM 接入 / 性能诊断 / 样式生成器 v2\n\n[![npm version](https://img.shields.io/npm/v/@caoguo/maplibre-ai.svg)](https://www.npmjs.com/package/@caoguo/maplibre-ai)\n[![license](https://img.shields.io/npm/l/@caoguo/maplibre-ai.svg)](LICENSE)\n\n## 安装\n\n```bash\nnpm install @caoguo/maplibre-ai\n```\n\n## 功能模块\n\n| 模块 | 子路径 | 说明 |\n|------|--------|------|\n| DeepSeek | `@caoguo/maplibre-ai/llm` | DeepSeek 大模型客户端（OpenAI 兼容 / 流式 / 重试 / 降级） |\n| MapCopilot | `@caoguo/maplibre-ai/copilot` | 自然语言 → 地图代码生成（规则引擎 + LLM 增强） |\n| GeoAI | `@caoguo/maplibre-ai/geoai` | 数据入图管线（表头识别 / 中文地址解析 / 坐标系纠偏 / 批量编码） |\n| NLPG | `@caoguo/maplibre-ai/nlpg` | 自然语言 → PostGIS SQL + 安全校验层（规则引擎 + LLM） |\n| AI Debug | `@caoguo/maplibre-ai/debug` | 诊断工具（性能 Profiler / 瓦片监控 / 内存泄漏 / 优化建议） |\n| 样式生成 | `@caoguo/maplibre-ai/stylegen` | 样式生成器 v2（色板提取 / 行业模板 / 品牌定制 / 运营商主题 / 昼夜切换） |\n\n## 快速开始\n\n### 接入 DeepSeek 大模型\n\n```ts\nimport { DeepSeekClient } from '@caoguo/maplibre-ai/llm';\n\n// 浏览器环境传入你的 DeepSeek API Key（生产环境建议经服务端代理，勿在前端暴露密钥）\nconst client = new DeepSeekClient({\n  apiKey: process.env.DEEPSEEK_API_KEY!,\n  model: 'deepseek-chat',          // 或 'deepseek-reasoner'（深度推理）\n  temperature: 0.3,\n});\n\n// 普通对话\nconst r = await client.chat([{ role: 'user', content: '武汉有多少个区？' }]);\nconsole.log(r.content);\n\n// JSON 输出（用于结构化提取）\nconst j = await client.chatJson<{ answer: string }>([\n  { role: 'user', content: '返回 JSON' },\n]);\n\n// 流式输出\nawait client.chat([{ role: 'user', content: '写一首诗' }], {\n  onChunk: (delta) => process.stdout.write(delta),\n});\n```\n\n### MapCopilot（LLM 优先 + 规则引擎降级）\n\n```ts\nimport { DeepSeekClient } from '@caoguo/maplibre-ai/llm';\nimport { LlmMapCopilot } from '@caoguo/maplibre-ai/copilot';\n\nconst copilot = new LlmMapCopilot({ client: new DeepSeekClient({ apiKey: '...' }) });\nconst r = await copilot.generate('创建一个武汉地图，暗色主题，缩放 12');\nconsole.log(r.code); // LLM 生成；若 LLM 失败自动降级规则引擎\n```\n\n### NLPG（LLM 生成 SQL + 安全校验兜底）\n\n```ts\nimport { LlmNlpg } from '@caoguo/maplibre-ai/nlpg';\n\nconst nlpg = new LlmNlpg({ client: new DeepSeekClient({ apiKey: '...' }) });\nconst r = await nlpg.query('查出使用超过 20 年的铸铁燃气管');\nconsole.log(r.query.sql); // 生成的 SQL（必经安全校验层）\nconsole.log(r.valid);      // 危险 SQL 会被拒绝并降级规则引擎\n```\n\n### GeoAI（数据自动入图）\n\n```ts\nimport { importToGeoJSON } from '@caoguo/maplibre-ai/geoai';\n\nconst headers = ['名称', '地址', '类型'];\nconst rows = [\n  ['网点A', '武汉光谷', '商业'],\n  ['网点B', '武汉江汉区', '政务'],\n];\nconst result = importToGeoJSON(headers, rows);\nconsole.log(result.stats.successRate); // 编码成功率\n// result.features 为 GeoJSON FeatureCollection\n```\n\n### NLPG（自然语言查询）\n\n```ts\nimport { nlpgQuery } from '@caoguo/maplibre-ai/nlpg';\n\nconst r = nlpgQuery('查出使用超过 20 年的铸铁燃气管');\nconsole.log(r.query.sql);    // SELECT * FROM pipelines WHERE ...\nconsole.log(r.valid);        // 是否通过安全校验（白名单表/危险操作拦截）\n```\n\n### 性能诊断\n\n```ts\nimport { diagnose } from '@caoguo/maplibre-ai/debug';\n\nconst report = diagnose({\n  perf: { fps: 24, drawCalls: 120, activeLayers: 60 },\n  tiles: { requested: 300, cached: 150, totalLoadMs: 1200 },\n});\nconsole.log(report.suggestions); // 命中的优化建议\n```\n\n### 样式生成器 v2\n\n```ts\nimport { generateBrandStyle, generateIndustryStyle } from '@caoguo/maplibre-ai/stylegen';\n\nconst brand = generateBrandStyle({ brandColor: '#4a9eff', mode: 'dark' });\nconst industry = generateIndustryStyle('pipeline', 'dark'); // 六张网行业模板\n```\n\n## 设计原则\n\n1. **AI 增强，非 AI 替代**：工具加速开发流程，不替代工程师判断。\n2. **双模式架构**：规则引擎（离线、可控、可解释）+ LLM 增强（DeepSeek，复杂自由意图）。LLM 优先，失败自动降级规则引擎。\n3. **安全第一**：NLPG 生成的 SQL 无论来自规则引擎还是 LLM，都必须通过安全校验层（白名单表 / 危险操作拦截 / 注入检测）方可执行。\n4. **密钥安全**：`DeepSeekClient` 仅接收 API Key，不内置任何密钥。生产环境请在服务端代理调用，避免前端暴露密钥。\n\n## 浏览器 / 环境要求\n\n- 现代浏览器（Chrome 90+）\n- Node.js 18+（`DeepSeekClient` 依赖原生 `fetch`/`ReadableStream`，或注入自定义 `fetchImpl`）\n- 所有模块在 Node.js 可测（已含 89 个 vitest 用例，LLM 相关测试使用 mock fetch，不产生真实 API 调用）\n\n## 许可\n\nApache-2.0","readmeFilename":"README.md"}