opencroc 1.8.1 → 1.8.2
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/dist/cli/index.js +755 -8
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +128 -1
- package/dist/index.js +548 -0
- package/dist/index.js.map +1 -1
- package/dist/web/dist/assets/main-Ccg3eDNK.js +1 -0
- package/dist/web/dist/assets/office-runtime-B3iNctxE.css +1 -0
- package/dist/web/dist/assets/office-runtime-BsCh82Pj.js +183 -0
- package/dist/web/dist/assets/pixel-page-3BYGm7dH.js +470 -0
- package/dist/web/dist/assets/react-vendor-C8RhVn0h.js +49 -0
- package/dist/web/dist/assets/studio-page-BInoyoV2.css +1 -0
- package/dist/web/dist/assets/studio-page-o3SCvE_v.js +351 -0
- package/dist/web/dist/assets/three-addons-BdrPp04O.js +470 -0
- package/dist/web/dist/assets/three-core-CsxM1PCY.js +4057 -0
- package/dist/web/dist/index.html +15 -0
- package/dist/web/index.html +11 -572
- package/dist/web/public/botreview/char_0.png +0 -0
- package/dist/web/public/botreview/char_1.png +0 -0
- package/dist/web/public/botreview/char_2.png +0 -0
- package/dist/web/public/botreview/coffee-machine.gif +0 -0
- package/dist/web/public/botreview/server.gif +0 -0
- package/dist/web/public/botreview/walls.png +0 -0
- package/dist/web/public/star/desk-v3.webp +0 -0
- package/dist/web/public/star/office_bg_small.webp +0 -0
- package/dist/web/public/star/star-idle-v5.png +0 -0
- package/dist/web/public/star/star-working-spritesheet-grid.webp +0 -0
- package/dist/web/src/app/AppLayout.tsx +34 -0
- package/dist/web/src/app/AppRouter.tsx +46 -0
- package/dist/web/src/app/bootstrap.tsx +22 -0
- package/dist/web/src/app/routes.tsx +52 -0
- package/dist/web/src/features/office/runtime/index.ts +1 -0
- package/dist/web/src/features/office/runtime/mount.ts +809 -0
- package/dist/web/src/features/pixel/runtime/index.ts +1 -0
- package/dist/web/src/features/pixel/runtime/mount.ts +728 -0
- package/dist/web/src/features/studio/runtime/index.ts +1 -0
- package/dist/web/src/features/studio/runtime/mount.ts +664 -0
- package/dist/web/src/features/three/engine/index.ts +1 -0
- package/dist/web/src/main.tsx +7 -0
- package/dist/web/src/pages/office/index.ts +1 -0
- package/dist/web/src/pages/office/page.tsx +283 -0
- package/dist/web/src/pages/pixel/index.ts +1 -0
- package/dist/web/src/pages/pixel/page.tsx +564 -0
- package/dist/web/src/pages/studio/index.ts +1 -0
- package/dist/web/src/pages/studio/page.tsx +446 -0
- package/dist/web/{js/agents.js → src/runtime/agents.ts} +304 -31
- package/dist/web/{js/camera.js → src/runtime/camera.ts} +12 -5
- package/dist/web/{js/dataviz.js → src/runtime/dataviz.ts} +38 -14
- package/dist/web/{js/effects.js → src/runtime/effects.ts} +139 -2
- package/dist/web/{js/engine.js → src/runtime/engine.ts} +45 -6
- package/dist/web/{js/office.js → src/runtime/office.ts} +136 -20
- package/dist/web/{js/ui.js → src/runtime/ui.ts} +11 -7
- package/dist/web/src/shared/assets.ts +4 -0
- package/dist/web/src/shared/navigation.ts +47 -0
- package/dist/web/src/styles/app-layout.css +19 -0
- package/dist/web/src/styles/office.css +268 -0
- package/dist/web/tsconfig.json +28 -0
- package/dist/web/vite.config.ts +93 -0
- package/package.json +11 -2
- package/dist/web/index-studio.html +0 -1644
- package/dist/web/index-v2-pixel.html +0 -1571
- /package/dist/web/{assets → dist}/botreview/char_0.png +0 -0
- /package/dist/web/{assets → dist}/botreview/char_1.png +0 -0
- /package/dist/web/{assets → dist}/botreview/char_2.png +0 -0
- /package/dist/web/{assets → dist}/botreview/coffee-machine.gif +0 -0
- /package/dist/web/{assets → dist}/botreview/server.gif +0 -0
- /package/dist/web/{assets → dist}/botreview/walls.png +0 -0
- /package/dist/web/{assets → dist}/star/desk-v3.webp +0 -0
- /package/dist/web/{assets → dist}/star/office_bg_small.webp +0 -0
- /package/dist/web/{assets → dist}/star/star-idle-v5.png +0 -0
- /package/dist/web/{assets → dist}/star/star-working-spritesheet-grid.webp +0 -0
- /package/dist/web/{js/state.js → src/runtime/state.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -9208,8 +9208,553 @@ function cleanJsonResponse(response) {
|
|
|
9208
9208
|
function sanitizeId2(id) {
|
|
9209
9209
|
return id.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
9210
9210
|
}
|
|
9211
|
+
|
|
9212
|
+
// src/agents/role-registry.ts
|
|
9213
|
+
init_esm_shims();
|
|
9214
|
+
var CORE_ROLES = [
|
|
9215
|
+
{
|
|
9216
|
+
id: "parser-croc",
|
|
9217
|
+
name: "\u89E3\u6790\u9CC4",
|
|
9218
|
+
nameEn: "Parser Croc",
|
|
9219
|
+
category: "core",
|
|
9220
|
+
description: "\u89E3\u6790\u9879\u76EE\u7ED3\u6784\u3001\u63D0\u53D6\u5B9E\u4F53\u548C\u5173\u7CFB",
|
|
9221
|
+
sprite: "parser",
|
|
9222
|
+
color: "#34d399",
|
|
9223
|
+
priority: 0,
|
|
9224
|
+
triggers: { custom: () => true },
|
|
9225
|
+
// Always summoned
|
|
9226
|
+
systemPrompt: "You are an expert code parser. Analyze the project structure, extract all entities (classes, functions, APIs, models) and their relationships.",
|
|
9227
|
+
outputType: "analysis",
|
|
9228
|
+
tags: ["core", "parser", "structure"]
|
|
9229
|
+
},
|
|
9230
|
+
{
|
|
9231
|
+
id: "analyzer-croc",
|
|
9232
|
+
name: "\u5206\u6790\u9CC4",
|
|
9233
|
+
nameEn: "Analyzer Croc",
|
|
9234
|
+
category: "core",
|
|
9235
|
+
description: "\u6784\u5EFA\u77E5\u8BC6\u56FE\u8C31\u3001\u5206\u6790\u4F9D\u8D56\u5173\u7CFB",
|
|
9236
|
+
sprite: "analyzer",
|
|
9237
|
+
color: "#60a5fa",
|
|
9238
|
+
priority: 1,
|
|
9239
|
+
triggers: { custom: () => true },
|
|
9240
|
+
systemPrompt: "You are an expert software architect. Build a knowledge graph of the project, analyze dependencies, coupling, and cohesion.",
|
|
9241
|
+
outputType: "diagram",
|
|
9242
|
+
tags: ["core", "graph", "architecture"]
|
|
9243
|
+
},
|
|
9244
|
+
{
|
|
9245
|
+
id: "tester-croc",
|
|
9246
|
+
name: "\u6D4B\u8BD5\u9CC4",
|
|
9247
|
+
nameEn: "Tester Croc",
|
|
9248
|
+
category: "core",
|
|
9249
|
+
description: "\u751F\u6210\u548C\u6267\u884C E2E \u6D4B\u8BD5",
|
|
9250
|
+
sprite: "tester",
|
|
9251
|
+
color: "#a78bfa",
|
|
9252
|
+
priority: 2,
|
|
9253
|
+
triggers: { custom: () => true },
|
|
9254
|
+
systemPrompt: "You are an expert test engineer. Generate comprehensive E2E test cases covering all critical paths, edge cases, and error scenarios.",
|
|
9255
|
+
outputType: "analysis",
|
|
9256
|
+
tags: ["core", "testing", "e2e"]
|
|
9257
|
+
},
|
|
9258
|
+
{
|
|
9259
|
+
id: "healer-croc",
|
|
9260
|
+
name: "\u4FEE\u590D\u9CC4",
|
|
9261
|
+
nameEn: "Healer Croc",
|
|
9262
|
+
category: "core",
|
|
9263
|
+
description: "\u81EA\u52A8\u4FEE\u590D\u6D4B\u8BD5\u5931\u8D25\u548C\u4EE3\u7801\u95EE\u9898",
|
|
9264
|
+
sprite: "healer",
|
|
9265
|
+
color: "#f87171",
|
|
9266
|
+
priority: 3,
|
|
9267
|
+
triggers: { custom: () => true },
|
|
9268
|
+
systemPrompt: "You are an expert debugger and code fixer. Analyze test failures, diagnose root causes, and propose minimal targeted fixes.",
|
|
9269
|
+
outputType: "fix",
|
|
9270
|
+
tags: ["core", "healing", "debug"]
|
|
9271
|
+
},
|
|
9272
|
+
{
|
|
9273
|
+
id: "planner-croc",
|
|
9274
|
+
name: "\u89C4\u5212\u9CC4",
|
|
9275
|
+
nameEn: "Planner Croc",
|
|
9276
|
+
category: "core",
|
|
9277
|
+
description: "\u5236\u5B9A\u6D4B\u8BD5\u7B56\u7565\u548C\u6267\u884C\u8BA1\u5212",
|
|
9278
|
+
sprite: "planner",
|
|
9279
|
+
color: "#fbbf24",
|
|
9280
|
+
priority: 4,
|
|
9281
|
+
triggers: { custom: () => true },
|
|
9282
|
+
systemPrompt: "You are an expert project planner. Create test strategies, prioritize test execution order, and optimize the testing pipeline.",
|
|
9283
|
+
outputType: "analysis",
|
|
9284
|
+
tags: ["core", "planning", "strategy"]
|
|
9285
|
+
},
|
|
9286
|
+
{
|
|
9287
|
+
id: "reporter-croc",
|
|
9288
|
+
name: "\u6C47\u62A5\u9CC4",
|
|
9289
|
+
nameEn: "Reporter Croc",
|
|
9290
|
+
category: "core",
|
|
9291
|
+
description: "\u751F\u6210\u591A\u89C6\u89D2\u5206\u6790\u62A5\u544A",
|
|
9292
|
+
sprite: "reporter",
|
|
9293
|
+
color: "#22d3ee",
|
|
9294
|
+
priority: 5,
|
|
9295
|
+
triggers: { custom: () => true },
|
|
9296
|
+
systemPrompt: "You are an expert technical writer. Generate clear, actionable reports from multiple perspectives (developer, architect, tester, product, executive).",
|
|
9297
|
+
outputType: "report",
|
|
9298
|
+
tags: ["core", "reporting", "documentation"]
|
|
9299
|
+
}
|
|
9300
|
+
];
|
|
9301
|
+
var LANGUAGE_ROLES = [
|
|
9302
|
+
{
|
|
9303
|
+
id: "python-croc",
|
|
9304
|
+
name: "Python\u4E13\u5BB6\u9CC4",
|
|
9305
|
+
nameEn: "Python Expert Croc",
|
|
9306
|
+
category: "language",
|
|
9307
|
+
description: "Python \u751F\u6001\u4E13\u5BB6\uFF1ADjango/Flask/FastAPI/SQLAlchemy",
|
|
9308
|
+
sprite: "language",
|
|
9309
|
+
color: "#3776ab",
|
|
9310
|
+
priority: 10,
|
|
9311
|
+
triggers: { languages: ["python"] },
|
|
9312
|
+
systemPrompt: "You are a Python ecosystem expert. Analyze Python code for best practices, type safety, async patterns, Django/Flask/FastAPI conventions, SQLAlchemy usage, and Python-specific security issues.",
|
|
9313
|
+
outputType: "review",
|
|
9314
|
+
tags: ["language", "python", "django", "flask", "fastapi"]
|
|
9315
|
+
},
|
|
9316
|
+
{
|
|
9317
|
+
id: "go-croc",
|
|
9318
|
+
name: "Go\u4E13\u5BB6\u9CC4",
|
|
9319
|
+
nameEn: "Go Expert Croc",
|
|
9320
|
+
category: "language",
|
|
9321
|
+
description: "Go \u751F\u6001\u4E13\u5BB6\uFF1Agoroutine/channel/\u63A5\u53E3\u8BBE\u8BA1",
|
|
9322
|
+
sprite: "language",
|
|
9323
|
+
color: "#00add8",
|
|
9324
|
+
priority: 10,
|
|
9325
|
+
triggers: { languages: ["go"] },
|
|
9326
|
+
systemPrompt: "You are a Go ecosystem expert. Analyze Go code for goroutine safety, channel patterns, interface design, error handling, and Go-specific performance concerns.",
|
|
9327
|
+
outputType: "review",
|
|
9328
|
+
tags: ["language", "go", "golang", "concurrency"]
|
|
9329
|
+
},
|
|
9330
|
+
{
|
|
9331
|
+
id: "java-croc",
|
|
9332
|
+
name: "Java\u4E13\u5BB6\u9CC4",
|
|
9333
|
+
nameEn: "Java Expert Croc",
|
|
9334
|
+
category: "language",
|
|
9335
|
+
description: "Java/Kotlin \u751F\u6001\u4E13\u5BB6\uFF1ASpring Boot/JPA/\u5FAE\u670D\u52A1",
|
|
9336
|
+
sprite: "language",
|
|
9337
|
+
color: "#ed8b00",
|
|
9338
|
+
priority: 10,
|
|
9339
|
+
triggers: { languages: ["java", "kotlin"] },
|
|
9340
|
+
systemPrompt: "You are a Java/Kotlin ecosystem expert. Analyze Spring Boot applications for bean lifecycle issues, JPA N+1 queries, transaction management, and microservice patterns.",
|
|
9341
|
+
outputType: "review",
|
|
9342
|
+
tags: ["language", "java", "kotlin", "spring"]
|
|
9343
|
+
},
|
|
9344
|
+
{
|
|
9345
|
+
id: "rust-croc",
|
|
9346
|
+
name: "Rust\u4E13\u5BB6\u9CC4",
|
|
9347
|
+
nameEn: "Rust Expert Croc",
|
|
9348
|
+
category: "language",
|
|
9349
|
+
description: "Rust \u751F\u6001\u4E13\u5BB6\uFF1A\u6240\u6709\u6743/\u751F\u547D\u5468\u671F/unsafe",
|
|
9350
|
+
sprite: "language",
|
|
9351
|
+
color: "#dea584",
|
|
9352
|
+
priority: 10,
|
|
9353
|
+
triggers: { languages: ["rust"] },
|
|
9354
|
+
systemPrompt: "You are a Rust ecosystem expert. Analyze Rust code for ownership patterns, lifetime issues, unsafe code safety, and performance optimization.",
|
|
9355
|
+
outputType: "review",
|
|
9356
|
+
tags: ["language", "rust", "ownership", "safety"]
|
|
9357
|
+
}
|
|
9358
|
+
];
|
|
9359
|
+
var FRAMEWORK_ROLES = [
|
|
9360
|
+
{
|
|
9361
|
+
id: "react-croc",
|
|
9362
|
+
name: "React\u4E13\u5BB6\u9CC4",
|
|
9363
|
+
nameEn: "React Expert Croc",
|
|
9364
|
+
category: "framework",
|
|
9365
|
+
description: "React/Next.js \u524D\u7AEF\u6027\u80FD\u548C\u67B6\u6784\u4E13\u5BB6",
|
|
9366
|
+
sprite: "framework",
|
|
9367
|
+
color: "#61dafb",
|
|
9368
|
+
priority: 15,
|
|
9369
|
+
triggers: { frameworks: ["React", "Next.js"] },
|
|
9370
|
+
systemPrompt: "You are a React/Next.js expert. Analyze component architecture, render performance, state management, SSR/SSG patterns, and React-specific anti-patterns.",
|
|
9371
|
+
outputType: "review",
|
|
9372
|
+
tags: ["framework", "react", "nextjs", "frontend"]
|
|
9373
|
+
},
|
|
9374
|
+
{
|
|
9375
|
+
id: "vue-croc",
|
|
9376
|
+
name: "Vue\u4E13\u5BB6\u9CC4",
|
|
9377
|
+
nameEn: "Vue Expert Croc",
|
|
9378
|
+
category: "framework",
|
|
9379
|
+
description: "Vue/Nuxt \u4E13\u5BB6\uFF1A\u7EC4\u5408\u5F0FAPI/\u54CD\u5E94\u5F0F/SSR",
|
|
9380
|
+
sprite: "framework",
|
|
9381
|
+
color: "#42b883",
|
|
9382
|
+
priority: 15,
|
|
9383
|
+
triggers: { frameworks: ["Vue", "Nuxt"] },
|
|
9384
|
+
systemPrompt: "You are a Vue/Nuxt expert. Analyze Composition API usage, reactivity patterns, Pinia stores, SSR hydration, and Vue-specific best practices.",
|
|
9385
|
+
outputType: "review",
|
|
9386
|
+
tags: ["framework", "vue", "nuxt", "frontend"]
|
|
9387
|
+
},
|
|
9388
|
+
{
|
|
9389
|
+
id: "express-croc",
|
|
9390
|
+
name: "Express\u4E13\u5BB6\u9CC4",
|
|
9391
|
+
nameEn: "Express Expert Croc",
|
|
9392
|
+
category: "framework",
|
|
9393
|
+
description: "Express/Koa/Fastify \u8DEF\u7531\u548C\u4E2D\u95F4\u4EF6\u4E13\u5BB6",
|
|
9394
|
+
sprite: "framework",
|
|
9395
|
+
color: "#68a063",
|
|
9396
|
+
priority: 15,
|
|
9397
|
+
triggers: { frameworks: ["Express", "Koa", "Fastify"] },
|
|
9398
|
+
systemPrompt: "You are a Node.js backend expert. Analyze Express/Koa/Fastify middleware chains, route organization, error handling, authentication patterns, and performance.",
|
|
9399
|
+
outputType: "review",
|
|
9400
|
+
tags: ["framework", "express", "koa", "fastify", "nodejs"]
|
|
9401
|
+
},
|
|
9402
|
+
{
|
|
9403
|
+
id: "django-croc",
|
|
9404
|
+
name: "Django\u4E13\u5BB6\u9CC4",
|
|
9405
|
+
nameEn: "Django Expert Croc",
|
|
9406
|
+
category: "framework",
|
|
9407
|
+
description: "Django/DRF \u4E13\u5BB6\uFF1AORM/\u5E8F\u5217\u5316/\u6743\u9650",
|
|
9408
|
+
sprite: "framework",
|
|
9409
|
+
color: "#092e20",
|
|
9410
|
+
priority: 15,
|
|
9411
|
+
triggers: { frameworks: ["Django", "DRF"] },
|
|
9412
|
+
systemPrompt: "You are a Django/DRF expert. Analyze ORM query efficiency, serializer design, view permissions, middleware, and Django-specific security practices.",
|
|
9413
|
+
outputType: "review",
|
|
9414
|
+
tags: ["framework", "django", "drf", "python"]
|
|
9415
|
+
},
|
|
9416
|
+
{
|
|
9417
|
+
id: "spring-croc",
|
|
9418
|
+
name: "SpringBoot\u4E13\u5BB6\u9CC4",
|
|
9419
|
+
nameEn: "Spring Boot Expert Croc",
|
|
9420
|
+
category: "framework",
|
|
9421
|
+
description: "Spring Boot/Cloud \u5FAE\u670D\u52A1\u67B6\u6784\u4E13\u5BB6",
|
|
9422
|
+
sprite: "framework",
|
|
9423
|
+
color: "#6db33f",
|
|
9424
|
+
priority: 15,
|
|
9425
|
+
triggers: { frameworks: ["Spring Boot", "Spring Cloud"] },
|
|
9426
|
+
systemPrompt: "You are a Spring Boot/Cloud expert. Analyze bean configurations, transaction management, service discovery, circuit breakers, and microservice communication patterns.",
|
|
9427
|
+
outputType: "review",
|
|
9428
|
+
tags: ["framework", "spring", "springboot", "microservice"]
|
|
9429
|
+
}
|
|
9430
|
+
];
|
|
9431
|
+
var DOMAIN_ROLES = [
|
|
9432
|
+
{
|
|
9433
|
+
id: "security-croc",
|
|
9434
|
+
name: "\u5B89\u5168\u5BA1\u8BA1\u9CC4",
|
|
9435
|
+
nameEn: "Security Auditor Croc",
|
|
9436
|
+
category: "domain",
|
|
9437
|
+
description: "\u5B89\u5168\u6F0F\u6D1E\u68C0\u6D4B\uFF1A\u6CE8\u5165/XSS/CSRF/\u8BA4\u8BC1/\u6388\u6743",
|
|
9438
|
+
sprite: "security",
|
|
9439
|
+
color: "#ef4444",
|
|
9440
|
+
priority: 8,
|
|
9441
|
+
triggers: {
|
|
9442
|
+
riskCategories: ["security"],
|
|
9443
|
+
custom: (ctx) => ctx.hasAPIs
|
|
9444
|
+
},
|
|
9445
|
+
systemPrompt: "You are a security auditor. Scan for OWASP Top 10 vulnerabilities: SQL injection, XSS, CSRF, broken authentication, sensitive data exposure, insecure deserialization, and missing access controls.",
|
|
9446
|
+
outputType: "report",
|
|
9447
|
+
tags: ["domain", "security", "owasp", "audit"]
|
|
9448
|
+
},
|
|
9449
|
+
{
|
|
9450
|
+
id: "performance-croc",
|
|
9451
|
+
name: "\u6027\u80FD\u5206\u6790\u9CC4",
|
|
9452
|
+
nameEn: "Performance Analyst Croc",
|
|
9453
|
+
category: "domain",
|
|
9454
|
+
description: "\u6027\u80FD\u74F6\u9888\u68C0\u6D4B\uFF1AN+1\u67E5\u8BE2/\u5185\u5B58\u6CC4\u6F0F/\u6162\u63A5\u53E3",
|
|
9455
|
+
sprite: "performance",
|
|
9456
|
+
color: "#f59e0b",
|
|
9457
|
+
priority: 9,
|
|
9458
|
+
triggers: {
|
|
9459
|
+
minEntities: 50,
|
|
9460
|
+
custom: (ctx) => ctx.hasModels && ctx.hasAPIs
|
|
9461
|
+
},
|
|
9462
|
+
systemPrompt: "You are a performance analyst. Detect N+1 queries, memory leaks, slow API endpoints, missing indexes, unnecessary data loading, and recommend caching strategies.",
|
|
9463
|
+
outputType: "report",
|
|
9464
|
+
tags: ["domain", "performance", "optimization", "n+1"]
|
|
9465
|
+
},
|
|
9466
|
+
{
|
|
9467
|
+
id: "architecture-croc",
|
|
9468
|
+
name: "\u67B6\u6784\u8BC4\u5BA1\u9CC4",
|
|
9469
|
+
nameEn: "Architecture Reviewer Croc",
|
|
9470
|
+
category: "domain",
|
|
9471
|
+
description: "\u67B6\u6784\u8D28\u91CF\u8BC4\u5BA1\uFF1A\u8026\u5408\u5EA6/\u5185\u805A\u6027/\u5206\u5C42/DDD",
|
|
9472
|
+
sprite: "architecture",
|
|
9473
|
+
color: "#8b5cf6",
|
|
9474
|
+
priority: 7,
|
|
9475
|
+
triggers: {
|
|
9476
|
+
minEntities: 30
|
|
9477
|
+
},
|
|
9478
|
+
systemPrompt: "You are a software architect. Evaluate coupling, cohesion, layering, dependency injection, SOLID principles, DDD patterns, and recommend architectural improvements.",
|
|
9479
|
+
outputType: "review",
|
|
9480
|
+
tags: ["domain", "architecture", "solid", "ddd"]
|
|
9481
|
+
},
|
|
9482
|
+
{
|
|
9483
|
+
id: "data-modeling-croc",
|
|
9484
|
+
name: "\u6570\u636E\u5EFA\u6A21\u9CC4",
|
|
9485
|
+
nameEn: "Data Modeling Croc",
|
|
9486
|
+
category: "domain",
|
|
9487
|
+
description: "\u6570\u636E\u6A21\u578B\u8BC4\u5BA1\uFF1A\u8303\u5F0F/\u7D22\u5F15/\u5173\u8054/\u8FC1\u79FB",
|
|
9488
|
+
sprite: "database",
|
|
9489
|
+
color: "#06b6d4",
|
|
9490
|
+
priority: 9,
|
|
9491
|
+
triggers: {
|
|
9492
|
+
custom: (ctx) => ctx.hasModels,
|
|
9493
|
+
frameworks: ["Sequelize", "Prisma", "TypeORM", "Drizzle", "SQLAlchemy", "Django"]
|
|
9494
|
+
},
|
|
9495
|
+
systemPrompt: "You are a database expert. Review data models for normalization, index design, relationship integrity, migration safety, cascade delete risks, and query optimization.",
|
|
9496
|
+
outputType: "review",
|
|
9497
|
+
tags: ["domain", "database", "modeling", "orm"]
|
|
9498
|
+
},
|
|
9499
|
+
{
|
|
9500
|
+
id: "devops-croc",
|
|
9501
|
+
name: "\u8FD0\u7EF4\u90E8\u7F72\u9CC4",
|
|
9502
|
+
nameEn: "DevOps Croc",
|
|
9503
|
+
category: "domain",
|
|
9504
|
+
description: "CI/CD\u3001Docker\u3001K8s \u90E8\u7F72\u548C\u8FD0\u7EF4\u4E13\u5BB6",
|
|
9505
|
+
sprite: "devops",
|
|
9506
|
+
color: "#2563eb",
|
|
9507
|
+
priority: 12,
|
|
9508
|
+
triggers: {
|
|
9509
|
+
custom: (ctx) => ctx.hasDocker || ctx.hasCI,
|
|
9510
|
+
filePatterns: ["Dockerfile", "docker-compose*", ".github/workflows/*", ".gitlab-ci*", "Jenkinsfile"]
|
|
9511
|
+
},
|
|
9512
|
+
systemPrompt: "You are a DevOps expert. Analyze Dockerfile efficiency, compose orchestration, CI/CD pipeline design, secret management, health checks, and deployment strategies.",
|
|
9513
|
+
outputType: "review",
|
|
9514
|
+
tags: ["domain", "devops", "docker", "ci/cd", "kubernetes"]
|
|
9515
|
+
},
|
|
9516
|
+
{
|
|
9517
|
+
id: "api-design-croc",
|
|
9518
|
+
name: "API\u8BBE\u8BA1\u9CC4",
|
|
9519
|
+
nameEn: "API Design Croc",
|
|
9520
|
+
category: "domain",
|
|
9521
|
+
description: "RESTful API \u8BBE\u8BA1\u8BC4\u5BA1\uFF1A\u547D\u540D/\u7248\u672C/\u5206\u9875/\u9519\u8BEF\u5904\u7406",
|
|
9522
|
+
sprite: "api",
|
|
9523
|
+
color: "#10b981",
|
|
9524
|
+
priority: 11,
|
|
9525
|
+
triggers: {
|
|
9526
|
+
custom: (ctx) => ctx.hasAPIs,
|
|
9527
|
+
minEntities: 10
|
|
9528
|
+
},
|
|
9529
|
+
systemPrompt: "You are an API design expert. Review REST API naming conventions, versioning strategy, pagination, filtering, error response format, rate limiting, and documentation completeness.",
|
|
9530
|
+
outputType: "review",
|
|
9531
|
+
tags: ["domain", "api", "rest", "design"]
|
|
9532
|
+
},
|
|
9533
|
+
{
|
|
9534
|
+
id: "refactor-croc",
|
|
9535
|
+
name: "\u91CD\u6784\u5EFA\u8BAE\u9CC4",
|
|
9536
|
+
nameEn: "Refactoring Croc",
|
|
9537
|
+
category: "domain",
|
|
9538
|
+
description: "\u4EE3\u7801\u8D28\u91CF\u8BC4\u4F30\uFF1A\u6280\u672F\u503A/\u590D\u6742\u5EA6/\u91CD\u590D\u4EE3\u7801",
|
|
9539
|
+
sprite: "refactor",
|
|
9540
|
+
color: "#ec4899",
|
|
9541
|
+
priority: 13,
|
|
9542
|
+
triggers: {
|
|
9543
|
+
riskCategories: ["maintainability"],
|
|
9544
|
+
minEntities: 40
|
|
9545
|
+
},
|
|
9546
|
+
systemPrompt: "You are a refactoring expert. Identify code smells, duplicated logic, high cyclomatic complexity, god classes, feature envy, and suggest targeted refactoring strategies with minimal risk.",
|
|
9547
|
+
outputType: "review",
|
|
9548
|
+
tags: ["domain", "refactoring", "quality", "tech-debt"]
|
|
9549
|
+
},
|
|
9550
|
+
{
|
|
9551
|
+
id: "microservice-croc",
|
|
9552
|
+
name: "\u670D\u52A1\u6CBB\u7406\u9CC4",
|
|
9553
|
+
nameEn: "Microservice Governance Croc",
|
|
9554
|
+
category: "domain",
|
|
9555
|
+
description: "\u5FAE\u670D\u52A1\u67B6\u6784\u6CBB\u7406\uFF1A\u670D\u52A1\u8FB9\u754C/\u7194\u65AD/\u94FE\u8DEF\u8FFD\u8E2A",
|
|
9556
|
+
sprite: "microservice",
|
|
9557
|
+
color: "#7c3aed",
|
|
9558
|
+
priority: 14,
|
|
9559
|
+
triggers: {
|
|
9560
|
+
projectTypes: ["microservice", "monorepo"],
|
|
9561
|
+
custom: (ctx) => ctx.entityCount > 100
|
|
9562
|
+
},
|
|
9563
|
+
systemPrompt: "You are a microservice governance expert. Analyze service boundaries, inter-service communication, circuit breakers, distributed tracing, service mesh, and API gateway patterns.",
|
|
9564
|
+
outputType: "review",
|
|
9565
|
+
tags: ["domain", "microservice", "governance", "distributed"]
|
|
9566
|
+
}
|
|
9567
|
+
];
|
|
9568
|
+
var RoleRegistry = class {
|
|
9569
|
+
roles = /* @__PURE__ */ new Map();
|
|
9570
|
+
constructor() {
|
|
9571
|
+
for (const role of [...CORE_ROLES, ...LANGUAGE_ROLES, ...FRAMEWORK_ROLES, ...DOMAIN_ROLES]) {
|
|
9572
|
+
this.roles.set(role.id, role);
|
|
9573
|
+
}
|
|
9574
|
+
}
|
|
9575
|
+
/** Register a new role (community or custom) */
|
|
9576
|
+
register(role) {
|
|
9577
|
+
if (this.roles.has(role.id)) {
|
|
9578
|
+
throw new Error(`Role "${role.id}" is already registered`);
|
|
9579
|
+
}
|
|
9580
|
+
this.roles.set(role.id, role);
|
|
9581
|
+
}
|
|
9582
|
+
/** Unregister a role */
|
|
9583
|
+
unregister(id) {
|
|
9584
|
+
return this.roles.delete(id);
|
|
9585
|
+
}
|
|
9586
|
+
/** Get a role by ID */
|
|
9587
|
+
get(id) {
|
|
9588
|
+
return this.roles.get(id);
|
|
9589
|
+
}
|
|
9590
|
+
/** List all registered roles */
|
|
9591
|
+
list() {
|
|
9592
|
+
return Array.from(this.roles.values());
|
|
9593
|
+
}
|
|
9594
|
+
/** List roles by category */
|
|
9595
|
+
listByCategory(category) {
|
|
9596
|
+
return this.list().filter((r) => r.category === category);
|
|
9597
|
+
}
|
|
9598
|
+
/** Search roles by tags */
|
|
9599
|
+
search(query) {
|
|
9600
|
+
const q = query.toLowerCase();
|
|
9601
|
+
return this.list().filter(
|
|
9602
|
+
(r) => r.name.toLowerCase().includes(q) || r.nameEn.toLowerCase().includes(q) || r.description.toLowerCase().includes(q) || r.tags.some((t) => t.includes(q))
|
|
9603
|
+
);
|
|
9604
|
+
}
|
|
9605
|
+
/** Total number of registered roles */
|
|
9606
|
+
get size() {
|
|
9607
|
+
return this.roles.size;
|
|
9608
|
+
}
|
|
9609
|
+
};
|
|
9610
|
+
var _registry = null;
|
|
9611
|
+
function getRoleRegistry() {
|
|
9612
|
+
if (!_registry) {
|
|
9613
|
+
_registry = new RoleRegistry();
|
|
9614
|
+
}
|
|
9615
|
+
return _registry;
|
|
9616
|
+
}
|
|
9617
|
+
|
|
9618
|
+
// src/agents/task-router.ts
|
|
9619
|
+
init_esm_shims();
|
|
9620
|
+
function buildMatchContext(scan) {
|
|
9621
|
+
const languages = scan.languages;
|
|
9622
|
+
const frameworks = scan.frameworks.map((f) => f.name);
|
|
9623
|
+
const frontendFrameworks = ["React", "Vue", "Angular", "Svelte", "Next.js", "Nuxt"];
|
|
9624
|
+
const backendFrameworks = ["Express", "Fastify", "NestJS", "Django", "Flask", "Spring Boot", "Gin", "Actix"];
|
|
9625
|
+
const hasFE = frameworks.some((f) => frontendFrameworks.includes(f));
|
|
9626
|
+
const hasBE = frameworks.some((f) => backendFrameworks.includes(f));
|
|
9627
|
+
const projectType = hasFE && hasBE ? "fullstack" : hasFE ? "frontend" : hasBE ? "backend" : "unknown";
|
|
9628
|
+
const entityTypes = new Set(scan.entities.map((e) => e.type));
|
|
9629
|
+
const hasModels = entityTypes.has("model") || entityTypes.has("class");
|
|
9630
|
+
const hasAPIs = entityTypes.has("api") || entityTypes.has("route");
|
|
9631
|
+
const hasFrontend = hasFE || (languages["html"] ?? 0) > 10 || (languages["css"] ?? 0) > 5;
|
|
9632
|
+
const allPaths = scan.files.map((f) => f.path);
|
|
9633
|
+
const hasDocker = allPaths.some(
|
|
9634
|
+
(p) => p.includes("Dockerfile") || p.includes("docker-compose")
|
|
9635
|
+
);
|
|
9636
|
+
const hasCI = allPaths.some(
|
|
9637
|
+
(p) => p.includes(".github/workflows") || p.includes(".gitlab-ci") || p.includes("Jenkinsfile")
|
|
9638
|
+
);
|
|
9639
|
+
const riskCategories = [];
|
|
9640
|
+
return {
|
|
9641
|
+
languages,
|
|
9642
|
+
frameworks,
|
|
9643
|
+
projectType,
|
|
9644
|
+
fileCount: scan.files.length,
|
|
9645
|
+
entityCount: scan.entities.length,
|
|
9646
|
+
riskCategories,
|
|
9647
|
+
hasModels,
|
|
9648
|
+
hasAPIs,
|
|
9649
|
+
hasFrontend,
|
|
9650
|
+
hasDocker,
|
|
9651
|
+
hasCI
|
|
9652
|
+
};
|
|
9653
|
+
}
|
|
9654
|
+
function matchesTriggers(trigger, ctx) {
|
|
9655
|
+
const reasons = [];
|
|
9656
|
+
let score = 0;
|
|
9657
|
+
let checks = 0;
|
|
9658
|
+
if (trigger.languages && trigger.languages.length > 0) {
|
|
9659
|
+
checks++;
|
|
9660
|
+
const matched = trigger.languages.filter((l) => (ctx.languages[l] ?? 0) > 0);
|
|
9661
|
+
if (matched.length > 0) {
|
|
9662
|
+
score++;
|
|
9663
|
+
reasons.push(`\u8BED\u8A00\u5339\u914D: ${matched.join(", ")}`);
|
|
9664
|
+
}
|
|
9665
|
+
}
|
|
9666
|
+
if (trigger.frameworks && trigger.frameworks.length > 0) {
|
|
9667
|
+
checks++;
|
|
9668
|
+
const matched = trigger.frameworks.filter(
|
|
9669
|
+
(f) => ctx.frameworks.some((cf) => cf.toLowerCase() === f.toLowerCase())
|
|
9670
|
+
);
|
|
9671
|
+
if (matched.length > 0) {
|
|
9672
|
+
score++;
|
|
9673
|
+
reasons.push(`\u6846\u67B6\u5339\u914D: ${matched.join(", ")}`);
|
|
9674
|
+
}
|
|
9675
|
+
}
|
|
9676
|
+
if (trigger.projectTypes && trigger.projectTypes.length > 0) {
|
|
9677
|
+
checks++;
|
|
9678
|
+
if (trigger.projectTypes.includes(ctx.projectType)) {
|
|
9679
|
+
score++;
|
|
9680
|
+
reasons.push(`\u9879\u76EE\u7C7B\u578B\u5339\u914D: ${ctx.projectType}`);
|
|
9681
|
+
}
|
|
9682
|
+
}
|
|
9683
|
+
if (trigger.minEntities !== void 0) {
|
|
9684
|
+
checks++;
|
|
9685
|
+
if (ctx.entityCount >= trigger.minEntities) {
|
|
9686
|
+
score++;
|
|
9687
|
+
reasons.push(`\u5B9E\u4F53\u6570\u91CF\u6EE1\u8DB3: ${ctx.entityCount} \u2265 ${trigger.minEntities}`);
|
|
9688
|
+
}
|
|
9689
|
+
}
|
|
9690
|
+
if (trigger.riskCategories && trigger.riskCategories.length > 0) {
|
|
9691
|
+
checks++;
|
|
9692
|
+
const matched = trigger.riskCategories.filter((r) => ctx.riskCategories.includes(r));
|
|
9693
|
+
if (matched.length > 0) {
|
|
9694
|
+
score++;
|
|
9695
|
+
reasons.push(`\u98CE\u9669\u7C7B\u522B\u5339\u914D: ${matched.join(", ")}`);
|
|
9696
|
+
}
|
|
9697
|
+
}
|
|
9698
|
+
if (trigger.custom) {
|
|
9699
|
+
checks++;
|
|
9700
|
+
try {
|
|
9701
|
+
if (trigger.custom(ctx)) {
|
|
9702
|
+
score++;
|
|
9703
|
+
reasons.push("\u81EA\u5B9A\u4E49\u6761\u4EF6\u6EE1\u8DB3");
|
|
9704
|
+
}
|
|
9705
|
+
} catch {
|
|
9706
|
+
}
|
|
9707
|
+
}
|
|
9708
|
+
const matches = checks === 0 ? false : score > 0;
|
|
9709
|
+
const confidence = checks > 0 ? score / checks : 0;
|
|
9710
|
+
return {
|
|
9711
|
+
matches,
|
|
9712
|
+
reason: reasons.join("; ") || "\u65E0\u5339\u914D",
|
|
9713
|
+
confidence
|
|
9714
|
+
};
|
|
9715
|
+
}
|
|
9716
|
+
function planSummon(scan, maxRoles = 8, riskCategories = []) {
|
|
9717
|
+
const registry = getRoleRegistry();
|
|
9718
|
+
const ctx = buildMatchContext(scan);
|
|
9719
|
+
ctx.riskCategories = riskCategories;
|
|
9720
|
+
const summoned = [];
|
|
9721
|
+
const reasoning = [];
|
|
9722
|
+
const allRoles = registry.list();
|
|
9723
|
+
const coreRoles = allRoles.filter((r) => r.category === "core");
|
|
9724
|
+
for (const role of coreRoles) {
|
|
9725
|
+
summoned.push({ role, reason: "\u6838\u5FC3\u89D2\u8272(\u59CB\u7EC8\u53EC\u5524)", confidence: 1 });
|
|
9726
|
+
reasoning.push(`\u2705 ${role.name} \u2014 \u6838\u5FC3\u89D2\u8272`);
|
|
9727
|
+
}
|
|
9728
|
+
const nonCore = allRoles.filter((r) => r.category !== "core");
|
|
9729
|
+
const candidates = [];
|
|
9730
|
+
for (const role of nonCore) {
|
|
9731
|
+
const result = matchesTriggers(role.triggers, ctx);
|
|
9732
|
+
if (result.matches) {
|
|
9733
|
+
candidates.push({
|
|
9734
|
+
role,
|
|
9735
|
+
reason: result.reason,
|
|
9736
|
+
confidence: result.confidence
|
|
9737
|
+
});
|
|
9738
|
+
}
|
|
9739
|
+
}
|
|
9740
|
+
candidates.sort((a, b) => {
|
|
9741
|
+
if (a.role.priority !== b.role.priority) return a.role.priority - b.role.priority;
|
|
9742
|
+
return b.confidence - a.confidence;
|
|
9743
|
+
});
|
|
9744
|
+
const selected = candidates.slice(0, maxRoles);
|
|
9745
|
+
for (const s of selected) {
|
|
9746
|
+
summoned.push(s);
|
|
9747
|
+
reasoning.push(`\u{1F40A} ${s.role.name} \u2014 ${s.reason} (\u7F6E\u4FE1\u5EA6: ${(s.confidence * 100).toFixed(0)}%)`);
|
|
9748
|
+
}
|
|
9749
|
+
const skipped = candidates.slice(maxRoles);
|
|
9750
|
+
for (const s of skipped) {
|
|
9751
|
+
reasoning.push(`\u23ED\uFE0F ${s.role.name} \u2014 \u5339\u914D\u4F46\u8D85\u51FA\u9650\u5236 (\u7F6E\u4FE1\u5EA6: ${(s.confidence * 100).toFixed(0)}%)`);
|
|
9752
|
+
}
|
|
9753
|
+
return { roles: summoned, reasoning, context: ctx };
|
|
9754
|
+
}
|
|
9211
9755
|
export {
|
|
9212
9756
|
NetworkMonitor,
|
|
9757
|
+
RoleRegistry,
|
|
9213
9758
|
SYSTEM_PROMPTS,
|
|
9214
9759
|
TokenTracker,
|
|
9215
9760
|
COMMANDS as VSCODE_COMMANDS,
|
|
@@ -9227,6 +9772,7 @@ export {
|
|
|
9227
9772
|
buildFailureSummary,
|
|
9228
9773
|
buildGraph,
|
|
9229
9774
|
buildKnowledgeGraph,
|
|
9775
|
+
buildMatchContext,
|
|
9230
9776
|
buildModuleTree,
|
|
9231
9777
|
buildPath,
|
|
9232
9778
|
buildStatusTree,
|
|
@@ -9296,6 +9842,7 @@ export {
|
|
|
9296
9842
|
getGraphStats,
|
|
9297
9843
|
getModulePreset,
|
|
9298
9844
|
getNeighbors,
|
|
9845
|
+
getRoleRegistry,
|
|
9299
9846
|
inferDependencies,
|
|
9300
9847
|
inferRelatedTables,
|
|
9301
9848
|
listCiPlatforms,
|
|
@@ -9313,6 +9860,7 @@ export {
|
|
|
9313
9860
|
parseModuleModels,
|
|
9314
9861
|
parsePlaywrightReport,
|
|
9315
9862
|
parseValidatorRules,
|
|
9863
|
+
planSummon,
|
|
9316
9864
|
printOrchestrationSummary,
|
|
9317
9865
|
queryNodes,
|
|
9318
9866
|
recoverJSON,
|