opencode-swarm 7.0.0-beta.1 → 7.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/LICENSE +21 -0
- package/README.md +1265 -40
- package/dist/__tests__/acknowledge-spec-drift.test.d.ts +1 -0
- package/dist/__tests__/cli-version.adversarial.test.d.ts +1 -0
- package/dist/__tests__/cli-version.test.d.ts +1 -0
- package/dist/__tests__/conflict-resolution.test.d.ts +1 -0
- package/dist/__tests__/convene-general-council.test.d.ts +10 -0
- package/dist/__tests__/critic_drift_verifier-whitelist.test.d.ts +1 -0
- package/dist/__tests__/critic_hallucination_verifier-whitelist.test.d.ts +1 -0
- package/dist/__tests__/disagreement-detector.test.d.ts +7 -0
- package/dist/__tests__/evidence-lock.adversarial.test.d.ts +8 -0
- package/dist/__tests__/evidence-lock.test.d.ts +6 -0
- package/dist/__tests__/gate-evidence.adversarial.test.d.ts +7 -0
- package/dist/__tests__/general-council-service.test.d.ts +7 -0
- package/dist/__tests__/lint-spec.test.d.ts +1 -0
- package/dist/__tests__/preflight-phase.test.d.ts +1 -0
- package/dist/__tests__/qa-gate-hardening.test.d.ts +12 -0
- package/dist/__tests__/req-coverage.test.d.ts +1 -0
- package/dist/__tests__/security-adversarial.test.d.ts +1 -0
- package/dist/__tests__/sounding-board-parser.test.d.ts +1 -0
- package/dist/__tests__/spec-hash.test.d.ts +1 -0
- package/dist/__tests__/spec-schema.test.d.ts +1 -0
- package/dist/__tests__/web-search-provider.test.d.ts +6 -0
- package/dist/__tests__/write-drift-evidence-requirement-coverage.test.d.ts +4 -0
- package/dist/adversarial-tests.test.d.ts +1 -0
- package/dist/agents/architect-permission.adversarial.test.d.ts +5 -0
- package/dist/agents/architect.commands-list.adversarial.test.d.ts +1 -0
- package/dist/agents/architect.commands-list.test.d.ts +1 -0
- package/dist/agents/architect.d.ts +57 -0
- package/dist/agents/architect.dark-matter.test.d.ts +1 -0
- package/dist/agents/architect.designer-gate.test.d.ts +1 -0
- package/dist/agents/coder.d.ts +2 -0
- package/dist/agents/council-member.d.ts +30 -0
- package/dist/agents/council-member.test.d.ts +8 -0
- package/dist/agents/council-moderator.d.ts +20 -0
- package/dist/agents/critic.d.ts +34 -0
- package/dist/agents/curator-agent.d.ts +14 -0
- package/dist/agents/designer.d.ts +2 -0
- package/dist/agents/docs.d.ts +2 -0
- package/dist/agents/explorer-consumer-contract.test.d.ts +1 -0
- package/dist/agents/explorer-role-boundary.test.d.ts +1 -0
- package/dist/agents/explorer.d.ts +5 -0
- package/dist/agents/index.d.ts +52 -0
- package/dist/agents/reviewer.d.ts +5 -0
- package/dist/agents/sme.d.ts +2 -0
- package/dist/agents/test-engineer.adversarial.test.d.ts +5 -0
- package/dist/agents/test-engineer.d.ts +2 -0
- package/dist/agents/test-engineer.security.test.d.ts +1 -0
- package/dist/background/circuit-breaker.d.ts +149 -0
- package/dist/background/event-bus.d.ts +60 -0
- package/dist/background/evidence-summary-integration.d.ts +73 -0
- package/dist/background/index.d.ts +22 -0
- package/dist/background/manager.d.ts +122 -0
- package/dist/background/plan-sync-worker.d.ts +122 -0
- package/dist/background/queue.d.ts +117 -0
- package/dist/background/status-artifact.d.ts +115 -0
- package/dist/background/trigger.d.ts +179 -0
- package/dist/background/trigger.vulnerability.test.d.ts +1 -0
- package/dist/background/worker.d.ts +92 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.js +31227 -11423
- package/dist/commands/acknowledge-spec-drift.d.ts +5 -0
- package/dist/commands/brainstorm.d.ts +13 -0
- package/dist/commands/brainstorm.test.d.ts +1 -0
- package/dist/commands/checkpoint.d.ts +5 -0
- package/dist/commands/close.d.ts +11 -0
- package/dist/commands/command-adapters.security.test.d.ts +14 -0
- package/dist/commands/commands.test.d.ts +1 -0
- package/dist/commands/config.d.ts +5 -0
- package/dist/commands/council.d.ts +17 -0
- package/dist/commands/council.test.d.ts +4 -0
- package/dist/commands/curate.test.d.ts +1 -0
- package/dist/commands/doctor.d.ts +17 -0
- package/dist/commands/full-auto-config-guard.test.d.ts +7 -0
- package/dist/commands/full-auto-discoverability.test.d.ts +8 -0
- package/dist/commands/full-auto-registration.test.d.ts +5 -0
- package/dist/commands/full-auto-sessionid.test.d.ts +5 -0
- package/dist/commands/full-auto.d.ts +10 -0
- package/dist/commands/full-auto.regression.test.d.ts +10 -0
- package/dist/commands/full-auto.test.d.ts +6 -0
- package/dist/commands/index.d.ts +50 -0
- package/dist/commands/index.help-text.test.d.ts +1 -0
- package/dist/commands/issue.d.ts +13 -0
- package/dist/{knowledge.d.ts → commands/knowledge.d.ts} +2 -0
- package/dist/commands/pr-review.d.ts +11 -0
- package/dist/commands/qa-gates.d.ts +15 -0
- package/dist/commands/qa-gates.test.d.ts +1 -0
- package/dist/commands/registry-documentation.test.d.ts +1 -0
- package/dist/commands/registry-type.test.d.ts +1 -0
- package/dist/commands/registry.d.ts +282 -0
- package/dist/commands/reset-session.d.ts +7 -0
- package/dist/commands/shortcut-routing.test.d.ts +11 -0
- package/dist/{sync-plan.d.ts → commands/sync-plan.d.ts} +3 -1
- package/dist/commands/turbo-registration.test.d.ts +5 -0
- package/dist/commands/turbo-sessionid.test.d.ts +5 -0
- package/dist/commands/turbo.regression.test.d.ts +11 -0
- package/dist/commands/turbo.test.d.ts +5 -0
- package/dist/config/agent-categories.d.ts +12 -0
- package/dist/config/cache-paths.d.ts +11 -0
- package/dist/config/constants.architect-whitelist.test.d.ts +1 -0
- package/dist/config/constants.d.ts +72 -0
- package/dist/config/evidence-schema.d.ts +1352 -0
- package/dist/config/index.d.ts +11 -0
- package/dist/{config.d.ts → config/loader.d.ts} +11 -6
- package/dist/config/plan-schema.d.ts +191 -0
- package/dist/config/schema.d.ts +1078 -0
- package/dist/config/spec-schema.d.ts +113 -0
- package/dist/context/role-filter.d.ts +27 -0
- package/dist/context/zone-classifier.d.ts +17 -0
- package/dist/council/__tests__/council-evidence-writer.adversarial.test.d.ts +6 -0
- package/dist/council/council-advisory.d.ts +46 -0
- package/dist/council/council-evidence-writer.d.ts +18 -0
- package/dist/council/council-service.d.ts +21 -0
- package/dist/council/criteria-store.d.ts +9 -0
- package/dist/council/disagreement-detector.d.ts +24 -0
- package/dist/council/general-council-advisory.d.ts +29 -0
- package/dist/council/general-council-service.d.ts +22 -0
- package/dist/council/general-council-types.d.ts +98 -0
- package/dist/council/types.d.ts +126 -0
- package/dist/council/web-search-provider.d.ts +35 -0
- package/dist/db/global-db.d.ts +22 -0
- package/dist/db/global-db.test.d.ts +7 -0
- package/dist/db/index.d.ts +13 -0
- package/dist/db/project-db.d.ts +40 -0
- package/dist/db/project-db.test.d.ts +4 -0
- package/dist/db/qa-gate-profile.d.ts +107 -0
- package/dist/db/qa-gate-profile.test.d.ts +4 -0
- package/dist/diff/__tests__/semantic-classifier.test.d.ts +1 -0
- package/dist/diff/__tests__/summary-generator.test.d.ts +1 -0
- package/dist/diff/ast-diff.d.ts +21 -0
- package/dist/diff/semantic-classifier.d.ts +59 -0
- package/dist/diff/summary-generator.d.ts +33 -0
- package/dist/environment/index.d.ts +3 -0
- package/dist/environment/profile.d.ts +50 -0
- package/dist/environment/prompt-renderer.d.ts +6 -0
- package/dist/evidence/index.d.ts +2 -0
- package/dist/evidence/lock.d.ts +36 -0
- package/dist/evidence/manager.d.ts +78 -0
- package/dist/gate-evidence.d.ts +69 -0
- package/dist/gate-evidence.test.d.ts +1 -0
- package/dist/git/branch.d.ts +70 -0
- package/dist/git/index.d.ts +22 -0
- package/dist/git/pr.d.ts +28 -0
- package/dist/graph/graph-builder.d.ts +39 -0
- package/dist/graph/graph-query.d.ts +42 -0
- package/dist/graph/graph-store.d.ts +27 -0
- package/dist/graph/import-extractor.d.ts +44 -0
- package/dist/graph/index.d.ts +16 -0
- package/dist/graph/symbol-extractor.d.ts +17 -0
- package/dist/graph/types.d.ts +84 -0
- package/dist/hooks/__tests__/semantic-diff-injection.test.d.ts +1 -0
- package/dist/hooks/adversarial-detector.d.ts +50 -0
- package/dist/hooks/agent-activity.d.ts +38 -0
- package/dist/hooks/co-change-suggester.d.ts +51 -0
- package/dist/hooks/compaction-customizer.d.ts +11 -0
- package/dist/hooks/conflict-resolution.d.ts +12 -0
- package/dist/hooks/context-budget.d.ts +34 -0
- package/dist/hooks/context-scoring.d.ts +70 -0
- package/dist/hooks/curator-drift-advisory.test.d.ts +1 -0
- package/dist/hooks/curator-drift.d.ts +30 -0
- package/dist/hooks/curator-llm-factory.d.ts +20 -0
- package/dist/hooks/curator-types.d.ts +103 -0
- package/dist/hooks/curator.d.ts +108 -0
- package/dist/hooks/dark-matter-detector.d.ts +38 -0
- package/dist/hooks/delegation-gate.d.ts +78 -0
- package/dist/hooks/delegation-gate.evidence.test.d.ts +4 -0
- package/dist/hooks/delegation-gate.getEvidenceTaskId.test.d.ts +20 -0
- package/dist/hooks/delegation-gate.plan-fallback-security.test.d.ts +13 -0
- package/dist/hooks/delegation-gate.plan-fallback.test.d.ts +5 -0
- package/dist/hooks/delegation-gate.seed-state.test.d.ts +1 -0
- package/dist/hooks/delegation-gate.turbo-evidence.test.d.ts +8 -0
- package/dist/hooks/delegation-gate.verify.test.d.ts +11 -0
- package/dist/hooks/delegation-ledger.d.ts +37 -0
- package/dist/hooks/delegation-ledger.test.d.ts +11 -0
- package/dist/hooks/delegation-sanitizer.d.ts +24 -0
- package/dist/hooks/delegation-tracker.d.ts +15 -0
- package/dist/hooks/diff-scope.d.ts +12 -0
- package/dist/hooks/diff-scope.test.d.ts +1 -0
- package/dist/hooks/extractors.d.ts +53 -0
- package/dist/hooks/full-auto-intercept.d.ts +77 -0
- package/dist/hooks/guardrails.d.ts +174 -0
- package/dist/hooks/hive-promoter.d.ts +40 -0
- package/dist/hooks/incremental-verify.d.ts +34 -0
- package/dist/hooks/incremental-verify.test.d.ts +1 -0
- package/dist/hooks/index.d.ts +20 -0
- package/dist/hooks/knowledge-curator.d.ts +27 -0
- package/dist/hooks/knowledge-injector.d.ts +20 -0
- package/dist/hooks/knowledge-migrator.d.ts +11 -0
- package/dist/hooks/knowledge-reader.d.ts +22 -0
- package/dist/hooks/knowledge-store.d.ts +30 -0
- package/dist/hooks/knowledge-types.d.ts +131 -0
- package/dist/hooks/knowledge-validator.d.ts +29 -0
- package/dist/hooks/loop-detector.d.ts +17 -0
- package/dist/hooks/loop-detector.test.d.ts +1 -0
- package/dist/hooks/message-priority.d.ts +105 -0
- package/dist/hooks/messages-transform.d.ts +13 -0
- package/dist/hooks/model-limits.d.ts +96 -0
- package/dist/hooks/normalize-tool-name.d.ts +25 -0
- package/dist/hooks/phase-monitor.d.ts +29 -0
- package/dist/hooks/pipeline-tracker.d.ts +41 -0
- package/dist/hooks/repo-graph-builder.d.ts +32 -0
- package/dist/hooks/repo-graph-injection.d.ts +45 -0
- package/dist/hooks/review-receipt.d.ts +189 -0
- package/dist/hooks/scope-guard-throw-behavior.test.d.ts +15 -0
- package/dist/hooks/scope-guard.adversarial.test.d.ts +1 -0
- package/dist/hooks/scope-guard.d.ts +43 -0
- package/dist/hooks/scope-guard.test.d.ts +14 -0
- package/dist/hooks/self-review.d.ts +14 -0
- package/dist/hooks/self-review.test.d.ts +14 -0
- package/dist/hooks/semantic-diff-injection.d.ts +24 -0
- package/dist/hooks/slop-detector.adversarial.test.d.ts +1 -0
- package/dist/hooks/slop-detector.d.ts +17 -0
- package/dist/hooks/slop-detector.test.d.ts +1 -0
- package/dist/hooks/spawn-helper.d.ts +5 -0
- package/dist/hooks/spawn-helper.test.d.ts +1 -0
- package/dist/hooks/steering-consumed.d.ts +30 -0
- package/dist/hooks/system-enhancer.d.ts +30 -0
- package/dist/hooks/tool-summarizer.d.ts +28 -0
- package/dist/hooks/trajectory-logger.d.ts +69 -0
- package/dist/hooks/utils.d.ts +20 -0
- package/dist/hooks/watchdog.integration.test.d.ts +9 -0
- package/dist/index.adversarial-bootstrap.test.d.ts +1 -0
- package/dist/index.bootstrap-adversarial.test.d.ts +1 -0
- package/dist/index.bootstrap-directory.test.d.ts +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +74704 -47714
- package/dist/knowledge/identity.d.ts +25 -0
- package/dist/knowledge/index.d.ts +2 -0
- package/dist/lang/detector.d.ts +20 -0
- package/dist/lang/framework-detector.d.ts +98 -0
- package/dist/lang/grammars/tree-sitter-dart.wasm +0 -0
- package/dist/lang/grammars/tree-sitter-kotlin.wasm +0 -0
- package/dist/lang/grammars/tree-sitter-swift.wasm +0 -0
- package/dist/lang/grammars/tree-sitter.wasm +0 -0
- package/dist/lang/index.d.ts +4 -0
- package/dist/lang/profiles.d.ts +72 -0
- package/dist/lang/registry.d.ts +24 -0
- package/dist/lang/runtime.d.ts +35 -0
- package/dist/model-fallback.adversarial.test.d.ts +22 -0
- package/dist/model-fallback.test.d.ts +12 -0
- package/dist/mutation/__tests__/engine.adversarial.test.d.ts +1 -0
- package/dist/mutation/__tests__/engine.test.d.ts +1 -0
- package/dist/mutation/__tests__/equivalence.adversarial.test.d.ts +1 -0
- package/dist/mutation/__tests__/equivalence.test.d.ts +1 -0
- package/dist/mutation/__tests__/gate.adversarial.test.d.ts +1 -0
- package/dist/mutation/__tests__/gate.test.d.ts +1 -0
- package/dist/mutation/__tests__/generator.test.d.ts +1 -0
- package/dist/mutation/engine.d.ts +47 -0
- package/dist/mutation/equivalence.d.ts +35 -0
- package/dist/mutation/gate.d.ts +28 -0
- package/dist/mutation/generator.d.ts +16 -0
- package/dist/output/agent-writer.d.ts +27 -0
- package/dist/output/index.d.ts +1 -0
- package/dist/parallel/dependency-graph.d.ts +34 -0
- package/dist/parallel/dispatcher/index.d.ts +12 -0
- package/dist/parallel/dispatcher/noop-dispatcher.d.ts +18 -0
- package/dist/parallel/dispatcher/noop-dispatcher.test.d.ts +10 -0
- package/dist/parallel/dispatcher/parallel-dispatcher.d.ts +18 -0
- package/dist/parallel/dispatcher/types.d.ts +33 -0
- package/dist/parallel/file-locks.d.ts +40 -0
- package/dist/parallel/index.d.ts +5 -0
- package/dist/parallel/meta-indexer.d.ts +32 -0
- package/dist/parallel/review-router.d.ts +29 -0
- package/dist/plan/checkpoint.d.ts +25 -0
- package/dist/plan/checkpoint.test.d.ts +1 -0
- package/dist/plan/index.d.ts +1 -0
- package/dist/plan/ledger-integrity.test.d.ts +5 -0
- package/dist/plan/ledger-snapshot-adversarial.test.d.ts +1 -0
- package/dist/plan/ledger.d.ts +286 -0
- package/dist/plan/ledger.test.d.ts +1 -0
- package/dist/plan/manager.cas-backoff.test.d.ts +10 -0
- package/dist/plan/manager.d.ts +90 -0
- package/dist/plan/manager.ledger-aware.test.d.ts +1 -0
- package/dist/plan/manager.loadplan-validation-guard.test.d.ts +13 -0
- package/dist/plan/manager.update-task-status.test.d.ts +1 -0
- package/dist/plan/migration-revert.regression.test.d.ts +8 -0
- package/dist/prm/__tests__/course-correction.test.d.ts +1 -0
- package/dist/prm/__tests__/escalation-queue-drain.test.d.ts +1 -0
- package/dist/prm/__tests__/escalation.test.d.ts +1 -0
- package/dist/prm/__tests__/index.test.d.ts +1 -0
- package/dist/prm/__tests__/integration.test.d.ts +1 -0
- package/dist/prm/__tests__/pattern-detector.test.d.ts +5 -0
- package/dist/prm/__tests__/replay.test.d.ts +1 -0
- package/dist/prm/__tests__/trajectory-store.test.d.ts +7 -0
- package/dist/prm/course-correction.d.ts +20 -0
- package/dist/prm/escalation.d.ts +73 -0
- package/dist/prm/index.d.ts +58 -0
- package/dist/prm/pattern-detector.d.ts +71 -0
- package/dist/prm/replay.d.ts +44 -0
- package/dist/prm/trajectory-store.d.ts +66 -0
- package/dist/prm/types.d.ts +120 -0
- package/dist/quality/index.d.ts +1 -0
- package/dist/quality/metrics.d.ts +25 -0
- package/dist/sast/rules/c.d.ts +9 -0
- package/dist/sast/rules/csharp.d.ts +9 -0
- package/dist/sast/rules/go.d.ts +9 -0
- package/dist/sast/rules/index.d.ts +72 -0
- package/dist/sast/rules/java.d.ts +9 -0
- package/dist/sast/rules/javascript.d.ts +9 -0
- package/dist/sast/rules/php.d.ts +9 -0
- package/dist/sast/rules/python.d.ts +9 -0
- package/dist/sast/semgrep.d.ts +68 -0
- package/dist/sast/semgrep.test.d.ts +1 -0
- package/dist/sbom/cyclonedx.d.ts +101 -0
- package/dist/sbom/detectors/dart.d.ts +7 -0
- package/dist/sbom/detectors/dotnet.d.ts +7 -0
- package/dist/sbom/detectors/go.d.ts +7 -0
- package/dist/sbom/detectors/index.d.ts +53 -0
- package/dist/sbom/detectors/java.d.ts +7 -0
- package/dist/sbom/detectors/nodejs.d.ts +7 -0
- package/dist/sbom/detectors/python.d.ts +7 -0
- package/dist/sbom/detectors/rust.d.ts +7 -0
- package/dist/sbom/detectors/swift.d.ts +7 -0
- package/dist/scope/scope-persistence.d.ts +109 -0
- package/dist/scope/scope-persistence.test.d.ts +13 -0
- package/dist/services/compaction-service.d.ts +28 -0
- package/dist/services/compaction-service.test.d.ts +1 -0
- package/dist/services/config-doctor.d.ts +125 -0
- package/dist/services/config-doctor.security.test.d.ts +1 -0
- package/dist/services/config-doctor.test.d.ts +1 -0
- package/dist/services/context-budget-service.d.ts +101 -0
- package/dist/services/decision-drift-analyzer.d.ts +96 -0
- package/dist/services/diagnose-service.d.ts +41 -0
- package/dist/services/evidence-service.d.ts +65 -0
- package/dist/services/evidence-summary-service.d.ts +75 -0
- package/dist/services/export-service.d.ts +30 -0
- package/dist/services/handoff-service.d.ts +74 -0
- package/dist/services/history-service.d.ts +35 -0
- package/dist/services/index.d.ts +13 -0
- package/dist/services/plan-service.d.ts +25 -0
- package/dist/services/preflight-integration.d.ts +38 -0
- package/dist/services/preflight-service.d.ts +62 -0
- package/dist/services/run-memory.d.ts +66 -0
- package/dist/services/status-service.d.ts +35 -0
- package/dist/services/status-service.turbo-indicator.test.d.ts +5 -0
- package/dist/services/tool-doctor.d.ts +26 -0
- package/dist/services/tool-doctor.test.d.ts +1 -0
- package/dist/services/version-check.d.ts +28 -0
- package/dist/services/warning-buffer.d.ts +9 -0
- package/dist/session/snapshot-reader.d.ts +37 -0
- package/dist/session/snapshot-writer.d.ts +115 -0
- package/dist/skills/index.d.ts +30 -0
- package/dist/state/agent-run-context.d.ts +24 -0
- package/dist/state.agent-run-context.test.d.ts +10 -0
- package/dist/state.d.ts +501 -1
- package/dist/state.rehydrate.test.d.ts +1 -0
- package/dist/state.rehydration-adversarial.test.d.ts +1 -0
- package/dist/state.rehydration-integration.test.d.ts +1 -0
- package/dist/state.session-restart.test.d.ts +7 -0
- package/dist/summaries/index.d.ts +2 -0
- package/dist/summaries/manager.d.ts +29 -0
- package/dist/summaries/summarizer.d.ts +38 -0
- package/dist/telemetry.d.ts +59 -0
- package/dist/telemetry.test.d.ts +1 -0
- package/dist/test-impact/__tests__/analyzer-import-fix.adversarial.test.d.ts +1 -0
- package/dist/test-impact/__tests__/analyzer-import-fix.test.d.ts +1 -0
- package/dist/test-impact/__tests__/analyzer.adversarial.test.d.ts +1 -0
- package/dist/test-impact/__tests__/analyzer.test.d.ts +1 -0
- package/dist/test-impact/__tests__/council-fixes.test.d.ts +1 -0
- package/dist/test-impact/__tests__/failure-classifier.adversarial.test.d.ts +1 -0
- package/dist/test-impact/__tests__/failure-classifier.test.d.ts +1 -0
- package/dist/test-impact/__tests__/flaky-detector.adversarial.test.d.ts +1 -0
- package/dist/test-impact/__tests__/flaky-detector.test.d.ts +1 -0
- package/dist/test-impact/__tests__/history-store.adversarial.test.d.ts +1 -0
- package/dist/test-impact/__tests__/history-store.test.d.ts +1 -0
- package/dist/test-impact/__tests__/test-impact.adversarial.test.d.ts +1 -0
- package/dist/test-impact/__tests__/test-impact.test.d.ts +1 -0
- package/dist/test-impact/analyzer.d.ts +9 -0
- package/dist/test-impact/failure-classifier.d.ts +26 -0
- package/dist/test-impact/flaky-detector.d.ts +14 -0
- package/dist/test-impact/history-store.d.ts +15 -0
- package/dist/tools/__tests__/barrel-exports.test.d.ts +1 -0
- package/dist/tools/__tests__/diff-ast-fallback.test.d.ts +1 -0
- package/dist/tools/__tests__/diff-markdown-summary.test.d.ts +1 -0
- package/dist/tools/__tests__/diff-semantic.test.d.ts +1 -0
- package/dist/tools/__tests__/diff-summary.adversarial.test.d.ts +1 -0
- package/dist/tools/__tests__/diff-summary.test.d.ts +1 -0
- package/dist/tools/__tests__/mutation-test.adversarial.test.d.ts +1 -0
- package/dist/tools/__tests__/mutation-test.sourcefiles.test.d.ts +1 -0
- package/dist/tools/__tests__/mutation-test.test.d.ts +1 -0
- package/dist/tools/__tests__/test-runner-history.test.d.ts +1 -0
- package/dist/tools/__tests__/test-runner-impact.adversarial.test.d.ts +1 -0
- package/dist/tools/__tests__/test-runner-impact.test.d.ts +1 -0
- package/dist/tools/__tests__/test-runner-source-files.test.d.ts +1 -0
- package/dist/tools/barrel-export-check-gate-status.test.d.ts +6 -0
- package/dist/tools/batch-symbols.d.ts +24 -0
- package/dist/tools/batch-symbols.test.d.ts +1 -0
- package/dist/tools/build-check.d.ts +50 -0
- package/dist/tools/check-gate-status.adversarial.test.d.ts +1 -0
- package/dist/tools/check-gate-status.d.ts +7 -0
- package/dist/tools/check-gate-status.gates.test.d.ts +1 -0
- package/dist/tools/check-gate-status.plugin-registration.test.d.ts +1 -0
- package/dist/tools/checkpoint.d.ts +2 -0
- package/dist/tools/co-change-analyzer.d.ts +45 -0
- package/dist/tools/completion-verify.d.ts +25 -0
- package/dist/tools/complexity-hotspots.d.ts +2 -0
- package/dist/tools/convene-council.d.ts +53 -0
- package/dist/tools/convene-general-council.d.ts +25 -0
- package/dist/{create-tool.d.ts → tools/create-tool.d.ts} +13 -1
- package/dist/tools/curator-analyze.d.ts +7 -0
- package/dist/tools/curator-analyze.test.d.ts +1 -0
- package/dist/tools/declare-council-criteria.d.ts +14 -0
- package/dist/tools/declare-scope.d.ts +50 -0
- package/dist/tools/diff-summary.d.ts +12 -0
- package/dist/tools/diff.d.ts +24 -0
- package/dist/tools/doc-scan.d.ts +38 -0
- package/dist/tools/domain-detector.d.ts +6 -0
- package/dist/tools/evidence-check.d.ts +8 -0
- package/dist/tools/file-extractor.d.ts +9 -0
- package/dist/tools/generate-mutants.d.ts +15 -0
- package/dist/tools/get-approved-plan.d.ts +55 -0
- package/dist/tools/get-qa-gate-profile.d.ts +27 -0
- package/dist/tools/gitingest.d.ts +18 -0
- package/dist/tools/imports.d.ts +5 -0
- package/dist/tools/index.d.ts +66 -0
- package/dist/tools/knowledge-add.d.ts +2 -0
- package/dist/tools/knowledge-query.d.ts +5 -0
- package/dist/tools/knowledge-recall.d.ts +2 -0
- package/dist/tools/knowledge-remove.d.ts +2 -0
- package/dist/tools/knowledge-tools.integration.test.d.ts +1 -0
- package/dist/tools/lint-spec.d.ts +2 -0
- package/dist/tools/lint.d.ts +63 -0
- package/dist/tools/mutation-test.d.ts +2 -0
- package/dist/tools/mutation-test.security.test.d.ts +1 -0
- package/dist/tools/phase-complete.d.ts +25 -0
- package/dist/tools/pkg-audit.d.ts +2 -0
- package/dist/tools/placeholder-scan.d.ts +28 -0
- package/dist/tools/plugin-registration-adversarial.test.d.ts +1 -0
- package/dist/tools/pre-check-batch.d.ts +89 -0
- package/dist/tools/quality-budget.d.ts +26 -0
- package/dist/tools/repo-graph.d.ts +226 -0
- package/dist/tools/repo-map.d.ts +2 -0
- package/dist/tools/req-coverage.d.ts +47 -0
- package/dist/tools/resolve-working-directory.d.ts +35 -0
- package/dist/tools/resolve-working-directory.test.d.ts +1 -0
- package/dist/tools/retrieve-summary.d.ts +2 -0
- package/dist/tools/sast-baseline.d.ts +126 -0
- package/dist/tools/sast-scan.d.ts +87 -0
- package/dist/tools/save-plan.d.ts +95 -0
- package/dist/tools/save-plan.subdirectory-rejection.test.d.ts +1 -0
- package/dist/tools/sbom-generate.d.ts +26 -0
- package/dist/tools/schema-drift.d.ts +2 -0
- package/dist/tools/search.adversarial.test.d.ts +1 -0
- package/dist/tools/search.d.ts +29 -0
- package/dist/tools/search.test.d.ts +1 -0
- package/dist/tools/secretscan.d.ts +35 -0
- package/dist/tools/set-qa-gates.d.ts +40 -0
- package/dist/tools/suggest-patch.adversarial.test.d.ts +1 -0
- package/dist/tools/suggest-patch.d.ts +37 -0
- package/dist/tools/suggest-patch.test.d.ts +1 -0
- package/dist/tools/symbols.d.ts +21 -0
- package/dist/tools/syntax-check.d.ts +37 -0
- package/dist/tools/test-impact.d.ts +2 -0
- package/dist/tools/test-runner.d.ts +86 -0
- package/dist/tools/test-runner.security-adversarial.test.d.ts +5 -0
- package/dist/tools/todo-extract.d.ts +2 -0
- package/dist/tools/tool-names.d.ts +10 -0
- package/dist/tools/update-task-status.adversarial.test.d.ts +13 -0
- package/dist/tools/update-task-status.d.ts +114 -0
- package/dist/tools/update-task-status.gates.test.d.ts +1 -0
- package/dist/tools/update-task-status.test.d.ts +1 -0
- package/dist/tools/update-task-status.turbo-bypass.test.d.ts +1 -0
- package/dist/tools/verify-six-tools-registration.test.d.ts +9 -0
- package/dist/tools/web-search.d.ts +13 -0
- package/dist/tools/write-drift-evidence.d.ts +31 -0
- package/dist/tools/write-hallucination-evidence.d.ts +30 -0
- package/dist/tools/write-mutation-evidence.d.ts +34 -0
- package/dist/tools/write-mutation-evidence.test.d.ts +1 -0
- package/dist/tools/write-retro.d.ts +55 -0
- package/dist/transient-retry.test.d.ts +10 -0
- package/dist/types/delegation.d.ts +24 -0
- package/dist/types/events.d.ts +125 -0
- package/dist/utils/errors.d.ts +33 -0
- package/dist/utils/gitignore-warning.d.ts +17 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/logger.d.ts +3 -0
- package/dist/utils/merge.d.ts +5 -0
- package/dist/utils/path-security.d.ts +36 -0
- package/dist/utils/regex.d.ts +30 -0
- package/dist/utils/spec-hash.d.ts +15 -0
- package/dist/utils/tool-output.d.ts +12 -0
- package/dist/validation/task-id.d.ts +43 -0
- package/package.json +21 -14
- package/dist/architect.d.ts +0 -7
- package/dist/checkpoint.d.ts +0 -7
- package/dist/co-change-analyzer.d.ts +0 -1
- package/dist/compat.d.ts +0 -12
- package/dist/config-doctor.d.ts +0 -1
- package/dist/detector.d.ts +0 -7
- package/dist/diagnose-service.d.ts +0 -1
- package/dist/doctor.d.ts +0 -5
- package/dist/evidence-schema.d.ts +0 -2
- package/dist/evidence-service.d.ts +0 -1
- package/dist/export-service.d.ts +0 -1
- package/dist/handoff-service.d.ts +0 -1
- package/dist/history-service.d.ts +0 -1
- package/dist/hive-promoter.d.ts +0 -2
- package/dist/knowledge-migrator.d.ts +0 -2
- package/dist/knowledge-store.d.ts +0 -1
- package/dist/knowledge-types.d.ts +0 -1
- package/dist/knowledge-validator.d.ts +0 -2
- package/dist/loader.d.ts +0 -1
- package/dist/manager.d.ts +0 -1
- package/dist/models.d.ts +0 -1
- package/dist/plan-service.d.ts +0 -1
- package/dist/preflight-service.d.ts +0 -1
- package/dist/profiles.d.ts +0 -7
- package/dist/register.d.ts +0 -36
- package/dist/schema.d.ts +0 -2
- package/dist/snapshot-writer.d.ts +0 -1
- package/dist/status-service.d.ts +0 -15
- package/dist/telemetry/src/events.d.ts +0 -308
- package/dist/telemetry/src/guards.d.ts +0 -14
- package/dist/telemetry/src/index.d.ts +0 -4
- package/dist/telemetry/src/version.d.ts +0 -1
- package/dist/utils.d.ts +0 -1
- package/dist/write-retro.d.ts +0 -1
- /package/dist/{discovery.d.ts → build/discovery.d.ts} +0 -0
- /package/dist/{agents.d.ts → commands/agents.d.ts} +0 -0
- /package/dist/{analyze.d.ts → commands/analyze.d.ts} +0 -0
- /package/dist/{archive.d.ts → commands/archive.d.ts} +0 -0
- /package/dist/{benchmark.d.ts → commands/benchmark.d.ts} +0 -0
- /package/dist/{clarify.d.ts → commands/clarify.d.ts} +0 -0
- /package/dist/{curate.d.ts → commands/curate.d.ts} +0 -0
- /package/dist/{dark-matter.d.ts → commands/dark-matter.d.ts} +0 -0
- /package/dist/{diagnose.d.ts → commands/diagnose.d.ts} +0 -0
- /package/dist/{evidence.d.ts → commands/evidence.d.ts} +0 -0
- /package/dist/{export.d.ts → commands/export.d.ts} +0 -0
- /package/dist/{handoff.d.ts → commands/handoff.d.ts} +0 -0
- /package/dist/{history.d.ts → commands/history.d.ts} +0 -0
- /package/dist/{plan.d.ts → commands/plan.d.ts} +0 -0
- /package/dist/{preflight.d.ts → commands/preflight.d.ts} +0 -0
- /package/dist/{promote.d.ts → commands/promote.d.ts} +0 -0
- /package/dist/{reset.d.ts → commands/reset.d.ts} +0 -0
- /package/dist/{retrieve.d.ts → commands/retrieve.d.ts} +0 -0
- /package/dist/{rollback.d.ts → commands/rollback.d.ts} +0 -0
- /package/dist/{simulate.d.ts → commands/simulate.d.ts} +0 -0
- /package/dist/{specify.d.ts → commands/specify.d.ts} +0 -0
- /package/dist/{status.d.ts → commands/status.d.ts} +0 -0
- /package/dist/{turbo.d.ts → commands/turbo.d.ts} +0 -0
- /package/dist/{write_retro.d.ts → commands/write-retro.d.ts} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escalation Tracker Module
|
|
3
|
+
* Implements a 3-strike protocol for pattern detection escalation
|
|
4
|
+
*/
|
|
5
|
+
import type { CourseCorrection, EscalationState, PatternMatch } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Creates a default EscalationState with all counters reset and flags cleared.
|
|
8
|
+
* Exported for testing purposes.
|
|
9
|
+
*
|
|
10
|
+
* @returns A fresh EscalationState with default values
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDefaultEscalationState(): EscalationState;
|
|
13
|
+
/**
|
|
14
|
+
* EscalationTracker
|
|
15
|
+
*
|
|
16
|
+
* Tracks pattern detection counts per session and implements a 3-strike escalation protocol:
|
|
17
|
+
* - Level 1 (1st detection): Guidance via pendingAdvisoryMessages
|
|
18
|
+
* - Level 2 (2nd detection): Stronger guidance + architect alert via telemetry
|
|
19
|
+
* - Level 3 (3rd+ detection): Hard stop flag that is read by messagesTransform
|
|
20
|
+
*
|
|
21
|
+
* All methods are safe and never throw errors.
|
|
22
|
+
*/
|
|
23
|
+
export declare class EscalationTracker {
|
|
24
|
+
private readonly _sessionId;
|
|
25
|
+
private _state;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new EscalationTracker for the given session.
|
|
28
|
+
*
|
|
29
|
+
* @param sessionId - The session identifier
|
|
30
|
+
* @param initialState - Optional initial state to restore (for session resumption)
|
|
31
|
+
*/
|
|
32
|
+
constructor(sessionId: string, initialState?: EscalationState);
|
|
33
|
+
/**
|
|
34
|
+
* Records a pattern detection and determines the escalation level.
|
|
35
|
+
* Updates internal state based on the 3-strike protocol.
|
|
36
|
+
*
|
|
37
|
+
* @param match - The pattern match to record
|
|
38
|
+
* @returns An object containing the escalation level, correction (if any), and hard stop flag
|
|
39
|
+
*/
|
|
40
|
+
recordDetection(match: PatternMatch): {
|
|
41
|
+
level: number;
|
|
42
|
+
correction: CourseCorrection | null;
|
|
43
|
+
hardStop: boolean;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Returns the current escalation state.
|
|
47
|
+
*
|
|
48
|
+
* @returns The current EscalationState (reference, not a copy)
|
|
49
|
+
*/
|
|
50
|
+
getState(): EscalationState;
|
|
51
|
+
/**
|
|
52
|
+
* Resets all escalation counts and flags to their default values.
|
|
53
|
+
* Clears pattern counts, corrections pending, and all flags.
|
|
54
|
+
*/
|
|
55
|
+
reset(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Returns all pending course corrections.
|
|
58
|
+
*
|
|
59
|
+
* @returns Array of pending CourseCorrection objects
|
|
60
|
+
*/
|
|
61
|
+
getPendingCorrections(): CourseCorrection[];
|
|
62
|
+
/**
|
|
63
|
+
* Clears all pending course corrections.
|
|
64
|
+
*/
|
|
65
|
+
clearPendingCorrections(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Returns whether a hard stop is pending.
|
|
68
|
+
* This flag is read by messagesTransform to halt agent execution.
|
|
69
|
+
*
|
|
70
|
+
* @returns true if hard stop is pending, false otherwise
|
|
71
|
+
*/
|
|
72
|
+
isHardStopPending(): boolean;
|
|
73
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRM (Process Remediation Manager) Facade
|
|
3
|
+
*
|
|
4
|
+
* Integration layer that wires together all PRM components:
|
|
5
|
+
* - Trajectory logging via trajectory-store
|
|
6
|
+
* - Pattern detection via pattern-detector
|
|
7
|
+
* - Course correction via course-correction
|
|
8
|
+
* - Escalation tracking via escalation
|
|
9
|
+
*
|
|
10
|
+
* This module provides the createPrmHook factory that returns the toolAfter
|
|
11
|
+
* handler used by the swarm hook system. PRM replaces loop-detector.ts for
|
|
12
|
+
* repetition_loop detection, but loop-detector.ts is kept as a fast circuit
|
|
13
|
+
* breaker for backward compatibility.
|
|
14
|
+
*/
|
|
15
|
+
export { formatCourseCorrectionForInjection, generateCourseCorrection, } from './course-correction';
|
|
16
|
+
export { createDefaultEscalationState, EscalationTracker } from './escalation';
|
|
17
|
+
export { detectContextThrash, detectExpansionDrift, detectPatterns, detectPingPong, detectRepetitionLoop, detectStuckOnTest, } from './pattern-detector';
|
|
18
|
+
export type { CourseCorrection, EscalationState, PatternDetectionResult, PatternMatch, PatternSeverity, PatternType, PrmConfig, TaxonomyCategory, TrajectoryEntry, } from './types';
|
|
19
|
+
import type { PrmConfig } from './types';
|
|
20
|
+
/**
|
|
21
|
+
* Context passed to toolAfter handler
|
|
22
|
+
*/
|
|
23
|
+
interface ToolAfterContext {
|
|
24
|
+
sessionID: string;
|
|
25
|
+
tool?: string;
|
|
26
|
+
args_summary?: string;
|
|
27
|
+
result?: 'success' | 'failure' | 'pending';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* PRM hook interface returned by createPrmHook
|
|
31
|
+
*/
|
|
32
|
+
interface PrmHook {
|
|
33
|
+
toolAfter: (context: ToolAfterContext) => Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a PRM hook for the given configuration.
|
|
37
|
+
*
|
|
38
|
+
* The returned toolAfter handler:
|
|
39
|
+
* - Runs after each tool execution when PRM is enabled
|
|
40
|
+
* - Reads the session trajectory
|
|
41
|
+
* - Runs pattern detection
|
|
42
|
+
* - Generates course corrections for detected patterns
|
|
43
|
+
* - Updates session state with corrections and escalation level
|
|
44
|
+
* - Emits telemetry events
|
|
45
|
+
*
|
|
46
|
+
* This function is non-blocking: errors are caught and logged, never thrown.
|
|
47
|
+
*
|
|
48
|
+
* @param config - PRM configuration (enabled, thresholds, etc.)
|
|
49
|
+
* @param directory - Project directory for trajectory storage
|
|
50
|
+
* @returns PrmHook with toolAfter handler
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const prmHook = createPrmHook(prmConfig, directory);
|
|
55
|
+
* // Wire prmHook.toolAfter into your tool.execute.after hook
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function createPrmHook(config: PrmConfig, directory: string): PrmHook;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRM Pattern Detector
|
|
3
|
+
* Rule-based pattern detection for trajectory analysis
|
|
4
|
+
*/
|
|
5
|
+
import type { PatternDetectionResult, PatternMatch, PrmConfig, TrajectoryEntry } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Sanitize a string to prevent prompt injection attacks.
|
|
8
|
+
* Removes newlines, carriage returns, backticks, and common injection patterns.
|
|
9
|
+
* Limits length to prevent overflow.
|
|
10
|
+
*
|
|
11
|
+
* @param input - The string to sanitize
|
|
12
|
+
* @returns Sanitized string safe for embedding in prompts
|
|
13
|
+
*/
|
|
14
|
+
export declare function sanitizeString(input: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Detect repetition_loop pattern
|
|
17
|
+
* Same agent targets same file with same action within N steps
|
|
18
|
+
*
|
|
19
|
+
* @param trajectory - Array of trajectory entries
|
|
20
|
+
* @param config - PRM configuration
|
|
21
|
+
* @returns Array of detected pattern matches
|
|
22
|
+
*/
|
|
23
|
+
export declare function detectRepetitionLoop(trajectory: TrajectoryEntry[], config: PrmConfig): PatternMatch[];
|
|
24
|
+
/**
|
|
25
|
+
* Detect ping_pong pattern
|
|
26
|
+
* Agent A delegates to B, B completes, A delegates to B again
|
|
27
|
+
* Alternating agent patterns with same target
|
|
28
|
+
*
|
|
29
|
+
* @param trajectory - Array of trajectory entries
|
|
30
|
+
* @param config - PRM configuration
|
|
31
|
+
* @returns Array of detected pattern matches
|
|
32
|
+
*/
|
|
33
|
+
export declare function detectPingPong(trajectory: TrajectoryEntry[], config: PrmConfig): PatternMatch[];
|
|
34
|
+
/**
|
|
35
|
+
* Detect expansion_drift pattern
|
|
36
|
+
* Successive plans grow in scope (unique targets increase >50%)
|
|
37
|
+
*
|
|
38
|
+
* @param trajectory - Array of trajectory entries
|
|
39
|
+
* @param config - PRM configuration
|
|
40
|
+
* @returns Array of detected pattern matches
|
|
41
|
+
*/
|
|
42
|
+
export declare function detectExpansionDrift(trajectory: TrajectoryEntry[], config: PrmConfig): PatternMatch[];
|
|
43
|
+
/**
|
|
44
|
+
* Detect stuck_on_test pattern
|
|
45
|
+
* Edit -> test fail -> edit same file cycle
|
|
46
|
+
*
|
|
47
|
+
* @param trajectory - Array of trajectory entries
|
|
48
|
+
* @param config - PRM configuration
|
|
49
|
+
* @returns Array of detected pattern matches
|
|
50
|
+
*/
|
|
51
|
+
export declare function detectStuckOnTest(trajectory: TrajectoryEntry[], config: PrmConfig): PatternMatch[];
|
|
52
|
+
/**
|
|
53
|
+
* Detect context_thrash pattern
|
|
54
|
+
* Agent requests increasingly large file sets (monotonic increase in unique targets)
|
|
55
|
+
* Context thrash is detected when the agent keeps introducing NEW targets without
|
|
56
|
+
* revisiting old ones - i.e., the unique target count increases for consecutive steps
|
|
57
|
+
* with NO plateaus in between.
|
|
58
|
+
*
|
|
59
|
+
* @param trajectory - Array of trajectory entries
|
|
60
|
+
* @param config - PRM configuration
|
|
61
|
+
* @returns Array of detected pattern matches
|
|
62
|
+
*/
|
|
63
|
+
export declare function detectContextThrash(trajectory: TrajectoryEntry[], config: PrmConfig): PatternMatch[];
|
|
64
|
+
/**
|
|
65
|
+
* Run all pattern detectors on a trajectory
|
|
66
|
+
*
|
|
67
|
+
* @param trajectory - Array of trajectory entries to analyze
|
|
68
|
+
* @param config - PRM configuration with thresholds
|
|
69
|
+
* @returns PatternDetectionResult with all matches and timing info
|
|
70
|
+
*/
|
|
71
|
+
export declare function detectPatterns(trajectory: TrajectoryEntry[], config: PrmConfig, lastProcessedStep?: number): PatternDetectionResult;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRM Replay System
|
|
3
|
+
*
|
|
4
|
+
* Provides deterministic replay functionality for PRM (Process Remediation Manager).
|
|
5
|
+
* Records all LLM requests/responses and tool I/O during a run for replay.
|
|
6
|
+
*
|
|
7
|
+
* Replay artifacts are stored in `.swarm/replays/{sessionId}-{timestamp}.jsonl`
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Entry types for replay recording
|
|
11
|
+
*/
|
|
12
|
+
export type ReplayEntryType = 'llm_request' | 'llm_response' | 'tool_call' | 'tool_result' | 'pattern_detected' | 'course_correction' | 'escalation' | 'hard_stop';
|
|
13
|
+
/**
|
|
14
|
+
* A single entry in the replay log
|
|
15
|
+
*/
|
|
16
|
+
export interface ReplayEntry {
|
|
17
|
+
/** ISO 8601 timestamp when entry was recorded */
|
|
18
|
+
timestamp: string;
|
|
19
|
+
/** Session identifier */
|
|
20
|
+
sessionID: string;
|
|
21
|
+
/** Type of replay entry */
|
|
22
|
+
type: ReplayEntryType;
|
|
23
|
+
/** Entry data payload */
|
|
24
|
+
data: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Initializes replay recording for a session.
|
|
28
|
+
* Creates the replay directory if it doesn't exist.
|
|
29
|
+
* Non-blocking: errors are caught and logged, returns null on failure.
|
|
30
|
+
*
|
|
31
|
+
* @param sessionID - Session identifier
|
|
32
|
+
* @param directory - Project directory
|
|
33
|
+
* @returns Path to the replay artifact file, or null on error
|
|
34
|
+
*/
|
|
35
|
+
export declare function startReplayRecording(sessionID: string, directory: string): Promise<string | null>;
|
|
36
|
+
/**
|
|
37
|
+
* Appends a ReplayEntry to the replay artifact file.
|
|
38
|
+
* Non-blocking: errors are caught and logged, never thrown.
|
|
39
|
+
*
|
|
40
|
+
* @param artifactPath - Path to the replay artifact file
|
|
41
|
+
* @param sessionID - Session identifier
|
|
42
|
+
* @param entry - Entry to record (without timestamp/sessionID)
|
|
43
|
+
*/
|
|
44
|
+
export declare function recordReplayEntry(artifactPath: string, sessionID: string, entry: Omit<ReplayEntry, 'timestamp' | 'sessionID'>): Promise<void>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TRAJECTORY STORE (Session-Level)
|
|
3
|
+
*
|
|
4
|
+
* Per-session trajectory storage for PRM pattern detection.
|
|
5
|
+
* Writes to .swarm/trajectories/{sessionId}.jsonl
|
|
6
|
+
*
|
|
7
|
+
* Coexists with task-level trajectory-logger.ts which writes to
|
|
8
|
+
* .swarm/evidence/{taskId}/trajectory.jsonl for audit/evidence.
|
|
9
|
+
*/
|
|
10
|
+
import type { TrajectoryEntry } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Returns cached trajectory entries for a session (empty array if not cached).
|
|
13
|
+
*/
|
|
14
|
+
export declare function getInMemoryTrajectory(sessionId: string): TrajectoryEntry[];
|
|
15
|
+
/**
|
|
16
|
+
* Clears trajectory cache (for test isolation or session cleanup).
|
|
17
|
+
*/
|
|
18
|
+
export declare function clearTrajectoryCache(sessionId?: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Appends a single TrajectoryEntry to the session's trajectory file.
|
|
21
|
+
*
|
|
22
|
+
* @param sessionId - Session identifier
|
|
23
|
+
* @param entry - Trajectory entry to append
|
|
24
|
+
* @param directory - Base directory (workspace root)
|
|
25
|
+
* @param maxLines - Maximum lines before in-memory cache trimming (default 1000)
|
|
26
|
+
*/
|
|
27
|
+
export declare function appendTrajectoryEntry(sessionId: string, entry: TrajectoryEntry, directory: string, maxLines?: number): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Reads all TrajectoryEntry records from a session's trajectory file.
|
|
30
|
+
*
|
|
31
|
+
* @param sessionId - Session identifier
|
|
32
|
+
* @param directory - Base directory (workspace root)
|
|
33
|
+
* @returns Array of trajectory entries (empty array if file doesn't exist)
|
|
34
|
+
*/
|
|
35
|
+
export declare function readTrajectory(sessionId: string, directory: string): Promise<TrajectoryEntry[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Alias for readTrajectory - retrieves trajectory entries for a session.
|
|
38
|
+
*
|
|
39
|
+
* @param sessionId - Session identifier
|
|
40
|
+
* @param directory - Base directory (workspace root)
|
|
41
|
+
* @returns Array of trajectory entries
|
|
42
|
+
*/
|
|
43
|
+
export declare function getTrajectoryForSession(sessionId: string, directory: string): Promise<TrajectoryEntry[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Truncates the trajectory file to the newest half if lines exceed maxLines.
|
|
46
|
+
*
|
|
47
|
+
* @param sessionId - Session identifier
|
|
48
|
+
* @param directory - Base directory (workspace root)
|
|
49
|
+
* @param maxLines - Maximum number of lines to retain
|
|
50
|
+
*/
|
|
51
|
+
export declare function truncateTrajectoryIfNeeded(sessionId: string, directory: string, maxLines: number): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the highest step number in the session's trajectory.
|
|
54
|
+
* Used to determine the next step number when appending.
|
|
55
|
+
*
|
|
56
|
+
* @param sessionId - Session identifier
|
|
57
|
+
* @param directory - Base directory (workspace root)
|
|
58
|
+
* @returns Highest step number, or 0 if no trajectory exists
|
|
59
|
+
*/
|
|
60
|
+
export declare function getCurrentStep(sessionId: string, directory: string): Promise<number>;
|
|
61
|
+
/**
|
|
62
|
+
* Deletes trajectory and replay files older than maxAgeDays.
|
|
63
|
+
* Runs against .swarm/trajectories/ and .swarm/replays/ directories.
|
|
64
|
+
* Non-blocking: errors logged, not thrown.
|
|
65
|
+
*/
|
|
66
|
+
export declare function cleanupOldTrajectoryFiles(directory: string, maxAgeDays?: number): Promise<void>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRM (Prompt Response Monitoring) Type Definitions
|
|
3
|
+
* Core types for trajectory logging, pattern detection, and course correction
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* All detectable pattern types in the SWE-PRM system
|
|
7
|
+
*/
|
|
8
|
+
export type PatternType = 'repetition_loop' | 'ping_pong' | 'expansion_drift' | 'stuck_on_test' | 'context_thrash';
|
|
9
|
+
/**
|
|
10
|
+
* SWE-PRM taxonomy classification for categorizing pattern root causes
|
|
11
|
+
*/
|
|
12
|
+
export type TaxonomyCategory = 'specification_error' | 'reasoning_error' | 'coordination_error';
|
|
13
|
+
/**
|
|
14
|
+
* Severity levels for pattern detection responses
|
|
15
|
+
*/
|
|
16
|
+
export type PatternSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
17
|
+
/**
|
|
18
|
+
* A single trajectory log entry recording one agent action
|
|
19
|
+
*/
|
|
20
|
+
export interface TrajectoryEntry {
|
|
21
|
+
/** Sequential step number (1-indexed) */
|
|
22
|
+
step: number;
|
|
23
|
+
/** Agent name */
|
|
24
|
+
agent: string;
|
|
25
|
+
/** Action type (plan, edit, review, test, delegate, etc.) */
|
|
26
|
+
action: string;
|
|
27
|
+
/** File or task being targeted */
|
|
28
|
+
target: string;
|
|
29
|
+
/** Human-readable description of intended outcome */
|
|
30
|
+
intent: string;
|
|
31
|
+
/** ISO 8601 timestamp */
|
|
32
|
+
timestamp: string;
|
|
33
|
+
/** Outcome of the action */
|
|
34
|
+
result: 'success' | 'failure' | 'pending';
|
|
35
|
+
/** Optional: tool name (for compatibility with existing logger) */
|
|
36
|
+
tool?: string;
|
|
37
|
+
/** Optional: tool arguments summary */
|
|
38
|
+
args_summary?: string;
|
|
39
|
+
/** Optional: elapsed time in milliseconds */
|
|
40
|
+
elapsed_ms?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Result of pattern detection indicating a detected problematic trajectory pattern
|
|
44
|
+
*/
|
|
45
|
+
export interface PatternMatch {
|
|
46
|
+
/** The type of pattern detected */
|
|
47
|
+
pattern: PatternType;
|
|
48
|
+
/** Severity level of the detected pattern */
|
|
49
|
+
severity: PatternSeverity;
|
|
50
|
+
/** Taxonomy category for the pattern */
|
|
51
|
+
category: TaxonomyCategory;
|
|
52
|
+
/** Start and end step numbers of the pattern occurrence */
|
|
53
|
+
stepRange: [number, number];
|
|
54
|
+
/** Human-readable description of the pattern */
|
|
55
|
+
description: string;
|
|
56
|
+
/** Agents involved in the pattern */
|
|
57
|
+
affectedAgents: string[];
|
|
58
|
+
/** Files/tasks involved in the pattern */
|
|
59
|
+
affectedTargets: string[];
|
|
60
|
+
/** How many times this pattern has been detected */
|
|
61
|
+
occurrenceCount: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Structured guidance message for steering agent behavior
|
|
65
|
+
*/
|
|
66
|
+
export interface CourseCorrection {
|
|
67
|
+
/** Alert header with pattern context */
|
|
68
|
+
alert: string;
|
|
69
|
+
/** Taxonomy category of the underlying issue */
|
|
70
|
+
category: TaxonomyCategory;
|
|
71
|
+
/** Concrete next-step instruction */
|
|
72
|
+
guidance: string;
|
|
73
|
+
/** Specific action to take */
|
|
74
|
+
action: string;
|
|
75
|
+
/** Pattern type being addressed */
|
|
76
|
+
pattern: PatternType;
|
|
77
|
+
/** Step range where the pattern was detected */
|
|
78
|
+
stepRange: [number, number];
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Aggregate result from running all pattern detectors
|
|
82
|
+
*/
|
|
83
|
+
export interface PatternDetectionResult {
|
|
84
|
+
/** All pattern matches found in this detection pass */
|
|
85
|
+
matches: PatternMatch[];
|
|
86
|
+
/** Time taken to run detection in milliseconds */
|
|
87
|
+
detectionTimeMs: number;
|
|
88
|
+
/** Number of patterns checked in this pass */
|
|
89
|
+
patternsChecked: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Configuration for the PRM system
|
|
93
|
+
*/
|
|
94
|
+
export interface PrmConfig {
|
|
95
|
+
/** Whether PRM is enabled */
|
|
96
|
+
enabled: boolean;
|
|
97
|
+
/** Threshold per pattern type (number of occurrences before alert) */
|
|
98
|
+
pattern_thresholds: Record<PatternType, number>;
|
|
99
|
+
/** Max trajectory lines before truncation */
|
|
100
|
+
max_trajectory_lines: number;
|
|
101
|
+
/** Whether 3-strike escalation is active */
|
|
102
|
+
escalation_enabled: boolean;
|
|
103
|
+
/** Max time for detection in milliseconds */
|
|
104
|
+
detection_timeout_ms: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Per-session escalation tracking state
|
|
108
|
+
*/
|
|
109
|
+
export interface EscalationState {
|
|
110
|
+
/** Pattern type to detection count mapping */
|
|
111
|
+
patternCounts: Map<PatternType, number>;
|
|
112
|
+
/** Current escalation level (0=none, 1=guidance, 2=strong guidance, 3=hard stop) */
|
|
113
|
+
escalationLevel: number;
|
|
114
|
+
/** Last pattern detected (if any) */
|
|
115
|
+
lastPatternDetected: PatternMatch | null;
|
|
116
|
+
/** Whether a hard stop has been triggered */
|
|
117
|
+
hardStopPending: boolean;
|
|
118
|
+
/** Queue of correction messages to inject */
|
|
119
|
+
correctionsPending: CourseCorrection[];
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { computeQualityMetrics, estimateCyclomaticComplexity, type QualityMetrics, type QualityViolation, } from './metrics';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { QualityBudgetConfig } from '../config/schema';
|
|
2
|
+
export interface QualityMetrics {
|
|
3
|
+
complexity_delta: number;
|
|
4
|
+
public_api_delta: number;
|
|
5
|
+
duplication_ratio: number;
|
|
6
|
+
test_to_code_ratio: number;
|
|
7
|
+
files_analyzed: string[];
|
|
8
|
+
thresholds: QualityBudgetConfig;
|
|
9
|
+
violations: QualityViolation[];
|
|
10
|
+
}
|
|
11
|
+
export interface QualityViolation {
|
|
12
|
+
type: 'complexity' | 'api' | 'duplication' | 'test_ratio';
|
|
13
|
+
message: string;
|
|
14
|
+
severity: 'error' | 'warning';
|
|
15
|
+
files: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Estimate cyclomatic complexity from source code
|
|
19
|
+
* Counts: if, for, while, switch, case, catch, &&, ||, ternary ?, optional chaining, nullish coalescing
|
|
20
|
+
*/
|
|
21
|
+
export declare function estimateCyclomaticComplexity(content: string): number;
|
|
22
|
+
/**
|
|
23
|
+
* Compute quality metrics for changed files
|
|
24
|
+
*/
|
|
25
|
+
export declare function computeQualityMetrics(changedFiles: string[], thresholds: QualityBudgetConfig, workingDir: string): Promise<QualityMetrics>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SAST Rule Engine - Main entry point
|
|
3
|
+
* Provides rule registration, loading, and execution for static security analysis
|
|
4
|
+
*/
|
|
5
|
+
export interface SastRule {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
9
|
+
languages: string[];
|
|
10
|
+
description: string;
|
|
11
|
+
remediation?: string;
|
|
12
|
+
query?: string;
|
|
13
|
+
pattern?: RegExp;
|
|
14
|
+
validate?: (match: SastMatch, context: SastContext) => boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SastMatch {
|
|
17
|
+
text: string;
|
|
18
|
+
line: number;
|
|
19
|
+
column: number;
|
|
20
|
+
endLine?: number;
|
|
21
|
+
endColumn?: number;
|
|
22
|
+
captures?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
export interface SastContext {
|
|
25
|
+
filePath: string;
|
|
26
|
+
content: string;
|
|
27
|
+
language: string;
|
|
28
|
+
parser?: unknown;
|
|
29
|
+
tree?: unknown;
|
|
30
|
+
}
|
|
31
|
+
export interface SastFinding {
|
|
32
|
+
rule_id: string;
|
|
33
|
+
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
34
|
+
message: string;
|
|
35
|
+
location: {
|
|
36
|
+
file: string;
|
|
37
|
+
line: number;
|
|
38
|
+
column?: number;
|
|
39
|
+
};
|
|
40
|
+
remediation?: string;
|
|
41
|
+
excerpt?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get all registered rules
|
|
45
|
+
*/
|
|
46
|
+
export declare function getAllRules(): SastRule[];
|
|
47
|
+
/**
|
|
48
|
+
* Get rules for a specific language
|
|
49
|
+
*/
|
|
50
|
+
export declare function getRulesForLanguage(language: string): SastRule[];
|
|
51
|
+
/**
|
|
52
|
+
* Get rule by ID
|
|
53
|
+
*/
|
|
54
|
+
export declare function getRuleById(id: string): SastRule | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Execute rules synchronously (pattern matching only)
|
|
57
|
+
* This is the primary execution method for offline SAST
|
|
58
|
+
*/
|
|
59
|
+
export declare function executeRulesSync(filePath: string, content: string, language: string): SastFinding[];
|
|
60
|
+
/**
|
|
61
|
+
* Execute rules against a file (async version with tree-sitter support)
|
|
62
|
+
* Falls back to pattern matching if tree-sitter is unavailable
|
|
63
|
+
*/
|
|
64
|
+
export declare function executeRules(filePath: string, content: string, language: string): Promise<SastFinding[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Get statistics about rules
|
|
67
|
+
*/
|
|
68
|
+
export declare function getRuleStats(): {
|
|
69
|
+
total: number;
|
|
70
|
+
bySeverity: Record<string, number>;
|
|
71
|
+
byLanguage: Record<string, number>;
|
|
72
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semgrep Integration for Tier B SAST Enhancement
|
|
3
|
+
* Provides optional Semgrep detection and invocation for advanced static analysis
|
|
4
|
+
*/
|
|
5
|
+
import type { SastFinding } from './rules/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Semgrep CLI options
|
|
8
|
+
*/
|
|
9
|
+
export interface SemgrepOptions {
|
|
10
|
+
/** Files or directories to scan */
|
|
11
|
+
files: string[];
|
|
12
|
+
/** Directory containing Semgrep rules (default: .swarm/semgrep-rules/) */
|
|
13
|
+
rulesDir?: string;
|
|
14
|
+
/** Timeout in milliseconds (default: 30000) */
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
/** Working directory for Semgrep execution */
|
|
17
|
+
cwd?: string;
|
|
18
|
+
/** Language identifier for --lang flag (used with useAutoConfig) */
|
|
19
|
+
lang?: string;
|
|
20
|
+
/** When true, use --config auto instead of local rulesDir (for profile-driven languages) */
|
|
21
|
+
useAutoConfig?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Result from Semgrep execution
|
|
25
|
+
*/
|
|
26
|
+
export interface SemgrepResult {
|
|
27
|
+
/** Whether Semgrep is available on the system */
|
|
28
|
+
available: boolean;
|
|
29
|
+
/** Array of security findings from Semgrep */
|
|
30
|
+
findings: SastFinding[];
|
|
31
|
+
/** Error message if Semgrep failed */
|
|
32
|
+
error?: string;
|
|
33
|
+
/** Engine label for the findings */
|
|
34
|
+
engine: 'tier_a' | 'tier_a+tier_b';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if Semgrep CLI is available on the system
|
|
38
|
+
* Uses caching to avoid shelling out on every check
|
|
39
|
+
* @returns true if Semgrep is available, false otherwise
|
|
40
|
+
*/
|
|
41
|
+
export declare function isSemgrepAvailable(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Check if Semgrep is available (async version for consistency)
|
|
44
|
+
* @returns Promise resolving to availability status
|
|
45
|
+
*/
|
|
46
|
+
export declare function checkSemgrepAvailable(): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Reset the Semgrep availability cache (useful for testing)
|
|
49
|
+
*/
|
|
50
|
+
export declare function resetSemgrepCache(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Run Semgrep on specified files
|
|
53
|
+
* @param options - Semgrep options
|
|
54
|
+
* @returns Promise resolving to SemgrepResult
|
|
55
|
+
*/
|
|
56
|
+
export declare function runSemgrep(options: SemgrepOptions): Promise<SemgrepResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Get the default rules directory path
|
|
59
|
+
* @param projectRoot - Optional project root directory
|
|
60
|
+
* @returns Absolute path to rules directory
|
|
61
|
+
*/
|
|
62
|
+
export declare function getRulesDirectory(projectRoot?: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Check if bundled rules directory exists
|
|
65
|
+
* @param projectRoot - Optional project root directory
|
|
66
|
+
* @returns true if rules directory exists
|
|
67
|
+
*/
|
|
68
|
+
export declare function hasBundledRules(projectRoot?: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|