kynjal-cli 4.0.0 → 4.0.1
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/src/appliance/gguf-engine.d.ts +91 -0
- package/dist/src/appliance/gguf-engine.d.ts.map +1 -0
- package/dist/src/appliance/gguf-engine.js +286 -525
- package/dist/src/appliance/gguf-engine.js.map +1 -1
- package/dist/src/appliance/ruvllm-bridge.d.ts +102 -0
- package/dist/src/appliance/ruvllm-bridge.d.ts.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +203 -403
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -1
- package/dist/src/appliance/rvfa-builder.d.ts +44 -0
- package/dist/src/appliance/rvfa-builder.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +154 -208
- package/dist/src/appliance/rvfa-builder.js.map +1 -1
- package/dist/src/appliance/rvfa-distribution.d.ts +97 -0
- package/dist/src/appliance/rvfa-distribution.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +260 -423
- package/dist/src/appliance/rvfa-distribution.js.map +1 -1
- package/dist/src/appliance/rvfa-format.d.ts +111 -0
- package/dist/src/appliance/rvfa-format.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-format.js +128 -200
- package/dist/src/appliance/rvfa-format.js.map +1 -1
- package/dist/src/appliance/rvfa-runner.d.ts +69 -0
- package/dist/src/appliance/rvfa-runner.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +168 -304
- package/dist/src/appliance/rvfa-runner.js.map +1 -1
- package/dist/src/appliance/rvfa-signing.d.ts +123 -0
- package/dist/src/appliance/rvfa-signing.d.ts.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +173 -295
- package/dist/src/appliance/rvfa-signing.js.map +1 -1
- package/dist/src/benchmarks/pretrain/index.d.ts +58 -0
- package/dist/src/benchmarks/pretrain/index.d.ts.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +331 -542
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.js +574 -697
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1218 -1548
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.js +158 -267
- package/dist/src/commands/appliance-advanced.js.map +1 -1
- package/dist/src/commands/appliance.js +318 -493
- package/dist/src/commands/appliance.js.map +1 -1
- package/dist/src/commands/benchmark.js +372 -523
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +274 -364
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.js +113 -157
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/completions.js +477 -118
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +237 -303
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.js +487 -596
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +194 -275
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.js +504 -686
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1293 -1543
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +449 -596
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +854 -938
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.js +3112 -3519
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.d.ts +115 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/index.js +126 -308
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.js +788 -940
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +383 -558
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.js +493 -605
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.js +833 -1026
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +282 -347
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.js +1289 -1563
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +497 -643
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +668 -841
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +392 -447
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +162 -256
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +150 -220
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +520 -665
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +505 -651
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +349 -401
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +224 -266
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +37 -75
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +336 -359
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +335 -322
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +375 -431
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +703 -117
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +364 -419
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.js +485 -608
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.js +504 -626
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.js +267 -364
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.js +380 -486
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +408 -488
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.js +423 -538
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +322 -412
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +196 -291
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +386 -486
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.d.ts +15 -0
- package/dist/src/config-adapter.d.ts.map +1 -0
- package/dist/src/config-adapter.js +38 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.d.ts +77 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +309 -411
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +68 -0
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +1 -0
- package/dist/src/infrastructure/in-memory-repositories.js +246 -507
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.d.ts +25 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -0
- package/dist/src/init/claudemd-generator.js +368 -78
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.d.ts +41 -0
- package/dist/src/init/executor.d.ts.map +1 -0
- package/dist/src/init/executor.js +1307 -996
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts +60 -0
- package/dist/src/init/helpers-generator.d.ts.map +1 -0
- package/dist/src/init/helpers-generator.js +657 -12
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/index.d.ts +1 -1
- package/dist/src/init/index.d.ts.map +1 -1
- package/dist/src/init/index.js +1 -1
- package/dist/src/init/index.js.map +1 -1
- package/dist/src/init/mcp-generator.js +33 -37
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.js +76 -77
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.js +801 -3
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +76 -59
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.d.ts +92 -0
- package/dist/src/mcp-client.d.ts.map +1 -0
- package/dist/src/mcp-client.js +81 -125
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.d.ts +161 -0
- package/dist/src/mcp-server.d.ts.map +1 -0
- package/dist/src/mcp-server.js +470 -757
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +391 -492
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.js +332 -533
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -1
- package/dist/src/mcp-tools/analyze-tools.js +172 -236
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.d.ts +83 -0
- package/dist/src/mcp-tools/auto-install.d.ts.map +1 -0
- package/dist/src/mcp-tools/auto-install.js +80 -142
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +252 -375
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +473 -565
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +197 -272
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +500 -572
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +286 -364
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +582 -693
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +260 -311
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +573 -640
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2215 -2648
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +350 -505
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +315 -412
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +420 -480
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +204 -278
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.js +163 -279
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -1
- package/dist/src/mcp-tools/security-tools.js +297 -429
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +185 -234
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +207 -260
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +276 -325
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +270 -336
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +148 -196
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +186 -333
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/types.d.ts +31 -0
- package/dist/src/mcp-tools/types.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +133 -280
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +405 -450
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.d.ts +295 -0
- package/dist/src/memory/ewc-consolidation.d.ts.map +1 -0
- package/dist/src/memory/ewc-consolidation.js +190 -303
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.d.ts +338 -0
- package/dist/src/memory/intelligence.d.ts.map +1 -0
- package/dist/src/memory/intelligence.js +569 -794
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.d.ts +407 -0
- package/dist/src/memory/memory-bridge.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge.js +1170 -1640
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-initializer.d.ts +412 -0
- package/dist/src/memory/memory-initializer.d.ts.map +1 -0
- package/dist/src/memory/memory-initializer.js +1836 -1851
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.d.ts +227 -0
- package/dist/src/memory/sona-optimizer.d.ts.map +1 -0
- package/dist/src/memory/sona-optimizer.js +199 -329
- package/dist/src/memory/sona-optimizer.js.map +1 -1
- package/dist/src/output.d.ts +2 -2
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +242 -272
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.d.ts +51 -0
- package/dist/src/parser.d.ts.map +1 -0
- package/dist/src/parser.js +140 -187
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.d.ts +133 -0
- package/dist/src/plugins/manager.d.ts.map +1 -0
- package/dist/src/plugins/manager.js +285 -521
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.d.ts +88 -0
- package/dist/src/plugins/store/discovery.d.ts.map +1 -0
- package/dist/src/plugins/store/discovery.js +271 -358
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.d.ts +76 -0
- package/dist/src/plugins/store/index.d.ts.map +1 -0
- package/dist/src/plugins/store/index.js +48 -105
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.d.ts +46 -0
- package/dist/src/plugins/store/search.d.ts.map +1 -0
- package/dist/src/plugins/store/search.js +69 -107
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/store/types.d.ts +274 -0
- package/dist/src/plugins/store/types.d.ts.map +1 -0
- package/dist/src/plugins/tests/demo-plugin-store.js +113 -160
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +172 -223
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +190 -228
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.d.ts +101 -0
- package/dist/src/production/circuit-breaker.d.ts.map +1 -0
- package/dist/src/production/circuit-breaker.js +62 -126
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.d.ts +92 -0
- package/dist/src/production/error-handler.d.ts.map +1 -0
- package/dist/src/production/error-handler.js +86 -156
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.d.ts +161 -0
- package/dist/src/production/monitoring.d.ts.map +1 -0
- package/dist/src/production/monitoring.js +139 -220
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.d.ts +80 -0
- package/dist/src/production/rate-limiter.d.ts.map +1 -0
- package/dist/src/production/rate-limiter.js +74 -93
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.d.ts +48 -0
- package/dist/src/production/retry.d.ts.map +1 -0
- package/dist/src/production/retry.js +75 -167
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.d.ts +44 -0
- package/dist/src/prompt.d.ts.map +1 -0
- package/dist/src/prompt.js +436 -560
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.d.ts +60 -0
- package/dist/src/runtime/headless.d.ts.map +1 -0
- package/dist/src/runtime/headless.js +197 -286
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.d.ts +182 -0
- package/dist/src/ruvector/agent-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/agent-wasm.js +156 -351
- package/dist/src/ruvector/agent-wasm.js.map +1 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +67 -0
- package/dist/src/ruvector/ast-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +145 -232
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.d.ts +160 -0
- package/dist/src/ruvector/coverage-router.d.ts.map +1 -0
- package/dist/src/ruvector/coverage-router.js +287 -419
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +56 -101
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.d.ts +175 -0
- package/dist/src/ruvector/diff-classifier.d.ts.map +1 -0
- package/dist/src/ruvector/diff-classifier.js +324 -451
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +146 -0
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +1 -0
- package/dist/src/ruvector/enhanced-model-router.js +260 -336
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.d.ts +195 -0
- package/dist/src/ruvector/flash-attention.d.ts.map +1 -0
- package/dist/src/ruvector/flash-attention.js +223 -254
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +187 -0
- package/dist/src/ruvector/graph-analyzer.d.ts.map +1 -0
- package/dist/src/ruvector/graph-analyzer.js +486 -680
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.d.ts +40 -0
- package/dist/src/ruvector/index.d.ts.map +1 -0
- package/dist/src/ruvector/index.js +36 -106
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.d.ts +218 -0
- package/dist/src/ruvector/lora-adapter.d.ts.map +1 -0
- package/dist/src/ruvector/lora-adapter.js +155 -248
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.d.ts +220 -0
- package/dist/src/ruvector/model-router.d.ts.map +1 -0
- package/dist/src/ruvector/model-router.js +175 -248
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.d.ts +206 -0
- package/dist/src/ruvector/moe-router.d.ts.map +1 -0
- package/dist/src/ruvector/moe-router.js +228 -286
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.d.ts +211 -0
- package/dist/src/ruvector/q-learning-router.d.ts.map +1 -0
- package/dist/src/ruvector/q-learning-router.js +257 -338
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.d.ts +179 -0
- package/dist/src/ruvector/ruvllm-wasm.d.ts.map +1 -0
- package/dist/src/ruvector/ruvllm-wasm.js +270 -434
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -1
- package/dist/src/ruvector/semantic-router.d.ts +77 -0
- package/dist/src/ruvector/semantic-router.d.ts.map +1 -0
- package/dist/src/ruvector/semantic-router.js +60 -67
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.d.ts +69 -0
- package/dist/src/ruvector/vector-db.d.ts.map +1 -0
- package/dist/src/ruvector/vector-db.js +119 -205
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.d.ts +50 -0
- package/dist/src/services/agentic-flow-bridge.d.ts.map +1 -0
- package/dist/src/services/agentic-flow-bridge.js +32 -105
- package/dist/src/services/agentic-flow-bridge.js.map +1 -1
- package/dist/src/services/claim-service.d.ts +204 -0
- package/dist/src/services/claim-service.d.ts.map +1 -0
- package/dist/src/services/claim-service.js +615 -940
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.d.ts +197 -0
- package/dist/src/services/container-worker-pool.d.ts.map +1 -0
- package/dist/src/services/container-worker-pool.js +398 -666
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.d.ts +304 -0
- package/dist/src/services/headless-worker-executor.d.ts.map +1 -0
- package/dist/src/services/headless-worker-executor.js +441 -467
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +4 -4
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +4 -4
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/registry-api.d.ts +58 -0
- package/dist/src/services/registry-api.d.ts.map +1 -0
- package/dist/src/services/registry-api.js +92 -200
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.d.ts +222 -0
- package/dist/src/services/ruvector-training.d.ts.map +1 -0
- package/dist/src/services/ruvector-training.js +257 -337
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.d.ts +228 -0
- package/dist/src/services/worker-daemon.d.ts.map +1 -0
- package/dist/src/services/worker-daemon.js +591 -849
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.d.ts +194 -0
- package/dist/src/services/worker-queue.d.ts.map +1 -0
- package/dist/src/services/worker-queue.js +331 -548
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.d.ts +53 -0
- package/dist/src/suggest.d.ts.map +1 -0
- package/dist/src/suggest.js +45 -55
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +29 -37
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.js +128 -155
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.d.ts +25 -0
- package/dist/src/transfer/export.d.ts.map +1 -0
- package/dist/src/transfer/export.js +84 -142
- package/dist/src/transfer/export.js.map +1 -1
- package/dist/src/transfer/index.d.ts +1 -1
- package/dist/src/transfer/index.d.ts.map +1 -1
- package/dist/src/transfer/index.js +0 -2
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.d.ts +109 -0
- package/dist/src/transfer/ipfs/client.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/client.js +187 -337
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.d.ts +95 -0
- package/dist/src/transfer/ipfs/upload.d.ts.map +1 -0
- package/dist/src/transfer/ipfs/upload.js +288 -434
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.d.ts +72 -0
- package/dist/src/transfer/models/seraphine.d.ts.map +1 -0
- package/dist/src/transfer/models/seraphine.js +55 -55
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.d.ts +49 -0
- package/dist/src/transfer/serialization/cfp.d.ts.map +1 -0
- package/dist/src/transfer/serialization/cfp.js +30 -31
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.d.ts +82 -0
- package/dist/src/transfer/storage/gcs.d.ts.map +1 -0
- package/dist/src/transfer/storage/gcs.js +165 -232
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.d.ts +84 -0
- package/dist/src/transfer/store/discovery.d.ts.map +1 -0
- package/dist/src/transfer/store/discovery.js +239 -349
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.d.ts +70 -0
- package/dist/src/transfer/store/download.d.ts.map +1 -0
- package/dist/src/transfer/store/download.js +243 -365
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.d.ts +84 -0
- package/dist/src/transfer/store/index.d.ts.map +1 -0
- package/dist/src/transfer/store/index.js +63 -130
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.d.ts +76 -0
- package/dist/src/transfer/store/publish.d.ts.map +1 -0
- package/dist/src/transfer/store/publish.js +184 -258
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +50 -72
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.d.ts +54 -0
- package/dist/src/transfer/store/search.d.ts.map +1 -0
- package/dist/src/transfer/store/search.js +64 -96
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +174 -231
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +95 -130
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +194 -239
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/transfer/types.d.ts +245 -0
- package/dist/src/transfer/types.d.ts.map +1 -0
- package/dist/src/types.d.ts +198 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +26 -55
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.d.ts +34 -0
- package/dist/src/update/checker.d.ts.map +1 -0
- package/dist/src/update/checker.js +106 -183
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.d.ts +32 -0
- package/dist/src/update/executor.d.ts.map +1 -0
- package/dist/src/update/executor.js +135 -198
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.d.ts +33 -0
- package/dist/src/update/index.d.ts.map +1 -0
- package/dist/src/update/index.js +38 -85
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.d.ts +20 -0
- package/dist/src/update/rate-limiter.d.ts.map +1 -0
- package/dist/src/update/rate-limiter.js +19 -31
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.d.ts +17 -0
- package/dist/src/update/validator.d.ts.map +1 -0
- package/dist/src/update/validator.js +38 -64
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,253 +1,174 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Diff Classifier for Change Analysis
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
__assign = Object.assign || function(t) {
|
|
6
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
7
|
-
s = arguments[i];
|
|
8
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
9
|
-
t[p] = s[p];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
return __assign.apply(this, arguments);
|
|
14
|
-
};
|
|
15
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
-
function step(op) {
|
|
29
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (_) try {
|
|
31
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
-
switch (op[0]) {
|
|
34
|
-
case 0: case 1: t = op; break;
|
|
35
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
-
default:
|
|
39
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
-
if (t[2]) _.ops.pop();
|
|
44
|
-
_.trys.pop(); continue;
|
|
45
|
-
}
|
|
46
|
-
op = body.call(thisArg, _);
|
|
47
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
52
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
53
|
-
if (ar || !(i in from)) {
|
|
54
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
55
|
-
ar[i] = from[i];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
59
|
-
};
|
|
60
|
-
var DEFAULT_CONFIG = {
|
|
4
|
+
const DEFAULT_CONFIG = {
|
|
61
5
|
maxDiffSize: 10000,
|
|
62
6
|
classifyByImpact: true,
|
|
63
7
|
detectRefactoring: true,
|
|
64
|
-
minConfidence: 0.5
|
|
8
|
+
minConfidence: 0.5,
|
|
65
9
|
};
|
|
66
|
-
|
|
10
|
+
const CLASSIFICATION_PATTERNS = {
|
|
67
11
|
feature: [/^feat/, /add.*feature/, /implement/, /new.*functionality/i],
|
|
68
12
|
bugfix: [/^fix/, /bug/, /patch/, /resolve.*issue/i, /hotfix/i],
|
|
69
13
|
refactor: [/^refactor/, /restructure/, /reorganize/, /cleanup/i, /rename/i],
|
|
70
14
|
docs: [/^docs?/, /documentation/, /readme/i, /comment/i, /\.md$/i],
|
|
71
15
|
test: [/^test/, /spec/, /\.test\.[jt]sx?$/, /\.spec\.[jt]sx?$/, /__tests__/],
|
|
72
16
|
config: [/^config/, /\.config\./, /package\.json/, /tsconfig/, /\.env/],
|
|
73
|
-
style: [/^style/, /format/, /lint/, /prettier/, /eslint/]
|
|
17
|
+
style: [/^style/, /format/, /lint/, /prettier/, /eslint/],
|
|
74
18
|
};
|
|
75
|
-
|
|
19
|
+
const IMPACT_KEYWORDS = {
|
|
76
20
|
security: 3, auth: 3, payment: 3, database: 2, api: 2, core: 2,
|
|
77
|
-
util: 1, helper: 1, test: 0, mock: 0, fixture: 0
|
|
21
|
+
util: 1, helper: 1, test: 0, mock: 0, fixture: 0,
|
|
78
22
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.config =
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.useNative = false;
|
|
106
|
-
return [3 /*break*/, 3];
|
|
107
|
-
case 3: return [2 /*return*/];
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
DiffClassifier.prototype.parseDiff = function (diffContent) {
|
|
113
|
-
var files = [];
|
|
114
|
-
var fileBlocks = diffContent.split(/^diff --git/m).filter(Boolean);
|
|
115
|
-
for (var _i = 0, fileBlocks_1 = fileBlocks; _i < fileBlocks_1.length; _i++) {
|
|
116
|
-
var block = fileBlocks_1[_i];
|
|
117
|
-
var pathMatch = block.match(/a\/(.+?)\s+b\/(.+)/);
|
|
23
|
+
export class DiffClassifier {
|
|
24
|
+
config;
|
|
25
|
+
ruvectorEngine = null;
|
|
26
|
+
useNative = false;
|
|
27
|
+
classificationCache = new Map();
|
|
28
|
+
constructor(config = {}) {
|
|
29
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
30
|
+
}
|
|
31
|
+
async initialize() {
|
|
32
|
+
try {
|
|
33
|
+
// @ruvector/diff is optional - gracefully fallback if not installed
|
|
34
|
+
const ruvector = await import('@ruvector/diff').catch(() => null);
|
|
35
|
+
if (ruvector) {
|
|
36
|
+
this.ruvectorEngine = ruvector.createDiffClassifier?.(this.config);
|
|
37
|
+
this.useNative = !!this.ruvectorEngine;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
this.useNative = false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
parseDiff(diffContent) {
|
|
45
|
+
const files = [];
|
|
46
|
+
const fileBlocks = diffContent.split(/^diff --git/m).filter(Boolean);
|
|
47
|
+
for (const block of fileBlocks) {
|
|
48
|
+
const pathMatch = block.match(/a\/(.+?)\s+b\/(.+)/);
|
|
118
49
|
if (!pathMatch)
|
|
119
50
|
continue;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
files.push({ path
|
|
51
|
+
const path = pathMatch[2];
|
|
52
|
+
const hunks = this.parseHunks(block);
|
|
53
|
+
const additions = hunks.reduce((sum, h) => sum + h.changes.filter(c => c.type === 'add').length, 0);
|
|
54
|
+
const deletions = hunks.reduce((sum, h) => sum + h.changes.filter(c => c.type === 'remove').length, 0);
|
|
55
|
+
const classification = this.classifyFile(path, hunks);
|
|
56
|
+
files.push({ path, hunks, additions, deletions, classification });
|
|
126
57
|
}
|
|
127
58
|
return files;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
totalAdditions: files.reduce(
|
|
133
|
-
totalDeletions: files.reduce(
|
|
59
|
+
}
|
|
60
|
+
classify(files) {
|
|
61
|
+
const overall = this.computeOverallClassification(files);
|
|
62
|
+
const stats = {
|
|
63
|
+
totalAdditions: files.reduce((sum, f) => sum + f.additions, 0),
|
|
64
|
+
totalDeletions: files.reduce((sum, f) => sum + f.deletions, 0),
|
|
134
65
|
filesChanged: files.length,
|
|
135
|
-
avgConfidence: files.length > 0 ? files.reduce(
|
|
66
|
+
avgConfidence: files.length > 0 ? files.reduce((sum, f) => sum + f.classification.confidence, 0) / files.length : 0,
|
|
136
67
|
};
|
|
137
|
-
return { files
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
for (
|
|
142
|
-
|
|
143
|
-
for (var _c = 0, patterns_1 = patterns; _c < patterns_1.length; _c++) {
|
|
144
|
-
var pattern = patterns_1[_c];
|
|
68
|
+
return { files, overall, stats, timestamp: Date.now() };
|
|
69
|
+
}
|
|
70
|
+
classifyCommitMessage(message) {
|
|
71
|
+
const lowerMessage = message.toLowerCase();
|
|
72
|
+
for (const [type, patterns] of Object.entries(CLASSIFICATION_PATTERNS)) {
|
|
73
|
+
for (const pattern of patterns) {
|
|
145
74
|
if (pattern.test(lowerMessage))
|
|
146
75
|
return type;
|
|
147
76
|
}
|
|
148
77
|
}
|
|
149
78
|
return 'unknown';
|
|
150
|
-
}
|
|
151
|
-
|
|
79
|
+
}
|
|
80
|
+
getStats() {
|
|
152
81
|
return { useNative: this.useNative, cacheSize: this.classificationCache.size };
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
for (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
hunks.push({ oldStart: oldStart, oldLines: oldLines, newStart: newStart, newLines: newLines, content: content, changes: changes });
|
|
82
|
+
}
|
|
83
|
+
clearCache() { this.classificationCache.clear(); }
|
|
84
|
+
parseHunks(block) {
|
|
85
|
+
const hunks = [];
|
|
86
|
+
const hunkMatches = block.matchAll(/@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@([^\n]*)\n([\s\S]*?)(?=@@|$)/g);
|
|
87
|
+
for (const match of hunkMatches) {
|
|
88
|
+
const oldStart = parseInt(match[1], 10);
|
|
89
|
+
const oldLines = parseInt(match[2] || '1', 10);
|
|
90
|
+
const newStart = parseInt(match[3], 10);
|
|
91
|
+
const newLines = parseInt(match[4] || '1', 10);
|
|
92
|
+
const content = match[6] || '';
|
|
93
|
+
const changes = this.parseChanges(content, newStart);
|
|
94
|
+
hunks.push({ oldStart, oldLines, newStart, newLines, content, changes });
|
|
167
95
|
}
|
|
168
96
|
return hunks;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
for (
|
|
175
|
-
var line = lines_1[_i];
|
|
97
|
+
}
|
|
98
|
+
parseChanges(content, startLine) {
|
|
99
|
+
const changes = [];
|
|
100
|
+
const lines = content.split('\n');
|
|
101
|
+
let lineNumber = startLine;
|
|
102
|
+
for (const line of lines) {
|
|
176
103
|
if (line.startsWith('+')) {
|
|
177
|
-
changes.push({ type: 'add', lineNumber
|
|
104
|
+
changes.push({ type: 'add', lineNumber, content: line.substring(1) });
|
|
178
105
|
lineNumber++;
|
|
179
106
|
}
|
|
180
107
|
else if (line.startsWith('-')) {
|
|
181
108
|
changes.push({ type: 'remove', lineNumber: -1, content: line.substring(1) });
|
|
182
109
|
}
|
|
183
110
|
else if (line.startsWith(' ') || line === '') {
|
|
184
|
-
changes.push({ type: 'context', lineNumber
|
|
111
|
+
changes.push({ type: 'context', lineNumber, content: line.substring(1) || '' });
|
|
185
112
|
lineNumber++;
|
|
186
113
|
}
|
|
187
114
|
}
|
|
188
115
|
return changes;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
116
|
+
}
|
|
117
|
+
classifyFile(path, hunks) {
|
|
118
|
+
const cacheKey = this.getCacheKey(path, hunks);
|
|
119
|
+
const cached = this.classificationCache.get(cacheKey);
|
|
193
120
|
if (cached)
|
|
194
121
|
return cached;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
122
|
+
const primary = this.determinePrimaryClassification(path, hunks);
|
|
123
|
+
const secondary = this.determineSecondaryClassifications(path, hunks, primary);
|
|
124
|
+
const confidence = this.calculateConfidence(path, hunks, primary);
|
|
125
|
+
const impactLevel = this.determineImpactLevel(path, hunks);
|
|
126
|
+
const suggestedReviewers = this.suggestReviewers(path, primary, impactLevel);
|
|
127
|
+
const testingStrategy = this.determineTestingStrategy(path, primary, impactLevel);
|
|
128
|
+
const riskFactors = this.identifyRiskFactors(path, hunks, impactLevel);
|
|
129
|
+
const classification = { primary, secondary, confidence, impactLevel, suggestedReviewers, testingStrategy, riskFactors };
|
|
203
130
|
this.classificationCache.set(cacheKey, classification);
|
|
204
131
|
return classification;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
132
|
+
}
|
|
133
|
+
getCacheKey(path, hunks) {
|
|
134
|
+
const hunkSummary = hunks.map(h => h.oldStart + ':' + h.newStart).join(',');
|
|
208
135
|
return path + ':' + hunkSummary;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
for (
|
|
212
|
-
|
|
213
|
-
for (var _c = 0, patterns_2 = patterns; _c < patterns_2.length; _c++) {
|
|
214
|
-
var pattern = patterns_2[_c];
|
|
136
|
+
}
|
|
137
|
+
determinePrimaryClassification(path, hunks) {
|
|
138
|
+
for (const [type, patterns] of Object.entries(CLASSIFICATION_PATTERNS)) {
|
|
139
|
+
for (const pattern of patterns) {
|
|
215
140
|
if (pattern.test(path))
|
|
216
141
|
return type;
|
|
217
142
|
}
|
|
218
143
|
}
|
|
219
|
-
|
|
220
|
-
if (/function|class|interface|type\s+\w+/.test(allContent) && hunks.some(
|
|
144
|
+
const allContent = hunks.flatMap(h => h.changes.map(c => c.content)).join('\n').toLowerCase();
|
|
145
|
+
if (/function|class|interface|type\s+\w+/.test(allContent) && hunks.some(h => h.changes.filter(c => c.type === 'add').length > 10))
|
|
221
146
|
return 'feature';
|
|
222
147
|
if (/fix|bug|issue|error|exception/.test(allContent))
|
|
223
148
|
return 'bugfix';
|
|
224
149
|
if (this.config.detectRefactoring && this.isRefactoring(hunks))
|
|
225
150
|
return 'refactor';
|
|
226
151
|
return 'unknown';
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
for (
|
|
231
|
-
|
|
232
|
-
for (var _a = 0, _b = hunk.changes; _a < _b.length; _a++) {
|
|
233
|
-
var change = _b[_a];
|
|
152
|
+
}
|
|
153
|
+
isRefactoring(hunks) {
|
|
154
|
+
let totalAdds = 0, totalRemoves = 0;
|
|
155
|
+
for (const hunk of hunks) {
|
|
156
|
+
for (const change of hunk.changes) {
|
|
234
157
|
if (change.type === 'add')
|
|
235
158
|
totalAdds++;
|
|
236
159
|
else if (change.type === 'remove')
|
|
237
160
|
totalRemoves++;
|
|
238
161
|
}
|
|
239
162
|
}
|
|
240
|
-
|
|
163
|
+
const ratio = totalAdds > 0 ? totalRemoves / totalAdds : 0;
|
|
241
164
|
return ratio > 0.7 && ratio < 1.4 && totalAdds > 5;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
for (
|
|
246
|
-
var _b = _a[_i], type = _b[0], patterns = _b[1];
|
|
165
|
+
}
|
|
166
|
+
determineSecondaryClassifications(path, hunks, primary) {
|
|
167
|
+
const secondary = [];
|
|
168
|
+
for (const [type, patterns] of Object.entries(CLASSIFICATION_PATTERNS)) {
|
|
247
169
|
if (type === primary)
|
|
248
170
|
continue;
|
|
249
|
-
for (
|
|
250
|
-
var pattern = patterns_3[_c];
|
|
171
|
+
for (const pattern of patterns) {
|
|
251
172
|
if (pattern.test(path)) {
|
|
252
173
|
secondary.push(type);
|
|
253
174
|
break;
|
|
@@ -255,20 +176,18 @@ var DiffClassifier = /** @class */ (function () {
|
|
|
255
176
|
}
|
|
256
177
|
}
|
|
257
178
|
return secondary.slice(0, 3);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
for (
|
|
262
|
-
|
|
263
|
-
for (var _b = 0, patterns_4 = patterns; _b < patterns_4.length; _b++) {
|
|
264
|
-
var pattern = patterns_4[_b];
|
|
179
|
+
}
|
|
180
|
+
calculateConfidence(path, hunks, primary) {
|
|
181
|
+
let confidence = 0.5;
|
|
182
|
+
for (const patterns of Object.values(CLASSIFICATION_PATTERNS)) {
|
|
183
|
+
for (const pattern of patterns) {
|
|
265
184
|
if (pattern.test(path)) {
|
|
266
185
|
confidence += 0.2;
|
|
267
186
|
break;
|
|
268
187
|
}
|
|
269
188
|
}
|
|
270
189
|
}
|
|
271
|
-
|
|
190
|
+
const totalChanges = hunks.reduce((sum, h) => sum + h.changes.length, 0);
|
|
272
191
|
if (totalChanges > 10)
|
|
273
192
|
confidence += 0.1;
|
|
274
193
|
if (totalChanges > 50)
|
|
@@ -276,16 +195,15 @@ var DiffClassifier = /** @class */ (function () {
|
|
|
276
195
|
if (primary !== 'unknown')
|
|
277
196
|
confidence += 0.1;
|
|
278
197
|
return Math.min(1, confidence);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
for (
|
|
284
|
-
var _b = _a[_i], keyword = _b[0], weight = _b[1];
|
|
198
|
+
}
|
|
199
|
+
determineImpactLevel(path, hunks) {
|
|
200
|
+
let score = 0;
|
|
201
|
+
const lowerPath = path.toLowerCase();
|
|
202
|
+
for (const [keyword, weight] of Object.entries(IMPACT_KEYWORDS)) {
|
|
285
203
|
if (lowerPath.includes(keyword))
|
|
286
204
|
score = Math.max(score, weight);
|
|
287
205
|
}
|
|
288
|
-
|
|
206
|
+
const totalChanges = hunks.reduce((sum, h) => sum + h.changes.filter(c => c.type !== 'context').length, 0);
|
|
289
207
|
if (totalChanges > 100)
|
|
290
208
|
score = Math.max(score, 2);
|
|
291
209
|
if (totalChanges > 300)
|
|
@@ -297,21 +215,21 @@ var DiffClassifier = /** @class */ (function () {
|
|
|
297
215
|
if (score >= 1)
|
|
298
216
|
return 'medium';
|
|
299
217
|
return 'low';
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
reviewers.push
|
|
218
|
+
}
|
|
219
|
+
suggestReviewers(path, primary, impact) {
|
|
220
|
+
const reviewers = [];
|
|
221
|
+
const typeReviewers = { feature: ['tech-lead', 'product-owner'], bugfix: ['qa-engineer', 'developer'], refactor: ['senior-developer', 'architect'], docs: ['tech-writer', 'developer'], test: ['qa-engineer', 'developer'], config: ['devops', 'tech-lead'], style: ['developer'], unknown: ['developer'] };
|
|
222
|
+
reviewers.push(...(typeReviewers[primary] || typeReviewers.unknown));
|
|
305
223
|
if (impact === 'critical' || impact === 'high')
|
|
306
224
|
reviewers.push('security-reviewer');
|
|
307
225
|
if (/security|auth/.test(path))
|
|
308
226
|
reviewers.push('security-team');
|
|
309
227
|
if (/database|migration/.test(path))
|
|
310
228
|
reviewers.push('dba');
|
|
311
|
-
return
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
229
|
+
return [...new Set(reviewers)].slice(0, 4);
|
|
230
|
+
}
|
|
231
|
+
determineTestingStrategy(path, primary, impact) {
|
|
232
|
+
const strategies = [];
|
|
315
233
|
if (primary !== 'test')
|
|
316
234
|
strategies.push('unit-tests');
|
|
317
235
|
if (primary === 'feature')
|
|
@@ -325,10 +243,10 @@ var DiffClassifier = /** @class */ (function () {
|
|
|
325
243
|
if (/security|auth|crypto/.test(path))
|
|
326
244
|
strategies.push('security-audit');
|
|
327
245
|
return strategies.slice(0, 5);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
246
|
+
}
|
|
247
|
+
identifyRiskFactors(path, hunks, impact) {
|
|
248
|
+
const risks = [];
|
|
249
|
+
const totalChanges = hunks.reduce((sum, h) => sum + h.changes.length, 0);
|
|
332
250
|
if (totalChanges > 200)
|
|
333
251
|
risks.push('Large change set - increased review time needed');
|
|
334
252
|
if (impact === 'critical')
|
|
@@ -341,59 +259,49 @@ var DiffClassifier = /** @class */ (function () {
|
|
|
341
259
|
risks.push('Database changes - ensure backup strategy');
|
|
342
260
|
if (/config|env/.test(path))
|
|
343
261
|
risks.push('Configuration changes - verify all environments');
|
|
344
|
-
|
|
262
|
+
const allContent = hunks.flatMap(h => h.changes.map(c => c.content)).join('\n');
|
|
345
263
|
if (/TODO|FIXME|HACK/.test(allContent))
|
|
346
264
|
risks.push('Contains TODO/FIXME comments');
|
|
347
265
|
if (/password|secret|key|token/i.test(allContent))
|
|
348
266
|
risks.push('Potential secrets in code');
|
|
349
267
|
return risks.slice(0, 5);
|
|
350
|
-
}
|
|
351
|
-
|
|
268
|
+
}
|
|
269
|
+
computeOverallClassification(files) {
|
|
352
270
|
if (files.length === 0)
|
|
353
271
|
return { primary: 'unknown', secondary: [], confidence: 0, impactLevel: 'low', suggestedReviewers: [], testingStrategy: [], riskFactors: [] };
|
|
354
|
-
|
|
355
|
-
for (
|
|
356
|
-
|
|
357
|
-
var p = file.classification.primary;
|
|
272
|
+
const primaryCounts = {};
|
|
273
|
+
for (const file of files) {
|
|
274
|
+
const p = file.classification.primary;
|
|
358
275
|
primaryCounts[p] = (primaryCounts[p] || 0) + 1;
|
|
359
276
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
for (
|
|
363
|
-
var _c = _b[_a], type = _c[0], count = _c[1];
|
|
277
|
+
let primary = 'unknown';
|
|
278
|
+
let maxCount = 0;
|
|
279
|
+
for (const [type, count] of Object.entries(primaryCounts)) {
|
|
364
280
|
if (count > maxCount) {
|
|
365
281
|
maxCount = count;
|
|
366
282
|
primary = type;
|
|
367
283
|
}
|
|
368
284
|
}
|
|
369
|
-
|
|
370
|
-
for (
|
|
371
|
-
|
|
372
|
-
for (var _e = 0, _f = file.classification.secondary; _e < _f.length; _e++) {
|
|
373
|
-
var s = _f[_e];
|
|
285
|
+
const secondaryCounts = {};
|
|
286
|
+
for (const file of files) {
|
|
287
|
+
for (const s of file.classification.secondary) {
|
|
374
288
|
secondaryCounts[s] = (secondaryCounts[s] || 0) + 1;
|
|
375
289
|
}
|
|
376
290
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
var impactOrder = ['low', 'medium', 'high', 'critical'];
|
|
383
|
-
var impactLevel = 'low';
|
|
384
|
-
for (var _g = 0, files_3 = files; _g < files_3.length; _g++) {
|
|
385
|
-
var file = files_3[_g];
|
|
291
|
+
const secondary = Object.entries(secondaryCounts).sort((a, b) => b[1] - a[1]).slice(0, 3).map(([type]) => type);
|
|
292
|
+
const confidence = files.reduce((sum, f) => sum + f.classification.confidence, 0) / files.length;
|
|
293
|
+
const impactOrder = ['low', 'medium', 'high', 'critical'];
|
|
294
|
+
let impactLevel = 'low';
|
|
295
|
+
for (const file of files) {
|
|
386
296
|
if (impactOrder.indexOf(file.classification.impactLevel) > impactOrder.indexOf(impactLevel))
|
|
387
297
|
impactLevel = file.classification.impactLevel;
|
|
388
298
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
return { primary
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
}());
|
|
396
|
-
export { DiffClassifier };
|
|
299
|
+
const reviewers = [...new Set(files.flatMap(f => f.classification.suggestedReviewers))].slice(0, 5);
|
|
300
|
+
const testingStrategy = [...new Set(files.flatMap(f => f.classification.testingStrategy))].slice(0, 5);
|
|
301
|
+
const riskFactors = [...new Set(files.flatMap(f => f.classification.riskFactors))].slice(0, 5);
|
|
302
|
+
return { primary, secondary, confidence, impactLevel, suggestedReviewers: reviewers, testingStrategy, riskFactors };
|
|
303
|
+
}
|
|
304
|
+
}
|
|
397
305
|
export function createDiffClassifier(config) {
|
|
398
306
|
return new DiffClassifier(config);
|
|
399
307
|
}
|
|
@@ -401,8 +309,8 @@ export function createDiffClassifier(config) {
|
|
|
401
309
|
// Optimized Git Diff Functions
|
|
402
310
|
// ============================================================================
|
|
403
311
|
// Cache for diff results (TTL-based)
|
|
404
|
-
|
|
405
|
-
|
|
312
|
+
const diffCache = new Map();
|
|
313
|
+
const CACHE_TTL_MS = 5000; // 5 seconds - short TTL since diffs change frequently
|
|
406
314
|
/**
|
|
407
315
|
* Validate git ref to prevent command injection
|
|
408
316
|
* Only allows safe characters: alphanumeric, -, _, /, ., ~, ^
|
|
@@ -410,73 +318,70 @@ var CACHE_TTL_MS = 5000; // 5 seconds - short TTL since diffs change frequently
|
|
|
410
318
|
function validateGitRef(ref) {
|
|
411
319
|
// Block shell metacharacters and dangerous patterns
|
|
412
320
|
if (!/^[a-zA-Z0-9_\-./~^@]+$/.test(ref)) {
|
|
413
|
-
throw new Error(
|
|
321
|
+
throw new Error(`Invalid git ref: contains unsafe characters`);
|
|
414
322
|
}
|
|
415
323
|
// Block multiple dots (path traversal)
|
|
416
324
|
if (ref.includes('..') && !ref.match(/^[a-zA-Z0-9_\-]+\.\.\.?[a-zA-Z0-9_\-]+$/)) {
|
|
417
325
|
if (!/^\w+\.\.[.\w]+$/.test(ref)) {
|
|
418
|
-
throw new Error(
|
|
326
|
+
throw new Error(`Invalid git ref: suspicious pattern`);
|
|
419
327
|
}
|
|
420
328
|
}
|
|
421
329
|
// Max length check
|
|
422
330
|
if (ref.length > 256) {
|
|
423
|
-
throw new Error(
|
|
331
|
+
throw new Error(`Invalid git ref: too long`);
|
|
424
332
|
}
|
|
425
333
|
}
|
|
426
334
|
/**
|
|
427
335
|
* Get git diff statistics using SINGLE combined command (optimized)
|
|
428
336
|
* Replaces two separate git commands with one
|
|
429
337
|
*/
|
|
430
|
-
export function getGitDiffNumstat(ref) {
|
|
431
|
-
if (ref === void 0) { ref = 'HEAD'; }
|
|
338
|
+
export function getGitDiffNumstat(ref = 'HEAD') {
|
|
432
339
|
// SECURITY: Validate git ref to prevent command injection
|
|
433
340
|
validateGitRef(ref);
|
|
434
341
|
// Check cache first
|
|
435
|
-
|
|
436
|
-
|
|
342
|
+
const cacheKey = `numstat:${ref}`;
|
|
343
|
+
const cached = diffCache.get(cacheKey);
|
|
437
344
|
if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
|
|
438
345
|
return cached.files;
|
|
439
346
|
}
|
|
440
|
-
|
|
347
|
+
const { execFileSync } = require('child_process');
|
|
441
348
|
try {
|
|
442
349
|
// SECURITY: Use execFileSync with args array instead of shell string
|
|
443
350
|
// This prevents command injection via the ref parameter
|
|
444
|
-
|
|
351
|
+
const numstatOutput = execFileSync('git', [
|
|
445
352
|
'diff', '--numstat', '--diff-filter=ACDMRTUXB', ref
|
|
446
353
|
], { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
|
|
447
|
-
|
|
354
|
+
const statusOutput = execFileSync('git', [
|
|
448
355
|
'diff', '--name-status', ref
|
|
449
356
|
], { encoding: 'utf-8', maxBuffer: 10 * 1024 * 1024 });
|
|
450
|
-
|
|
451
|
-
|
|
357
|
+
const output = numstatOutput + '---STATUS---' + statusOutput;
|
|
358
|
+
const [numstatPart, statusPart] = output.split('---STATUS---');
|
|
452
359
|
// Parse status (usually smaller, parse first)
|
|
453
|
-
|
|
360
|
+
const statusMap = new Map();
|
|
454
361
|
if (statusPart) {
|
|
455
|
-
for (
|
|
456
|
-
var line = _b[_i];
|
|
362
|
+
for (const line of statusPart.trim().split('\n')) {
|
|
457
363
|
if (!line)
|
|
458
364
|
continue;
|
|
459
|
-
|
|
460
|
-
|
|
365
|
+
const [status, ...pathParts] = line.split('\t');
|
|
366
|
+
const path = pathParts[pathParts.length - 1] || pathParts[0];
|
|
461
367
|
if (path)
|
|
462
368
|
statusMap.set(path, status.charAt(0));
|
|
463
369
|
}
|
|
464
370
|
}
|
|
465
371
|
// Parse numstat
|
|
466
|
-
|
|
372
|
+
const files = [];
|
|
467
373
|
if (numstatPart) {
|
|
468
|
-
for (
|
|
469
|
-
var line = _e[_d];
|
|
374
|
+
for (const line of numstatPart.trim().split('\n')) {
|
|
470
375
|
if (!line)
|
|
471
376
|
continue;
|
|
472
|
-
|
|
377
|
+
const [addStr, delStr, path] = line.split('\t');
|
|
473
378
|
if (!path)
|
|
474
379
|
continue;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
380
|
+
const additions = addStr === '-' ? 0 : parseInt(addStr, 10) || 0;
|
|
381
|
+
const deletions = delStr === '-' ? 0 : parseInt(delStr, 10) || 0;
|
|
382
|
+
const binary = addStr === '-' && delStr === '-';
|
|
383
|
+
const statusChar = statusMap.get(path) || 'M';
|
|
384
|
+
let status = 'modified';
|
|
480
385
|
switch (statusChar) {
|
|
481
386
|
case 'A':
|
|
482
387
|
status = 'added';
|
|
@@ -489,102 +394,87 @@ export function getGitDiffNumstat(ref) {
|
|
|
489
394
|
break;
|
|
490
395
|
default: status = 'modified';
|
|
491
396
|
}
|
|
492
|
-
files.push({ path
|
|
397
|
+
files.push({ path, status, additions, deletions, hunks: 1, binary });
|
|
493
398
|
}
|
|
494
399
|
}
|
|
495
400
|
// Cache the result
|
|
496
|
-
diffCache.set(cacheKey, { files
|
|
401
|
+
diffCache.set(cacheKey, { files, timestamp: Date.now() });
|
|
497
402
|
return files;
|
|
498
403
|
}
|
|
499
|
-
catch
|
|
404
|
+
catch {
|
|
500
405
|
return [];
|
|
501
406
|
}
|
|
502
407
|
}
|
|
503
408
|
/**
|
|
504
409
|
* Async version of getGitDiffNumstat for non-blocking operation
|
|
505
410
|
*/
|
|
506
|
-
export function getGitDiffNumstatAsync(ref) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
case 'A':
|
|
566
|
-
status = 'added';
|
|
567
|
-
break;
|
|
568
|
-
case 'D':
|
|
569
|
-
status = 'deleted';
|
|
570
|
-
break;
|
|
571
|
-
case 'R':
|
|
572
|
-
status = 'renamed';
|
|
573
|
-
break;
|
|
574
|
-
default: status = 'modified';
|
|
575
|
-
}
|
|
576
|
-
files.push({ path: path, status: status, additions: additions, deletions: deletions, hunks: 1, binary: binary });
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
diffCache.set(cacheKey, { files: files, timestamp: Date.now() });
|
|
580
|
-
return [2 /*return*/, files];
|
|
581
|
-
case 4:
|
|
582
|
-
_g = _h.sent();
|
|
583
|
-
return [2 /*return*/, []];
|
|
584
|
-
case 5: return [2 /*return*/];
|
|
411
|
+
export async function getGitDiffNumstatAsync(ref = 'HEAD') {
|
|
412
|
+
// SECURITY: Validate git ref to prevent command injection
|
|
413
|
+
validateGitRef(ref);
|
|
414
|
+
// Check cache first
|
|
415
|
+
const cacheKey = `numstat:${ref}`;
|
|
416
|
+
const cached = diffCache.get(cacheKey);
|
|
417
|
+
if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
|
|
418
|
+
return cached.files;
|
|
419
|
+
}
|
|
420
|
+
const { execFile } = require('child_process');
|
|
421
|
+
const { promisify } = require('util');
|
|
422
|
+
const execFileAsync = promisify(execFile);
|
|
423
|
+
try {
|
|
424
|
+
// SECURITY: Use execFile with args array instead of shell string
|
|
425
|
+
const { stdout: numstatOutput } = await execFileAsync('git', [
|
|
426
|
+
'diff', '--numstat', '--diff-filter=ACDMRTUXB', ref
|
|
427
|
+
], { maxBuffer: 10 * 1024 * 1024 });
|
|
428
|
+
const { stdout: statusOutput } = await execFileAsync('git', [
|
|
429
|
+
'diff', '--name-status', ref
|
|
430
|
+
], { maxBuffer: 10 * 1024 * 1024 });
|
|
431
|
+
const stdout = numstatOutput + '---STATUS---' + statusOutput;
|
|
432
|
+
const [numstatPart, statusPart] = stdout.split('---STATUS---');
|
|
433
|
+
const statusMap = new Map();
|
|
434
|
+
if (statusPart) {
|
|
435
|
+
for (const line of statusPart.trim().split('\n')) {
|
|
436
|
+
if (!line)
|
|
437
|
+
continue;
|
|
438
|
+
const [status, ...pathParts] = line.split('\t');
|
|
439
|
+
const path = pathParts[pathParts.length - 1] || pathParts[0];
|
|
440
|
+
if (path)
|
|
441
|
+
statusMap.set(path, status.charAt(0));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
const files = [];
|
|
445
|
+
if (numstatPart) {
|
|
446
|
+
for (const line of numstatPart.trim().split('\n')) {
|
|
447
|
+
if (!line)
|
|
448
|
+
continue;
|
|
449
|
+
const [addStr, delStr, path] = line.split('\t');
|
|
450
|
+
if (!path)
|
|
451
|
+
continue;
|
|
452
|
+
const additions = addStr === '-' ? 0 : parseInt(addStr, 10) || 0;
|
|
453
|
+
const deletions = delStr === '-' ? 0 : parseInt(delStr, 10) || 0;
|
|
454
|
+
const binary = addStr === '-' && delStr === '-';
|
|
455
|
+
const statusChar = statusMap.get(path) || 'M';
|
|
456
|
+
let status = 'modified';
|
|
457
|
+
switch (statusChar) {
|
|
458
|
+
case 'A':
|
|
459
|
+
status = 'added';
|
|
460
|
+
break;
|
|
461
|
+
case 'D':
|
|
462
|
+
status = 'deleted';
|
|
463
|
+
break;
|
|
464
|
+
case 'R':
|
|
465
|
+
status = 'renamed';
|
|
466
|
+
break;
|
|
467
|
+
default: status = 'modified';
|
|
468
|
+
}
|
|
469
|
+
files.push({ path, status, additions, deletions, hunks: 1, binary });
|
|
585
470
|
}
|
|
586
|
-
}
|
|
587
|
-
|
|
471
|
+
}
|
|
472
|
+
diffCache.set(cacheKey, { files, timestamp: Date.now() });
|
|
473
|
+
return files;
|
|
474
|
+
}
|
|
475
|
+
catch {
|
|
476
|
+
return [];
|
|
477
|
+
}
|
|
588
478
|
}
|
|
589
479
|
/**
|
|
590
480
|
* Clear the diff cache (call when git state changes)
|
|
@@ -596,10 +486,10 @@ export function clearDiffCache() {
|
|
|
596
486
|
* Assess risk for a single file
|
|
597
487
|
*/
|
|
598
488
|
export function assessFileRisk(file) {
|
|
599
|
-
|
|
600
|
-
|
|
489
|
+
const reasons = [];
|
|
490
|
+
let score = 0;
|
|
601
491
|
// Size-based risk
|
|
602
|
-
|
|
492
|
+
const totalChanges = file.additions + file.deletions;
|
|
603
493
|
if (totalChanges > 300) {
|
|
604
494
|
score += 30;
|
|
605
495
|
reasons.push('Large change size (>300 lines)');
|
|
@@ -609,7 +499,7 @@ export function assessFileRisk(file) {
|
|
|
609
499
|
reasons.push('Medium change size (>100 lines)');
|
|
610
500
|
}
|
|
611
501
|
// Path-based risk
|
|
612
|
-
|
|
502
|
+
const lowerPath = file.path.toLowerCase();
|
|
613
503
|
if (/security|auth|crypto|password/.test(lowerPath)) {
|
|
614
504
|
score += 40;
|
|
615
505
|
reasons.push('Security-sensitive file');
|
|
@@ -640,40 +530,39 @@ export function assessFileRisk(file) {
|
|
|
640
530
|
score += 5;
|
|
641
531
|
reasons.push('Binary file');
|
|
642
532
|
}
|
|
643
|
-
|
|
533
|
+
let risk = 'low';
|
|
644
534
|
if (score >= 60)
|
|
645
535
|
risk = 'critical';
|
|
646
536
|
else if (score >= 40)
|
|
647
537
|
risk = 'high';
|
|
648
538
|
else if (score >= 20)
|
|
649
539
|
risk = 'medium';
|
|
650
|
-
return { file: file.path, risk
|
|
540
|
+
return { file: file.path, risk, score: Math.min(100, score), reasons };
|
|
651
541
|
}
|
|
652
542
|
/**
|
|
653
543
|
* Assess overall risk from files and file risks
|
|
654
544
|
*/
|
|
655
545
|
export function assessOverallRisk(files, fileRisks) {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
for (
|
|
659
|
-
var fr = fileRisks_1[_i];
|
|
546
|
+
const breakdown = { low: 0, medium: 0, high: 0, critical: 0 };
|
|
547
|
+
let totalScore = 0;
|
|
548
|
+
for (const fr of fileRisks) {
|
|
660
549
|
breakdown[fr.risk]++;
|
|
661
550
|
totalScore += fr.score;
|
|
662
551
|
}
|
|
663
|
-
|
|
552
|
+
const avgScore = fileRisks.length > 0 ? totalScore / fileRisks.length : 0;
|
|
664
553
|
// Weight more heavily towards high/critical files
|
|
665
|
-
|
|
666
|
-
|
|
554
|
+
const weightedScore = avgScore + (breakdown.critical * 15) + (breakdown.high * 10);
|
|
555
|
+
let overall = 'low';
|
|
667
556
|
if (weightedScore >= 60 || breakdown.critical > 0)
|
|
668
557
|
overall = 'critical';
|
|
669
558
|
else if (weightedScore >= 40 || breakdown.high > 1)
|
|
670
559
|
overall = 'high';
|
|
671
560
|
else if (weightedScore >= 20 || breakdown.medium > 2)
|
|
672
561
|
overall = 'medium';
|
|
673
|
-
return { overall
|
|
562
|
+
return { overall, score: Math.min(100, Math.round(weightedScore)), breakdown };
|
|
674
563
|
}
|
|
675
564
|
// Singleton classifier instance for reuse
|
|
676
|
-
|
|
565
|
+
let classifierInstance = null;
|
|
677
566
|
function getClassifier() {
|
|
678
567
|
if (!classifierInstance) {
|
|
679
568
|
classifierInstance = new DiffClassifier();
|
|
@@ -684,24 +573,23 @@ function getClassifier() {
|
|
|
684
573
|
* Classify a diff based on files (uses singleton classifier)
|
|
685
574
|
*/
|
|
686
575
|
export function classifyDiff(files) {
|
|
687
|
-
|
|
688
|
-
|
|
576
|
+
const classifier = getClassifier();
|
|
577
|
+
const fileDiffs = files.map(f => ({
|
|
689
578
|
path: f.path,
|
|
690
579
|
hunks: [],
|
|
691
580
|
additions: f.additions,
|
|
692
581
|
deletions: f.deletions,
|
|
693
|
-
classification: classifier['classifyFile'](f.path, [])
|
|
694
|
-
})
|
|
582
|
+
classification: classifier['classifyFile'](f.path, []),
|
|
583
|
+
}));
|
|
695
584
|
return classifier['computeOverallClassification'](fileDiffs);
|
|
696
585
|
}
|
|
697
586
|
/**
|
|
698
587
|
* Suggest reviewers based on files and risks
|
|
699
588
|
*/
|
|
700
589
|
export function suggestReviewers(files, fileRisks) {
|
|
701
|
-
|
|
702
|
-
for (
|
|
703
|
-
|
|
704
|
-
var lowerPath = file.path.toLowerCase();
|
|
590
|
+
const reviewers = new Set();
|
|
591
|
+
for (const file of files) {
|
|
592
|
+
const lowerPath = file.path.toLowerCase();
|
|
705
593
|
if (/security|auth|crypto/.test(lowerPath))
|
|
706
594
|
reviewers.add('security-team');
|
|
707
595
|
if (/database|migration/.test(lowerPath))
|
|
@@ -718,7 +606,7 @@ export function suggestReviewers(files, fileRisks) {
|
|
|
718
606
|
reviewers.add('backend-lead');
|
|
719
607
|
}
|
|
720
608
|
// Add based on risk
|
|
721
|
-
|
|
609
|
+
const hasHighRisk = fileRisks.some(fr => fr.risk === 'high' || fr.risk === 'critical');
|
|
722
610
|
if (hasHighRisk) {
|
|
723
611
|
reviewers.add('tech-lead');
|
|
724
612
|
reviewers.add('senior-developer');
|
|
@@ -730,88 +618,73 @@ export function suggestReviewers(files, fileRisks) {
|
|
|
730
618
|
return Array.from(reviewers).slice(0, 5);
|
|
731
619
|
}
|
|
732
620
|
// Analysis result cache
|
|
733
|
-
|
|
734
|
-
|
|
621
|
+
const analysisCache = new Map();
|
|
622
|
+
const ANALYSIS_CACHE_TTL_MS = 3000; // 3 seconds
|
|
735
623
|
/**
|
|
736
624
|
* Analyze a diff with full analysis (optimized with caching)
|
|
737
625
|
*/
|
|
738
|
-
export function analyzeDiff(options) {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
ref: ref,
|
|
772
|
-
timestamp: Date.now(),
|
|
773
|
-
files: files,
|
|
774
|
-
risk: risk,
|
|
775
|
-
classification: classification,
|
|
776
|
-
summary: files.length + " files changed (+" + totalAdditions + "/-" + totalDeletions + "), " + risk.overall + " risk",
|
|
777
|
-
fileRisks: fileRisks,
|
|
778
|
-
recommendedReviewers: recommendedReviewers
|
|
779
|
-
};
|
|
780
|
-
// Cache the result
|
|
781
|
-
analysisCache.set(ref, { result: result, timestamp: Date.now() });
|
|
782
|
-
return [2 /*return*/, result];
|
|
783
|
-
}
|
|
784
|
-
});
|
|
785
|
-
});
|
|
626
|
+
export async function analyzeDiff(options) {
|
|
627
|
+
const ref = options.ref || 'HEAD';
|
|
628
|
+
// Check analysis cache (unless skipCache is true)
|
|
629
|
+
if (!options.skipCache) {
|
|
630
|
+
const cached = analysisCache.get(ref);
|
|
631
|
+
if (cached && Date.now() - cached.timestamp < ANALYSIS_CACHE_TTL_MS) {
|
|
632
|
+
return cached.result;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
// Use async git diff for non-blocking operation
|
|
636
|
+
const files = await getGitDiffNumstatAsync(ref);
|
|
637
|
+
// Parallel file risk assessment for large diffs
|
|
638
|
+
const fileRisks = files.length > 20
|
|
639
|
+
? await Promise.all(files.map(f => Promise.resolve(assessFileRisk(f))))
|
|
640
|
+
: files.map(assessFileRisk);
|
|
641
|
+
const risk = assessOverallRisk(files, fileRisks);
|
|
642
|
+
const classification = classifyDiff(files);
|
|
643
|
+
const recommendedReviewers = suggestReviewers(files, fileRisks);
|
|
644
|
+
const totalAdditions = files.reduce((sum, f) => sum + f.additions, 0);
|
|
645
|
+
const totalDeletions = files.reduce((sum, f) => sum + f.deletions, 0);
|
|
646
|
+
const result = {
|
|
647
|
+
ref,
|
|
648
|
+
timestamp: Date.now(),
|
|
649
|
+
files,
|
|
650
|
+
risk,
|
|
651
|
+
classification,
|
|
652
|
+
summary: `${files.length} files changed (+${totalAdditions}/-${totalDeletions}), ${risk.overall} risk`,
|
|
653
|
+
fileRisks,
|
|
654
|
+
recommendedReviewers,
|
|
655
|
+
};
|
|
656
|
+
// Cache the result
|
|
657
|
+
analysisCache.set(ref, { result, timestamp: Date.now() });
|
|
658
|
+
return result;
|
|
786
659
|
}
|
|
787
660
|
/**
|
|
788
661
|
* Synchronous version of analyzeDiff for backward compatibility
|
|
789
662
|
*/
|
|
790
663
|
export function analyzeDiffSync(options) {
|
|
791
|
-
|
|
664
|
+
const ref = options.ref || 'HEAD';
|
|
792
665
|
// Check analysis cache
|
|
793
|
-
|
|
666
|
+
const cached = analysisCache.get(ref);
|
|
794
667
|
if (cached && Date.now() - cached.timestamp < ANALYSIS_CACHE_TTL_MS) {
|
|
795
668
|
return cached.result;
|
|
796
669
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
ref
|
|
670
|
+
const files = getGitDiffNumstat(ref);
|
|
671
|
+
const fileRisks = files.map(assessFileRisk);
|
|
672
|
+
const risk = assessOverallRisk(files, fileRisks);
|
|
673
|
+
const classification = classifyDiff(files);
|
|
674
|
+
const recommendedReviewers = suggestReviewers(files, fileRisks);
|
|
675
|
+
const totalAdditions = files.reduce((sum, f) => sum + f.additions, 0);
|
|
676
|
+
const totalDeletions = files.reduce((sum, f) => sum + f.deletions, 0);
|
|
677
|
+
const result = {
|
|
678
|
+
ref,
|
|
806
679
|
timestamp: Date.now(),
|
|
807
|
-
files
|
|
808
|
-
risk
|
|
809
|
-
classification
|
|
810
|
-
summary: files.length
|
|
811
|
-
fileRisks
|
|
812
|
-
recommendedReviewers
|
|
680
|
+
files,
|
|
681
|
+
risk,
|
|
682
|
+
classification,
|
|
683
|
+
summary: `${files.length} files changed (+${totalAdditions}/-${totalDeletions}), ${risk.overall} risk`,
|
|
684
|
+
fileRisks,
|
|
685
|
+
recommendedReviewers,
|
|
813
686
|
};
|
|
814
|
-
analysisCache.set(ref, { result
|
|
687
|
+
analysisCache.set(ref, { result, timestamp: Date.now() });
|
|
815
688
|
return result;
|
|
816
689
|
}
|
|
817
690
|
/**
|
|
@@ -820,6 +693,6 @@ export function analyzeDiffSync(options) {
|
|
|
820
693
|
export function clearAllDiffCaches() {
|
|
821
694
|
diffCache.clear();
|
|
822
695
|
analysisCache.clear();
|
|
823
|
-
classifierInstance
|
|
696
|
+
classifierInstance?.clearCache();
|
|
824
697
|
}
|
|
825
698
|
//# sourceMappingURL=diff-classifier.js.map
|