@tonycasey/lisa 1.2.0 → 2.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/README.md +22 -15
- package/dist/hooks/session-start.js +43114 -0
- package/dist/hooks/session-stop.js +42699 -0
- package/dist/hooks/user-prompt-submit.js +42757 -0
- package/dist/lib/application/handlers/PromptSubmitHandler.d.ts +27 -0
- package/dist/lib/application/handlers/PromptSubmitHandler.d.ts.map +1 -0
- package/dist/lib/application/handlers/PromptSubmitHandler.js +53 -0
- package/dist/lib/application/handlers/PromptSubmitHandler.js.map +1 -0
- package/dist/lib/application/handlers/SessionStartHandler.d.ts +50 -0
- package/dist/lib/application/handlers/SessionStartHandler.d.ts.map +1 -0
- package/dist/lib/application/handlers/SessionStartHandler.js +448 -0
- package/dist/lib/application/handlers/SessionStartHandler.js.map +1 -0
- package/dist/lib/application/handlers/SessionStopHandler.d.ts +15 -0
- package/dist/lib/application/handlers/SessionStopHandler.d.ts.map +1 -0
- package/dist/lib/application/handlers/SessionStopHandler.js +35 -0
- package/dist/lib/application/handlers/SessionStopHandler.js.map +1 -0
- package/dist/lib/application/handlers/index.d.ts +8 -0
- package/dist/lib/application/handlers/index.d.ts.map +1 -0
- package/dist/lib/application/handlers/index.js +14 -0
- package/dist/lib/application/handlers/index.js.map +1 -0
- package/dist/lib/application/index.d.ts +13 -0
- package/dist/lib/application/index.d.ts.map +1 -0
- package/dist/lib/application/index.js +31 -0
- package/dist/lib/application/index.js.map +1 -0
- package/dist/lib/application/interfaces/ISessionStartResult.d.ts +22 -0
- package/dist/lib/application/interfaces/ISessionStartResult.d.ts.map +1 -0
- package/dist/lib/application/interfaces/ISessionStartResult.js +3 -0
- package/dist/lib/application/interfaces/ISessionStartResult.js.map +1 -0
- package/dist/lib/application/interfaces/index.d.ts +5 -0
- package/dist/lib/application/interfaces/index.d.ts.map +1 -0
- package/dist/lib/application/interfaces/index.js +6 -0
- package/dist/lib/application/interfaces/index.js.map +1 -0
- package/dist/lib/cli.d.ts +34 -0
- package/dist/lib/cli.d.ts.map +1 -0
- package/dist/lib/cli.js +664 -0
- package/dist/lib/cli.js.map +1 -0
- package/dist/lib/domain/errors/LisaError.d.ts +41 -0
- package/dist/lib/domain/errors/LisaError.d.ts.map +1 -0
- package/dist/lib/domain/errors/LisaError.js +69 -0
- package/dist/lib/domain/errors/LisaError.js.map +1 -0
- package/dist/lib/domain/errors/index.d.ts +5 -0
- package/dist/lib/domain/errors/index.d.ts.map +1 -0
- package/dist/lib/domain/errors/index.js +14 -0
- package/dist/lib/domain/errors/index.js.map +1 -0
- package/dist/lib/domain/index.d.ts +14 -0
- package/dist/lib/domain/index.d.ts.map +1 -0
- package/dist/lib/domain/index.js +33 -0
- package/dist/lib/domain/index.js.map +1 -0
- package/dist/lib/domain/interfaces/IEventEmitter.d.ts +32 -0
- package/dist/lib/domain/interfaces/IEventEmitter.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/IEventEmitter.js +3 -0
- package/dist/lib/domain/interfaces/IEventEmitter.js.map +1 -0
- package/dist/lib/domain/interfaces/ILisaContext.d.ts +25 -0
- package/dist/lib/domain/interfaces/ILisaContext.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/ILisaContext.js +3 -0
- package/dist/lib/domain/interfaces/ILisaContext.js.map +1 -0
- package/dist/lib/domain/interfaces/ILisaServices.d.ts +34 -0
- package/dist/lib/domain/interfaces/ILisaServices.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/ILisaServices.js +3 -0
- package/dist/lib/domain/interfaces/ILisaServices.js.map +1 -0
- package/dist/lib/domain/interfaces/ILogger.d.ts +94 -0
- package/dist/lib/domain/interfaces/ILogger.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/ILogger.js +3 -0
- package/dist/lib/domain/interfaces/ILogger.js.map +1 -0
- package/dist/lib/domain/interfaces/IMcpClient.d.ts +31 -0
- package/dist/lib/domain/interfaces/IMcpClient.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/IMcpClient.js +3 -0
- package/dist/lib/domain/interfaces/IMcpClient.js.map +1 -0
- package/dist/lib/domain/interfaces/IMemoryService.d.ts +56 -0
- package/dist/lib/domain/interfaces/IMemoryService.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/IMemoryService.js +3 -0
- package/dist/lib/domain/interfaces/IMemoryService.js.map +1 -0
- package/dist/lib/domain/interfaces/IRecursionService.d.ts +52 -0
- package/dist/lib/domain/interfaces/IRecursionService.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/IRecursionService.js +3 -0
- package/dist/lib/domain/interfaces/IRecursionService.js.map +1 -0
- package/dist/lib/domain/interfaces/ISessionCaptureService.d.ts +16 -0
- package/dist/lib/domain/interfaces/ISessionCaptureService.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/ISessionCaptureService.js +3 -0
- package/dist/lib/domain/interfaces/ISessionCaptureService.js.map +1 -0
- package/dist/lib/domain/interfaces/ITaskService.d.ts +52 -0
- package/dist/lib/domain/interfaces/ITaskService.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/ITaskService.js +3 -0
- package/dist/lib/domain/interfaces/ITaskService.js.map +1 -0
- package/dist/lib/domain/interfaces/dal/IConnectionManager.d.ts +110 -0
- package/dist/lib/domain/interfaces/dal/IConnectionManager.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/dal/IConnectionManager.js +8 -0
- package/dist/lib/domain/interfaces/dal/IConnectionManager.js.map +1 -0
- package/dist/lib/domain/interfaces/dal/IMemoryRepository.d.ts +93 -0
- package/dist/lib/domain/interfaces/dal/IMemoryRepository.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/dal/IMemoryRepository.js +9 -0
- package/dist/lib/domain/interfaces/dal/IMemoryRepository.js.map +1 -0
- package/dist/lib/domain/interfaces/dal/IRepositoryRouter.d.ts +88 -0
- package/dist/lib/domain/interfaces/dal/IRepositoryRouter.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/dal/IRepositoryRouter.js +23 -0
- package/dist/lib/domain/interfaces/dal/IRepositoryRouter.js.map +1 -0
- package/dist/lib/domain/interfaces/dal/ITaskRepository.d.ts +87 -0
- package/dist/lib/domain/interfaces/dal/ITaskRepository.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/dal/ITaskRepository.js +9 -0
- package/dist/lib/domain/interfaces/dal/ITaskRepository.js.map +1 -0
- package/dist/lib/domain/interfaces/dal/index.d.ts +14 -0
- package/dist/lib/domain/interfaces/dal/index.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/dal/index.js +15 -0
- package/dist/lib/domain/interfaces/dal/index.js.map +1 -0
- package/dist/lib/domain/interfaces/dal/types.d.ts +81 -0
- package/dist/lib/domain/interfaces/dal/types.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/dal/types.js +28 -0
- package/dist/lib/domain/interfaces/dal/types.js.map +1 -0
- package/dist/lib/domain/interfaces/events/IMemoryEvent.d.ts +27 -0
- package/dist/lib/domain/interfaces/events/IMemoryEvent.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/events/IMemoryEvent.js +26 -0
- package/dist/lib/domain/interfaces/events/IMemoryEvent.js.map +1 -0
- package/dist/lib/domain/interfaces/events/IPromptSubmitEvent.d.ts +20 -0
- package/dist/lib/domain/interfaces/events/IPromptSubmitEvent.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/events/IPromptSubmitEvent.js +16 -0
- package/dist/lib/domain/interfaces/events/IPromptSubmitEvent.js.map +1 -0
- package/dist/lib/domain/interfaces/events/ISessionStartEvent.d.ts +19 -0
- package/dist/lib/domain/interfaces/events/ISessionStartEvent.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/events/ISessionStartEvent.js +15 -0
- package/dist/lib/domain/interfaces/events/ISessionStartEvent.js.map +1 -0
- package/dist/lib/domain/interfaces/events/ISessionStopEvent.d.ts +22 -0
- package/dist/lib/domain/interfaces/events/ISessionStopEvent.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/events/ISessionStopEvent.js +15 -0
- package/dist/lib/domain/interfaces/events/ISessionStopEvent.js.map +1 -0
- package/dist/lib/domain/interfaces/events/LisaEvent.d.ts +13 -0
- package/dist/lib/domain/interfaces/events/LisaEvent.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/events/LisaEvent.js +3 -0
- package/dist/lib/domain/interfaces/events/LisaEvent.js.map +1 -0
- package/dist/lib/domain/interfaces/events/index.d.ts +9 -0
- package/dist/lib/domain/interfaces/events/index.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/events/index.js +16 -0
- package/dist/lib/domain/interfaces/events/index.js.map +1 -0
- package/dist/lib/domain/interfaces/index.d.ts +16 -0
- package/dist/lib/domain/interfaces/index.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/index.js +25 -0
- package/dist/lib/domain/interfaces/index.js.map +1 -0
- package/dist/lib/domain/interfaces/types/ICapturedWork.d.ts +14 -0
- package/dist/lib/domain/interfaces/types/ICapturedWork.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/types/ICapturedWork.js +14 -0
- package/dist/lib/domain/interfaces/types/ICapturedWork.js.map +1 -0
- package/dist/lib/domain/interfaces/types/IMemoryResult.d.ts +39 -0
- package/dist/lib/domain/interfaces/types/IMemoryResult.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/types/IMemoryResult.js +29 -0
- package/dist/lib/domain/interfaces/types/IMemoryResult.js.map +1 -0
- package/dist/lib/domain/interfaces/types/ITask.d.ts +46 -0
- package/dist/lib/domain/interfaces/types/ITask.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/types/ITask.js +17 -0
- package/dist/lib/domain/interfaces/types/ITask.js.map +1 -0
- package/dist/lib/domain/interfaces/types/index.d.ts +7 -0
- package/dist/lib/domain/interfaces/types/index.d.ts.map +1 -0
- package/dist/lib/domain/interfaces/types/index.js +14 -0
- package/dist/lib/domain/interfaces/types/index.js.map +1 -0
- package/dist/lib/domain/types/ISOTimestamp.d.ts +19 -0
- package/dist/lib/domain/types/ISOTimestamp.d.ts.map +1 -0
- package/dist/lib/domain/types/ISOTimestamp.js +18 -0
- package/dist/lib/domain/types/ISOTimestamp.js.map +1 -0
- package/dist/lib/domain/types/index.d.ts +7 -0
- package/dist/lib/domain/types/index.d.ts.map +1 -0
- package/dist/lib/domain/types/index.js +12 -0
- package/dist/lib/domain/types/index.js.map +1 -0
- package/dist/lib/infrastructure/adapters/claude/index.d.ts +8 -0
- package/dist/lib/infrastructure/adapters/claude/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/adapters/claude/index.js +18 -0
- package/dist/lib/infrastructure/adapters/claude/index.js.map +1 -0
- package/dist/lib/infrastructure/adapters/claude/session-start.d.ts +9 -0
- package/dist/lib/infrastructure/adapters/claude/session-start.d.ts.map +1 -0
- package/dist/lib/infrastructure/adapters/claude/session-start.js +54 -0
- package/dist/lib/infrastructure/adapters/claude/session-start.js.map +1 -0
- package/dist/lib/infrastructure/adapters/claude/session-stop.d.ts +13 -0
- package/dist/lib/infrastructure/adapters/claude/session-stop.d.ts.map +1 -0
- package/dist/lib/infrastructure/adapters/claude/session-stop.js +43 -0
- package/dist/lib/infrastructure/adapters/claude/session-stop.js.map +1 -0
- package/dist/lib/infrastructure/adapters/claude/stdin.d.ts +13 -0
- package/dist/lib/infrastructure/adapters/claude/stdin.d.ts.map +1 -0
- package/dist/lib/infrastructure/adapters/claude/stdin.js +36 -0
- package/dist/lib/infrastructure/adapters/claude/stdin.js.map +1 -0
- package/dist/lib/infrastructure/adapters/claude/user-prompt-submit.d.ts +13 -0
- package/dist/lib/infrastructure/adapters/claude/user-prompt-submit.d.ts.map +1 -0
- package/dist/lib/infrastructure/adapters/claude/user-prompt-submit.js +58 -0
- package/dist/lib/infrastructure/adapters/claude/user-prompt-submit.js.map +1 -0
- package/dist/lib/infrastructure/adapters/opencode/index.d.ts +7 -0
- package/dist/lib/infrastructure/adapters/opencode/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/adapters/opencode/index.js +18 -0
- package/dist/lib/infrastructure/adapters/opencode/index.js.map +1 -0
- package/dist/lib/infrastructure/adapters/opencode/opencode-events.d.ts +73 -0
- package/dist/lib/infrastructure/adapters/opencode/opencode-events.d.ts.map +1 -0
- package/dist/lib/infrastructure/adapters/opencode/opencode-events.js +131 -0
- package/dist/lib/infrastructure/adapters/opencode/opencode-events.js.map +1 -0
- package/dist/lib/infrastructure/adapters/opencode/plugin.d.ts +60 -0
- package/dist/lib/infrastructure/adapters/opencode/plugin.d.ts.map +1 -0
- package/dist/lib/infrastructure/adapters/opencode/plugin.js +147 -0
- package/dist/lib/infrastructure/adapters/opencode/plugin.js.map +1 -0
- package/dist/lib/infrastructure/context/ContextDetector.d.ts +92 -0
- package/dist/lib/infrastructure/context/ContextDetector.d.ts.map +1 -0
- package/dist/lib/infrastructure/context/ContextDetector.js +415 -0
- package/dist/lib/infrastructure/context/ContextDetector.js.map +1 -0
- package/dist/lib/infrastructure/context/index.d.ts +5 -0
- package/dist/lib/infrastructure/context/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/context/index.js +9 -0
- package/dist/lib/infrastructure/context/index.js.map +1 -0
- package/dist/lib/infrastructure/dal/RepositoryFactory.d.ts +71 -0
- package/dist/lib/infrastructure/dal/RepositoryFactory.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/RepositoryFactory.js +134 -0
- package/dist/lib/infrastructure/dal/RepositoryFactory.js.map +1 -0
- package/dist/lib/infrastructure/dal/connections/McpConnectionManager.d.ts +56 -0
- package/dist/lib/infrastructure/dal/connections/McpConnectionManager.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/connections/McpConnectionManager.js +98 -0
- package/dist/lib/infrastructure/dal/connections/McpConnectionManager.js.map +1 -0
- package/dist/lib/infrastructure/dal/connections/Neo4jConnectionManager.d.ts +60 -0
- package/dist/lib/infrastructure/dal/connections/Neo4jConnectionManager.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/connections/Neo4jConnectionManager.js +181 -0
- package/dist/lib/infrastructure/dal/connections/Neo4jConnectionManager.js.map +1 -0
- package/dist/lib/infrastructure/dal/connections/ZepConnectionManager.d.ts +53 -0
- package/dist/lib/infrastructure/dal/connections/ZepConnectionManager.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/connections/ZepConnectionManager.js +168 -0
- package/dist/lib/infrastructure/dal/connections/ZepConnectionManager.js.map +1 -0
- package/dist/lib/infrastructure/dal/connections/index.d.ts +9 -0
- package/dist/lib/infrastructure/dal/connections/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/connections/index.js +18 -0
- package/dist/lib/infrastructure/dal/connections/index.js.map +1 -0
- package/dist/lib/infrastructure/dal/index.d.ts +27 -0
- package/dist/lib/infrastructure/dal/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/index.js +50 -0
- package/dist/lib/infrastructure/dal/index.js.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/index.d.ts +7 -0
- package/dist/lib/infrastructure/dal/repositories/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/index.js +19 -0
- package/dist/lib/infrastructure/dal/repositories/index.js.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/McpMemoryRepository.d.ts +54 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/McpMemoryRepository.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/McpMemoryRepository.js +131 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/McpMemoryRepository.js.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/McpTaskRepository.d.ts +60 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/McpTaskRepository.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/McpTaskRepository.js +182 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/McpTaskRepository.js.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/index.d.ts +6 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/index.js +11 -0
- package/dist/lib/infrastructure/dal/repositories/mcp/index.js.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/Neo4jMemoryRepository.d.ts +47 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/Neo4jMemoryRepository.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/Neo4jMemoryRepository.js +144 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/Neo4jMemoryRepository.js.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/Neo4jTaskRepository.d.ts +46 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/Neo4jTaskRepository.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/Neo4jTaskRepository.js +160 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/Neo4jTaskRepository.js.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/index.d.ts +6 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/index.js +11 -0
- package/dist/lib/infrastructure/dal/repositories/neo4j/index.js.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/zep/ZepMemoryRepository.d.ts +55 -0
- package/dist/lib/infrastructure/dal/repositories/zep/ZepMemoryRepository.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/zep/ZepMemoryRepository.js +165 -0
- package/dist/lib/infrastructure/dal/repositories/zep/ZepMemoryRepository.js.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/zep/ZepTaskRepository.d.ts +58 -0
- package/dist/lib/infrastructure/dal/repositories/zep/ZepTaskRepository.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/zep/ZepTaskRepository.js +206 -0
- package/dist/lib/infrastructure/dal/repositories/zep/ZepTaskRepository.js.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/zep/index.d.ts +6 -0
- package/dist/lib/infrastructure/dal/repositories/zep/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/repositories/zep/index.js +11 -0
- package/dist/lib/infrastructure/dal/repositories/zep/index.js.map +1 -0
- package/dist/lib/infrastructure/dal/routing/RepositoryRouter.d.ts +73 -0
- package/dist/lib/infrastructure/dal/routing/RepositoryRouter.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/routing/RepositoryRouter.js +170 -0
- package/dist/lib/infrastructure/dal/routing/RepositoryRouter.js.map +1 -0
- package/dist/lib/infrastructure/dal/routing/index.d.ts +5 -0
- package/dist/lib/infrastructure/dal/routing/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/dal/routing/index.js +10 -0
- package/dist/lib/infrastructure/dal/routing/index.js.map +1 -0
- package/dist/lib/infrastructure/di/ServiceFactory.d.ts +44 -0
- package/dist/lib/infrastructure/di/ServiceFactory.d.ts.map +1 -0
- package/dist/lib/infrastructure/di/ServiceFactory.js +141 -0
- package/dist/lib/infrastructure/di/ServiceFactory.js.map +1 -0
- package/dist/lib/infrastructure/di/index.d.ts +5 -0
- package/dist/lib/infrastructure/di/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/di/index.js +10 -0
- package/dist/lib/infrastructure/di/index.js.map +1 -0
- package/dist/lib/infrastructure/index.d.ts +17 -0
- package/dist/lib/infrastructure/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/index.js +41 -0
- package/dist/lib/infrastructure/index.js.map +1 -0
- package/dist/lib/infrastructure/logging/Logger.d.ts +50 -0
- package/dist/lib/infrastructure/logging/Logger.d.ts.map +1 -0
- package/dist/lib/infrastructure/logging/Logger.js +167 -0
- package/dist/lib/infrastructure/logging/Logger.js.map +1 -0
- package/dist/lib/infrastructure/logging/context.d.ts +51 -0
- package/dist/lib/infrastructure/logging/context.d.ts.map +1 -0
- package/dist/lib/infrastructure/logging/context.js +77 -0
- package/dist/lib/infrastructure/logging/context.js.map +1 -0
- package/dist/lib/infrastructure/logging/factory.d.ts +36 -0
- package/dist/lib/infrastructure/logging/factory.d.ts.map +1 -0
- package/dist/lib/infrastructure/logging/factory.js +122 -0
- package/dist/lib/infrastructure/logging/factory.js.map +1 -0
- package/dist/lib/infrastructure/logging/index.d.ts +26 -0
- package/dist/lib/infrastructure/logging/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/logging/index.js +45 -0
- package/dist/lib/infrastructure/logging/index.js.map +1 -0
- package/dist/lib/infrastructure/mcp/McpClient.d.ts +36 -0
- package/dist/lib/infrastructure/mcp/McpClient.d.ts.map +1 -0
- package/dist/lib/infrastructure/mcp/McpClient.js +155 -0
- package/dist/lib/infrastructure/mcp/McpClient.js.map +1 -0
- package/dist/lib/infrastructure/mcp/index.d.ts +5 -0
- package/dist/lib/infrastructure/mcp/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/mcp/index.js +9 -0
- package/dist/lib/infrastructure/mcp/index.js.map +1 -0
- package/dist/lib/infrastructure/services/EventEmitter.d.ts +24 -0
- package/dist/lib/infrastructure/services/EventEmitter.d.ts.map +1 -0
- package/dist/lib/infrastructure/services/EventEmitter.js +41 -0
- package/dist/lib/infrastructure/services/EventEmitter.js.map +1 -0
- package/dist/lib/infrastructure/services/MemoryService.d.ts +48 -0
- package/dist/lib/infrastructure/services/MemoryService.d.ts.map +1 -0
- package/dist/lib/infrastructure/services/MemoryService.js +298 -0
- package/dist/lib/infrastructure/services/MemoryService.js.map +1 -0
- package/dist/lib/infrastructure/services/RecursionService.d.ts +50 -0
- package/dist/lib/infrastructure/services/RecursionService.d.ts.map +1 -0
- package/dist/lib/infrastructure/services/RecursionService.js +233 -0
- package/dist/lib/infrastructure/services/RecursionService.js.map +1 -0
- package/dist/lib/infrastructure/services/SessionCaptureService.d.ts +31 -0
- package/dist/lib/infrastructure/services/SessionCaptureService.d.ts.map +1 -0
- package/dist/lib/infrastructure/services/SessionCaptureService.js +38 -0
- package/dist/lib/infrastructure/services/SessionCaptureService.js.map +1 -0
- package/dist/lib/infrastructure/services/TaskService.d.ts +38 -0
- package/dist/lib/infrastructure/services/TaskService.d.ts.map +1 -0
- package/dist/lib/infrastructure/services/TaskService.js +227 -0
- package/dist/lib/infrastructure/services/TaskService.js.map +1 -0
- package/dist/lib/infrastructure/services/index.d.ts +9 -0
- package/dist/lib/infrastructure/services/index.d.ts.map +1 -0
- package/dist/lib/infrastructure/services/index.js +17 -0
- package/dist/lib/infrastructure/services/index.js.map +1 -0
- package/dist/lib/interfaces/IDockerClient.d.ts +6 -0
- package/dist/lib/interfaces/IDockerClient.d.ts.map +1 -0
- package/dist/lib/interfaces/IDockerClient.js +1 -0
- package/dist/lib/interfaces/IDockerClient.js.map +1 -0
- package/dist/lib/interfaces/IMcpClient.d.ts +7 -0
- package/dist/lib/interfaces/IMcpClient.d.ts.map +1 -0
- package/dist/lib/interfaces/IMcpClient.js +1 -0
- package/dist/lib/interfaces/IMcpClient.js.map +1 -0
- package/dist/lib/interfaces/IServices.d.ts +9 -0
- package/dist/lib/interfaces/IServices.d.ts.map +1 -0
- package/dist/lib/interfaces/IServices.js +1 -0
- package/dist/lib/interfaces/IServices.js.map +1 -0
- package/dist/lib/interfaces/ITemplateCopier.d.ts +6 -0
- package/dist/lib/interfaces/ITemplateCopier.d.ts.map +1 -0
- package/dist/lib/interfaces/ITemplateCopier.js +1 -0
- package/dist/lib/interfaces/ITemplateCopier.js.map +1 -0
- package/dist/lib/mcp.d.ts +5 -0
- package/dist/lib/mcp.d.ts.map +1 -0
- package/dist/lib/mcp.js +12 -1
- package/dist/lib/mcp.js.map +1 -0
- package/dist/lib/scanner/analyzer.d.ts +51 -0
- package/dist/lib/scanner/analyzer.d.ts.map +1 -0
- package/dist/lib/scanner/analyzer.js +6 -1
- package/dist/lib/scanner/analyzer.js.map +1 -0
- package/dist/lib/scanner/discovery.d.ts +25 -0
- package/dist/lib/scanner/discovery.d.ts.map +1 -0
- package/dist/lib/scanner/discovery.js +4 -3
- package/dist/lib/scanner/discovery.js.map +1 -0
- package/dist/lib/scanner/facts.d.ts +33 -0
- package/dist/lib/scanner/facts.d.ts.map +1 -0
- package/dist/lib/scanner/facts.js +23 -5
- package/dist/lib/scanner/facts.js.map +1 -0
- package/dist/lib/scanner/index.d.ts +31 -0
- package/dist/lib/scanner/index.d.ts.map +1 -0
- package/dist/lib/scanner/index.js +1 -6
- package/dist/lib/scanner/index.js.map +1 -0
- package/dist/lib/scanner/reviewer.d.ts +62 -0
- package/dist/lib/scanner/reviewer.d.ts.map +1 -0
- package/dist/lib/scanner/reviewer.js +26 -8
- package/dist/lib/scanner/reviewer.js.map +1 -0
- package/dist/lib/services.d.ts +7 -0
- package/dist/lib/services.d.ts.map +1 -0
- package/dist/lib/services.js +1 -0
- package/dist/lib/services.js.map +1 -0
- package/dist/opencode/lisa.js +43344 -0
- package/dist/package.json +15 -3
- package/dist/project/.lisa/.env.template +18 -0
- package/dist/{templates → project/.lisa}/rules/shared/git-rules.md +6 -6
- package/dist/project/.lisa/skills/common/group-id.d.ts.map +1 -0
- package/dist/{templates/agents → project/.lisa}/skills/common/group-id.js +1 -0
- package/dist/project/.lisa/skills/common/group-id.js.map +1 -0
- package/dist/project/.lisa/skills/common/type-mappings.d.ts.map +1 -0
- package/dist/project/.lisa/skills/common/type-mappings.js +93 -0
- package/dist/project/.lisa/skills/common/type-mappings.js.map +1 -0
- package/dist/{templates/agents → project/.lisa}/skills/git/SKILL.md +7 -7
- package/dist/project/.lisa/skills/git/scripts/bump-version.d.ts.map +1 -0
- package/dist/project/.lisa/skills/git/scripts/bump-version.js +58 -0
- package/dist/project/.lisa/skills/git/scripts/bump-version.js.map +1 -0
- package/dist/{templates/agents → project/.lisa}/skills/init-review/SKILL.md +2 -2
- package/dist/project/.lisa/skills/init-review/scripts/ai-enrich.d.ts.map +1 -0
- package/dist/project/.lisa/skills/init-review/scripts/ai-enrich.js +177 -0
- package/dist/project/.lisa/skills/init-review/scripts/ai-enrich.js.map +1 -0
- package/dist/project/.lisa/skills/init-review/scripts/init-review.d.ts.map +1 -0
- package/dist/project/.lisa/skills/init-review/scripts/init-review.js +143 -0
- package/dist/project/.lisa/skills/init-review/scripts/init-review.js.map +1 -0
- package/dist/project/.lisa/skills/jira/scripts/jira.d.ts.map +1 -0
- package/dist/project/.lisa/skills/jira/scripts/jira.js +159 -0
- package/dist/project/.lisa/skills/jira/scripts/jira.js.map +1 -0
- package/dist/{templates/agents → project/.lisa}/skills/lisa/SKILL.md +17 -15
- package/dist/project/.lisa/skills/lisa/scripts/compile-skills.d.ts.map +1 -0
- package/dist/project/.lisa/skills/lisa/scripts/compile-skills.js +75 -0
- package/dist/project/.lisa/skills/lisa/scripts/compile-skills.js.map +1 -0
- package/dist/project/.lisa/skills/lisa/scripts/storage.d.ts.map +1 -0
- package/dist/project/.lisa/skills/lisa/scripts/storage.js +114 -0
- package/dist/project/.lisa/skills/lisa/scripts/storage.js.map +1 -0
- package/dist/{templates/agents → project/.lisa}/skills/memory/SKILL.md +3 -3
- package/dist/project/.lisa/skills/memory/scripts/memory.d.ts.map +1 -0
- package/dist/project/.lisa/skills/memory/scripts/memory.js +95 -0
- package/dist/project/.lisa/skills/memory/scripts/memory.js.map +1 -0
- package/dist/{templates/agents → project/.lisa}/skills/prompt/SKILL.md +1 -1
- package/dist/project/.lisa/skills/prompt/scripts/prompt.d.ts.map +1 -0
- package/dist/project/.lisa/skills/prompt/scripts/prompt.js +80 -0
- package/dist/project/.lisa/skills/prompt/scripts/prompt.js.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/McpClient.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/McpClient.js +117 -0
- package/dist/project/.lisa/skills/shared/clients/McpClient.js.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/Neo4jClient.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/Neo4jClient.js +81 -0
- package/dist/project/.lisa/skills/shared/clients/Neo4jClient.js.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/ZepClient.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/ZepClient.js +238 -0
- package/dist/project/.lisa/skills/shared/clients/ZepClient.js.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/index.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/index.js +33 -0
- package/dist/project/.lisa/skills/shared/clients/index.js.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/IMcpClient.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/IMcpClient.js +3 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/IMcpClient.js.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/INeo4jClient.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/INeo4jClient.js +3 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/INeo4jClient.js.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/IZepClient.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/IZepClient.js +3 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/IZepClient.js.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/index.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/index.js +23 -0
- package/dist/project/.lisa/skills/shared/clients/interfaces/index.js.map +1 -0
- package/dist/project/.lisa/skills/shared/group-id.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/group-id.js +18 -0
- package/dist/project/.lisa/skills/shared/group-id.js.map +1 -0
- package/dist/project/.lisa/skills/shared/index.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/index.js +31 -0
- package/dist/project/.lisa/skills/shared/index.js.map +1 -0
- package/dist/project/.lisa/skills/shared/logger.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/logger.js +18 -0
- package/dist/project/.lisa/skills/shared/logger.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/InitReviewService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/InitReviewService.js +287 -0
- package/dist/project/.lisa/skills/shared/services/InitReviewService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/JiraService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/JiraService.js +257 -0
- package/dist/project/.lisa/skills/shared/services/JiraService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/MemoryCliService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/MemoryCliService.js +36 -0
- package/dist/project/.lisa/skills/shared/services/MemoryCliService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/MemoryService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/MemoryService.js +146 -0
- package/dist/project/.lisa/skills/shared/services/MemoryService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/PromptService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/PromptService.js +53 -0
- package/dist/project/.lisa/skills/shared/services/PromptService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/SkillCompilerService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/SkillCompilerService.js +115 -0
- package/dist/project/.lisa/skills/shared/services/SkillCompilerService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/StorageService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/StorageService.js +257 -0
- package/dist/project/.lisa/skills/shared/services/StorageService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/TaskCliService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/TaskCliService.js +40 -0
- package/dist/project/.lisa/skills/shared/services/TaskCliService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/TaskService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/TaskService.js +158 -0
- package/dist/project/.lisa/skills/shared/services/TaskService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/VersionService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/VersionService.js +88 -0
- package/dist/project/.lisa/skills/shared/services/VersionService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/index.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/index.js +47 -0
- package/dist/project/.lisa/skills/shared/services/index.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/interfaces/IMemoryService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/interfaces/IMemoryService.js +7 -0
- package/dist/project/.lisa/skills/shared/services/interfaces/IMemoryService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/interfaces/ITaskService.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/interfaces/ITaskService.js +7 -0
- package/dist/project/.lisa/skills/shared/services/interfaces/ITaskService.js.map +1 -0
- package/dist/project/.lisa/skills/shared/services/interfaces/index.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/services/interfaces/index.js +22 -0
- package/dist/project/.lisa/skills/shared/services/interfaces/index.js.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/FileCache.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/FileCache.js +119 -0
- package/dist/project/.lisa/skills/shared/utils/FileCache.js.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/Logger.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/Logger.js +197 -0
- package/dist/project/.lisa/skills/shared/utils/Logger.js.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/cache.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/cache.js +76 -0
- package/dist/project/.lisa/skills/shared/utils/cache.js.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/cli.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/cli.js +87 -0
- package/dist/project/.lisa/skills/shared/utils/cli.js.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/env.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/env.js +103 -0
- package/dist/project/.lisa/skills/shared/utils/env.js.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/group-id.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/group-id.js +91 -0
- package/dist/project/.lisa/skills/shared/utils/group-id.js.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/index.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/index.js +55 -0
- package/dist/project/.lisa/skills/shared/utils/index.js.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/interfaces/ICache.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/interfaces/ICache.js +3 -0
- package/dist/project/.lisa/skills/shared/utils/interfaces/ICache.js.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/interfaces/ILogger.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/interfaces/ILogger.js +3 -0
- package/dist/project/.lisa/skills/shared/utils/interfaces/ILogger.js.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/interfaces/index.d.ts.map +1 -0
- package/dist/project/.lisa/skills/shared/utils/interfaces/index.js +22 -0
- package/dist/project/.lisa/skills/shared/utils/interfaces/index.js.map +1 -0
- package/dist/{templates/agents → project/.lisa}/skills/tasks/SKILL.md +2 -2
- package/dist/project/.lisa/skills/tasks/scripts/tasks.d.ts.map +1 -0
- package/dist/project/.lisa/skills/tasks/scripts/tasks.js +98 -0
- package/dist/project/.lisa/skills/tasks/scripts/tasks.js.map +1 -0
- package/package.json +31 -10
- package/scripts/postinstall.js +93 -60
- package/dist/cli.js +0 -414
- package/dist/templates/agents/.sample.env +0 -12
- package/dist/templates/agents/docs/EXTENDING-SKILLS.md +0 -291
- package/dist/templates/agents/docs/EXTENDING-rules.md +0 -57
- package/dist/templates/agents/docs/STORAGE_SETUP.md +0 -161
- package/dist/templates/agents/skills/git/scripts/bump-version.js +0 -112
- package/dist/templates/agents/skills/init-review/scripts/ai-enrich.js +0 -258
- package/dist/templates/agents/skills/init-review/scripts/init-review.js +0 -769
- package/dist/templates/agents/skills/jira/scripts/jira.js +0 -406
- package/dist/templates/agents/skills/lisa/scripts/compile-skills.js +0 -177
- package/dist/templates/agents/skills/lisa/scripts/storage.js +0 -374
- package/dist/templates/agents/skills/memory/scripts/memory.js +0 -533
- package/dist/templates/agents/skills/prompt/scripts/prompt.js +0 -184
- package/dist/templates/agents/skills/tasks/scripts/tasks.js +0 -489
- package/dist/templates/claude/config.js +0 -40
- package/dist/templates/claude/hooks/README.md +0 -158
- package/dist/templates/claude/hooks/common/complexity-rater.js +0 -290
- package/dist/templates/claude/hooks/common/context.js +0 -263
- package/dist/templates/claude/hooks/common/group-id.js +0 -188
- package/dist/templates/claude/hooks/common/mcp-client.js +0 -131
- package/dist/templates/claude/hooks/common/transcript-parser.js +0 -256
- package/dist/templates/claude/hooks/common/zep-client.js +0 -175
- package/dist/templates/claude/hooks/session-start.js +0 -511
- package/dist/templates/claude/hooks/session-stop-worker.js +0 -484
- package/dist/templates/claude/hooks/session-stop.js +0 -122
- package/dist/templates/claude/hooks/user-prompt-submit.js +0 -479
- package/dist/templates/claude/settings.json +0 -46
- package/dist/templates/docker/.env.lisa.example +0 -17
- /package/dist/{templates → project/.lisa}/docker/docker-compose.graphiti.yml +0 -0
- /package/dist/{templates → project/.lisa}/rules/shared/clean-architecture.md +0 -0
- /package/dist/{templates → project/.lisa}/rules/shared/code-quality-rules.md +0 -0
- /package/dist/{templates → project/.lisa}/rules/shared/git-rules.local.md +0 -0
- /package/dist/{templates → project/.lisa}/rules/shared/testing-principles.md +0 -0
- /package/dist/{templates → project/.lisa}/rules/typescript/coding-standards.md +0 -0
- /package/dist/{templates → project/.lisa}/rules/typescript/testing.md +0 -0
- /package/dist/{templates → project/.lisa}/rules/typescript/typescript-config-guide.md +0 -0
- /package/dist/{templates/agents → project/.lisa}/skills/git/scripts/poll-ci.sh +0 -0
- /package/dist/{templates/agents → project/.lisa}/skills/jira/SKILL.md +0 -0
- /package/dist/{templates/agents → project/.lisa}/skills/lisa/cache/.gitkeep +0 -0
|
@@ -1,484 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
/**
|
|
5
|
-
* Claude Code - Session Stop Worker (Background)
|
|
6
|
-
*
|
|
7
|
-
* ASYNC BACKGROUND WORKER - Runs detached from main hook
|
|
8
|
-
*
|
|
9
|
-
* This worker:
|
|
10
|
-
* 1. Parses the session transcript
|
|
11
|
-
* 2. Rates work complexity (1-5)
|
|
12
|
-
* 3. Routes to Graphiti (3+) or local logs (1-2)
|
|
13
|
-
*
|
|
14
|
-
* Called by session-stop.ts with input as CLI argument
|
|
15
|
-
*/
|
|
16
|
-
const fs = require('fs');
|
|
17
|
-
const path = require('path');
|
|
18
|
-
const { spawn } = require('child_process');
|
|
19
|
-
// Import common modules
|
|
20
|
-
const { parseTranscript, findMostRecentTranscript, formatDuration } = require('./common/transcript-parser');
|
|
21
|
-
const { rateComplexity, getRatingLabel } = require('./common/complexity-rater');
|
|
22
|
-
const { detectRepo, detectBranch } = require('./common/context');
|
|
23
|
-
const LOGS_DIR = '.logs';
|
|
24
|
-
const WORK_SESSIONS_FILE = 'work-sessions.jsonl';
|
|
25
|
-
const ERROR_LOG_FILE = 'stop-hook-errors.log';
|
|
26
|
-
const MAX_LOG_SIZE = 10 * 1024 * 1024; // 10 MB
|
|
27
|
-
const MEMORY_SKILL_TIMEOUT_MS = 10000; // 10 seconds
|
|
28
|
-
/**
|
|
29
|
-
* Main worker entry point
|
|
30
|
-
*/
|
|
31
|
-
async function main() {
|
|
32
|
-
try {
|
|
33
|
-
// 1. Parse input from CLI argument
|
|
34
|
-
const inputArg = process.argv[2];
|
|
35
|
-
if (!inputArg) {
|
|
36
|
-
logError('No input provided to worker');
|
|
37
|
-
process.exit(0);
|
|
38
|
-
}
|
|
39
|
-
const input = JSON.parse(inputArg);
|
|
40
|
-
// 2. Change to working directory
|
|
41
|
-
if (input.cwd && fs.existsSync(input.cwd)) {
|
|
42
|
-
process.chdir(input.cwd);
|
|
43
|
-
}
|
|
44
|
-
// 3. Find transcript file
|
|
45
|
-
const transcriptPath = findTranscript(input.transcript_path);
|
|
46
|
-
if (!transcriptPath) {
|
|
47
|
-
logError('Transcript not found', input.transcript_path);
|
|
48
|
-
process.exit(0);
|
|
49
|
-
}
|
|
50
|
-
// 4. Parse transcript
|
|
51
|
-
const work = parseTranscript(transcriptPath);
|
|
52
|
-
// 5. Check if there was any meaningful work
|
|
53
|
-
if (work.filesModified.size === 0 && work.filesCreated.size === 0 && work.commandsRun.length === 0) {
|
|
54
|
-
// No work to capture - exit silently
|
|
55
|
-
process.exit(0);
|
|
56
|
-
}
|
|
57
|
-
// 6. Rate complexity
|
|
58
|
-
const rating = rateComplexity(work);
|
|
59
|
-
// 7. Route based on complexity
|
|
60
|
-
if (rating.rating >= 3) {
|
|
61
|
-
// Significant work -> Graphiti
|
|
62
|
-
await saveToGraphiti(work, rating, input);
|
|
63
|
-
// 7b. Save retrospective learnings for significant work
|
|
64
|
-
await saveRetrospective(work, input);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
// Minor work -> Local logs
|
|
68
|
-
await saveToLocalLogs(work, rating, input);
|
|
69
|
-
}
|
|
70
|
-
// 8. Exit successfully
|
|
71
|
-
process.exit(0);
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
const error = err;
|
|
75
|
-
logError('Worker error', error.message);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Find transcript file, handling known bugs with stale paths
|
|
81
|
-
*/
|
|
82
|
-
function findTranscript(providedPath) {
|
|
83
|
-
// Try provided path first
|
|
84
|
-
if (providedPath && fs.existsSync(providedPath)) {
|
|
85
|
-
return providedPath;
|
|
86
|
-
}
|
|
87
|
-
// Fall back to finding most recent transcript in the session directory
|
|
88
|
-
if (providedPath) {
|
|
89
|
-
const dir = path.dirname(providedPath);
|
|
90
|
-
const found = findMostRecentTranscript(dir);
|
|
91
|
-
if (found)
|
|
92
|
-
return found;
|
|
93
|
-
}
|
|
94
|
-
// Try common transcript locations
|
|
95
|
-
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
96
|
-
const sessionDirs = [
|
|
97
|
-
path.join(homeDir, '.claude', 'projects'),
|
|
98
|
-
path.join(homeDir, '.claude-code', 'sessions'),
|
|
99
|
-
];
|
|
100
|
-
for (const baseDir of sessionDirs) {
|
|
101
|
-
if (fs.existsSync(baseDir)) {
|
|
102
|
-
const found = findMostRecentTranscript(baseDir);
|
|
103
|
-
if (found)
|
|
104
|
-
return found;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Save significant work to Graphiti via memory skill
|
|
111
|
-
*/
|
|
112
|
-
async function saveToGraphiti(work, rating, input) {
|
|
113
|
-
const repo = detectRepo();
|
|
114
|
-
const branch = detectBranch();
|
|
115
|
-
// Build summary text for Graphiti
|
|
116
|
-
const summary = buildGraphitiSummary(work, rating, repo, branch, input.session_id);
|
|
117
|
-
// Find memory skill script
|
|
118
|
-
const memoryScript = path.join(process.cwd(), '.agents/skills/memory/scripts/memory.js');
|
|
119
|
-
if (!fs.existsSync(memoryScript)) {
|
|
120
|
-
// Memory skill not available - fall back to local logs
|
|
121
|
-
logError('Memory skill not found, saving locally');
|
|
122
|
-
await saveToLocalLogs(work, rating, input);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
// Call memory skill to save
|
|
126
|
-
return new Promise((resolve) => {
|
|
127
|
-
let resolved = false; // Guard against multiple resolves
|
|
128
|
-
const safeResolve = () => {
|
|
129
|
-
if (resolved)
|
|
130
|
-
return;
|
|
131
|
-
resolved = true;
|
|
132
|
-
resolve();
|
|
133
|
-
};
|
|
134
|
-
const fallbackAndResolve = async () => {
|
|
135
|
-
if (resolved)
|
|
136
|
-
return;
|
|
137
|
-
resolved = true;
|
|
138
|
-
await saveToLocalLogs(work, rating, input);
|
|
139
|
-
resolve();
|
|
140
|
-
};
|
|
141
|
-
const args = [
|
|
142
|
-
memoryScript,
|
|
143
|
-
'add',
|
|
144
|
-
summary,
|
|
145
|
-
'--group',
|
|
146
|
-
repo || 'agent-memories',
|
|
147
|
-
'--tag',
|
|
148
|
-
'automated',
|
|
149
|
-
'--tag',
|
|
150
|
-
`complexity:${rating.rating}`,
|
|
151
|
-
'--tag',
|
|
152
|
-
'milestone',
|
|
153
|
-
'--tag',
|
|
154
|
-
`session:${input.session_id}`,
|
|
155
|
-
'--source',
|
|
156
|
-
'session-stop',
|
|
157
|
-
'--cache',
|
|
158
|
-
];
|
|
159
|
-
if (repo)
|
|
160
|
-
args.push('--tag', `repo:${repo}`);
|
|
161
|
-
if (branch)
|
|
162
|
-
args.push('--tag', `branch:${branch}`);
|
|
163
|
-
const child = spawn('node', args, {
|
|
164
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
165
|
-
cwd: process.cwd(),
|
|
166
|
-
});
|
|
167
|
-
let stderr = '';
|
|
168
|
-
child.stderr?.on('data', (data) => {
|
|
169
|
-
stderr += data.toString();
|
|
170
|
-
});
|
|
171
|
-
child.on('close', (code) => {
|
|
172
|
-
if (code !== 0 && stderr) {
|
|
173
|
-
logError('Memory skill failed', stderr);
|
|
174
|
-
// Fall back to local logs on Graphiti failure
|
|
175
|
-
fallbackAndResolve();
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
safeResolve();
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
child.on('error', (err) => {
|
|
182
|
-
logError('Memory skill spawn error', err.message);
|
|
183
|
-
// Fall back to local logs
|
|
184
|
-
fallbackAndResolve();
|
|
185
|
-
});
|
|
186
|
-
// Timeout handling
|
|
187
|
-
const timeoutId = setTimeout(() => {
|
|
188
|
-
if (resolved)
|
|
189
|
-
return;
|
|
190
|
-
try {
|
|
191
|
-
child.kill();
|
|
192
|
-
}
|
|
193
|
-
catch (_e) {
|
|
194
|
-
// Ignore kill errors
|
|
195
|
-
}
|
|
196
|
-
logError('Memory skill timeout');
|
|
197
|
-
fallbackAndResolve();
|
|
198
|
-
}, MEMORY_SKILL_TIMEOUT_MS);
|
|
199
|
-
// Clear timeout if resolved normally
|
|
200
|
-
child.on('close', () => {
|
|
201
|
-
clearTimeout(timeoutId);
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Build summary text for Graphiti storage
|
|
207
|
-
*/
|
|
208
|
-
function buildGraphitiSummary(work, rating, repo, branch, sessionId) {
|
|
209
|
-
const lines = [];
|
|
210
|
-
// Header with complexity rating
|
|
211
|
-
lines.push(`MILESTONE [complexity:${rating.rating}]: ${rating.summary}`);
|
|
212
|
-
lines.push('');
|
|
213
|
-
// Session info
|
|
214
|
-
lines.push(`Session: ${sessionId}`);
|
|
215
|
-
if (repo)
|
|
216
|
-
lines.push(`Repository: ${repo}${branch ? ` (${branch})` : ''}`);
|
|
217
|
-
lines.push(`Duration: ${formatDuration(work.durationMs)}`);
|
|
218
|
-
lines.push(`Timestamp: ${work.timestamp}`);
|
|
219
|
-
lines.push('');
|
|
220
|
-
// Work summary
|
|
221
|
-
lines.push(`Files modified: ${work.filesModified.size}`);
|
|
222
|
-
lines.push(`Files created: ${work.filesCreated.size}`);
|
|
223
|
-
if (work.commandsRun.length > 0) {
|
|
224
|
-
lines.push(`Commands run: ${work.commandsRun.length}`);
|
|
225
|
-
}
|
|
226
|
-
lines.push('');
|
|
227
|
-
// Key changes
|
|
228
|
-
if (work.filesCreated.size > 0 || work.filesModified.size > 0) {
|
|
229
|
-
lines.push('Key changes:');
|
|
230
|
-
const allFiles = [...work.filesCreated].map((f) => `- Created ${f}`);
|
|
231
|
-
allFiles.push(...[...work.filesModified].map((f) => `- Modified ${f}`));
|
|
232
|
-
// Limit to 10 files
|
|
233
|
-
lines.push(...allFiles.slice(0, 10));
|
|
234
|
-
if (allFiles.length > 10) {
|
|
235
|
-
lines.push(`- ... and ${allFiles.length - 10} more`);
|
|
236
|
-
}
|
|
237
|
-
lines.push('');
|
|
238
|
-
}
|
|
239
|
-
// Tools used
|
|
240
|
-
const toolsSummary = Array.from(work.toolsUsed.entries())
|
|
241
|
-
.map(([tool, count]) => `${tool} (${count}x)`)
|
|
242
|
-
.join(', ');
|
|
243
|
-
if (toolsSummary) {
|
|
244
|
-
lines.push(`Tools used: ${toolsSummary}`);
|
|
245
|
-
lines.push('');
|
|
246
|
-
}
|
|
247
|
-
// Complexity signals
|
|
248
|
-
if (rating.signals.length > 0) {
|
|
249
|
-
lines.push(`Signals: ${rating.signals.join(', ')}`);
|
|
250
|
-
lines.push('');
|
|
251
|
-
}
|
|
252
|
-
// Assistant summary (truncated)
|
|
253
|
-
if (work.assistantSummary) {
|
|
254
|
-
lines.push('Summary:');
|
|
255
|
-
lines.push(work.assistantSummary);
|
|
256
|
-
}
|
|
257
|
-
return lines.join('\n');
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Analyze work and save retrospective learnings
|
|
261
|
-
* Extracts patterns from files created/modified
|
|
262
|
-
*/
|
|
263
|
-
async function saveRetrospective(work, input) {
|
|
264
|
-
const allFiles = [...work.filesCreated, ...work.filesModified];
|
|
265
|
-
if (allFiles.length === 0)
|
|
266
|
-
return;
|
|
267
|
-
const patterns = analyzePatterns(allFiles);
|
|
268
|
-
if (!patterns)
|
|
269
|
-
return;
|
|
270
|
-
const repo = detectRepo();
|
|
271
|
-
const memoryScript = path.join(process.cwd(), '.agents/skills/memory/scripts/memory.js');
|
|
272
|
-
if (!fs.existsSync(memoryScript)) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
const retrospective = `RETROSPECTIVE: ${patterns}`;
|
|
276
|
-
return new Promise((resolve) => {
|
|
277
|
-
const args = [
|
|
278
|
-
memoryScript,
|
|
279
|
-
'add',
|
|
280
|
-
retrospective,
|
|
281
|
-
'--group',
|
|
282
|
-
repo || 'agent-memories',
|
|
283
|
-
'--tag',
|
|
284
|
-
'retrospective',
|
|
285
|
-
'--tag',
|
|
286
|
-
'automated',
|
|
287
|
-
'--tag',
|
|
288
|
-
`session:${input.session_id}`,
|
|
289
|
-
'--source',
|
|
290
|
-
'session-stop-retrospective',
|
|
291
|
-
'--cache',
|
|
292
|
-
];
|
|
293
|
-
if (repo)
|
|
294
|
-
args.push('--tag', `repo:${repo}`);
|
|
295
|
-
const child = spawn('node', args, {
|
|
296
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
297
|
-
cwd: process.cwd(),
|
|
298
|
-
});
|
|
299
|
-
child.on('close', () => resolve());
|
|
300
|
-
child.on('error', () => resolve());
|
|
301
|
-
// Timeout after 5 seconds
|
|
302
|
-
setTimeout(() => {
|
|
303
|
-
try {
|
|
304
|
-
child.kill();
|
|
305
|
-
}
|
|
306
|
-
catch {
|
|
307
|
-
// Ignore
|
|
308
|
-
}
|
|
309
|
-
resolve();
|
|
310
|
-
}, 5000);
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Analyze file patterns to extract learnings
|
|
315
|
-
*/
|
|
316
|
-
function analyzePatterns(files) {
|
|
317
|
-
const learnings = [];
|
|
318
|
-
// Analyze directory structure
|
|
319
|
-
const directories = new Set();
|
|
320
|
-
const extensions = new Map();
|
|
321
|
-
const hasTests = files.some((f) => f.includes('test') || f.includes('spec') || f.includes('__tests__'));
|
|
322
|
-
const hasTypes = files.some((f) => f.endsWith('.d.ts') || f.includes('types'));
|
|
323
|
-
for (const file of files) {
|
|
324
|
-
// Track directories
|
|
325
|
-
const dir = path.dirname(file);
|
|
326
|
-
if (dir && dir !== '.') {
|
|
327
|
-
directories.add(dir.split('/')[0] || dir);
|
|
328
|
-
}
|
|
329
|
-
// Track extensions
|
|
330
|
-
const ext = path.extname(file);
|
|
331
|
-
if (ext) {
|
|
332
|
-
extensions.set(ext, (extensions.get(ext) || 0) + 1);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
// Structure patterns
|
|
336
|
-
if (directories.size > 0) {
|
|
337
|
-
const topDirs = Array.from(directories).slice(0, 5);
|
|
338
|
-
learnings.push(`STRUCTURE: Files organized in ${topDirs.join(', ')}`);
|
|
339
|
-
}
|
|
340
|
-
// Technology patterns
|
|
341
|
-
const extList = Array.from(extensions.entries())
|
|
342
|
-
.sort((a, b) => b[1] - a[1])
|
|
343
|
-
.slice(0, 3)
|
|
344
|
-
.map(([ext]) => ext);
|
|
345
|
-
if (extList.length > 0) {
|
|
346
|
-
learnings.push(`TECH: Primary file types ${extList.join(', ')}`);
|
|
347
|
-
}
|
|
348
|
-
// Test patterns
|
|
349
|
-
if (hasTests) {
|
|
350
|
-
const testFiles = files.filter((f) => f.includes('test') || f.includes('spec'));
|
|
351
|
-
const testDir = testFiles.length > 0 ? path.dirname(testFiles[0]) : null;
|
|
352
|
-
if (testDir) {
|
|
353
|
-
learnings.push(`TESTING: Tests located in ${testDir}`);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
// Type patterns
|
|
357
|
-
if (hasTypes) {
|
|
358
|
-
learnings.push('STYLE: Project uses TypeScript type definitions');
|
|
359
|
-
}
|
|
360
|
-
// Naming patterns
|
|
361
|
-
const namingPatterns = detectNamingPatterns(files);
|
|
362
|
-
if (namingPatterns) {
|
|
363
|
-
learnings.push(`NAMING: ${namingPatterns}`);
|
|
364
|
-
}
|
|
365
|
-
return learnings.length > 0 ? learnings.join('; ') : null;
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Detect naming conventions from file names
|
|
369
|
-
*/
|
|
370
|
-
function detectNamingPatterns(files) {
|
|
371
|
-
const fileNames = files.map((f) => path.basename(f, path.extname(f)));
|
|
372
|
-
let kebabCount = 0;
|
|
373
|
-
let camelCount = 0;
|
|
374
|
-
let pascalCount = 0;
|
|
375
|
-
let snakeCount = 0;
|
|
376
|
-
for (const name of fileNames) {
|
|
377
|
-
if (name.includes('-'))
|
|
378
|
-
kebabCount++;
|
|
379
|
-
else if (name.includes('_'))
|
|
380
|
-
snakeCount++;
|
|
381
|
-
else if (name[0] === name[0].toUpperCase() && name.includes(name.toLowerCase()))
|
|
382
|
-
pascalCount++;
|
|
383
|
-
else if (/[a-z][A-Z]/.test(name))
|
|
384
|
-
camelCount++;
|
|
385
|
-
}
|
|
386
|
-
const total = fileNames.length;
|
|
387
|
-
if (total === 0)
|
|
388
|
-
return null;
|
|
389
|
-
const patterns = [];
|
|
390
|
-
if (kebabCount / total > 0.5)
|
|
391
|
-
patterns.push('kebab-case for files');
|
|
392
|
-
if (camelCount / total > 0.5)
|
|
393
|
-
patterns.push('camelCase for files');
|
|
394
|
-
if (pascalCount / total > 0.5)
|
|
395
|
-
patterns.push('PascalCase for files');
|
|
396
|
-
if (snakeCount / total > 0.5)
|
|
397
|
-
patterns.push('snake_case for files');
|
|
398
|
-
return patterns.length > 0 ? patterns.join(', ') : null;
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* Save minor work to local JSONL logs
|
|
402
|
-
*/
|
|
403
|
-
async function saveToLocalLogs(work, rating, input) {
|
|
404
|
-
const logsDir = path.join(process.cwd(), LOGS_DIR);
|
|
405
|
-
const logsFile = path.join(logsDir, WORK_SESSIONS_FILE);
|
|
406
|
-
// Ensure directory exists
|
|
407
|
-
if (!fs.existsSync(logsDir)) {
|
|
408
|
-
fs.mkdirSync(logsDir, { recursive: true });
|
|
409
|
-
}
|
|
410
|
-
// Rotate logs if needed
|
|
411
|
-
rotateLogsIfNeeded(logsFile);
|
|
412
|
-
// Build log entry
|
|
413
|
-
const entry = {
|
|
414
|
-
timestamp: new Date().toISOString(),
|
|
415
|
-
sessionId: input.session_id,
|
|
416
|
-
complexity: rating.rating,
|
|
417
|
-
rawScore: rating.rawScore,
|
|
418
|
-
signals: rating.signals,
|
|
419
|
-
summary: rating.summary,
|
|
420
|
-
repo: detectRepo(),
|
|
421
|
-
branch: detectBranch(),
|
|
422
|
-
duration: formatDuration(work.durationMs),
|
|
423
|
-
durationMs: work.durationMs,
|
|
424
|
-
filesModified: Array.from(work.filesModified),
|
|
425
|
-
filesCreated: Array.from(work.filesCreated),
|
|
426
|
-
commandCount: work.commandsRun.length,
|
|
427
|
-
toolsUsed: Object.fromEntries(work.toolsUsed),
|
|
428
|
-
assistantSummary: work.assistantSummary.substring(0, 200),
|
|
429
|
-
};
|
|
430
|
-
// Append to JSONL file
|
|
431
|
-
fs.appendFileSync(logsFile, JSON.stringify(entry) + '\n');
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Rotate log file if it exceeds max size
|
|
435
|
-
*/
|
|
436
|
-
function rotateLogsIfNeeded(logsFile) {
|
|
437
|
-
if (!fs.existsSync(logsFile))
|
|
438
|
-
return;
|
|
439
|
-
try {
|
|
440
|
-
const stats = fs.statSync(logsFile);
|
|
441
|
-
if (stats.size > MAX_LOG_SIZE) {
|
|
442
|
-
const archiveDir = path.join(path.dirname(logsFile), 'archive');
|
|
443
|
-
if (!fs.existsSync(archiveDir)) {
|
|
444
|
-
fs.mkdirSync(archiveDir, { recursive: true });
|
|
445
|
-
}
|
|
446
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
447
|
-
const archivePath = path.join(archiveDir, `work-sessions-${timestamp}.jsonl`);
|
|
448
|
-
fs.renameSync(logsFile, archivePath);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
catch (_err) {
|
|
452
|
-
// Ignore rotation errors
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Log error to error log file
|
|
457
|
-
*/
|
|
458
|
-
function logError(message, details) {
|
|
459
|
-
const logsDir = path.join(process.cwd(), LOGS_DIR);
|
|
460
|
-
const errorLog = path.join(logsDir, ERROR_LOG_FILE);
|
|
461
|
-
try {
|
|
462
|
-
if (!fs.existsSync(logsDir)) {
|
|
463
|
-
fs.mkdirSync(logsDir, { recursive: true });
|
|
464
|
-
}
|
|
465
|
-
const timestamp = new Date().toISOString();
|
|
466
|
-
const entry = `[${timestamp}] ${message}${details ? `: ${details}` : ''}\n`;
|
|
467
|
-
fs.appendFileSync(errorLog, entry);
|
|
468
|
-
}
|
|
469
|
-
catch (_err) {
|
|
470
|
-
// Ignore log errors - don't fail silently
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
// Global error handlers
|
|
474
|
-
process.on('uncaughtException', (err) => {
|
|
475
|
-
logError('Uncaught exception', err.stack || err.message);
|
|
476
|
-
process.exit(1);
|
|
477
|
-
});
|
|
478
|
-
process.on('unhandledRejection', (reason) => {
|
|
479
|
-
const message = reason instanceof Error ? reason.message : String(reason);
|
|
480
|
-
logError('Unhandled rejection', message);
|
|
481
|
-
process.exit(1);
|
|
482
|
-
});
|
|
483
|
-
// Run main
|
|
484
|
-
main();
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
/**
|
|
5
|
-
* Claude Code - Session Stop Hook (Main)
|
|
6
|
-
*
|
|
7
|
-
* FAST EXIT HOOK - Must exit in < 50ms
|
|
8
|
-
*
|
|
9
|
-
* This hook spawns a detached background worker to analyze the session
|
|
10
|
-
* and capture work to Graphiti or local logs. The main hook exits
|
|
11
|
-
* immediately to avoid blocking the CLI.
|
|
12
|
-
*
|
|
13
|
-
* Architecture:
|
|
14
|
-
* 1. Main Hook (this file) - Spawns worker, exits fast
|
|
15
|
-
* 2. Background Worker (session-stop-worker.js) - Does heavy lifting async
|
|
16
|
-
*
|
|
17
|
-
* Configuration: .claude/settings.json -> hooks.Stop
|
|
18
|
-
*/
|
|
19
|
-
const { spawn } = require('child_process');
|
|
20
|
-
const path = require('path');
|
|
21
|
-
const fs = require('fs');
|
|
22
|
-
const STDIN_TIMEOUT_MS = 100; // Max time to wait for stdin
|
|
23
|
-
/**
|
|
24
|
-
* Read JSON input from stdin
|
|
25
|
-
*/
|
|
26
|
-
async function readStdin() {
|
|
27
|
-
return new Promise((resolve) => {
|
|
28
|
-
let input = '';
|
|
29
|
-
// Set a short timeout for reading stdin
|
|
30
|
-
const timeout = setTimeout(() => {
|
|
31
|
-
resolve({});
|
|
32
|
-
}, STDIN_TIMEOUT_MS);
|
|
33
|
-
process.stdin.setEncoding('utf8');
|
|
34
|
-
process.stdin.on('data', (chunk) => {
|
|
35
|
-
input += chunk;
|
|
36
|
-
});
|
|
37
|
-
process.stdin.on('end', () => {
|
|
38
|
-
clearTimeout(timeout);
|
|
39
|
-
try {
|
|
40
|
-
resolve(JSON.parse(input));
|
|
41
|
-
}
|
|
42
|
-
catch (_err) {
|
|
43
|
-
resolve({});
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
// Handle case where stdin is already closed
|
|
47
|
-
if (process.stdin.readableEnded) {
|
|
48
|
-
clearTimeout(timeout);
|
|
49
|
-
resolve({});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Main hook entry point
|
|
55
|
-
* MUST exit within 50ms to avoid blocking CLI
|
|
56
|
-
*/
|
|
57
|
-
async function main() {
|
|
58
|
-
// 1. Read input from stdin
|
|
59
|
-
const input = await readStdin();
|
|
60
|
-
// 2. Safety: prevent infinite loops
|
|
61
|
-
if (input.stop_hook_active) {
|
|
62
|
-
console.log(JSON.stringify({ continue: false }));
|
|
63
|
-
process.exit(0);
|
|
64
|
-
}
|
|
65
|
-
// 3. Determine working directory
|
|
66
|
-
const cwd = input.cwd || process.cwd();
|
|
67
|
-
// 4. Find the worker script
|
|
68
|
-
const workerPath = path.join(__dirname, 'session-stop-worker.js');
|
|
69
|
-
// Check if worker exists
|
|
70
|
-
if (!fs.existsSync(workerPath)) {
|
|
71
|
-
// Worker not deployed yet - exit silently
|
|
72
|
-
console.log(JSON.stringify({
|
|
73
|
-
continue: false,
|
|
74
|
-
stopReason: 'Worker not found',
|
|
75
|
-
}));
|
|
76
|
-
process.exit(0);
|
|
77
|
-
}
|
|
78
|
-
// 5. Prepare input for worker
|
|
79
|
-
const workerInput = JSON.stringify({
|
|
80
|
-
session_id: input.session_id || 'unknown',
|
|
81
|
-
transcript_path: input.transcript_path || '',
|
|
82
|
-
cwd: cwd,
|
|
83
|
-
});
|
|
84
|
-
// 6. Spawn detached background worker
|
|
85
|
-
try {
|
|
86
|
-
const worker = spawn('node', [workerPath, workerInput], {
|
|
87
|
-
detached: true, // Detach from parent process
|
|
88
|
-
stdio: 'ignore', // Don't wait for I/O
|
|
89
|
-
cwd: cwd, // Worker runs in project directory
|
|
90
|
-
env: {
|
|
91
|
-
...process.env,
|
|
92
|
-
STOP_HOOK_WORKER: 'true', // Mark as worker process
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
// Unref to allow parent to exit independently
|
|
96
|
-
worker.unref();
|
|
97
|
-
}
|
|
98
|
-
catch (_err) {
|
|
99
|
-
// Spawn failed - exit silently, don't block CLI
|
|
100
|
-
}
|
|
101
|
-
// 7. Exit immediately
|
|
102
|
-
console.log(JSON.stringify({
|
|
103
|
-
continue: false,
|
|
104
|
-
stopReason: 'Work capture queued in background',
|
|
105
|
-
}));
|
|
106
|
-
process.exit(0);
|
|
107
|
-
}
|
|
108
|
-
// Run main with error handling
|
|
109
|
-
// CRITICAL: Never block - exit cleanly even on error
|
|
110
|
-
main().catch((err) => {
|
|
111
|
-
// Log error for debugging but don't block
|
|
112
|
-
const errorLog = '/tmp/claude-stop-hook-error.log';
|
|
113
|
-
try {
|
|
114
|
-
fs.appendFileSync(errorLog, `[${new Date().toISOString()}] ${err.message}\n`);
|
|
115
|
-
}
|
|
116
|
-
catch (_writeErr) {
|
|
117
|
-
// Ignore write errors
|
|
118
|
-
}
|
|
119
|
-
// Always exit cleanly
|
|
120
|
-
console.log(JSON.stringify({ continue: false }));
|
|
121
|
-
process.exit(0);
|
|
122
|
-
});
|