@noorm/marie-cli 0.1.18 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -15
- package/SENTINEL.md +4 -7
- package/dist/cli-new/components/App.js +16 -63
- package/dist/cli-new/components/App.js.map +1 -1
- package/dist/cli-new/components/ApprovalDialog.js +2 -1
- package/dist/cli-new/components/ApprovalDialog.js.map +1 -1
- package/dist/cli-new/components/Banner.js +4 -3
- package/dist/cli-new/components/Banner.js.map +1 -1
- package/dist/cli-new/components/ChatArea.js +6 -7
- package/dist/cli-new/components/ChatArea.js.map +1 -1
- package/dist/cli-new/components/Header.js +13 -7
- package/dist/cli-new/components/Header.js.map +1 -1
- package/dist/cli-new/components/InputArea.js +73 -12
- package/dist/cli-new/components/InputArea.js.map +1 -1
- package/dist/cli-new/components/MessageBubble.js +26 -18
- package/dist/cli-new/components/MessageBubble.js.map +1 -1
- package/dist/cli-new/components/SessionSwitcher.js +4 -7
- package/dist/cli-new/components/SessionSwitcher.js.map +1 -1
- package/dist/cli-new/components/SetupWizard.js +80 -257
- package/dist/cli-new/components/SetupWizard.js.map +1 -1
- package/dist/cli-new/components/ToolCallDisplay.js +20 -5
- package/dist/cli-new/components/ToolCallDisplay.js.map +1 -1
- package/dist/cli-new/components/WizardSteps.js +22 -0
- package/dist/cli-new/components/WizardSteps.js.map +1 -0
- package/dist/cli-new/constants/SetupConstants.js +42 -0
- package/dist/cli-new/constants/SetupConstants.js.map +1 -0
- package/dist/cli-new/hooks/useGit.js +19 -62
- package/dist/cli-new/hooks/useGit.js.map +1 -1
- package/dist/cli-new/hooks/useMarie.js +26 -18
- package/dist/cli-new/hooks/useMarie.js.map +1 -1
- package/dist/cli-new/hooks/useSessions.js +1 -1
- package/dist/cli-new/hooks/useSessions.js.map +1 -1
- package/dist/cli-new/hooks/useSetupWizard.js +88 -0
- package/dist/cli-new/hooks/useSetupWizard.js.map +1 -0
- package/dist/cli-new/hooks/useUpdateCheck.js +4 -3
- package/dist/cli-new/hooks/useUpdateCheck.js.map +1 -1
- package/dist/cli-new/index.js +2 -4
- package/dist/cli-new/index.js.map +1 -1
- package/dist/cli-new/services/CommandService.js +104 -0
- package/dist/cli-new/services/CommandService.js.map +1 -0
- package/dist/cli-new/services/GitService.js +91 -0
- package/dist/cli-new/services/GitService.js.map +1 -0
- package/dist/cli-new/services/MarieService.js +77 -0
- package/dist/cli-new/services/MarieService.js.map +1 -0
- package/dist/cli-new/services/auth-server.js +128 -0
- package/dist/cli-new/services/auth-server.js.map +1 -0
- package/dist/cli-new/utils/version.js +24 -0
- package/dist/cli-new/utils/version.js.map +1 -0
- package/dist/monolith/adapters/CliMarieAdapter.js +12 -11
- package/dist/monolith/adapters/CliMarieAdapter.js.map +1 -1
- package/dist/monolith/cli/CliFileSystemPort.js +17 -3
- package/dist/monolith/cli/CliFileSystemPort.js.map +1 -1
- package/dist/monolith/cli/MarieToolDefinitionsCLI.js +39 -31
- package/dist/monolith/cli/MarieToolDefinitionsCLI.js.map +1 -1
- package/dist/monolith/cli/index.js +5 -20
- package/dist/monolith/cli/index.js.map +1 -1
- package/dist/monolith/cli/services/JoyAutomationServiceCLI.js +15 -62
- package/dist/monolith/cli/services/JoyAutomationServiceCLI.js.map +1 -1
- package/dist/monolith/cli/storage.js +142 -72
- package/dist/monolith/cli/storage.js.map +1 -1
- package/dist/monolith/domain/joy/RitualService.js +44 -46
- package/dist/monolith/domain/joy/RitualService.js.map +1 -1
- package/dist/monolith/domain/marie/MarieCortex.js +148 -0
- package/dist/monolith/domain/marie/MarieCortex.js.map +1 -0
- package/dist/monolith/domain/marie/PersonalityRenderer.js +97 -0
- package/dist/monolith/domain/marie/PersonalityRenderer.js.map +1 -0
- package/dist/monolith/infrastructure/Configuration.js +68 -0
- package/dist/monolith/infrastructure/Configuration.js.map +1 -0
- package/dist/monolith/infrastructure/CoreInfrastructure.js +204 -0
- package/dist/monolith/infrastructure/CoreInfrastructure.js.map +1 -0
- package/dist/monolith/infrastructure/ai/agents/MarieAscendant.js +3 -3
- package/dist/monolith/infrastructure/ai/agents/MarieAscendant.js.map +1 -1
- package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js +6 -27
- package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js.map +1 -1
- package/dist/monolith/infrastructure/ai/context/ContextManager.js +142 -131
- package/dist/monolith/infrastructure/ai/context/ContextManager.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieEngine.js +115 -1077
- package/dist/monolith/infrastructure/ai/core/MarieEngine.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieEventDispatcher.js +1 -37
- package/dist/monolith/infrastructure/ai/core/MarieEventDispatcher.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieLockManager.js +6 -1
- package/dist/monolith/infrastructure/ai/core/MarieLockManager.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js +172 -221
- package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js +292 -141
- package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js +331 -614
- package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js.map +1 -1
- package/dist/monolith/infrastructure/ai/core/MarieVitality.js +238 -0
- package/dist/monolith/infrastructure/ai/core/MarieVitality.js.map +1 -0
- package/dist/monolith/infrastructure/ai/core/SessionLogService.js +9 -2
- package/dist/monolith/infrastructure/ai/core/SessionLogService.js.map +1 -1
- package/dist/monolith/infrastructure/ai/providers/AIProvider.js +402 -1
- package/dist/monolith/infrastructure/ai/providers/AIProvider.js.map +1 -1
- package/dist/monolith/infrastructure/ai/providers/DreamBeesProvider.js +114 -0
- package/dist/monolith/infrastructure/ai/providers/DreamBeesProvider.js.map +1 -0
- package/dist/monolith/infrastructure/ai/providers/OpenRouterProvider.js +426 -392
- package/dist/monolith/infrastructure/ai/providers/OpenRouterProvider.js.map +1 -1
- package/dist/monolith/infrastructure/ai/providers/OpenRouterStreamParser.js +235 -241
- package/dist/monolith/infrastructure/ai/providers/OpenRouterStreamParser.js.map +1 -1
- package/dist/monolith/infrastructure/ai/workerAi.js +185 -0
- package/dist/monolith/infrastructure/ai/workerAi.js.map +1 -0
- package/dist/monolith/infrastructure/config/ConfigService.js +216 -503
- package/dist/monolith/infrastructure/config/ConfigService.js.map +1 -1
- package/dist/monolith/infrastructure/joy/CognitiveRituals.js +4 -165
- package/dist/monolith/infrastructure/joy/CognitiveRituals.js.map +1 -1
- package/dist/monolith/infrastructure/joy/JoyTools.js +14 -47
- package/dist/monolith/infrastructure/joy/JoyTools.js.map +1 -1
- package/dist/monolith/infrastructure/persistence/MarieMindAutonomics.js +4 -0
- package/dist/monolith/infrastructure/persistence/MarieMindAutonomics.js.map +1 -0
- package/dist/monolith/infrastructure/persistence/MarieMindEngine.js +11 -0
- package/dist/monolith/infrastructure/persistence/MarieMindEngine.js.map +1 -0
- package/dist/monolith/infrastructure/persistence/NoormmeAutonomics.js +123 -106
- package/dist/monolith/infrastructure/persistence/NoormmeAutonomics.js.map +1 -1
- package/dist/monolith/infrastructure/persistence/NoormmeEngine.js +508 -63
- package/dist/monolith/infrastructure/persistence/NoormmeEngine.js.map +1 -1
- package/dist/monolith/infrastructure/persistence/NoormmeSchema.js +68 -39
- package/dist/monolith/infrastructure/persistence/NoormmeSchema.js.map +1 -1
- package/dist/monolith/infrastructure/persistence/NoormmeSeeder.js +80 -67
- package/dist/monolith/infrastructure/persistence/NoormmeSeeder.js.map +1 -1
- package/dist/monolith/infrastructure/persistence/NoormmeTools.js +122 -75
- package/dist/monolith/infrastructure/persistence/NoormmeTools.js.map +1 -1
- package/dist/monolith/infrastructure/services/MarieMemoryStore.js +133 -134
- package/dist/monolith/infrastructure/services/MarieMemoryStore.js.map +1 -1
- package/dist/monolith/infrastructure/tools/MarieToolDefinitions.js +6 -30
- package/dist/monolith/infrastructure/tools/MarieToolDefinitions.js.map +1 -1
- package/dist/monolith/infrastructure/tools/PureStreamParser.js +68 -80
- package/dist/monolith/infrastructure/tools/PureStreamParser.js.map +1 -1
- package/dist/monolith/infrastructure/tools/SharedToolDefinitions.js +12 -11
- package/dist/monolith/infrastructure/tools/SharedToolDefinitions.js.map +1 -1
- package/dist/monolith/infrastructure/tools/SovereignTools.js +326 -0
- package/dist/monolith/infrastructure/tools/SovereignTools.js.map +1 -0
- package/dist/monolith/infrastructure/tools/ToolRegistry.js +45 -26
- package/dist/monolith/infrastructure/tools/ToolRegistry.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/AnalysisTools.js +39 -153
- package/dist/monolith/infrastructure/tools/definitions/AnalysisTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/AutomationTools.js +31 -46
- package/dist/monolith/infrastructure/tools/definitions/AutomationTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/ContextTools.js +41 -13
- package/dist/monolith/infrastructure/tools/definitions/ContextTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/CoreTools.js +10 -14
- package/dist/monolith/infrastructure/tools/definitions/CoreTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/DiagnosticTools.js +39 -70
- package/dist/monolith/infrastructure/tools/definitions/DiagnosticTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/NavigationTools.js +30 -181
- package/dist/monolith/infrastructure/tools/definitions/NavigationTools.js.map +1 -1
- package/dist/monolith/infrastructure/tools/definitions/PlanningTools.js +12 -9
- package/dist/monolith/infrastructure/tools/definitions/PlanningTools.js.map +1 -1
- package/dist/monolith/plumbing/Plumbing.js +238 -0
- package/dist/monolith/plumbing/Plumbing.js.map +1 -0
- package/dist/monolith/plumbing/PlumbingAnalysis.js +109 -0
- package/dist/monolith/plumbing/PlumbingAnalysis.js.map +1 -0
- package/dist/monolith/plumbing/PlumbingSystem.js +169 -0
- package/dist/monolith/plumbing/PlumbingSystem.js.map +1 -0
- package/dist/monolith/plumbing/analysis/ComplexityService.js +30 -34
- package/dist/monolith/plumbing/analysis/ComplexityService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/DependencyService.js +55 -44
- package/dist/monolith/plumbing/analysis/DependencyService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/DiscoveryService.js +40 -42
- package/dist/monolith/plumbing/analysis/DiscoveryService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/JoyMapService.js +52 -56
- package/dist/monolith/plumbing/analysis/JoyMapService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/LintService.js +118 -118
- package/dist/monolith/plumbing/analysis/LintService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/MarieSentinelService.js +278 -268
- package/dist/monolith/plumbing/analysis/MarieSentinelService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/QualityGuardrailService.js +116 -114
- package/dist/monolith/plumbing/analysis/QualityGuardrailService.js.map +1 -1
- package/dist/monolith/plumbing/analysis/SurgicalMender.js +57 -59
- package/dist/monolith/plumbing/analysis/SurgicalMender.js.map +1 -1
- package/dist/monolith/plumbing/analysis/TestService.js +89 -89
- package/dist/monolith/plumbing/analysis/TestService.js.map +1 -1
- package/dist/monolith/plumbing/filesystem/FileService.js +123 -195
- package/dist/monolith/plumbing/filesystem/FileService.js.map +1 -1
- package/dist/monolith/plumbing/filesystem/PathResolver.js +7 -8
- package/dist/monolith/plumbing/filesystem/PathResolver.js.map +1 -1
- package/dist/monolith/plumbing/git/GitService.js +4 -4
- package/dist/monolith/plumbing/git/GitService.js.map +1 -1
- package/dist/monolith/plumbing/lsp/SymbolService.js +5 -34
- package/dist/monolith/plumbing/lsp/SymbolService.js.map +1 -1
- package/dist/monolith/plumbing/terminal/ProcessRegistry.js +20 -22
- package/dist/monolith/plumbing/terminal/ProcessRegistry.js.map +1 -1
- package/dist/monolith/plumbing/terminal/TerminalService.js +127 -141
- package/dist/monolith/plumbing/terminal/TerminalService.js.map +1 -1
- package/dist/monolith/plumbing/utils/EnvironmentUtils.js +3 -23
- package/dist/monolith/plumbing/utils/EnvironmentUtils.js.map +1 -1
- package/dist/monolith/plumbing/utils/JsonUtils.js +252 -311
- package/dist/monolith/plumbing/utils/JsonUtils.js.map +1 -1
- package/dist/monolith/plumbing/utils/PlumbingCore.js +549 -0
- package/dist/monolith/plumbing/utils/PlumbingCore.js.map +1 -0
- package/dist/monolith/plumbing/utils/PrefixTree.js +61 -114
- package/dist/monolith/plumbing/utils/PrefixTree.js.map +1 -1
- package/dist/monolith/plumbing/utils/StreamTagDetector.js +89 -127
- package/dist/monolith/plumbing/utils/StreamTagDetector.js.map +1 -1
- package/dist/monolith/plumbing/utils/StringUtils.js +87 -89
- package/dist/monolith/plumbing/utils/StringUtils.js.map +1 -1
- package/dist/monolith/runtime/MarieRuntime.js +76 -499
- package/dist/monolith/runtime/MarieRuntime.js.map +1 -1
- package/dist/monolith/runtime/RuntimeAdapterBase.js +1 -1
- package/dist/monolith/runtime/RuntimeAdapterBase.js.map +1 -1
- package/dist/monolith/runtime/providerFactory.js +1 -7
- package/dist/monolith/runtime/providerFactory.js.map +1 -1
- package/dist/monolith/services/HealthService.js +29 -32
- package/dist/monolith/services/HealthService.js.map +1 -1
- package/dist/monolith/services/JoyAutomationService.js +58 -95
- package/dist/monolith/services/JoyAutomationService.js.map +1 -1
- package/dist/monolith/services/MarieAutomationService.js +59 -0
- package/dist/monolith/services/MarieAutomationService.js.map +1 -0
- package/dist/monolith/services/MarieGhostService.js +46 -173
- package/dist/monolith/services/MarieGhostService.js.map +1 -1
- package/dist/monolith/services/MarieServices.js +102 -0
- package/dist/monolith/services/MarieServices.js.map +1 -0
- package/dist/monolith/services/MarieTypes.js +2 -0
- package/dist/monolith/services/MarieTypes.js.map +1 -0
- package/dist/monolith/services/UpdateService.js +47 -49
- package/dist/monolith/services/UpdateService.js.map +1 -1
- package/dist/prompts.js +11 -5
- package/dist/prompts.js.map +1 -1
- package/dist/test_prefix_tree.js +9 -9
- package/dist/test_prefix_tree.js.map +1 -1
- package/package.json +18 -89
- package/run_test.js +5 -0
- package/.marie_visual_verify_1771225696548/progress_bar_check.txt +0 -1
- package/dist/extension.cjs +0 -1155
- package/dist/extension.js +0 -474
- package/dist/extension.js.map +0 -1
- package/dist/monolith/adapters/VscodeMarieAdapter.js +0 -81
- package/dist/monolith/adapters/VscodeMarieAdapter.js.map +0 -1
- package/dist/monolith/infrastructure/ai/core/GhostPort.js +0 -2
- package/dist/monolith/infrastructure/ai/core/GhostPort.js.map +0 -1
- package/dist/monolith/infrastructure/ai/core/VscodeFileSystemPort.js +0 -33
- package/dist/monolith/infrastructure/ai/core/VscodeFileSystemPort.js.map +0 -1
- package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js +0 -154
- package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js.map +0 -1
- package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js +0 -214
- package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js.map +0 -1
- package/dist/monolith/plumbing/ui/DecorationService.js +0 -54
- package/dist/monolith/plumbing/ui/DecorationService.js.map +0 -1
- package/dist/monolith/services/JoyLogService.js +0 -48
- package/dist/monolith/services/JoyLogService.js.map +0 -1
- package/dist/monolith/services/JoyService.js +0 -209
- package/dist/monolith/services/JoyService.js.map +0 -1
- package/dist/monolith/services/MarieSCMProvider.js +0 -41
- package/dist/monolith/services/MarieSCMProvider.js.map +0 -1
- package/dist/webview-ui/main.css +0 -1
- package/dist/webview-ui/main.js +0 -108
- package/lint_output.txt +0 -705
- package/lint_output_v2.txt +0 -711
- package/test-mind-p6.sqlite +0 -0
- package/test-mind-p6.sqlite-shm +0 -0
- package/test-mind-p6.sqlite-wal +0 -0
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { levenshtein } from "./StringUtils.js";
|
|
2
|
+
const MAX_CACHE_SIZE = 1000;
|
|
2
3
|
/**
|
|
3
|
-
* Prefix Tree (Trie) for efficient tag detection.
|
|
4
|
+
* Creates a Prefix Tree (Trie) for efficient tag detection.
|
|
4
5
|
* Provides O(k) complexity for finding tags where k = input length.
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
-
root = { children: new Map(), isEndOfTag: false };
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.insert(tag);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Insert a tag into the trie.
|
|
17
|
-
*/
|
|
18
|
-
insert(tag) {
|
|
19
|
-
let node = this.root;
|
|
7
|
+
export function createPrefixTree(tags) {
|
|
8
|
+
const root = { children: new Map(), isEndOfTag: false };
|
|
9
|
+
const editDistanceCache = new Map();
|
|
10
|
+
// Initialize
|
|
11
|
+
for (const tag of tags) {
|
|
12
|
+
let node = root;
|
|
20
13
|
for (const char of tag) {
|
|
21
14
|
if (!node.children.has(char)) {
|
|
22
15
|
node.children.set(char, { children: new Map(), isEndOfTag: false });
|
|
@@ -26,128 +19,82 @@ export class PrefixTree {
|
|
|
26
19
|
node.isEndOfTag = true;
|
|
27
20
|
node.tag = tag;
|
|
28
21
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* Returns { index: number, tag: string } if found, null otherwise.
|
|
32
|
-
* Optimized with early-exit for O(k) performance.
|
|
33
|
-
*/
|
|
34
|
-
findEarliestTag(text) {
|
|
35
|
-
let earliestIndex = Infinity;
|
|
36
|
-
let earliestTag = "";
|
|
37
|
-
// Try to match from each position in the text (with early-exit)
|
|
38
|
-
for (let startIdx = 0; startIdx < text.length; startIdx++) {
|
|
39
|
-
// Early-exit: if we already found a tag at an earlier position, stop
|
|
40
|
-
if (startIdx >= earliestIndex) {
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
const result = this.matchFromPosition(text, startIdx);
|
|
44
|
-
if (result && result.index < earliestIndex) {
|
|
45
|
-
earliestIndex = result.index;
|
|
46
|
-
earliestTag = result.tag;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return earliestTag ? { index: earliestIndex, tag: earliestTag } : null;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Match a tag starting from a specific position.
|
|
53
|
-
* Returns the SHORTEST matching tag (to handle prefix overlaps correctly).
|
|
54
|
-
*/
|
|
55
|
-
matchFromPosition(text, startIdx) {
|
|
56
|
-
let node = this.root;
|
|
22
|
+
function matchFromPosition(text, startIdx) {
|
|
23
|
+
let node = root;
|
|
57
24
|
let firstMatch = null;
|
|
58
25
|
for (let i = startIdx; i < text.length; i++) {
|
|
59
26
|
const char = text[i];
|
|
60
|
-
if (!node.children.has(char))
|
|
61
|
-
// Can't continue matching
|
|
27
|
+
if (!node.children.has(char))
|
|
62
28
|
break;
|
|
63
|
-
}
|
|
64
29
|
node = node.children.get(char);
|
|
65
30
|
if (node.isEndOfTag && !firstMatch) {
|
|
66
|
-
// Found first complete tag at this position
|
|
67
31
|
firstMatch = node.tag;
|
|
68
|
-
// Return immediately to get the shortest match
|
|
69
32
|
return { index: startIdx, tag: firstMatch };
|
|
70
33
|
}
|
|
71
34
|
}
|
|
72
35
|
return null;
|
|
73
36
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* Returns the length of the partial match (0 if none).
|
|
77
|
-
*/
|
|
78
|
-
findLongestPartialAtEnd(text) {
|
|
79
|
-
let maxPartialLength = 0;
|
|
80
|
-
// Try matching from each position toward the end
|
|
81
|
-
for (let startIdx = 0; startIdx < text.length; startIdx++) {
|
|
82
|
-
const partialLength = this.matchPartialFromPosition(text, startIdx);
|
|
83
|
-
if (partialLength > 0 && startIdx + partialLength === text.length) {
|
|
84
|
-
maxPartialLength = Math.max(maxPartialLength, partialLength);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return maxPartialLength;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Match a partial tag from a position, returns length of match.
|
|
91
|
-
*/
|
|
92
|
-
matchPartialFromPosition(text, startIdx) {
|
|
93
|
-
let node = this.root;
|
|
37
|
+
function matchPartialFromPosition(text, startIdx) {
|
|
38
|
+
let node = root;
|
|
94
39
|
let matchLength = 0;
|
|
95
40
|
for (let i = startIdx; i < text.length; i++) {
|
|
96
41
|
const char = text[i];
|
|
97
|
-
if (!node.children.has(char))
|
|
42
|
+
if (!node.children.has(char))
|
|
98
43
|
return matchLength;
|
|
99
|
-
}
|
|
100
44
|
node = node.children.get(char);
|
|
101
45
|
matchLength++;
|
|
102
|
-
if (node.isEndOfTag)
|
|
103
|
-
// This is a complete tag, not a partial
|
|
46
|
+
if (node.isEndOfTag)
|
|
104
47
|
return 0;
|
|
105
|
-
}
|
|
106
48
|
}
|
|
107
|
-
// We matched up to the end of text without completing a tag
|
|
108
49
|
return matchLength;
|
|
109
50
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
let distance = this.editDistanceCache.get(cacheKey);
|
|
122
|
-
if (distance === undefined) {
|
|
123
|
-
distance = this.editDistance(input, tag);
|
|
124
|
-
// Evict oldest half when cache exceeds max size
|
|
125
|
-
if (this.editDistanceCache.size >= PrefixTree.MAX_CACHE_SIZE) {
|
|
126
|
-
const keysToDelete = Array.from(this.editDistanceCache.keys()).slice(0, PrefixTree.MAX_CACHE_SIZE / 2);
|
|
127
|
-
for (const key of keysToDelete) {
|
|
128
|
-
this.editDistanceCache.delete(key);
|
|
129
|
-
}
|
|
51
|
+
return {
|
|
52
|
+
findEarliestTag(text) {
|
|
53
|
+
let earliestIndex = Infinity;
|
|
54
|
+
let earliestTag = "";
|
|
55
|
+
for (let startIdx = 0; startIdx < text.length; startIdx++) {
|
|
56
|
+
if (startIdx >= earliestIndex)
|
|
57
|
+
break;
|
|
58
|
+
const result = matchFromPosition(text, startIdx);
|
|
59
|
+
if (result && result.index < earliestIndex) {
|
|
60
|
+
earliestIndex = result.index;
|
|
61
|
+
earliestTag = result.tag;
|
|
130
62
|
}
|
|
131
|
-
this.editDistanceCache.set(cacheKey, distance);
|
|
132
63
|
}
|
|
133
|
-
|
|
134
|
-
|
|
64
|
+
return earliestTag ? { index: earliestIndex, tag: earliestTag } : null;
|
|
65
|
+
},
|
|
66
|
+
findLongestPartialAtEnd(text) {
|
|
67
|
+
let maxPartialLength = 0;
|
|
68
|
+
for (let startIdx = 0; startIdx < text.length; startIdx++) {
|
|
69
|
+
const partialLength = matchPartialFromPosition(text, startIdx);
|
|
70
|
+
if (partialLength > 0 && startIdx + partialLength === text.length) {
|
|
71
|
+
maxPartialLength = Math.max(maxPartialLength, partialLength);
|
|
72
|
+
}
|
|
135
73
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
74
|
+
return maxPartialLength;
|
|
75
|
+
},
|
|
76
|
+
findSimilarTags(input, maxDistance = 2) {
|
|
77
|
+
const similar = [];
|
|
78
|
+
for (const tag of tags) {
|
|
79
|
+
const cacheKey = `${input}:${tag}`;
|
|
80
|
+
let distance = editDistanceCache.get(cacheKey);
|
|
81
|
+
if (distance === undefined) {
|
|
82
|
+
distance = levenshtein(input, tag);
|
|
83
|
+
if (editDistanceCache.size >= MAX_CACHE_SIZE) {
|
|
84
|
+
const keysToDelete = Array.from(editDistanceCache.keys()).slice(0, MAX_CACHE_SIZE / 2);
|
|
85
|
+
for (const key of keysToDelete)
|
|
86
|
+
editDistanceCache.delete(key);
|
|
87
|
+
}
|
|
88
|
+
editDistanceCache.set(cacheKey, distance);
|
|
89
|
+
}
|
|
90
|
+
if (distance <= maxDistance)
|
|
91
|
+
similar.push(tag);
|
|
92
|
+
}
|
|
93
|
+
return similar;
|
|
94
|
+
},
|
|
95
|
+
clearCache() {
|
|
96
|
+
editDistanceCache.clear();
|
|
97
|
+
},
|
|
98
|
+
};
|
|
152
99
|
}
|
|
153
100
|
//# sourceMappingURL=PrefixTree.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrefixTree.js","sourceRoot":"","sources":["../../../../src/monolith/plumbing/utils/PrefixTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"PrefixTree.js","sourceRoot":"","sources":["../../../../src/monolith/plumbing/utils/PrefixTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAe/C,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAc;IAC7C,MAAM,IAAI,GAAa,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAClE,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEpD,aAAa;IACb,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,IAAI,GAAG,IAAI,CAAC;QAChB,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;YACtE,CAAC;YACD,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,GAA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|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* - 'tag': A full tag was found. The returned `text` is content BEFORE the tag. `tag` is the tag itself.
|
|
42
|
-
* The buffer will contain any remainder AFTER the tag for the next call.
|
|
43
|
-
* - 'incomplete': A partial tag was found at the end. `text` is the safe content before it.
|
|
44
|
-
* The buffer holds the partial tag.
|
|
45
|
-
* - 'content': No tags found. `text` Is the full content. Buffer is empty.
|
|
46
|
-
*/
|
|
47
|
-
process(chunk) {
|
|
48
|
-
this.buffer += chunk;
|
|
49
|
-
// --- Buffer Growth Safety ---
|
|
50
|
-
if (this.buffer.length > StreamTagDetector.MAX_BUFFER_SIZE) {
|
|
51
|
-
console.error("[Marie] StreamTagDetector buffer exceeded safety limit. Flushing.");
|
|
52
|
-
const flushed = this.buffer;
|
|
53
|
-
this.buffer = "";
|
|
54
|
-
return { type: "content", text: flushed };
|
|
55
|
-
}
|
|
56
|
-
// 1. Check if we have any FULL tags using prefix tree (O(k) complexity)
|
|
57
|
-
const tagMatch = this.prefixTree.findEarliestTag(this.buffer);
|
|
58
|
-
if (tagMatch) {
|
|
59
|
-
// Found a tag!
|
|
60
|
-
// Emit content up to tag
|
|
61
|
-
const content = this.buffer.substring(0, tagMatch.index);
|
|
62
|
-
// Remove content + tag from buffer, keep remainder
|
|
63
|
-
this.buffer = this.buffer.substring(tagMatch.index + tagMatch.tag.length);
|
|
64
|
-
console.log(`[Marie] Tag detected: ${tagMatch.tag} at index ${tagMatch.index}`);
|
|
65
|
-
return { type: "tag", text: content, tag: tagMatch.tag };
|
|
66
|
-
}
|
|
67
|
-
// 2. Check for dynamic/malformed tags using regex
|
|
68
|
-
const lookbackLength = Math.min(200, this.buffer.length);
|
|
69
|
-
const recentBuffer = this.buffer.substring(this.buffer.length - lookbackLength);
|
|
70
|
-
// IMPORTANT: Keep this strict to avoid treating normal HTML/text tags
|
|
71
|
-
// (e.g. <script>, </button>) as tool tags.
|
|
72
|
-
// We only accept:
|
|
73
|
-
// - LLM control tags like <|tool_call_begin|>
|
|
74
|
-
// - compact call markers like call:0>
|
|
75
|
-
// - bracketed tool markers like [Tool Use: name]
|
|
76
|
-
const dynamicTagPattern = /<\|[\w_]{3,}(?:\|>|>)?|(?:^|[^a-zA-Z0-9_])(call:\d+>)|(?:^|[\s,])(\[Tool (?:Use|Result):[^\]]+\])/g;
|
|
77
|
-
const matches = Array.from(recentBuffer.matchAll(dynamicTagPattern));
|
|
78
|
-
if (matches.length > 0) {
|
|
79
|
-
const lastMatch = matches[matches.length - 1];
|
|
80
|
-
// If we have a capture group (index 1 or 2), use it, otherwise use the full match
|
|
81
|
-
const potentialTag = lastMatch[2] || lastMatch[1] || lastMatch[0];
|
|
82
|
-
// If it's a perfect match for a known tag or matches our dynamic pattern
|
|
83
|
-
// If we used a capture group, we need to adjust the index to point to that group specifically
|
|
84
|
-
const matchIndex = this.buffer.length -
|
|
85
|
-
lookbackLength +
|
|
86
|
-
lastMatch.index +
|
|
87
|
-
(lastMatch[0].length - potentialTag.length);
|
|
88
|
-
// Check if this is a definite tag (ends with > or ] or is a known tag)
|
|
89
|
-
if (potentialTag.endsWith(">") ||
|
|
90
|
-
potentialTag.endsWith("]") ||
|
|
91
|
-
this.tags.includes(potentialTag)) {
|
|
92
|
-
const content = this.buffer.substring(0, matchIndex);
|
|
93
|
-
this.buffer = this.buffer.substring(matchIndex + potentialTag.length);
|
|
94
|
-
console.log(`[Marie] Dynamic tag detected: ${potentialTag}`);
|
|
95
|
-
return { type: "tag", text: content, tag: potentialTag };
|
|
1
|
+
import { createPrefixTree } from "./PrefixTree.js";
|
|
2
|
+
const MAX_BUFFER_SIZE = 100000; // 100k chars safety limit
|
|
3
|
+
// Tags we want to detect.
|
|
4
|
+
const DEFAULT_TAGS = [
|
|
5
|
+
"<|tool_call_begin|>",
|
|
6
|
+
"<|tool_call_end|>",
|
|
7
|
+
"<|tool_calls_section_begin|>", // Section begin marker
|
|
8
|
+
"<|tool_calls_section_end|>", // Section end marker
|
|
9
|
+
"<|tool_call_id|>", // Some models emit tool IDs separately
|
|
10
|
+
"<|tool_call_argument_begin|>",
|
|
11
|
+
"<|tool_call_arguments_begin|>", // Plural variant
|
|
12
|
+
"<tool>",
|
|
13
|
+
"</tool>",
|
|
14
|
+
"<function",
|
|
15
|
+
"</function>",
|
|
16
|
+
"<function_calls>",
|
|
17
|
+
"</function_calls>",
|
|
18
|
+
"<invoke",
|
|
19
|
+
"</invoke>",
|
|
20
|
+
"<thought>",
|
|
21
|
+
"</thought>",
|
|
22
|
+
"<tool_code>",
|
|
23
|
+
"</tool_code>",
|
|
24
|
+
"<tool_call>",
|
|
25
|
+
"</tool_call>",
|
|
26
|
+
"<|eot_id|>", // End of turn marker
|
|
27
|
+
"<|start_header_id|>", // Header start marker
|
|
28
|
+
"<|end_header_id|>", // Header end marker
|
|
29
|
+
];
|
|
30
|
+
export function createStreamTagDetector() {
|
|
31
|
+
let buffer = "";
|
|
32
|
+
const prefixTree = createPrefixTree(DEFAULT_TAGS);
|
|
33
|
+
return {
|
|
34
|
+
process(chunk) {
|
|
35
|
+
buffer += chunk;
|
|
36
|
+
if (buffer.length > MAX_BUFFER_SIZE) {
|
|
37
|
+
console.error("[Marie] StreamTagDetector buffer exceeded safety limit. Flushing.");
|
|
38
|
+
const flushed = buffer;
|
|
39
|
+
buffer = "";
|
|
40
|
+
return { type: "content", text: flushed };
|
|
96
41
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
42
|
+
const tagMatch = prefixTree.findEarliestTag(buffer);
|
|
43
|
+
if (tagMatch) {
|
|
44
|
+
const content = buffer.substring(0, tagMatch.index);
|
|
45
|
+
buffer = buffer.substring(tagMatch.index + tagMatch.tag.length);
|
|
46
|
+
console.log(`[Marie] Tag detected: ${tagMatch.tag} at index ${tagMatch.index}`);
|
|
47
|
+
return { type: "tag", text: content, tag: tagMatch.tag };
|
|
48
|
+
}
|
|
49
|
+
const lookbackLength = Math.min(200, buffer.length);
|
|
50
|
+
const recentBuffer = buffer.substring(buffer.length - lookbackLength);
|
|
51
|
+
const dynamicTagPattern = /<\|[\w_]{3,}(?:\|>|>)?|(?:^|[^a-zA-Z0-9_])(call:\d+>)|(?:^|[\s,])(\[Tool (?:Use|Result):[^\]]+\])/g;
|
|
52
|
+
const matches = Array.from(recentBuffer.matchAll(dynamicTagPattern));
|
|
53
|
+
if (matches.length > 0) {
|
|
54
|
+
const lastMatch = matches[matches.length - 1];
|
|
55
|
+
const potentialTag = lastMatch[2] || lastMatch[1] || lastMatch[0];
|
|
56
|
+
const matchIndex = buffer.length -
|
|
57
|
+
lookbackLength +
|
|
58
|
+
lastMatch.index +
|
|
59
|
+
(lastMatch[0].length - potentialTag.length);
|
|
60
|
+
if (potentialTag.endsWith(">") ||
|
|
61
|
+
potentialTag.endsWith("]") ||
|
|
62
|
+
DEFAULT_TAGS.includes(potentialTag)) {
|
|
63
|
+
const content = buffer.substring(0, matchIndex);
|
|
64
|
+
buffer = buffer.substring(matchIndex + potentialTag.length);
|
|
65
|
+
console.log(`[Marie] Dynamic tag detected: ${potentialTag}`);
|
|
66
|
+
return { type: "tag", text: content, tag: potentialTag };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const partialLength = prefixTree.findLongestPartialAtEnd(buffer);
|
|
70
|
+
const trailingControlTag = buffer.match(/<\|[\w_]*$/);
|
|
71
|
+
const trailingCallMarker = buffer.match(/call:\d*$/);
|
|
72
|
+
const dynamicPartialLength = Math.max(trailingControlTag ? trailingControlTag[0].length : 0, trailingCallMarker ? trailingCallMarker[0].length : 0);
|
|
73
|
+
const maxPartial = Math.max(partialLength, dynamicPartialLength);
|
|
74
|
+
if (maxPartial > 0) {
|
|
75
|
+
const unsafeStart = buffer.length - maxPartial;
|
|
76
|
+
const content = buffer.substring(0, unsafeStart);
|
|
77
|
+
buffer = buffer.substring(unsafeStart);
|
|
78
|
+
return { type: "incomplete", text: content };
|
|
79
|
+
}
|
|
80
|
+
const allContent = buffer;
|
|
81
|
+
buffer = "";
|
|
82
|
+
return { type: "content", text: allContent };
|
|
83
|
+
},
|
|
84
|
+
reset() {
|
|
85
|
+
buffer = "";
|
|
86
|
+
},
|
|
87
|
+
getBufferSize() {
|
|
88
|
+
return buffer.length;
|
|
89
|
+
},
|
|
90
|
+
};
|
|
129
91
|
}
|
|
130
92
|
//# sourceMappingURL=StreamTagDetector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamTagDetector.js","sourceRoot":"","sources":["../../../../src/monolith/plumbing/utils/StreamTagDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"StreamTagDetector.js","sourceRoot":"","sources":["../../../../src/monolith/plumbing/utils/StreamTagDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAanD,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC,0BAA0B;AAE1D,0BAA0B;AAC1B,MAAM,YAAY,GAAG;IACnB,qBAAqB;IACrB,mBAAmB;IACnB,8BAA8B,EAAE,uBAAuB;IACvD,4BAA4B,EAAE,qBAAqB;IACnD,kBAAkB,EAAE,uCAAuC;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