codehere 0.4.0 → 0.5.0-alpha

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.
Files changed (324) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +113 -30
  3. package/dist/application/agents/execution-agent.js +2 -2
  4. package/dist/application/agents/execution-agent.js.map +1 -1
  5. package/dist/application/agents/multi-agent-orchestrator.d.ts +1 -0
  6. package/dist/application/agents/multi-agent-orchestrator.d.ts.map +1 -1
  7. package/dist/application/agents/multi-agent-orchestrator.js +10 -3
  8. package/dist/application/agents/multi-agent-orchestrator.js.map +1 -1
  9. package/dist/application/agents/planning-agent.d.ts.map +1 -1
  10. package/dist/application/agents/planning-agent.js +22 -10
  11. package/dist/application/agents/planning-agent.js.map +1 -1
  12. package/dist/application/agents/validation-agent.js +2 -2
  13. package/dist/application/agents/validation-agent.js.map +1 -1
  14. package/dist/application/reasoning/multi-model-planning-strategy.d.ts +21 -0
  15. package/dist/application/reasoning/multi-model-planning-strategy.d.ts.map +1 -0
  16. package/dist/application/reasoning/multi-model-planning-strategy.js +158 -0
  17. package/dist/application/reasoning/multi-model-planning-strategy.js.map +1 -0
  18. package/dist/application/reasoning/reasoning-config.d.ts +15 -0
  19. package/dist/application/reasoning/reasoning-config.d.ts.map +1 -0
  20. package/dist/application/reasoning/reasoning-config.js +50 -0
  21. package/dist/application/reasoning/reasoning-config.js.map +1 -0
  22. package/dist/application/reasoning/reasoning-orchestrator.d.ts +18 -0
  23. package/dist/application/reasoning/reasoning-orchestrator.d.ts.map +1 -0
  24. package/dist/application/reasoning/reasoning-orchestrator.js +170 -0
  25. package/dist/application/reasoning/reasoning-orchestrator.js.map +1 -0
  26. package/dist/application/reasoning/reasoning-strategy.interface.d.ts +24 -0
  27. package/dist/application/reasoning/reasoning-strategy.interface.d.ts.map +1 -0
  28. package/dist/application/reasoning/reasoning-strategy.interface.js +6 -0
  29. package/dist/application/reasoning/reasoning-strategy.interface.js.map +1 -0
  30. package/dist/application/reasoning/role-provider-resolver.d.ts +36 -0
  31. package/dist/application/reasoning/role-provider-resolver.d.ts.map +1 -0
  32. package/dist/application/reasoning/role-provider-resolver.js +74 -0
  33. package/dist/application/reasoning/role-provider-resolver.js.map +1 -0
  34. package/dist/application/reasoning/simple-planning-strategy.d.ts +22 -0
  35. package/dist/application/reasoning/simple-planning-strategy.d.ts.map +1 -0
  36. package/dist/application/reasoning/simple-planning-strategy.js +217 -0
  37. package/dist/application/reasoning/simple-planning-strategy.js.map +1 -0
  38. package/dist/application/reasoning/types.d.ts +65 -0
  39. package/dist/application/reasoning/types.d.ts.map +1 -0
  40. package/dist/application/reasoning/types.js +6 -0
  41. package/dist/application/reasoning/types.js.map +1 -0
  42. package/dist/application/reasoning/validator-strategy.d.ts +56 -0
  43. package/dist/application/reasoning/validator-strategy.d.ts.map +1 -0
  44. package/dist/application/reasoning/validator-strategy.js +103 -0
  45. package/dist/application/reasoning/validator-strategy.js.map +1 -0
  46. package/dist/application/services/dependency-container.d.ts +30 -6
  47. package/dist/application/services/dependency-container.d.ts.map +1 -1
  48. package/dist/application/services/dependency-container.js +96 -44
  49. package/dist/application/services/dependency-container.js.map +1 -1
  50. package/dist/application/services/intelligent-router.d.ts +6 -0
  51. package/dist/application/services/intelligent-router.d.ts.map +1 -1
  52. package/dist/application/services/intelligent-router.js +98 -9
  53. package/dist/application/services/intelligent-router.js.map +1 -1
  54. package/dist/application/use-cases/ask-question-use-case.d.ts +1 -0
  55. package/dist/application/use-cases/ask-question-use-case.d.ts.map +1 -1
  56. package/dist/application/use-cases/ask-question-use-case.js +4 -3
  57. package/dist/application/use-cases/ask-question-use-case.js.map +1 -1
  58. package/dist/application/use-cases/planning-use-case.d.ts +14 -1
  59. package/dist/application/use-cases/planning-use-case.d.ts.map +1 -1
  60. package/dist/application/use-cases/planning-use-case.js +109 -2
  61. package/dist/application/use-cases/planning-use-case.js.map +1 -1
  62. package/dist/domain/entities/memory.d.ts.map +1 -1
  63. package/dist/domain/entities/task.d.ts +1 -1
  64. package/dist/domain/entities/task.d.ts.map +1 -1
  65. package/dist/domain/entities/task.js +2 -2
  66. package/dist/domain/entities/task.js.map +1 -1
  67. package/dist/domain/errors/embeddings-not-found-error.d.ts +9 -0
  68. package/dist/domain/errors/embeddings-not-found-error.d.ts.map +1 -0
  69. package/dist/domain/errors/embeddings-not-found-error.js +13 -0
  70. package/dist/domain/errors/embeddings-not-found-error.js.map +1 -0
  71. package/dist/domain/interfaces/embedding-repository.interface.d.ts +5 -0
  72. package/dist/domain/interfaces/embedding-repository.interface.d.ts.map +1 -1
  73. package/dist/domain/services/environment-mode-manager.d.ts +4 -10
  74. package/dist/domain/services/environment-mode-manager.d.ts.map +1 -1
  75. package/dist/domain/services/environment-mode-manager.js +7 -22
  76. package/dist/domain/services/environment-mode-manager.js.map +1 -1
  77. package/dist/domain/services/query-intent-classifier.d.ts.map +1 -1
  78. package/dist/domain/services/query-intent-classifier.js +20 -1
  79. package/dist/domain/services/query-intent-classifier.js.map +1 -1
  80. package/dist/domain/services/risk-tier-detector.d.ts +8 -9
  81. package/dist/domain/services/risk-tier-detector.d.ts.map +1 -1
  82. package/dist/domain/services/risk-tier-detector.js +53 -40
  83. package/dist/domain/services/risk-tier-detector.js.map +1 -1
  84. package/dist/embed.d.ts.map +1 -1
  85. package/dist/embed.js +18 -8
  86. package/dist/embed.js.map +1 -1
  87. package/dist/index.js +405 -52
  88. package/dist/index.js.map +1 -1
  89. package/dist/infrastructure/ai/cohere-ai-service.js +4 -4
  90. package/dist/infrastructure/ai/cohere-ai-service.js.map +1 -1
  91. package/dist/infrastructure/ai/provider-ai-service.d.ts.map +1 -1
  92. package/dist/infrastructure/ai/provider-ai-service.js +7 -7
  93. package/dist/infrastructure/ai/provider-ai-service.js.map +1 -1
  94. package/dist/infrastructure/cache/query-result-cache.d.ts +14 -55
  95. package/dist/infrastructure/cache/query-result-cache.d.ts.map +1 -1
  96. package/dist/infrastructure/cache/query-result-cache.js +40 -112
  97. package/dist/infrastructure/cache/query-result-cache.js.map +1 -1
  98. package/dist/infrastructure/cache/response-cache.d.ts +10 -78
  99. package/dist/infrastructure/cache/response-cache.d.ts.map +1 -1
  100. package/dist/infrastructure/cache/response-cache.js +22 -198
  101. package/dist/infrastructure/cache/response-cache.js.map +1 -1
  102. package/dist/infrastructure/cache/security-scan-cache.d.ts +8 -49
  103. package/dist/infrastructure/cache/security-scan-cache.d.ts.map +1 -1
  104. package/dist/infrastructure/cache/security-scan-cache.js +25 -102
  105. package/dist/infrastructure/cache/security-scan-cache.js.map +1 -1
  106. package/dist/infrastructure/completion/bash-completion.d.ts +2 -3
  107. package/dist/infrastructure/completion/bash-completion.d.ts.map +1 -1
  108. package/dist/infrastructure/completion/bash-completion.js +11 -87
  109. package/dist/infrastructure/completion/bash-completion.js.map +1 -1
  110. package/dist/infrastructure/completion/fish-completion.d.ts +2 -3
  111. package/dist/infrastructure/completion/fish-completion.d.ts.map +1 -1
  112. package/dist/infrastructure/completion/fish-completion.js +15 -58
  113. package/dist/infrastructure/completion/fish-completion.js.map +1 -1
  114. package/dist/infrastructure/completion/zsh-completion.d.ts +2 -3
  115. package/dist/infrastructure/completion/zsh-completion.d.ts.map +1 -1
  116. package/dist/infrastructure/completion/zsh-completion.js +18 -73
  117. package/dist/infrastructure/completion/zsh-completion.js.map +1 -1
  118. package/dist/infrastructure/config/config-manager.d.ts +10 -0
  119. package/dist/infrastructure/config/config-manager.d.ts.map +1 -1
  120. package/dist/infrastructure/config/config-manager.js +13 -2
  121. package/dist/infrastructure/config/config-manager.js.map +1 -1
  122. package/dist/infrastructure/context/conversation-context.d.ts +27 -31
  123. package/dist/infrastructure/context/conversation-context.d.ts.map +1 -1
  124. package/dist/infrastructure/context/conversation-context.js +95 -136
  125. package/dist/infrastructure/context/conversation-context.js.map +1 -1
  126. package/dist/infrastructure/context/session-manager.d.ts +27 -11
  127. package/dist/infrastructure/context/session-manager.d.ts.map +1 -1
  128. package/dist/infrastructure/context/session-manager.js +69 -73
  129. package/dist/infrastructure/context/session-manager.js.map +1 -1
  130. package/dist/infrastructure/protocols/a2a-metadata.js +1 -1
  131. package/dist/infrastructure/protocols/mcp-oauth.js +1 -1
  132. package/dist/infrastructure/providers/cohere-provider.d.ts.map +1 -1
  133. package/dist/infrastructure/providers/cohere-provider.js +102 -17
  134. package/dist/infrastructure/providers/cohere-provider.js.map +1 -1
  135. package/dist/infrastructure/providers/openrouter-provider.d.ts +42 -0
  136. package/dist/infrastructure/providers/openrouter-provider.d.ts.map +1 -0
  137. package/dist/infrastructure/providers/openrouter-provider.js +401 -0
  138. package/dist/infrastructure/providers/openrouter-provider.js.map +1 -0
  139. package/dist/infrastructure/providers/operation-provider-resolver.d.ts.map +1 -1
  140. package/dist/infrastructure/providers/operation-provider-resolver.js +33 -7
  141. package/dist/infrastructure/providers/operation-provider-resolver.js.map +1 -1
  142. package/dist/infrastructure/security/input-validator.d.ts.map +1 -1
  143. package/dist/infrastructure/security/input-validator.js +19 -6
  144. package/dist/infrastructure/security/input-validator.js.map +1 -1
  145. package/dist/infrastructure/serialization/toon-serializer.d.ts +45 -0
  146. package/dist/infrastructure/serialization/toon-serializer.d.ts.map +1 -0
  147. package/dist/infrastructure/serialization/toon-serializer.js +119 -0
  148. package/dist/infrastructure/serialization/toon-serializer.js.map +1 -0
  149. package/dist/infrastructure/storage/embeddings-path.d.ts +18 -0
  150. package/dist/infrastructure/storage/embeddings-path.d.ts.map +1 -0
  151. package/dist/infrastructure/storage/embeddings-path.js +37 -0
  152. package/dist/infrastructure/storage/embeddings-path.js.map +1 -0
  153. package/dist/infrastructure/storage/plan-repository.d.ts +2 -0
  154. package/dist/infrastructure/storage/plan-repository.d.ts.map +1 -1
  155. package/dist/infrastructure/storage/plan-repository.js +36 -73
  156. package/dist/infrastructure/storage/plan-repository.js.map +1 -1
  157. package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts +10 -1
  158. package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts.map +1 -1
  159. package/dist/infrastructure/storage/sqlite-embedding-repository.js +37 -3
  160. package/dist/infrastructure/storage/sqlite-embedding-repository.js.map +1 -1
  161. package/dist/infrastructure/storage/task-helpers.d.ts +12 -1
  162. package/dist/infrastructure/storage/task-helpers.d.ts.map +1 -1
  163. package/dist/infrastructure/storage/task-helpers.js +48 -8
  164. package/dist/infrastructure/storage/task-helpers.js.map +1 -1
  165. package/dist/infrastructure/storage/task-repository.d.ts +2 -1
  166. package/dist/infrastructure/storage/task-repository.d.ts.map +1 -1
  167. package/dist/infrastructure/storage/task-repository.js +14 -3
  168. package/dist/infrastructure/storage/task-repository.js.map +1 -1
  169. package/dist/infrastructure/telemetry/telemetry-service.d.ts +74 -0
  170. package/dist/infrastructure/telemetry/telemetry-service.d.ts.map +1 -0
  171. package/dist/infrastructure/telemetry/telemetry-service.js +167 -0
  172. package/dist/infrastructure/telemetry/telemetry-service.js.map +1 -0
  173. package/dist/infrastructure/ux/capability-boundaries.d.ts +9 -37
  174. package/dist/infrastructure/ux/capability-boundaries.d.ts.map +1 -1
  175. package/dist/infrastructure/ux/capability-boundaries.js +23 -148
  176. package/dist/infrastructure/ux/capability-boundaries.js.map +1 -1
  177. package/dist/infrastructure/ux/comprehensive-formatter.d.ts +12 -54
  178. package/dist/infrastructure/ux/comprehensive-formatter.d.ts.map +1 -1
  179. package/dist/infrastructure/ux/comprehensive-formatter.js +87 -182
  180. package/dist/infrastructure/ux/comprehensive-formatter.js.map +1 -1
  181. package/dist/infrastructure/ux/contextual-feature-discovery.d.ts +5 -18
  182. package/dist/infrastructure/ux/contextual-feature-discovery.d.ts.map +1 -1
  183. package/dist/infrastructure/ux/contextual-feature-discovery.js +5 -139
  184. package/dist/infrastructure/ux/contextual-feature-discovery.js.map +1 -1
  185. package/dist/infrastructure/ux/feature-discovery.d.ts +3 -33
  186. package/dist/infrastructure/ux/feature-discovery.d.ts.map +1 -1
  187. package/dist/infrastructure/ux/feature-discovery.js +5 -181
  188. package/dist/infrastructure/ux/feature-discovery.js.map +1 -1
  189. package/dist/infrastructure/ux/feedback-prompt.d.ts +15 -31
  190. package/dist/infrastructure/ux/feedback-prompt.d.ts.map +1 -1
  191. package/dist/infrastructure/ux/feedback-prompt.js +30 -166
  192. package/dist/infrastructure/ux/feedback-prompt.js.map +1 -1
  193. package/dist/infrastructure/ux/progress-indicator.d.ts +4 -6
  194. package/dist/infrastructure/ux/progress-indicator.d.ts.map +1 -1
  195. package/dist/infrastructure/ux/progress-indicator.js +35 -50
  196. package/dist/infrastructure/ux/progress-indicator.js.map +1 -1
  197. package/dist/infrastructure/ux/review-checkpoint.d.ts +3 -1
  198. package/dist/infrastructure/ux/review-checkpoint.d.ts.map +1 -1
  199. package/dist/infrastructure/ux/review-checkpoint.js +33 -80
  200. package/dist/infrastructure/ux/review-checkpoint.js.map +1 -1
  201. package/dist/infrastructure/ux/staged-feature-intro.d.ts +14 -39
  202. package/dist/infrastructure/ux/staged-feature-intro.d.ts.map +1 -1
  203. package/dist/infrastructure/ux/staged-feature-intro.js +12 -132
  204. package/dist/infrastructure/ux/staged-feature-intro.js.map +1 -1
  205. package/dist/infrastructure/ux/syntax-highlighter.d.ts +1 -2
  206. package/dist/infrastructure/ux/syntax-highlighter.d.ts.map +1 -1
  207. package/dist/infrastructure/ux/syntax-highlighter.js +67 -148
  208. package/dist/infrastructure/ux/syntax-highlighter.js.map +1 -1
  209. package/dist/infrastructure/validation/agent-feedback.d.ts +25 -89
  210. package/dist/infrastructure/validation/agent-feedback.d.ts.map +1 -1
  211. package/dist/infrastructure/validation/agent-feedback.js +32 -204
  212. package/dist/infrastructure/validation/agent-feedback.js.map +1 -1
  213. package/dist/infrastructure/validation/agent-validation-helper.d.ts +53 -53
  214. package/dist/infrastructure/validation/agent-validation-helper.d.ts.map +1 -1
  215. package/dist/infrastructure/validation/agent-validation-helper.js +110 -61
  216. package/dist/infrastructure/validation/agent-validation-helper.js.map +1 -1
  217. package/dist/infrastructure/validation/review-handler.d.ts +13 -41
  218. package/dist/infrastructure/validation/review-handler.d.ts.map +1 -1
  219. package/dist/infrastructure/validation/review-handler.js +23 -189
  220. package/dist/infrastructure/validation/review-handler.js.map +1 -1
  221. package/dist/infrastructure/validation/summary-aggregator.d.ts +25 -22
  222. package/dist/infrastructure/validation/summary-aggregator.d.ts.map +1 -1
  223. package/dist/infrastructure/validation/summary-aggregator.js +47 -133
  224. package/dist/infrastructure/validation/summary-aggregator.js.map +1 -1
  225. package/dist/infrastructure/validation/summary-extractor.d.ts +13 -48
  226. package/dist/infrastructure/validation/summary-extractor.d.ts.map +1 -1
  227. package/dist/infrastructure/validation/summary-extractor.js +32 -89
  228. package/dist/infrastructure/validation/summary-extractor.js.map +1 -1
  229. package/dist/infrastructure/validation/trace-summary.d.ts +30 -57
  230. package/dist/infrastructure/validation/trace-summary.d.ts.map +1 -1
  231. package/dist/infrastructure/validation/trace-summary.js +37 -356
  232. package/dist/infrastructure/validation/trace-summary.js.map +1 -1
  233. package/dist/monitoring.d.ts +1 -1
  234. package/dist/monitoring.d.ts.map +1 -1
  235. package/dist/monitoring.js +12 -9
  236. package/dist/monitoring.js.map +1 -1
  237. package/dist/parallel-processor.d.ts.map +1 -1
  238. package/dist/parallel-processor.js +124 -45
  239. package/dist/parallel-processor.js.map +1 -1
  240. package/dist/presentation/cli/commands/ask-command.d.ts +2 -0
  241. package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -1
  242. package/dist/presentation/cli/commands/ask-command.js +316 -129
  243. package/dist/presentation/cli/commands/ask-command.js.map +1 -1
  244. package/dist/presentation/cli/commands/config-command.d.ts.map +1 -1
  245. package/dist/presentation/cli/commands/config-command.js +22 -8
  246. package/dist/presentation/cli/commands/config-command.js.map +1 -1
  247. package/dist/presentation/cli/commands/decision-command.js +23 -6
  248. package/dist/presentation/cli/commands/decision-command.js.map +1 -1
  249. package/dist/presentation/cli/commands/docs-command.d.ts +3 -1
  250. package/dist/presentation/cli/commands/docs-command.d.ts.map +1 -1
  251. package/dist/presentation/cli/commands/docs-command.js +13 -184
  252. package/dist/presentation/cli/commands/docs-command.js.map +1 -1
  253. package/dist/presentation/cli/commands/fix-command.d.ts +2 -0
  254. package/dist/presentation/cli/commands/fix-command.d.ts.map +1 -1
  255. package/dist/presentation/cli/commands/fix-command.js +61 -276
  256. package/dist/presentation/cli/commands/fix-command.js.map +1 -1
  257. package/dist/presentation/cli/commands/help-command.d.ts.map +1 -1
  258. package/dist/presentation/cli/commands/help-command.js +21 -1
  259. package/dist/presentation/cli/commands/help-command.js.map +1 -1
  260. package/dist/presentation/cli/commands/memory-command.d.ts +17 -0
  261. package/dist/presentation/cli/commands/memory-command.d.ts.map +1 -0
  262. package/dist/presentation/cli/commands/memory-command.js +252 -0
  263. package/dist/presentation/cli/commands/memory-command.js.map +1 -0
  264. package/dist/presentation/cli/commands/models-command.d.ts +13 -0
  265. package/dist/presentation/cli/commands/models-command.d.ts.map +1 -0
  266. package/dist/presentation/cli/commands/models-command.js +194 -0
  267. package/dist/presentation/cli/commands/models-command.js.map +1 -0
  268. package/dist/presentation/cli/commands/orchestrate-command.d.ts +1 -0
  269. package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -1
  270. package/dist/presentation/cli/commands/orchestrate-command.js +129 -14
  271. package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -1
  272. package/dist/presentation/cli/commands/plan-command.d.ts +1 -0
  273. package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -1
  274. package/dist/presentation/cli/commands/plan-command.js +134 -25
  275. package/dist/presentation/cli/commands/plan-command.js.map +1 -1
  276. package/dist/presentation/cli/commands/product-command.d.ts +6 -4
  277. package/dist/presentation/cli/commands/product-command.d.ts.map +1 -1
  278. package/dist/presentation/cli/commands/product-command.js +12 -178
  279. package/dist/presentation/cli/commands/product-command.js.map +1 -1
  280. package/dist/presentation/cli/commands/react-command.d.ts.map +1 -1
  281. package/dist/presentation/cli/commands/react-command.js +5 -1
  282. package/dist/presentation/cli/commands/react-command.js.map +1 -1
  283. package/dist/presentation/cli/commands/review-command.d.ts +7 -7
  284. package/dist/presentation/cli/commands/review-command.d.ts.map +1 -1
  285. package/dist/presentation/cli/commands/review-command.js +167 -16
  286. package/dist/presentation/cli/commands/review-command.js.map +1 -1
  287. package/dist/presentation/cli/commands/run-command.d.ts +6 -8
  288. package/dist/presentation/cli/commands/run-command.d.ts.map +1 -1
  289. package/dist/presentation/cli/commands/run-command.js +182 -23
  290. package/dist/presentation/cli/commands/run-command.js.map +1 -1
  291. package/dist/presentation/cli/commands/setup-command.d.ts.map +1 -1
  292. package/dist/presentation/cli/commands/setup-command.js +15 -0
  293. package/dist/presentation/cli/commands/setup-command.js.map +1 -1
  294. package/dist/presentation/cli/commands/smart-command.d.ts.map +1 -1
  295. package/dist/presentation/cli/commands/smart-command.js +74 -6
  296. package/dist/presentation/cli/commands/smart-command.js.map +1 -1
  297. package/dist/presentation/cli/commands/status-command.d.ts +3 -0
  298. package/dist/presentation/cli/commands/status-command.d.ts.map +1 -1
  299. package/dist/presentation/cli/commands/status-command.js +151 -156
  300. package/dist/presentation/cli/commands/status-command.js.map +1 -1
  301. package/dist/presentation/cli/commands/suggest-command.d.ts +3 -5
  302. package/dist/presentation/cli/commands/suggest-command.d.ts.map +1 -1
  303. package/dist/presentation/cli/commands/suggest-command.js +132 -19
  304. package/dist/presentation/cli/commands/suggest-command.js.map +1 -1
  305. package/dist/presentation/cli/error-display.d.ts.map +1 -1
  306. package/dist/presentation/cli/error-display.js +75 -17
  307. package/dist/presentation/cli/error-display.js.map +1 -1
  308. package/dist/search.d.ts.map +1 -1
  309. package/dist/search.js +6 -1
  310. package/dist/search.js.map +1 -1
  311. package/dist/session.d.ts +1 -0
  312. package/dist/session.d.ts.map +1 -1
  313. package/dist/session.js +55 -7
  314. package/dist/session.js.map +1 -1
  315. package/dist/tools/bash.d.ts.map +1 -1
  316. package/dist/tools/bash.js +3 -0
  317. package/dist/tools/bash.js.map +1 -1
  318. package/dist/tools/git-tool.js +7 -7
  319. package/dist/tools/git-tool.js.map +1 -1
  320. package/dist/ui.d.ts +11 -0
  321. package/dist/ui.d.ts.map +1 -1
  322. package/dist/ui.js +54 -1
  323. package/dist/ui.js.map +1 -1
  324. package/package.json +14 -4
@@ -1,58 +1,54 @@
1
1
  /**
2
2
  * Conversation Context Manager
3
- * Maintains conversation history and enables reference resolution
3
+ * Manages conversation history and context for session-aware interactions
4
+ *
5
+ * Phase 1: v0.5.0-alpha.0
4
6
  */
5
7
  export interface ConversationTurn {
6
8
  query: string;
7
9
  response: string;
8
- timestamp: number;
9
- entities?: string[];
10
- intent?: string;
10
+ timestamp: string | number;
11
+ entities?: any[];
12
+ intent?: any;
11
13
  }
12
- export interface ConversationContext {
14
+ interface ConversationSession {
13
15
  sessionId: string;
14
16
  turns: ConversationTurn[];
15
- currentFocus?: {
16
- entity?: string;
17
- filepath?: string;
18
- topic?: string;
19
- };
20
17
  createdAt: number;
21
18
  lastUpdated: number;
22
19
  }
23
- export declare class ConversationContextManager {
24
- private conversations;
25
- private maxHistoryLength;
26
- private maxTotalHistoryLength;
27
- /**
28
- * Get or create conversation context for a session
29
- */
30
- getContext(sessionId: string): ConversationContext;
31
- /**
32
- * Add a turn to conversation history
33
- * EDGE CASE: Handles very long histories, concurrent sessions, and memory limits
34
- */
35
- addTurn(sessionId: string, query: string, response: string, entities?: string[], intent?: string): void;
20
+ /**
21
+ * In-memory conversation context manager
22
+ * Stores conversation history per session for reference resolution
23
+ */
24
+ declare class ConversationContextManager {
25
+ private sessions;
26
+ private readonly maxHistoryPerSession;
36
27
  /**
37
- * Get conversation history for context
28
+ * Get conversation history for a session
38
29
  */
39
- getHistory(sessionId: string, maxTurns?: number): ConversationTurn[];
30
+ getHistory(sessionId: string, limit?: number): ConversationTurn[];
40
31
  /**
41
32
  * Resolve references in query (e.g., "it", "that", "the previous")
42
33
  */
43
34
  resolveReferences(sessionId: string, query: string): string;
44
35
  /**
45
- * Extract entities from query (file names, functions, classes)
36
+ * Extract entities from text (simple heuristic-based extraction)
37
+ */
38
+ extractEntities(text: string, options?: any): any[];
39
+ /**
40
+ * Add a conversation turn
46
41
  */
47
- extractEntities(query: string): string[];
42
+ addTurn(sessionId: string, query: string, response: string, entities?: any[], intent?: any): void;
48
43
  /**
49
- * Get conversation context summary for AI prompts
44
+ * Get full context for a session
50
45
  */
51
- getContextSummary(sessionId: string, maxTurns?: number): string;
46
+ getContext(sessionId: string): ConversationSession | null;
52
47
  /**
53
- * Clear conversation context (for new session)
48
+ * Clear conversation history for a session
54
49
  */
55
- clearContext(sessionId: string): void;
50
+ clear(sessionId?: string): void;
56
51
  }
57
52
  export declare const conversationContextManager: ConversationContextManager;
53
+ export {};
58
54
  //# sourceMappingURL=conversation-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-context.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/conversation-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,0BAA0B;IACrC,OAAO,CAAC,aAAa,CAA+C;IACpE,OAAO,CAAC,gBAAgB,CAAM;IAC9B,OAAO,CAAC,qBAAqB,CAAM;IAEnC;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GA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;IAE3C;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,gBAAgB,EAAE;IAgBrE;;OAEG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAkC3D;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE;IAqBnD;;OAEG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,GAAG,EAAO,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,IAAI;IA8BrG;;OAEG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;IAIzD;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;CAOhC;AAED,eAAO,MAAM,0BAA0B,4BAAmC,CAAC"}
@@ -1,170 +1,129 @@
1
1
  /**
2
2
  * Conversation Context Manager
3
- * Maintains conversation history and enables reference resolution
3
+ * Manages conversation history and context for session-aware interactions
4
+ *
5
+ * Phase 1: v0.5.0-alpha.0
4
6
  */
5
- export class ConversationContextManager {
6
- conversations = new Map();
7
- maxHistoryLength = 10; // Keep last 10 turns
8
- maxTotalHistoryLength = 50; // Hard limit to prevent memory issues
9
- /**
10
- * Get or create conversation context for a session
11
- */
12
- getContext(sessionId) {
13
- if (!this.conversations.has(sessionId)) {
14
- this.conversations.set(sessionId, {
15
- sessionId,
16
- turns: [],
17
- createdAt: Date.now(),
18
- lastUpdated: Date.now(),
19
- });
20
- }
21
- return this.conversations.get(sessionId);
22
- }
7
+ /**
8
+ * In-memory conversation context manager
9
+ * Stores conversation history per session for reference resolution
10
+ */
11
+ class ConversationContextManager {
12
+ sessions = new Map();
13
+ maxHistoryPerSession = 50;
23
14
  /**
24
- * Add a turn to conversation history
25
- * EDGE CASE: Handles very long histories, concurrent sessions, and memory limits
15
+ * Get conversation history for a session
26
16
  */
27
- addTurn(sessionId, query, response, entities, intent) {
28
- const context = this.getContext(sessionId);
29
- // EDGE CASE: Prevent memory issues with very long histories
30
- if (context.turns.length >= this.maxTotalHistoryLength) {
31
- // Keep only the most recent turns (remove oldest 25%)
32
- const removeCount = Math.floor(this.maxTotalHistoryLength * 0.25);
33
- context.turns = context.turns.slice(removeCount);
17
+ getHistory(sessionId, limit = 10) {
18
+ const session = this.sessions.get(sessionId);
19
+ if (!session) {
20
+ return [];
34
21
  }
35
- // EDGE CASE: Truncate very long responses to prevent memory bloat
36
- const maxResponseLength = 5000; // 5KB per response
37
- const truncatedResponse = response.length > maxResponseLength
38
- ? response.substring(0, maxResponseLength) + '... [truncated]'
39
- : response;
40
- const turn = {
41
- query: query.substring(0, 500), // Limit query length too
42
- response: truncatedResponse,
43
- timestamp: Date.now(),
44
- entities: entities?.slice(0, 10), // Limit entities to prevent bloat
45
- intent,
46
- };
47
- context.turns.push(turn);
48
- // Keep only last N turns for active context
49
- if (context.turns.length > this.maxHistoryLength) {
50
- context.turns.shift();
51
- }
52
- // Update current focus based on entities
53
- if (entities && entities.length > 0) {
54
- context.currentFocus = {
55
- entity: entities[0],
56
- filepath: entities.find(e => e.includes('/') || e.endsWith('.ts') || e.endsWith('.js')) || entities[0],
57
- topic: query.split(' ').slice(0, 5).join(' '), // First 5 words as topic
58
- };
59
- }
60
- context.lastUpdated = Date.now();
61
- }
62
- /**
63
- * Get conversation history for context
64
- */
65
- getHistory(sessionId, maxTurns = 5) {
66
- const context = this.getContext(sessionId);
67
- return context.turns.slice(-maxTurns);
22
+ // Return most recent turns, up to limit
23
+ const turns = session.turns.slice(-limit);
24
+ return turns.map(turn => ({
25
+ query: turn.query,
26
+ response: turn.response,
27
+ timestamp: turn.timestamp,
28
+ intent: turn.intent, // Include intent in history
29
+ }));
68
30
  }
69
31
  /**
70
32
  * Resolve references in query (e.g., "it", "that", "the previous")
71
33
  */
72
34
  resolveReferences(sessionId, query) {
73
- const context = this.getContext(sessionId);
74
- const lastTurn = context.turns[context.turns.length - 1];
75
- if (!lastTurn) {
76
- return query; // No history to reference
77
- }
78
- let resolvedQuery = query;
79
- const queryLower = query.toLowerCase();
80
- // Resolve "it" references
81
- if (queryLower.includes(' it ') || queryLower.startsWith('it ') || queryLower.endsWith(' it')) {
82
- if (context.currentFocus?.entity) {
83
- resolvedQuery = resolvedQuery.replace(/\bit\b/gi, context.currentFocus.entity);
84
- }
85
- else if (lastTurn.entities && lastTurn.entities.length > 0) {
86
- resolvedQuery = resolvedQuery.replace(/\bit\b/gi, lastTurn.entities[0]);
87
- }
88
- else {
89
- // Use last query's main subject
90
- const lastQueryWords = lastTurn.query.split(' ');
91
- const mainSubject = lastQueryWords.find(word => word.length > 3 && !['what', 'how', 'where', 'when', 'why', 'does', 'the', 'a', 'an'].includes(word.toLowerCase())) || lastQueryWords[lastQueryWords.length - 1];
92
- resolvedQuery = resolvedQuery.replace(/\bit\b/gi, mainSubject);
93
- }
35
+ const history = this.getHistory(sessionId, 3);
36
+ if (history.length === 0) {
37
+ return query;
94
38
  }
95
- // Resolve "that" references
96
- if (queryLower.includes(' that ') || queryLower.startsWith('that ') || queryLower.endsWith(' that')) {
97
- if (context.currentFocus?.entity) {
98
- resolvedQuery = resolvedQuery.replace(/\bthat\b/gi, context.currentFocus.entity);
99
- }
100
- else if (lastTurn.entities && lastTurn.entities.length > 0) {
101
- resolvedQuery = resolvedQuery.replace(/\bthat\b/gi, lastTurn.entities[0]);
39
+ // Simple reference resolution - replace common references
40
+ let resolved = query;
41
+ const lastTurn = history[history.length - 1];
42
+ // Replace "it" with last mentioned entity/context
43
+ if (/\bit\b/i.test(query) && lastTurn.response) {
44
+ // Extract key entities from last response (simple heuristic)
45
+ const lastResponse = lastTurn.response;
46
+ const words = lastResponse.split(/\s+/).filter(w => w.length > 3);
47
+ if (words.length > 0) {
48
+ // Try to replace "it" with last significant noun phrase
49
+ resolved = resolved.replace(/\bit\b/gi, words[words.length - 1]);
102
50
  }
103
51
  }
104
- // Resolve "the previous" references
105
- if (queryLower.includes('previous') || queryLower.includes('last')) {
106
- if (lastTurn.query) {
107
- resolvedQuery = resolvedQuery.replace(/\b(previous|last)\s+(one|query|question|command)?\b/gi, lastTurn.query);
108
- }
52
+ // Replace "that" with last query
53
+ if (/\bthat\b/i.test(query)) {
54
+ resolved = resolved.replace(/\bthat\b/gi, `"${lastTurn.query}"`);
109
55
  }
110
- // Resolve "too" / "also" - append to previous action
111
- if (queryLower.includes(' too') || queryLower.includes(' also')) {
112
- if (lastTurn.query) {
113
- resolvedQuery = query.replace(/\s+(too|also)\b/i, '');
114
- // If previous was an edit, append to same file
115
- if (lastTurn.intent === 'edit' && context.currentFocus?.filepath) {
116
- resolvedQuery = `Add to ${context.currentFocus.filepath}: ${resolvedQuery}`;
117
- }
118
- }
56
+ // Replace "the previous" with last query
57
+ if (/\bthe previous\b/i.test(query)) {
58
+ resolved = resolved.replace(/\bthe previous\b/gi, `"${lastTurn.query}"`);
119
59
  }
120
- return resolvedQuery.trim();
60
+ return resolved;
121
61
  }
122
62
  /**
123
- * Extract entities from query (file names, functions, classes)
63
+ * Extract entities from text (simple heuristic-based extraction)
124
64
  */
125
- extractEntities(query) {
65
+ extractEntities(text, options) {
66
+ // Simple entity extraction - can be enhanced later
126
67
  const entities = [];
127
68
  // Extract file paths
128
- const filePathPattern = /[\w\-./]+\.(ts|js|tsx|jsx|py|java|go|rs|rb|php|cs)/g;
129
- const filePaths = query.match(filePathPattern);
130
- if (filePaths) {
131
- entities.push(...filePaths);
69
+ const filePathRegex = /[\w\/\-\.]+\.(ts|js|tsx|jsx|json|md|yaml|yml|txt|py|go|rs|java|cpp|h|hpp)/g;
70
+ const filePaths = text.match(filePathRegex) || [];
71
+ filePaths.forEach(path => {
72
+ entities.push({ type: 'file', value: path });
73
+ });
74
+ // Extract function/class names (simple heuristic)
75
+ const functionRegex = /(?:function|class|const|let|var)\s+([A-Z][a-zA-Z0-9_]+|[a-z][a-zA-Z0-9_]+)/g;
76
+ const matches = text.matchAll(functionRegex);
77
+ for (const match of matches) {
78
+ entities.push({ type: 'symbol', value: match[1] });
132
79
  }
133
- // Extract function/class names (capitalized words or camelCase)
134
- const identifierPattern = /[A-Z][a-zA-Z0-9]+/g;
135
- const identifiers = query.match(identifierPattern);
136
- if (identifiers) {
137
- entities.push(...identifiers.filter(id => id.length > 2));
80
+ return entities;
81
+ }
82
+ /**
83
+ * Add a conversation turn
84
+ */
85
+ addTurn(sessionId, query, response, entities = [], intent) {
86
+ let session = this.sessions.get(sessionId);
87
+ if (!session) {
88
+ session = {
89
+ sessionId,
90
+ turns: [],
91
+ createdAt: Date.now(),
92
+ lastUpdated: Date.now(),
93
+ };
94
+ this.sessions.set(sessionId, session);
138
95
  }
139
- // Extract quoted strings (often entity names)
140
- const quotedPattern = /"([^"]+)"/g;
141
- const quoted = query.match(quotedPattern);
142
- if (quoted) {
143
- entities.push(...quoted.map(q => q.replace(/"/g, '')));
96
+ const turn = {
97
+ query,
98
+ response,
99
+ timestamp: new Date().toISOString(),
100
+ entities,
101
+ intent,
102
+ };
103
+ session.turns.push(turn);
104
+ session.lastUpdated = Date.now();
105
+ // Trim history if too long
106
+ if (session.turns.length > this.maxHistoryPerSession) {
107
+ session.turns = session.turns.slice(-this.maxHistoryPerSession);
144
108
  }
145
- return [...new Set(entities)]; // Remove duplicates
146
109
  }
147
110
  /**
148
- * Get conversation context summary for AI prompts
111
+ * Get full context for a session
149
112
  */
150
- getContextSummary(sessionId, maxTurns = 3) {
151
- const history = this.getHistory(sessionId, maxTurns);
152
- if (history.length === 0) {
153
- return '';
154
- }
155
- const summary = history.map((turn, idx) => {
156
- const turnNum = history.length - maxTurns + idx + 1;
157
- return `[Previous ${turnNum}]: User asked "${turn.query}". Response: ${turn.response.substring(0, 100)}...`;
158
- }).join('\n');
159
- return `\n\nCONVERSATION HISTORY:\n${summary}\n`;
113
+ getContext(sessionId) {
114
+ return this.sessions.get(sessionId) || null;
160
115
  }
161
116
  /**
162
- * Clear conversation context (for new session)
117
+ * Clear conversation history for a session
163
118
  */
164
- clearContext(sessionId) {
165
- this.conversations.delete(sessionId);
119
+ clear(sessionId) {
120
+ if (sessionId) {
121
+ this.sessions.delete(sessionId);
122
+ }
123
+ else {
124
+ this.sessions.clear();
125
+ }
166
126
  }
167
127
  }
168
- // Singleton instance
169
128
  export const conversationContextManager = new ConversationContextManager();
170
129
  //# sourceMappingURL=conversation-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-context.js","sourceRoot":"","sources":["../../../src/infrastructure/context/conversation-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsBH,MAAM,OAAO,0BAA0B;IAC7B,aAAa,GAAqC,IAAI,GAAG,EAAE,CAAC;IAC5D,gBAAgB,GAAG,EAAE,CAAC,CAAC,qBAAqB;IAC5C,qBAAqB,GAAG,EAAE,CAAC,CAAC,sCAAsC;IAE1E;;OAEG;IACH,UAAU,CAAC,SAAiB;QAC1B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE;gBAChC,SAAS;gBACT,KAAK,EAAE,EAAE;gBACT,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;gBACrB,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;aACxB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,SAAiB,EAAE,KAAa,EAAE,QAAgB,EAAE,QAAmB,EAAE,MAAe;QAC9F,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAE3C,4DAA4D;QAC5D,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM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EAAE,GAAG,CAAC,KAAK,CAAC;QAC9G,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,OAAO,8BAA8B,OAAO,IAAI,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,SAAiB;QAC5B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;CACF;AAED,qBAAqB;AACrB,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
1
+ {"version":3,"file":"conversation-context.js","sourceRoot":"","sources":["../../../src/infrastructure/context/conversation-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH;;;GAGG;AACH,MAAM,0BAA0B;IACtB,QAAQ,GAAqC,IAAI,GAAG,EAAE,CAAC;IAC9C,oBAAoB,GAAG,EAAE,CAAC;IAE3C;;OAEG;IACH,UAAU,CAAC,SAAiB,EAAE,QAAgB,EAAE;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,wCAAwC;QACxC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;QAC1C,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACxB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,4BAA4B;SAClD,CAAC,CAAC,CAAC;IACN,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,SAAiB,EAAE,KAAa;QAChD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,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AAQ;YACR,MAAM;SACP,CAAC;QAEF,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEjC,2BAA2B;QAC3B,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;YACrD,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,SAAiB;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAkB;QACtB,IAAI,SAAS,EAAE,CAAC;YACd,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
@@ -1,26 +1,42 @@
1
1
  /**
2
2
  * Session Manager
3
- * Manages persistent session IDs for conversation context across CLI commands
3
+ * Manages CLI sessions for context tracking
4
+ *
5
+ * Phase 1: v0.5.0-alpha.0
4
6
  */
5
- export declare class SessionManager {
7
+ interface Session {
8
+ sessionId: string;
9
+ cwd: string;
10
+ startedAt: number;
11
+ lastActivity: number;
12
+ }
13
+ /**
14
+ * Session manager for tracking CLI sessions
15
+ */
16
+ declare class SessionManager {
6
17
  private sessions;
7
- constructor();
18
+ private readonly sessionTimeout;
19
+ /**
20
+ * Get or create session ID for a working directory
21
+ */
22
+ getSessionId(cwd: string): string;
8
23
  /**
9
- * Get or create session ID for a codebase directory
24
+ * Get current session for a working directory
10
25
  */
11
- getSessionId(codebasePath: string): string;
26
+ getCurrentSession(cwd: string): Session | null;
12
27
  /**
13
- * Load sessions from disk
28
+ * Create a new session explicitly
14
29
  */
15
- private loadSessions;
30
+ createSession(cwd: string): Session;
16
31
  /**
17
- * Save sessions to disk
32
+ * End a session
18
33
  */
19
- private saveSessions;
34
+ endSession(cwd: string): void;
20
35
  /**
21
- * Clear session for a codebase
36
+ * Clean up expired sessions
22
37
  */
23
- clearSession(codebasePath: string): void;
38
+ cleanup(): void;
24
39
  }
25
40
  export declare const sessionManager: SessionManager;
41
+ export {};
26
42
  //# sourceMappingURL=session-manager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/session-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAuC;;IAMvD;;OAEG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IA0B1C;;OAEG;IACH,OAAO,CAAC,YAAY;IA4BpB;;OAEG;IACH,OAAO,CAAC,YAAY;IAmBpB;;OAEG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;CAKzC;AAGD,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
1
+ {"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/context/session-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,UAAU,OAAO;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,cAAM,cAAc;IAClB,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAuB;IAEtD;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IA8BjC;;OAEG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAK9C;;OAEG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAenC;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK7B;;OAEG;IACH,OAAO,IAAI,IAAI;CAShB;AAED,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
@@ -1,98 +1,94 @@
1
1
  /**
2
2
  * Session Manager
3
- * Manages persistent session IDs for conversation context across CLI commands
3
+ * Manages CLI sessions for context tracking
4
+ *
5
+ * Phase 1: v0.5.0-alpha.0
4
6
  */
5
- import * as fs from 'fs';
6
- import * as path from 'path';
7
- import { homedir } from 'os';
8
- const SESSION_DIR = path.join(homedir(), '.codehere');
9
- const SESSION_FILE = path.join(SESSION_DIR, 'sessions.json');
10
- export class SessionManager {
7
+ /**
8
+ * Session manager for tracking CLI sessions
9
+ */
10
+ class SessionManager {
11
11
  sessions = new Map();
12
- constructor() {
13
- this.loadSessions();
14
- }
12
+ sessionTimeout = 24 * 60 * 60 * 1000; // 24 hours
15
13
  /**
16
- * Get or create session ID for a codebase directory
14
+ * Get or create session ID for a working directory
17
15
  */
18
- getSessionId(codebasePath) {
19
- // Normalize path
20
- const normalizedPath = path.resolve(codebasePath);
21
- // Check if we already have a session for this codebase
22
- if (this.sessions.has(normalizedPath)) {
23
- const session = this.sessions.get(normalizedPath);
24
- session.lastUsed = Date.now();
25
- this.saveSessions();
26
- return session.sessionId;
16
+ getSessionId(cwd) {
17
+ // Normalize cwd path
18
+ const normalizedCwd = cwd || process.cwd();
19
+ // Check if session exists and is still valid
20
+ const existingSession = this.sessions.get(normalizedCwd);
21
+ if (existingSession) {
22
+ const age = Date.now() - existingSession.lastActivity;
23
+ if (age < this.sessionTimeout) {
24
+ existingSession.lastActivity = Date.now();
25
+ return existingSession.sessionId;
26
+ }
27
+ else {
28
+ // Session expired, remove it
29
+ this.sessions.delete(normalizedCwd);
30
+ }
27
31
  }
28
32
  // Create new session
29
- const sessionId = `session-${normalizedPath}-${Date.now()}`;
33
+ const sessionId = `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
30
34
  const session = {
31
35
  sessionId,
32
- codebasePath: normalizedPath,
33
- createdAt: Date.now(),
34
- lastUsed: Date.now(),
36
+ cwd: normalizedCwd,
37
+ startedAt: Date.now(),
38
+ lastActivity: Date.now(),
35
39
  };
36
- this.sessions.set(normalizedPath, session);
37
- this.saveSessions();
40
+ this.sessions.set(normalizedCwd, session);
38
41
  return sessionId;
39
42
  }
40
43
  /**
41
- * Load sessions from disk
44
+ * Get current session for a working directory
42
45
  */
43
- loadSessions() {
44
- try {
45
- if (!fs.existsSync(SESSION_FILE)) {
46
- return;
47
- }
48
- const data = fs.readFileSync(SESSION_FILE, 'utf-8');
49
- const sessions = JSON.parse(data);
50
- // Clean up old sessions (older than 7 days)
51
- const sevenDaysAgo = Date.now() - (7 * 24 * 60 * 60 * 1000);
52
- for (const [key, session] of Object.entries(sessions)) {
53
- if (session.lastUsed > sevenDaysAgo) {
54
- this.sessions.set(key, session);
55
- }
56
- }
57
- // Save cleaned sessions
58
- if (this.sessions.size !== Object.keys(sessions).length) {
59
- this.saveSessions();
60
- }
61
- }
62
- catch (error) {
63
- // If file is corrupted or doesn't exist, start fresh
64
- this.sessions.clear();
65
- }
46
+ getCurrentSession(cwd) {
47
+ const normalizedCwd = cwd || process.cwd();
48
+ return this.sessions.get(normalizedCwd) || null;
66
49
  }
67
50
  /**
68
- * Save sessions to disk
51
+ * Create a new session explicitly
69
52
  */
70
- saveSessions() {
71
- try {
72
- // Ensure directory exists
73
- if (!fs.existsSync(SESSION_DIR)) {
74
- fs.mkdirSync(SESSION_DIR, { recursive: true });
75
- }
76
- const sessionsObj = {};
77
- for (const [key, session] of this.sessions.entries()) {
78
- sessionsObj[key] = session;
79
- }
80
- fs.writeFileSync(SESSION_FILE, JSON.stringify(sessionsObj, null, 2), 'utf-8');
81
- }
82
- catch (error) {
83
- // Fail silently - session persistence is not critical
84
- console.warn('[SessionManager] Failed to save sessions:', error);
85
- }
53
+ createSession(cwd) {
54
+ const normalizedCwd = cwd || process.cwd();
55
+ const sessionId = `session-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
56
+ const session = {
57
+ sessionId,
58
+ cwd: normalizedCwd,
59
+ startedAt: Date.now(),
60
+ lastActivity: Date.now(),
61
+ };
62
+ this.sessions.set(normalizedCwd, session);
63
+ return session;
86
64
  }
87
65
  /**
88
- * Clear session for a codebase
66
+ * End a session
89
67
  */
90
- clearSession(codebasePath) {
91
- const normalizedPath = path.resolve(codebasePath);
92
- this.sessions.delete(normalizedPath);
93
- this.saveSessions();
68
+ endSession(cwd) {
69
+ const normalizedCwd = cwd || process.cwd();
70
+ this.sessions.delete(normalizedCwd);
71
+ }
72
+ /**
73
+ * Clean up expired sessions
74
+ */
75
+ cleanup() {
76
+ const now = Date.now();
77
+ for (const [cwd, session] of this.sessions.entries()) {
78
+ const age = now - session.lastActivity;
79
+ if (age >= this.sessionTimeout) {
80
+ this.sessions.delete(cwd);
81
+ }
82
+ }
94
83
  }
95
84
  }
96
- // Singleton instance
97
85
  export const sessionManager = new SessionManager();
86
+ // Cleanup expired sessions periodically
87
+ // Use .unref() to allow process to exit even with timer active
88
+ if (typeof setInterval !== 'undefined') {
89
+ const cleanupInterval = setInterval(() => {
90
+ sessionManager.cleanup();
91
+ }, 60 * 60 * 1000); // Every hour
92
+ cleanupInterval.unref();
93
+ }
98
94
  //# sourceMappingURL=session-manager.js.map