@noorm/marie-cli 0.1.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.
Files changed (193) hide show
  1. package/JOY_ZONING.md +200 -0
  2. package/LICENSE.md +190 -0
  3. package/README.md +94 -0
  4. package/dist/cli-new/components/App.js +138 -0
  5. package/dist/cli-new/components/App.js.map +1 -0
  6. package/dist/cli-new/components/ApprovalDialog.js +31 -0
  7. package/dist/cli-new/components/ApprovalDialog.js.map +1 -0
  8. package/dist/cli-new/components/Banner.js +23 -0
  9. package/dist/cli-new/components/Banner.js.map +1 -0
  10. package/dist/cli-new/components/ChatArea.js +49 -0
  11. package/dist/cli-new/components/ChatArea.js.map +1 -0
  12. package/dist/cli-new/components/Header.js +20 -0
  13. package/dist/cli-new/components/Header.js.map +1 -0
  14. package/dist/cli-new/components/InputArea.js +97 -0
  15. package/dist/cli-new/components/InputArea.js.map +1 -0
  16. package/dist/cli-new/components/MessageBubble.js +114 -0
  17. package/dist/cli-new/components/MessageBubble.js.map +1 -0
  18. package/dist/cli-new/components/SessionSwitcher.js +46 -0
  19. package/dist/cli-new/components/SessionSwitcher.js.map +1 -0
  20. package/dist/cli-new/components/SetupWizard.js +283 -0
  21. package/dist/cli-new/components/SetupWizard.js.map +1 -0
  22. package/dist/cli-new/components/ToolCallDisplay.js +45 -0
  23. package/dist/cli-new/components/ToolCallDisplay.js.map +1 -0
  24. package/dist/cli-new/hooks/useGit.js +99 -0
  25. package/dist/cli-new/hooks/useGit.js.map +1 -0
  26. package/dist/cli-new/hooks/useMarie.js +249 -0
  27. package/dist/cli-new/hooks/useMarie.js.map +1 -0
  28. package/dist/cli-new/hooks/useSessions.js +75 -0
  29. package/dist/cli-new/hooks/useSessions.js.map +1 -0
  30. package/dist/cli-new/index.js +52 -0
  31. package/dist/cli-new/index.js.map +1 -0
  32. package/dist/cli-new/styles/theme.js +68 -0
  33. package/dist/cli-new/styles/theme.js.map +1 -0
  34. package/dist/cli-new/types/cli.js +2 -0
  35. package/dist/cli-new/types/cli.js.map +1 -0
  36. package/dist/extension.cjs +655 -0
  37. package/dist/monolith/adapters/CliMarieAdapter.js +72 -0
  38. package/dist/monolith/adapters/CliMarieAdapter.js.map +1 -0
  39. package/dist/monolith/adapters/VscodeMarieAdapter.js +81 -0
  40. package/dist/monolith/adapters/VscodeMarieAdapter.js.map +1 -0
  41. package/dist/monolith/cli/CliFileSystemPort.js +83 -0
  42. package/dist/monolith/cli/CliFileSystemPort.js.map +1 -0
  43. package/dist/monolith/cli/MarieToolDefinitionsCLI.js +438 -0
  44. package/dist/monolith/cli/MarieToolDefinitionsCLI.js.map +1 -0
  45. package/dist/monolith/cli/index.js +272 -0
  46. package/dist/monolith/cli/index.js.map +1 -0
  47. package/dist/monolith/cli/services/JoyAutomationServiceCLI.js +80 -0
  48. package/dist/monolith/cli/services/JoyAutomationServiceCLI.js.map +1 -0
  49. package/dist/monolith/cli/services/JoyServiceCLI.js +63 -0
  50. package/dist/monolith/cli/services/JoyServiceCLI.js.map +1 -0
  51. package/dist/monolith/cli/storage.js +119 -0
  52. package/dist/monolith/cli/storage.js.map +1 -0
  53. package/dist/monolith/domain/joy/JoyTools.js +513 -0
  54. package/dist/monolith/domain/joy/JoyTools.js.map +1 -0
  55. package/dist/monolith/domain/joy/RitualService.js +51 -0
  56. package/dist/monolith/domain/joy/RitualService.js.map +1 -0
  57. package/dist/monolith/domain/marie/MarieTypes.js +2 -0
  58. package/dist/monolith/domain/marie/MarieTypes.js.map +1 -0
  59. package/dist/monolith/infrastructure/ai/agents/MarieAscendant.js +230 -0
  60. package/dist/monolith/infrastructure/ai/agents/MarieAscendant.js.map +1 -0
  61. package/dist/monolith/infrastructure/ai/agents/MarieYOLO.js +207 -0
  62. package/dist/monolith/infrastructure/ai/agents/MarieYOLO.js.map +1 -0
  63. package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js +129 -0
  64. package/dist/monolith/infrastructure/ai/context/ContextArchiveService.js.map +1 -0
  65. package/dist/monolith/infrastructure/ai/context/ContextManager.js +118 -0
  66. package/dist/monolith/infrastructure/ai/context/ContextManager.js.map +1 -0
  67. package/dist/monolith/infrastructure/ai/core/FileSystemPort.js +2 -0
  68. package/dist/monolith/infrastructure/ai/core/FileSystemPort.js.map +1 -0
  69. package/dist/monolith/infrastructure/ai/core/GhostPort.js +2 -0
  70. package/dist/monolith/infrastructure/ai/core/GhostPort.js.map +1 -0
  71. package/dist/monolith/infrastructure/ai/core/MarieAscensionTypes.js +2 -0
  72. package/dist/monolith/infrastructure/ai/core/MarieAscensionTypes.js.map +1 -0
  73. package/dist/monolith/infrastructure/ai/core/MarieEngine.js +590 -0
  74. package/dist/monolith/infrastructure/ai/core/MarieEngine.js.map +1 -0
  75. package/dist/monolith/infrastructure/ai/core/MarieEventDispatcher.js +161 -0
  76. package/dist/monolith/infrastructure/ai/core/MarieEventDispatcher.js.map +1 -0
  77. package/dist/monolith/infrastructure/ai/core/MarieLockManager.js +121 -0
  78. package/dist/monolith/infrastructure/ai/core/MarieLockManager.js.map +1 -0
  79. package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js +256 -0
  80. package/dist/monolith/infrastructure/ai/core/MarieProgressTracker.js.map +1 -0
  81. package/dist/monolith/infrastructure/ai/core/MariePulseService.js +67 -0
  82. package/dist/monolith/infrastructure/ai/core/MariePulseService.js.map +1 -0
  83. package/dist/monolith/infrastructure/ai/core/MarieResponse.js +101 -0
  84. package/dist/monolith/infrastructure/ai/core/MarieResponse.js.map +1 -0
  85. package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js +86 -0
  86. package/dist/monolith/infrastructure/ai/core/MarieSanitizer.js.map +1 -0
  87. package/dist/monolith/infrastructure/ai/core/MarieSession.js +202 -0
  88. package/dist/monolith/infrastructure/ai/core/MarieSession.js.map +1 -0
  89. package/dist/monolith/infrastructure/ai/core/MarieStabilityMonitor.js +58 -0
  90. package/dist/monolith/infrastructure/ai/core/MarieStabilityMonitor.js.map +1 -0
  91. package/dist/monolith/infrastructure/ai/core/MarieToolMender.js +127 -0
  92. package/dist/monolith/infrastructure/ai/core/MarieToolMender.js.map +1 -0
  93. package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js +548 -0
  94. package/dist/monolith/infrastructure/ai/core/MarieToolProcessor.js.map +1 -0
  95. package/dist/monolith/infrastructure/ai/core/MarieYOLOTypes.js +2 -0
  96. package/dist/monolith/infrastructure/ai/core/MarieYOLOTypes.js.map +1 -0
  97. package/dist/monolith/infrastructure/ai/core/ReasoningBudget.js +125 -0
  98. package/dist/monolith/infrastructure/ai/core/ReasoningBudget.js.map +1 -0
  99. package/dist/monolith/infrastructure/ai/core/VscodeFileSystemPort.js +30 -0
  100. package/dist/monolith/infrastructure/ai/core/VscodeFileSystemPort.js.map +1 -0
  101. package/dist/monolith/infrastructure/ai/providers/AIProvider.js +2 -0
  102. package/dist/monolith/infrastructure/ai/providers/AIProvider.js.map +1 -0
  103. package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js +148 -0
  104. package/dist/monolith/infrastructure/ai/providers/AnthropicProvider.js.map +1 -0
  105. package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js +208 -0
  106. package/dist/monolith/infrastructure/ai/providers/CerebrasProvider.js.map +1 -0
  107. package/dist/monolith/infrastructure/ai/providers/OpenRouterProvider.js +404 -0
  108. package/dist/monolith/infrastructure/ai/providers/OpenRouterProvider.js.map +1 -0
  109. package/dist/monolith/infrastructure/ai/providers/OpenRouterStreamParser.js +283 -0
  110. package/dist/monolith/infrastructure/ai/providers/OpenRouterStreamParser.js.map +1 -0
  111. package/dist/monolith/infrastructure/config/ConfigService.js +398 -0
  112. package/dist/monolith/infrastructure/config/ConfigService.js.map +1 -0
  113. package/dist/monolith/infrastructure/services/MarieMemoryStore.js +140 -0
  114. package/dist/monolith/infrastructure/services/MarieMemoryStore.js.map +1 -0
  115. package/dist/monolith/infrastructure/tools/MarieToolDefinitions.js +1568 -0
  116. package/dist/monolith/infrastructure/tools/MarieToolDefinitions.js.map +1 -0
  117. package/dist/monolith/infrastructure/tools/PureStreamParser.js +147 -0
  118. package/dist/monolith/infrastructure/tools/PureStreamParser.js.map +1 -0
  119. package/dist/monolith/infrastructure/tools/SharedToolDefinitions.js +223 -0
  120. package/dist/monolith/infrastructure/tools/SharedToolDefinitions.js.map +1 -0
  121. package/dist/monolith/infrastructure/tools/ToolRegistry.js +29 -0
  122. package/dist/monolith/infrastructure/tools/ToolRegistry.js.map +1 -0
  123. package/dist/monolith/infrastructure/tools/ToolUtils.js +59 -0
  124. package/dist/monolith/infrastructure/tools/ToolUtils.js.map +1 -0
  125. package/dist/monolith/plumbing/analysis/CodeHealthService.js +146 -0
  126. package/dist/monolith/plumbing/analysis/CodeHealthService.js.map +1 -0
  127. package/dist/monolith/plumbing/analysis/ComplexityService.js +43 -0
  128. package/dist/monolith/plumbing/analysis/ComplexityService.js.map +1 -0
  129. package/dist/monolith/plumbing/analysis/DependencyService.js +51 -0
  130. package/dist/monolith/plumbing/analysis/DependencyService.js.map +1 -0
  131. package/dist/monolith/plumbing/analysis/DiscoveryService.js +49 -0
  132. package/dist/monolith/plumbing/analysis/DiscoveryService.js.map +1 -0
  133. package/dist/monolith/plumbing/analysis/JoyMapService.js +66 -0
  134. package/dist/monolith/plumbing/analysis/JoyMapService.js.map +1 -0
  135. package/dist/monolith/plumbing/analysis/LintService.js +132 -0
  136. package/dist/monolith/plumbing/analysis/LintService.js.map +1 -0
  137. package/dist/monolith/plumbing/analysis/MarieSentinelService.js +276 -0
  138. package/dist/monolith/plumbing/analysis/MarieSentinelService.js.map +1 -0
  139. package/dist/monolith/plumbing/analysis/QualityGuardrailService.js +119 -0
  140. package/dist/monolith/plumbing/analysis/QualityGuardrailService.js.map +1 -0
  141. package/dist/monolith/plumbing/analysis/SurgicalMender.js +70 -0
  142. package/dist/monolith/plumbing/analysis/SurgicalMender.js.map +1 -0
  143. package/dist/monolith/plumbing/analysis/TestService.js +104 -0
  144. package/dist/monolith/plumbing/analysis/TestService.js.map +1 -0
  145. package/dist/monolith/plumbing/filesystem/FileService.js +406 -0
  146. package/dist/monolith/plumbing/filesystem/FileService.js.map +1 -0
  147. package/dist/monolith/plumbing/filesystem/PathResolver.js +26 -0
  148. package/dist/monolith/plumbing/filesystem/PathResolver.js.map +1 -0
  149. package/dist/monolith/plumbing/git/GitService.js +71 -0
  150. package/dist/monolith/plumbing/git/GitService.js.map +1 -0
  151. package/dist/monolith/plumbing/lsp/SymbolService.js +36 -0
  152. package/dist/monolith/plumbing/lsp/SymbolService.js.map +1 -0
  153. package/dist/monolith/plumbing/terminal/ProcessRegistry.js +31 -0
  154. package/dist/monolith/plumbing/terminal/ProcessRegistry.js.map +1 -0
  155. package/dist/monolith/plumbing/terminal/TerminalService.js +180 -0
  156. package/dist/monolith/plumbing/terminal/TerminalService.js.map +1 -0
  157. package/dist/monolith/plumbing/ui/DecorationService.js +54 -0
  158. package/dist/monolith/plumbing/ui/DecorationService.js.map +1 -0
  159. package/dist/monolith/plumbing/utils/ErrorUtils.js +11 -0
  160. package/dist/monolith/plumbing/utils/ErrorUtils.js.map +1 -0
  161. package/dist/monolith/plumbing/utils/JsonUtils.js +360 -0
  162. package/dist/monolith/plumbing/utils/JsonUtils.js.map +1 -0
  163. package/dist/monolith/plumbing/utils/PrefixTree.js +153 -0
  164. package/dist/monolith/plumbing/utils/PrefixTree.js.map +1 -0
  165. package/dist/monolith/plumbing/utils/RetryUtils.js +141 -0
  166. package/dist/monolith/plumbing/utils/RetryUtils.js.map +1 -0
  167. package/dist/monolith/plumbing/utils/StreamTagDetector.js +128 -0
  168. package/dist/monolith/plumbing/utils/StreamTagDetector.js.map +1 -0
  169. package/dist/monolith/plumbing/utils/StringUtils.js +97 -0
  170. package/dist/monolith/plumbing/utils/StringUtils.js.map +1 -0
  171. package/dist/monolith/plumbing/utils/TimeoutUtils.js +21 -0
  172. package/dist/monolith/plumbing/utils/TimeoutUtils.js.map +1 -0
  173. package/dist/monolith/runtime/MarieRuntime.js +354 -0
  174. package/dist/monolith/runtime/MarieRuntime.js.map +1 -0
  175. package/dist/monolith/runtime/RuntimeAdapterBase.js +59 -0
  176. package/dist/monolith/runtime/RuntimeAdapterBase.js.map +1 -0
  177. package/dist/monolith/runtime/providerFactory.js +11 -0
  178. package/dist/monolith/runtime/providerFactory.js.map +1 -0
  179. package/dist/monolith/runtime/types.js +2 -0
  180. package/dist/monolith/runtime/types.js.map +1 -0
  181. package/dist/monolith/services/HealthService.js +38 -0
  182. package/dist/monolith/services/HealthService.js.map +1 -0
  183. package/dist/monolith/services/JoyAutomationService.js +131 -0
  184. package/dist/monolith/services/JoyAutomationService.js.map +1 -0
  185. package/dist/monolith/services/JoyLogService.js +48 -0
  186. package/dist/monolith/services/JoyLogService.js.map +1 -0
  187. package/dist/monolith/services/JoyService.js +190 -0
  188. package/dist/monolith/services/JoyService.js.map +1 -0
  189. package/dist/monolith/services/MarieGhostService.js +168 -0
  190. package/dist/monolith/services/MarieGhostService.js.map +1 -0
  191. package/dist/monolith/services/MarieSCMProvider.js +41 -0
  192. package/dist/monolith/services/MarieSCMProvider.js.map +1 -0
  193. package/package.json +168 -0
@@ -0,0 +1,230 @@
1
+ import { MARIE_YOLO_SYSTEM_PROMPT } from "../../../../prompts.js";
2
+ import { ConfigService } from "../../config/ConfigService.js";
3
+ import { MarieResponse } from "../core/MarieResponse.js";
4
+ export class MarieAscendant {
5
+ provider;
6
+ // ASCENSION PROTOCOL: Spirit pressure persistence across turns
7
+ lastConfidence = 1.2;
8
+ consecutiveSuccesses = 0;
9
+ constructor(provider) {
10
+ this.provider = provider;
11
+ }
12
+ async evaluate(messages, state, options) {
13
+ try {
14
+ const profile = options?.profile ?? ConfigService.getAscensionProfile();
15
+ const aggression = options?.aggression ?? ConfigService.getAscensionIntensity();
16
+ const maxRequiredActions = options?.maxRequiredActions ??
17
+ ConfigService.getAscensionMaxRequiredActions();
18
+ const hotspots = Object.entries(state.errorHotspots)
19
+ .filter(([_, c]) => c >= 2)
20
+ .map(([f, c]) => `${f}(${c}x)`)
21
+ .join(", ") || "None";
22
+ const contextPrompt = `
23
+ [ASCENSION CONTEXT]
24
+ Memory Snapshot:
25
+ - Spirit Pressure (Flow): ${state.spiritPressure}/100
26
+ - Victory Streak: ${state.victoryStreak}
27
+ - Karma Drain (Errors): ${state.totalErrorCount}
28
+ - Curse Hotspots: ${hotspots}
29
+ - Recent Echoes: ${state.recentFiles.slice(-5).join(", ")}
30
+ - Protocol: ${profile}
31
+ - Intensity: ${aggression}
32
+ - Environment: ${state.environment}
33
+
34
+ [SOVEREIGN DUTIES]
35
+ Your decree integrates Strategic Trajectory, Quality Audit, and Stability Guardianship.
36
+
37
+ Return guidance in the exact structure below:
38
+ Strategy: EXECUTE|DEBUG|RESEARCH|HYPE|PANIC
39
+ Urgency: LOW|MEDIUM|HIGH
40
+ Confidence: 0.5-3.0
41
+ Structural Uncertainty: YES|NO
42
+ Continue Directive: YES|NO
43
+ Required Actions: action1 | action2
44
+ Blocked By: blocker1 | blocker2
45
+ Stop Condition: landed|structural_uncertainty
46
+ Reason: <one concise line integrating Auditor/ISO findings>
47
+
48
+ Required Actions must be <= ${maxRequiredActions}.`;
49
+ const providerResponse = await this.provider.createMessage({
50
+ model: ConfigService.getModel(),
51
+ system: MARIE_YOLO_SYSTEM_PROMPT,
52
+ messages: [
53
+ ...messages.map((m) => ({ role: m.role, content: m.content })),
54
+ { role: "user", content: contextPrompt },
55
+ ],
56
+ max_tokens: 900,
57
+ });
58
+ const raw = MarieResponse.wrap(providerResponse.content)
59
+ .getText()
60
+ .substring(0, 1200);
61
+ return this.parseDecree(raw, messages, state, profile, aggression, maxRequiredActions, state.victoryStreak);
62
+ }
63
+ catch (error) {
64
+ console.error("MarieAscendant evaluation error", error);
65
+ return {
66
+ strategy: "EXECUTE",
67
+ urgency: "MEDIUM",
68
+ confidence: Math.max(1.2, this.lastConfidence * 0.8),
69
+ isContinueDirective: this.hasContinueDirective(messages),
70
+ structuralUncertainty: false,
71
+ reason: "Fallback: Hero maintains course via instinct.",
72
+ requiredActions: [],
73
+ blockedBy: [],
74
+ stopCondition: "landed",
75
+ profile: ConfigService.getAscensionProfile(),
76
+ raw: "Fallback decree (spirit pressure rift)",
77
+ };
78
+ }
79
+ }
80
+ parseDecree(raw, messages, state, profile, aggression, maxRequiredActions, victoryStreak) {
81
+ const normalized = raw.replace(/\r/g, "");
82
+ const strategyMatch = normalized.match(/Strategy\s*:\s*(EXECUTE|DEBUG|RESEARCH|HYPE|PANIC)/i);
83
+ const urgencyMatch = normalized.match(/Urgency\s*:\s*(LOW|MEDIUM|HIGH)/i);
84
+ const confidenceMatch = normalized.match(/Confidence\s*:\s*([0-9]+(?:\.[0-9]+)?)/i);
85
+ const uncertaintyMatch = normalized.match(/Structural\s*Uncertainty\s*:\s*(YES|NO|TRUE|FALSE)/i);
86
+ const continueMatch = normalized.match(/Continue\s*Directive\s*:\s*(YES|NO|TRUE|FALSE)/i);
87
+ const requiredActionsMatch = normalized.match(/Required\s*Actions\s*:\s*(.+)/i);
88
+ const vowMatch = normalized.match(/Heroic\s*Vow\s*:\s*(.+)/i);
89
+ const bondMatch = normalized.match(/Karma\s*Bond\s*:\s*(.+)/i);
90
+ const sacrificeMatch = normalized.match(/Sacrifice\s*Triggered\s*:\s*(YES|NO|TRUE|FALSE)/i);
91
+ const blockedByMatch = normalized.match(/Blocked\s*By\s*:\s*(.+)/i);
92
+ const stopConditionMatch = normalized.match(/Stop\s*Condition\s*:\s*(landed|structural_uncertainty)/i);
93
+ const reasonMatch = normalized.match(/Reason\s*:\s*(.+)/i);
94
+ const inferredStrategy = this.inferStrategy(normalized);
95
+ const strategy = strategyMatch?.[1]?.toUpperCase() ||
96
+ inferredStrategy;
97
+ const urgency = urgencyMatch?.[1]?.toUpperCase() ||
98
+ this.inferUrgency(normalized);
99
+ let confidence = this.clampConfidence(Number(confidenceMatch?.[1] ?? this.inferConfidence(urgency, strategy)));
100
+ const structuralUncertainty = this.parseBoolean(uncertaintyMatch?.[1]) ||
101
+ this.inferUncertainty(normalized);
102
+ const isContinueDirective = this.parseBoolean(continueMatch?.[1]) ||
103
+ this.hasContinueDirective(messages) ||
104
+ /continue\s+immediately/i.test(normalized);
105
+ const requiredActions = this.parseDelimitedList(requiredActionsMatch?.[1]).slice(0, maxRequiredActions);
106
+ const heroicVow = vowMatch?.[1]?.trim();
107
+ const karmaBond = bondMatch?.[1]?.trim();
108
+ const sacrificeTriggered = this.parseBoolean(sacrificeMatch?.[1]);
109
+ const blockedBy = this.parseDelimitedList(blockedByMatch?.[1]).slice(0, 4);
110
+ const stopCondition = stopConditionMatch?.[1]?.toLowerCase() ||
111
+ (structuralUncertainty ? "structural_uncertainty" : "landed");
112
+ if (heroicVow) {
113
+ confidence = Math.min(3.0, confidence + 0.5); // Vow bonus
114
+ }
115
+ if (state.isAwakened) {
116
+ confidence = 3.0; // Awakened state locks confidence at maximum
117
+ }
118
+ confidence = this.applyProfileTuning(confidence, profile, aggression, structuralUncertainty, victoryStreak);
119
+ if (isContinueDirective &&
120
+ (strategy === "EXECUTE" || strategy === "HYPE")) {
121
+ confidence = Math.min(3.0, confidence + 0.3);
122
+ }
123
+ // Update persistence for next turn
124
+ this.lastConfidence = confidence;
125
+ if (strategy === "EXECUTE" || strategy === "HYPE") {
126
+ this.consecutiveSuccesses++;
127
+ }
128
+ else {
129
+ this.consecutiveSuccesses = 0;
130
+ }
131
+ return {
132
+ strategy,
133
+ urgency,
134
+ confidence,
135
+ structuralUncertainty,
136
+ isContinueDirective,
137
+ heroicVow,
138
+ sacrificeTriggered,
139
+ reason: (reasonMatch?.[1] || this.defaultReason(strategy, urgency))
140
+ .trim()
141
+ .substring(0, 220),
142
+ requiredActions,
143
+ blockedBy,
144
+ stopCondition,
145
+ profile,
146
+ raw: normalized.substring(0, 1200),
147
+ };
148
+ }
149
+ inferStrategy(text) {
150
+ if (/uncertainty|unknown|unclear|ambiguous\s+structure|dependency\s+risk/i.test(text))
151
+ return "DEBUG";
152
+ if (/research|investigate|inspect/i.test(text))
153
+ return "RESEARCH";
154
+ if (/ship|launch|demo day|hype|singularity/i.test(text))
155
+ return "HYPE";
156
+ if (/panic|halt|assess\s+failure/i.test(text))
157
+ return "PANIC";
158
+ if (/limit\s*break|absolute\s*conviction|no\s*limit/i.test(text))
159
+ return "LIMIT_BREAK";
160
+ return "EXECUTE";
161
+ }
162
+ inferUrgency(text) {
163
+ if (/immediately|now|urgent|critical momentum|no hesitation/i.test(text))
164
+ return "HIGH";
165
+ if (/careful|cautious|stability/i.test(text))
166
+ return "LOW";
167
+ return "MEDIUM";
168
+ }
169
+ inferConfidence(urgency, strategy) {
170
+ if (strategy === "HYPE")
171
+ return 2.0;
172
+ if (strategy === "PANIC")
173
+ return 0.5;
174
+ if (urgency === "HIGH")
175
+ return 1.9;
176
+ if (urgency === "LOW")
177
+ return 1.0;
178
+ return 1.5;
179
+ }
180
+ inferUncertainty(text) {
181
+ return /structural\s+uncertainty|critical unknown|not enough context|missing wiring/i.test(text);
182
+ }
183
+ defaultReason(strategy, urgency) {
184
+ return `Hero signal: ${strategy} with ${urgency.toLowerCase()} urgency.`;
185
+ }
186
+ parseBoolean(value) {
187
+ if (!value)
188
+ return false;
189
+ return ["YES", "TRUE"].includes(value.toUpperCase());
190
+ }
191
+ clampConfidence(value) {
192
+ if (!Number.isFinite(value))
193
+ return 1.2;
194
+ return Math.min(3.0, Math.max(0.5, value));
195
+ }
196
+ applyProfileTuning(baseConfidence, profile, aggression, structuralUncertainty, victoryStreak) {
197
+ let profileMultiplier = 1.0;
198
+ if (profile === "demo_day")
199
+ profileMultiplier = 1.2;
200
+ if (profile === "recovery")
201
+ profileMultiplier = 0.9;
202
+ const streakBonus = Math.min(0.5, (victoryStreak || 0) * 0.05);
203
+ let tuned = baseConfidence * profileMultiplier * aggression * (1 + streakBonus);
204
+ if (structuralUncertainty)
205
+ tuned *= 0.85;
206
+ const persistenceBonus = this.lastConfidence * 0.15;
207
+ tuned += persistenceBonus;
208
+ return this.clampConfidence(tuned);
209
+ }
210
+ parseDelimitedList(raw) {
211
+ if (!raw)
212
+ return [];
213
+ if (/^none$/i.test(raw.trim()))
214
+ return [];
215
+ return raw
216
+ .split(/[|,;]/)
217
+ .map((s) => s.trim())
218
+ .filter(Boolean)
219
+ .slice(0, 6);
220
+ }
221
+ hasContinueDirective(messages) {
222
+ const lastUser = [...messages]
223
+ .reverse()
224
+ .find((m) => m?.role === "user" && typeof m?.content === "string");
225
+ if (!lastUser)
226
+ return false;
227
+ return /\bcontinue\b/i.test(lastUser.content);
228
+ }
229
+ }
230
+ //# sourceMappingURL=MarieAscendant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarieAscendant.js","sourceRoot":"","sources":["../../../../../src/monolith/infrastructure/ai/agents/MarieAscendant.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AASzD,MAAM,OAAO,cAAc;IAKL;IAJpB,+DAA+D;IACvD,cAAc,GAAW,GAAG,CAAC;IAC7B,oBAAoB,GAAW,CAAC,CAAC;IAEzC,YAAoB,QAAoB;QAApB,aAAQ,GAAR,QAAQ,CAAY;IAAG,CAAC;IAErC,KAAK,CAAC,QAAQ,CACnB,QAAe,EACf,KAAqB,EACrB,OAIC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,aAAa,CAAC,mBAAmB,EAAE,CAAC;YACxE,MAAM,UAAU,GACd,OAAO,EAAE,UAAU,IAAI,aAAa,CAAC,qBAAqB,EAAE,CAAC;YAC/D,MAAM,kBAAkB,GACtB,OAAO,EAAE,kBAAkB;gBAC3B,aAAa,CAAC,8BAA8B,EAAE,CAAC;YAEjD,MAAM,QAAQ,GACZ,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC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,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QAE/D,IAAI,KAAK,GACP,cAAc,GAAG,iBAAiB,GAAG,UAAU,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC;QACtE,IAAI,qBAAqB;YAAE,KAAK,IAAI,IAAI,CAAC;QAEzC,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QACpD,KAAK,IAAI,gBAAgB,CAAC;QAE1B,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAEO,kBAAkB,CAAC,GAAY;QACrC,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,CAAC;QACpB,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YAAE,OAAO,EAAE,CAAC;QAC1C,OAAO,GAAG;aACP,KAAK,CAAC,OAAO,CAAC;aACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,MAAM,CAAC,OAAO,CAAC;aACf,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjB,CAAC;IAEO,oBAAoB,CAAC,QAAe;QAC1C,MAAM,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC;aAC3B,OAAO,EAAE;aACT,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5B,OAAO,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;CACF"}
@@ -0,0 +1,207 @@
1
+ import { MARIE_YOLO_SYSTEM_PROMPT } from "../../../../prompts.js";
2
+ import { ConfigService } from "../../config/ConfigService.js";
3
+ import { MarieResponse } from "../core/MarieResponse.js";
4
+ export class MarieYOLO {
5
+ provider;
6
+ // ASCENSION PROTOCOL: Spirit pressure persistence across turns
7
+ lastConfidence = 1.2;
8
+ consecutiveSuccesses = 0;
9
+ constructor(provider) {
10
+ this.provider = provider;
11
+ }
12
+ async evaluate(messages, memory, options) {
13
+ try {
14
+ const profile = options?.profile ?? ConfigService.getYoloProfile();
15
+ const aggression = options?.aggression ?? ConfigService.getYoloAggression();
16
+ const maxRequiredActions = options?.maxRequiredActions ?? ConfigService.getYoloMaxRequiredActions();
17
+ // CONSOLIDATED REASONING: YOLO now acts as Auditor, Strategist, and ISO9001
18
+ const hotspots = Object.entries(memory.errorHotspots)
19
+ .filter(([_, c]) => c >= 2)
20
+ .map(([f, c]) => `${f}(${c}x)`)
21
+ .join(', ') || 'None';
22
+ const contextPrompt = `
23
+ [ASCENSION CONTEXT]
24
+ Memory Snapshot:
25
+ - Spirit Pressure (Flow): ${memory.flowState}/100
26
+ - Victory Streak: ${memory.successStreak}
27
+ - Karma Drain (Errors): ${memory.totalErrorCount}
28
+ - Curse Hotspots: ${hotspots}
29
+ - Recent Echoes: ${memory.recentFiles.slice(-5).join(', ')}
30
+ - Protocol: ${profile}
31
+ - Intensity: ${aggression}
32
+
33
+ [SOVEREIGN DUTIES]
34
+ Your decree integrates Strategic Trajectory, Quality Audit, and Stability Guardianship.
35
+
36
+ Return guidance in the exact structure below:
37
+ Strategy: EXECUTE|DEBUG|RESEARCH|HYPE|PANIC
38
+ Urgency: LOW|MEDIUM|HIGH
39
+ Confidence: 0.5-3.0
40
+ Structural Uncertainty: YES|NO
41
+ Continue Directive: YES|NO
42
+ Required Actions: action1 | action2
43
+ Blocked By: blocker1 | blocker2
44
+ Stop Condition: landed|structural_uncertainty
45
+ Reason: <one concise line integrating Auditor/ISO findings>
46
+
47
+ Required Actions must be <= ${maxRequiredActions}.`;
48
+ const providerResponse = await this.provider.createMessage({
49
+ model: ConfigService.getModel(),
50
+ system: MARIE_YOLO_SYSTEM_PROMPT,
51
+ messages: [
52
+ ...messages.map(m => ({ role: m.role, content: m.content })),
53
+ { role: 'user', content: contextPrompt }
54
+ ],
55
+ max_tokens: 900,
56
+ });
57
+ const raw = MarieResponse.wrap(providerResponse.content).getText().substring(0, 1200);
58
+ return this.parseDecision(raw, messages, profile, aggression, maxRequiredActions, memory.successStreak);
59
+ }
60
+ catch (error) {
61
+ console.error("MarieYOLO evaluation error", error);
62
+ return {
63
+ strategy: 'EXECUTE',
64
+ urgency: 'MEDIUM',
65
+ confidence: Math.max(1.2, this.lastConfidence * 0.8),
66
+ isContinueDirective: this.hasContinueDirective(messages),
67
+ structuralUncertainty: false,
68
+ reason: 'Fallback: Hero maintains course via instinct.',
69
+ requiredActions: [],
70
+ blockedBy: [],
71
+ stopCondition: 'landed',
72
+ profile: ConfigService.getYoloProfile(),
73
+ raw: 'Fallback decision (spirit pressure rift)'
74
+ };
75
+ }
76
+ }
77
+ parseDecision(raw, messages, profile, aggression, maxRequiredActions, successStreak) {
78
+ const normalized = raw.replace(/\r/g, '');
79
+ const strategyMatch = normalized.match(/Strategy\s*:\s*(EXECUTE|DEBUG|RESEARCH|HYPE|PANIC)/i);
80
+ const urgencyMatch = normalized.match(/Urgency\s*:\s*(LOW|MEDIUM|HIGH)/i);
81
+ const confidenceMatch = normalized.match(/Confidence\s*:\s*([0-9]+(?:\.[0-9]+)?)/i);
82
+ const uncertaintyMatch = normalized.match(/Structural\s*Uncertainty\s*:\s*(YES|NO|TRUE|FALSE)/i);
83
+ const continueMatch = normalized.match(/Continue\s*Directive\s*:\s*(YES|NO|TRUE|FALSE)/i);
84
+ const requiredActionsMatch = normalized.match(/Required\s*Actions\s*:\s*(.+)/i);
85
+ const blockedByMatch = normalized.match(/Blocked\s*By\s*:\s*(.+)/i);
86
+ const stopConditionMatch = normalized.match(/Stop\s*Condition\s*:\s*(landed|structural_uncertainty)/i);
87
+ const reasonMatch = normalized.match(/Reason\s*:\s*(.+)/i);
88
+ const inferredStrategy = this.inferStrategy(normalized);
89
+ const strategy = strategyMatch?.[1]?.toUpperCase() || inferredStrategy;
90
+ const urgency = urgencyMatch?.[1]?.toUpperCase() || this.inferUrgency(normalized);
91
+ let confidence = this.clampConfidence(Number(confidenceMatch?.[1] ?? this.inferConfidence(urgency, strategy)));
92
+ const structuralUncertainty = this.parseBoolean(uncertaintyMatch?.[1]) || this.inferUncertainty(normalized);
93
+ const isContinueDirective = this.parseBoolean(continueMatch?.[1]) || this.hasContinueDirective(messages) || /continue\s+immediately/i.test(normalized);
94
+ const requiredActions = this.parseDelimitedList(requiredActionsMatch?.[1]).slice(0, maxRequiredActions);
95
+ const blockedBy = this.parseDelimitedList(blockedByMatch?.[1]).slice(0, 4);
96
+ const stopCondition = stopConditionMatch?.[1]?.toLowerCase()
97
+ || (structuralUncertainty ? 'structural_uncertainty' : 'landed');
98
+ confidence = this.applyProfileTuning(confidence, profile, aggression, structuralUncertainty, successStreak);
99
+ // ASCENSION PROTOCOL: Stronger continue directive boost
100
+ if (isContinueDirective && (strategy === 'EXECUTE' || strategy === 'HYPE')) {
101
+ confidence = Math.min(3.0, confidence + 0.3);
102
+ }
103
+ // Update persistence for next turn
104
+ this.lastConfidence = confidence;
105
+ if (strategy === 'EXECUTE' || strategy === 'HYPE') {
106
+ this.consecutiveSuccesses++;
107
+ }
108
+ else {
109
+ this.consecutiveSuccesses = 0;
110
+ }
111
+ return {
112
+ strategy,
113
+ urgency,
114
+ confidence,
115
+ structuralUncertainty,
116
+ isContinueDirective,
117
+ reason: (reasonMatch?.[1] || this.defaultReason(strategy, urgency)).trim().substring(0, 220),
118
+ requiredActions,
119
+ blockedBy,
120
+ stopCondition,
121
+ profile,
122
+ raw: normalized.substring(0, 1200)
123
+ };
124
+ }
125
+ inferStrategy(text) {
126
+ if (/uncertainty|unknown|unclear|ambiguous\s+structure|dependency\s+risk/i.test(text))
127
+ return 'DEBUG';
128
+ if (/research|investigate|inspect/i.test(text))
129
+ return 'RESEARCH';
130
+ if (/ship|launch|demo day|hype|singularity/i.test(text))
131
+ return 'HYPE';
132
+ if (/panic|halt|assess\s+failure/i.test(text))
133
+ return 'PANIC';
134
+ return 'EXECUTE';
135
+ }
136
+ inferUrgency(text) {
137
+ if (/immediately|now|urgent|critical momentum|no hesitation/i.test(text))
138
+ return 'HIGH';
139
+ if (/careful|cautious|stability/i.test(text))
140
+ return 'LOW';
141
+ return 'MEDIUM';
142
+ }
143
+ inferConfidence(urgency, strategy) {
144
+ if (strategy === 'HYPE')
145
+ return 2.0;
146
+ if (strategy === 'PANIC')
147
+ return 0.5;
148
+ if (urgency === 'HIGH')
149
+ return 1.9;
150
+ if (urgency === 'LOW')
151
+ return 1.0;
152
+ return 1.5;
153
+ }
154
+ inferUncertainty(text) {
155
+ return /structural\s+uncertainty|critical unknown|not enough context|missing wiring/i.test(text);
156
+ }
157
+ defaultReason(strategy, urgency) {
158
+ return `Founder signal: ${strategy} with ${urgency.toLowerCase()} urgency.`;
159
+ }
160
+ parseBoolean(value) {
161
+ if (!value)
162
+ return false;
163
+ return ['YES', 'TRUE'].includes(value.toUpperCase());
164
+ }
165
+ // BALANCED SUPREMACY: Higher max confidence (3.0 vs 2.5)
166
+ clampConfidence(value) {
167
+ if (!Number.isFinite(value))
168
+ return 1.2;
169
+ return Math.min(3.0, Math.max(0.5, value));
170
+ }
171
+ applyProfileTuning(baseConfidence, profile, aggression, structuralUncertainty, successStreak) {
172
+ let profileMultiplier = 1.0;
173
+ // BALANCED SUPREMACY: Boosted profile multipliers
174
+ if (profile === 'demo_day')
175
+ profileMultiplier = 1.2;
176
+ if (profile === 'recovery')
177
+ profileMultiplier = 0.9;
178
+ // ASCENSION PROTOCOL: Success streak amplification (+0.05 per streak, max +0.5)
179
+ const streakBonus = Math.min(0.5, (successStreak || 0) * 0.05);
180
+ let tuned = baseConfidence * profileMultiplier * aggression * (1 + streakBonus);
181
+ // ASCENSION PROTOCOL: Gentler structural uncertainty penalty
182
+ if (structuralUncertainty)
183
+ tuned *= 0.85;
184
+ // ASCENSION PROTOCOL: Conviction persistence (15% carryover from last turn)
185
+ const persistenceBonus = this.lastConfidence * 0.15;
186
+ tuned += persistenceBonus;
187
+ return this.clampConfidence(tuned);
188
+ }
189
+ parseDelimitedList(raw) {
190
+ if (!raw)
191
+ return [];
192
+ if (/^none$/i.test(raw.trim()))
193
+ return [];
194
+ return raw
195
+ .split(/[|,;]/)
196
+ .map(s => s.trim())
197
+ .filter(Boolean)
198
+ .slice(0, 6);
199
+ }
200
+ hasContinueDirective(messages) {
201
+ const lastUser = [...messages].reverse().find(m => m?.role === 'user' && typeof m?.content === 'string');
202
+ if (!lastUser)
203
+ return false;
204
+ return /\bcontinue\b/i.test(lastUser.content);
205
+ }
206
+ }
207
+ //# sourceMappingURL=MarieYOLO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarieYOLO.js","sourceRoot":"","sources":["../../../../../src/monolith/infrastructure/ai/agents/MarieYOLO.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,MAAM,OAAO,SAAS;IAKE;IAJpB,+DAA+D;IACvD,cAAc,GAAW,GAAG,CAAC;IAC7B,oBAAoB,GAAW,CAAC,CAAC;IAEzC,YAAoB,QAAoB;QAApB,aAAQ,GAAR,QAAQ,CAAY;IAAI,CAAC;IAEtC,KAAK,CAAC,QAAQ,CACjB,QAAe,EACf,MAAkB,EAClB,OAIC;QAED,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,aAAa,CAAC,cAAc,EAAE,CAAC;YACnE,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,aAAa,CAAC,iBAAiB,EAAE,CAAC;YAC5E,MAAM,kBAAkB,GAAG,OAAO,EAAE,kBAAkB,IAAI,aAAa,CAAC,yBAAyB,EAA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AAM,CAAC,OAAO,CAAC;aACf,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,CAAC;IAEO,oBAAoB,CAAC,QAAe;QACxC,MAAM,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC;QACzG,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC5B,OAAO,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;CACJ"}
@@ -0,0 +1,129 @@
1
+ import * as vscode from "vscode";
2
+ import * as fs from "fs/promises";
3
+ import * as path from "path";
4
+ /**
5
+ * Manages "anchored" context for Marie, providing a stable memory for critical information.
6
+ */
7
+ export class ContextArchiveService {
8
+ static instance;
9
+ anchors = new Map();
10
+ ready;
11
+ saveQueue = Promise.resolve();
12
+ static context;
13
+ constructor() {
14
+ this.ready = this.loadFromDisk();
15
+ }
16
+ static init(context) {
17
+ this.context = context;
18
+ }
19
+ async awaitReady() {
20
+ return this.ready;
21
+ }
22
+ static getInstance() {
23
+ if (!ContextArchiveService.instance) {
24
+ ContextArchiveService.instance = new ContextArchiveService();
25
+ }
26
+ return ContextArchiveService.instance;
27
+ }
28
+ async loadFromDisk() {
29
+ if (!ContextArchiveService.context)
30
+ return;
31
+ const storageUri = ContextArchiveService.context.storageUri;
32
+ if (!storageUri)
33
+ return;
34
+ const memoryPath = path.join(storageUri.fsPath, "marie_memory.json");
35
+ try {
36
+ // Ensure storage directory exists
37
+ await fs.mkdir(storageUri.fsPath, { recursive: true });
38
+ const data = await fs.readFile(memoryPath, "utf-8");
39
+ const parsed = JSON.parse(data);
40
+ this.anchors = new Map(Object.entries(parsed));
41
+ }
42
+ catch (e) {
43
+ // Check for migration from workspace root
44
+ await this.migrateFromWorkspaceRoot(memoryPath);
45
+ }
46
+ }
47
+ async migrateFromWorkspaceRoot(newPath) {
48
+ const root = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
49
+ if (!root)
50
+ return;
51
+ const oldPath = path.join(root, ".marie_memory.json");
52
+ try {
53
+ const data = await fs.readFile(oldPath, "utf-8");
54
+ const parsed = JSON.parse(data);
55
+ this.anchors = new Map(Object.entries(parsed));
56
+ // Save to new location immediately
57
+ const serialized = JSON.stringify(Object.fromEntries(this.anchors.entries()), null, 2);
58
+ await fs.writeFile(newPath, serialized);
59
+ // Optional: delete old file? Let's leave it for now but maybe rename it to .marie_memory.json.bak
60
+ await fs.rename(oldPath, oldPath + ".bak");
61
+ console.log(`[ContextArchiveService] Migrated memory from ${oldPath} to ${newPath}`);
62
+ }
63
+ catch (err) {
64
+ // No old file to migrate
65
+ }
66
+ }
67
+ async saveToDisk() {
68
+ if (!ContextArchiveService.context)
69
+ return;
70
+ const storageUri = ContextArchiveService.context.storageUri;
71
+ if (!storageUri)
72
+ return;
73
+ const memoryPath = path.join(storageUri.fsPath, "marie_memory.json");
74
+ try {
75
+ await fs.mkdir(storageUri.fsPath, { recursive: true });
76
+ const data = JSON.stringify(Object.fromEntries(this.anchors.entries()), null, 2);
77
+ await fs.writeFile(memoryPath, data);
78
+ }
79
+ catch (e) {
80
+ console.error("Failed to save strategic memory", e);
81
+ }
82
+ }
83
+ /**
84
+ * Anchors a new piece of context.
85
+ */
86
+ /**
87
+ * Anchors a new piece of context. Safe to call anytime; awaits initialization if needed.
88
+ */
89
+ async anchor(anchor) {
90
+ await this.ready;
91
+ this.anchors.set(anchor.id, {
92
+ ...anchor,
93
+ timestamp: Date.now(),
94
+ });
95
+ this.queueSave();
96
+ }
97
+ queueSave() {
98
+ this.saveQueue = this.saveQueue
99
+ .then(() => this.saveToDisk())
100
+ .catch((e) => console.error("Save queue error:", e));
101
+ }
102
+ /**
103
+ * Retrieves all anchored context as a formatted string for the AI.
104
+ */
105
+ getAllAnchors() {
106
+ if (this.anchors.size === 0) {
107
+ return "No context is currently anchored.";
108
+ }
109
+ const parts = ["# ⚓ Anchored Strategic Context\n\n"];
110
+ const sortedAnchors = Array.from(this.anchors.values()).sort((a, b) => b.timestamp - a.timestamp);
111
+ for (const anchor of sortedAnchors) {
112
+ parts.push(`### ${anchor.label} (${anchor.type})\n`);
113
+ parts.push(`ID: \`${anchor.id}\` | Time: ${new Date(anchor.timestamp).toLocaleTimeString()}\n`);
114
+ parts.push(`\`\`\`\n${anchor.content}\n\`\`\`\n\n`);
115
+ }
116
+ return parts.join("");
117
+ }
118
+ /**
119
+ * Removes an anchor by ID.
120
+ */
121
+ async release(id) {
122
+ await this.ready;
123
+ const deleted = this.anchors.delete(id);
124
+ if (deleted)
125
+ this.queueSave();
126
+ return deleted;
127
+ }
128
+ }
129
+ //# sourceMappingURL=ContextArchiveService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextArchiveService.js","sourceRoot":"","sources":["../../../../../src/monolith/infrastructure/ai/context/ContextArchiveService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAU7B;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACxB,MAAM,CAAC,QAAQ,CAAwB;IACvC,OAAO,GAAiC,IAAI,GAAG,EAAE,CAAC;IAClD,KAAK,CAAgB;IACrB,SAAS,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAE7C,MAAM,CAAC,OAAO,CAA0B;IAEhD;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;IACnC,CAAC;IAEM,MAAM,CAAC,IAAI,CAAC,OAAgC;QACjD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,OAAO,IAAI,CAAC,K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