@nxuss/lemma 1.6.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/README.md +114 -5
  2. package/bin/checkpoint.js +49 -0
  3. package/bin/init.js +21 -2
  4. package/dist/cjs/mcp/prompts.d.ts +1 -2
  5. package/dist/cjs/mcp/prompts.d.ts.map +1 -1
  6. package/dist/cjs/mcp/prompts.js +29 -126
  7. package/dist/cjs/mcp/prompts.js.map +1 -1
  8. package/dist/cjs/mcp/resources.d.ts.map +1 -1
  9. package/dist/cjs/mcp/resources.js +4 -4
  10. package/dist/cjs/mcp/resources.js.map +1 -1
  11. package/dist/cjs/mcp/tool-profiles.d.ts +55 -0
  12. package/dist/cjs/mcp/tool-profiles.d.ts.map +1 -0
  13. package/dist/cjs/mcp/tool-profiles.js +204 -0
  14. package/dist/cjs/mcp/tool-profiles.js.map +1 -0
  15. package/dist/cjs/mcp/tools.d.ts +12 -0
  16. package/dist/cjs/mcp/tools.d.ts.map +1 -1
  17. package/dist/cjs/mcp/tools.js +175 -26
  18. package/dist/cjs/mcp/tools.js.map +1 -1
  19. package/dist/cjs/subconscious/TheBrainV2.d.ts +36 -2
  20. package/dist/cjs/subconscious/TheBrainV2.d.ts.map +1 -1
  21. package/dist/cjs/subconscious/TheBrainV2.js +104 -23
  22. package/dist/cjs/subconscious/TheBrainV2.js.map +1 -1
  23. package/dist/cjs/utils/AutoContextBundle.d.ts.map +1 -1
  24. package/dist/cjs/utils/AutoContextBundle.js +17 -20
  25. package/dist/cjs/utils/AutoContextBundle.js.map +1 -1
  26. package/dist/cjs/utils/ConversationCheckpoint.d.ts +13 -0
  27. package/dist/cjs/utils/ConversationCheckpoint.d.ts.map +1 -1
  28. package/dist/cjs/utils/ConversationCheckpoint.js +58 -0
  29. package/dist/cjs/utils/ConversationCheckpoint.js.map +1 -1
  30. package/dist/cjs/utils/TestAutofixInterceptor.d.ts.map +1 -1
  31. package/dist/cjs/utils/TestAutofixInterceptor.js +15 -26
  32. package/dist/cjs/utils/TestAutofixInterceptor.js.map +1 -1
  33. package/dist/esm/api/dashboardRoutes.d.ts +3 -3
  34. package/dist/esm/api/dashboardRoutes.js +1 -1
  35. package/dist/esm/api/server.d.ts +4 -4
  36. package/dist/esm/api/server.js +3 -3
  37. package/dist/esm/autopilot/AutopilotWatcher.js +3 -3
  38. package/dist/esm/autopilot/Notifier.d.ts +1 -1
  39. package/dist/esm/cli/lemma-proxy.js +14 -14
  40. package/dist/esm/cli/stack.d.ts +4 -4
  41. package/dist/esm/cli/stack.js +5 -5
  42. package/dist/esm/cloud/KeyManager.d.ts +1 -1
  43. package/dist/esm/cloud/KeyManager.js +1 -1
  44. package/dist/esm/cloud/TenantCache.d.ts +1 -1
  45. package/dist/esm/cloud/TenantCache.js +1 -1
  46. package/dist/esm/cloud/index.d.ts +3 -3
  47. package/dist/esm/cloud/index.js +3 -3
  48. package/dist/esm/cloud/server.d.ts +3 -3
  49. package/dist/esm/cloud/server.js +5 -5
  50. package/dist/esm/config/index.d.ts +1 -1
  51. package/dist/esm/config/index.js +1 -1
  52. package/dist/esm/consensus/index.d.ts +2 -2
  53. package/dist/esm/consensus/index.js +2 -2
  54. package/dist/esm/core/AgentRegistry.d.ts +1 -1
  55. package/dist/esm/core/AgentRegistry.js +1 -1
  56. package/dist/esm/core/DashboardBroadcaster.d.ts +3 -3
  57. package/dist/esm/core/DashboardBroadcaster.js +2 -2
  58. package/dist/esm/core/DashboardWebSocketServer.d.ts +1 -1
  59. package/dist/esm/core/DashboardWebSocketServer.js +1 -1
  60. package/dist/esm/core/GhostAlchemist.js +1 -1
  61. package/dist/esm/core/GhostListener.js +2 -2
  62. package/dist/esm/core/OrchestrationEngine.d.ts +3 -3
  63. package/dist/esm/core/OrchestrationEngine.js +2 -2
  64. package/dist/esm/core/SubconsciousEngine.d.ts +1 -1
  65. package/dist/esm/core/SubconsciousEngine.js +2 -2
  66. package/dist/esm/core/WebSocketServer.d.ts +2 -2
  67. package/dist/esm/core/WebSocketServer.js +1 -1
  68. package/dist/esm/core/index.d.ts +6 -6
  69. package/dist/esm/core/index.js +6 -6
  70. package/dist/esm/core/router.d.ts +3 -3
  71. package/dist/esm/core/router.js +1 -1
  72. package/dist/esm/db/database.js +1 -1
  73. package/dist/esm/embed.d.ts +2 -2
  74. package/dist/esm/embed.js +2 -2
  75. package/dist/esm/examples/basic-usage.js +1 -1
  76. package/dist/esm/index.d.ts +14 -14
  77. package/dist/esm/index.js +14 -14
  78. package/dist/esm/infra/analyzers/DriftDetector.d.ts +1 -1
  79. package/dist/esm/infra/analyzers/InfraAnalyzer.d.ts +1 -1
  80. package/dist/esm/infra/analyzers/MonolithAnalyzer.d.ts +1 -1
  81. package/dist/esm/infra/analyzers/index.d.ts +3 -3
  82. package/dist/esm/infra/analyzers/index.js +3 -3
  83. package/dist/esm/infra/cli.js +2 -2
  84. package/dist/esm/infra/config.d.ts +1 -1
  85. package/dist/esm/infra/index.d.ts +5 -5
  86. package/dist/esm/infra/index.js +5 -5
  87. package/dist/esm/infra/mcp-tools.js +5 -5
  88. package/dist/esm/infra/providers/InfraProvider.d.ts +1 -1
  89. package/dist/esm/infra/providers/JenkinsProvider.d.ts +2 -2
  90. package/dist/esm/infra/providers/OKDProvider.d.ts +2 -2
  91. package/dist/esm/infra/providers/TerraformProvider.d.ts +2 -2
  92. package/dist/esm/infra/providers/index.d.ts +5 -5
  93. package/dist/esm/infra/providers/index.js +3 -3
  94. package/dist/esm/mcp/index.js +5 -5
  95. package/dist/esm/mcp/prompts.d.ts +1 -2
  96. package/dist/esm/mcp/prompts.d.ts.map +1 -1
  97. package/dist/esm/mcp/prompts.js +28 -125
  98. package/dist/esm/mcp/prompts.js.map +1 -1
  99. package/dist/esm/mcp/resources.d.ts.map +1 -1
  100. package/dist/esm/mcp/resources.js +5 -5
  101. package/dist/esm/mcp/resources.js.map +1 -1
  102. package/dist/esm/mcp/tool-profiles.d.ts +55 -0
  103. package/dist/esm/mcp/tool-profiles.d.ts.map +1 -0
  104. package/dist/esm/mcp/tool-profiles.js +196 -0
  105. package/dist/esm/mcp/tool-profiles.js.map +1 -0
  106. package/dist/esm/mcp/tools.d.ts +12 -0
  107. package/dist/esm/mcp/tools.d.ts.map +1 -1
  108. package/dist/esm/mcp/tools.js +209 -63
  109. package/dist/esm/mcp/tools.js.map +1 -1
  110. package/dist/esm/observability/IdeContextSync.d.ts +1 -1
  111. package/dist/esm/observability/IdeContextSync.js +5 -5
  112. package/dist/esm/pr-review/PRReviewEngine.d.ts +1 -1
  113. package/dist/esm/pr-review/PRReviewEngine.js +4 -4
  114. package/dist/esm/pr-review/ReviewStore.d.ts +1 -1
  115. package/dist/esm/pr-review/adapters/AzureDevOpsAdapter.d.ts +2 -2
  116. package/dist/esm/pr-review/adapters/AzureDevOpsAdapter.js +1 -1
  117. package/dist/esm/pr-review/adapters/GitHubAdapter.d.ts +2 -2
  118. package/dist/esm/pr-review/adapters/GitHubAdapter.js +1 -1
  119. package/dist/esm/pr-review/adapters/GitLabAdapter.d.ts +2 -2
  120. package/dist/esm/pr-review/adapters/GitLabAdapter.js +1 -1
  121. package/dist/esm/pr-review/adapters/GitPlatformAdapter.d.ts +1 -1
  122. package/dist/esm/pr-review/adapters/index.d.ts +4 -4
  123. package/dist/esm/pr-review/adapters/index.js +3 -3
  124. package/dist/esm/pr-review/analyzers/QualityGrader.d.ts +1 -1
  125. package/dist/esm/pr-review/analyzers/RegressionDetector.d.ts +1 -1
  126. package/dist/esm/pr-review/analyzers/SecurityScanner.d.ts +1 -1
  127. package/dist/esm/pr-review/analyzers/StaticAnalyzer.d.ts +1 -1
  128. package/dist/esm/pr-review/analyzers/index.d.ts +8 -8
  129. package/dist/esm/pr-review/analyzers/index.js +4 -4
  130. package/dist/esm/pr-review/bridge/BrainBridge.d.ts +1 -1
  131. package/dist/esm/pr-review/bridge/BrainBridge.js +1 -1
  132. package/dist/esm/pr-review/bridge/index.d.ts +1 -1
  133. package/dist/esm/pr-review/bridge/index.js +1 -1
  134. package/dist/esm/pr-review/index.d.ts +4 -4
  135. package/dist/esm/pr-review/index.js +2 -2
  136. package/dist/esm/pr-review/reviewRunner.d.ts +2 -2
  137. package/dist/esm/pr-review/reviewRunner.js +6 -6
  138. package/dist/esm/pr-review/webhook/WebhookServer.js +1 -1
  139. package/dist/esm/pr-review/webhook/index.d.ts +1 -1
  140. package/dist/esm/pr-review/webhook/index.js +1 -1
  141. package/dist/esm/protocol/flows.d.ts +1 -1
  142. package/dist/esm/protocol/flows.js +1 -1
  143. package/dist/esm/protocol/index.d.ts +4 -4
  144. package/dist/esm/protocol/index.js +4 -4
  145. package/dist/esm/protocol/utils.d.ts +1 -1
  146. package/dist/esm/protocol/utils.js +2 -2
  147. package/dist/esm/protocol/validators.d.ts +1 -1
  148. package/dist/esm/protocol/validators.js +1 -1
  149. package/dist/esm/proxy/ContextInjector.d.ts +1 -1
  150. package/dist/esm/proxy/Gatekeeper.d.ts +1 -1
  151. package/dist/esm/security/SecurityMiddleware.d.ts +1 -1
  152. package/dist/esm/security/SecurityMiddleware.js +3 -3
  153. package/dist/esm/security/index.d.ts +4 -4
  154. package/dist/esm/security/index.js +4 -4
  155. package/dist/esm/speculative/SpeculativeCache.d.ts +2 -2
  156. package/dist/esm/speculative/SpeculativeEngine.d.ts +2 -2
  157. package/dist/esm/speculative/SpeculativeEngine.js +3 -3
  158. package/dist/esm/speculative/WorkerPool.d.ts +1 -1
  159. package/dist/esm/speculative/index.d.ts +4 -4
  160. package/dist/esm/speculative/index.js +4 -4
  161. package/dist/esm/subconscious/SemanticCache.d.ts +2 -2
  162. package/dist/esm/subconscious/SemanticCache.js +2 -2
  163. package/dist/esm/subconscious/SubconsciousEngine.d.ts +1 -1
  164. package/dist/esm/subconscious/SubconsciousEngine.js +3 -3
  165. package/dist/esm/subconscious/TheBrainV2.d.ts +36 -2
  166. package/dist/esm/subconscious/TheBrainV2.d.ts.map +1 -1
  167. package/dist/esm/subconscious/TheBrainV2.js +103 -23
  168. package/dist/esm/subconscious/TheBrainV2.js.map +1 -1
  169. package/dist/esm/subconscious/index.d.ts +4 -4
  170. package/dist/esm/subconscious/index.js +4 -4
  171. package/dist/esm/utils/AutoContextBundle.d.ts +1 -1
  172. package/dist/esm/utils/AutoContextBundle.d.ts.map +1 -1
  173. package/dist/esm/utils/AutoContextBundle.js +20 -23
  174. package/dist/esm/utils/AutoContextBundle.js.map +1 -1
  175. package/dist/esm/utils/BulkFileDigest.js +2 -2
  176. package/dist/esm/utils/ClipboardWatcher.js +2 -2
  177. package/dist/esm/utils/ContextCollapser.js +1 -1
  178. package/dist/esm/utils/ConversationCheckpoint.d.ts +13 -0
  179. package/dist/esm/utils/ConversationCheckpoint.d.ts.map +1 -1
  180. package/dist/esm/utils/ConversationCheckpoint.js +57 -0
  181. package/dist/esm/utils/ConversationCheckpoint.js.map +1 -1
  182. package/dist/esm/utils/ExecutiveReport.js +1 -1
  183. package/dist/esm/utils/StructuralSearch.d.ts +1 -1
  184. package/dist/esm/utils/SurgicalASTInsert.js +1 -1
  185. package/dist/esm/utils/SymbolSurgicalContext.js +1 -1
  186. package/dist/esm/utils/TestAutofixInterceptor.d.ts.map +1 -1
  187. package/dist/esm/utils/TestAutofixInterceptor.js +15 -26
  188. package/dist/esm/utils/TestAutofixInterceptor.js.map +1 -1
  189. package/dist/esm/utils/WorkspaceSearch.js +0 -0
  190. package/dist/esm/utils/logger.js +1 -1
  191. package/package.json +9 -10
  192. package/sdks/crewai/README.md +178 -0
  193. package/sdks/crewai/dist/index.d.ts +130 -0
  194. package/sdks/crewai/dist/index.js +308 -0
@@ -4,10 +4,10 @@
4
4
  * High-performance orchestration hub for autonomous AI agents
5
5
  * Implements the Inter-Agent Protocol (I.A.P.) for standardized communication
6
6
  */
7
- import { WebSocketServer } from './core/WebSocketServer';
8
- import { AgentRegistry } from './core/AgentRegistry';
9
- import { Router } from './core/router';
10
- import { ServerConfig, RouterConfig, IdeSyncConfig } from './types';
7
+ import { WebSocketServer } from './core/WebSocketServer.js';
8
+ import { AgentRegistry } from './core/AgentRegistry.js';
9
+ import { Router } from './core/router.js';
10
+ import { ServerConfig, RouterConfig, IdeSyncConfig } from './types/index.js';
11
11
  /**
12
12
  * Main Hub Configuration
13
13
  */
@@ -53,7 +53,7 @@ export declare class SubconsciousHub {
53
53
  totalTasksCompleted: number;
54
54
  totalTasksFailed: number;
55
55
  };
56
- connectionStats: import("./types").ConnectionStats;
56
+ connectionStats: import("./types/index.js").ConnectionStats;
57
57
  };
58
58
  /**
59
59
  * Print current status
@@ -72,14 +72,14 @@ export declare class SubconsciousHub {
72
72
  */
73
73
  getRouter(): Router;
74
74
  }
75
- export * from './types';
76
- export * from './core';
77
- export * from './security';
78
- export * as Protocol from './protocol';
79
- export * as Subconscious from './subconscious';
80
- export * as Consensus from './consensus';
81
- export * as Speculative from './speculative';
82
- export { config, getSecurityConfig, validateConfig } from './config';
83
- export { Lemma, LemmaConfig, CacheResult, LemmaMetrics } from './embed';
75
+ export * from './types/index.js';
76
+ export * from './core/index.js';
77
+ export * from './security/index.js';
78
+ export * as Protocol from './protocol/index.js';
79
+ export * as Subconscious from './subconscious/index.js';
80
+ export * as Consensus from './consensus/index.js';
81
+ export * as Speculative from './speculative/index.js';
82
+ export { config, getSecurityConfig, validateConfig } from './config/index.js';
83
+ export { Lemma, LemmaConfig, CacheResult, LemmaMetrics } from './embed.js';
84
84
  export default SubconsciousHub;
85
85
  //# sourceMappingURL=index.d.ts.map
package/dist/esm/index.js CHANGED
@@ -4,11 +4,11 @@
4
4
  * High-performance orchestration hub for autonomous AI agents
5
5
  * Implements the Inter-Agent Protocol (I.A.P.) for standardized communication
6
6
  */
7
- import { WebSocketServer } from './core/WebSocketServer';
8
- import { AgentRegistry } from './core/AgentRegistry';
9
- import { Router } from './core/router';
10
- import { IdeContextSync } from './observability/IdeContextSync';
11
- import { logger } from './utils/logger';
7
+ import { WebSocketServer } from './core/WebSocketServer.js';
8
+ import { AgentRegistry } from './core/AgentRegistry.js';
9
+ import { Router } from './core/router.js';
10
+ import { IdeContextSync } from './observability/IdeContextSync.js';
11
+ import { logger } from './utils/logger.js';
12
12
  /**
13
13
  * Subconscious Router Hub
14
14
  * Orchestrates WebSocket connections, agent registry, and message routing
@@ -148,16 +148,16 @@ export class SubconsciousHub {
148
148
  }
149
149
  }
150
150
  // Export all types and core components
151
- export * from './types';
152
- export * from './core';
153
- export * from './security';
154
- export * as Protocol from './protocol';
155
- export * as Subconscious from './subconscious';
156
- export * as Consensus from './consensus';
157
- export * as Speculative from './speculative';
158
- export { config, getSecurityConfig, validateConfig } from './config';
151
+ export * from './types/index.js';
152
+ export * from './core/index.js';
153
+ export * from './security/index.js';
154
+ export * as Protocol from './protocol/index.js';
155
+ export * as Subconscious from './subconscious/index.js';
156
+ export * as Consensus from './consensus/index.js';
157
+ export * as Speculative from './speculative/index.js';
158
+ export { config, getSecurityConfig, validateConfig } from './config/index.js';
159
159
  // Embedded mode — zero-config semantic cache
160
- export { Lemma } from './embed';
160
+ export { Lemma } from './embed.js';
161
161
  // Export default hub instance creator
162
162
  export default SubconsciousHub;
163
163
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import type { DriftResult } from '../types';
1
+ import type { DriftResult } from '../types.js';
2
2
  export declare function detectTerraformDrift(workDir?: string): DriftResult[];
3
3
  export declare function detectOKDDrift(project: string): DriftResult[];
4
4
  //# sourceMappingURL=DriftDetector.d.ts.map
@@ -1,3 +1,3 @@
1
- import type { InfraAnalysisResult } from '../types';
1
+ import type { InfraAnalysisResult } from '../types.js';
2
2
  export declare function analyzeInfra(provider: string, status: Record<string, any>): InfraAnalysisResult;
3
3
  //# sourceMappingURL=InfraAnalyzer.d.ts.map
@@ -1,3 +1,3 @@
1
- import type { MonolithAnalysis } from '../types';
1
+ import type { MonolithAnalysis } from '../types.js';
2
2
  export declare function analyzeMonolith(workspaceRoot: string): MonolithAnalysis;
3
3
  //# sourceMappingURL=MonolithAnalyzer.d.ts.map
@@ -1,4 +1,4 @@
1
- export { analyzeInfra } from './InfraAnalyzer';
2
- export { detectTerraformDrift, detectOKDDrift } from './DriftDetector';
3
- export { analyzeMonolith } from './MonolithAnalyzer';
1
+ export { analyzeInfra } from './InfraAnalyzer.js';
2
+ export { detectTerraformDrift, detectOKDDrift } from './DriftDetector.js';
3
+ export { analyzeMonolith } from './MonolithAnalyzer.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- export { analyzeInfra } from './InfraAnalyzer';
2
- export { detectTerraformDrift, detectOKDDrift } from './DriftDetector';
3
- export { analyzeMonolith } from './MonolithAnalyzer';
1
+ export { analyzeInfra } from './InfraAnalyzer.js';
2
+ export { detectTerraformDrift, detectOKDDrift } from './DriftDetector.js';
3
+ export { analyzeMonolith } from './MonolithAnalyzer.js';
4
4
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  import { program } from 'commander';
2
- import { getInfraConfig } from './config';
3
- import { getProvider } from './providers';
2
+ import { getInfraConfig } from './config.js';
3
+ import { getProvider } from './providers/index.js';
4
4
  export function registerInfraCommands() {
5
5
  const infra = program.command('infra').description('Infrastructure Command Center — manage Jenkins, OKD, and Terraform');
6
6
  infra.command('discover')
@@ -1,4 +1,4 @@
1
- import type { InfraConfig } from './types';
1
+ import type { InfraConfig } from './types.js';
2
2
  export declare function getInfraConfig(): InfraConfig;
3
3
  interface DeployRecord {
4
4
  provider: string;
@@ -1,8 +1,8 @@
1
- import { getInfraToolDefinitions, getInfraToolHandlers, INFRA_TOOL_NAMES } from './mcp-tools';
2
- import { registerInfraCommands } from './cli';
1
+ import { getInfraToolDefinitions, getInfraToolHandlers, INFRA_TOOL_NAMES } from './mcp-tools.js';
2
+ import { registerInfraCommands } from './cli.js';
3
3
  export { getInfraToolDefinitions, getInfraToolHandlers, INFRA_TOOL_NAMES };
4
4
  export { registerInfraCommands };
5
- export { getInfraConfig, markProviderConnected, getConnectedProviders, recordDeploy, getDeployHistory } from './config';
6
- export { getProvider, listProviders, JenkinsProvider, OKDProvider, TerraformProvider } from './providers';
7
- export { analyzeInfra, detectTerraformDrift, detectOKDDrift, analyzeMonolith } from './analyzers';
5
+ export { getInfraConfig, markProviderConnected, getConnectedProviders, recordDeploy, getDeployHistory } from './config.js';
6
+ export { getProvider, listProviders, JenkinsProvider, OKDProvider, TerraformProvider } from './providers/index.js';
7
+ export { analyzeInfra, detectTerraformDrift, detectOKDDrift, analyzeMonolith } from './analyzers/index.js';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1,9 +1,9 @@
1
- import { getInfraToolDefinitions, getInfraToolHandlers, INFRA_TOOL_NAMES } from './mcp-tools';
2
- import { registerInfraCommands } from './cli';
1
+ import { getInfraToolDefinitions, getInfraToolHandlers, INFRA_TOOL_NAMES } from './mcp-tools.js';
2
+ import { registerInfraCommands } from './cli.js';
3
3
  export { getInfraToolDefinitions, getInfraToolHandlers, INFRA_TOOL_NAMES };
4
4
  export { registerInfraCommands };
5
5
  // Re-export for direct usage
6
- export { getInfraConfig, markProviderConnected, getConnectedProviders, recordDeploy, getDeployHistory } from './config';
7
- export { getProvider, listProviders, JenkinsProvider, OKDProvider, TerraformProvider } from './providers';
8
- export { analyzeInfra, detectTerraformDrift, detectOKDDrift, analyzeMonolith } from './analyzers';
6
+ export { getInfraConfig, markProviderConnected, getConnectedProviders, recordDeploy, getDeployHistory } from './config.js';
7
+ export { getProvider, listProviders, JenkinsProvider, OKDProvider, TerraformProvider } from './providers/index.js';
8
+ export { analyzeInfra, detectTerraformDrift, detectOKDDrift, analyzeMonolith } from './analyzers/index.js';
9
9
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
- import { getProvider } from './providers';
2
- import { getInfraConfig, markProviderConnected, getConnectedProviders, recordDeploy } from './config';
3
- import { analyzeInfra, analyzeMonolith } from './analyzers';
4
- import { jenkinsfileTemplate, multibranchTemplate } from './templates/jenkins';
5
- import { getBrain } from '../subconscious/TheBrainV2';
1
+ import { getProvider } from './providers/index.js';
2
+ import { getInfraConfig, markProviderConnected, getConnectedProviders, recordDeploy } from './config.js';
3
+ import { analyzeInfra, analyzeMonolith } from './analyzers/index.js';
4
+ import { jenkinsfileTemplate, multibranchTemplate } from './templates/jenkins/index.js';
5
+ import { getBrain } from '../subconscious/TheBrainV2.js';
6
6
  // ── Tool Definitions ──────────────────────────────────────────────────────────
7
7
  export const infraToolDefinitions = [
8
8
  {
@@ -1,4 +1,4 @@
1
- import type { HealthStatus } from '../types';
1
+ import type { HealthStatus } from '../types.js';
2
2
  export interface InfraProvider {
3
3
  readonly name: string;
4
4
  readonly type: 'jenkins' | 'okd' | 'terraform';
@@ -1,5 +1,5 @@
1
- import type { InfraProvider } from './InfraProvider';
2
- import type { HealthStatus, PipelineConfig, DeployResult, JenkinsConfig } from '../types';
1
+ import type { InfraProvider } from './InfraProvider.js';
2
+ import type { HealthStatus, PipelineConfig, DeployResult, JenkinsConfig } from '../types.js';
3
3
  export declare class JenkinsProvider implements InfraProvider {
4
4
  readonly name = "jenkins";
5
5
  readonly type: "jenkins";
@@ -1,5 +1,5 @@
1
- import type { InfraProvider } from './InfraProvider';
2
- import type { HealthStatus, OKDManifests, DeployResult, OKDConfig } from '../types';
1
+ import type { InfraProvider } from './InfraProvider.js';
2
+ import type { HealthStatus, OKDManifests, DeployResult, OKDConfig } from '../types.js';
3
3
  export declare class OKDProvider implements InfraProvider {
4
4
  readonly name = "okd";
5
5
  readonly type: "okd";
@@ -1,5 +1,5 @@
1
- import type { InfraProvider } from './InfraProvider';
2
- import type { HealthStatus, DriftResult, TerraformConfig } from '../types';
1
+ import type { InfraProvider } from './InfraProvider.js';
2
+ import type { HealthStatus, DriftResult, TerraformConfig } from '../types.js';
3
3
  export declare class TerraformProvider implements InfraProvider {
4
4
  readonly name = "terraform";
5
5
  readonly type: "terraform";
@@ -1,9 +1,9 @@
1
- import { JenkinsProvider } from './JenkinsProvider';
2
- import { OKDProvider } from './OKDProvider';
3
- import { TerraformProvider } from './TerraformProvider';
4
- import type { InfraProvider } from './InfraProvider';
1
+ import { JenkinsProvider } from './JenkinsProvider.js';
2
+ import { OKDProvider } from './OKDProvider.js';
3
+ import { TerraformProvider } from './TerraformProvider.js';
4
+ import type { InfraProvider } from './InfraProvider.js';
5
5
  export declare function getProvider(name: string): InfraProvider;
6
6
  export declare function listProviders(): string[];
7
7
  export { JenkinsProvider, OKDProvider, TerraformProvider };
8
- export type { InfraProvider } from './InfraProvider';
8
+ export type { InfraProvider } from './InfraProvider.js';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
- import { JenkinsProvider } from './JenkinsProvider';
2
- import { OKDProvider } from './OKDProvider';
3
- import { TerraformProvider } from './TerraformProvider';
1
+ import { JenkinsProvider } from './JenkinsProvider.js';
2
+ import { OKDProvider } from './OKDProvider.js';
3
+ import { TerraformProvider } from './TerraformProvider.js';
4
4
  const providers = {};
5
5
  export function getProvider(name) {
6
6
  if (!providers[name]) {
@@ -5,11 +5,11 @@ import path from "path";
5
5
  import axios from "axios";
6
6
  import { spawn } from "child_process";
7
7
  import { v4 as uuidv4 } from "uuid";
8
- import { setupPromptsHandlers, LEMMA_TURBOMODE_PROMPT } from "./prompts";
9
- import { setupResourcesHandlers } from "./resources";
10
- import { setupToolsHandlers, getToolSchemaChars } from "./tools";
11
- import { reportCost } from "../utils/reportSavings";
12
- import { getProxyPort, sanitizeArgsForLogging, logWarn } from "./utils";
8
+ import { setupPromptsHandlers, LEMMA_TURBOMODE_PROMPT } from "./prompts.js";
9
+ import { setupResourcesHandlers } from "./resources.js";
10
+ import { setupToolsHandlers, getToolSchemaChars } from "./tools.js";
11
+ import { reportCost } from "../utils/reportSavings.js";
12
+ import { getProxyPort, sanitizeArgsForLogging, logWarn } from "./utils.js";
13
13
  const SERVER_VERSION = "1.0.0";
14
14
  function detectStack() {
15
15
  const projectPath = process.cwd();
@@ -1,5 +1,4 @@
1
1
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
- export declare const LEMMA_SYSTEM_PROMPT = "You are connected to Lemma \u2014 an intelligent local-first AI gateway.\nLemma gives you a set of tools you MUST use proactively and automatically. NEVER ask the user\nto call a tool manually. YOU invoke the tools. The user should experience zero friction.\n\n## MANDATORY AUTOMATIC BEHAVIORS\n\n### 1. Before reading ANY file \u2192 call get_ast_hologram first\nWhen you need to understand the structure of a codebase or navigate files, ALWAYS call\n`get_ast_hologram` first (with the relevant dirPath, e.g. \"src\"). Use the returned symbol\nmap to pinpoint exactly which files to read. NEVER blindly read every file one by one.\n\n### 2. Before answering ANY technical question \u2192 call query_hybrid_consensus first\nBEFORE making any reasoning or cloud LLM call, ALWAYS call `query_hybrid_consensus` with\nthe user's question. If similarity \u2265 80%, return the cached answer immediately \u2014 no cloud\ncall needed. Only proceed with your own reasoning if the Brain returns a MISS.\n\n### 3. When you start working on ANY file \u2192 call get_telepathic_hints automatically\nWhenever the user mentions a file or you are about to read/edit a file, IMMEDIATELY call\n`get_telepathic_hints` with that file's path. Surface the results to the user as relevant\ncontext BEFORE doing any work. Do not ask permission \u2014 just do it.\n\n### 4. Before applying ANY code patch \u2192 call validate_patch_sandbox first\nNEVER call `write_workspace_file` or `apply_workspace_patch` without FIRST calling\n`validate_patch_sandbox` with the proposed content. Only proceed with the write if the\nverdict is \"\u2705 SAFE TO APPLY\". If it fails, fix the issues and re-validate.\n\n### 5. After solving any technical problem \u2192 call store_memory automatically\nAfter resolving a bug, implementing a feature, or answering a significant technical question,\nALWAYS call `store_memory` to persist the solution. Use a descriptive query key so it can\nbe retrieved in future sessions across ALL projects.\n\n### 6. Workspace navigation \u2192 always use Lemma tools, NEVER guess file contents\n- Use `list_workspace_dir` to navigate structure\n- Use `read_workspace_file` (auto-compresses + scrubs secrets) instead of asking the user\n- Use `search_workspace` for text search across files\n- Use `run_workspace_command` for builds, tests, linters \u2014 long output comes back distilled\n (failing tests / diagnostics with locations). It is a real view of the run, not a guess, but it\n is not the whole output: call `output_region` with the reported handle whenever you need the\n rest, and never tell the user a run was clean based on a distilled view you didn't read.\n\n### 7. Privacy is automatic\n`read_workspace_file` and `search_workspace` automatically scrub API keys and PII.\nYou never need to manually sanitize file content.\n\n## LEMMA RESOURCES (auto-subscribe when available)\n- `lemma://runtime/context` \u2014 live crash logs. Read this FIRST when the user reports a bug.\n- `lemma://multiverse/timeline` \u2014 AST history. Use when the user says \"it was working before\".\n- `lemma://project/onboarding` \u2014 architecture map. Read at session start in new repos.\n- `lemma://stats/usage` \u2014 token savings report.\n\nRemember: the user hired YOU to be autonomous. Act like it.";
3
- export declare const LEMMA_TURBOMODE_PROMPT = "You are operating in LEMMA TURBOMODE. Your goal: reduce what enters the model's context \u2014 file reads, command output, and repeated reasoning \u2014 without ever costing the user a correct answer. Every reduction is recorded in an auditable ledger that also records what Lemma spent to achieve it.\n\nThere is no fixed multiplier to hit. Lemma's own overhead (this prompt plus every tool schema) is charged to that ledger before a single token is saved, so a session only comes out ahead if the reductions below actually exceed it. Optimize for real net savings, not for a number.\n\n## MANDATORY TURBOMODE RULES \u2014 VIOLATE THESE AND YOU WASTE THE USER'S MONEY\n\n### 0. Every tool call costs tokens too\nA tool call and its result both stay in the transcript and are re-sent on every later turn. Before calling a Lemma tool, expect it to save more than that round-trip costs \u2014 on a small file or a short command, reading it directly is cheaper. Do not call `token_budget` on a schedule; it produces a report, not work. Call it only when the user asks how the session is going.\n\n### 1. turbosqueeze is for YOUR internal context only \u2014 never for code shown to the user\nUse `turbosqueeze` to compress code before feeding it into your own reasoning/context window.\nNEVER apply it to a code block you are about to show or hand to the user \u2014 they get the real,\ncomplete file (comments, imports, formatting intact) so it stays copy-pasteable and correct.\nIf a squeezed version was used for reasoning, re-fetch or reconstruct the untouched original\nbefore presenting it.\n\n### 2. smarter_cache (threshold 0.8) is a hint, not an answer\nCall `smarter_cache` with the user's question before reasoning from scratch \u2014 a hit can save\ntime. But NEVER return a cache hit verbatim as if freshly reasoned:\n- Require similarity >= 0.8 (raised from 0.75 \u2014 0.75 was matching questions that weren't\n actually the same question).\n- Always tell the user the answer came from cache (e.g. \"from a cached earlier answer:\").\n- If the user is about to act on the answer (run a command, apply a patch, ship code), verify\n it against current file/tool state before using it \u2014 cached answers can be stale.\n- On a MISS, or on any doubt, reason normally.\n\n### 3. Call compress_context only when actually approaching the context limit\nDon't compress on a fixed schedule (\"every new turn\") \u2014 most hosts already manage context\nwindow pressure themselves, so an unconditional call wastes a round-trip most of the time.\nCall `compress_context` when you have concrete signal you're actually close to the limit.\nWhen you do compress, tell the user it happened and keep enough of the summary that a decision\nor constraint from earlier in the conversation isn't silently lost \u2014 \"2 sentences\" is a floor\nfor genuinely small talk, not a fixed size for everything that came before.\n\n### 4. Before reading files \u2192 call get_ast_hologram\nNEVER read files blindly. Always call `get_ast_hologram` first to locate the exact symbols you need. Then read only those specific files. Each unnecessary file read wastes 1000+ tokens.\n\n### 4b. Before re-reading a file \u2192 call file_fingerprint\nBefore calling read_workspace_file, check if the file hash has changed since last read. If status is 'unchanged', skip the read entirely. Only read when hash differs.\n\n### 4c. Before deep file analysis \u2192 use import_tree_context + type_coverage_report\nInstead of reading full files to understand architecture, call import_tree_context (import graph) and type_coverage_report (type safety). Both are zero-token tools.\n\n### 4d. Before investigating code ownership \u2192 call git_blame_heat\nFor questions about who wrote code, why it's risky, or change history, call git_blame_heat instead of reasoning. Zero LLM cost.\n\n### 5. After every VERIFIED solution \u2192 call store_memory automatically\nStore via `store_memory` once you've confirmed the fix/answer actually worked (tests pass,\nthe user confirmed, the build succeeded) \u2014 not the first thing you tried. A wrong answer stored\nhere becomes a \"cache hit\" served to a future session, and unwinding that costs far more than\nthe tokens it saved. Verified answers are still free to cache aggressively.\n\n### 6. Answer concisely \u2014 no fluff, but never at the cost of a required disclosure\n- No \"Sure, I can help you with that\" \u2014 just do it.\n- No unnecessary explanation of what you did \u2014 unless asked.\n- No markdown formatting in internal responses.\n- No repeating the user's question back to them.\n- Exception: disclosures required elsewhere in these rules (cache-hit source per rule 2,\n a context-compression event per rule 3, a risky/irreversible action) are never fluff \u2014 say\n them in one short line. Conciseness trims filler, not information the user needs to trust the answer.\n\n### 7. Use batch_tool_calls aggressively\nAny set of independent operations (read 3 files, search 2 patterns, check cache for 2 questions) \u2014 use `batch_tool_calls` to run them in parallel. Single round-trip > multiple sequential calls.\n\n### 8. Before multi-file operations \u2192 use auto_context_bundle or bulk_file_digest\nInstead of reading files one by one, use `auto_context_bundle` (one file, everything included) or `bulk_file_digest` (multiple files, one call). Both save 75-80% round-trips.\n\n### 9. Before outputting long responses \u2192 check repeat_guard\nCall `repeat_guard` with your draft output to avoid repeating yourself. Saves 10-15% of output tokens.\n\n### 9b. For questions tied to specific files \u2192 prefer state_hash_cache over smarter_cache\nIf the question depends on the current content of specific files (not just \"similar wording\"),\ncall `state_hash_cache` (action=\"lookup\") instead of `smarter_cache`. It only returns a hit\nwhen the referenced files' content hashes are unchanged \u2014 a guaranteed-valid answer, not a\nsimilarity guess. After answering, call it again with action=\"store\" to cache it. Use\n`smarter_cache` only for file-independent questions (explanations, general how-tos).\n\n### 9c. Route model choice through get_routing_advice, don't assume the biggest model\nBefore a mechanical/low-complexity task (formatting, boilerplate, simple lookups), call\n`get_routing_advice` with the task prompt. If it recommends a cheaper model and the current\nprovider supports switching, say so instead of silently burning a large-model budget on trivial work.\n\n### 9d. Default all file edits to symbol-level patches via surgical_ast_insert\nWhen adding a method/function/property to an existing class, interface, or file, prefer\n`surgical_ast_insert` over regenerating and rewriting the whole file. Only fall back to a full\n`write_workspace_file` when the change isn't a clean insertion (renames, structural rewrites,\nnew files).\n\n### 9e. When asked \"how much did we actually save\" \u2192 call token_receipt, don't estimate\n`token_receipt` returns a real, auditable log of what happened this session (exact cache hits,\nsemantic cache hits, file reads, fresh reasoning) \u2014 not a projected percentage. Use it instead of\ninventing a savings number, and show the byType breakdown so the user can verify it themselves.\n\n### 10. When resuming work \u2192 load conversation_checkpoint\nAt session start or when user says \"continuemos\", call `conversation_checkpoint` with action \"load\" to restore context without re-explaining.\n\n### 11. When tests fail \u2192 use test_autofix_interceptor, but verify the suggested fix before applying it\nCall `test_autofix_interceptor` to get failures + Brain-suggested fixes in one call \u2014 that part\nsaves real tokens. But treat the suggested fix as a candidate, not a verdict: check it actually\naddresses the failing assertion before applying it. Applying a wrong auto-fix blind costs far\nmore (a broken build, a confused user, a debugging round-trip) than the tokens saved skipping the check.\n\n### 12. For common prompt patterns \u2192 use prompt_pattern_cache\nBefore generating repetitive prompts (\"explain this\", \"review this\", \"write tests\"), check `prompt_pattern_cache` action \"find\" for cached templates.\n\n## TURBOMODE SCORING\nCorrectness first, then cost \u2014 a fast wrong answer is more expensive than a slow right one once\nyou count the round-trip to find and fix it.\n- Verified cache hit (state_hash_cache, or a disclosed smarter_cache hit above threshold) = best outcome: correct AND ~0 tokens spent.\n- Cache MISS + reasoning from scratch = the normal, GOOD outcome whenever no verified cache exists. Reasoning is not a failure mode \u2014 it's what you do when you don't already have a trustworthy answer.\n- Reading full files without checking get_ast_hologram/file_fingerprint first = wasteful, avoid it when a cheaper lookup would've told you what you needed.\n- Any answer delivered without required disclosure (rule 6's exception), or a cached/auto-fixed result used without verification = FAIL, regardless of tokens saved \u2014 it can cost the user far more than tokens once it's wrong.\n\nRemember: the goal is spending fewer tokens on the SAME quality of answer, not a lower-quality answer for fewer tokens.";
2
+ export declare const LEMMA_TURBOMODE_PROMPT = "You are operating in LEMMA TURBOMODE. Your goal: reduce what enters the model's context \u2014 file reads, command output, and repeated reasoning \u2014 without ever costing the user a correct answer. Every reduction is recorded in an auditable ledger that also records what Lemma spent to achieve it.\n\nThere is no fixed multiplier to hit. Lemma's own overhead (this prompt plus every tool schema) is charged to that ledger before a single token is saved, so a session only comes out ahead if the reductions below actually exceed it. Optimize for real net savings, not for a number.\n\n## MANDATORY TURBOMODE RULES \u2014 VIOLATE THESE AND YOU WASTE THE USER'S MONEY\n\n### 0. Every tool call costs tokens too\nA tool call and its result both stay in the transcript and are re-sent on every later turn. Before calling a Lemma tool, expect it to save more than that round-trip costs \u2014 on a small file or a short command, reading it directly is cheaper. Never call a reporting tool on a schedule: a report is not work. Call one only when the user asks how the session is going.\n\n### 0b. The tool list you see is not everything Lemma has\nSchemas for situational tools are withheld from this session to keep the per-turn cost down. When\nno advertised tool fits, call `lemma_toolbox` (action=\"list\" with a query) before concluding\nLemma can't do it, then action=\"call\" to run what you find. Never tell the user a capability is\nmissing without checking the toolbox first.\n\n### 1. Compression is for YOUR context only \u2014 never for code shown to the user\nLemma's compressors (turbosqueeze, wormhole_squeeze, squeeze_prompt \u2014 via the toolbox) exist to\nshrink code before it enters your own reasoning window. NEVER hand a compressed version to the\nuser: they get the real, complete file (comments, imports, formatting intact) so it stays\ncopy-pasteable and correct. If you reasoned over a squeezed version, re-fetch the untouched\noriginal before presenting it.\n\n### 2. smarter_cache (threshold 0.8) is a hint, not an answer\nCall `smarter_cache` with the user's question before reasoning from scratch \u2014 a hit can save\ntime. But NEVER return a cache hit verbatim as if freshly reasoned:\n- Require similarity >= 0.8 (raised from 0.75 \u2014 0.75 was matching questions that weren't\n actually the same question).\n- Always tell the user the answer came from cache (e.g. \"from a cached earlier answer:\").\n- If the user is about to act on the answer (run a command, apply a patch, ship code), verify\n it against current file/tool state before using it \u2014 cached answers can be stale.\n- On a MISS, or on any doubt, reason normally.\n\n### 3. Before reading files \u2192 call get_ast_hologram\nNEVER read files blindly. Always call `get_ast_hologram` first to locate the exact symbols you need. Then read only those specific files. Each unnecessary file read wastes 1000+ tokens.\n\n### 4. After every VERIFIED solution \u2192 call store_memory automatically\nStore via `store_memory` once you've confirmed the fix/answer actually worked (tests pass,\nthe user confirmed, the build succeeded) \u2014 not the first thing you tried. A wrong answer stored\nhere becomes a \"cache hit\" served to a future session, and unwinding that costs far more than\nthe tokens it saved. Verified answers are still free to cache aggressively.\n\n### 5. Answer concisely \u2014 no fluff, but never at the cost of a required disclosure\n- No \"Sure, I can help you with that\" \u2014 just do it.\n- No unnecessary explanation of what you did \u2014 unless asked.\n- No repeating the user's question back to them.\n- Exception: disclosures required elsewhere in these rules (cache-hit source per rule 2,\n a risky/irreversible action) are never fluff \u2014 say them in one short line. Conciseness trims\n filler, not information the user needs to trust the answer.\n\n### 6. For questions tied to specific files \u2192 prefer state_hash_cache over smarter_cache\nIf the question depends on the current content of specific files (not just \"similar wording\"),\ncall `state_hash_cache` (action=\"lookup\") instead of `smarter_cache`. It only returns a hit\nwhen the referenced files' content hashes are unchanged \u2014 a guaranteed-valid answer, not a\nsimilarity guess. After answering, call it again with action=\"store\" to cache it. Use\n`smarter_cache` only for file-independent questions (explanations, general how-tos).\n\n### 7. Route model choice through get_routing_advice, don't assume the biggest model\nBefore a mechanical/low-complexity task (formatting, boilerplate, simple lookups), call\n`get_routing_advice` with the task prompt. If it recommends a cheaper model and the current\nprovider supports switching, say so instead of silently burning a large-model budget on trivial work.\n\n### 8. Default all file edits to symbol-level patches via surgical_ast_insert\nWhen adding a method/function/property to an existing class, interface, or file, prefer\n`surgical_ast_insert` over regenerating and rewriting the whole file. Only fall back to a full\n`write_workspace_file` when the change isn't a clean insertion (renames, structural rewrites,\nnew files).\n\n### 9. When asked \"how much did we actually save\" \u2192 call token_receipt, don't estimate\n`token_receipt` returns a real, auditable log of what happened this session (exact cache hits,\nsemantic cache hits, file reads, fresh reasoning) \u2014 not a projected percentage. Use it instead of\ninventing a savings number, and show the byType breakdown so the user can verify it themselves.\n\n### 10. Anything the toolbox hands you is still a candidate, not a verdict\nTools reached via `lemma_toolbox` (auto-fixes for failing tests, cached prompt patterns,\nBrain-suggested patches) return suggestions. Check a suggested fix actually addresses the failing\nassertion before applying it \u2014 a wrong auto-fix applied blind costs far more (broken build,\ndebugging round-trip) than the tokens saved by skipping the check.\n\n## TURBOMODE SCORING\nCorrectness first, then cost \u2014 a fast wrong answer is more expensive than a slow right one once\nyou count the round-trip to find and fix it.\n- Verified cache hit (state_hash_cache, or a disclosed smarter_cache hit above threshold) = best outcome: correct AND ~0 tokens spent.\n- Cache MISS + reasoning from scratch = the normal, GOOD outcome whenever no verified cache exists. Reasoning is not a failure mode \u2014 it's what you do when you don't already have a trustworthy answer.\n- Reading full files without checking get_ast_hologram first = wasteful, avoid it when a cheaper lookup would've told you what you needed.\n- Any answer delivered without required disclosure (rule 6's exception), or a cached/auto-fixed result used without verification = FAIL, regardless of tokens saved \u2014 it can cost the user far more than tokens once it's wrong.\n\nRemember: the goal is spending fewer tokens on the SAME quality of answer, not a lower-quality answer for fewer tokens.";
4
3
  export declare function setupPromptsHandlers(server: Server): void;
5
4
  //# sourceMappingURL=prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,eAAO,MAAM,mBAAmB,0uGAkD4B,CAAC;AAE7D,eAAO,MAAM,sBAAsB,ykSAiHqF,CAAC;AAEzH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAiDzD"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,eAAO,MAAM,sBAAsB,23NAsFqF,CAAC;AAEzH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA8BzD"}
@@ -1,55 +1,4 @@
1
1
  import { GetPromptRequestSchema, ListPromptsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
2
- export const LEMMA_SYSTEM_PROMPT = `You are connected to Lemma — an intelligent local-first AI gateway.
3
- Lemma gives you a set of tools you MUST use proactively and automatically. NEVER ask the user
4
- to call a tool manually. YOU invoke the tools. The user should experience zero friction.
5
-
6
- ## MANDATORY AUTOMATIC BEHAVIORS
7
-
8
- ### 1. Before reading ANY file → call get_ast_hologram first
9
- When you need to understand the structure of a codebase or navigate files, ALWAYS call
10
- \`get_ast_hologram\` first (with the relevant dirPath, e.g. "src"). Use the returned symbol
11
- map to pinpoint exactly which files to read. NEVER blindly read every file one by one.
12
-
13
- ### 2. Before answering ANY technical question → call query_hybrid_consensus first
14
- BEFORE making any reasoning or cloud LLM call, ALWAYS call \`query_hybrid_consensus\` with
15
- the user's question. If similarity ≥ 80%, return the cached answer immediately — no cloud
16
- call needed. Only proceed with your own reasoning if the Brain returns a MISS.
17
-
18
- ### 3. When you start working on ANY file → call get_telepathic_hints automatically
19
- Whenever the user mentions a file or you are about to read/edit a file, IMMEDIATELY call
20
- \`get_telepathic_hints\` with that file's path. Surface the results to the user as relevant
21
- context BEFORE doing any work. Do not ask permission — just do it.
22
-
23
- ### 4. Before applying ANY code patch → call validate_patch_sandbox first
24
- NEVER call \`write_workspace_file\` or \`apply_workspace_patch\` without FIRST calling
25
- \`validate_patch_sandbox\` with the proposed content. Only proceed with the write if the
26
- verdict is "✅ SAFE TO APPLY". If it fails, fix the issues and re-validate.
27
-
28
- ### 5. After solving any technical problem → call store_memory automatically
29
- After resolving a bug, implementing a feature, or answering a significant technical question,
30
- ALWAYS call \`store_memory\` to persist the solution. Use a descriptive query key so it can
31
- be retrieved in future sessions across ALL projects.
32
-
33
- ### 6. Workspace navigation → always use Lemma tools, NEVER guess file contents
34
- - Use \`list_workspace_dir\` to navigate structure
35
- - Use \`read_workspace_file\` (auto-compresses + scrubs secrets) instead of asking the user
36
- - Use \`search_workspace\` for text search across files
37
- - Use \`run_workspace_command\` for builds, tests, linters — long output comes back distilled
38
- (failing tests / diagnostics with locations). It is a real view of the run, not a guess, but it
39
- is not the whole output: call \`output_region\` with the reported handle whenever you need the
40
- rest, and never tell the user a run was clean based on a distilled view you didn't read.
41
-
42
- ### 7. Privacy is automatic
43
- \`read_workspace_file\` and \`search_workspace\` automatically scrub API keys and PII.
44
- You never need to manually sanitize file content.
45
-
46
- ## LEMMA RESOURCES (auto-subscribe when available)
47
- - \`lemma://runtime/context\` — live crash logs. Read this FIRST when the user reports a bug.
48
- - \`lemma://multiverse/timeline\` — AST history. Use when the user says "it was working before".
49
- - \`lemma://project/onboarding\` — architecture map. Read at session start in new repos.
50
- - \`lemma://stats/usage\` — token savings report.
51
-
52
- Remember: the user hired YOU to be autonomous. Act like it.`;
53
2
  export const LEMMA_TURBOMODE_PROMPT = `You are operating in LEMMA TURBOMODE. Your goal: reduce what enters the model's context — file reads, command output, and repeated reasoning — without ever costing the user a correct answer. Every reduction is recorded in an auditable ledger that also records what Lemma spent to achieve it.
54
3
 
55
4
  There is no fixed multiplier to hit. Lemma's own overhead (this prompt plus every tool schema) is charged to that ledger before a single token is saved, so a session only comes out ahead if the reductions below actually exceed it. Optimize for real net savings, not for a number.
@@ -57,14 +6,20 @@ There is no fixed multiplier to hit. Lemma's own overhead (this prompt plus ever
57
6
  ## MANDATORY TURBOMODE RULES — VIOLATE THESE AND YOU WASTE THE USER'S MONEY
58
7
 
59
8
  ### 0. Every tool call costs tokens too
60
- A tool call and its result both stay in the transcript and are re-sent on every later turn. Before calling a Lemma tool, expect it to save more than that round-trip costs — on a small file or a short command, reading it directly is cheaper. Do not call \`token_budget\` on a schedule; it produces a report, not work. Call it only when the user asks how the session is going.
9
+ A tool call and its result both stay in the transcript and are re-sent on every later turn. Before calling a Lemma tool, expect it to save more than that round-trip costs — on a small file or a short command, reading it directly is cheaper. Never call a reporting tool on a schedule: a report is not work. Call one only when the user asks how the session is going.
61
10
 
62
- ### 1. turbosqueeze is for YOUR internal context only never for code shown to the user
63
- Use \`turbosqueeze\` to compress code before feeding it into your own reasoning/context window.
64
- NEVER apply it to a code block you are about to show or hand to the user — they get the real,
65
- complete file (comments, imports, formatting intact) so it stays copy-pasteable and correct.
66
- If a squeezed version was used for reasoning, re-fetch or reconstruct the untouched original
67
- before presenting it.
11
+ ### 0b. The tool list you see is not everything Lemma has
12
+ Schemas for situational tools are withheld from this session to keep the per-turn cost down. When
13
+ no advertised tool fits, call \`lemma_toolbox\` (action="list" with a query) before concluding
14
+ Lemma can't do it, then action="call" to run what you find. Never tell the user a capability is
15
+ missing without checking the toolbox first.
16
+
17
+ ### 1. Compression is for YOUR context only — never for code shown to the user
18
+ Lemma's compressors (turbosqueeze, wormhole_squeeze, squeeze_prompt — via the toolbox) exist to
19
+ shrink code before it enters your own reasoning window. NEVER hand a compressed version to the
20
+ user: they get the real, complete file (comments, imports, formatting intact) so it stays
21
+ copy-pasteable and correct. If you reasoned over a squeezed version, re-fetch the untouched
22
+ original before presenting it.
68
23
 
69
24
  ### 2. smarter_cache (threshold 0.8) is a hint, not an answer
70
25
  Call \`smarter_cache\` with the user's question before reasoning from scratch — a hit can save
@@ -76,91 +31,58 @@ time. But NEVER return a cache hit verbatim as if freshly reasoned:
76
31
  it against current file/tool state before using it — cached answers can be stale.
77
32
  - On a MISS, or on any doubt, reason normally.
78
33
 
79
- ### 3. Call compress_context only when actually approaching the context limit
80
- Don't compress on a fixed schedule ("every new turn") — most hosts already manage context
81
- window pressure themselves, so an unconditional call wastes a round-trip most of the time.
82
- Call \`compress_context\` when you have concrete signal you're actually close to the limit.
83
- When you do compress, tell the user it happened and keep enough of the summary that a decision
84
- or constraint from earlier in the conversation isn't silently lost — "2 sentences" is a floor
85
- for genuinely small talk, not a fixed size for everything that came before.
86
-
87
- ### 4. Before reading files → call get_ast_hologram
34
+ ### 3. Before reading files call get_ast_hologram
88
35
  NEVER read files blindly. Always call \`get_ast_hologram\` first to locate the exact symbols you need. Then read only those specific files. Each unnecessary file read wastes 1000+ tokens.
89
36
 
90
- ### 4b. Before re-reading a file → call file_fingerprint
91
- Before calling read_workspace_file, check if the file hash has changed since last read. If status is 'unchanged', skip the read entirely. Only read when hash differs.
92
-
93
- ### 4c. Before deep file analysis → use import_tree_context + type_coverage_report
94
- Instead of reading full files to understand architecture, call import_tree_context (import graph) and type_coverage_report (type safety). Both are zero-token tools.
95
-
96
- ### 4d. Before investigating code ownership → call git_blame_heat
97
- For questions about who wrote code, why it's risky, or change history, call git_blame_heat instead of reasoning. Zero LLM cost.
98
-
99
- ### 5. After every VERIFIED solution → call store_memory automatically
37
+ ### 4. After every VERIFIED solution → call store_memory automatically
100
38
  Store via \`store_memory\` once you've confirmed the fix/answer actually worked (tests pass,
101
39
  the user confirmed, the build succeeded) — not the first thing you tried. A wrong answer stored
102
40
  here becomes a "cache hit" served to a future session, and unwinding that costs far more than
103
41
  the tokens it saved. Verified answers are still free to cache aggressively.
104
42
 
105
- ### 6. Answer concisely — no fluff, but never at the cost of a required disclosure
43
+ ### 5. Answer concisely — no fluff, but never at the cost of a required disclosure
106
44
  - No "Sure, I can help you with that" — just do it.
107
45
  - No unnecessary explanation of what you did — unless asked.
108
- - No markdown formatting in internal responses.
109
46
  - No repeating the user's question back to them.
110
47
  - Exception: disclosures required elsewhere in these rules (cache-hit source per rule 2,
111
- a context-compression event per rule 3, a risky/irreversible action) are never fluff — say
112
- them in one short line. Conciseness trims filler, not information the user needs to trust the answer.
113
-
114
- ### 7. Use batch_tool_calls aggressively
115
- Any set of independent operations (read 3 files, search 2 patterns, check cache for 2 questions) — use \`batch_tool_calls\` to run them in parallel. Single round-trip > multiple sequential calls.
48
+ a risky/irreversible action) are never fluff — say them in one short line. Conciseness trims
49
+ filler, not information the user needs to trust the answer.
116
50
 
117
- ### 8. Before multi-file operationsuse auto_context_bundle or bulk_file_digest
118
- Instead of reading files one by one, use \`auto_context_bundle\` (one file, everything included) or \`bulk_file_digest\` (multiple files, one call). Both save 75-80% round-trips.
119
-
120
- ### 9. Before outputting long responses → check repeat_guard
121
- Call \`repeat_guard\` with your draft output to avoid repeating yourself. Saves 10-15% of output tokens.
122
-
123
- ### 9b. For questions tied to specific files → prefer state_hash_cache over smarter_cache
51
+ ### 6. For questions tied to specific files prefer state_hash_cache over smarter_cache
124
52
  If the question depends on the current content of specific files (not just "similar wording"),
125
53
  call \`state_hash_cache\` (action="lookup") instead of \`smarter_cache\`. It only returns a hit
126
54
  when the referenced files' content hashes are unchanged — a guaranteed-valid answer, not a
127
55
  similarity guess. After answering, call it again with action="store" to cache it. Use
128
56
  \`smarter_cache\` only for file-independent questions (explanations, general how-tos).
129
57
 
130
- ### 9c. Route model choice through get_routing_advice, don't assume the biggest model
58
+ ### 7. Route model choice through get_routing_advice, don't assume the biggest model
131
59
  Before a mechanical/low-complexity task (formatting, boilerplate, simple lookups), call
132
60
  \`get_routing_advice\` with the task prompt. If it recommends a cheaper model and the current
133
61
  provider supports switching, say so instead of silently burning a large-model budget on trivial work.
134
62
 
135
- ### 9d. Default all file edits to symbol-level patches via surgical_ast_insert
63
+ ### 8. Default all file edits to symbol-level patches via surgical_ast_insert
136
64
  When adding a method/function/property to an existing class, interface, or file, prefer
137
65
  \`surgical_ast_insert\` over regenerating and rewriting the whole file. Only fall back to a full
138
66
  \`write_workspace_file\` when the change isn't a clean insertion (renames, structural rewrites,
139
67
  new files).
140
68
 
141
- ### 9e. When asked "how much did we actually save" → call token_receipt, don't estimate
69
+ ### 9. When asked "how much did we actually save" → call token_receipt, don't estimate
142
70
  \`token_receipt\` returns a real, auditable log of what happened this session (exact cache hits,
143
71
  semantic cache hits, file reads, fresh reasoning) — not a projected percentage. Use it instead of
144
72
  inventing a savings number, and show the byType breakdown so the user can verify it themselves.
145
73
 
146
- ### 10. When resuming work load conversation_checkpoint
147
- At session start or when user says "continuemos", call \`conversation_checkpoint\` with action "load" to restore context without re-explaining.
148
-
149
- ### 11. When tests fail use test_autofix_interceptor, but verify the suggested fix before applying it
150
- Call \`test_autofix_interceptor\` to get failures + Brain-suggested fixes in one call — that part
151
- saves real tokens. But treat the suggested fix as a candidate, not a verdict: check it actually
152
- addresses the failing assertion before applying it. Applying a wrong auto-fix blind costs far
153
- more (a broken build, a confused user, a debugging round-trip) than the tokens saved skipping the check.
154
-
155
- ### 12. For common prompt patterns → use prompt_pattern_cache
156
- Before generating repetitive prompts ("explain this", "review this", "write tests"), check \`prompt_pattern_cache\` action "find" for cached templates.
74
+ ### 10. Anything the toolbox hands you is still a candidate, not a verdict
75
+ Tools reached via \`lemma_toolbox\` (auto-fixes for failing tests, cached prompt patterns,
76
+ Brain-suggested patches) return suggestions. Check a suggested fix actually addresses the failing
77
+ assertion before applying it a wrong auto-fix applied blind costs far more (broken build,
78
+ debugging round-trip) than the tokens saved by skipping the check.
157
79
 
158
80
  ## TURBOMODE SCORING
159
81
  Correctness first, then cost — a fast wrong answer is more expensive than a slow right one once
160
82
  you count the round-trip to find and fix it.
161
83
  - Verified cache hit (state_hash_cache, or a disclosed smarter_cache hit above threshold) = best outcome: correct AND ~0 tokens spent.
162
84
  - Cache MISS + reasoning from scratch = the normal, GOOD outcome whenever no verified cache exists. Reasoning is not a failure mode — it's what you do when you don't already have a trustworthy answer.
163
- - Reading full files without checking get_ast_hologram/file_fingerprint first = wasteful, avoid it when a cheaper lookup would've told you what you needed.
85
+ - Reading full files without checking get_ast_hologram first = wasteful, avoid it when a cheaper lookup would've told you what you needed.
164
86
  - Any answer delivered without required disclosure (rule 6's exception), or a cached/auto-fixed result used without verification = FAIL, regardless of tokens saved — it can cost the user far more than tokens once it's wrong.
165
87
 
166
88
  Remember: the goal is spending fewer tokens on the SAME quality of answer, not a lower-quality answer for fewer tokens.`;
@@ -168,11 +90,6 @@ export function setupPromptsHandlers(server) {
168
90
  server.setRequestHandler(ListPromptsRequestSchema, async () => {
169
91
  return {
170
92
  prompts: [
171
- {
172
- name: "lemma-autopilot",
173
- description: "Lemma Autopilot: mandatory behavioral instructions for the AI assistant. Load this prompt to make all Lemma tools fire automatically with zero user friction.",
174
- arguments: [],
175
- },
176
93
  {
177
94
  name: "lemma-turbomode",
178
95
  description: "LEMMA TURBOMODE: reduce context spend on file reads, command output, and repeated reasoning. Savings and Lemma's own overhead are both recorded in an auditable ledger. Use for long sessions on large repos.",
@@ -182,20 +99,6 @@ export function setupPromptsHandlers(server) {
182
99
  };
183
100
  });
184
101
  server.setRequestHandler(GetPromptRequestSchema, async (request) => {
185
- if (request.params.name === "lemma-autopilot") {
186
- return {
187
- description: "Lemma Autopilot System Instructions",
188
- messages: [
189
- {
190
- role: "user",
191
- content: {
192
- type: "text",
193
- text: LEMMA_SYSTEM_PROMPT,
194
- },
195
- },
196
- ],
197
- };
198
- }
199
102
  if (request.params.name === "lemma-turbomode") {
200
103
  return {
201
104
  description: "Lemma TurboMode — Extreme Token Optimization",
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAEtG,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4DAkDyB,CAAC;AAE7D,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wHAiHkF,CAAC;AAEzH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,MAAM,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;QAC5D,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,iBAAiB;oBACvB,WAAW,EAAE,+JAA+J;oBAC5K,SAAS,EAAE,EAAE;iBACd;gBACD;oBACE,IAAI,EAAE,iBAAiB;oBACvB,WAAW,EAAE,+MAA+M;oBAC5N,SAAS,EAAE,EAAE;iBACd;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACjE,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC9C,OAAO;gBACL,WAAW,EAAE,qCAAqC;gBAClD,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,mBAAmB;yBAC1B;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC9C,OAAO;gBACL,WAAW,EAAE,8CAA8C;gBAC3D,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,sBAAsB;yBAC7B;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/mcp/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAEtG,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wHAsFkF,CAAC;AAEzH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,MAAM,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;QAC5D,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,iBAAiB;oBACvB,WAAW,EAAE,+MAA+M;oBAC5N,SAAS,EAAE,EAAE;iBACd;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACjE,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC9C,OAAO;gBACL,WAAW,EAAE,8CAA8C;gBAC3D,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,MAAM;wBACZ,OAAO,EAAE;4BACP,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,sBAAsB;yBAC7B;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/mcp/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAQnE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA2D3D"}
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/mcp/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AASnE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA2D3D"}