@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,263 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const { execSync } = require('child_process');
|
|
6
|
-
const ENV_FILE = '.agents/.env';
|
|
7
|
-
/**
|
|
8
|
-
* Parse a .env file into key-value pairs
|
|
9
|
-
*/
|
|
10
|
-
function parseEnvFile(content) {
|
|
11
|
-
const env = {};
|
|
12
|
-
content.split(/\r?\n/).forEach((line) => {
|
|
13
|
-
if (!line || line.startsWith('#'))
|
|
14
|
-
return;
|
|
15
|
-
const idx = line.indexOf('=');
|
|
16
|
-
if (idx === -1)
|
|
17
|
-
return;
|
|
18
|
-
env[line.slice(0, idx).trim()] = line.slice(idx + 1).trim();
|
|
19
|
-
});
|
|
20
|
-
return env;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Read the .agents/.env file
|
|
24
|
-
*/
|
|
25
|
-
function readEnvConfig() {
|
|
26
|
-
const envPath = path.join(process.cwd(), ENV_FILE);
|
|
27
|
-
try {
|
|
28
|
-
if (fs.existsSync(envPath)) {
|
|
29
|
-
const content = fs.readFileSync(envPath, 'utf8');
|
|
30
|
-
return parseEnvFile(content);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
catch (_err) {
|
|
34
|
-
// File doesn't exist or is invalid
|
|
35
|
-
}
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Write or update PROJECT_NAME in .agents/.env
|
|
40
|
-
* Preserves existing entries
|
|
41
|
-
*/
|
|
42
|
-
function writeProjectName(projectName, detectedFrom) {
|
|
43
|
-
const envPath = path.join(process.cwd(), ENV_FILE);
|
|
44
|
-
const agentsDir = path.join(process.cwd(), '.agents');
|
|
45
|
-
try {
|
|
46
|
-
// Ensure .agents directory exists
|
|
47
|
-
if (!fs.existsSync(agentsDir)) {
|
|
48
|
-
fs.mkdirSync(agentsDir, { recursive: true });
|
|
49
|
-
}
|
|
50
|
-
// Read existing content
|
|
51
|
-
let lines = [];
|
|
52
|
-
if (fs.existsSync(envPath)) {
|
|
53
|
-
lines = fs.readFileSync(envPath, 'utf8').split(/\r?\n/);
|
|
54
|
-
}
|
|
55
|
-
// Check if PROJECT_NAME already exists
|
|
56
|
-
const hasProjectName = lines.some(line => line.trim().startsWith('PROJECT_NAME='));
|
|
57
|
-
if (!hasProjectName) {
|
|
58
|
-
// Add PROJECT_NAME with a comment about detection source
|
|
59
|
-
const newLines = [
|
|
60
|
-
`# Project name detected from ${detectedFrom}`,
|
|
61
|
-
`PROJECT_NAME=${projectName}`,
|
|
62
|
-
'',
|
|
63
|
-
];
|
|
64
|
-
// Prepend to existing content
|
|
65
|
-
const content = [...newLines, ...lines].join('\n');
|
|
66
|
-
fs.writeFileSync(envPath, content);
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
catch (_err) {
|
|
71
|
-
// Failed to write - continue without persisting
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Detect project name from package.json
|
|
77
|
-
*/
|
|
78
|
-
function detectFromPackageJson() {
|
|
79
|
-
try {
|
|
80
|
-
const pkgPath = path.join(process.cwd(), 'package.json');
|
|
81
|
-
if (fs.existsSync(pkgPath)) {
|
|
82
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
83
|
-
if (pkg.name && typeof pkg.name === 'string') {
|
|
84
|
-
// Strip org scope if present (e.g., @org/package -> package)
|
|
85
|
-
return pkg.name.replace(/^@[^/]+\//, '');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
catch (_err) {
|
|
90
|
-
// Ignore parse errors
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Detect project name from pyproject.toml (Python)
|
|
96
|
-
*/
|
|
97
|
-
function detectFromPyproject() {
|
|
98
|
-
try {
|
|
99
|
-
const pyPath = path.join(process.cwd(), 'pyproject.toml');
|
|
100
|
-
if (fs.existsSync(pyPath)) {
|
|
101
|
-
const content = fs.readFileSync(pyPath, 'utf8');
|
|
102
|
-
// Simple regex to find name in [project] or [tool.poetry] section
|
|
103
|
-
const match = content.match(/^\s*name\s*=\s*["']([^"']+)["']/m);
|
|
104
|
-
if (match) {
|
|
105
|
-
return match[1];
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
catch (_err) {
|
|
110
|
-
// Ignore errors
|
|
111
|
-
}
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Detect project name from Cargo.toml (Rust)
|
|
116
|
-
*/
|
|
117
|
-
function detectFromCargoToml() {
|
|
118
|
-
try {
|
|
119
|
-
const cargoPath = path.join(process.cwd(), 'Cargo.toml');
|
|
120
|
-
if (fs.existsSync(cargoPath)) {
|
|
121
|
-
const content = fs.readFileSync(cargoPath, 'utf8');
|
|
122
|
-
const match = content.match(/^\s*name\s*=\s*["']([^"']+)["']/m);
|
|
123
|
-
if (match) {
|
|
124
|
-
return match[1];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
catch (_err) {
|
|
129
|
-
// Ignore errors
|
|
130
|
-
}
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Detect project name from go.mod (Go)
|
|
135
|
-
*/
|
|
136
|
-
function detectFromGoMod() {
|
|
137
|
-
try {
|
|
138
|
-
const goModPath = path.join(process.cwd(), 'go.mod');
|
|
139
|
-
if (fs.existsSync(goModPath)) {
|
|
140
|
-
const content = fs.readFileSync(goModPath, 'utf8');
|
|
141
|
-
// Module line like: module github.com/user/project
|
|
142
|
-
const match = content.match(/^\s*module\s+(\S+)/m);
|
|
143
|
-
if (match) {
|
|
144
|
-
// Return just the last part (project name)
|
|
145
|
-
const parts = match[1].split('/');
|
|
146
|
-
return parts[parts.length - 1];
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
catch (_err) {
|
|
151
|
-
// Ignore errors
|
|
152
|
-
}
|
|
153
|
-
return null;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Detect project name using the fallback chain
|
|
157
|
-
* Returns { name, source } where source indicates where it was detected from
|
|
158
|
-
*/
|
|
159
|
-
function detectProjectName() {
|
|
160
|
-
// 1. Try package.json
|
|
161
|
-
const pkgName = detectFromPackageJson();
|
|
162
|
-
if (pkgName) {
|
|
163
|
-
return { name: pkgName, source: 'package.json' };
|
|
164
|
-
}
|
|
165
|
-
// 2. Try pyproject.toml
|
|
166
|
-
const pyName = detectFromPyproject();
|
|
167
|
-
if (pyName) {
|
|
168
|
-
return { name: pyName, source: 'pyproject.toml' };
|
|
169
|
-
}
|
|
170
|
-
// 3. Try Cargo.toml
|
|
171
|
-
const cargoName = detectFromCargoToml();
|
|
172
|
-
if (cargoName) {
|
|
173
|
-
return { name: cargoName, source: 'Cargo.toml' };
|
|
174
|
-
}
|
|
175
|
-
// 4. Try go.mod
|
|
176
|
-
const goName = detectFromGoMod();
|
|
177
|
-
if (goName) {
|
|
178
|
-
return { name: goName, source: 'go.mod' };
|
|
179
|
-
}
|
|
180
|
-
// 5. Fallback to folder name
|
|
181
|
-
return { name: path.basename(process.cwd()), source: 'folder' };
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Get the project name, initializing .agents/.env if needed
|
|
185
|
-
*/
|
|
186
|
-
function detectRepo() {
|
|
187
|
-
// 1. Check for PROJECT_NAME in .agents/.env
|
|
188
|
-
const env = readEnvConfig();
|
|
189
|
-
if (env.PROJECT_NAME) {
|
|
190
|
-
return env.PROJECT_NAME;
|
|
191
|
-
}
|
|
192
|
-
// 2. Detect from config files and auto-initialize
|
|
193
|
-
const detected = detectProjectName();
|
|
194
|
-
writeProjectName(detected.name, detected.source);
|
|
195
|
-
return detected.name;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Get project aliases for querying (includes current name and all aliases)
|
|
199
|
-
*/
|
|
200
|
-
function getProjectAliases() {
|
|
201
|
-
const env = readEnvConfig();
|
|
202
|
-
const projectName = env.PROJECT_NAME || detectRepo();
|
|
203
|
-
const folderName = path.basename(process.cwd());
|
|
204
|
-
const aliases = new Set();
|
|
205
|
-
aliases.add(projectName);
|
|
206
|
-
// Add explicit aliases from PROJECT_ALIASES
|
|
207
|
-
if (env.PROJECT_ALIASES) {
|
|
208
|
-
env.PROJECT_ALIASES.split(',').forEach(alias => {
|
|
209
|
-
const trimmed = alias.trim();
|
|
210
|
-
if (trimmed)
|
|
211
|
-
aliases.add(trimmed);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
// Auto-include folder name if different from project name
|
|
215
|
-
if (folderName !== projectName) {
|
|
216
|
-
aliases.add(folderName);
|
|
217
|
-
}
|
|
218
|
-
return Array.from(aliases);
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Get the env file path
|
|
222
|
-
*/
|
|
223
|
-
function getEnvPath() {
|
|
224
|
-
return path.join(process.cwd(), ENV_FILE);
|
|
225
|
-
}
|
|
226
|
-
function detectBranch() {
|
|
227
|
-
try {
|
|
228
|
-
const out = execSync('git rev-parse --abbrev-ref HEAD', { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
229
|
-
return out.toString().trim();
|
|
230
|
-
}
|
|
231
|
-
catch (_err) {
|
|
232
|
-
return null;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function repoTags({ repo, branch } = {}) {
|
|
236
|
-
const tags = [];
|
|
237
|
-
if (repo)
|
|
238
|
-
tags.push(`repo:${repo}`);
|
|
239
|
-
if (branch)
|
|
240
|
-
tags.push(`branch:${branch}`);
|
|
241
|
-
return tags;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Generate repo tags for all aliases (for querying)
|
|
245
|
-
*/
|
|
246
|
-
function repoTagsWithAliases({ branch } = {}) {
|
|
247
|
-
const aliases = getProjectAliases();
|
|
248
|
-
return aliases.map(alias => repoTags({ repo: alias, branch }));
|
|
249
|
-
}
|
|
250
|
-
function getUserName() {
|
|
251
|
-
return process.env.USER || process.env.USERNAME || 'unknown';
|
|
252
|
-
}
|
|
253
|
-
module.exports = {
|
|
254
|
-
detectRepo,
|
|
255
|
-
detectBranch,
|
|
256
|
-
repoTags,
|
|
257
|
-
repoTagsWithAliases,
|
|
258
|
-
getProjectAliases,
|
|
259
|
-
getEnvPath,
|
|
260
|
-
getUserName,
|
|
261
|
-
readEnvConfig,
|
|
262
|
-
ENV_FILE,
|
|
263
|
-
};
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const os = require('os');
|
|
6
|
-
const MAX_GROUP_ID_LENGTH = 128;
|
|
7
|
-
// ============================================================================
|
|
8
|
-
// Group ID Functions
|
|
9
|
-
// ============================================================================
|
|
10
|
-
/**
|
|
11
|
-
* Normalize a path to a valid group ID string.
|
|
12
|
-
* /Users/tony.casey/Repos/api -> users-tony.casey-repos-api
|
|
13
|
-
*/
|
|
14
|
-
function normalizePathToGroupId(absolutePath) {
|
|
15
|
-
let normalized = absolutePath
|
|
16
|
-
.toLowerCase()
|
|
17
|
-
.replace(/^\//, '') // Remove leading slash
|
|
18
|
-
.replace(/\//g, '-') // Replace slashes with dashes
|
|
19
|
-
.replace(/\./g, '_'); // Replace dots with underscores (Graphiti requires alphanumeric, dashes, underscores only)
|
|
20
|
-
// Truncate if too long (keep the end which is most specific)
|
|
21
|
-
if (normalized.length > MAX_GROUP_ID_LENGTH) {
|
|
22
|
-
normalized = normalized.slice(-MAX_GROUP_ID_LENGTH);
|
|
23
|
-
}
|
|
24
|
-
return normalized;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Get the current folder's group ID.
|
|
28
|
-
*/
|
|
29
|
-
function getCurrentGroupId(cwd = process.cwd()) {
|
|
30
|
-
return normalizePathToGroupId(cwd);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Get hierarchical group IDs from current folder up to home directory.
|
|
34
|
-
* Returns array ordered from most specific (current) to least specific (home).
|
|
35
|
-
*
|
|
36
|
-
* Example for /Users/tony/Repos/api/src:
|
|
37
|
-
* ['users-tony-repos-api-src', 'users-tony-repos-api', 'users-tony-repos', 'users-tony']
|
|
38
|
-
*/
|
|
39
|
-
function getHierarchicalGroupIds(cwd = process.cwd()) {
|
|
40
|
-
const homeDir = os.homedir();
|
|
41
|
-
const groups = [];
|
|
42
|
-
let currentPath = path.resolve(cwd);
|
|
43
|
-
// Walk up the directory tree until we reach home or root
|
|
44
|
-
while (currentPath.length >= homeDir.length) {
|
|
45
|
-
groups.push(normalizePathToGroupId(currentPath));
|
|
46
|
-
// Stop at home directory
|
|
47
|
-
if (currentPath === homeDir) {
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
const parentPath = path.dirname(currentPath);
|
|
51
|
-
// Stop if we can't go up anymore (reached root)
|
|
52
|
-
if (parentPath === currentPath) {
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
currentPath = parentPath;
|
|
56
|
-
}
|
|
57
|
-
return groups;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Detect folder metadata by checking for project markers and file types.
|
|
61
|
-
*/
|
|
62
|
-
function detectFolderMetadata(cwd = process.cwd()) {
|
|
63
|
-
const groupId = getCurrentGroupId(cwd);
|
|
64
|
-
const base = { path: cwd, groupId, type: 'unknown' };
|
|
65
|
-
// Check for Node.js/TypeScript project
|
|
66
|
-
const packageJsonPath = path.join(cwd, 'package.json');
|
|
67
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
68
|
-
try {
|
|
69
|
-
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
70
|
-
const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
|
|
71
|
-
// Detect framework
|
|
72
|
-
let framework;
|
|
73
|
-
if (deps.next)
|
|
74
|
-
framework = 'nextjs';
|
|
75
|
-
else if (deps.react)
|
|
76
|
-
framework = 'react';
|
|
77
|
-
else if (deps.express)
|
|
78
|
-
framework = 'express';
|
|
79
|
-
else if (deps.fastify)
|
|
80
|
-
framework = 'fastify';
|
|
81
|
-
else if (deps.hono)
|
|
82
|
-
framework = 'hono';
|
|
83
|
-
else if (deps.vue)
|
|
84
|
-
framework = 'vue';
|
|
85
|
-
else if (deps.angular)
|
|
86
|
-
framework = 'angular';
|
|
87
|
-
else if (deps.svelte)
|
|
88
|
-
framework = 'svelte';
|
|
89
|
-
// Detect if TypeScript
|
|
90
|
-
const isTypeScript = deps.typescript || fs.existsSync(path.join(cwd, 'tsconfig.json'));
|
|
91
|
-
return {
|
|
92
|
-
...base,
|
|
93
|
-
type: 'project',
|
|
94
|
-
projectType: isTypeScript ? 'typescript' : 'javascript',
|
|
95
|
-
framework,
|
|
96
|
-
description: pkg.description,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
catch (_err) {
|
|
100
|
-
// Invalid package.json, continue detection
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// Check for Python project
|
|
104
|
-
if (fs.existsSync(path.join(cwd, 'pyproject.toml')) || fs.existsSync(path.join(cwd, 'setup.py'))) {
|
|
105
|
-
let framework;
|
|
106
|
-
const reqPath = path.join(cwd, 'requirements.txt');
|
|
107
|
-
if (fs.existsSync(reqPath)) {
|
|
108
|
-
try {
|
|
109
|
-
const reqs = fs.readFileSync(reqPath, 'utf8').toLowerCase();
|
|
110
|
-
if (reqs.includes('fastapi'))
|
|
111
|
-
framework = 'fastapi';
|
|
112
|
-
else if (reqs.includes('django'))
|
|
113
|
-
framework = 'django';
|
|
114
|
-
else if (reqs.includes('flask'))
|
|
115
|
-
framework = 'flask';
|
|
116
|
-
}
|
|
117
|
-
catch (_err) {
|
|
118
|
-
// Ignore
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return { ...base, type: 'project', projectType: 'python', framework };
|
|
122
|
-
}
|
|
123
|
-
// Check for Rust project
|
|
124
|
-
if (fs.existsSync(path.join(cwd, 'Cargo.toml'))) {
|
|
125
|
-
return { ...base, type: 'project', projectType: 'rust' };
|
|
126
|
-
}
|
|
127
|
-
// Check for Go project
|
|
128
|
-
if (fs.existsSync(path.join(cwd, 'go.mod'))) {
|
|
129
|
-
return { ...base, type: 'project', projectType: 'go' };
|
|
130
|
-
}
|
|
131
|
-
// Check for Java/Kotlin project
|
|
132
|
-
if (fs.existsSync(path.join(cwd, 'pom.xml')) || fs.existsSync(path.join(cwd, 'build.gradle'))) {
|
|
133
|
-
return { ...base, type: 'project', projectType: 'java' };
|
|
134
|
-
}
|
|
135
|
-
// Check folder contents for type hints
|
|
136
|
-
try {
|
|
137
|
-
const files = fs.readdirSync(cwd);
|
|
138
|
-
const hasDocuments = files.some((f) => /\.(md|txt|doc|docx|rst)$/i.test(f));
|
|
139
|
-
const hasAssets = files.some((f) => /\.(png|jpg|jpeg|gif|svg|mp4|mp3|pdf|ai|psd)$/i.test(f));
|
|
140
|
-
if (hasAssets && !hasDocuments) {
|
|
141
|
-
return { ...base, type: 'assets' };
|
|
142
|
-
}
|
|
143
|
-
if (hasDocuments) {
|
|
144
|
-
return { ...base, type: 'documents' };
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
catch (_err) {
|
|
148
|
-
// Can't read directory
|
|
149
|
-
}
|
|
150
|
-
return base;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Format folder metadata for display.
|
|
154
|
-
* Returns a string like "TypeScript/React project" or "Python/FastAPI project"
|
|
155
|
-
*/
|
|
156
|
-
function formatFolderMetadata(metadata) {
|
|
157
|
-
if (metadata.type === 'unknown') {
|
|
158
|
-
return 'folder';
|
|
159
|
-
}
|
|
160
|
-
if (metadata.type === 'documents') {
|
|
161
|
-
return 'documents';
|
|
162
|
-
}
|
|
163
|
-
if (metadata.type === 'assets') {
|
|
164
|
-
return 'assets';
|
|
165
|
-
}
|
|
166
|
-
// Project type
|
|
167
|
-
const parts = [];
|
|
168
|
-
if (metadata.projectType) {
|
|
169
|
-
// Capitalize first letter
|
|
170
|
-
parts.push(metadata.projectType.charAt(0).toUpperCase() + metadata.projectType.slice(1));
|
|
171
|
-
}
|
|
172
|
-
if (metadata.framework) {
|
|
173
|
-
// Capitalize first letter
|
|
174
|
-
parts.push(metadata.framework.charAt(0).toUpperCase() + metadata.framework.slice(1));
|
|
175
|
-
}
|
|
176
|
-
if (parts.length === 0) {
|
|
177
|
-
return 'project';
|
|
178
|
-
}
|
|
179
|
-
return `${parts.join('/')} project`;
|
|
180
|
-
}
|
|
181
|
-
module.exports = {
|
|
182
|
-
MAX_GROUP_ID_LENGTH,
|
|
183
|
-
normalizePathToGroupId,
|
|
184
|
-
getCurrentGroupId,
|
|
185
|
-
getHierarchicalGroupIds,
|
|
186
|
-
detectFolderMetadata,
|
|
187
|
-
formatFolderMetadata,
|
|
188
|
-
};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const { MCP_ENDPOINT, ZEP_API_KEY } = require('../../config');
|
|
4
|
-
const { getCurrentGroupId, getHierarchicalGroupIds } = require('./group-id');
|
|
5
|
-
const CLIENT_INFO = { name: 'claude-hooks', version: '0.1.0' };
|
|
6
|
-
const PROTOCOL_VERSION = '2024-11-05';
|
|
7
|
-
/**
|
|
8
|
-
* Get headers for MCP requests.
|
|
9
|
-
* Adds Zep API key authentication when using Zep Cloud endpoint.
|
|
10
|
-
*/
|
|
11
|
-
function getHeaders() {
|
|
12
|
-
const headers = {
|
|
13
|
-
'Content-Type': 'application/json',
|
|
14
|
-
Accept: 'application/json, text/event-stream',
|
|
15
|
-
};
|
|
16
|
-
// Add Zep auth header when using Zep Cloud
|
|
17
|
-
if (ZEP_API_KEY && MCP_ENDPOINT.includes('getzep.com')) {
|
|
18
|
-
headers['Authorization'] = `Api-Key ${ZEP_API_KEY}`;
|
|
19
|
-
}
|
|
20
|
-
return headers;
|
|
21
|
-
}
|
|
22
|
-
let SESSION_ID = null;
|
|
23
|
-
class MCPError extends Error {
|
|
24
|
-
constructor(message, status) {
|
|
25
|
-
super(message);
|
|
26
|
-
this.status = status;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function extractEventStreamData(text) {
|
|
30
|
-
const lines = text.split('\n').map((l) => l.trim());
|
|
31
|
-
const dataLines = lines.filter((l) => l.startsWith('data:')).map((l) => l.replace(/^data:\s*/, ''));
|
|
32
|
-
if (!dataLines.length)
|
|
33
|
-
return null;
|
|
34
|
-
const candidate = dataLines.join('\n');
|
|
35
|
-
try {
|
|
36
|
-
return JSON.parse(candidate);
|
|
37
|
-
}
|
|
38
|
-
catch (_err) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async function initialize(timeoutMs = 8000) {
|
|
43
|
-
const body = {
|
|
44
|
-
jsonrpc: '2.0',
|
|
45
|
-
id: 'init',
|
|
46
|
-
method: 'initialize',
|
|
47
|
-
params: {
|
|
48
|
-
protocolVersion: PROTOCOL_VERSION,
|
|
49
|
-
capabilities: {},
|
|
50
|
-
clientInfo: CLIENT_INFO,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
const resp = await fetch(MCP_ENDPOINT, {
|
|
54
|
-
method: 'POST',
|
|
55
|
-
headers: getHeaders(),
|
|
56
|
-
body: JSON.stringify(body),
|
|
57
|
-
signal: AbortSignal.timeout(timeoutMs),
|
|
58
|
-
});
|
|
59
|
-
const session = resp.headers.get('mcp-session-id');
|
|
60
|
-
if (!session)
|
|
61
|
-
throw new MCPError('No mcp-session-id header from MCP', resp.status);
|
|
62
|
-
SESSION_ID = session;
|
|
63
|
-
return SESSION_ID;
|
|
64
|
-
}
|
|
65
|
-
async function rpcCall(method, params = {}, sessionId = null, timeoutMs = 8000) {
|
|
66
|
-
const sid = sessionId || SESSION_ID || (await initialize(timeoutMs));
|
|
67
|
-
const headers = { ...getHeaders(), 'MCP-SESSION-ID': sid };
|
|
68
|
-
const payload = method === 'initialize' || method === 'ping' || method.startsWith('tools/')
|
|
69
|
-
? { jsonrpc: '2.0', id: '1', method, params }
|
|
70
|
-
: { jsonrpc: '2.0', id: '1', method: 'tools/call', params: { name: method, arguments: params } };
|
|
71
|
-
const resp = await fetch(MCP_ENDPOINT, {
|
|
72
|
-
method: 'POST',
|
|
73
|
-
headers,
|
|
74
|
-
body: JSON.stringify(payload),
|
|
75
|
-
signal: AbortSignal.timeout(timeoutMs),
|
|
76
|
-
});
|
|
77
|
-
const newSid = resp.headers.get('mcp-session-id');
|
|
78
|
-
if (newSid)
|
|
79
|
-
SESSION_ID = newSid;
|
|
80
|
-
const text = await resp.text();
|
|
81
|
-
let data;
|
|
82
|
-
try {
|
|
83
|
-
data = JSON.parse(text);
|
|
84
|
-
}
|
|
85
|
-
catch (_err) {
|
|
86
|
-
const eventParsed = extractEventStreamData(text);
|
|
87
|
-
if (eventParsed) {
|
|
88
|
-
data = eventParsed;
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
const snippet = text ? text.slice(0, 200) : '<empty>';
|
|
92
|
-
throw new MCPError(`Invalid JSON from MCP (status ${resp.status || 'unknown'}): ${snippet}`);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (resp.status >= 400) {
|
|
96
|
-
const msg = data?.error?.message || `HTTP ${resp.status}`;
|
|
97
|
-
throw new MCPError(msg, resp.status);
|
|
98
|
-
}
|
|
99
|
-
if (data.error)
|
|
100
|
-
throw new MCPError(data.error.message || 'RPC error');
|
|
101
|
-
const result = data.result?.structuredContent?.result || data.result || data;
|
|
102
|
-
return [result, SESSION_ID];
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Add a single group ID to params (for write operations).
|
|
106
|
-
* Uses the current folder's group ID if not specified.
|
|
107
|
-
*/
|
|
108
|
-
function withGroup(params, groupId = null) {
|
|
109
|
-
if (params.group_ids)
|
|
110
|
-
return params;
|
|
111
|
-
return { ...params, group_ids: [groupId || getCurrentGroupId()] };
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Add hierarchical group IDs to params (for read operations).
|
|
115
|
-
* Queries current folder + all parent folders up to $HOME.
|
|
116
|
-
*/
|
|
117
|
-
function withHierarchicalGroups(params) {
|
|
118
|
-
if (params.group_ids)
|
|
119
|
-
return params;
|
|
120
|
-
return { ...params, group_ids: getHierarchicalGroupIds() };
|
|
121
|
-
}
|
|
122
|
-
module.exports = {
|
|
123
|
-
rpcCall,
|
|
124
|
-
withGroup,
|
|
125
|
-
withHierarchicalGroups,
|
|
126
|
-
initialize,
|
|
127
|
-
MCP_ENDPOINT,
|
|
128
|
-
getCurrentGroupId,
|
|
129
|
-
getHierarchicalGroupIds,
|
|
130
|
-
MCPError,
|
|
131
|
-
};
|