@nxuss/lemma 1.16.1 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/init.js +101 -11
- package/dist/cjs/cli/lemma-proxy.d.ts.map +1 -1
- package/dist/cjs/cli/lemma-proxy.js +19 -11
- package/dist/cjs/cli/lemma-proxy.js.map +1 -1
- package/dist/cjs/cloud/TenantCache.d.ts.map +1 -1
- package/dist/cjs/cloud/TenantCache.js +0 -4
- package/dist/cjs/cloud/TenantCache.js.map +1 -1
- package/dist/cjs/cloud/identity/ApiKey.d.ts +32 -0
- package/dist/cjs/cloud/identity/ApiKey.d.ts.map +1 -0
- package/dist/cjs/cloud/identity/ApiKey.js +59 -0
- package/dist/cjs/cloud/identity/ApiKey.js.map +1 -0
- package/dist/cjs/cloud/identity/PlanPolicy.d.ts +79 -0
- package/dist/cjs/cloud/identity/PlanPolicy.d.ts.map +1 -0
- package/dist/cjs/cloud/identity/PlanPolicy.js +135 -0
- package/dist/cjs/cloud/identity/PlanPolicy.js.map +1 -0
- package/dist/cjs/cloud/identity/RateLimiter.d.ts +49 -0
- package/dist/cjs/cloud/identity/RateLimiter.d.ts.map +1 -0
- package/dist/cjs/cloud/identity/RateLimiter.js +75 -0
- package/dist/cjs/cloud/identity/RateLimiter.js.map +1 -0
- package/dist/cjs/cloud/identity/TenantResolver.d.ts +19 -0
- package/dist/cjs/cloud/identity/TenantResolver.d.ts.map +1 -0
- package/dist/cjs/cloud/identity/TenantResolver.js +40 -0
- package/dist/cjs/cloud/identity/TenantResolver.js.map +1 -0
- package/dist/cjs/cloud/identity/authenticateV2.d.ts +48 -0
- package/dist/cjs/cloud/identity/authenticateV2.d.ts.map +1 -0
- package/dist/cjs/cloud/identity/authenticateV2.js +66 -0
- package/dist/cjs/cloud/identity/authenticateV2.js.map +1 -0
- package/dist/cjs/cloud/identity/identityStore.d.ts +56 -0
- package/dist/cjs/cloud/identity/identityStore.d.ts.map +1 -0
- package/dist/cjs/cloud/identity/identityStore.js +99 -0
- package/dist/cjs/cloud/identity/identityStore.js.map +1 -0
- package/dist/cjs/cloud/identity/index.d.ts +14 -0
- package/dist/cjs/cloud/identity/index.d.ts.map +1 -0
- package/dist/cjs/cloud/identity/index.js +30 -0
- package/dist/cjs/cloud/identity/index.js.map +1 -0
- package/dist/cjs/cloud/metering/TokenCounter.d.ts +26 -0
- package/dist/cjs/cloud/metering/TokenCounter.d.ts.map +1 -0
- package/dist/cjs/cloud/metering/TokenCounter.js +80 -0
- package/dist/cjs/cloud/metering/TokenCounter.js.map +1 -0
- package/dist/cjs/cloud/metering/UsageLedger.d.ts +68 -0
- package/dist/cjs/cloud/metering/UsageLedger.d.ts.map +1 -0
- package/dist/cjs/cloud/metering/UsageLedger.js +106 -0
- package/dist/cjs/cloud/metering/UsageLedger.js.map +1 -0
- package/dist/cjs/cloud/metering/index.d.ts +12 -0
- package/dist/cjs/cloud/metering/index.d.ts.map +1 -0
- package/dist/cjs/cloud/metering/index.js +28 -0
- package/dist/cjs/cloud/metering/index.js.map +1 -0
- package/dist/cjs/cloud/scrub/StatelessScrubber.d.ts +53 -0
- package/dist/cjs/cloud/scrub/StatelessScrubber.d.ts.map +1 -0
- package/dist/cjs/cloud/scrub/StatelessScrubber.js +203 -0
- package/dist/cjs/cloud/scrub/StatelessScrubber.js.map +1 -0
- package/dist/cjs/cloud/scrub/index.d.ts +5 -0
- package/dist/cjs/cloud/scrub/index.d.ts.map +1 -0
- package/dist/cjs/cloud/scrub/index.js +21 -0
- package/dist/cjs/cloud/scrub/index.js.map +1 -0
- package/dist/cjs/cloud/store/FileBrainStore.d.ts +26 -0
- package/dist/cjs/cloud/store/FileBrainStore.d.ts.map +1 -0
- package/dist/cjs/cloud/store/FileBrainStore.js +219 -0
- package/dist/cjs/cloud/store/FileBrainStore.js.map +1 -0
- package/dist/cjs/cloud/store/PostgresBrainStore.d.ts +50 -0
- package/dist/cjs/cloud/store/PostgresBrainStore.d.ts.map +1 -0
- package/dist/cjs/cloud/store/PostgresBrainStore.js +181 -0
- package/dist/cjs/cloud/store/PostgresBrainStore.js.map +1 -0
- package/dist/cjs/cloud/store/index.d.ts +6 -0
- package/dist/cjs/cloud/store/index.d.ts.map +1 -0
- package/dist/cjs/cloud/store/index.js +22 -0
- package/dist/cjs/cloud/store/index.js.map +1 -0
- package/dist/cjs/cloud/types.d.ts +0 -4
- package/dist/cjs/cloud/types.d.ts.map +1 -1
- package/dist/cjs/cloud/types.js +1 -3
- package/dist/cjs/cloud/types.js.map +1 -1
- package/dist/cjs/cloud/v2/app.d.ts +15 -0
- package/dist/cjs/cloud/v2/app.d.ts.map +1 -0
- package/dist/cjs/cloud/v2/app.js +63 -0
- package/dist/cjs/cloud/v2/app.js.map +1 -0
- package/dist/cjs/cloud/v2/routes/index.d.ts +24 -0
- package/dist/cjs/cloud/v2/routes/index.d.ts.map +1 -0
- package/dist/cjs/cloud/v2/routes/index.js +35 -0
- package/dist/cjs/cloud/v2/routes/index.js.map +1 -0
- package/dist/cjs/cloud/v2/routes/memories.d.ts +83 -0
- package/dist/cjs/cloud/v2/routes/memories.d.ts.map +1 -0
- package/dist/cjs/cloud/v2/routes/memories.js +249 -0
- package/dist/cjs/cloud/v2/routes/memories.js.map +1 -0
- package/dist/cjs/cloud/v2/routes/recall.d.ts +33 -0
- package/dist/cjs/cloud/v2/routes/recall.d.ts.map +1 -0
- package/dist/cjs/cloud/v2/routes/recall.js +51 -0
- package/dist/cjs/cloud/v2/routes/recall.js.map +1 -0
- package/dist/cjs/cloud/v2/routes/scrub.d.ts +13 -0
- package/dist/cjs/cloud/v2/routes/scrub.d.ts.map +1 -0
- package/dist/cjs/cloud/v2/routes/scrub.js +82 -0
- package/dist/cjs/cloud/v2/routes/scrub.js.map +1 -0
- package/dist/cjs/cloud/v2/routes/usage.d.ts +18 -0
- package/dist/cjs/cloud/v2/routes/usage.d.ts.map +1 -0
- package/dist/cjs/cloud/v2/routes/usage.js +18 -0
- package/dist/cjs/cloud/v2/routes/usage.js.map +1 -0
- package/dist/cjs/cloud/v2/routes/verify.d.ts +35 -0
- package/dist/cjs/cloud/v2/routes/verify.d.ts.map +1 -0
- package/dist/cjs/cloud/v2/routes/verify.js +43 -0
- package/dist/cjs/cloud/v2/routes/verify.js.map +1 -0
- package/dist/cjs/cloud/v2/server.d.ts +27 -0
- package/dist/cjs/cloud/v2/server.d.ts.map +1 -0
- package/dist/cjs/cloud/v2/server.js +47 -0
- package/dist/cjs/cloud/v2/server.js.map +1 -0
- package/dist/cjs/contracts/api-v2.types.d.ts +103 -0
- package/dist/cjs/contracts/api-v2.types.d.ts.map +1 -0
- package/dist/cjs/contracts/api-v2.types.js +3 -0
- package/dist/cjs/contracts/api-v2.types.js.map +1 -0
- package/dist/cjs/contracts/errors.d.ts +40 -0
- package/dist/cjs/contracts/errors.d.ts.map +1 -0
- package/dist/cjs/contracts/errors.js +50 -0
- package/dist/cjs/contracts/errors.js.map +1 -0
- package/dist/cjs/contracts/evidence.d.ts +49 -0
- package/dist/cjs/contracts/evidence.d.ts.map +1 -0
- package/dist/cjs/contracts/evidence.js +12 -0
- package/dist/cjs/contracts/evidence.js.map +1 -0
- package/dist/cjs/contracts/index.d.ts +10 -0
- package/dist/cjs/contracts/index.d.ts.map +1 -0
- package/dist/cjs/contracts/index.js +26 -0
- package/dist/cjs/contracts/index.js.map +1 -0
- package/dist/cjs/contracts/store.d.ts +30 -0
- package/dist/cjs/contracts/store.d.ts.map +1 -0
- package/dist/cjs/contracts/store.js +3 -0
- package/dist/cjs/contracts/store.js.map +1 -0
- package/dist/cjs/mcp/tool-profiles.d.ts.map +1 -1
- package/dist/cjs/mcp/tool-profiles.js +46 -1
- package/dist/cjs/mcp/tool-profiles.js.map +1 -1
- package/dist/cjs/mcp/tools.d.ts +2 -0
- package/dist/cjs/mcp/tools.d.ts.map +1 -1
- package/dist/cjs/mcp/tools.js +319 -30
- package/dist/cjs/mcp/tools.js.map +1 -1
- package/dist/cjs/pr-review/bridge/BrainBridge.js +1 -1
- package/dist/cjs/pr-review/bridge/BrainBridge.js.map +1 -1
- package/dist/cjs/subconscious/BrainEmbeddings.d.ts +59 -0
- package/dist/cjs/subconscious/BrainEmbeddings.d.ts.map +1 -0
- package/dist/cjs/subconscious/BrainEmbeddings.js +222 -0
- package/dist/cjs/subconscious/BrainEmbeddings.js.map +1 -0
- package/dist/cjs/subconscious/GitIngest.js +2 -2
- package/dist/cjs/subconscious/GitIngest.js.map +1 -1
- package/dist/cjs/subconscious/TheBrainV2.d.ts +327 -9
- package/dist/cjs/subconscious/TheBrainV2.d.ts.map +1 -1
- package/dist/cjs/subconscious/TheBrainV2.js +952 -98
- package/dist/cjs/subconscious/TheBrainV2.js.map +1 -1
- package/dist/cjs/subconscious/freshness/LocalFsResolver.d.ts +16 -0
- package/dist/cjs/subconscious/freshness/LocalFsResolver.d.ts.map +1 -0
- package/dist/cjs/subconscious/freshness/LocalFsResolver.js +74 -0
- package/dist/cjs/subconscious/freshness/LocalFsResolver.js.map +1 -0
- package/dist/cjs/subconscious/freshness/SuppliedEvidenceResolver.d.ts +23 -0
- package/dist/cjs/subconscious/freshness/SuppliedEvidenceResolver.d.ts.map +1 -0
- package/dist/cjs/subconscious/freshness/SuppliedEvidenceResolver.js +24 -0
- package/dist/cjs/subconscious/freshness/SuppliedEvidenceResolver.js.map +1 -0
- package/dist/cjs/subconscious/freshness/index.d.ts +10 -0
- package/dist/cjs/subconscious/freshness/index.d.ts.map +1 -0
- package/dist/cjs/subconscious/freshness/index.js +26 -0
- package/dist/cjs/subconscious/freshness/index.js.map +1 -0
- package/dist/cjs/utils/ConversationCheckpoint.js +1 -1
- package/dist/cjs/utils/ConversationCheckpoint.js.map +1 -1
- package/dist/cjs/utils/ProjectIdentity.d.ts +12 -0
- package/dist/cjs/utils/ProjectIdentity.d.ts.map +1 -0
- package/dist/cjs/utils/ProjectIdentity.js +44 -0
- package/dist/cjs/utils/ProjectIdentity.js.map +1 -0
- package/dist/cjs/utils/PromptPatternCache.d.ts.map +1 -1
- package/dist/cjs/utils/PromptPatternCache.js +12 -2
- package/dist/cjs/utils/PromptPatternCache.js.map +1 -1
- package/dist/cjs/utils/RepeatGuard.d.ts.map +1 -1
- package/dist/cjs/utils/RepeatGuard.js +10 -2
- package/dist/cjs/utils/RepeatGuard.js.map +1 -1
- package/dist/cjs/utils/StateHashCache.d.ts +5 -0
- package/dist/cjs/utils/StateHashCache.d.ts.map +1 -1
- package/dist/cjs/utils/StateHashCache.js +40 -16
- package/dist/cjs/utils/StateHashCache.js.map +1 -1
- package/dist/esm/api/dashboardRoutes.d.ts +3 -3
- package/dist/esm/api/dashboardRoutes.js +1 -1
- package/dist/esm/api/server.d.ts +4 -4
- package/dist/esm/api/server.js +3 -3
- package/dist/esm/autopilot/AutopilotWatcher.js +3 -3
- package/dist/esm/autopilot/Notifier.d.ts +1 -1
- package/dist/esm/cli/lemma-proxy.d.ts.map +1 -1
- package/dist/esm/cli/lemma-proxy.js +33 -25
- package/dist/esm/cli/lemma-proxy.js.map +1 -1
- package/dist/esm/cli/stack.d.ts +4 -4
- package/dist/esm/cli/stack.js +5 -5
- package/dist/esm/cloud/KeyManager.d.ts +1 -1
- package/dist/esm/cloud/KeyManager.js +1 -1
- package/dist/esm/cloud/TenantCache.d.ts +1 -1
- package/dist/esm/cloud/TenantCache.d.ts.map +1 -1
- package/dist/esm/cloud/TenantCache.js +0 -4
- package/dist/esm/cloud/TenantCache.js.map +1 -1
- package/dist/esm/cloud/identity/ApiKey.d.ts +32 -0
- package/dist/esm/cloud/identity/ApiKey.d.ts.map +1 -0
- package/dist/esm/cloud/identity/ApiKey.js +49 -0
- package/dist/esm/cloud/identity/ApiKey.js.map +1 -0
- package/dist/esm/cloud/identity/PlanPolicy.d.ts +79 -0
- package/dist/esm/cloud/identity/PlanPolicy.d.ts.map +1 -0
- package/dist/esm/cloud/identity/PlanPolicy.js +129 -0
- package/dist/esm/cloud/identity/PlanPolicy.js.map +1 -0
- package/dist/esm/cloud/identity/RateLimiter.d.ts +49 -0
- package/dist/esm/cloud/identity/RateLimiter.d.ts.map +1 -0
- package/dist/esm/cloud/identity/RateLimiter.js +69 -0
- package/dist/esm/cloud/identity/RateLimiter.js.map +1 -0
- package/dist/esm/cloud/identity/TenantResolver.d.ts +19 -0
- package/dist/esm/cloud/identity/TenantResolver.d.ts.map +1 -0
- package/dist/esm/cloud/identity/TenantResolver.js +36 -0
- package/dist/esm/cloud/identity/TenantResolver.js.map +1 -0
- package/dist/esm/cloud/identity/authenticateV2.d.ts +48 -0
- package/dist/esm/cloud/identity/authenticateV2.d.ts.map +1 -0
- package/dist/esm/cloud/identity/authenticateV2.js +62 -0
- package/dist/esm/cloud/identity/authenticateV2.js.map +1 -0
- package/dist/esm/cloud/identity/identityStore.d.ts +56 -0
- package/dist/esm/cloud/identity/identityStore.d.ts.map +1 -0
- package/dist/esm/cloud/identity/identityStore.js +94 -0
- package/dist/esm/cloud/identity/identityStore.js.map +1 -0
- package/dist/esm/cloud/identity/index.d.ts +14 -0
- package/dist/esm/cloud/identity/index.d.ts.map +1 -0
- package/dist/esm/cloud/identity/index.js +14 -0
- package/dist/esm/cloud/identity/index.js.map +1 -0
- package/dist/esm/cloud/index.d.ts +3 -3
- package/dist/esm/cloud/index.js +3 -3
- package/dist/esm/cloud/metering/TokenCounter.d.ts +26 -0
- package/dist/esm/cloud/metering/TokenCounter.d.ts.map +1 -0
- package/dist/esm/cloud/metering/TokenCounter.js +76 -0
- package/dist/esm/cloud/metering/TokenCounter.js.map +1 -0
- package/dist/esm/cloud/metering/UsageLedger.d.ts +68 -0
- package/dist/esm/cloud/metering/UsageLedger.d.ts.map +1 -0
- package/dist/esm/cloud/metering/UsageLedger.js +98 -0
- package/dist/esm/cloud/metering/UsageLedger.js.map +1 -0
- package/dist/esm/cloud/metering/index.d.ts +12 -0
- package/dist/esm/cloud/metering/index.d.ts.map +1 -0
- package/dist/esm/cloud/metering/index.js +12 -0
- package/dist/esm/cloud/metering/index.js.map +1 -0
- package/dist/esm/cloud/scrub/StatelessScrubber.d.ts +53 -0
- package/dist/esm/cloud/scrub/StatelessScrubber.d.ts.map +1 -0
- package/dist/esm/cloud/scrub/StatelessScrubber.js +199 -0
- package/dist/esm/cloud/scrub/StatelessScrubber.js.map +1 -0
- package/dist/esm/cloud/scrub/index.d.ts +5 -0
- package/dist/esm/cloud/scrub/index.d.ts.map +1 -0
- package/dist/esm/cloud/scrub/index.js +5 -0
- package/dist/esm/cloud/scrub/index.js.map +1 -0
- package/dist/esm/cloud/server.d.ts +3 -3
- package/dist/esm/cloud/server.js +5 -5
- package/dist/esm/cloud/store/FileBrainStore.d.ts +26 -0
- package/dist/esm/cloud/store/FileBrainStore.d.ts.map +1 -0
- package/dist/esm/cloud/store/FileBrainStore.js +212 -0
- package/dist/esm/cloud/store/FileBrainStore.js.map +1 -0
- package/dist/esm/cloud/store/PostgresBrainStore.d.ts +50 -0
- package/dist/esm/cloud/store/PostgresBrainStore.d.ts.map +1 -0
- package/dist/esm/cloud/store/PostgresBrainStore.js +176 -0
- package/dist/esm/cloud/store/PostgresBrainStore.js.map +1 -0
- package/dist/esm/cloud/store/index.d.ts +6 -0
- package/dist/esm/cloud/store/index.d.ts.map +1 -0
- package/dist/esm/cloud/store/index.js +6 -0
- package/dist/esm/cloud/store/index.js.map +1 -0
- package/dist/esm/cloud/types.d.ts +0 -4
- package/dist/esm/cloud/types.d.ts.map +1 -1
- package/dist/esm/cloud/types.js +0 -2
- package/dist/esm/cloud/types.js.map +1 -1
- package/dist/esm/cloud/v2/app.d.ts +15 -0
- package/dist/esm/cloud/v2/app.d.ts.map +1 -0
- package/dist/esm/cloud/v2/app.js +57 -0
- package/dist/esm/cloud/v2/app.js.map +1 -0
- package/dist/esm/cloud/v2/routes/index.d.ts +24 -0
- package/dist/esm/cloud/v2/routes/index.d.ts.map +1 -0
- package/dist/esm/cloud/v2/routes/index.js +32 -0
- package/dist/esm/cloud/v2/routes/index.js.map +1 -0
- package/dist/esm/cloud/v2/routes/memories.d.ts +83 -0
- package/dist/esm/cloud/v2/routes/memories.d.ts.map +1 -0
- package/dist/esm/cloud/v2/routes/memories.js +238 -0
- package/dist/esm/cloud/v2/routes/memories.js.map +1 -0
- package/dist/esm/cloud/v2/routes/recall.d.ts +33 -0
- package/dist/esm/cloud/v2/routes/recall.d.ts.map +1 -0
- package/dist/esm/cloud/v2/routes/recall.js +47 -0
- package/dist/esm/cloud/v2/routes/recall.js.map +1 -0
- package/dist/esm/cloud/v2/routes/scrub.d.ts +13 -0
- package/dist/esm/cloud/v2/routes/scrub.d.ts.map +1 -0
- package/dist/esm/cloud/v2/routes/scrub.js +79 -0
- package/dist/esm/cloud/v2/routes/scrub.js.map +1 -0
- package/dist/esm/cloud/v2/routes/usage.d.ts +18 -0
- package/dist/esm/cloud/v2/routes/usage.d.ts.map +1 -0
- package/dist/esm/cloud/v2/routes/usage.js +15 -0
- package/dist/esm/cloud/v2/routes/usage.js.map +1 -0
- package/dist/esm/cloud/v2/routes/verify.d.ts +35 -0
- package/dist/esm/cloud/v2/routes/verify.d.ts.map +1 -0
- package/dist/esm/cloud/v2/routes/verify.js +39 -0
- package/dist/esm/cloud/v2/routes/verify.js.map +1 -0
- package/dist/esm/cloud/v2/server.d.ts +27 -0
- package/dist/esm/cloud/v2/server.d.ts.map +1 -0
- package/dist/esm/cloud/v2/server.js +44 -0
- package/dist/esm/cloud/v2/server.js.map +1 -0
- package/dist/esm/config/index.d.ts +1 -1
- package/dist/esm/config/index.js +1 -1
- package/dist/esm/consensus/index.d.ts +2 -2
- package/dist/esm/consensus/index.js +2 -2
- package/dist/esm/contracts/api-v2.types.d.ts +103 -0
- package/dist/esm/contracts/api-v2.types.d.ts.map +1 -0
- package/dist/esm/contracts/api-v2.types.js +2 -0
- package/dist/esm/contracts/api-v2.types.js.map +1 -0
- package/dist/esm/contracts/errors.d.ts +40 -0
- package/dist/esm/contracts/errors.d.ts.map +1 -0
- package/dist/esm/contracts/errors.js +45 -0
- package/dist/esm/contracts/errors.js.map +1 -0
- package/dist/esm/contracts/evidence.d.ts +49 -0
- package/dist/esm/contracts/evidence.d.ts.map +1 -0
- package/dist/esm/contracts/evidence.js +11 -0
- package/dist/esm/contracts/evidence.js.map +1 -0
- package/dist/esm/contracts/index.d.ts +10 -0
- package/dist/esm/contracts/index.d.ts.map +1 -0
- package/dist/esm/contracts/index.js +10 -0
- package/dist/esm/contracts/index.js.map +1 -0
- package/dist/esm/contracts/store.d.ts +30 -0
- package/dist/esm/contracts/store.d.ts.map +1 -0
- package/dist/esm/contracts/store.js +2 -0
- package/dist/esm/contracts/store.js.map +1 -0
- package/dist/esm/core/AgentRegistry.d.ts +1 -1
- package/dist/esm/core/AgentRegistry.js +1 -1
- package/dist/esm/core/DashboardBroadcaster.d.ts +3 -3
- package/dist/esm/core/DashboardBroadcaster.js +2 -2
- package/dist/esm/core/DashboardWebSocketServer.d.ts +1 -1
- package/dist/esm/core/DashboardWebSocketServer.js +1 -1
- package/dist/esm/core/GhostAlchemist.js +1 -1
- package/dist/esm/core/GhostListener.js +2 -2
- package/dist/esm/core/OrchestrationEngine.d.ts +3 -3
- package/dist/esm/core/OrchestrationEngine.js +2 -2
- package/dist/esm/core/SubconsciousEngine.d.ts +1 -1
- package/dist/esm/core/SubconsciousEngine.js +2 -2
- package/dist/esm/core/WebSocketServer.d.ts +2 -2
- package/dist/esm/core/WebSocketServer.js +1 -1
- package/dist/esm/core/index.d.ts +6 -6
- package/dist/esm/core/index.js +6 -6
- package/dist/esm/core/router.d.ts +3 -3
- package/dist/esm/core/router.js +1 -1
- package/dist/esm/db/database.js +1 -1
- package/dist/esm/embed.d.ts +2 -2
- package/dist/esm/embed.js +2 -2
- package/dist/esm/examples/basic-usage.js +1 -1
- package/dist/esm/index.d.ts +14 -14
- package/dist/esm/index.js +14 -14
- package/dist/esm/infra/analyzers/DriftDetector.d.ts +1 -1
- package/dist/esm/infra/analyzers/InfraAnalyzer.d.ts +1 -1
- package/dist/esm/infra/analyzers/MonolithAnalyzer.d.ts +1 -1
- package/dist/esm/infra/analyzers/index.d.ts +3 -3
- package/dist/esm/infra/analyzers/index.js +3 -3
- package/dist/esm/infra/cli.js +2 -2
- package/dist/esm/infra/config.d.ts +1 -1
- package/dist/esm/infra/index.d.ts +5 -5
- package/dist/esm/infra/index.js +5 -5
- package/dist/esm/infra/mcp-tools.js +5 -5
- package/dist/esm/infra/providers/InfraProvider.d.ts +1 -1
- package/dist/esm/infra/providers/JenkinsProvider.d.ts +2 -2
- package/dist/esm/infra/providers/OKDProvider.d.ts +2 -2
- package/dist/esm/infra/providers/TerraformProvider.d.ts +2 -2
- package/dist/esm/infra/providers/index.d.ts +5 -5
- package/dist/esm/infra/providers/index.js +3 -3
- package/dist/esm/mcp/index.js +5 -5
- package/dist/esm/mcp/prompts.js +1 -1
- package/dist/esm/mcp/resources.js +2 -2
- package/dist/esm/mcp/tasks.js +1 -1
- package/dist/esm/mcp/tool-profiles.d.ts.map +1 -1
- package/dist/esm/mcp/tool-profiles.js +47 -2
- package/dist/esm/mcp/tool-profiles.js.map +1 -1
- package/dist/esm/mcp/tools.d.ts +2 -0
- package/dist/esm/mcp/tools.d.ts.map +1 -1
- package/dist/esm/mcp/tools.js +366 -78
- package/dist/esm/mcp/tools.js.map +1 -1
- package/dist/esm/observability/IdeContextSync.d.ts +1 -1
- package/dist/esm/observability/IdeContextSync.js +5 -5
- package/dist/esm/pr-review/PRReviewEngine.d.ts +1 -1
- package/dist/esm/pr-review/PRReviewEngine.js +4 -4
- package/dist/esm/pr-review/ReviewStore.d.ts +1 -1
- package/dist/esm/pr-review/adapters/AzureDevOpsAdapter.d.ts +2 -2
- package/dist/esm/pr-review/adapters/AzureDevOpsAdapter.js +1 -1
- package/dist/esm/pr-review/adapters/GitHubAdapter.d.ts +2 -2
- package/dist/esm/pr-review/adapters/GitHubAdapter.js +1 -1
- package/dist/esm/pr-review/adapters/GitLabAdapter.d.ts +2 -2
- package/dist/esm/pr-review/adapters/GitLabAdapter.js +1 -1
- package/dist/esm/pr-review/adapters/GitPlatformAdapter.d.ts +1 -1
- package/dist/esm/pr-review/adapters/index.d.ts +4 -4
- package/dist/esm/pr-review/adapters/index.js +3 -3
- package/dist/esm/pr-review/analyzers/QualityGrader.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/RegressionDetector.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/SecurityScanner.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/StaticAnalyzer.d.ts +1 -1
- package/dist/esm/pr-review/analyzers/index.d.ts +8 -8
- package/dist/esm/pr-review/analyzers/index.js +4 -4
- package/dist/esm/pr-review/bridge/BrainBridge.d.ts +1 -1
- package/dist/esm/pr-review/bridge/BrainBridge.js +2 -2
- package/dist/esm/pr-review/bridge/BrainBridge.js.map +1 -1
- package/dist/esm/pr-review/bridge/index.d.ts +1 -1
- package/dist/esm/pr-review/bridge/index.js +1 -1
- package/dist/esm/pr-review/index.d.ts +4 -4
- package/dist/esm/pr-review/index.js +2 -2
- package/dist/esm/pr-review/reviewRunner.d.ts +2 -2
- package/dist/esm/pr-review/reviewRunner.js +6 -6
- package/dist/esm/pr-review/webhook/WebhookServer.js +1 -1
- package/dist/esm/pr-review/webhook/index.d.ts +1 -1
- package/dist/esm/pr-review/webhook/index.js +1 -1
- package/dist/esm/protocol/flows.d.ts +1 -1
- package/dist/esm/protocol/flows.js +1 -1
- package/dist/esm/protocol/index.d.ts +4 -4
- package/dist/esm/protocol/index.js +4 -4
- package/dist/esm/protocol/utils.d.ts +1 -1
- package/dist/esm/protocol/utils.js +2 -2
- package/dist/esm/protocol/validators.d.ts +1 -1
- package/dist/esm/protocol/validators.js +1 -1
- package/dist/esm/proxy/ContextInjector.d.ts +1 -1
- package/dist/esm/proxy/Gatekeeper.d.ts +1 -1
- package/dist/esm/security/SecurityMiddleware.d.ts +1 -1
- package/dist/esm/security/SecurityMiddleware.js +3 -3
- package/dist/esm/security/index.d.ts +4 -4
- package/dist/esm/security/index.js +4 -4
- package/dist/esm/speculative/SpeculativeCache.d.ts +2 -2
- package/dist/esm/speculative/SpeculativeEngine.d.ts +2 -2
- package/dist/esm/speculative/SpeculativeEngine.js +3 -3
- package/dist/esm/speculative/WorkerPool.d.ts +1 -1
- package/dist/esm/speculative/index.d.ts +4 -4
- package/dist/esm/speculative/index.js +4 -4
- package/dist/esm/subconscious/BrainEmbeddings.d.ts +59 -0
- package/dist/esm/subconscious/BrainEmbeddings.d.ts.map +1 -0
- package/dist/esm/subconscious/BrainEmbeddings.js +211 -0
- package/dist/esm/subconscious/BrainEmbeddings.js.map +1 -0
- package/dist/esm/subconscious/GitIngest.d.ts +1 -1
- package/dist/esm/subconscious/GitIngest.js +3 -3
- package/dist/esm/subconscious/GitIngest.js.map +1 -1
- package/dist/esm/subconscious/SemanticCache.d.ts +2 -2
- package/dist/esm/subconscious/SemanticCache.js +2 -2
- package/dist/esm/subconscious/SubconsciousEngine.d.ts +1 -1
- package/dist/esm/subconscious/SubconsciousEngine.js +3 -3
- package/dist/esm/subconscious/TheBrainV2.d.ts +327 -9
- package/dist/esm/subconscious/TheBrainV2.d.ts.map +1 -1
- package/dist/esm/subconscious/TheBrainV2.js +947 -98
- package/dist/esm/subconscious/TheBrainV2.js.map +1 -1
- package/dist/esm/subconscious/freshness/LocalFsResolver.d.ts +16 -0
- package/dist/esm/subconscious/freshness/LocalFsResolver.d.ts.map +1 -0
- package/dist/esm/subconscious/freshness/LocalFsResolver.js +67 -0
- package/dist/esm/subconscious/freshness/LocalFsResolver.js.map +1 -0
- package/dist/esm/subconscious/freshness/SuppliedEvidenceResolver.d.ts +23 -0
- package/dist/esm/subconscious/freshness/SuppliedEvidenceResolver.d.ts.map +1 -0
- package/dist/esm/subconscious/freshness/SuppliedEvidenceResolver.js +20 -0
- package/dist/esm/subconscious/freshness/SuppliedEvidenceResolver.js.map +1 -0
- package/dist/esm/subconscious/freshness/index.d.ts +10 -0
- package/dist/esm/subconscious/freshness/index.d.ts.map +1 -0
- package/dist/esm/subconscious/freshness/index.js +10 -0
- package/dist/esm/subconscious/freshness/index.js.map +1 -0
- package/dist/esm/subconscious/index.d.ts +4 -4
- package/dist/esm/subconscious/index.js +4 -4
- package/dist/esm/utils/AffectedTests.js +1 -1
- package/dist/esm/utils/AutoContextBundle.d.ts +1 -1
- package/dist/esm/utils/AutoContextBundle.js +4 -4
- package/dist/esm/utils/BulkFileDigest.js +2 -2
- package/dist/esm/utils/ClipboardWatcher.js +2 -2
- package/dist/esm/utils/ContextCollapser.js +1 -1
- package/dist/esm/utils/ConversationCheckpoint.js +2 -2
- package/dist/esm/utils/ConversationCheckpoint.js.map +1 -1
- package/dist/esm/utils/ExecutiveReport.js +1 -1
- package/dist/esm/utils/OutputLedger.js +2 -2
- package/dist/esm/utils/ProjectIdentity.d.ts +12 -0
- package/dist/esm/utils/ProjectIdentity.d.ts.map +1 -0
- package/dist/esm/utils/ProjectIdentity.js +37 -0
- package/dist/esm/utils/ProjectIdentity.js.map +1 -0
- package/dist/esm/utils/PromptPatternCache.d.ts.map +1 -1
- package/dist/esm/utils/PromptPatternCache.js +12 -2
- package/dist/esm/utils/PromptPatternCache.js.map +1 -1
- package/dist/esm/utils/ReadWorkspaceCache.js +1 -1
- package/dist/esm/utils/RepeatGuard.d.ts.map +1 -1
- package/dist/esm/utils/RepeatGuard.js +10 -2
- package/dist/esm/utils/RepeatGuard.js.map +1 -1
- package/dist/esm/utils/SpeculativeWarmer.d.ts +1 -1
- package/dist/esm/utils/SpeculativeWarmer.js +2 -2
- package/dist/esm/utils/StateHashCache.d.ts +5 -0
- package/dist/esm/utils/StateHashCache.d.ts.map +1 -1
- package/dist/esm/utils/StateHashCache.js +40 -16
- package/dist/esm/utils/StateHashCache.js.map +1 -1
- package/dist/esm/utils/StructuralSearch.d.ts +1 -1
- package/dist/esm/utils/SurgicalASTInsert.js +1 -1
- package/dist/esm/utils/SymbolSurgicalContext.js +1 -1
- package/dist/esm/utils/TestAutofixInterceptor.js +1 -1
- package/dist/esm/utils/WorkspaceSearch.js +0 -0
- package/dist/esm/utils/logger.js +1 -1
- package/dist/esm/utils/reportSavings.js +1 -1
- package/package.json +1 -1
- package/sdks/crewai/README.md +25 -0
- package/dist/cjs/package.json +0 -3
- package/dist/esm/package.json +0 -3
- package/sdks/crewai/dist/index.d.ts +0 -130
- package/sdks/crewai/dist/index.js +0 -308
package/dist/esm/mcp/tools.js
CHANGED
|
@@ -5,50 +5,51 @@ import { execSync, execFileSync, spawn } from "child_process";
|
|
|
5
5
|
import os from "os";
|
|
6
6
|
import axios from "axios";
|
|
7
7
|
import * as ts from "typescript";
|
|
8
|
-
import { SemanticScrubber } from "../security/SemanticScrubber
|
|
9
|
-
import { ComplexityRouter } from "../proxy/ComplexityRouter
|
|
10
|
-
import { squeezeCode, squeezePrompt, pruneHistoryMessages, generateAstDiff } from "../utils/ContextSqueezer
|
|
11
|
-
import { reportSavings, reportCost } from "../utils/reportSavings
|
|
12
|
-
import { getProxyPort, safeResolvePath, logError, logWarn, estimateTokensFromResult, isCommandAllowed, loadAllowedCommands } from "./utils
|
|
13
|
-
import { computeFingerprint } from "../utils/FileFingerprint
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
8
|
+
import { SemanticScrubber } from "../security/SemanticScrubber";
|
|
9
|
+
import { ComplexityRouter } from "../proxy/ComplexityRouter";
|
|
10
|
+
import { squeezeCode, squeezePrompt, pruneHistoryMessages, generateAstDiff, stripComments, stripImports, compactWhitespace } from "../utils/ContextSqueezer";
|
|
11
|
+
import { reportSavings, reportCost } from "../utils/reportSavings";
|
|
12
|
+
import { getProxyPort, safeResolvePath, logError, logWarn, estimateTokensFromResult, isCommandAllowed, loadAllowedCommands } from "./utils";
|
|
13
|
+
import { computeFingerprint } from "../utils/FileFingerprint";
|
|
14
|
+
import { detectProjectName } from "../utils/ProjectIdentity";
|
|
15
|
+
import { analyzeBlameHeat } from "../utils/GitBlameHeat";
|
|
16
|
+
import { analyzeTypeCoverage } from "../utils/TypeCoverage";
|
|
17
|
+
import { buildImportTree } from "../utils/ImportTreeContext";
|
|
18
|
+
import { readTokenBudgeted } from "../utils/TokenBudgetedReader";
|
|
19
|
+
import { bulkFileDigest } from "../utils/BulkFileDigest";
|
|
20
|
+
import { autoContextBundle } from "../utils/AutoContextBundle";
|
|
21
|
+
import { checkRepeat, recordOutput } from "../utils/RepeatGuard";
|
|
22
|
+
import { saveCheckpoint, loadLatestCheckpoint, loadRecentCheckpoints, buildCheckpointSummary } from "../utils/ConversationCheckpoint";
|
|
23
|
+
import { runTestAutofix } from "../utils/TestAutofixInterceptor";
|
|
24
|
+
import { findPattern, storePattern, getPatternStats } from "../utils/PromptPatternCache";
|
|
25
|
+
import { runAnalysis, parseDiff } from "../pr-review/PRReviewEngine";
|
|
26
|
+
import { ReviewStore } from "../pr-review/ReviewStore";
|
|
27
|
+
import { runPRReview } from "../pr-review/reviewRunner";
|
|
28
|
+
import { getBrain, deriveProjectId, currentGitContext } from "../subconscious/TheBrainV2";
|
|
29
|
+
import { collapseContext } from "../utils/ContextCollapser";
|
|
30
|
+
import { getSymbolSurgicalContext } from "../utils/SymbolSurgicalContext";
|
|
31
|
+
import { compressWormhole } from "../utils/WormholeCompressor";
|
|
32
|
+
import { generateExecutiveReport } from "../utils/ExecutiveReport";
|
|
33
|
+
import { surgicalASTInsert } from "../utils/SurgicalASTInsert";
|
|
34
|
+
import { getInfraToolDefinitions, getInfraToolHandlers, INFRA_TOOL_NAMES } from "../infra/mcp-tools";
|
|
35
|
+
import { resolveToolSurface, buildToolboxCatalog } from "./tool-profiles";
|
|
36
|
+
import { lookupStateHash, storeStateHash } from "../utils/StateHashCache";
|
|
37
|
+
import { recordReceiptEvent, getReceiptSummary, getLedgerLength } from "../utils/TokenReceipt";
|
|
38
|
+
import { distillCommandOutput, buildDistillFooter, readRegion } from "../utils/CommandOutputDistiller";
|
|
39
|
+
import { findMatch, reindentReplacement } from "../utils/PatchMatcher";
|
|
40
|
+
import { registerTaskHandlers, runAsTask, TASK_CAPABLE_TOOLS } from "./tasks";
|
|
41
|
+
import { searchWorkspace, groupSearchResults, parseExtensionFilter } from "../utils/WorkspaceSearch";
|
|
42
|
+
import { rankCandidates } from "../utils/LocalPrefilter";
|
|
43
|
+
import { checkAlreadySent, recordSent, getLastEmitted } from "../utils/ReadWorkspaceCache";
|
|
44
|
+
import { shouldEmitDelta } from "../utils/OutputDelta";
|
|
45
|
+
import { ledgerKey, checkOutput, recordOutput as recordLedgerOutput } from "../utils/OutputLedger";
|
|
46
|
+
import { buildDepGraphMap, bfsDepGraph } from "../utils/DepGraph";
|
|
47
|
+
import { getOrExtractSymbols } from "../utils/AstSymbolCache";
|
|
48
|
+
import { warmNeighbors, registerSymbolExtractor } from "../utils/SpeculativeWarmer";
|
|
49
|
+
import { findAffectedTests, formatAffectedTests, changedFilesFromGit } from "../utils/AffectedTests";
|
|
50
|
+
import { mapSqueezedToOriginal, withLineNumbers, sequentialNumbers } from "../utils/LineNumberMap";
|
|
51
|
+
import { fileOutline, formatOutline } from "../utils/FileOutline";
|
|
52
|
+
import { getCachedSearch, setCachedSearch } from "../utils/SearchCache";
|
|
52
53
|
// ── Pro License Gate ──────────────────────────────────────────────────────────
|
|
53
54
|
const LICENSE_FILE = path.join(os.homedir(), '.lemma-cache', 'license.json');
|
|
54
55
|
let _proStatusCache = null;
|
|
@@ -69,6 +70,10 @@ function isProUser() {
|
|
|
69
70
|
const FREE_TOOLS = new Set([
|
|
70
71
|
// Cache & Memory — the hook that shows instant value
|
|
71
72
|
"smarter_cache", "state_hash_cache", "token_receipt", "search_memory", "store_memory", "downvote_memory", "verify_memory", "get_project_history",
|
|
73
|
+
// Memory upkeep. Deleting your own memories, re-verifying them, and getting them back out
|
|
74
|
+
// of the tool must never be behind a paywall — a user who cannot export or forget what a
|
|
75
|
+
// free tier collected does not really own it.
|
|
76
|
+
"forget_memory", "refresh_memory", "brain_stats", "brain_export", "brain_import",
|
|
72
77
|
// Token optimization — shows what they're saving
|
|
73
78
|
"token_budget", "squeeze_prompt", "turbosqueeze",
|
|
74
79
|
// Utility — just enough to function
|
|
@@ -307,6 +312,81 @@ const toolDefinitions = [
|
|
|
307
312
|
required: ["id"],
|
|
308
313
|
},
|
|
309
314
|
},
|
|
315
|
+
{
|
|
316
|
+
name: "forget_memory",
|
|
317
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
318
|
+
description: "Permanently delete one memory from the Brain by id. Use when a memory is flat wrong, was captured by mistake, or should never have been stored — not when it is merely a poor match for one query (that is downvote_memory, which keeps it around for a different question later). Deletion is irreversible and the id will not come back from another session's copy.",
|
|
319
|
+
inputSchema: {
|
|
320
|
+
type: "object",
|
|
321
|
+
properties: {
|
|
322
|
+
id: { type: "string", description: "The memory's id, from a search_memory or store_memory result." },
|
|
323
|
+
},
|
|
324
|
+
required: ["id"],
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "refresh_memory",
|
|
329
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
330
|
+
description: "Re-anchor a STALE memory to the code as it stands now, keeping its id, hit count and derivedFrom links (storing a near-duplicate instead loses all three, and dedup often refuses it anyway). Call with just the id after you have verified the memory is still correct; pass filePaths/symbols instead when the code moved and it should track something new. Only call this once you have actually checked — it records your assertion that the memory is true today, it cannot verify that itself.",
|
|
331
|
+
inputSchema: {
|
|
332
|
+
type: "object",
|
|
333
|
+
properties: {
|
|
334
|
+
id: { type: "string", description: "The memory's id, from a search_memory or verify_memory result." },
|
|
335
|
+
filePaths: { type: "array", items: { type: "string" }, description: "New files to track instead of the current ones. Omit to re-hash whatever it already tracks." },
|
|
336
|
+
symbols: {
|
|
337
|
+
type: "array",
|
|
338
|
+
items: {
|
|
339
|
+
type: "object",
|
|
340
|
+
properties: {
|
|
341
|
+
filePath: { type: "string" },
|
|
342
|
+
symbolName: { type: "string" },
|
|
343
|
+
},
|
|
344
|
+
required: ["filePath", "symbolName"],
|
|
345
|
+
},
|
|
346
|
+
description: "New symbols to track instead of the current ones (e.g. the function was renamed or moved).",
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
required: ["id"],
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: "brain_stats",
|
|
354
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
355
|
+
description: "Health report for the Brain itself: entry count, how many memories no search has ever reused, how many were downvoted, what wrote them (manual vs. each auto-capture path), projects covered, and corpus size. Pass deep:true to also re-hash every tracked file and report the stale ratio — accurate but thousands of file reads on a large Brain.",
|
|
356
|
+
inputSchema: {
|
|
357
|
+
type: "object",
|
|
358
|
+
properties: {
|
|
359
|
+
deep: { type: "boolean", description: "Also compute the stale ratio by re-hashing all tracked evidence. Slow.", default: false },
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: "brain_export",
|
|
365
|
+
annotations: { readOnlyHint: true, idempotentHint: false, openWorldHint: false },
|
|
366
|
+
description: "Write memories to a portable NDJSON bundle for backup, moving to another machine, or sharing with a teammate. Defaults to this project's memories only, and to fresh ones only (a stale memory exported and imported elsewhere is just a wrong answer with a passport).",
|
|
367
|
+
inputSchema: {
|
|
368
|
+
type: "object",
|
|
369
|
+
properties: {
|
|
370
|
+
outPath: { type: "string", description: "Where to write the bundle (relative to the workspace root)." },
|
|
371
|
+
allProjects: { type: "boolean", description: "Export every project's memories, not just this one.", default: false },
|
|
372
|
+
domain: { type: "string", description: "Only export memories tagged with this domain." },
|
|
373
|
+
includeStale: { type: "boolean", description: "Include memories whose tracked evidence no longer matches.", default: false },
|
|
374
|
+
},
|
|
375
|
+
required: ["outPath"],
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: "brain_import",
|
|
380
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
381
|
+
description: "Merge a bundle written by brain_export into this Brain. Additive and non-destructive: an id already present keeps the newer version, and anything previously deleted with forget_memory stays deleted. Imported memories track the paths of the machine they came from, so most will read as stale here until refresh_memory re-anchors them.",
|
|
382
|
+
inputSchema: {
|
|
383
|
+
type: "object",
|
|
384
|
+
properties: {
|
|
385
|
+
path: { type: "string", description: "Path to the bundle file (relative to the workspace root)." },
|
|
386
|
+
},
|
|
387
|
+
required: ["path"],
|
|
388
|
+
},
|
|
389
|
+
},
|
|
310
390
|
{
|
|
311
391
|
name: "get_routing_advice",
|
|
312
392
|
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
@@ -1437,6 +1517,11 @@ const toolHandlers = {
|
|
|
1437
1517
|
store_memory: handleStoreMemory,
|
|
1438
1518
|
downvote_memory: handleDownvoteMemory,
|
|
1439
1519
|
verify_memory: handleVerifyMemory,
|
|
1520
|
+
forget_memory: handleForgetMemory,
|
|
1521
|
+
refresh_memory: handleRefreshMemory,
|
|
1522
|
+
brain_stats: handleBrainStats,
|
|
1523
|
+
brain_export: handleBrainExport,
|
|
1524
|
+
brain_import: handleBrainImport,
|
|
1440
1525
|
get_routing_advice: handleGetRoutingAdvice,
|
|
1441
1526
|
auto_heal: handleAutoHeal,
|
|
1442
1527
|
read_workspace_file: handleReadWorkspaceFile,
|
|
@@ -1715,7 +1800,9 @@ async function handleSearchMemory(args) {
|
|
|
1715
1800
|
throw new Error("Query is required");
|
|
1716
1801
|
try {
|
|
1717
1802
|
const brain = getBrain();
|
|
1718
|
-
|
|
1803
|
+
// searchHybrid is search() plus one boolean check unless LEMMA_BRAIN_EMBEDDINGS is set,
|
|
1804
|
+
// so this costs nothing by default and picks up the semantic re-rank when it is enabled.
|
|
1805
|
+
const results = await brain.searchHybrid(query, limit, minSimilarity, { projectId: deriveProjectId(), domain, semanticDiff });
|
|
1719
1806
|
if (results.length === 0) {
|
|
1720
1807
|
recordReceiptEvent("reasoning", query.substring(0, 100), {
|
|
1721
1808
|
tool: "search_memory",
|
|
@@ -1766,7 +1853,15 @@ async function handleSearchMemory(args) {
|
|
|
1766
1853
|
}
|
|
1767
1854
|
if (stale.length > 0) {
|
|
1768
1855
|
const staleText = stale
|
|
1769
|
-
.map((r, i) =>
|
|
1856
|
+
.map((r, i) => {
|
|
1857
|
+
// "You are on a different branch" and "someone rewrote this function" are the same
|
|
1858
|
+
// hash mismatch and completely different situations for the reader: the first is
|
|
1859
|
+
// usually not a reason to distrust the memory at all.
|
|
1860
|
+
const cause = r.staleCause === "branch-changed"
|
|
1861
|
+
? `\nNOTE: stored on branch \`${r.storedOnBranch}\`, you are on \`${currentGitContext().branch || "an unknown branch"}\`. The difference may be the branch switch rather than an edit — check before discarding this.`
|
|
1862
|
+
: "";
|
|
1863
|
+
return `${formatResult(r, i)}\nSTALE — changed since stored: ${r.staleFiles.join(", ")}${cause}`;
|
|
1864
|
+
})
|
|
1770
1865
|
.join("\n\n---\n\n");
|
|
1771
1866
|
parts.push(`${stale.length} more ${stale.length === 1 ? "memory is" : "memories are"} similar but STALE (underlying file(s) changed) — do not reuse verbatim, re-verify against current file state:\n\n${staleText}`);
|
|
1772
1867
|
}
|
|
@@ -1800,7 +1895,7 @@ async function handleStoreMemory(args) {
|
|
|
1800
1895
|
throw new Error("Query and response are required");
|
|
1801
1896
|
try {
|
|
1802
1897
|
const brain = getBrain();
|
|
1803
|
-
const storeRes = brain.store(query, responseText, provider, 0.92, filePaths, undefined, outcome, symbols, claims, domain, derivedFrom);
|
|
1898
|
+
const storeRes = brain.store(query, responseText, provider, 0.92, filePaths, undefined, outcome, symbols, claims, domain, derivedFrom, { source: "manual" });
|
|
1804
1899
|
// Storing a memory saves nothing — it only creates the chance of a saving later.
|
|
1805
1900
|
// Crediting tokens here inflated the ledger on write and then credited the same
|
|
1806
1901
|
// answer again on every read. The saving is booked by search_memory on a fresh hit.
|
|
@@ -1823,7 +1918,11 @@ async function handleStoreMemory(args) {
|
|
|
1823
1918
|
? `\n\n⚠️ ${storeRes.conflicts.length} existing ${storeRes.conflicts.length === 1 ? "memory shares" : "memories share"} a symbol with this one but disagree on outcome — review before trusting either:\n` +
|
|
1824
1919
|
storeRes.conflicts.map((c) => ` - [${c.outcome}] ${c.id}: ${c.query.substring(0, 120)}`).join("\n")
|
|
1825
1920
|
: "";
|
|
1826
|
-
|
|
1921
|
+
// The id is the handle for every follow-up action on this memory — derivedFrom on a
|
|
1922
|
+
// later store, verify_memory, refresh_memory, forget_memory. Without it the caller had
|
|
1923
|
+
// to search for the memory it had just written to do anything with it.
|
|
1924
|
+
const idNote = storeRes.id ? ` (id: ${storeRes.id})` : "";
|
|
1925
|
+
return { content: [{ type: "text", text: `Success: Memory stored${idNote}. ${storeRes.reason}${trackingNote}${symbolNote}${outcomeNote}${claimsNote}${domainNote}${derivedFromNote}${conflictsNote}` }] };
|
|
1827
1926
|
}
|
|
1828
1927
|
catch (e) {
|
|
1829
1928
|
logError("store_memory", e);
|
|
@@ -1843,6 +1942,138 @@ async function handleDownvoteMemory(args) {
|
|
|
1843
1942
|
return { content: [{ type: "text", text: `Failed to downvote memory: ${e.message}` }] };
|
|
1844
1943
|
}
|
|
1845
1944
|
}
|
|
1945
|
+
/**
|
|
1946
|
+
* Deleting a memory is the one Brain operation with no undo, so it asks the client to
|
|
1947
|
+
* confirm where the client supports it, and echoes back what was destroyed where it doesn't
|
|
1948
|
+
* — an irreversible action must at minimum leave a record of what it removed.
|
|
1949
|
+
*/
|
|
1950
|
+
async function handleForgetMemory(args) {
|
|
1951
|
+
const id = args?.id;
|
|
1952
|
+
if (!id)
|
|
1953
|
+
throw new Error("id is required");
|
|
1954
|
+
try {
|
|
1955
|
+
const brain = getBrain();
|
|
1956
|
+
const preview = brain.verifyByIds([id])[0];
|
|
1957
|
+
if (preview?.status === "unknown") {
|
|
1958
|
+
return { content: [{ type: "text", text: `No memory with id "${id}" in the Brain — nothing to delete.` }] };
|
|
1959
|
+
}
|
|
1960
|
+
const elicited = await tryElicitConfirmation(`Permanently delete Brain memory "${id}"? This cannot be undone.`);
|
|
1961
|
+
if (elicited.supported && !elicited.confirmed) {
|
|
1962
|
+
return { content: [{ type: "text", text: `Memory "${id}" was not deleted: declined during confirmation.` }] };
|
|
1963
|
+
}
|
|
1964
|
+
const result = brain.forget(id);
|
|
1965
|
+
if (!result.ok || !result.forgotten) {
|
|
1966
|
+
return { content: [{ type: "text", text: result.message }] };
|
|
1967
|
+
}
|
|
1968
|
+
return {
|
|
1969
|
+
content: [{
|
|
1970
|
+
type: "text",
|
|
1971
|
+
text: `${result.message}\n\nDeleted content, for the record (nothing else can recover it):\n stored: ${result.forgotten.timestamp}\n reused: ${result.forgotten.hits} time(s)\n query: ${result.forgotten.query.substring(0, 300)}`,
|
|
1972
|
+
}],
|
|
1973
|
+
};
|
|
1974
|
+
}
|
|
1975
|
+
catch (e) {
|
|
1976
|
+
logError("forget_memory", e);
|
|
1977
|
+
return { content: [{ type: "text", text: `Failed to delete memory: ${e.message}` }] };
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
async function handleRefreshMemory(args) {
|
|
1981
|
+
const id = args?.id;
|
|
1982
|
+
if (!id)
|
|
1983
|
+
throw new Error("id is required");
|
|
1984
|
+
const filePaths = Array.isArray(args?.filePaths) ? args.filePaths.filter((p) => typeof p === "string" && p) : undefined;
|
|
1985
|
+
const symbols = Array.isArray(args?.symbols)
|
|
1986
|
+
? args.symbols.filter((sym) => sym?.filePath && sym?.symbolName)
|
|
1987
|
+
: undefined;
|
|
1988
|
+
try {
|
|
1989
|
+
const result = getBrain().refresh(id, { filePaths, symbols });
|
|
1990
|
+
if (!result.ok)
|
|
1991
|
+
return { content: [{ type: "text", text: result.message }] };
|
|
1992
|
+
const retrackedNote = result.retracked && result.retracked.length > 0
|
|
1993
|
+
? `\nNow tracking: ${result.retracked.join(", ")}`
|
|
1994
|
+
: "\nThis memory tracks no files or symbols, so there was nothing to re-anchor — its age clock was reset.";
|
|
1995
|
+
return { content: [{ type: "text", text: `${result.message}${retrackedNote}` }] };
|
|
1996
|
+
}
|
|
1997
|
+
catch (e) {
|
|
1998
|
+
logError("refresh_memory", e);
|
|
1999
|
+
return { content: [{ type: "text", text: `Failed to refresh memory: ${e.message}` }] };
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
async function handleBrainStats(args) {
|
|
2003
|
+
try {
|
|
2004
|
+
const stats = getBrain().getStats({ deep: args?.deep === true });
|
|
2005
|
+
const lines = [];
|
|
2006
|
+
lines.push(`# Brain health`);
|
|
2007
|
+
lines.push(`Entries: ${stats.totalEntries} (${stats.totalTerms} indexed terms, ${((stats.corpusBytes || 0) / 1024).toFixed(0)} KB on disk)`);
|
|
2008
|
+
lines.push(`This session: ${stats.cacheHits} hit(s), ${stats.cacheMisses} miss(es)`);
|
|
2009
|
+
if (stats.totalEntries > 0) {
|
|
2010
|
+
const neverHitPct = ((stats.neverHit || 0) / stats.totalEntries) * 100;
|
|
2011
|
+
lines.push(`Never reused: ${stats.neverHit} (${neverHitPct.toFixed(0)}% — these are evicted first)`);
|
|
2012
|
+
lines.push(`Downvoted: ${stats.downvoted}`);
|
|
2013
|
+
lines.push(`Projects: ${stats.projects}${stats.unscopedEntries ? ` (+${stats.unscopedEntries} entries predating project scoping)` : ""}`);
|
|
2014
|
+
if (stats.oldestEntry)
|
|
2015
|
+
lines.push(`Oldest entry: ${stats.oldestEntry}`);
|
|
2016
|
+
if (stats.tombstones)
|
|
2017
|
+
lines.push(`Deleted ids still suppressed: ${stats.tombstones}`);
|
|
2018
|
+
const sources = Object.entries(stats.bySource || {}).sort((a, b) => b[1] - a[1]);
|
|
2019
|
+
if (sources.length > 0) {
|
|
2020
|
+
lines.push(`Written by: ${sources.map(([k, v]) => `${k}=${v}`).join(", ")}`);
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
if (stats.staleEntries !== undefined) {
|
|
2024
|
+
lines.push(`Stale: ${stats.staleEntries} of the entries that track evidence (${((stats.staleRatio || 0) * 100).toFixed(0)}%) — refresh_memory re-anchors one, forget_memory drops it.`);
|
|
2025
|
+
}
|
|
2026
|
+
else {
|
|
2027
|
+
lines.push(`(stale ratio not computed — pass deep:true)`);
|
|
2028
|
+
}
|
|
2029
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
2030
|
+
}
|
|
2031
|
+
catch (e) {
|
|
2032
|
+
logError("brain_stats", e);
|
|
2033
|
+
return { content: [{ type: "text", text: `Failed to read Brain stats: ${e.message}` }] };
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
async function handleBrainExport(args) {
|
|
2037
|
+
const outPath = args?.outPath;
|
|
2038
|
+
if (!outPath)
|
|
2039
|
+
throw new Error("outPath is required");
|
|
2040
|
+
try {
|
|
2041
|
+
const bundle = getBrain().exportBundle({
|
|
2042
|
+
// Scoped to this project unless asked otherwise: exporting every project's memories
|
|
2043
|
+
// by default is how a bundle meant for one teammate ends up carrying another client's
|
|
2044
|
+
// codebase notes with it.
|
|
2045
|
+
projectId: args?.allProjects === true ? undefined : deriveProjectId(),
|
|
2046
|
+
domain: typeof args?.domain === "string" && args.domain.trim() ? args.domain.trim() : undefined,
|
|
2047
|
+
includeStale: args?.includeStale === true,
|
|
2048
|
+
});
|
|
2049
|
+
const { resolved } = safeResolvePath(process.cwd(), outPath);
|
|
2050
|
+
fs.mkdirSync(path.dirname(resolved), { recursive: true });
|
|
2051
|
+
fs.writeFileSync(resolved, bundle.text, "utf8");
|
|
2052
|
+
const staleNote = bundle.skippedStale > 0
|
|
2053
|
+
? ` Skipped ${bundle.skippedStale} stale memor${bundle.skippedStale === 1 ? "y" : "ies"} (pass includeStale:true to export those too).`
|
|
2054
|
+
: "";
|
|
2055
|
+
return { content: [{ type: "text", text: `Exported ${bundle.count} memor${bundle.count === 1 ? "y" : "ies"} to ${outPath}.${staleNote}` }] };
|
|
2056
|
+
}
|
|
2057
|
+
catch (e) {
|
|
2058
|
+
logError("brain_export", e);
|
|
2059
|
+
return { content: [{ type: "text", text: `Failed to export Brain: ${e.message}` }] };
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
async function handleBrainImport(args) {
|
|
2063
|
+
const bundlePath = args?.path;
|
|
2064
|
+
if (!bundlePath)
|
|
2065
|
+
throw new Error("path is required");
|
|
2066
|
+
try {
|
|
2067
|
+
const { resolved } = safeResolvePath(process.cwd(), bundlePath);
|
|
2068
|
+
const text = fs.readFileSync(resolved, "utf8");
|
|
2069
|
+
const result = getBrain().importBundle(text);
|
|
2070
|
+
return { content: [{ type: "text", text: result.message }] };
|
|
2071
|
+
}
|
|
2072
|
+
catch (e) {
|
|
2073
|
+
logError("brain_import", e);
|
|
2074
|
+
return { content: [{ type: "text", text: `Failed to import Brain bundle: ${e.message}` }] };
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
1846
2077
|
async function handleVerifyMemory(args) {
|
|
1847
2078
|
const ids = Array.isArray(args?.ids) ? args.ids.filter((id) => typeof id === "string" && id) : [];
|
|
1848
2079
|
const semanticDiff = args?.semanticDiff === true;
|
|
@@ -1904,7 +2135,7 @@ async function handleGetRoutingAdvice(args) {
|
|
|
1904
2135
|
async function handleAutoHeal(args) {
|
|
1905
2136
|
const apply = !!args?.apply;
|
|
1906
2137
|
try {
|
|
1907
|
-
const { performAutoHeal: heal } = await import("../cli/lemma-proxy
|
|
2138
|
+
const { performAutoHeal: heal } = await import("../cli/lemma-proxy");
|
|
1908
2139
|
const res = await heal(apply);
|
|
1909
2140
|
return { content: [{ type: "text", text: JSON.stringify(res, null, 2) }] };
|
|
1910
2141
|
}
|
|
@@ -2030,7 +2261,7 @@ async function handleReadWorkspaceFile(args) {
|
|
|
2030
2261
|
`If you no longer hold that copy, re-fetch with force:true.`,
|
|
2031
2262
|
``,
|
|
2032
2263
|
delta.body,
|
|
2033
|
-
].join("\n"),
|
|
2264
|
+
].join("\n") + formatRecallNote(filePath),
|
|
2034
2265
|
},
|
|
2035
2266
|
],
|
|
2036
2267
|
};
|
|
@@ -2039,7 +2270,7 @@ async function handleReadWorkspaceFile(args) {
|
|
|
2039
2270
|
}
|
|
2040
2271
|
recordSent(resolved, view, dedup.hash, content);
|
|
2041
2272
|
warmNeighbors(workspaceRoot, resolved);
|
|
2042
|
-
return { content: [{ type: "text", text: rangeHeader + content }] };
|
|
2273
|
+
return { content: [{ type: "text", text: rangeHeader + content + formatRecallNote(filePath) }] };
|
|
2043
2274
|
}
|
|
2044
2275
|
catch (err) {
|
|
2045
2276
|
logError("read_workspace_file", err);
|
|
@@ -2129,6 +2360,46 @@ function formatBlastRadiusNote(result) {
|
|
|
2129
2360
|
const failedIds = result.failedHits.map((h) => h.id).join(", ");
|
|
2130
2361
|
return `${base}\n⚠️ ${result.failedHits.length} of those document a PRIOR ATTEMPT THAT FAILED on related code: ${failedIds}. Review before continuing down this path.`;
|
|
2131
2362
|
}
|
|
2363
|
+
/**
|
|
2364
|
+
* The read-side counterpart to formatBlastRadiusNote.
|
|
2365
|
+
*
|
|
2366
|
+
* Fase E made the write path proactive: a tool that stales memories says so on the spot.
|
|
2367
|
+
* The read path stayed entirely opt-in — the Brain only spoke when the agent remembered to
|
|
2368
|
+
* call search_memory, which is exactly the moment an agent that doesn't know a memory exists
|
|
2369
|
+
* has no reason to. This closes that asymmetry: reading code the Brain already has notes on
|
|
2370
|
+
* surfaces them, including any documented dead end, before the investigation restarts from
|
|
2371
|
+
* scratch.
|
|
2372
|
+
*
|
|
2373
|
+
* Same rules as the write-side note: advisory only, never blocks, never mutates, and adds no
|
|
2374
|
+
* tool schema (it enriches an existing response), so it costs nothing per turn. It reports
|
|
2375
|
+
* ids rather than content — pulling whole memories into every file read would spend far more
|
|
2376
|
+
* context than it saves; search_memory or verify_memory fetches the ones that matter.
|
|
2377
|
+
*/
|
|
2378
|
+
const _recallNoted = new Set();
|
|
2379
|
+
function formatRecallNote(filePath, symbolName) {
|
|
2380
|
+
try {
|
|
2381
|
+
const result = getBrain().findBlastRadius(filePath, symbolName);
|
|
2382
|
+
if (result.hits.length === 0)
|
|
2383
|
+
return "";
|
|
2384
|
+
// Repeating the identical note on every read of the same file is nagging, not signal.
|
|
2385
|
+
// Keyed by the memory set, so a note reappears when the set genuinely changes.
|
|
2386
|
+
const ids = result.hits.map((h) => h.id).sort();
|
|
2387
|
+
const key = `${path.resolve(filePath)}::${symbolName || ""}::${ids.join(",")}`;
|
|
2388
|
+
if (_recallNoted.has(key))
|
|
2389
|
+
return "";
|
|
2390
|
+
_recallNoted.add(key);
|
|
2391
|
+
const subject = symbolName ? `\`${symbolName}\`` : "this file";
|
|
2392
|
+
const base = `\n\n🧠 The Brain already has ${result.hits.length} memor${result.hits.length === 1 ? "y" : "ies"} about ${subject}: ${ids.join(", ")}. Call verify_memory on them before investigating from scratch.`;
|
|
2393
|
+
if (result.failedHits.length === 0)
|
|
2394
|
+
return base;
|
|
2395
|
+
const failedIds = result.failedHits.map((h) => h.id).join(", ");
|
|
2396
|
+
return `${base}\n⚠️ ${result.failedHits.length} of those document an approach that was tried here and FAILED: ${failedIds}. Read those first so you don't repeat it.`;
|
|
2397
|
+
}
|
|
2398
|
+
catch {
|
|
2399
|
+
// A recall note must never be the reason a file read fails.
|
|
2400
|
+
return "";
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2132
2403
|
async function applyMatch(match, filePath, resolved, originalContent, searchContent, replaceContent) {
|
|
2133
2404
|
let updatedContent;
|
|
2134
2405
|
if (match.strategy === "exact" && match.charStart !== undefined && match.charEnd !== undefined) {
|
|
@@ -2694,11 +2965,27 @@ function buildLocalOnboarding(cwd) {
|
|
|
2694
2965
|
catch { /* brain unavailable */ }
|
|
2695
2966
|
return lines.join("\n");
|
|
2696
2967
|
}
|
|
2968
|
+
// Re-exported for callers/tests that already import detectExpectedProjectName from here —
|
|
2969
|
+
// the actual implementation lives in ../utils/ProjectIdentity, shared with the proxy daemon
|
|
2970
|
+
// (src/cli/lemma-proxy.ts) so both sides compute "project name" exactly one way.
|
|
2971
|
+
export const detectExpectedProjectName = detectProjectName;
|
|
2697
2972
|
async function handleGetProjectOnboarding(_args) {
|
|
2698
2973
|
const cwd = process.cwd();
|
|
2699
2974
|
try {
|
|
2700
2975
|
const port = getProxyPort();
|
|
2701
|
-
|
|
2976
|
+
// The proxy daemon is one global process per machine, tracked by a single shared
|
|
2977
|
+
// ~/.lemma-cache/proxy.port file — every MCP client on the box points at whichever
|
|
2978
|
+
// daemon happens to be listening there, regardless of which project it's actually
|
|
2979
|
+
// running in. Its project identity is fixed to whatever cwd IT was started from, not
|
|
2980
|
+
// ours. Without expectedProject, a daemon started for a different project answers with
|
|
2981
|
+
// THAT project's stack/files/memories — a real cross-project data leak, not a cosmetic
|
|
2982
|
+
// bug. The route only returns `markdown` when this matches; otherwise we fall through
|
|
2983
|
+
// to the local (always correctly-scoped) generator below.
|
|
2984
|
+
const expectedProject = detectExpectedProjectName(cwd);
|
|
2985
|
+
const response = await axios.get(`http://localhost:${port}/api/project/onboarding`, {
|
|
2986
|
+
timeout: 2000,
|
|
2987
|
+
params: { expectedProject },
|
|
2988
|
+
});
|
|
2702
2989
|
if (response.data?.markdown) {
|
|
2703
2990
|
return { content: [{ type: "text", text: response.data.markdown }] };
|
|
2704
2991
|
}
|
|
@@ -3223,30 +3510,31 @@ async function handleBatchToolCalls(args) {
|
|
|
3223
3510
|
// ── TurboSqueeze ─────────────────────────────────────────────────
|
|
3224
3511
|
async function handleTurboSqueeze(args) {
|
|
3225
3512
|
const text = args?.text;
|
|
3226
|
-
const
|
|
3227
|
-
const
|
|
3513
|
+
const wantStripComments = args?.stripComments !== false;
|
|
3514
|
+
const wantStripImports = args?.stripImports !== false;
|
|
3228
3515
|
const compactJson = args?.compactJson !== false;
|
|
3229
3516
|
if (!text)
|
|
3230
3517
|
throw new Error("text is required");
|
|
3518
|
+
// Delegates to the same stripComments/stripImports/compactWhitespace primitives
|
|
3519
|
+
// squeeze_prompt and the proxy's own cache-miss path use — this used to be a second,
|
|
3520
|
+
// independent regex implementation of the same job that had drifted out of sync: its
|
|
3521
|
+
// naive `//.*$` comment strip mangled any line containing a URL (http://, https://),
|
|
3522
|
+
// a case the shared stripComments already guards against. One implementation now.
|
|
3231
3523
|
let squeezed = text;
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
squeezed = squeezed
|
|
3236
|
-
|
|
3237
|
-
//
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
//
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
squeezed = squeezed.replace(/^require\(['"][\w@\/\.-]+['"]\);?\s*$/gm, '');
|
|
3247
|
-
}
|
|
3248
|
-
// Compact JSON
|
|
3249
|
-
if (compactJson) {
|
|
3524
|
+
if (wantStripComments)
|
|
3525
|
+
squeezed = stripComments(squeezed);
|
|
3526
|
+
if (wantStripImports)
|
|
3527
|
+
squeezed = stripImports(squeezed);
|
|
3528
|
+
squeezed = compactWhitespace(squeezed);
|
|
3529
|
+
// Compact JSON — the one genuinely turbosqueeze-specific step, kept as-is, but only when
|
|
3530
|
+
// the input actually looks like JSON. Pre-existing bug found while consolidating this
|
|
3531
|
+
// function: these regexes ran unconditionally whenever compactJson wasn't explicitly
|
|
3532
|
+
// false, so ordinary code went through them too — `{ foo }` in an import statement came
|
|
3533
|
+
// out as `{foo}`, and the same regexes would just as happily squash braces in real
|
|
3534
|
+
// control-flow code. Gate on the input's own shape instead of trusting the caller only
|
|
3535
|
+
// ever sets compactJson for genuine JSON.
|
|
3536
|
+
const looksLikeJson = /^\s*[[{]/.test(squeezed);
|
|
3537
|
+
if (compactJson && looksLikeJson) {
|
|
3250
3538
|
squeezed = squeezed.replace(/"\s*:\s*/g, '":');
|
|
3251
3539
|
squeezed = squeezed.replace(/,\s*"/g, ',"');
|
|
3252
3540
|
squeezed = squeezed.replace(/\[\s+/g, '[');
|
|
@@ -3259,7 +3547,7 @@ async function handleTurboSqueeze(args) {
|
|
|
3259
3547
|
const ratio = text.length > 0 ? ((1 - squeezed.length / text.length) * 100).toFixed(1) : "0";
|
|
3260
3548
|
const saved = Math.max(0, text.length - squeezed.length);
|
|
3261
3549
|
try {
|
|
3262
|
-
const { reportSavings } = await import("../utils/reportSavings
|
|
3550
|
+
const { reportSavings } = await import("../utils/reportSavings");
|
|
3263
3551
|
reportSavings({ source: "contextSqueeze", charsBefore: text.length, charsAfter: squeezed.length, toolName: "turbosqueeze" });
|
|
3264
3552
|
}
|
|
3265
3553
|
catch { }
|
|
@@ -3304,7 +3592,7 @@ async function handleCompressContext(args) {
|
|
|
3304
3592
|
...recent,
|
|
3305
3593
|
];
|
|
3306
3594
|
try {
|
|
3307
|
-
const { reportSavings } = await import("../utils/reportSavings
|
|
3595
|
+
const { reportSavings } = await import("../utils/reportSavings");
|
|
3308
3596
|
reportSavings({ source: "historyPrune", tokens: tokensSaved, toolName: "compress_context" });
|
|
3309
3597
|
}
|
|
3310
3598
|
catch { }
|
|
@@ -3331,7 +3619,7 @@ async function handleSmarterCache(args) {
|
|
|
3331
3619
|
const responseText = topHit.response;
|
|
3332
3620
|
const tokensSaved = Math.floor(responseText.length / 4);
|
|
3333
3621
|
try {
|
|
3334
|
-
const { reportSavings } = await import("../utils/reportSavings
|
|
3622
|
+
const { reportSavings } = await import("../utils/reportSavings");
|
|
3335
3623
|
reportSavings({ source: "cache", tokens: tokensSaved, toolName: "smarter_cache", query: query.substring(0, 100) });
|
|
3336
3624
|
}
|
|
3337
3625
|
catch { }
|
|
@@ -5047,7 +5335,7 @@ async function handleGetSymbolSurgicalContext(args) {
|
|
|
5047
5335
|
filePath
|
|
5048
5336
|
});
|
|
5049
5337
|
return {
|
|
5050
|
-
content: [{ type: "text", text: output }]
|
|
5338
|
+
content: [{ type: "text", text: output + formatRecallNote(filePath, symbolName) }]
|
|
5051
5339
|
};
|
|
5052
5340
|
}
|
|
5053
5341
|
catch (err) {
|
|
@@ -5228,7 +5516,7 @@ async function handleSmartFileSlice(args) {
|
|
|
5228
5516
|
resultText += `${i + 1}: ${lines[i]}\n`;
|
|
5229
5517
|
}
|
|
5230
5518
|
});
|
|
5231
|
-
return { content: [{ type: "text", text: resultText }] };
|
|
5519
|
+
return { content: [{ type: "text", text: resultText + formatRecallNote(filePath) }] };
|
|
5232
5520
|
}
|
|
5233
5521
|
catch (e) {
|
|
5234
5522
|
return { content: [{ type: "text", text: `Error slicing file: ${e.message}` }] };
|
|
@@ -5256,7 +5544,7 @@ function autoStoreGreenTests(command, workspaceRoot) {
|
|
|
5256
5544
|
const domain = deriveDomainForFile(changed[0]);
|
|
5257
5545
|
const query = `tests passing after changes to ${changed.slice(0, 5).join(", ")}${changed.length > 5 ? ` and ${changed.length - 5} more file(s)` : ""}`;
|
|
5258
5546
|
const response = `\`${command}\` passed with these files changed (uncommitted at capture time):\n${changed.join("\n")}`;
|
|
5259
|
-
const storeRes = getBrain().store(query, response, "test_oracle_auto", 0.92, changed, undefined, "confirmed", undefined, undefined, domain);
|
|
5547
|
+
const storeRes = getBrain().store(query, response, "test_oracle_auto", 0.92, changed, undefined, "confirmed", undefined, undefined, domain, undefined, { source: "auto-test" });
|
|
5260
5548
|
if (!storeRes.stored)
|
|
5261
5549
|
return "";
|
|
5262
5550
|
return `\n\n[Lemma] Auto-captured this green state in Brain (${changed.length} file(s), tagged confirmed) — search_memory will surface it, and will flag it stale the moment any of these files change again.`;
|