@claude-flow/shared 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agentic-flow/intelligence.json +16 -0
- package/README.md +323 -0
- package/__tests__/coverage/base.css +224 -0
- package/__tests__/coverage/block-navigation.js +87 -0
- package/__tests__/coverage/coverage-final.json +50 -0
- package/__tests__/coverage/favicon.png +0 -0
- package/__tests__/coverage/index.html +326 -0
- package/__tests__/coverage/lcov-report/base.css +224 -0
- package/__tests__/coverage/lcov-report/block-navigation.js +87 -0
- package/__tests__/coverage/lcov-report/favicon.png +0 -0
- package/__tests__/coverage/lcov-report/index.html +326 -0
- package/__tests__/coverage/lcov-report/prettify.css +1 -0
- package/__tests__/coverage/lcov-report/prettify.js +2 -0
- package/__tests__/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/__tests__/coverage/lcov-report/sorter.js +210 -0
- package/__tests__/coverage/lcov-report/src/core/config/defaults.ts.html +706 -0
- package/__tests__/coverage/lcov-report/src/core/config/index.html +161 -0
- package/__tests__/coverage/lcov-report/src/core/config/loader.ts.html +898 -0
- package/__tests__/coverage/lcov-report/src/core/config/schema.ts.html +649 -0
- package/__tests__/coverage/lcov-report/src/core/config/validator.ts.html +712 -0
- package/__tests__/coverage/lcov-report/src/core/event-bus.ts.html +793 -0
- package/__tests__/coverage/lcov-report/src/core/index.html +116 -0
- package/__tests__/coverage/lcov-report/src/core/interfaces/event.interface.ts.html +886 -0
- package/__tests__/coverage/lcov-report/src/core/interfaces/index.html +116 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/event-coordinator.ts.html +451 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/health-monitor.ts.html +727 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/index.html +176 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/lifecycle-manager.ts.html +874 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/session-manager.ts.html +922 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/task-manager.ts.html +1036 -0
- package/__tests__/coverage/lcov-report/src/events/domain-events.ts.html +1837 -0
- package/__tests__/coverage/lcov-report/src/events/event-store.ts.html +1849 -0
- package/__tests__/coverage/lcov-report/src/events/example-usage.ts.html +964 -0
- package/__tests__/coverage/lcov-report/src/events/index.html +176 -0
- package/__tests__/coverage/lcov-report/src/events/projections.ts.html +1768 -0
- package/__tests__/coverage/lcov-report/src/events/state-reconstructor.ts.html +1132 -0
- package/__tests__/coverage/lcov-report/src/events.ts.html +1186 -0
- package/__tests__/coverage/lcov-report/src/hooks/example-usage.ts.html +1582 -0
- package/__tests__/coverage/lcov-report/src/hooks/executor.ts.html +1222 -0
- package/__tests__/coverage/lcov-report/src/hooks/index.html +191 -0
- package/__tests__/coverage/lcov-report/src/hooks/registry.ts.html +1084 -0
- package/__tests__/coverage/lcov-report/src/hooks/safety/bash-safety.ts.html +1897 -0
- package/__tests__/coverage/lcov-report/src/hooks/safety/file-organization.ts.html +1504 -0
- package/__tests__/coverage/lcov-report/src/hooks/safety/git-commit.ts.html +1954 -0
- package/__tests__/coverage/lcov-report/src/hooks/safety/index.html +146 -0
- package/__tests__/coverage/lcov-report/src/hooks/session-hooks.ts.html +1762 -0
- package/__tests__/coverage/lcov-report/src/hooks/task-hooks.ts.html +1624 -0
- package/__tests__/coverage/lcov-report/src/hooks/types.ts.html +1156 -0
- package/__tests__/coverage/lcov-report/src/index.html +176 -0
- package/__tests__/coverage/lcov-report/src/mcp/connection-pool.ts.html +1399 -0
- package/__tests__/coverage/lcov-report/src/mcp/index.html +176 -0
- package/__tests__/coverage/lcov-report/src/mcp/server.ts.html +2407 -0
- package/__tests__/coverage/lcov-report/src/mcp/session-manager.ts.html +1369 -0
- package/__tests__/coverage/lcov-report/src/mcp/tool-registry.ts.html +1783 -0
- package/__tests__/coverage/lcov-report/src/mcp/transport/http.ts.html +1756 -0
- package/__tests__/coverage/lcov-report/src/mcp/transport/index.html +146 -0
- package/__tests__/coverage/lcov-report/src/mcp/transport/stdio.ts.html +1057 -0
- package/__tests__/coverage/lcov-report/src/mcp/transport/websocket.ts.html +1537 -0
- package/__tests__/coverage/lcov-report/src/mcp/types.ts.html +1780 -0
- package/__tests__/coverage/lcov-report/src/plugin-interface.ts.html +2074 -0
- package/__tests__/coverage/lcov-report/src/plugin-loader.ts.html +1999 -0
- package/__tests__/coverage/lcov-report/src/plugin-registry.ts.html +1897 -0
- package/__tests__/coverage/lcov-report/src/plugins/official/hive-mind-plugin.ts.html +1075 -0
- package/__tests__/coverage/lcov-report/src/plugins/official/index.html +131 -0
- package/__tests__/coverage/lcov-report/src/plugins/official/maestro-plugin.ts.html +1609 -0
- package/__tests__/coverage/lcov-report/src/resilience/bulkhead.ts.html +916 -0
- package/__tests__/coverage/lcov-report/src/resilience/circuit-breaker.ts.html +1063 -0
- package/__tests__/coverage/lcov-report/src/resilience/index.html +161 -0
- package/__tests__/coverage/lcov-report/src/resilience/rate-limiter.ts.html +1345 -0
- package/__tests__/coverage/lcov-report/src/resilience/retry.ts.html +757 -0
- package/__tests__/coverage/lcov-report/src/security/index.html +131 -0
- package/__tests__/coverage/lcov-report/src/security/input-validation.ts.html +880 -0
- package/__tests__/coverage/lcov-report/src/security/secure-random.ts.html +562 -0
- package/__tests__/coverage/lcov-report/src/types/index.html +131 -0
- package/__tests__/coverage/lcov-report/src/types/swarm.types.ts.html +850 -0
- package/__tests__/coverage/lcov-report/src/types/task.types.ts.html +700 -0
- package/__tests__/coverage/lcov-report/src/types.ts.html +1186 -0
- package/__tests__/coverage/lcov-report/src/utils/index.html +116 -0
- package/__tests__/coverage/lcov-report/src/utils/secure-logger.ts.html +856 -0
- package/__tests__/coverage/lcov.info +19877 -0
- package/__tests__/coverage/prettify.css +1 -0
- package/__tests__/coverage/prettify.js +2 -0
- package/__tests__/coverage/sort-arrow-sprite.png +0 -0
- package/__tests__/coverage/sorter.js +210 -0
- package/__tests__/coverage/src/core/config/defaults.ts.html +706 -0
- package/__tests__/coverage/src/core/config/index.html +161 -0
- package/__tests__/coverage/src/core/config/loader.ts.html +898 -0
- package/__tests__/coverage/src/core/config/schema.ts.html +649 -0
- package/__tests__/coverage/src/core/config/validator.ts.html +712 -0
- package/__tests__/coverage/src/core/event-bus.ts.html +793 -0
- package/__tests__/coverage/src/core/index.html +116 -0
- package/__tests__/coverage/src/core/interfaces/event.interface.ts.html +886 -0
- package/__tests__/coverage/src/core/interfaces/index.html +116 -0
- package/__tests__/coverage/src/core/orchestrator/event-coordinator.ts.html +451 -0
- package/__tests__/coverage/src/core/orchestrator/health-monitor.ts.html +727 -0
- package/__tests__/coverage/src/core/orchestrator/index.html +176 -0
- package/__tests__/coverage/src/core/orchestrator/lifecycle-manager.ts.html +874 -0
- package/__tests__/coverage/src/core/orchestrator/session-manager.ts.html +922 -0
- package/__tests__/coverage/src/core/orchestrator/task-manager.ts.html +1036 -0
- package/__tests__/coverage/src/events/domain-events.ts.html +1837 -0
- package/__tests__/coverage/src/events/event-store.ts.html +1849 -0
- package/__tests__/coverage/src/events/example-usage.ts.html +964 -0
- package/__tests__/coverage/src/events/index.html +176 -0
- package/__tests__/coverage/src/events/projections.ts.html +1768 -0
- package/__tests__/coverage/src/events/state-reconstructor.ts.html +1132 -0
- package/__tests__/coverage/src/events.ts.html +1186 -0
- package/__tests__/coverage/src/hooks/example-usage.ts.html +1582 -0
- package/__tests__/coverage/src/hooks/executor.ts.html +1222 -0
- package/__tests__/coverage/src/hooks/index.html +191 -0
- package/__tests__/coverage/src/hooks/registry.ts.html +1084 -0
- package/__tests__/coverage/src/hooks/safety/bash-safety.ts.html +1897 -0
- package/__tests__/coverage/src/hooks/safety/file-organization.ts.html +1504 -0
- package/__tests__/coverage/src/hooks/safety/git-commit.ts.html +1954 -0
- package/__tests__/coverage/src/hooks/safety/index.html +146 -0
- package/__tests__/coverage/src/hooks/session-hooks.ts.html +1762 -0
- package/__tests__/coverage/src/hooks/task-hooks.ts.html +1624 -0
- package/__tests__/coverage/src/hooks/types.ts.html +1156 -0
- package/__tests__/coverage/src/index.html +176 -0
- package/__tests__/coverage/src/mcp/connection-pool.ts.html +1399 -0
- package/__tests__/coverage/src/mcp/index.html +176 -0
- package/__tests__/coverage/src/mcp/server.ts.html +2407 -0
- package/__tests__/coverage/src/mcp/session-manager.ts.html +1369 -0
- package/__tests__/coverage/src/mcp/tool-registry.ts.html +1783 -0
- package/__tests__/coverage/src/mcp/transport/http.ts.html +1756 -0
- package/__tests__/coverage/src/mcp/transport/index.html +146 -0
- package/__tests__/coverage/src/mcp/transport/stdio.ts.html +1057 -0
- package/__tests__/coverage/src/mcp/transport/websocket.ts.html +1537 -0
- package/__tests__/coverage/src/mcp/types.ts.html +1780 -0
- package/__tests__/coverage/src/plugin-interface.ts.html +2074 -0
- package/__tests__/coverage/src/plugin-loader.ts.html +1999 -0
- package/__tests__/coverage/src/plugin-registry.ts.html +1897 -0
- package/__tests__/coverage/src/plugins/official/hive-mind-plugin.ts.html +1075 -0
- package/__tests__/coverage/src/plugins/official/index.html +131 -0
- package/__tests__/coverage/src/plugins/official/maestro-plugin.ts.html +1609 -0
- package/__tests__/coverage/src/resilience/bulkhead.ts.html +916 -0
- package/__tests__/coverage/src/resilience/circuit-breaker.ts.html +1063 -0
- package/__tests__/coverage/src/resilience/index.html +161 -0
- package/__tests__/coverage/src/resilience/rate-limiter.ts.html +1345 -0
- package/__tests__/coverage/src/resilience/retry.ts.html +757 -0
- package/__tests__/coverage/src/security/index.html +131 -0
- package/__tests__/coverage/src/security/input-validation.ts.html +880 -0
- package/__tests__/coverage/src/security/secure-random.ts.html +562 -0
- package/__tests__/coverage/src/types/index.html +131 -0
- package/__tests__/coverage/src/types/swarm.types.ts.html +850 -0
- package/__tests__/coverage/src/types/task.types.ts.html +700 -0
- package/__tests__/coverage/src/types.ts.html +1186 -0
- package/__tests__/coverage/src/utils/index.html +116 -0
- package/__tests__/coverage/src/utils/secure-logger.ts.html +856 -0
- package/__tests__/hooks/bash-safety.test.ts +289 -0
- package/__tests__/hooks/file-organization.test.ts +335 -0
- package/__tests__/hooks/git-commit.test.ts +336 -0
- package/__tests__/hooks/index.ts +23 -0
- package/__tests__/hooks/session-hooks.test.ts +357 -0
- package/__tests__/hooks/task-hooks.test.ts +193 -0
- package/dist/core/config/defaults.d.ts +41 -0
- package/dist/core/config/defaults.d.ts.map +1 -0
- package/dist/core/config/defaults.js +186 -0
- package/dist/core/config/defaults.js.map +1 -0
- package/dist/core/config/index.d.ts +8 -0
- package/dist/core/config/index.d.ts.map +1 -0
- package/dist/core/config/index.js +12 -0
- package/dist/core/config/index.js.map +1 -0
- package/dist/core/config/loader.d.ts +45 -0
- package/dist/core/config/loader.d.ts.map +1 -0
- package/dist/core/config/loader.js +222 -0
- package/dist/core/config/loader.js.map +1 -0
- package/dist/core/config/schema.d.ts +1134 -0
- package/dist/core/config/schema.d.ts.map +1 -0
- package/dist/core/config/schema.js +158 -0
- package/dist/core/config/schema.js.map +1 -0
- package/dist/core/config/validator.d.ts +92 -0
- package/dist/core/config/validator.d.ts.map +1 -0
- package/dist/core/config/validator.js +147 -0
- package/dist/core/config/validator.js.map +1 -0
- package/dist/core/event-bus.d.ts +31 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +197 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +19 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/interfaces/agent.interface.d.ts +200 -0
- package/dist/core/interfaces/agent.interface.d.ts.map +1 -0
- package/dist/core/interfaces/agent.interface.js +6 -0
- package/dist/core/interfaces/agent.interface.js.map +1 -0
- package/dist/core/interfaces/coordinator.interface.d.ts +310 -0
- package/dist/core/interfaces/coordinator.interface.d.ts.map +1 -0
- package/dist/core/interfaces/coordinator.interface.js +7 -0
- package/dist/core/interfaces/coordinator.interface.js.map +1 -0
- package/dist/core/interfaces/event.interface.d.ts +224 -0
- package/dist/core/interfaces/event.interface.d.ts.map +1 -0
- package/dist/core/interfaces/event.interface.js +46 -0
- package/dist/core/interfaces/event.interface.js.map +1 -0
- package/dist/core/interfaces/index.d.ts +10 -0
- package/dist/core/interfaces/index.d.ts.map +1 -0
- package/dist/core/interfaces/index.js +15 -0
- package/dist/core/interfaces/index.js.map +1 -0
- package/dist/core/interfaces/memory.interface.d.ts +298 -0
- package/dist/core/interfaces/memory.interface.d.ts.map +1 -0
- package/dist/core/interfaces/memory.interface.js +7 -0
- package/dist/core/interfaces/memory.interface.js.map +1 -0
- package/dist/core/interfaces/task.interface.d.ts +185 -0
- package/dist/core/interfaces/task.interface.d.ts.map +1 -0
- package/dist/core/interfaces/task.interface.js +6 -0
- package/dist/core/interfaces/task.interface.js.map +1 -0
- package/dist/core/orchestrator/event-coordinator.d.ts +35 -0
- package/dist/core/orchestrator/event-coordinator.d.ts.map +1 -0
- package/dist/core/orchestrator/event-coordinator.js +101 -0
- package/dist/core/orchestrator/event-coordinator.js.map +1 -0
- package/dist/core/orchestrator/health-monitor.d.ts +60 -0
- package/dist/core/orchestrator/health-monitor.d.ts.map +1 -0
- package/dist/core/orchestrator/health-monitor.js +166 -0
- package/dist/core/orchestrator/health-monitor.js.map +1 -0
- package/dist/core/orchestrator/index.d.ts +46 -0
- package/dist/core/orchestrator/index.d.ts.map +1 -0
- package/dist/core/orchestrator/index.js +64 -0
- package/dist/core/orchestrator/index.js.map +1 -0
- package/dist/core/orchestrator/lifecycle-manager.d.ts +56 -0
- package/dist/core/orchestrator/lifecycle-manager.d.ts.map +1 -0
- package/dist/core/orchestrator/lifecycle-manager.js +195 -0
- package/dist/core/orchestrator/lifecycle-manager.js.map +1 -0
- package/dist/core/orchestrator/session-manager.d.ts +83 -0
- package/dist/core/orchestrator/session-manager.d.ts.map +1 -0
- package/dist/core/orchestrator/session-manager.js +193 -0
- package/dist/core/orchestrator/session-manager.js.map +1 -0
- package/dist/core/orchestrator/task-manager.d.ts +49 -0
- package/dist/core/orchestrator/task-manager.d.ts.map +1 -0
- package/dist/core/orchestrator/task-manager.js +253 -0
- package/dist/core/orchestrator/task-manager.js.map +1 -0
- package/dist/events/domain-events.d.ts +282 -0
- package/dist/events/domain-events.d.ts.map +1 -0
- package/dist/events/domain-events.js +165 -0
- package/dist/events/domain-events.js.map +1 -0
- package/dist/events/event-store.d.ts +126 -0
- package/dist/events/event-store.d.ts.map +1 -0
- package/dist/events/event-store.js +416 -0
- package/dist/events/event-store.js.map +1 -0
- package/dist/events/event-store.test.d.ts +8 -0
- package/dist/events/event-store.test.d.ts.map +1 -0
- package/dist/events/event-store.test.js +293 -0
- package/dist/events/event-store.test.js.map +1 -0
- package/dist/events/example-usage.d.ts +10 -0
- package/dist/events/example-usage.d.ts.map +1 -0
- package/dist/events/example-usage.js +193 -0
- package/dist/events/example-usage.js.map +1 -0
- package/dist/events/index.d.ts +19 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +20 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/projections.d.ts +177 -0
- package/dist/events/projections.d.ts.map +1 -0
- package/dist/events/projections.js +421 -0
- package/dist/events/projections.js.map +1 -0
- package/dist/events/state-reconstructor.d.ts +101 -0
- package/dist/events/state-reconstructor.d.ts.map +1 -0
- package/dist/events/state-reconstructor.js +263 -0
- package/dist/events/state-reconstructor.js.map +1 -0
- package/dist/events.d.ts +80 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +249 -0
- package/dist/events.js.map +1 -0
- package/dist/hooks/example-usage.d.ts +42 -0
- package/dist/hooks/example-usage.d.ts.map +1 -0
- package/dist/hooks/example-usage.js +351 -0
- package/dist/hooks/example-usage.js.map +1 -0
- package/dist/hooks/executor.d.ts +100 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +264 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/hooks.test.d.ts +9 -0
- package/dist/hooks/hooks.test.d.ts.map +1 -0
- package/dist/hooks/hooks.test.js +322 -0
- package/dist/hooks/hooks.test.js.map +1 -0
- package/dist/hooks/index.d.ts +52 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +51 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/registry.d.ts +133 -0
- package/dist/hooks/registry.d.ts.map +1 -0
- package/dist/hooks/registry.js +277 -0
- package/dist/hooks/registry.js.map +1 -0
- package/dist/hooks/safety/bash-safety.d.ts +105 -0
- package/dist/hooks/safety/bash-safety.d.ts.map +1 -0
- package/dist/hooks/safety/bash-safety.js +481 -0
- package/dist/hooks/safety/bash-safety.js.map +1 -0
- package/dist/hooks/safety/file-organization.d.ts +144 -0
- package/dist/hooks/safety/file-organization.d.ts.map +1 -0
- package/dist/hooks/safety/file-organization.js +328 -0
- package/dist/hooks/safety/file-organization.js.map +1 -0
- package/dist/hooks/safety/git-commit.d.ts +158 -0
- package/dist/hooks/safety/git-commit.d.ts.map +1 -0
- package/dist/hooks/safety/git-commit.js +450 -0
- package/dist/hooks/safety/git-commit.js.map +1 -0
- package/dist/hooks/safety/index.d.ts +17 -0
- package/dist/hooks/safety/index.d.ts.map +1 -0
- package/dist/hooks/safety/index.js +17 -0
- package/dist/hooks/safety/index.js.map +1 -0
- package/dist/hooks/session-hooks.d.ts +234 -0
- package/dist/hooks/session-hooks.d.ts.map +1 -0
- package/dist/hooks/session-hooks.js +334 -0
- package/dist/hooks/session-hooks.js.map +1 -0
- package/dist/hooks/task-hooks.d.ts +163 -0
- package/dist/hooks/task-hooks.d.ts.map +1 -0
- package/dist/hooks/task-hooks.js +326 -0
- package/dist/hooks/task-hooks.js.map +1 -0
- package/dist/hooks/types.d.ts +267 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +62 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/hooks/verify-exports.test.d.ts +9 -0
- package/dist/hooks/verify-exports.test.d.ts.map +1 -0
- package/dist/hooks/verify-exports.test.js +93 -0
- package/dist/hooks/verify-exports.test.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/connection-pool.d.ts +98 -0
- package/dist/mcp/connection-pool.d.ts.map +1 -0
- package/dist/mcp/connection-pool.js +364 -0
- package/dist/mcp/connection-pool.js.map +1 -0
- package/dist/mcp/index.d.ts +69 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +84 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +166 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +593 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/session-manager.d.ts +136 -0
- package/dist/mcp/session-manager.d.ts.map +1 -0
- package/dist/mcp/session-manager.js +335 -0
- package/dist/mcp/session-manager.js.map +1 -0
- package/dist/mcp/tool-registry.d.ts +178 -0
- package/dist/mcp/tool-registry.d.ts.map +1 -0
- package/dist/mcp/tool-registry.js +439 -0
- package/dist/mcp/tool-registry.js.map +1 -0
- package/dist/mcp/transport/http.d.ts +104 -0
- package/dist/mcp/transport/http.d.ts.map +1 -0
- package/dist/mcp/transport/http.js +476 -0
- package/dist/mcp/transport/http.js.map +1 -0
- package/dist/mcp/transport/index.d.ts +102 -0
- package/dist/mcp/transport/index.d.ts.map +1 -0
- package/dist/mcp/transport/index.js +238 -0
- package/dist/mcp/transport/index.js.map +1 -0
- package/dist/mcp/transport/stdio.d.ts +104 -0
- package/dist/mcp/transport/stdio.d.ts.map +1 -0
- package/dist/mcp/transport/stdio.js +263 -0
- package/dist/mcp/transport/stdio.js.map +1 -0
- package/dist/mcp/transport/websocket.d.ts +133 -0
- package/dist/mcp/transport/websocket.d.ts.map +1 -0
- package/dist/mcp/transport/websocket.js +396 -0
- package/dist/mcp/transport/websocket.js.map +1 -0
- package/dist/mcp/types.d.ts +438 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +54 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/plugin-interface.d.ts +544 -0
- package/dist/plugin-interface.d.ts.map +1 -0
- package/dist/plugin-interface.js +23 -0
- package/dist/plugin-interface.js.map +1 -0
- package/dist/plugin-loader.d.ts +139 -0
- package/dist/plugin-loader.d.ts.map +1 -0
- package/dist/plugin-loader.js +434 -0
- package/dist/plugin-loader.js.map +1 -0
- package/dist/plugin-registry.d.ts +183 -0
- package/dist/plugin-registry.d.ts.map +1 -0
- package/dist/plugin-registry.js +457 -0
- package/dist/plugin-registry.js.map +1 -0
- package/dist/plugins/index.d.ts +10 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +10 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/official/hive-mind-plugin.d.ts +106 -0
- package/dist/plugins/official/hive-mind-plugin.d.ts.map +1 -0
- package/dist/plugins/official/hive-mind-plugin.js +241 -0
- package/dist/plugins/official/hive-mind-plugin.js.map +1 -0
- package/dist/plugins/official/index.d.ts +10 -0
- package/dist/plugins/official/index.d.ts.map +1 -0
- package/dist/plugins/official/index.js +10 -0
- package/dist/plugins/official/index.js.map +1 -0
- package/dist/plugins/official/maestro-plugin.d.ts +121 -0
- package/dist/plugins/official/maestro-plugin.d.ts.map +1 -0
- package/dist/plugins/official/maestro-plugin.js +355 -0
- package/dist/plugins/official/maestro-plugin.js.map +1 -0
- package/dist/plugins/types.d.ts +93 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +9 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/resilience/bulkhead.d.ts +105 -0
- package/dist/resilience/bulkhead.d.ts.map +1 -0
- package/dist/resilience/bulkhead.js +206 -0
- package/dist/resilience/bulkhead.js.map +1 -0
- package/dist/resilience/circuit-breaker.d.ts +132 -0
- package/dist/resilience/circuit-breaker.d.ts.map +1 -0
- package/dist/resilience/circuit-breaker.js +233 -0
- package/dist/resilience/circuit-breaker.js.map +1 -0
- package/dist/resilience/index.d.ts +19 -0
- package/dist/resilience/index.d.ts.map +1 -0
- package/dist/resilience/index.js +19 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/resilience/rate-limiter.d.ts +168 -0
- package/dist/resilience/rate-limiter.d.ts.map +1 -0
- package/dist/resilience/rate-limiter.js +314 -0
- package/dist/resilience/rate-limiter.js.map +1 -0
- package/dist/resilience/retry.d.ts +91 -0
- package/dist/resilience/retry.d.ts.map +1 -0
- package/dist/resilience/retry.js +159 -0
- package/dist/resilience/retry.js.map +1 -0
- package/dist/security/index.d.ts +10 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +12 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/input-validation.d.ts +73 -0
- package/dist/security/input-validation.d.ts.map +1 -0
- package/dist/security/input-validation.js +201 -0
- package/dist/security/input-validation.js.map +1 -0
- package/dist/security/secure-random.d.ts +92 -0
- package/dist/security/secure-random.d.ts.map +1 -0
- package/dist/security/secure-random.js +142 -0
- package/dist/security/secure-random.js.map +1 -0
- package/dist/types/agent.types.d.ts +137 -0
- package/dist/types/agent.types.d.ts.map +1 -0
- package/dist/types/agent.types.js +6 -0
- package/dist/types/agent.types.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +17 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mcp.types.d.ts +266 -0
- package/dist/types/mcp.types.d.ts.map +1 -0
- package/dist/types/mcp.types.js +7 -0
- package/dist/types/mcp.types.js.map +1 -0
- package/dist/types/memory.types.d.ts +236 -0
- package/dist/types/memory.types.d.ts.map +1 -0
- package/dist/types/memory.types.js +7 -0
- package/dist/types/memory.types.js.map +1 -0
- package/dist/types/swarm.types.d.ts +186 -0
- package/dist/types/swarm.types.d.ts.map +1 -0
- package/dist/types/swarm.types.js +65 -0
- package/dist/types/swarm.types.js.map +1 -0
- package/dist/types/task.types.d.ts +178 -0
- package/dist/types/task.types.d.ts.map +1 -0
- package/dist/types/task.types.js +32 -0
- package/dist/types/task.types.js.map +1 -0
- package/dist/types.d.ts +197 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/secure-logger.d.ts +69 -0
- package/dist/utils/secure-logger.d.ts.map +1 -0
- package/dist/utils/secure-logger.js +208 -0
- package/dist/utils/secure-logger.js.map +1 -0
- package/docs/EVENTS_IMPLEMENTATION_SUMMARY.md +388 -0
- package/docs/EVENTS_QUICK_REFERENCE.md +470 -0
- package/docs/EVENTS_README.md +352 -0
- package/package.json +34 -0
- package/src/core/config/defaults.ts +207 -0
- package/src/core/config/index.ts +15 -0
- package/src/core/config/loader.ts +271 -0
- package/src/core/config/schema.ts +188 -0
- package/src/core/config/validator.ts +209 -0
- package/src/core/event-bus.ts +236 -0
- package/src/core/index.ts +22 -0
- package/src/core/interfaces/agent.interface.ts +251 -0
- package/src/core/interfaces/coordinator.interface.ts +363 -0
- package/src/core/interfaces/event.interface.ts +267 -0
- package/src/core/interfaces/index.ts +19 -0
- package/src/core/interfaces/memory.interface.ts +332 -0
- package/src/core/interfaces/task.interface.ts +223 -0
- package/src/core/orchestrator/event-coordinator.ts +122 -0
- package/src/core/orchestrator/health-monitor.ts +214 -0
- package/src/core/orchestrator/index.ts +89 -0
- package/src/core/orchestrator/lifecycle-manager.ts +263 -0
- package/src/core/orchestrator/session-manager.ts +279 -0
- package/src/core/orchestrator/task-manager.ts +317 -0
- package/src/events/domain-events.ts +584 -0
- package/src/events/event-store.test.ts +387 -0
- package/src/events/event-store.ts +588 -0
- package/src/events/example-usage.ts +293 -0
- package/src/events/index.ts +90 -0
- package/src/events/projections.ts +561 -0
- package/src/events/state-reconstructor.ts +349 -0
- package/src/events.ts +367 -0
- package/src/hooks/INTEGRATION.md +658 -0
- package/src/hooks/README.md +532 -0
- package/src/hooks/example-usage.ts +499 -0
- package/src/hooks/executor.ts +379 -0
- package/src/hooks/hooks.test.ts +421 -0
- package/src/hooks/index.ts +131 -0
- package/src/hooks/registry.ts +333 -0
- package/src/hooks/safety/bash-safety.ts +604 -0
- package/src/hooks/safety/file-organization.ts +473 -0
- package/src/hooks/safety/git-commit.ts +623 -0
- package/src/hooks/safety/index.ts +46 -0
- package/src/hooks/session-hooks.ts +559 -0
- package/src/hooks/task-hooks.ts +513 -0
- package/src/hooks/types.ts +357 -0
- package/src/hooks/verify-exports.test.ts +125 -0
- package/src/index.ts +190 -0
- package/src/mcp/connection-pool.ts +438 -0
- package/src/mcp/index.ts +183 -0
- package/src/mcp/server.ts +774 -0
- package/src/mcp/session-manager.ts +428 -0
- package/src/mcp/tool-registry.ts +566 -0
- package/src/mcp/transport/http.ts +557 -0
- package/src/mcp/transport/index.ts +294 -0
- package/src/mcp/transport/stdio.ts +324 -0
- package/src/mcp/transport/websocket.ts +484 -0
- package/src/mcp/types.ts +565 -0
- package/src/plugin-interface.ts +663 -0
- package/src/plugin-loader.ts +638 -0
- package/src/plugin-registry.ts +604 -0
- package/src/plugins/index.ts +34 -0
- package/src/plugins/official/hive-mind-plugin.ts +330 -0
- package/src/plugins/official/index.ts +24 -0
- package/src/plugins/official/maestro-plugin.ts +508 -0
- package/src/plugins/types.ts +108 -0
- package/src/resilience/bulkhead.ts +277 -0
- package/src/resilience/circuit-breaker.ts +326 -0
- package/src/resilience/index.ts +26 -0
- package/src/resilience/rate-limiter.ts +420 -0
- package/src/resilience/retry.ts +224 -0
- package/src/security/index.ts +39 -0
- package/src/security/input-validation.ts +265 -0
- package/src/security/secure-random.ts +159 -0
- package/src/types/agent.types.ts +144 -0
- package/src/types/index.ts +22 -0
- package/src/types/mcp.types.ts +300 -0
- package/src/types/memory.types.ts +263 -0
- package/src/types/swarm.types.ts +255 -0
- package/src/types/task.types.ts +205 -0
- package/src/types.ts +367 -0
- package/src/utils/secure-logger.d.ts +69 -0
- package/src/utils/secure-logger.d.ts.map +1 -0
- package/src/utils/secure-logger.js +208 -0
- package/src/utils/secure-logger.js.map +1 -0
- package/src/utils/secure-logger.ts +257 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 Bash Safety Hook Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for command safety analysis and dangerous command detection.
|
|
5
|
+
*
|
|
6
|
+
* @module v3/shared/hooks/__tests__/bash-safety.test
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
10
|
+
import {
|
|
11
|
+
createHookRegistry,
|
|
12
|
+
createBashSafetyHook,
|
|
13
|
+
BashSafetyHook,
|
|
14
|
+
HookRegistry,
|
|
15
|
+
} from '../../src/hooks/index.js';
|
|
16
|
+
|
|
17
|
+
describe('BashSafetyHook', () => {
|
|
18
|
+
let registry: HookRegistry;
|
|
19
|
+
let bashSafety: BashSafetyHook;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
registry = createHookRegistry();
|
|
23
|
+
bashSafety = createBashSafetyHook(registry);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('dangerous command detection', () => {
|
|
27
|
+
it('should block rm -rf / command', async () => {
|
|
28
|
+
const result = await bashSafety.analyze('rm -rf /');
|
|
29
|
+
|
|
30
|
+
expect(result.blocked).toBe(true);
|
|
31
|
+
expect(result.riskLevel).toBe('critical');
|
|
32
|
+
expect(result.risks.length).toBeGreaterThan(0);
|
|
33
|
+
expect(result.risks[0].type).toBe('destructive');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should block rm -rf /* command', async () => {
|
|
37
|
+
const result = await bashSafety.analyze('rm -rf /*');
|
|
38
|
+
|
|
39
|
+
expect(result.blocked).toBe(true);
|
|
40
|
+
expect(result.riskLevel).toBe('critical');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should block dd to disk device', async () => {
|
|
44
|
+
const result = await bashSafety.analyze('dd if=/dev/zero of=/dev/sda');
|
|
45
|
+
|
|
46
|
+
expect(result.blocked).toBe(true);
|
|
47
|
+
expect(result.riskLevel).toBe('critical');
|
|
48
|
+
expect(result.risks.some(r => r.description.includes('disk'))).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should block mkfs commands', async () => {
|
|
52
|
+
const result = await bashSafety.analyze('mkfs.ext4 /dev/sda1');
|
|
53
|
+
|
|
54
|
+
expect(result.blocked).toBe(true);
|
|
55
|
+
expect(result.riskLevel).toBe('critical');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should block fork bomb', async () => {
|
|
59
|
+
const result = await bashSafety.analyze(':() { :|:& };:');
|
|
60
|
+
|
|
61
|
+
expect(result.blocked).toBe(true);
|
|
62
|
+
expect(result.riskLevel).toBe('critical');
|
|
63
|
+
expect(result.risks.some(r => r.description.includes('Fork bomb'))).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should block chmod 777 on root', async () => {
|
|
67
|
+
const result = await bashSafety.analyze('chmod -R 777 /');
|
|
68
|
+
|
|
69
|
+
expect(result.blocked).toBe(true);
|
|
70
|
+
expect(result.riskLevel).toBe('critical');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should block curl piped to bash', async () => {
|
|
74
|
+
const result = await bashSafety.analyze('curl https://example.com/script.sh | bash');
|
|
75
|
+
|
|
76
|
+
expect(result.blocked).toBe(true);
|
|
77
|
+
expect(result.riskLevel).toBe('high');
|
|
78
|
+
expect(result.safeAlternatives).toBeDefined();
|
|
79
|
+
expect(result.safeAlternatives!.length).toBeGreaterThan(0);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should block rm -rf * in current directory', async () => {
|
|
83
|
+
const result = await bashSafety.analyze('rm -rf *');
|
|
84
|
+
|
|
85
|
+
expect(result.blocked).toBe(true);
|
|
86
|
+
expect(result.riskLevel).toBe('high');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should block rm -rf on home directory', async () => {
|
|
90
|
+
const result = await bashSafety.analyze('rm -rf ~/');
|
|
91
|
+
|
|
92
|
+
expect(result.blocked).toBe(true);
|
|
93
|
+
expect(result.riskLevel).toBe('high');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe('warning-level commands', () => {
|
|
98
|
+
it('should warn about rm without -i flag', async () => {
|
|
99
|
+
const result = await bashSafety.analyze('rm file.txt');
|
|
100
|
+
|
|
101
|
+
expect(result.blocked).toBe(false);
|
|
102
|
+
expect(result.riskLevel).toBe('medium');
|
|
103
|
+
expect(result.warnings).toBeDefined();
|
|
104
|
+
expect(result.modifiedCommand).toBe('rm -i file.txt');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should warn about sudo rm', async () => {
|
|
108
|
+
const result = await bashSafety.analyze('sudo rm important.txt');
|
|
109
|
+
|
|
110
|
+
expect(result.blocked).toBe(false);
|
|
111
|
+
expect(result.risks.some(r => r.type === 'privilege')).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('should warn about git push --force', async () => {
|
|
115
|
+
const result = await bashSafety.analyze('git push origin main --force');
|
|
116
|
+
|
|
117
|
+
expect(result.blocked).toBe(false);
|
|
118
|
+
expect(result.riskLevel).toBe('medium');
|
|
119
|
+
expect(result.risks.some(r => r.description.includes('Force push'))).toBe(true);
|
|
120
|
+
expect(result.safeAlternatives).toBeDefined();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should warn about git reset --hard', async () => {
|
|
124
|
+
const result = await bashSafety.analyze('git reset --hard HEAD~1');
|
|
125
|
+
|
|
126
|
+
expect(result.blocked).toBe(false);
|
|
127
|
+
expect(result.riskLevel).toBe('medium');
|
|
128
|
+
expect(result.risks.some(r => r.description.includes('Hard reset'))).toBe(true);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should warn about DROP DATABASE', async () => {
|
|
132
|
+
const result = await bashSafety.analyze('mysql -e "DROP DATABASE production"');
|
|
133
|
+
|
|
134
|
+
expect(result.blocked).toBe(false);
|
|
135
|
+
expect(result.riskLevel).toBe('high');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should warn about kill -9', async () => {
|
|
139
|
+
const result = await bashSafety.analyze('kill -9 12345');
|
|
140
|
+
|
|
141
|
+
expect(result.blocked).toBe(false);
|
|
142
|
+
expect(result.riskLevel).toBe('low');
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('secret detection', () => {
|
|
147
|
+
it('should detect password in command', async () => {
|
|
148
|
+
const result = await bashSafety.analyze('mysql -p password=secret123');
|
|
149
|
+
|
|
150
|
+
expect(result.risks.some(r => r.type === 'secret')).toBe(true);
|
|
151
|
+
expect(result.warnings).toBeDefined();
|
|
152
|
+
expect(result.warnings!.some(w => w.includes('password'))).toBe(true);
|
|
153
|
+
expect(result.redactedCommand).toBeDefined();
|
|
154
|
+
expect(result.redactedCommand).toContain('[REDACTED]');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('should detect API key in command', async () => {
|
|
158
|
+
const result = await bashSafety.analyze('curl -H "api_key=sk_live_abc123"');
|
|
159
|
+
|
|
160
|
+
expect(result.risks.some(r => r.type === 'secret')).toBe(true);
|
|
161
|
+
expect(result.redactedCommand).toContain('[REDACTED]');
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it('should detect bearer token', async () => {
|
|
165
|
+
const result = await bashSafety.analyze('curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"');
|
|
166
|
+
|
|
167
|
+
expect(result.risks.some(r => r.type === 'secret')).toBe(true);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should detect OpenAI API key pattern', async () => {
|
|
171
|
+
const result = await bashSafety.analyze('export OPENAI_API_KEY=sk-abcdefghijklmnopqrstuvwxyz');
|
|
172
|
+
|
|
173
|
+
expect(result.risks.some(r => r.type === 'secret')).toBe(true);
|
|
174
|
+
expect(result.warnings!.some(w => w.includes('OpenAI'))).toBe(true);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should detect GitHub token', async () => {
|
|
178
|
+
const result = await bashSafety.analyze('git clone https://ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@github.com/user/repo');
|
|
179
|
+
|
|
180
|
+
expect(result.risks.some(r => r.type === 'secret')).toBe(true);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('should detect AWS access key', async () => {
|
|
184
|
+
const result = await bashSafety.analyze('aws configure set aws_access_key_id AKIAIOSFODNN7EXAMPLE');
|
|
185
|
+
|
|
186
|
+
expect(result.risks.some(r => r.type === 'secret')).toBe(true);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe('safe commands', () => {
|
|
191
|
+
it('should pass safe ls command', async () => {
|
|
192
|
+
const result = await bashSafety.analyze('ls -la');
|
|
193
|
+
|
|
194
|
+
expect(result.blocked).toBe(false);
|
|
195
|
+
expect(result.riskLevel).toBe('low');
|
|
196
|
+
expect(result.risks.length).toBe(0);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should pass safe git status', async () => {
|
|
200
|
+
const result = await bashSafety.analyze('git status');
|
|
201
|
+
|
|
202
|
+
expect(result.blocked).toBe(false);
|
|
203
|
+
expect(result.riskLevel).toBe('low');
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('should pass npm install', async () => {
|
|
207
|
+
const result = await bashSafety.analyze('npm install lodash');
|
|
208
|
+
|
|
209
|
+
expect(result.blocked).toBe(false);
|
|
210
|
+
expect(result.riskLevel).toBe('low');
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('should pass safe rm -i command', async () => {
|
|
214
|
+
const result = await bashSafety.analyze('rm -i file.txt');
|
|
215
|
+
|
|
216
|
+
expect(result.blocked).toBe(false);
|
|
217
|
+
expect(result.modifiedCommand).toBeUndefined();
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('should pass cat command', async () => {
|
|
221
|
+
const result = await bashSafety.analyze('cat /etc/passwd');
|
|
222
|
+
|
|
223
|
+
expect(result.blocked).toBe(false);
|
|
224
|
+
expect(result.riskLevel).toBe('low');
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe('safe alternatives', () => {
|
|
229
|
+
it('should suggest safe alternatives for rm -rf', async () => {
|
|
230
|
+
const result = await bashSafety.analyze('rm -rf ./build');
|
|
231
|
+
|
|
232
|
+
expect(result.safeAlternatives).toBeDefined();
|
|
233
|
+
expect(result.safeAlternatives!.some(a => a.includes('interactive'))).toBe(true);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('should suggest safe alternatives for kill -9', async () => {
|
|
237
|
+
const result = await bashSafety.analyze('kill -9 1234');
|
|
238
|
+
|
|
239
|
+
expect(result.safeAlternatives).toBeDefined();
|
|
240
|
+
expect(result.safeAlternatives!.some(a => a.includes('graceful') || a.includes('SIGTERM'))).toBe(true);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
describe('helper methods', () => {
|
|
245
|
+
it('should check if command would be blocked', () => {
|
|
246
|
+
expect(bashSafety.wouldBlock('rm -rf /')).toBe(true);
|
|
247
|
+
expect(bashSafety.wouldBlock('ls -la')).toBe(false);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('should allow adding custom dangerous patterns', async () => {
|
|
251
|
+
bashSafety.addDangerousPattern(
|
|
252
|
+
/danger_command/,
|
|
253
|
+
'dangerous',
|
|
254
|
+
'critical',
|
|
255
|
+
'Custom dangerous command'
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
const result = await bashSafety.analyze('danger_command --execute');
|
|
259
|
+
|
|
260
|
+
expect(result.blocked).toBe(true);
|
|
261
|
+
expect(result.risks.some(r => r.description === 'Custom dangerous command')).toBe(true);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it('should track available dependencies', async () => {
|
|
265
|
+
bashSafety.markDependencyAvailable('custom-tool');
|
|
266
|
+
// This would affect dependency checking logic
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
describe('command modification', () => {
|
|
271
|
+
it('should add -i flag to rm commands', async () => {
|
|
272
|
+
const result = await bashSafety.analyze('rm file1.txt file2.txt');
|
|
273
|
+
|
|
274
|
+
expect(result.modifiedCommand).toBe('rm -i file1.txt file2.txt');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('should not modify rm -i commands', async () => {
|
|
278
|
+
const result = await bashSafety.analyze('rm -i file.txt');
|
|
279
|
+
|
|
280
|
+
expect(result.modifiedCommand).toBeUndefined();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('should not modify blocked commands', async () => {
|
|
284
|
+
const result = await bashSafety.analyze('rm -rf /');
|
|
285
|
+
|
|
286
|
+
expect(result.modifiedCommand).toBeUndefined();
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
});
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 File Organization Hook Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for file organization enforcement and formatter recommendations.
|
|
5
|
+
*
|
|
6
|
+
* @module v3/shared/hooks/__tests__/file-organization.test
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
10
|
+
import {
|
|
11
|
+
createHookRegistry,
|
|
12
|
+
createFileOrganizationHook,
|
|
13
|
+
FileOrganizationHook,
|
|
14
|
+
HookRegistry,
|
|
15
|
+
} from '../../src/hooks/index.js';
|
|
16
|
+
|
|
17
|
+
describe('FileOrganizationHook', () => {
|
|
18
|
+
let registry: HookRegistry;
|
|
19
|
+
let fileOrg: FileOrganizationHook;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
registry = createHookRegistry();
|
|
23
|
+
fileOrg = createFileOrganizationHook(registry);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('root folder blocking', () => {
|
|
27
|
+
it('should block TypeScript source files in root', async () => {
|
|
28
|
+
const result = await fileOrg.analyze('utils.ts');
|
|
29
|
+
|
|
30
|
+
expect(result.blocked).toBe(true);
|
|
31
|
+
expect(result.blockReason).toBeDefined();
|
|
32
|
+
expect(result.suggestedDirectory).toBe('src/');
|
|
33
|
+
expect(result.suggestedPath).toBe('src/utils.ts');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should block JavaScript source files in root', async () => {
|
|
37
|
+
const result = await fileOrg.analyze('index.js');
|
|
38
|
+
|
|
39
|
+
expect(result.blocked).toBe(true);
|
|
40
|
+
expect(result.suggestedDirectory).toBe('src/');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should block TypeScript test files in root', async () => {
|
|
44
|
+
const result = await fileOrg.analyze('utils.test.ts');
|
|
45
|
+
|
|
46
|
+
expect(result.blocked).toBe(true);
|
|
47
|
+
expect(result.suggestedDirectory).toBe('tests/');
|
|
48
|
+
expect(result.suggestedPath).toBe('tests/utils.test.ts');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should block spec files in root', async () => {
|
|
52
|
+
const result = await fileOrg.analyze('api.spec.ts');
|
|
53
|
+
|
|
54
|
+
expect(result.blocked).toBe(true);
|
|
55
|
+
expect(result.suggestedDirectory).toBe('tests/');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should block Python files in root', async () => {
|
|
59
|
+
const result = await fileOrg.analyze('main.py');
|
|
60
|
+
|
|
61
|
+
expect(result.blocked).toBe(true);
|
|
62
|
+
expect(result.suggestedDirectory).toBe('src/');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should block Go files in root', async () => {
|
|
66
|
+
const result = await fileOrg.analyze('main.go');
|
|
67
|
+
|
|
68
|
+
expect(result.blocked).toBe(true);
|
|
69
|
+
expect(result.suggestedDirectory).toBe('cmd/');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should block shell scripts in root', async () => {
|
|
73
|
+
const result = await fileOrg.analyze('deploy.sh');
|
|
74
|
+
|
|
75
|
+
expect(result.blocked).toBe(true);
|
|
76
|
+
expect(result.suggestedDirectory).toBe('scripts/');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should block CSS files in root', async () => {
|
|
80
|
+
const result = await fileOrg.analyze('styles.css');
|
|
81
|
+
|
|
82
|
+
expect(result.blocked).toBe(true);
|
|
83
|
+
expect(result.suggestedDirectory).toBe('styles/');
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('allowed root files', () => {
|
|
88
|
+
it('should allow JSON config files in root', async () => {
|
|
89
|
+
const result = await fileOrg.analyze('package.json');
|
|
90
|
+
|
|
91
|
+
expect(result.blocked).toBe(false);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should allow YAML config files in root', async () => {
|
|
95
|
+
const result = await fileOrg.analyze('config.yaml');
|
|
96
|
+
|
|
97
|
+
expect(result.blocked).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should allow Markdown files in root', async () => {
|
|
101
|
+
const result = await fileOrg.analyze('README.md');
|
|
102
|
+
|
|
103
|
+
expect(result.blocked).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should allow environment files in root', async () => {
|
|
107
|
+
const result = await fileOrg.analyze('.env');
|
|
108
|
+
|
|
109
|
+
expect(result.blocked).toBe(false);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should allow .env.local files in root', async () => {
|
|
113
|
+
const result = await fileOrg.analyze('.env.local');
|
|
114
|
+
|
|
115
|
+
expect(result.blocked).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe('files in correct directories', () => {
|
|
120
|
+
it('should allow TypeScript files in src/', async () => {
|
|
121
|
+
const result = await fileOrg.analyze('src/utils.ts');
|
|
122
|
+
|
|
123
|
+
expect(result.blocked).toBe(false);
|
|
124
|
+
expect(result.issues?.some(i => i.type === 'wrong-directory')).toBeFalsy();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('should allow test files in tests/', async () => {
|
|
128
|
+
const result = await fileOrg.analyze('tests/utils.test.ts');
|
|
129
|
+
|
|
130
|
+
expect(result.blocked).toBe(false);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should allow test files in __tests__/', async () => {
|
|
134
|
+
const result = await fileOrg.analyze('__tests__/utils.test.ts');
|
|
135
|
+
|
|
136
|
+
expect(result.blocked).toBe(false);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should allow scripts in scripts/', async () => {
|
|
140
|
+
const result = await fileOrg.analyze('scripts/deploy.sh');
|
|
141
|
+
|
|
142
|
+
expect(result.blocked).toBe(false);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('should allow Go files in cmd/', async () => {
|
|
146
|
+
const result = await fileOrg.analyze('cmd/main.go');
|
|
147
|
+
|
|
148
|
+
expect(result.blocked).toBe(false);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe('files in wrong directories', () => {
|
|
153
|
+
it('should warn about test files in src/', async () => {
|
|
154
|
+
const result = await fileOrg.analyze('src/utils.test.ts');
|
|
155
|
+
|
|
156
|
+
expect(result.blocked).toBe(false);
|
|
157
|
+
expect(result.issues?.some(i => i.type === 'wrong-directory')).toBe(true);
|
|
158
|
+
expect(result.warnings?.length).toBeGreaterThan(0);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('should warn about source files in tests/', async () => {
|
|
162
|
+
const result = await fileOrg.analyze('tests/utils.ts');
|
|
163
|
+
|
|
164
|
+
expect(result.blocked).toBe(false);
|
|
165
|
+
expect(result.issues?.some(i => i.type === 'wrong-directory')).toBe(true);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('formatter recommendations', () => {
|
|
170
|
+
it('should recommend Prettier for TypeScript', async () => {
|
|
171
|
+
const result = await fileOrg.analyze('src/utils.ts');
|
|
172
|
+
|
|
173
|
+
expect(result.formatter).toBeDefined();
|
|
174
|
+
expect(result.formatter!.name).toBe('Prettier');
|
|
175
|
+
expect(result.formatter!.command).toBe('prettier --write');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('should recommend Black for Python', async () => {
|
|
179
|
+
const result = await fileOrg.analyze('src/main.py');
|
|
180
|
+
|
|
181
|
+
expect(result.formatter).toBeDefined();
|
|
182
|
+
expect(result.formatter!.name).toBe('Black');
|
|
183
|
+
expect(result.formatter!.command).toBe('black');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('should recommend gofmt for Go', async () => {
|
|
187
|
+
const result = await fileOrg.analyze('cmd/main.go');
|
|
188
|
+
|
|
189
|
+
expect(result.formatter).toBeDefined();
|
|
190
|
+
expect(result.formatter!.name).toBe('gofmt');
|
|
191
|
+
expect(result.formatter!.command).toBe('gofmt -w');
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('should recommend rustfmt for Rust', async () => {
|
|
195
|
+
const result = await fileOrg.analyze('src/main.rs');
|
|
196
|
+
|
|
197
|
+
expect(result.formatter).toBeDefined();
|
|
198
|
+
expect(result.formatter!.name).toBe('rustfmt');
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('should recommend Prettier for CSS', async () => {
|
|
202
|
+
const result = await fileOrg.analyze('styles/app.css');
|
|
203
|
+
|
|
204
|
+
expect(result.formatter).toBeDefined();
|
|
205
|
+
expect(result.formatter!.name).toBe('Prettier');
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('should recommend Prettier for JSON', async () => {
|
|
209
|
+
const result = await fileOrg.analyze('config.json');
|
|
210
|
+
|
|
211
|
+
expect(result.formatter).toBeDefined();
|
|
212
|
+
expect(result.formatter!.name).toBe('Prettier');
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe('linter recommendations', () => {
|
|
217
|
+
it('should recommend ESLint for TypeScript', async () => {
|
|
218
|
+
const result = await fileOrg.analyze('src/utils.ts');
|
|
219
|
+
|
|
220
|
+
expect(result.linter).toBeDefined();
|
|
221
|
+
expect(result.linter!.name).toBe('ESLint');
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('should recommend Pylint for Python', async () => {
|
|
225
|
+
const result = await fileOrg.analyze('src/main.py');
|
|
226
|
+
|
|
227
|
+
expect(result.linter).toBeDefined();
|
|
228
|
+
expect(result.linter!.name).toBe('Pylint');
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('should recommend golangci-lint for Go', async () => {
|
|
232
|
+
const result = await fileOrg.analyze('cmd/main.go');
|
|
233
|
+
|
|
234
|
+
expect(result.linter).toBeDefined();
|
|
235
|
+
expect(result.linter!.name).toBe('golangci-lint');
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('should recommend Clippy for Rust', async () => {
|
|
239
|
+
const result = await fileOrg.analyze('src/main.rs');
|
|
240
|
+
|
|
241
|
+
expect(result.linter).toBeDefined();
|
|
242
|
+
expect(result.linter!.name).toBe('Clippy');
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
describe('organization issues', () => {
|
|
247
|
+
it('should detect root write issues', async () => {
|
|
248
|
+
const result = await fileOrg.analyze('utils.ts');
|
|
249
|
+
|
|
250
|
+
expect(result.issues).toBeDefined();
|
|
251
|
+
expect(result.issues!.some(i => i.type === 'root-write')).toBe(true);
|
|
252
|
+
expect(result.issues![0].severity).toBe('error');
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('should provide suggested fixes', async () => {
|
|
256
|
+
const result = await fileOrg.analyze('utils.ts');
|
|
257
|
+
|
|
258
|
+
expect(result.issues).toBeDefined();
|
|
259
|
+
expect(result.issues![0].suggestedFix).toBeDefined();
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
describe('helper methods', () => {
|
|
264
|
+
it('should get suggested directory for file', () => {
|
|
265
|
+
expect(fileOrg.getSuggestedDirectory('app.ts')).toBe('src/');
|
|
266
|
+
expect(fileOrg.getSuggestedDirectory('test.spec.ts')).toBe('tests/');
|
|
267
|
+
expect(fileOrg.getSuggestedDirectory('deploy.sh')).toBe('scripts/');
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it('should check if file would be blocked', () => {
|
|
271
|
+
expect(fileOrg.wouldBlock('utils.ts')).toBe(true);
|
|
272
|
+
expect(fileOrg.wouldBlock('package.json')).toBe(false);
|
|
273
|
+
expect(fileOrg.wouldBlock('src/utils.ts')).toBe(false);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('should allow setting project root', () => {
|
|
277
|
+
fileOrg.setProjectRoot('/custom/project');
|
|
278
|
+
// No error should be thrown
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('should get all formatters', () => {
|
|
282
|
+
const formatters = fileOrg.getAllFormatters();
|
|
283
|
+
|
|
284
|
+
expect(formatters['.ts']).toBeDefined();
|
|
285
|
+
expect(formatters['.py']).toBeDefined();
|
|
286
|
+
expect(formatters['.go']).toBeDefined();
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('should get all linters', () => {
|
|
290
|
+
const linters = fileOrg.getAllLinters();
|
|
291
|
+
|
|
292
|
+
expect(linters['.ts']).toBeDefined();
|
|
293
|
+
expect(linters['.py']).toBeDefined();
|
|
294
|
+
expect(linters['.go']).toBeDefined();
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
describe('file type detection', () => {
|
|
299
|
+
it('should detect TypeScript source type', async () => {
|
|
300
|
+
const result = await fileOrg.analyze('src/app.ts');
|
|
301
|
+
|
|
302
|
+
expect(result.fileType).toBe('TypeScript source');
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('should detect test file type', async () => {
|
|
306
|
+
const result = await fileOrg.analyze('tests/app.test.ts');
|
|
307
|
+
|
|
308
|
+
expect(result.fileType).toBe('test file');
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('should detect spec file type', async () => {
|
|
312
|
+
const result = await fileOrg.analyze('spec/app.spec.ts');
|
|
313
|
+
|
|
314
|
+
expect(result.fileType).toBe('spec file');
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('should detect shell script type', async () => {
|
|
318
|
+
const result = await fileOrg.analyze('scripts/build.sh');
|
|
319
|
+
|
|
320
|
+
expect(result.fileType).toBe('shell script');
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it('should detect SQL file type', async () => {
|
|
324
|
+
const result = await fileOrg.analyze('migrations/001_init.sql');
|
|
325
|
+
|
|
326
|
+
expect(result.fileType).toBe('SQL file');
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it('should detect image file type', async () => {
|
|
330
|
+
const result = await fileOrg.analyze('assets/logo.png');
|
|
331
|
+
|
|
332
|
+
expect(result.fileType).toBe('image');
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
});
|