kynjal-cli 3.1.3 → 4.0.0
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/.claude/agents/core/coder.md +1 -1
- package/.claude/agents/core/planner.md +2 -2
- package/.claude/agents/core/researcher.md +1 -1
- package/.claude/agents/core/reviewer.md +1 -1
- package/.claude/agents/core/tester.md +1 -1
- package/.claude/agents/data/data-ml-model.md +4 -4
- package/.claude/agents/development/dev-backend-api.md +4 -4
- package/.claude/agents/documentation/docs-api-openapi.md +4 -4
- package/.claude/agents/github/code-review-swarm.md +2 -2
- package/.claude/agents/github/issue-tracker.md +2 -2
- package/.claude/agents/github/pr-manager.md +2 -2
- package/.claude/agents/github/release-manager.md +2 -2
- package/.claude/agents/github/workflow-automation.md +2 -2
- package/.claude/agents/sparc/architecture.md +3 -3
- package/.claude/agents/sparc/pseudocode.md +2 -2
- package/.claude/agents/sparc/refinement.md +3 -3
- package/.claude/agents/sparc/specification.md +2 -2
- package/.claude/agents/swarm/adaptive-coordinator.md +1 -1
- package/.claude/agents/swarm/hierarchical-coordinator.md +1 -1
- package/.claude/agents/swarm/mesh-coordinator.md +1 -1
- package/.claude/agents/templates/base-template-generator.md +25 -4
- package/.claude/agents/templates/sparc-coordinator.md +3 -3
- package/.claude/helpers/auto-commit.sh +1 -1
- package/.claude/helpers/auto-memory-hook.mjs +27 -9
- package/.claude/helpers/hook-handler.cjs +58 -18
- package/.claude/helpers/statusline.cjs +14 -33
- package/.claude/helpers/statusline.js +3 -3
- package/.claude/settings.json +9 -9
- package/.claude/skills/reasoningbank-intelligence/SKILL.md +2 -2
- package/.claude/skills/swarm-orchestration/SKILL.md +1 -1
- package/README.md +383 -170
- package/bin/cli.js +6 -6
- package/bin/mcp-server.js +1 -1
- package/bin/preinstall.cjs +2 -0
- package/dist/src/appliance/gguf-engine.js +664 -0
- package/dist/src/appliance/gguf-engine.js.map +1 -0
- package/dist/src/appliance/ruvllm-bridge.js +492 -0
- package/dist/src/appliance/ruvllm-bridge.js.map +1 -0
- package/dist/src/appliance/rvfa-builder.js +383 -0
- package/dist/src/appliance/rvfa-builder.js.map +1 -0
- package/dist/src/appliance/rvfa-distribution.js +533 -0
- package/dist/src/appliance/rvfa-distribution.js.map +1 -0
- package/dist/src/appliance/rvfa-format.js +465 -0
- package/dist/src/appliance/rvfa-format.js.map +1 -0
- package/dist/src/appliance/rvfa-runner.js +373 -0
- package/dist/src/appliance/rvfa-runner.js.map +1 -0
- package/dist/src/appliance/rvfa-signing.js +469 -0
- package/dist/src/appliance/rvfa-signing.js.map +1 -0
- package/dist/src/benchmarks/pretrain/index.js +542 -331
- package/dist/src/benchmarks/pretrain/index.js.map +1 -1
- package/dist/src/commands/agent.d.ts.map +1 -1
- package/dist/src/commands/agent.js +725 -502
- package/dist/src/commands/agent.js.map +1 -1
- package/dist/src/commands/analyze.js +1548 -1218
- package/dist/src/commands/analyze.js.map +1 -1
- package/dist/src/commands/appliance-advanced.d.ts +9 -0
- package/dist/src/commands/appliance-advanced.d.ts.map +1 -0
- package/dist/src/commands/appliance-advanced.js +324 -0
- package/dist/src/commands/appliance-advanced.js.map +1 -0
- package/dist/src/commands/appliance.d.ts +8 -0
- package/dist/src/commands/appliance.d.ts.map +1 -0
- package/dist/src/commands/appliance.js +581 -0
- package/dist/src/commands/appliance.js.map +1 -0
- package/dist/src/commands/benchmark.js +523 -372
- package/dist/src/commands/benchmark.js.map +1 -1
- package/dist/src/commands/claims.js +364 -274
- package/dist/src/commands/claims.js.map +1 -1
- package/dist/src/commands/cleanup.d.ts +13 -0
- package/dist/src/commands/cleanup.d.ts.map +1 -0
- package/dist/src/commands/cleanup.js +262 -0
- package/dist/src/commands/cleanup.js.map +1 -0
- package/dist/src/commands/completions.js +118 -477
- package/dist/src/commands/completions.js.map +1 -1
- package/dist/src/commands/config.js +303 -237
- package/dist/src/commands/config.js.map +1 -1
- package/dist/src/commands/daemon.d.ts.map +1 -1
- package/dist/src/commands/daemon.js +597 -425
- package/dist/src/commands/daemon.js.map +1 -1
- package/dist/src/commands/deployment.js +275 -194
- package/dist/src/commands/deployment.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +690 -460
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/embeddings.js +1543 -1293
- package/dist/src/commands/embeddings.js.map +1 -1
- package/dist/src/commands/guidance.js +596 -449
- package/dist/src/commands/guidance.js.map +1 -1
- package/dist/src/commands/hive-mind.js +938 -854
- package/dist/src/commands/hive-mind.js.map +1 -1
- package/dist/src/commands/hooks.d.ts.map +1 -1
- package/dist/src/commands/hooks.js +3677 -2570
- package/dist/src/commands/hooks.js.map +1 -1
- package/dist/src/commands/index.js +322 -122
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.d.ts +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +943 -787
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/issues.js +558 -383
- package/dist/src/commands/issues.js.map +1 -1
- package/dist/src/commands/mcp.d.ts.map +1 -1
- package/dist/src/commands/mcp.js +605 -475
- package/dist/src/commands/mcp.js.map +1 -1
- package/dist/src/commands/memory.d.ts.map +1 -1
- package/dist/src/commands/memory.js +1031 -814
- package/dist/src/commands/memory.js.map +1 -1
- package/dist/src/commands/migrate.js +347 -282
- package/dist/src/commands/migrate.js.map +1 -1
- package/dist/src/commands/neural.d.ts.map +1 -1
- package/dist/src/commands/neural.js +1563 -1283
- package/dist/src/commands/neural.js.map +1 -1
- package/dist/src/commands/performance.js +643 -497
- package/dist/src/commands/performance.js.map +1 -1
- package/dist/src/commands/plugins.js +841 -668
- package/dist/src/commands/plugins.js.map +1 -1
- package/dist/src/commands/process.js +447 -392
- package/dist/src/commands/process.js.map +1 -1
- package/dist/src/commands/progress.js +256 -162
- package/dist/src/commands/progress.js.map +1 -1
- package/dist/src/commands/providers.js +220 -150
- package/dist/src/commands/providers.js.map +1 -1
- package/dist/src/commands/route.js +665 -520
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/commands/ruvector/backup.js +651 -505
- package/dist/src/commands/ruvector/backup.js.map +1 -1
- package/dist/src/commands/ruvector/benchmark.js +401 -349
- package/dist/src/commands/ruvector/benchmark.js.map +1 -1
- package/dist/src/commands/ruvector/import.js +267 -225
- package/dist/src/commands/ruvector/import.js.map +1 -1
- package/dist/src/commands/ruvector/index.js +75 -37
- package/dist/src/commands/ruvector/index.js.map +1 -1
- package/dist/src/commands/ruvector/init.js +359 -336
- package/dist/src/commands/ruvector/init.js.map +1 -1
- package/dist/src/commands/ruvector/migrate.js +322 -335
- package/dist/src/commands/ruvector/migrate.js.map +1 -1
- package/dist/src/commands/ruvector/optimize.js +431 -375
- package/dist/src/commands/ruvector/optimize.js.map +1 -1
- package/dist/src/commands/ruvector/setup.js +117 -703
- package/dist/src/commands/ruvector/setup.js.map +1 -1
- package/dist/src/commands/ruvector/status.js +419 -364
- package/dist/src/commands/ruvector/status.js.map +1 -1
- package/dist/src/commands/security.d.ts.map +1 -1
- package/dist/src/commands/security.js +610 -456
- package/dist/src/commands/security.js.map +1 -1
- package/dist/src/commands/session.d.ts +1 -1
- package/dist/src/commands/session.js +627 -505
- package/dist/src/commands/session.js.map +1 -1
- package/dist/src/commands/start.d.ts +1 -1
- package/dist/src/commands/start.js +368 -271
- package/dist/src/commands/start.js.map +1 -1
- package/dist/src/commands/status.d.ts +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +492 -379
- package/dist/src/commands/status.js.map +1 -1
- package/dist/src/commands/swarm.js +488 -408
- package/dist/src/commands/swarm.js.map +1 -1
- package/dist/src/commands/task.d.ts +1 -1
- package/dist/src/commands/task.js +539 -424
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/transfer-store.js +412 -322
- package/dist/src/commands/transfer-store.js.map +1 -1
- package/dist/src/commands/update.js +291 -196
- package/dist/src/commands/update.js.map +1 -1
- package/dist/src/commands/workflow.js +486 -386
- package/dist/src/commands/workflow.js.map +1 -1
- package/dist/src/config-adapter.js +40 -39
- package/dist/src/config-adapter.js.map +1 -1
- package/dist/src/index.js +416 -312
- package/dist/src/index.js.map +1 -1
- package/dist/src/infrastructure/in-memory-repositories.js +507 -246
- package/dist/src/infrastructure/in-memory-repositories.js.map +1 -1
- package/dist/src/init/claudemd-generator.js +78 -368
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/executor.js +1019 -1345
- package/dist/src/init/executor.js.map +1 -1
- package/dist/src/init/helpers-generator.js +60 -635
- 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.d.ts +0 -1
- package/dist/src/init/mcp-generator.d.ts.map +1 -1
- package/dist/src/init/mcp-generator.js +62 -42
- package/dist/src/init/mcp-generator.js.map +1 -1
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +167 -100
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/statusline-generator.d.ts +16 -8
- package/dist/src/init/statusline-generator.d.ts.map +1 -1
- package/dist/src/init/statusline-generator.js +20 -1300
- package/dist/src/init/statusline-generator.js.map +1 -1
- package/dist/src/init/types.d.ts +15 -5
- package/dist/src/init/types.d.ts.map +1 -1
- package/dist/src/init/types.js +66 -76
- package/dist/src/init/types.js.map +1 -1
- package/dist/src/mcp-client.js +130 -76
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-server.js +758 -445
- package/dist/src/mcp-server.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +492 -391
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/agentdb-tools.d.ts +30 -0
- package/dist/src/mcp-tools/agentdb-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/agentdb-tools.js +758 -0
- package/dist/src/mcp-tools/agentdb-tools.js.map +1 -0
- package/dist/src/mcp-tools/analyze-tools.js +236 -172
- package/dist/src/mcp-tools/analyze-tools.js.map +1 -1
- package/dist/src/mcp-tools/auto-install.js +142 -80
- package/dist/src/mcp-tools/auto-install.js.map +1 -1
- package/dist/src/mcp-tools/browser-tools.js +375 -252
- package/dist/src/mcp-tools/browser-tools.js.map +1 -1
- package/dist/src/mcp-tools/claims-tools.js +565 -473
- package/dist/src/mcp-tools/claims-tools.js.map +1 -1
- package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/config-tools.js +284 -190
- package/dist/src/mcp-tools/config-tools.js.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/coordination-tools.js +600 -349
- package/dist/src/mcp-tools/coordination-tools.js.map +1 -1
- package/dist/src/mcp-tools/daa-tools.js +367 -289
- package/dist/src/mcp-tools/daa-tools.js.map +1 -1
- package/dist/src/mcp-tools/embeddings-tools.js +693 -582
- package/dist/src/mcp-tools/embeddings-tools.js.map +1 -1
- package/dist/src/mcp-tools/github-tools.js +312 -261
- package/dist/src/mcp-tools/github-tools.js.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hive-mind-tools.js +718 -423
- package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2726 -1978
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +2 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +2 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +514 -329
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/mcp-tools/neural-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/neural-tools.js +428 -326
- package/dist/src/mcp-tools/neural-tools.js.map +1 -1
- package/dist/src/mcp-tools/performance-tools.js +480 -420
- package/dist/src/mcp-tools/performance-tools.js.map +1 -1
- package/dist/src/mcp-tools/progress-tools.js +278 -204
- package/dist/src/mcp-tools/progress-tools.js.map +1 -1
- package/dist/src/mcp-tools/ruvllm-tools.d.ts +9 -0
- package/dist/src/mcp-tools/ruvllm-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/ruvllm-tools.js +399 -0
- package/dist/src/mcp-tools/ruvllm-tools.js.map +1 -0
- package/dist/src/mcp-tools/security-tools.js +429 -297
- package/dist/src/mcp-tools/security-tools.js.map +1 -1
- package/dist/src/mcp-tools/session-tools.js +234 -185
- package/dist/src/mcp-tools/session-tools.js.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.d.ts +2 -1
- package/dist/src/mcp-tools/swarm-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/swarm-tools.js +303 -64
- package/dist/src/mcp-tools/swarm-tools.js.map +1 -1
- package/dist/src/mcp-tools/system-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/system-tools.js +352 -200
- package/dist/src/mcp-tools/system-tools.js.map +1 -1
- package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/task-tools.js +357 -189
- package/dist/src/mcp-tools/task-tools.js.map +1 -1
- package/dist/src/mcp-tools/terminal-tools.js +196 -148
- package/dist/src/mcp-tools/terminal-tools.js.map +1 -1
- package/dist/src/mcp-tools/transfer-tools.js +333 -186
- package/dist/src/mcp-tools/transfer-tools.js.map +1 -1
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts +9 -0
- package/dist/src/mcp-tools/wasm-agent-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js +377 -0
- package/dist/src/mcp-tools/wasm-agent-tools.js.map +1 -0
- package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/workflow-tools.js +471 -335
- package/dist/src/mcp-tools/workflow-tools.js.map +1 -1
- package/dist/src/memory/ewc-consolidation.js +345 -173
- package/dist/src/memory/ewc-consolidation.js.map +1 -1
- package/dist/src/memory/intelligence.js +841 -359
- package/dist/src/memory/intelligence.js.map +1 -1
- package/dist/src/memory/memory-bridge.js +1964 -0
- package/dist/src/memory/memory-bridge.js.map +1 -0
- package/dist/src/memory/memory-initializer.js +1895 -1602
- package/dist/src/memory/memory-initializer.js.map +1 -1
- package/dist/src/memory/sona-optimizer.js +329 -199
- 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 +273 -242
- package/dist/src/output.js.map +1 -1
- package/dist/src/parser.js +217 -124
- package/dist/src/parser.js.map +1 -1
- package/dist/src/plugins/manager.js +531 -278
- package/dist/src/plugins/manager.js.map +1 -1
- package/dist/src/plugins/store/discovery.js +362 -275
- package/dist/src/plugins/store/discovery.js.map +1 -1
- package/dist/src/plugins/store/index.js +105 -48
- package/dist/src/plugins/store/index.js.map +1 -1
- package/dist/src/plugins/store/search.js +107 -69
- package/dist/src/plugins/store/search.js.map +1 -1
- package/dist/src/plugins/tests/demo-plugin-store.js +160 -113
- package/dist/src/plugins/tests/demo-plugin-store.js.map +1 -1
- package/dist/src/plugins/tests/standalone-test.js +223 -172
- package/dist/src/plugins/tests/standalone-test.js.map +1 -1
- package/dist/src/plugins/tests/test-plugin-store.js +228 -190
- package/dist/src/plugins/tests/test-plugin-store.js.map +1 -1
- package/dist/src/production/circuit-breaker.js +126 -62
- package/dist/src/production/circuit-breaker.js.map +1 -1
- package/dist/src/production/error-handler.js +156 -86
- package/dist/src/production/error-handler.js.map +1 -1
- package/dist/src/production/monitoring.js +220 -139
- package/dist/src/production/monitoring.js.map +1 -1
- package/dist/src/production/rate-limiter.js +93 -74
- package/dist/src/production/rate-limiter.js.map +1 -1
- package/dist/src/production/retry.js +167 -75
- package/dist/src/production/retry.js.map +1 -1
- package/dist/src/prompt.js +560 -436
- package/dist/src/prompt.js.map +1 -1
- package/dist/src/runtime/headless.js +289 -200
- package/dist/src/runtime/headless.js.map +1 -1
- package/dist/src/ruvector/agent-wasm.js +511 -0
- package/dist/src/ruvector/agent-wasm.js.map +1 -0
- package/dist/src/ruvector/ast-analyzer.js +232 -145
- package/dist/src/ruvector/ast-analyzer.js.map +1 -1
- package/dist/src/ruvector/coverage-router.js +419 -287
- package/dist/src/ruvector/coverage-router.js.map +1 -1
- package/dist/src/ruvector/coverage-tools.js +101 -56
- package/dist/src/ruvector/coverage-tools.js.map +1 -1
- package/dist/src/ruvector/diff-classifier.js +451 -324
- package/dist/src/ruvector/diff-classifier.js.map +1 -1
- package/dist/src/ruvector/enhanced-model-router.js +337 -251
- package/dist/src/ruvector/enhanced-model-router.js.map +1 -1
- package/dist/src/ruvector/flash-attention.js +254 -223
- package/dist/src/ruvector/flash-attention.js.map +1 -1
- package/dist/src/ruvector/graph-analyzer.js +680 -486
- package/dist/src/ruvector/graph-analyzer.js.map +1 -1
- package/dist/src/ruvector/index.js +113 -27
- package/dist/src/ruvector/index.js.map +1 -1
- package/dist/src/ruvector/lora-adapter.js +248 -155
- package/dist/src/ruvector/lora-adapter.js.map +1 -1
- package/dist/src/ruvector/model-router.js +248 -175
- package/dist/src/ruvector/model-router.js.map +1 -1
- package/dist/src/ruvector/moe-router.js +286 -228
- package/dist/src/ruvector/moe-router.js.map +1 -1
- package/dist/src/ruvector/q-learning-router.js +338 -257
- package/dist/src/ruvector/q-learning-router.js.map +1 -1
- package/dist/src/ruvector/ruvllm-wasm.js +527 -0
- package/dist/src/ruvector/ruvllm-wasm.js.map +1 -0
- package/dist/src/ruvector/semantic-router.js +67 -60
- package/dist/src/ruvector/semantic-router.js.map +1 -1
- package/dist/src/ruvector/vector-db.js +205 -119
- package/dist/src/ruvector/vector-db.js.map +1 -1
- package/dist/src/services/agentic-flow-bridge.js +168 -0
- package/dist/src/services/agentic-flow-bridge.js.map +1 -0
- package/dist/src/services/claim-service.js +940 -615
- package/dist/src/services/claim-service.js.map +1 -1
- package/dist/src/services/container-worker-pool.js +669 -399
- package/dist/src/services/container-worker-pool.js.map +1 -1
- package/dist/src/services/headless-worker-executor.js +467 -441
- package/dist/src/services/headless-worker-executor.js.map +1 -1
- package/dist/src/services/index.d.ts +5 -5
- 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.js +201 -93
- package/dist/src/services/registry-api.js.map +1 -1
- package/dist/src/services/ruvector-training.js +414 -144
- package/dist/src/services/ruvector-training.js.map +1 -1
- package/dist/src/services/worker-daemon.js +928 -531
- package/dist/src/services/worker-daemon.js.map +1 -1
- package/dist/src/services/worker-queue.js +550 -331
- package/dist/src/services/worker-queue.js.map +1 -1
- package/dist/src/suggest.js +55 -45
- package/dist/src/suggest.js.map +1 -1
- package/dist/src/transfer/anonymization/index.js +37 -29
- package/dist/src/transfer/anonymization/index.js.map +1 -1
- package/dist/src/transfer/deploy-seraphine.d.ts +1 -1
- package/dist/src/transfer/deploy-seraphine.js +156 -129
- package/dist/src/transfer/deploy-seraphine.js.map +1 -1
- package/dist/src/transfer/export.js +142 -84
- 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 +2 -0
- package/dist/src/transfer/index.js.map +1 -1
- package/dist/src/transfer/ipfs/client.js +337 -179
- package/dist/src/transfer/ipfs/client.js.map +1 -1
- package/dist/src/transfer/ipfs/upload.js +434 -290
- package/dist/src/transfer/ipfs/upload.js.map +1 -1
- package/dist/src/transfer/models/seraphine.js +58 -58
- package/dist/src/transfer/models/seraphine.js.map +1 -1
- package/dist/src/transfer/serialization/cfp.js +37 -33
- package/dist/src/transfer/serialization/cfp.js.map +1 -1
- package/dist/src/transfer/storage/gcs.js +248 -139
- package/dist/src/transfer/storage/gcs.js.map +1 -1
- package/dist/src/transfer/store/discovery.js +353 -243
- package/dist/src/transfer/store/discovery.js.map +1 -1
- package/dist/src/transfer/store/download.js +365 -243
- package/dist/src/transfer/store/download.js.map +1 -1
- package/dist/src/transfer/store/index.js +130 -63
- package/dist/src/transfer/store/index.js.map +1 -1
- package/dist/src/transfer/store/publish.js +258 -184
- package/dist/src/transfer/store/publish.js.map +1 -1
- package/dist/src/transfer/store/registry.js +73 -51
- package/dist/src/transfer/store/registry.js.map +1 -1
- package/dist/src/transfer/store/search.js +96 -64
- package/dist/src/transfer/store/search.js.map +1 -1
- package/dist/src/transfer/store/tests/standalone-test.js +231 -174
- package/dist/src/transfer/store/tests/standalone-test.js.map +1 -1
- package/dist/src/transfer/test-seraphine.js +130 -95
- package/dist/src/transfer/test-seraphine.js.map +1 -1
- package/dist/src/transfer/tests/test-store.js +239 -194
- package/dist/src/transfer/tests/test-store.js.map +1 -1
- package/dist/src/types.js +56 -27
- package/dist/src/types.js.map +1 -1
- package/dist/src/update/checker.js +183 -106
- package/dist/src/update/checker.js.map +1 -1
- package/dist/src/update/executor.js +198 -135
- package/dist/src/update/executor.js.map +1 -1
- package/dist/src/update/index.js +85 -38
- package/dist/src/update/index.js.map +1 -1
- package/dist/src/update/rate-limiter.js +31 -19
- package/dist/src/update/rate-limiter.js.map +1 -1
- package/dist/src/update/validator.js +64 -38
- package/dist/src/update/validator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -10
- package/.claude/agents/custom/accessibility-auditor.yaml +0 -56
- package/.claude/agents/custom/design-architect.yaml +0 -48
- package/.claude/agents/custom/ui-developer.yaml +0 -46
- package/.claude/agents/custom/ux-researcher.yaml +0 -60
- package/dist/src/benchmarks/pretrain/index.d.ts +0 -58
- package/dist/src/benchmarks/pretrain/index.d.ts.map +0 -1
- package/dist/src/commands/index.d.ts +0 -108
- package/dist/src/commands/index.d.ts.map +0 -1
- package/dist/src/config-adapter.d.ts +0 -15
- package/dist/src/config-adapter.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -76
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/infrastructure/in-memory-repositories.d.ts +0 -68
- package/dist/src/infrastructure/in-memory-repositories.d.ts.map +0 -1
- package/dist/src/init/claudemd-generator.d.ts +0 -25
- package/dist/src/init/claudemd-generator.d.ts.map +0 -1
- package/dist/src/init/executor.d.ts +0 -41
- package/dist/src/init/executor.d.ts.map +0 -1
- package/dist/src/init/helpers-generator.d.ts +0 -60
- package/dist/src/init/helpers-generator.d.ts.map +0 -1
- package/dist/src/mcp-client.d.ts +0 -92
- package/dist/src/mcp-client.d.ts.map +0 -1
- package/dist/src/mcp-server.d.ts +0 -161
- package/dist/src/mcp-server.d.ts.map +0 -1
- package/dist/src/mcp-tools/auto-install.d.ts +0 -83
- package/dist/src/mcp-tools/auto-install.d.ts.map +0 -1
- package/dist/src/mcp-tools/types.d.ts +0 -31
- package/dist/src/mcp-tools/types.d.ts.map +0 -1
- package/dist/src/memory/ewc-consolidation.d.ts +0 -271
- package/dist/src/memory/ewc-consolidation.d.ts.map +0 -1
- package/dist/src/memory/intelligence.d.ts +0 -285
- package/dist/src/memory/intelligence.d.ts.map +0 -1
- package/dist/src/memory/memory-initializer.d.ts +0 -396
- package/dist/src/memory/memory-initializer.d.ts.map +0 -1
- package/dist/src/memory/sona-optimizer.d.ts +0 -227
- package/dist/src/memory/sona-optimizer.d.ts.map +0 -1
- package/dist/src/parser.d.ts +0 -41
- package/dist/src/parser.d.ts.map +0 -1
- package/dist/src/plugins/manager.d.ts +0 -133
- package/dist/src/plugins/manager.d.ts.map +0 -1
- package/dist/src/plugins/store/discovery.d.ts +0 -88
- package/dist/src/plugins/store/discovery.d.ts.map +0 -1
- package/dist/src/plugins/store/index.d.ts +0 -76
- package/dist/src/plugins/store/index.d.ts.map +0 -1
- package/dist/src/plugins/store/search.d.ts +0 -46
- package/dist/src/plugins/store/search.d.ts.map +0 -1
- package/dist/src/plugins/store/types.d.ts +0 -274
- package/dist/src/plugins/store/types.d.ts.map +0 -1
- package/dist/src/production/circuit-breaker.d.ts +0 -101
- package/dist/src/production/circuit-breaker.d.ts.map +0 -1
- package/dist/src/production/error-handler.d.ts +0 -92
- package/dist/src/production/error-handler.d.ts.map +0 -1
- package/dist/src/production/monitoring.d.ts +0 -161
- package/dist/src/production/monitoring.d.ts.map +0 -1
- package/dist/src/production/rate-limiter.d.ts +0 -80
- package/dist/src/production/rate-limiter.d.ts.map +0 -1
- package/dist/src/production/retry.d.ts +0 -48
- package/dist/src/production/retry.d.ts.map +0 -1
- package/dist/src/prompt.d.ts +0 -44
- package/dist/src/prompt.d.ts.map +0 -1
- package/dist/src/runtime/headless.d.ts +0 -60
- package/dist/src/runtime/headless.d.ts.map +0 -1
- package/dist/src/ruvector/ast-analyzer.d.ts +0 -67
- package/dist/src/ruvector/ast-analyzer.d.ts.map +0 -1
- package/dist/src/ruvector/coverage-router.d.ts +0 -160
- package/dist/src/ruvector/coverage-router.d.ts.map +0 -1
- package/dist/src/ruvector/diff-classifier.d.ts +0 -175
- package/dist/src/ruvector/diff-classifier.d.ts.map +0 -1
- package/dist/src/ruvector/enhanced-model-router.d.ts +0 -146
- package/dist/src/ruvector/enhanced-model-router.d.ts.map +0 -1
- package/dist/src/ruvector/flash-attention.d.ts +0 -195
- package/dist/src/ruvector/flash-attention.d.ts.map +0 -1
- package/dist/src/ruvector/graph-analyzer.d.ts +0 -187
- package/dist/src/ruvector/graph-analyzer.d.ts.map +0 -1
- package/dist/src/ruvector/index.d.ts +0 -34
- package/dist/src/ruvector/index.d.ts.map +0 -1
- package/dist/src/ruvector/lora-adapter.d.ts +0 -218
- package/dist/src/ruvector/lora-adapter.d.ts.map +0 -1
- package/dist/src/ruvector/model-router.d.ts +0 -220
- package/dist/src/ruvector/model-router.d.ts.map +0 -1
- package/dist/src/ruvector/moe-router.d.ts +0 -206
- package/dist/src/ruvector/moe-router.d.ts.map +0 -1
- package/dist/src/ruvector/q-learning-router.d.ts +0 -211
- package/dist/src/ruvector/q-learning-router.d.ts.map +0 -1
- package/dist/src/ruvector/semantic-router.d.ts +0 -77
- package/dist/src/ruvector/semantic-router.d.ts.map +0 -1
- package/dist/src/ruvector/vector-db.d.ts +0 -69
- package/dist/src/ruvector/vector-db.d.ts.map +0 -1
- package/dist/src/services/claim-service.d.ts +0 -204
- package/dist/src/services/claim-service.d.ts.map +0 -1
- package/dist/src/services/container-worker-pool.d.ts +0 -197
- package/dist/src/services/container-worker-pool.d.ts.map +0 -1
- package/dist/src/services/headless-worker-executor.d.ts +0 -304
- package/dist/src/services/headless-worker-executor.d.ts.map +0 -1
- package/dist/src/services/registry-api.d.ts +0 -58
- package/dist/src/services/registry-api.d.ts.map +0 -1
- package/dist/src/services/ruvector-training.d.ts +0 -213
- package/dist/src/services/ruvector-training.d.ts.map +0 -1
- package/dist/src/services/worker-daemon.d.ts +0 -203
- package/dist/src/services/worker-daemon.d.ts.map +0 -1
- package/dist/src/services/worker-queue.d.ts +0 -194
- package/dist/src/services/worker-queue.d.ts.map +0 -1
- package/dist/src/suggest.d.ts +0 -53
- package/dist/src/suggest.d.ts.map +0 -1
- package/dist/src/transfer/export.d.ts +0 -25
- package/dist/src/transfer/export.d.ts.map +0 -1
- package/dist/src/transfer/ipfs/client.d.ts +0 -109
- package/dist/src/transfer/ipfs/client.d.ts.map +0 -1
- package/dist/src/transfer/ipfs/upload.d.ts +0 -95
- package/dist/src/transfer/ipfs/upload.d.ts.map +0 -1
- package/dist/src/transfer/models/seraphine.d.ts +0 -72
- package/dist/src/transfer/models/seraphine.d.ts.map +0 -1
- package/dist/src/transfer/serialization/cfp.d.ts +0 -49
- package/dist/src/transfer/serialization/cfp.d.ts.map +0 -1
- package/dist/src/transfer/storage/gcs.d.ts +0 -82
- package/dist/src/transfer/storage/gcs.d.ts.map +0 -1
- package/dist/src/transfer/store/discovery.d.ts +0 -84
- package/dist/src/transfer/store/discovery.d.ts.map +0 -1
- package/dist/src/transfer/store/download.d.ts +0 -70
- package/dist/src/transfer/store/download.d.ts.map +0 -1
- package/dist/src/transfer/store/index.d.ts +0 -84
- package/dist/src/transfer/store/index.d.ts.map +0 -1
- package/dist/src/transfer/store/publish.d.ts +0 -76
- package/dist/src/transfer/store/publish.d.ts.map +0 -1
- package/dist/src/transfer/store/search.d.ts +0 -54
- package/dist/src/transfer/store/search.d.ts.map +0 -1
- package/dist/src/transfer/types.d.ts +0 -245
- package/dist/src/transfer/types.d.ts.map +0 -1
- package/dist/src/types.d.ts +0 -198
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/update/checker.d.ts +0 -34
- package/dist/src/update/checker.d.ts.map +0 -1
- package/dist/src/update/executor.d.ts +0 -32
- package/dist/src/update/executor.d.ts.map +0 -1
- package/dist/src/update/index.d.ts +0 -33
- package/dist/src/update/index.d.ts.map +0 -1
- package/dist/src/update/rate-limiter.d.ts +0 -20
- package/dist/src/update/rate-limiter.d.ts.map +0 -1
- package/dist/src/update/validator.d.ts +0 -17
- package/dist/src/update/validator.d.ts.map +0 -1
|
@@ -12,6 +12,68 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @see /v3/implementation/adrs/ADR-016-collaborative-issue-claims.md
|
|
14
14
|
*/
|
|
15
|
+
var __extends = (this && this.__extends) || (function () {
|
|
16
|
+
var extendStatics = function (d, b) {
|
|
17
|
+
extendStatics = Object.setPrototypeOf ||
|
|
18
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
19
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
20
|
+
return extendStatics(d, b);
|
|
21
|
+
};
|
|
22
|
+
return function (d, b) {
|
|
23
|
+
if (typeof b !== "function" && b !== null)
|
|
24
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
25
|
+
extendStatics(d, b);
|
|
26
|
+
function __() { this.constructor = d; }
|
|
27
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
28
|
+
};
|
|
29
|
+
})();
|
|
30
|
+
var __assign = (this && this.__assign) || function () {
|
|
31
|
+
__assign = Object.assign || function(t) {
|
|
32
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
33
|
+
s = arguments[i];
|
|
34
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
35
|
+
t[p] = s[p];
|
|
36
|
+
}
|
|
37
|
+
return t;
|
|
38
|
+
};
|
|
39
|
+
return __assign.apply(this, arguments);
|
|
40
|
+
};
|
|
41
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
42
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
43
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
44
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
45
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
46
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
47
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
51
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
52
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
53
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
54
|
+
function step(op) {
|
|
55
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
56
|
+
while (_) try {
|
|
57
|
+
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;
|
|
58
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
59
|
+
switch (op[0]) {
|
|
60
|
+
case 0: case 1: t = op; break;
|
|
61
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
62
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
63
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
64
|
+
default:
|
|
65
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
66
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
67
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
68
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
69
|
+
if (t[2]) _.ops.pop();
|
|
70
|
+
_.trys.pop(); continue;
|
|
71
|
+
}
|
|
72
|
+
op = body.call(thisArg, _);
|
|
73
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
74
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
75
|
+
}
|
|
76
|
+
};
|
|
15
77
|
import { EventEmitter } from 'events';
|
|
16
78
|
import * as fs from 'fs';
|
|
17
79
|
import * as path from 'path';
|
|
@@ -19,7 +81,7 @@ import { execFileSync } from 'child_process';
|
|
|
19
81
|
// ============================================================================
|
|
20
82
|
// Default Configuration
|
|
21
83
|
// ============================================================================
|
|
22
|
-
|
|
84
|
+
var DEFAULT_CONFIG = {
|
|
23
85
|
staleThresholdMinutes: 30,
|
|
24
86
|
blockedThresholdMinutes: 60,
|
|
25
87
|
overloadThreshold: 5,
|
|
@@ -30,435 +92,647 @@ const DEFAULT_CONFIG = {
|
|
|
30
92
|
allowCrossTypeSteal: [
|
|
31
93
|
['coder', 'debugger'],
|
|
32
94
|
['tester', 'reviewer'],
|
|
33
|
-
]
|
|
95
|
+
]
|
|
34
96
|
};
|
|
35
97
|
// ============================================================================
|
|
36
98
|
// Claim Service Implementation
|
|
37
99
|
// ============================================================================
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
100
|
+
var ClaimService = /** @class */ (function (_super) {
|
|
101
|
+
__extends(ClaimService, _super);
|
|
102
|
+
function ClaimService(projectRoot, config) {
|
|
103
|
+
var _this = _super.call(this) || this;
|
|
104
|
+
_this.claims = new Map();
|
|
105
|
+
_this.stealableInfo = new Map();
|
|
106
|
+
_this.eventLog = [];
|
|
107
|
+
_this.storagePath = path.join(projectRoot, '.claude-flow', 'claims');
|
|
108
|
+
_this.config = __assign(__assign({}, DEFAULT_CONFIG), config);
|
|
109
|
+
return _this;
|
|
48
110
|
}
|
|
49
111
|
// ==========================================================================
|
|
50
112
|
// Initialization
|
|
51
113
|
// ==========================================================================
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
claim.statusChangedAt = new Date(claim.statusChangedAt);
|
|
68
|
-
if (claim.expiresAt)
|
|
69
|
-
claim.expiresAt = new Date(claim.expiresAt);
|
|
70
|
-
this.claims.set(claim.issueId, claim);
|
|
114
|
+
ClaimService.prototype.initialize = function () {
|
|
115
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0:
|
|
119
|
+
// Ensure storage directory exists
|
|
120
|
+
if (!fs.existsSync(this.storagePath)) {
|
|
121
|
+
fs.mkdirSync(this.storagePath, { recursive: true });
|
|
122
|
+
}
|
|
123
|
+
// Load existing claims
|
|
124
|
+
return [4 /*yield*/, this.loadClaims()];
|
|
125
|
+
case 1:
|
|
126
|
+
// Load existing claims
|
|
127
|
+
_a.sent();
|
|
128
|
+
return [2 /*return*/];
|
|
71
129
|
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
ClaimService.prototype.loadClaims = function () {
|
|
134
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
135
|
+
var claimsFile, data, _i, _a, claim;
|
|
136
|
+
return __generator(this, function (_b) {
|
|
137
|
+
claimsFile = path.join(this.storagePath, 'claims.json');
|
|
138
|
+
if (fs.existsSync(claimsFile)) {
|
|
139
|
+
try {
|
|
140
|
+
data = JSON.parse(fs.readFileSync(claimsFile, 'utf-8'));
|
|
141
|
+
for (_i = 0, _a = data.claims || []; _i < _a.length; _i++) {
|
|
142
|
+
claim = _a[_i];
|
|
143
|
+
claim.claimedAt = new Date(claim.claimedAt);
|
|
144
|
+
claim.statusChangedAt = new Date(claim.statusChangedAt);
|
|
145
|
+
if (claim.expiresAt)
|
|
146
|
+
claim.expiresAt = new Date(claim.expiresAt);
|
|
147
|
+
this.claims.set(claim.issueId, claim);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (_c) {
|
|
151
|
+
// Start fresh if file is corrupted
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return [2 /*return*/];
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
ClaimService.prototype.saveClaims = function () {
|
|
159
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
160
|
+
var claimsFile, data;
|
|
161
|
+
return __generator(this, function (_a) {
|
|
162
|
+
claimsFile = path.join(this.storagePath, 'claims.json');
|
|
163
|
+
data = {
|
|
164
|
+
claims: Array.from(this.claims.values()),
|
|
165
|
+
savedAt: new Date().toISOString()
|
|
166
|
+
};
|
|
167
|
+
fs.writeFileSync(claimsFile, JSON.stringify(data, null, 2));
|
|
168
|
+
return [2 /*return*/];
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
};
|
|
86
172
|
// ==========================================================================
|
|
87
173
|
// Core Claiming
|
|
88
174
|
// ==========================================================================
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
175
|
+
ClaimService.prototype.claim = function (issueId, claimant) {
|
|
176
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
177
|
+
var existing, now, claim;
|
|
178
|
+
return __generator(this, function (_a) {
|
|
179
|
+
switch (_a.label) {
|
|
180
|
+
case 0:
|
|
181
|
+
existing = this.claims.get(issueId);
|
|
182
|
+
if (existing && existing.status !== 'stealable') {
|
|
183
|
+
return [2 /*return*/, {
|
|
184
|
+
success: false,
|
|
185
|
+
error: "Issue " + issueId + " is already claimed by " + this.formatClaimant(existing.claimant)
|
|
186
|
+
}];
|
|
187
|
+
}
|
|
188
|
+
now = new Date();
|
|
189
|
+
claim = {
|
|
190
|
+
issueId: issueId,
|
|
191
|
+
claimant: claimant,
|
|
192
|
+
claimedAt: now,
|
|
193
|
+
status: 'active',
|
|
194
|
+
statusChangedAt: now,
|
|
195
|
+
progress: 0
|
|
196
|
+
};
|
|
197
|
+
this.claims.set(issueId, claim);
|
|
198
|
+
return [4 /*yield*/, this.saveClaims()];
|
|
199
|
+
case 1:
|
|
200
|
+
_a.sent();
|
|
201
|
+
this.emitEvent({
|
|
202
|
+
type: 'issue:claimed',
|
|
203
|
+
timestamp: now,
|
|
204
|
+
issueId: issueId,
|
|
205
|
+
claimant: claimant,
|
|
206
|
+
previousClaimant: existing === null || existing === void 0 ? void 0 : existing.claimant
|
|
207
|
+
});
|
|
208
|
+
return [2 /*return*/, { success: true, claim: claim }];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
115
211
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
212
|
+
};
|
|
213
|
+
ClaimService.prototype.release = function (issueId, claimant) {
|
|
214
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
215
|
+
var claim;
|
|
216
|
+
return __generator(this, function (_a) {
|
|
217
|
+
switch (_a.label) {
|
|
218
|
+
case 0:
|
|
219
|
+
claim = this.claims.get(issueId);
|
|
220
|
+
if (!claim) {
|
|
221
|
+
throw new Error("Issue " + issueId + " is not claimed");
|
|
222
|
+
}
|
|
223
|
+
if (!this.isSameClaimant(claim.claimant, claimant)) {
|
|
224
|
+
throw new Error("Issue " + issueId + " is not claimed by " + this.formatClaimant(claimant));
|
|
225
|
+
}
|
|
226
|
+
this.claims["delete"](issueId);
|
|
227
|
+
this.stealableInfo["delete"](issueId);
|
|
228
|
+
return [4 /*yield*/, this.saveClaims()];
|
|
229
|
+
case 1:
|
|
230
|
+
_a.sent();
|
|
231
|
+
this.emitEvent({
|
|
232
|
+
type: 'issue:released',
|
|
233
|
+
timestamp: new Date(),
|
|
234
|
+
issueId: issueId,
|
|
235
|
+
claimant: claimant
|
|
236
|
+
});
|
|
237
|
+
return [2 /*return*/];
|
|
238
|
+
}
|
|
239
|
+
});
|
|
134
240
|
});
|
|
135
|
-
}
|
|
241
|
+
};
|
|
136
242
|
// ==========================================================================
|
|
137
243
|
// Handoffs
|
|
138
244
|
// ==========================================================================
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
245
|
+
ClaimService.prototype.requestHandoff = function (issueId, from, to, reason) {
|
|
246
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
247
|
+
var claim;
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
switch (_a.label) {
|
|
250
|
+
case 0:
|
|
251
|
+
claim = this.claims.get(issueId);
|
|
252
|
+
if (!claim) {
|
|
253
|
+
throw new Error("Issue " + issueId + " is not claimed");
|
|
254
|
+
}
|
|
255
|
+
if (!this.isSameClaimant(claim.claimant, from)) {
|
|
256
|
+
throw new Error("Issue " + issueId + " is not claimed by " + this.formatClaimant(from));
|
|
257
|
+
}
|
|
258
|
+
claim.status = 'handoff-pending';
|
|
259
|
+
claim.statusChangedAt = new Date();
|
|
260
|
+
claim.handoffTo = to;
|
|
261
|
+
claim.handoffReason = reason;
|
|
262
|
+
return [4 /*yield*/, this.saveClaims()];
|
|
263
|
+
case 1:
|
|
264
|
+
_a.sent();
|
|
265
|
+
this.emitEvent({
|
|
266
|
+
type: 'issue:handoff:requested',
|
|
267
|
+
timestamp: new Date(),
|
|
268
|
+
issueId: issueId,
|
|
269
|
+
claimant: from,
|
|
270
|
+
data: { to: to, reason: reason }
|
|
271
|
+
});
|
|
272
|
+
return [2 /*return*/];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
158
275
|
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
276
|
+
};
|
|
277
|
+
ClaimService.prototype.acceptHandoff = function (issueId, claimant) {
|
|
278
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
279
|
+
var claim, previousClaimant;
|
|
280
|
+
return __generator(this, function (_a) {
|
|
281
|
+
switch (_a.label) {
|
|
282
|
+
case 0:
|
|
283
|
+
claim = this.claims.get(issueId);
|
|
284
|
+
if (!claim || claim.status !== 'handoff-pending') {
|
|
285
|
+
throw new Error("No pending handoff for issue " + issueId);
|
|
286
|
+
}
|
|
287
|
+
if (!claim.handoffTo || !this.isSameClaimant(claim.handoffTo, claimant)) {
|
|
288
|
+
throw new Error("Handoff not addressed to " + this.formatClaimant(claimant));
|
|
289
|
+
}
|
|
290
|
+
previousClaimant = claim.claimant;
|
|
291
|
+
claim.claimant = claimant;
|
|
292
|
+
claim.status = 'active';
|
|
293
|
+
claim.statusChangedAt = new Date();
|
|
294
|
+
delete claim.handoffTo;
|
|
295
|
+
delete claim.handoffReason;
|
|
296
|
+
return [4 /*yield*/, this.saveClaims()];
|
|
297
|
+
case 1:
|
|
298
|
+
_a.sent();
|
|
299
|
+
this.emitEvent({
|
|
300
|
+
type: 'issue:handoff:accepted',
|
|
301
|
+
timestamp: new Date(),
|
|
302
|
+
issueId: issueId,
|
|
303
|
+
claimant: claimant,
|
|
304
|
+
previousClaimant: previousClaimant
|
|
305
|
+
});
|
|
306
|
+
return [2 /*return*/];
|
|
307
|
+
}
|
|
308
|
+
});
|
|
181
309
|
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
310
|
+
};
|
|
311
|
+
ClaimService.prototype.rejectHandoff = function (issueId, claimant, reason) {
|
|
312
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
313
|
+
var claim;
|
|
314
|
+
return __generator(this, function (_a) {
|
|
315
|
+
switch (_a.label) {
|
|
316
|
+
case 0:
|
|
317
|
+
claim = this.claims.get(issueId);
|
|
318
|
+
if (!claim || claim.status !== 'handoff-pending') {
|
|
319
|
+
throw new Error("No pending handoff for issue " + issueId);
|
|
320
|
+
}
|
|
321
|
+
if (!claim.handoffTo || !this.isSameClaimant(claim.handoffTo, claimant)) {
|
|
322
|
+
throw new Error("Handoff not addressed to " + this.formatClaimant(claimant));
|
|
323
|
+
}
|
|
324
|
+
claim.status = 'active';
|
|
325
|
+
claim.statusChangedAt = new Date();
|
|
326
|
+
delete claim.handoffTo;
|
|
327
|
+
delete claim.handoffReason;
|
|
328
|
+
return [4 /*yield*/, this.saveClaims()];
|
|
329
|
+
case 1:
|
|
330
|
+
_a.sent();
|
|
331
|
+
this.emitEvent({
|
|
332
|
+
type: 'issue:handoff:rejected',
|
|
333
|
+
timestamp: new Date(),
|
|
334
|
+
issueId: issueId,
|
|
335
|
+
claimant: claimant,
|
|
336
|
+
data: { reason: reason }
|
|
337
|
+
});
|
|
338
|
+
return [2 /*return*/];
|
|
339
|
+
}
|
|
340
|
+
});
|
|
202
341
|
});
|
|
203
|
-
}
|
|
342
|
+
};
|
|
204
343
|
// ==========================================================================
|
|
205
344
|
// Status Updates
|
|
206
345
|
// ==========================================================================
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
346
|
+
ClaimService.prototype.updateStatus = function (issueId, status, note) {
|
|
347
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
348
|
+
var claim, previousStatus;
|
|
349
|
+
return __generator(this, function (_a) {
|
|
350
|
+
switch (_a.label) {
|
|
351
|
+
case 0:
|
|
352
|
+
claim = this.claims.get(issueId);
|
|
353
|
+
if (!claim) {
|
|
354
|
+
throw new Error("Issue " + issueId + " is not claimed");
|
|
355
|
+
}
|
|
356
|
+
previousStatus = claim.status;
|
|
357
|
+
claim.status = status;
|
|
358
|
+
claim.statusChangedAt = new Date();
|
|
359
|
+
if (status === 'blocked' && note) {
|
|
360
|
+
claim.blockReason = note;
|
|
361
|
+
}
|
|
362
|
+
if (status === 'completed') {
|
|
363
|
+
claim.progress = 100;
|
|
364
|
+
}
|
|
365
|
+
return [4 /*yield*/, this.saveClaims()];
|
|
366
|
+
case 1:
|
|
367
|
+
_a.sent();
|
|
368
|
+
this.emitEvent({
|
|
369
|
+
type: 'issue:status:changed',
|
|
370
|
+
timestamp: new Date(),
|
|
371
|
+
issueId: issueId,
|
|
372
|
+
data: { previousStatus: previousStatus, newStatus: status, note: note }
|
|
373
|
+
});
|
|
374
|
+
return [2 /*return*/];
|
|
375
|
+
}
|
|
376
|
+
});
|
|
227
377
|
});
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
type: 'issue:review:requested',
|
|
247
|
-
timestamp: new Date(),
|
|
248
|
-
issueId,
|
|
249
|
-
claimant: claim.claimant,
|
|
250
|
-
data: { reviewers },
|
|
378
|
+
};
|
|
379
|
+
ClaimService.prototype.updateProgress = function (issueId, progress) {
|
|
380
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
381
|
+
var claim;
|
|
382
|
+
return __generator(this, function (_a) {
|
|
383
|
+
switch (_a.label) {
|
|
384
|
+
case 0:
|
|
385
|
+
claim = this.claims.get(issueId);
|
|
386
|
+
if (!claim) {
|
|
387
|
+
throw new Error("Issue " + issueId + " is not claimed");
|
|
388
|
+
}
|
|
389
|
+
claim.progress = Math.min(100, Math.max(0, progress));
|
|
390
|
+
return [4 /*yield*/, this.saveClaims()];
|
|
391
|
+
case 1:
|
|
392
|
+
_a.sent();
|
|
393
|
+
return [2 /*return*/];
|
|
394
|
+
}
|
|
395
|
+
});
|
|
251
396
|
});
|
|
252
|
-
}
|
|
397
|
+
};
|
|
398
|
+
ClaimService.prototype.requestReview = function (issueId, reviewers) {
|
|
399
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
400
|
+
var claim;
|
|
401
|
+
return __generator(this, function (_a) {
|
|
402
|
+
switch (_a.label) {
|
|
403
|
+
case 0:
|
|
404
|
+
claim = this.claims.get(issueId);
|
|
405
|
+
if (!claim) {
|
|
406
|
+
throw new Error("Issue " + issueId + " is not claimed");
|
|
407
|
+
}
|
|
408
|
+
claim.status = 'review-requested';
|
|
409
|
+
claim.statusChangedAt = new Date();
|
|
410
|
+
return [4 /*yield*/, this.saveClaims()];
|
|
411
|
+
case 1:
|
|
412
|
+
_a.sent();
|
|
413
|
+
this.emitEvent({
|
|
414
|
+
type: 'issue:review:requested',
|
|
415
|
+
timestamp: new Date(),
|
|
416
|
+
issueId: issueId,
|
|
417
|
+
claimant: claim.claimant,
|
|
418
|
+
data: { reviewers: reviewers }
|
|
419
|
+
});
|
|
420
|
+
return [2 /*return*/];
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
};
|
|
253
425
|
// ==========================================================================
|
|
254
426
|
// Work Stealing
|
|
255
427
|
// ==========================================================================
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
428
|
+
ClaimService.prototype.markStealable = function (issueId, info) {
|
|
429
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
430
|
+
var claim;
|
|
431
|
+
return __generator(this, function (_a) {
|
|
432
|
+
switch (_a.label) {
|
|
433
|
+
case 0:
|
|
434
|
+
claim = this.claims.get(issueId);
|
|
435
|
+
if (!claim) {
|
|
436
|
+
throw new Error("Issue " + issueId + " is not claimed");
|
|
437
|
+
}
|
|
438
|
+
claim.status = 'stealable';
|
|
439
|
+
claim.statusChangedAt = new Date();
|
|
440
|
+
claim.context = info.context;
|
|
441
|
+
claim.progress = info.progress;
|
|
442
|
+
this.stealableInfo.set(issueId, info);
|
|
443
|
+
return [4 /*yield*/, this.saveClaims()];
|
|
444
|
+
case 1:
|
|
445
|
+
_a.sent();
|
|
446
|
+
this.emitEvent({
|
|
447
|
+
type: 'issue:stealable',
|
|
448
|
+
timestamp: new Date(),
|
|
449
|
+
issueId: issueId,
|
|
450
|
+
claimant: claim.claimant,
|
|
451
|
+
data: { info: info }
|
|
452
|
+
});
|
|
453
|
+
return [2 /*return*/];
|
|
454
|
+
}
|
|
455
|
+
});
|
|
273
456
|
});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
457
|
+
};
|
|
458
|
+
ClaimService.prototype.steal = function (issueId, stealer) {
|
|
459
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
460
|
+
var claim, info, previousOwner, allowed;
|
|
461
|
+
return __generator(this, function (_a) {
|
|
462
|
+
switch (_a.label) {
|
|
463
|
+
case 0:
|
|
464
|
+
claim = this.claims.get(issueId);
|
|
465
|
+
if (!claim) {
|
|
466
|
+
return [2 /*return*/, { success: false, error: "Issue " + issueId + " is not claimed" }];
|
|
467
|
+
}
|
|
468
|
+
if (claim.status !== 'stealable') {
|
|
469
|
+
return [2 /*return*/, { success: false, error: "Issue " + issueId + " is not stealable" }];
|
|
470
|
+
}
|
|
471
|
+
info = this.stealableInfo.get(issueId);
|
|
472
|
+
previousOwner = claim.claimant;
|
|
473
|
+
// Check if steal is allowed
|
|
474
|
+
if (this.config.requireSameType && stealer.type === 'agent' && previousOwner.type === 'agent') {
|
|
475
|
+
if (stealer.agentType !== previousOwner.agentType) {
|
|
476
|
+
allowed = this.config.allowCrossTypeSteal.some(function (pair) { return pair.includes(stealer.agentType) && pair.includes(previousOwner.agentType); });
|
|
477
|
+
if (!allowed) {
|
|
478
|
+
return [2 /*return*/, { success: false, error: "Cross-type steal not allowed" }];
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
// Execute steal
|
|
483
|
+
claim.claimant = stealer;
|
|
484
|
+
claim.status = 'active';
|
|
485
|
+
claim.statusChangedAt = new Date();
|
|
486
|
+
claim.claimedAt = new Date();
|
|
487
|
+
this.stealableInfo["delete"](issueId);
|
|
488
|
+
return [4 /*yield*/, this.saveClaims()];
|
|
489
|
+
case 1:
|
|
490
|
+
_a.sent();
|
|
491
|
+
this.emitEvent({
|
|
492
|
+
type: 'issue:stolen',
|
|
493
|
+
timestamp: new Date(),
|
|
494
|
+
issueId: issueId,
|
|
495
|
+
claimant: stealer,
|
|
496
|
+
previousClaimant: previousOwner,
|
|
497
|
+
data: { context: info }
|
|
498
|
+
});
|
|
499
|
+
return [2 /*return*/, { success: true, claim: claim, previousOwner: previousOwner, context: info }];
|
|
291
500
|
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
// Execute steal
|
|
295
|
-
claim.claimant = stealer;
|
|
296
|
-
claim.status = 'active';
|
|
297
|
-
claim.statusChangedAt = new Date();
|
|
298
|
-
claim.claimedAt = new Date();
|
|
299
|
-
this.stealableInfo.delete(issueId);
|
|
300
|
-
await this.saveClaims();
|
|
301
|
-
this.emitEvent({
|
|
302
|
-
type: 'issue:stolen',
|
|
303
|
-
timestamp: new Date(),
|
|
304
|
-
issueId,
|
|
305
|
-
claimant: stealer,
|
|
306
|
-
previousClaimant: previousOwner,
|
|
307
|
-
data: { context: info },
|
|
501
|
+
});
|
|
308
502
|
});
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
this.emitEvent({
|
|
331
|
-
type: 'issue:steal:contested',
|
|
332
|
-
timestamp: new Date(),
|
|
333
|
-
issueId,
|
|
334
|
-
claimant: originalClaimant,
|
|
335
|
-
data: { reason, currentOwner: claim.claimant },
|
|
503
|
+
};
|
|
504
|
+
ClaimService.prototype.getStealable = function (agentType) {
|
|
505
|
+
var _a;
|
|
506
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
507
|
+
var stealable, _i, _b, claim, info;
|
|
508
|
+
return __generator(this, function (_c) {
|
|
509
|
+
stealable = [];
|
|
510
|
+
for (_i = 0, _b = this.claims.values(); _i < _b.length; _i++) {
|
|
511
|
+
claim = _b[_i];
|
|
512
|
+
if (claim.status !== 'stealable')
|
|
513
|
+
continue;
|
|
514
|
+
info = this.stealableInfo.get(claim.issueId);
|
|
515
|
+
if (agentType && ((_a = info === null || info === void 0 ? void 0 : info.preferredTypes) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
516
|
+
if (!info.preferredTypes.includes(agentType))
|
|
517
|
+
continue;
|
|
518
|
+
}
|
|
519
|
+
stealable.push(claim);
|
|
520
|
+
}
|
|
521
|
+
return [2 /*return*/, stealable];
|
|
522
|
+
});
|
|
336
523
|
});
|
|
337
|
-
|
|
338
|
-
|
|
524
|
+
};
|
|
525
|
+
ClaimService.prototype.contestSteal = function (issueId, originalClaimant, reason) {
|
|
526
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
527
|
+
var claim;
|
|
528
|
+
return __generator(this, function (_a) {
|
|
529
|
+
claim = this.claims.get(issueId);
|
|
530
|
+
if (!claim) {
|
|
531
|
+
throw new Error("Issue " + issueId + " is not claimed");
|
|
532
|
+
}
|
|
533
|
+
this.emitEvent({
|
|
534
|
+
type: 'issue:steal:contested',
|
|
535
|
+
timestamp: new Date(),
|
|
536
|
+
issueId: issueId,
|
|
537
|
+
claimant: originalClaimant,
|
|
538
|
+
data: { reason: reason, currentOwner: claim.claimant }
|
|
539
|
+
});
|
|
540
|
+
return [2 /*return*/];
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
};
|
|
339
544
|
// ==========================================================================
|
|
340
545
|
// Load Balancing
|
|
341
546
|
// ==========================================================================
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
claims
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
agentType,
|
|
356
|
-
claimCount: claims.length,
|
|
357
|
-
maxClaims: this.config.overloadThreshold,
|
|
358
|
-
utilization: claims.length / this.config.overloadThreshold,
|
|
359
|
-
claims,
|
|
360
|
-
avgCompletionTime: 0, // Would need historical data
|
|
361
|
-
currentBlockedCount: blockedCount,
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
async rebalance(swarmId) {
|
|
365
|
-
const result = { moved: [], suggested: [] };
|
|
366
|
-
// Get all agent loads
|
|
367
|
-
const agentLoads = new Map();
|
|
368
|
-
const agentTypes = new Set();
|
|
369
|
-
for (const claim of this.claims.values()) {
|
|
370
|
-
if (claim.claimant.type !== 'agent')
|
|
371
|
-
continue;
|
|
372
|
-
const agentId = claim.claimant.agentId;
|
|
373
|
-
if (!agentLoads.has(agentId)) {
|
|
374
|
-
const load = await this.getAgentLoad(agentId);
|
|
375
|
-
agentLoads.set(agentId, load);
|
|
376
|
-
agentTypes.add(load.agentType);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
// For each agent type, calculate average load
|
|
380
|
-
for (const agentType of agentTypes) {
|
|
381
|
-
const typeLoads = Array.from(agentLoads.values()).filter(l => l.agentType === agentType);
|
|
382
|
-
const avgLoad = typeLoads.reduce((sum, l) => sum + l.utilization, 0) / typeLoads.length;
|
|
383
|
-
const overloaded = typeLoads.filter(l => l.utilization > avgLoad * 1.5);
|
|
384
|
-
const underloaded = typeLoads.filter(l => l.utilization < avgLoad * 0.5);
|
|
385
|
-
// Generate suggestions
|
|
386
|
-
for (const over of overloaded) {
|
|
387
|
-
const lowProgressClaims = over.claims
|
|
388
|
-
.filter(c => c.progress < 25)
|
|
389
|
-
.sort((a, b) => a.progress - b.progress);
|
|
390
|
-
for (const claim of lowProgressClaims) {
|
|
391
|
-
const target = underloaded.find(u => u.claimCount < u.maxClaims);
|
|
392
|
-
if (target) {
|
|
393
|
-
result.suggested.push({
|
|
394
|
-
issueId: claim.issueId,
|
|
395
|
-
currentOwner: claim.claimant,
|
|
396
|
-
suggestedOwner: {
|
|
397
|
-
type: 'agent',
|
|
398
|
-
agentId: target.agentId,
|
|
399
|
-
agentType: target.agentType,
|
|
400
|
-
},
|
|
401
|
-
reason: 'Load balancing: redistributing work across swarm',
|
|
402
|
-
});
|
|
547
|
+
ClaimService.prototype.getAgentLoad = function (agentId) {
|
|
548
|
+
var _a;
|
|
549
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
550
|
+
var claims, blockedCount, _i, _b, claim, agentType;
|
|
551
|
+
return __generator(this, function (_c) {
|
|
552
|
+
claims = [];
|
|
553
|
+
blockedCount = 0;
|
|
554
|
+
for (_i = 0, _b = this.claims.values(); _i < _b.length; _i++) {
|
|
555
|
+
claim = _b[_i];
|
|
556
|
+
if (claim.claimant.type === 'agent' && claim.claimant.agentId === agentId) {
|
|
557
|
+
claims.push(claim);
|
|
558
|
+
if (claim.status === 'blocked')
|
|
559
|
+
blockedCount++;
|
|
403
560
|
}
|
|
404
561
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
562
|
+
agentType = ((_a = claims[0]) === null || _a === void 0 ? void 0 : _a.claimant.type) === 'agent' ? claims[0].claimant.agentType : 'unknown';
|
|
563
|
+
return [2 /*return*/, {
|
|
564
|
+
agentId: agentId,
|
|
565
|
+
agentType: agentType,
|
|
566
|
+
claimCount: claims.length,
|
|
567
|
+
maxClaims: this.config.overloadThreshold,
|
|
568
|
+
utilization: claims.length / this.config.overloadThreshold,
|
|
569
|
+
claims: claims,
|
|
570
|
+
avgCompletionTime: 0,
|
|
571
|
+
currentBlockedCount: blockedCount
|
|
572
|
+
}];
|
|
573
|
+
});
|
|
574
|
+
});
|
|
575
|
+
};
|
|
576
|
+
ClaimService.prototype.rebalance = function (swarmId) {
|
|
577
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
578
|
+
var result, agentLoads, agentTypes, _i, _a, claim, agentId, load, _loop_1, _b, agentTypes_1, agentType;
|
|
579
|
+
return __generator(this, function (_c) {
|
|
580
|
+
switch (_c.label) {
|
|
581
|
+
case 0:
|
|
582
|
+
result = { moved: [], suggested: [] };
|
|
583
|
+
agentLoads = new Map();
|
|
584
|
+
agentTypes = new Set();
|
|
585
|
+
_i = 0, _a = this.claims.values();
|
|
586
|
+
_c.label = 1;
|
|
587
|
+
case 1:
|
|
588
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
589
|
+
claim = _a[_i];
|
|
590
|
+
if (claim.claimant.type !== 'agent')
|
|
591
|
+
return [3 /*break*/, 3];
|
|
592
|
+
agentId = claim.claimant.agentId;
|
|
593
|
+
if (!!agentLoads.has(agentId)) return [3 /*break*/, 3];
|
|
594
|
+
return [4 /*yield*/, this.getAgentLoad(agentId)];
|
|
595
|
+
case 2:
|
|
596
|
+
load = _c.sent();
|
|
597
|
+
agentLoads.set(agentId, load);
|
|
598
|
+
agentTypes.add(load.agentType);
|
|
599
|
+
_c.label = 3;
|
|
600
|
+
case 3:
|
|
601
|
+
_i++;
|
|
602
|
+
return [3 /*break*/, 1];
|
|
603
|
+
case 4:
|
|
604
|
+
_loop_1 = function (agentType) {
|
|
605
|
+
var typeLoads = Array.from(agentLoads.values()).filter(function (l) { return l.agentType === agentType; });
|
|
606
|
+
var avgLoad = typeLoads.reduce(function (sum, l) { return sum + l.utilization; }, 0) / typeLoads.length;
|
|
607
|
+
var overloaded = typeLoads.filter(function (l) { return l.utilization > avgLoad * 1.5; });
|
|
608
|
+
var underloaded = typeLoads.filter(function (l) { return l.utilization < avgLoad * 0.5; });
|
|
609
|
+
// Generate suggestions
|
|
610
|
+
for (var _d = 0, overloaded_1 = overloaded; _d < overloaded_1.length; _d++) {
|
|
611
|
+
var over = overloaded_1[_d];
|
|
612
|
+
var lowProgressClaims = over.claims
|
|
613
|
+
.filter(function (c) { return c.progress < 25; })
|
|
614
|
+
.sort(function (a, b) { return a.progress - b.progress; });
|
|
615
|
+
for (var _e = 0, lowProgressClaims_1 = lowProgressClaims; _e < lowProgressClaims_1.length; _e++) {
|
|
616
|
+
var claim = lowProgressClaims_1[_e];
|
|
617
|
+
var target = underloaded.find(function (u) { return u.claimCount < u.maxClaims; });
|
|
618
|
+
if (target) {
|
|
619
|
+
result.suggested.push({
|
|
620
|
+
issueId: claim.issueId,
|
|
621
|
+
currentOwner: claim.claimant,
|
|
622
|
+
suggestedOwner: {
|
|
623
|
+
type: 'agent',
|
|
624
|
+
agentId: target.agentId,
|
|
625
|
+
agentType: target.agentType
|
|
626
|
+
},
|
|
627
|
+
reason: 'Load balancing: redistributing work across swarm'
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
// For each agent type, calculate average load
|
|
634
|
+
for (_b = 0, agentTypes_1 = agentTypes; _b < agentTypes_1.length; _b++) {
|
|
635
|
+
agentType = agentTypes_1[_b];
|
|
636
|
+
_loop_1(agentType);
|
|
637
|
+
}
|
|
638
|
+
return [2 /*return*/, result];
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
};
|
|
409
643
|
// ==========================================================================
|
|
410
644
|
// Queries
|
|
411
645
|
// ==========================================================================
|
|
412
|
-
|
|
413
|
-
return
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
646
|
+
ClaimService.prototype.getClaimedBy = function (claimant) {
|
|
647
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
648
|
+
var _this = this;
|
|
649
|
+
return __generator(this, function (_a) {
|
|
650
|
+
return [2 /*return*/, Array.from(this.claims.values()).filter(function (c) {
|
|
651
|
+
return _this.isSameClaimant(c.claimant, claimant);
|
|
652
|
+
})];
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
};
|
|
656
|
+
ClaimService.prototype.getAvailableIssues = function (_filters) {
|
|
657
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
658
|
+
return __generator(this, function (_a) {
|
|
659
|
+
// This would integrate with GitHub API
|
|
660
|
+
// For now, return issues that are not claimed
|
|
661
|
+
return [2 /*return*/, []];
|
|
662
|
+
});
|
|
663
|
+
});
|
|
664
|
+
};
|
|
665
|
+
ClaimService.prototype.getIssueStatus = function (issueId) {
|
|
666
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
667
|
+
return __generator(this, function (_a) {
|
|
668
|
+
return [2 /*return*/, this.claims.get(issueId) || null];
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
};
|
|
672
|
+
ClaimService.prototype.getAllClaims = function () {
|
|
673
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
674
|
+
return __generator(this, function (_a) {
|
|
675
|
+
return [2 /*return*/, Array.from(this.claims.values())];
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
};
|
|
679
|
+
ClaimService.prototype.getByStatus = function (status) {
|
|
680
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
681
|
+
return __generator(this, function (_a) {
|
|
682
|
+
return [2 /*return*/, Array.from(this.claims.values()).filter(function (c) { return c.status === status; })];
|
|
683
|
+
});
|
|
684
|
+
});
|
|
685
|
+
};
|
|
429
686
|
// ==========================================================================
|
|
430
687
|
// Auto-Management
|
|
431
688
|
// ==========================================================================
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
689
|
+
ClaimService.prototype.expireStale = function (maxAgeMinutes) {
|
|
690
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
691
|
+
var threshold, now, expired, _i, _a, claim, age;
|
|
692
|
+
return __generator(this, function (_b) {
|
|
693
|
+
switch (_b.label) {
|
|
694
|
+
case 0:
|
|
695
|
+
threshold = maxAgeMinutes !== null && maxAgeMinutes !== void 0 ? maxAgeMinutes : this.config.staleThresholdMinutes;
|
|
696
|
+
now = Date.now();
|
|
697
|
+
expired = [];
|
|
698
|
+
_i = 0, _a = this.claims.values();
|
|
699
|
+
_b.label = 1;
|
|
700
|
+
case 1:
|
|
701
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
702
|
+
claim = _a[_i];
|
|
703
|
+
if (claim.status === 'stealable' || claim.status === 'completed')
|
|
704
|
+
return [3 /*break*/, 3];
|
|
705
|
+
age = (now - claim.statusChangedAt.getTime()) / 60000;
|
|
706
|
+
if (!(age > threshold)) return [3 /*break*/, 3];
|
|
707
|
+
// Mark as stealable
|
|
708
|
+
return [4 /*yield*/, this.markStealable(claim.issueId, {
|
|
709
|
+
reason: 'stale',
|
|
710
|
+
stealableAt: new Date(),
|
|
711
|
+
progress: claim.progress,
|
|
712
|
+
context: "Stale: No activity for " + Math.round(age) + " minutes"
|
|
713
|
+
})];
|
|
714
|
+
case 2:
|
|
715
|
+
// Mark as stealable
|
|
716
|
+
_b.sent();
|
|
717
|
+
expired.push(claim);
|
|
718
|
+
_b.label = 3;
|
|
719
|
+
case 3:
|
|
720
|
+
_i++;
|
|
721
|
+
return [3 /*break*/, 1];
|
|
722
|
+
case 4: return [2 /*return*/, expired];
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
});
|
|
726
|
+
};
|
|
453
727
|
// ==========================================================================
|
|
454
728
|
// Helpers
|
|
455
729
|
// ==========================================================================
|
|
456
|
-
formatClaimant(claimant) {
|
|
730
|
+
ClaimService.prototype.formatClaimant = function (claimant) {
|
|
457
731
|
return claimant.type === 'human'
|
|
458
|
-
?
|
|
459
|
-
:
|
|
460
|
-
}
|
|
461
|
-
isSameClaimant(a, b) {
|
|
732
|
+
? "human:" + claimant.name
|
|
733
|
+
: "agent:" + claimant.agentType + ":" + claimant.agentId;
|
|
734
|
+
};
|
|
735
|
+
ClaimService.prototype.isSameClaimant = function (a, b) {
|
|
462
736
|
if (a.type !== b.type)
|
|
463
737
|
return false;
|
|
464
738
|
if (a.type === 'human' && b.type === 'human') {
|
|
@@ -468,28 +742,31 @@ export class ClaimService extends EventEmitter {
|
|
|
468
742
|
return a.agentId === b.agentId;
|
|
469
743
|
}
|
|
470
744
|
return false;
|
|
471
|
-
}
|
|
472
|
-
emitEvent(event) {
|
|
745
|
+
};
|
|
746
|
+
ClaimService.prototype.emitEvent = function (event) {
|
|
473
747
|
this.eventLog.push(event);
|
|
474
748
|
if (this.eventLog.length > 1000) {
|
|
475
749
|
this.eventLog = this.eventLog.slice(-500);
|
|
476
750
|
}
|
|
477
751
|
this.emit(event.type, event);
|
|
478
|
-
}
|
|
479
|
-
getEventLog
|
|
752
|
+
};
|
|
753
|
+
ClaimService.prototype.getEventLog = function (limit) {
|
|
754
|
+
if (limit === void 0) { limit = 100; }
|
|
480
755
|
return this.eventLog.slice(-limit);
|
|
481
|
-
}
|
|
482
|
-
|
|
756
|
+
};
|
|
757
|
+
return ClaimService;
|
|
758
|
+
}(EventEmitter));
|
|
759
|
+
export { ClaimService };
|
|
483
760
|
// ============================================================================
|
|
484
761
|
// GitHub Sync Implementation
|
|
485
762
|
// ============================================================================
|
|
486
|
-
|
|
763
|
+
var DEFAULT_GITHUB_CONFIG = {
|
|
487
764
|
enabled: false,
|
|
488
765
|
syncLabels: true,
|
|
489
766
|
claimLabel: 'claimed',
|
|
490
767
|
autoAssign: true,
|
|
491
768
|
commentOnClaim: true,
|
|
492
|
-
commentOnRelease: true
|
|
769
|
+
commentOnRelease: true
|
|
493
770
|
};
|
|
494
771
|
// ============================================================================
|
|
495
772
|
// Input Validation (Security)
|
|
@@ -528,283 +805,331 @@ function isValidLabel(label) {
|
|
|
528
805
|
* Sanitize error messages to prevent information disclosure
|
|
529
806
|
*/
|
|
530
807
|
function sanitizeError(error) {
|
|
531
|
-
|
|
808
|
+
var msg = error.message || 'Unknown error';
|
|
532
809
|
// Remove paths and sensitive details
|
|
533
810
|
return msg.replace(/\/[\w./-]+/g, '[path]').substring(0, 200);
|
|
534
811
|
}
|
|
535
|
-
|
|
536
|
-
config
|
|
537
|
-
claimService;
|
|
538
|
-
constructor(claimService, config) {
|
|
812
|
+
var GitHubSync = /** @class */ (function () {
|
|
813
|
+
function GitHubSync(claimService, config) {
|
|
539
814
|
this.claimService = claimService;
|
|
540
|
-
this.config = {
|
|
815
|
+
this.config = __assign(__assign({}, DEFAULT_GITHUB_CONFIG), config);
|
|
541
816
|
}
|
|
542
817
|
/**
|
|
543
818
|
* Check if GitHub CLI is available
|
|
544
819
|
*/
|
|
545
|
-
isGhAvailable() {
|
|
820
|
+
GitHubSync.prototype.isGhAvailable = function () {
|
|
546
821
|
try {
|
|
547
822
|
execFileSync('gh', ['--version'], { stdio: 'ignore' });
|
|
548
823
|
return true;
|
|
549
824
|
}
|
|
550
|
-
catch {
|
|
825
|
+
catch (_a) {
|
|
551
826
|
return false;
|
|
552
827
|
}
|
|
553
|
-
}
|
|
828
|
+
};
|
|
554
829
|
/**
|
|
555
830
|
* Get the current repository from git remote
|
|
556
831
|
*/
|
|
557
|
-
getRepo() {
|
|
832
|
+
GitHubSync.prototype.getRepo = function () {
|
|
558
833
|
if (this.config.repo) {
|
|
559
834
|
return isValidRepo(this.config.repo) ? this.config.repo : null;
|
|
560
835
|
}
|
|
561
836
|
try {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
837
|
+
var remote = execFileSync('git', ['remote', 'get-url', 'origin'], { encoding: 'utf-8' }).trim();
|
|
838
|
+
var match = remote.match(/github\.com[/:]([\w.-]+\/[\w.-]+)/);
|
|
839
|
+
var repo = match ? match[1].replace('.git', '') : null;
|
|
565
840
|
return repo && isValidRepo(repo) ? repo : null;
|
|
566
841
|
}
|
|
567
|
-
catch {
|
|
842
|
+
catch (_a) {
|
|
568
843
|
return null;
|
|
569
844
|
}
|
|
570
|
-
}
|
|
845
|
+
};
|
|
571
846
|
/**
|
|
572
847
|
* Sync issues from GitHub
|
|
573
848
|
*/
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
849
|
+
GitHubSync.prototype.syncIssues = function (state) {
|
|
850
|
+
var _a, _b;
|
|
851
|
+
if (state === void 0) { state = 'open'; }
|
|
852
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
853
|
+
var errors, issues, repo, validStates, issuesJson, rawIssues, _i, rawIssues_1, raw;
|
|
854
|
+
return __generator(this, function (_c) {
|
|
855
|
+
errors = [];
|
|
856
|
+
issues = [];
|
|
857
|
+
if (!this.isGhAvailable()) {
|
|
858
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['GitHub CLI (gh) not installed'] }];
|
|
859
|
+
}
|
|
860
|
+
repo = this.getRepo();
|
|
861
|
+
if (!repo) {
|
|
862
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['Could not determine GitHub repository'] }];
|
|
863
|
+
}
|
|
864
|
+
validStates = ['open', 'closed', 'all'];
|
|
865
|
+
if (!validStates.includes(state)) {
|
|
866
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['Invalid state parameter'] }];
|
|
867
|
+
}
|
|
868
|
+
try {
|
|
869
|
+
issuesJson = execFileSync('gh', [
|
|
870
|
+
'issue', 'list',
|
|
871
|
+
'--repo', repo,
|
|
872
|
+
'--state', state,
|
|
873
|
+
'--json', 'number,title,body,state,labels,assignees,url,createdAt,updatedAt',
|
|
874
|
+
'--limit', '100'
|
|
875
|
+
], { encoding: 'utf-8' });
|
|
876
|
+
rawIssues = JSON.parse(issuesJson);
|
|
877
|
+
for (_i = 0, rawIssues_1 = rawIssues; _i < rawIssues_1.length; _i++) {
|
|
878
|
+
raw = rawIssues_1[_i];
|
|
879
|
+
issues.push({
|
|
880
|
+
number: raw.number,
|
|
881
|
+
title: raw.title,
|
|
882
|
+
body: raw.body || '',
|
|
883
|
+
state: raw.state === 'OPEN' ? 'open' : 'closed',
|
|
884
|
+
labels: ((_a = raw.labels) === null || _a === void 0 ? void 0 : _a.map(function (l) { return l.name; })) || [],
|
|
885
|
+
assignees: ((_b = raw.assignees) === null || _b === void 0 ? void 0 : _b.map(function (a) { return a.login; })) || [],
|
|
886
|
+
url: raw.url,
|
|
887
|
+
createdAt: new Date(raw.createdAt),
|
|
888
|
+
updatedAt: new Date(raw.updatedAt)
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
return [2 /*return*/, { success: true, synced: issues.length, errors: errors, issues: issues }];
|
|
892
|
+
}
|
|
893
|
+
catch (error) {
|
|
894
|
+
errors.push("Failed to fetch issues: " + sanitizeError(error));
|
|
895
|
+
return [2 /*return*/, { success: false, synced: 0, errors: errors }];
|
|
896
|
+
}
|
|
897
|
+
return [2 /*return*/];
|
|
898
|
+
});
|
|
899
|
+
});
|
|
900
|
+
};
|
|
618
901
|
/**
|
|
619
902
|
* Sync a local claim to GitHub (add label/assignee/comment)
|
|
620
903
|
*/
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
return
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
}
|
|
629
|
-
// Validate issue number
|
|
630
|
-
if (!isValidIssueNumber(issueNumber)) {
|
|
631
|
-
return { success: false, synced: 0, errors: ['Invalid issue number'] };
|
|
632
|
-
}
|
|
633
|
-
const repo = this.getRepo();
|
|
634
|
-
if (!repo) {
|
|
635
|
-
return { success: false, synced: 0, errors: ['Could not determine repository'] };
|
|
636
|
-
}
|
|
637
|
-
// Validate claim label
|
|
638
|
-
if (!isValidLabel(this.config.claimLabel)) {
|
|
639
|
-
return { success: false, synced: 0, errors: ['Invalid claim label configuration'] };
|
|
640
|
-
}
|
|
641
|
-
try {
|
|
642
|
-
// Add claim label
|
|
643
|
-
if (this.config.syncLabels) {
|
|
644
|
-
try {
|
|
645
|
-
execFileSync('gh', [
|
|
646
|
-
'issue', 'edit', String(issueNumber),
|
|
647
|
-
'--repo', repo,
|
|
648
|
-
'--add-label', this.config.claimLabel
|
|
649
|
-
], { stdio: 'ignore' });
|
|
904
|
+
GitHubSync.prototype.claimOnGitHub = function (issueNumber, claimant) {
|
|
905
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
906
|
+
var errors, repo, claimantStr, comment;
|
|
907
|
+
return __generator(this, function (_a) {
|
|
908
|
+
errors = [];
|
|
909
|
+
if (!this.config.enabled) {
|
|
910
|
+
return [2 /*return*/, { success: true, synced: 0, errors: ['GitHub sync not enabled'] }];
|
|
650
911
|
}
|
|
651
|
-
|
|
652
|
-
|
|
912
|
+
if (!this.isGhAvailable()) {
|
|
913
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['GitHub CLI (gh) not installed'] }];
|
|
653
914
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
if (!isValidClaimantName(claimant.name)) {
|
|
658
|
-
errors.push('Invalid claimant name format');
|
|
915
|
+
// Validate issue number
|
|
916
|
+
if (!isValidIssueNumber(issueNumber)) {
|
|
917
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['Invalid issue number'] }];
|
|
659
918
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
}
|
|
668
|
-
catch {
|
|
669
|
-
errors.push('Failed to assign issue');
|
|
670
|
-
}
|
|
919
|
+
repo = this.getRepo();
|
|
920
|
+
if (!repo) {
|
|
921
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['Could not determine repository'] }];
|
|
922
|
+
}
|
|
923
|
+
// Validate claim label
|
|
924
|
+
if (!isValidLabel(this.config.claimLabel)) {
|
|
925
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['Invalid claim label configuration'] }];
|
|
671
926
|
}
|
|
672
|
-
}
|
|
673
|
-
// Add comment
|
|
674
|
-
if (this.config.commentOnClaim) {
|
|
675
|
-
const claimantStr = claimant.type === 'human'
|
|
676
|
-
? `@${claimant.name.replace(/[^a-zA-Z0-9_-]/g, '')}`
|
|
677
|
-
: `Agent: ${(claimant.agentType || 'unknown').replace(/[^a-zA-Z0-9_-]/g, '')}`;
|
|
678
|
-
const comment = `🤖 **Issue claimed** by ${claimantStr}\n\n_Coordinated by KynjalFlow V3_`;
|
|
679
927
|
try {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
928
|
+
// Add claim label
|
|
929
|
+
if (this.config.syncLabels) {
|
|
930
|
+
try {
|
|
931
|
+
execFileSync('gh', [
|
|
932
|
+
'issue', 'edit', String(issueNumber),
|
|
933
|
+
'--repo', repo,
|
|
934
|
+
'--add-label', this.config.claimLabel
|
|
935
|
+
], { stdio: 'ignore' });
|
|
936
|
+
}
|
|
937
|
+
catch (_b) {
|
|
938
|
+
errors.push('Failed to add claim label (label may not exist)');
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
// Auto-assign if human claimant
|
|
942
|
+
if (this.config.autoAssign && claimant.type === 'human') {
|
|
943
|
+
if (!isValidClaimantName(claimant.name)) {
|
|
944
|
+
errors.push('Invalid claimant name format');
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
try {
|
|
948
|
+
execFileSync('gh', [
|
|
949
|
+
'issue', 'edit', String(issueNumber),
|
|
950
|
+
'--repo', repo,
|
|
951
|
+
'--add-assignee', claimant.name
|
|
952
|
+
], { stdio: 'ignore' });
|
|
953
|
+
}
|
|
954
|
+
catch (_c) {
|
|
955
|
+
errors.push('Failed to assign issue');
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
// Add comment
|
|
960
|
+
if (this.config.commentOnClaim) {
|
|
961
|
+
claimantStr = claimant.type === 'human'
|
|
962
|
+
? "@" + claimant.name.replace(/[^a-zA-Z0-9_-]/g, '')
|
|
963
|
+
: "Agent: " + (claimant.agentType || 'unknown').replace(/[^a-zA-Z0-9_-]/g, '');
|
|
964
|
+
comment = "\uD83E\uDD16 **Issue claimed** by " + claimantStr + "\n\n_Coordinated by RuFlo V3_";
|
|
965
|
+
try {
|
|
966
|
+
execFileSync('gh', [
|
|
967
|
+
'issue', 'comment', String(issueNumber),
|
|
968
|
+
'--repo', repo,
|
|
969
|
+
'--body', comment
|
|
970
|
+
], { stdio: 'ignore' });
|
|
971
|
+
}
|
|
972
|
+
catch (_d) {
|
|
973
|
+
errors.push('Failed to add comment');
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
return [2 /*return*/, { success: errors.length === 0, synced: 1, errors: errors }];
|
|
685
977
|
}
|
|
686
|
-
catch {
|
|
687
|
-
errors.push(
|
|
978
|
+
catch (error) {
|
|
979
|
+
errors.push("GitHub sync failed: " + sanitizeError(error));
|
|
980
|
+
return [2 /*return*/, { success: false, synced: 0, errors: errors }];
|
|
688
981
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
errors.push(`GitHub sync failed: ${sanitizeError(error)}`);
|
|
694
|
-
return { success: false, synced: 0, errors };
|
|
695
|
-
}
|
|
696
|
-
}
|
|
982
|
+
return [2 /*return*/];
|
|
983
|
+
});
|
|
984
|
+
});
|
|
985
|
+
};
|
|
697
986
|
/**
|
|
698
987
|
* Release claim on GitHub (remove label/assignee/comment)
|
|
699
988
|
*/
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
return
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
}
|
|
708
|
-
// Validate issue number
|
|
709
|
-
if (!isValidIssueNumber(issueNumber)) {
|
|
710
|
-
return { success: false, synced: 0, errors: ['Invalid issue number'] };
|
|
711
|
-
}
|
|
712
|
-
const repo = this.getRepo();
|
|
713
|
-
if (!repo) {
|
|
714
|
-
return { success: false, synced: 0, errors: ['Could not determine repository'] };
|
|
715
|
-
}
|
|
716
|
-
// Validate claim label
|
|
717
|
-
if (!isValidLabel(this.config.claimLabel)) {
|
|
718
|
-
return { success: false, synced: 0, errors: ['Invalid claim label configuration'] };
|
|
719
|
-
}
|
|
720
|
-
try {
|
|
721
|
-
// Remove claim label
|
|
722
|
-
if (this.config.syncLabels) {
|
|
723
|
-
try {
|
|
724
|
-
execFileSync('gh', [
|
|
725
|
-
'issue', 'edit', String(issueNumber),
|
|
726
|
-
'--repo', repo,
|
|
727
|
-
'--remove-label', this.config.claimLabel
|
|
728
|
-
], { stdio: 'ignore' });
|
|
989
|
+
GitHubSync.prototype.releaseOnGitHub = function (issueNumber, claimant) {
|
|
990
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
991
|
+
var errors, repo, claimantStr, comment;
|
|
992
|
+
return __generator(this, function (_a) {
|
|
993
|
+
errors = [];
|
|
994
|
+
if (!this.config.enabled) {
|
|
995
|
+
return [2 /*return*/, { success: true, synced: 0, errors: ['GitHub sync not enabled'] }];
|
|
729
996
|
}
|
|
730
|
-
|
|
731
|
-
|
|
997
|
+
if (!this.isGhAvailable()) {
|
|
998
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['GitHub CLI (gh) not installed'] }];
|
|
732
999
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
}
|
|
744
|
-
catch {
|
|
745
|
-
errors.push('Failed to remove assignee');
|
|
746
|
-
}
|
|
1000
|
+
// Validate issue number
|
|
1001
|
+
if (!isValidIssueNumber(issueNumber)) {
|
|
1002
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['Invalid issue number'] }];
|
|
1003
|
+
}
|
|
1004
|
+
repo = this.getRepo();
|
|
1005
|
+
if (!repo) {
|
|
1006
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['Could not determine repository'] }];
|
|
1007
|
+
}
|
|
1008
|
+
// Validate claim label
|
|
1009
|
+
if (!isValidLabel(this.config.claimLabel)) {
|
|
1010
|
+
return [2 /*return*/, { success: false, synced: 0, errors: ['Invalid claim label configuration'] }];
|
|
747
1011
|
}
|
|
748
|
-
}
|
|
749
|
-
// Add release comment
|
|
750
|
-
if (this.config.commentOnRelease) {
|
|
751
|
-
const claimantStr = claimant.type === 'human'
|
|
752
|
-
? `@${claimant.name.replace(/[^a-zA-Z0-9_-]/g, '')}`
|
|
753
|
-
: `Agent: ${(claimant.agentType || 'unknown').replace(/[^a-zA-Z0-9_-]/g, '')}`;
|
|
754
|
-
const comment = `🔓 **Issue released** by ${claimantStr}\n\n_This issue is now available for others to claim._`;
|
|
755
1012
|
try {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
1013
|
+
// Remove claim label
|
|
1014
|
+
if (this.config.syncLabels) {
|
|
1015
|
+
try {
|
|
1016
|
+
execFileSync('gh', [
|
|
1017
|
+
'issue', 'edit', String(issueNumber),
|
|
1018
|
+
'--repo', repo,
|
|
1019
|
+
'--remove-label', this.config.claimLabel
|
|
1020
|
+
], { stdio: 'ignore' });
|
|
1021
|
+
}
|
|
1022
|
+
catch (_b) {
|
|
1023
|
+
// Label might not exist
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
// Remove assignee if human claimant
|
|
1027
|
+
if (this.config.autoAssign && claimant.type === 'human') {
|
|
1028
|
+
if (isValidClaimantName(claimant.name)) {
|
|
1029
|
+
try {
|
|
1030
|
+
execFileSync('gh', [
|
|
1031
|
+
'issue', 'edit', String(issueNumber),
|
|
1032
|
+
'--repo', repo,
|
|
1033
|
+
'--remove-assignee', claimant.name
|
|
1034
|
+
], { stdio: 'ignore' });
|
|
1035
|
+
}
|
|
1036
|
+
catch (_c) {
|
|
1037
|
+
errors.push('Failed to remove assignee');
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
// Add release comment
|
|
1042
|
+
if (this.config.commentOnRelease) {
|
|
1043
|
+
claimantStr = claimant.type === 'human'
|
|
1044
|
+
? "@" + claimant.name.replace(/[^a-zA-Z0-9_-]/g, '')
|
|
1045
|
+
: "Agent: " + (claimant.agentType || 'unknown').replace(/[^a-zA-Z0-9_-]/g, '');
|
|
1046
|
+
comment = "\uD83D\uDD13 **Issue released** by " + claimantStr + "\n\n_This issue is now available for others to claim._";
|
|
1047
|
+
try {
|
|
1048
|
+
execFileSync('gh', [
|
|
1049
|
+
'issue', 'comment', String(issueNumber),
|
|
1050
|
+
'--repo', repo,
|
|
1051
|
+
'--body', comment
|
|
1052
|
+
], { stdio: 'ignore' });
|
|
1053
|
+
}
|
|
1054
|
+
catch (_d) {
|
|
1055
|
+
errors.push('Failed to add release comment');
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
return [2 /*return*/, { success: errors.length === 0, synced: 1, errors: errors }];
|
|
761
1059
|
}
|
|
762
|
-
catch {
|
|
763
|
-
errors.push(
|
|
1060
|
+
catch (error) {
|
|
1061
|
+
errors.push("GitHub release sync failed: " + sanitizeError(error));
|
|
1062
|
+
return [2 /*return*/, { success: false, synced: 0, errors: errors }];
|
|
764
1063
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
errors.push(`GitHub release sync failed: ${sanitizeError(error)}`);
|
|
770
|
-
return { success: false, synced: 0, errors };
|
|
771
|
-
}
|
|
772
|
-
}
|
|
1064
|
+
return [2 /*return*/];
|
|
1065
|
+
});
|
|
1066
|
+
});
|
|
1067
|
+
};
|
|
773
1068
|
/**
|
|
774
1069
|
* Bulk sync all local claims to GitHub
|
|
775
1070
|
*/
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1071
|
+
GitHubSync.prototype.syncAllClaimsToGitHub = function () {
|
|
1072
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
1073
|
+
var errors, synced, claims, _i, claims_1, claim, issueMatch, result;
|
|
1074
|
+
return __generator(this, function (_a) {
|
|
1075
|
+
switch (_a.label) {
|
|
1076
|
+
case 0:
|
|
1077
|
+
errors = [];
|
|
1078
|
+
synced = 0;
|
|
1079
|
+
return [4 /*yield*/, this.claimService.getAllClaims()];
|
|
1080
|
+
case 1:
|
|
1081
|
+
claims = _a.sent();
|
|
1082
|
+
_i = 0, claims_1 = claims;
|
|
1083
|
+
_a.label = 2;
|
|
1084
|
+
case 2:
|
|
1085
|
+
if (!(_i < claims_1.length)) return [3 /*break*/, 5];
|
|
1086
|
+
claim = claims_1[_i];
|
|
1087
|
+
issueMatch = claim.issueId.match(/(\d+)/);
|
|
1088
|
+
if (!issueMatch) return [3 /*break*/, 4];
|
|
1089
|
+
return [4 /*yield*/, this.claimOnGitHub(parseInt(issueMatch[1], 10), claim.claimant)];
|
|
1090
|
+
case 3:
|
|
1091
|
+
result = _a.sent();
|
|
1092
|
+
if (result.success)
|
|
1093
|
+
synced++;
|
|
1094
|
+
else
|
|
1095
|
+
errors.push.apply(errors, result.errors);
|
|
1096
|
+
_a.label = 4;
|
|
1097
|
+
case 4:
|
|
1098
|
+
_i++;
|
|
1099
|
+
return [3 /*break*/, 2];
|
|
1100
|
+
case 5: return [2 /*return*/, { success: errors.length === 0, synced: synced, errors: errors }];
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
});
|
|
1104
|
+
};
|
|
793
1105
|
/**
|
|
794
1106
|
* Get GitHub issues that are claimed locally
|
|
795
1107
|
*/
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
return
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
1108
|
+
GitHubSync.prototype.getClaimedGitHubIssues = function () {
|
|
1109
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
1110
|
+
var syncResult, localClaims, claimedIds;
|
|
1111
|
+
return __generator(this, function (_a) {
|
|
1112
|
+
switch (_a.label) {
|
|
1113
|
+
case 0: return [4 /*yield*/, this.syncIssues('open')];
|
|
1114
|
+
case 1:
|
|
1115
|
+
syncResult = _a.sent();
|
|
1116
|
+
if (!syncResult.success || !syncResult.issues)
|
|
1117
|
+
return [2 /*return*/, []];
|
|
1118
|
+
return [4 /*yield*/, this.claimService.getAllClaims()];
|
|
1119
|
+
case 2:
|
|
1120
|
+
localClaims = _a.sent();
|
|
1121
|
+
claimedIds = new Set(localClaims.map(function (c) {
|
|
1122
|
+
var match = c.issueId.match(/(\d+)/);
|
|
1123
|
+
return match ? parseInt(match[1], 10) : null;
|
|
1124
|
+
}).filter(Boolean));
|
|
1125
|
+
return [2 /*return*/, syncResult.issues.filter(function (issue) { return claimedIds.has(issue.number); })];
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
});
|
|
1129
|
+
};
|
|
1130
|
+
return GitHubSync;
|
|
1131
|
+
}());
|
|
1132
|
+
export { GitHubSync };
|
|
808
1133
|
// ============================================================================
|
|
809
1134
|
// Factory
|
|
810
1135
|
// ============================================================================
|