@vishal_20/basetree 1.0.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 (149) hide show
  1. package/.env.example +10 -0
  2. package/README.md +369 -0
  3. package/dist/agents/alignmentAgent.js +68 -0
  4. package/dist/agents/governanceOrchestrator.js +152 -0
  5. package/dist/agents/planet/climateAgent.js +39 -0
  6. package/dist/agents/planet/diplomacyAgent.js +52 -0
  7. package/dist/agents/planet/discoveryAgent.js +41 -0
  8. package/dist/agents/planet/economicAgent.js +64 -0
  9. package/dist/agents/planet/educationAgent.js +41 -0
  10. package/dist/agents/planet/governanceCouncilAgent.js +76 -0
  11. package/dist/agents/planet/healthcareAgent.js +42 -0
  12. package/dist/agents/planet/infrastructureAgent.js +49 -0
  13. package/dist/agents/planet/planetAgent.js +5 -0
  14. package/dist/agents/planet/riskStabilityAgent.js +84 -0
  15. package/dist/agents/planet/urbanSystemsAgent.js +42 -0
  16. package/dist/agents/policyAgent.js +31 -0
  17. package/dist/agents/promptGenomeAgent.js +120 -0
  18. package/dist/agents/reasoningOptimizerAgent.js +72 -0
  19. package/dist/agents/regressionAgent.js +162 -0
  20. package/dist/agents/reinforcementLearnerAgent.js +108 -0
  21. package/dist/agents/riskEvaluationAgent.js +131 -0
  22. package/dist/agents/rollbackAgent.js +53 -0
  23. package/dist/agents/stabilityAgent.js +90 -0
  24. package/dist/agents/strategyMutationAgent.js +74 -0
  25. package/dist/agents/systemIntrospectionAgent.js +274 -0
  26. package/dist/agents/upgradeExecutorAgent.js +146 -0
  27. package/dist/agents/upgradePlannerAgent.js +80 -0
  28. package/dist/agents/venture/businessModelAgent.js +81 -0
  29. package/dist/agents/venture/growthAgent.js +82 -0
  30. package/dist/agents/venture/ideationAgent.js +89 -0
  31. package/dist/agents/venture/investorAgent.js +90 -0
  32. package/dist/agents/venture/legalAgent.js +112 -0
  33. package/dist/agents/venture/marketResearchAgent.js +80 -0
  34. package/dist/agents/venture/productAgent.js +96 -0
  35. package/dist/agents/venture/revenueAgent.js +63 -0
  36. package/dist/agents/venture/validationAgent.js +189 -0
  37. package/dist/bootstrap.js +200 -0
  38. package/dist/cli.js +453 -0
  39. package/dist/cognitiveGraph/cognitiveGraphEngine.js +180 -0
  40. package/dist/cognitiveGraph/graphStore.js +81 -0
  41. package/dist/cognitiveGraph/reasoningStreamBus.js +190 -0
  42. package/dist/config/config.js +76 -0
  43. package/dist/core/agent/AdaptivePlanner.js +49 -0
  44. package/dist/core/agent/AutoFixEngine.js +37 -0
  45. package/dist/core/agent/ExecutorAgent.js +79 -0
  46. package/dist/core/agent/LearningMemoryAgent.js +67 -0
  47. package/dist/core/agent/MemoryAgent.js +35 -0
  48. package/dist/core/agent/MetaCognitionAgent.js +38 -0
  49. package/dist/core/agent/PlannerAgent.js +59 -0
  50. package/dist/core/agent/ReflectionLoop.js +34 -0
  51. package/dist/core/agent/ReviewerAgent.js +34 -0
  52. package/dist/core/agent/VerificationAgent.js +20 -0
  53. package/dist/core/agent/specialists/SpecializedAgents.js +43 -0
  54. package/dist/core/ai/GeminiProvider.js +113 -0
  55. package/dist/core/ai/listModels.js +73 -0
  56. package/dist/core/monitor/PerformanceMonitor.js +18 -0
  57. package/dist/core/swarm/AgentSwarm.js +56 -0
  58. package/dist/core/swarm/ReasoningBus.js +26 -0
  59. package/dist/core/swarm/SwarmOrchestrator.js +36 -0
  60. package/dist/discovery/experimentOrchestrator.js +75 -0
  61. package/dist/discovery/hypothesisEngine.js +79 -0
  62. package/dist/discovery/knowledgeSynthesizer.js +83 -0
  63. package/dist/discovery/simulationPipeline.js +57 -0
  64. package/dist/experiments/experimentationEngine.js +174 -0
  65. package/dist/index.js +67 -0
  66. package/dist/kernel/eventBus.js +89 -0
  67. package/dist/kernel/kernel.js +146 -0
  68. package/dist/llm/tokenEfficiencyOptimizer.js +91 -0
  69. package/dist/memory/civilizationMemory.js +147 -0
  70. package/dist/memory/globalVectorMemory.js +87 -0
  71. package/dist/mesh/crossOrgProtocol.js +110 -0
  72. package/dist/mesh/globalReasoningBus.js +99 -0
  73. package/dist/observability/businessDashboard.js +103 -0
  74. package/dist/observability/businessMetrics.js +105 -0
  75. package/dist/observability/cognitiveMetrics.js +119 -0
  76. package/dist/observability/failureSurfaceMapper.js +135 -0
  77. package/dist/observability/metricsCollector.js +94 -0
  78. package/dist/observability/planetaryDashboard.js +97 -0
  79. package/dist/observability/planetaryMetrics.js +127 -0
  80. package/dist/observability/reportRenderer.js +100 -0
  81. package/dist/performance/memoryProfiler.js +107 -0
  82. package/dist/performance/profiler.js +130 -0
  83. package/dist/pipelines/evolvePipeline.js +150 -0
  84. package/dist/pipelines/governanceReviewPipeline.js +68 -0
  85. package/dist/pipelines/introspectPipeline.js +73 -0
  86. package/dist/pipelines/venture/growPipeline.js +51 -0
  87. package/dist/pipelines/venture/launchPipeline.js +55 -0
  88. package/dist/pipelines/venture/monetizePipeline.js +46 -0
  89. package/dist/pipelines/venture/shutdownPipeline.js +40 -0
  90. package/dist/pipelines/venture/startupPipeline.js +145 -0
  91. package/dist/pipelines/venture/validatePipeline.js +40 -0
  92. package/dist/planet/controlPlane.js +131 -0
  93. package/dist/planet/executionEngine.js +142 -0
  94. package/dist/planet/globalTypes.js +5 -0
  95. package/dist/planet/regionManager.js +114 -0
  96. package/dist/quality/codeQualityAuditor.js +161 -0
  97. package/dist/safety/containmentProtocols.js +87 -0
  98. package/dist/safety/integrityChecker.js +110 -0
  99. package/dist/safety/kernelGuard.js +57 -0
  100. package/dist/safety/killSwitch.js +100 -0
  101. package/dist/safety/planetaryKernel.js +92 -0
  102. package/dist/safety/policyEngine.js +129 -0
  103. package/dist/safety/rollbackManager.js +141 -0
  104. package/dist/safety/sandbox.js +143 -0
  105. package/dist/server/mindmapServer.js +102 -0
  106. package/dist/state/distributedState.js +241 -0
  107. package/dist/state/fileStateStore.js +264 -0
  108. package/dist/state/snapshotter.js +96 -0
  109. package/dist/state/stateStore.js +5 -0
  110. package/dist/tools/FileTools.js +25 -0
  111. package/dist/tools/GitTools.js +16 -0
  112. package/dist/tools/ShellTools.js +24 -0
  113. package/dist/types/architecture.js +5 -0
  114. package/dist/types/core.js +35 -0
  115. package/dist/types/governance.js +5 -0
  116. package/dist/types/venture.js +5 -0
  117. package/dist/ui/App.js +32 -0
  118. package/dist/ui/animation/AnimationEngine.js +117 -0
  119. package/dist/ui/animation/Easing.js +61 -0
  120. package/dist/ui/cli.js +50 -0
  121. package/dist/ui/command/ActionPreview.js +47 -0
  122. package/dist/ui/command/CommandPalette.js +55 -0
  123. package/dist/ui/command/NaturalLanguageBar.js +77 -0
  124. package/dist/ui/emotion/AnimationSequences.js +59 -0
  125. package/dist/ui/emotion/EmotionalUXEngine.js +86 -0
  126. package/dist/ui/integration/BackendAdapter.js +50 -0
  127. package/dist/ui/integration/WebSocketAdapter.js +90 -0
  128. package/dist/ui/intelligence/AdaptiveUIEngine.js +75 -0
  129. package/dist/ui/intelligence/UserBehaviorTracker.js +88 -0
  130. package/dist/ui/layout/LayoutEngine.js +115 -0
  131. package/dist/ui/mindmap/CognitiveMindmapRenderer.js +53 -0
  132. package/dist/ui/mindmap/EdgeRenderer.js +35 -0
  133. package/dist/ui/mindmap/GraphLayout.js +137 -0
  134. package/dist/ui/mindmap/MindmapControls.js +53 -0
  135. package/dist/ui/mindmap/NodeRenderer.js +53 -0
  136. package/dist/ui/modes/CognitiveMode.js +31 -0
  137. package/dist/ui/modes/CommandMode.js +6 -0
  138. package/dist/ui/modes/GovernanceMode.js +6 -0
  139. package/dist/ui/modes/MissionControlMode.js +6 -0
  140. package/dist/ui/modes/ModeManager.js +67 -0
  141. package/dist/ui/modes/ObservatoryMode.js +10 -0
  142. package/dist/ui/modes/TimelineMode.js +27 -0
  143. package/dist/ui/terminalOS.js +180 -0
  144. package/dist/ui/theme/ThemeEngine.js +164 -0
  145. package/dist/ui/visual/ColorGradient.js +91 -0
  146. package/dist/ui/visual/Typography.js +128 -0
  147. package/dist/ui/visual/UnicodeRenderer.js +86 -0
  148. package/dist/venture/ventureMemory.js +62 -0
  149. package/package.json +70 -0
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Mindmap Controls for BASETREE V8
4
+ * Zoom, pan, filter controls
5
+ */
6
+ import { useState, useEffect } from 'react';
7
+ import { useInput } from 'ink';
8
+ import { Box, Text } from 'ink';
9
+ export function MindmapControls({ onStateChange }) {
10
+ const [zoom, setZoom] = useState(1);
11
+ const [panX, setPanX] = useState(0);
12
+ const [panY, setPanY] = useState(0);
13
+ const [filterType, setFilterType] = useState(null);
14
+ useEffect(() => {
15
+ onStateChange({ zoom, panX, panY, filterType });
16
+ }, [zoom, panX, panY, filterType, onStateChange]);
17
+ useInput((input, key) => {
18
+ if (key.ctrl && input === '=') {
19
+ // Zoom in
20
+ setZoom((z) => Math.min(z * 1.2, 5));
21
+ }
22
+ else if (key.ctrl && input === '-') {
23
+ // Zoom out
24
+ setZoom((z) => Math.max(z / 1.2, 0.2));
25
+ }
26
+ else if (key.leftArrow) {
27
+ setPanX((x) => x - 1);
28
+ }
29
+ else if (key.rightArrow) {
30
+ setPanX((x) => x + 1);
31
+ }
32
+ else if (key.upArrow) {
33
+ setPanY((y) => y - 1);
34
+ }
35
+ else if (key.downArrow) {
36
+ setPanY((y) => y + 1);
37
+ }
38
+ else if (input === 'f') {
39
+ // Cycle filter
40
+ const types = ['goal', 'task', 'agent', 'decision', 'risk', null];
41
+ const currentIndex = types.indexOf(filterType);
42
+ setFilterType(types[(currentIndex + 1) % types.length] || null);
43
+ }
44
+ else if (input === 'r') {
45
+ // Reset
46
+ setZoom(1);
47
+ setPanX(0);
48
+ setPanY(0);
49
+ setFilterType(null);
50
+ }
51
+ });
52
+ return (_jsx(Box, { children: _jsx(Text, { children: "Controls: [Ctrl+=] Zoom In [Ctrl+-] Zoom Out [Arrows] Pan [f] Filter [r] Reset" }) }));
53
+ }
@@ -0,0 +1,53 @@
1
+ import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Text } from 'ink';
3
+ export function NodeRenderer({ node, position, themeEngine, zoom, selected }) {
4
+ const theme = themeEngine.getTheme();
5
+ const nodeSymbol = getNodeSymbol(node.type);
6
+ const nodeColor = getNodeColor(node.type, theme);
7
+ // Truncate label for terminal
8
+ const maxLabelLength = Math.floor(20 / zoom);
9
+ const label = node.label.length > maxLabelLength
10
+ ? node.label.substring(0, maxLabelLength - 3) + '...'
11
+ : node.label;
12
+ return (_jsxs(Text, { children: [nodeSymbol, " ", label] }));
13
+ }
14
+ function getNodeSymbol(type) {
15
+ switch (type) {
16
+ case 'goal':
17
+ return '●';
18
+ case 'task':
19
+ return '■';
20
+ case 'agent':
21
+ return '◆';
22
+ case 'decision':
23
+ return '▲';
24
+ case 'risk':
25
+ return '⚠';
26
+ case 'evidence':
27
+ return '○';
28
+ case 'strategy':
29
+ return '▢';
30
+ default:
31
+ return '•';
32
+ }
33
+ }
34
+ function getNodeColor(type, theme) {
35
+ switch (type) {
36
+ case 'goal':
37
+ return theme.primary;
38
+ case 'task':
39
+ return theme.info;
40
+ case 'agent':
41
+ return theme.success;
42
+ case 'decision':
43
+ return theme.secondary;
44
+ case 'risk':
45
+ return theme.error;
46
+ case 'evidence':
47
+ return theme.muted;
48
+ case 'strategy':
49
+ return theme.warning;
50
+ default:
51
+ return theme.foreground;
52
+ }
53
+ }
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Cognitive Mode for BASETREE V8
4
+ * Full-screen mindmap with live reasoning visualization
5
+ */
6
+ import { useState, useEffect } from 'react';
7
+ import { Box, Text } from 'ink';
8
+ import { CognitiveMindmapRenderer } from '../mindmap/CognitiveMindmapRenderer.js';
9
+ import { BackendAdapter } from '../integration/BackendAdapter.js';
10
+ import { useInput } from 'ink';
11
+ export function CognitiveMode({ modeManager, themeEngine, terminalOS, goalId }) {
12
+ const [backendAdapter] = useState(() => new BackendAdapter());
13
+ const [initialized, setInitialized] = useState(false);
14
+ const [currentGoalId] = useState(goalId || 'default-goal');
15
+ useEffect(() => {
16
+ backendAdapter.initialize().then(() => {
17
+ setInitialized(true);
18
+ });
19
+ }, []);
20
+ useInput((input) => {
21
+ if (input === 'c') {
22
+ modeManager.switchMode('command');
23
+ }
24
+ });
25
+ if (!initialized) {
26
+ return (_jsx(Box, { children: _jsx(Text, { children: "Initializing cognitive mindmap..." }) }));
27
+ }
28
+ const graphEngine = backendAdapter.getGraphEngine();
29
+ const streamBus = backendAdapter.getStreamBus();
30
+ return (_jsx(Box, { flexDirection: "column", width: "100%", height: "100%", children: _jsx(CognitiveMindmapRenderer, { graphEngine: graphEngine, streamBus: streamBus, goalId: currentGoalId, themeEngine: themeEngine, modeManager: modeManager, terminalOS: terminalOS }) }));
31
+ }
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ export function CommandMode({ modeManager, themeEngine, terminalOS }) {
4
+ const theme = themeEngine.getTheme();
5
+ return (_jsxs(Box, { flexDirection: "column", width: "100%", height: "100%", children: [_jsxs(Box, { padding: 1, borderStyle: "single", children: [_jsx(Text, { children: "BASETREE V8 - Command Mode" }), _jsx(Text, { children: " Press 'c' for Cognitive Mode, 'm' for Mission Control" })] }), _jsx(Box, { flexGrow: 1, padding: 1, children: _jsx(Text, { children: "Classic CLI mode - Enhanced with live updates" }) })] }));
6
+ }
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ export function GovernanceMode({ modeManager, themeEngine, terminalOS }) {
4
+ const theme = themeEngine.getTheme();
5
+ return (_jsxs(Box, { flexDirection: "column", width: "100%", height: "100%", children: [_jsx(Box, { padding: 1, borderStyle: "single", children: _jsx(Text, { children: "Governance Mode - Policy & Approvals" }) }), _jsxs(Box, { flexDirection: "row", flexGrow: 1, children: [_jsxs(Box, { width: "50%", borderStyle: "single", padding: 1, children: [_jsx(Text, { bold: true, children: "Policies" }), _jsx(Text, { children: "Policy rules will be displayed here" })] }), _jsxs(Box, { width: "50%", borderStyle: "single", padding: 1, children: [_jsx(Text, { bold: true, children: "Pending Approvals" }), _jsx(Text, { children: "Pending proposals will be displayed here" })] })] }), _jsxs(Box, { height: 5, borderStyle: "single", padding: 1, children: [_jsx(Text, { bold: true, children: "Risk Assessment" }), _jsx(Text, { children: "Risk visualization will be displayed here" })] })] }));
6
+ }
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ export function MissionControlMode({ modeManager, themeEngine, terminalOS }) {
4
+ const theme = themeEngine.getTheme();
5
+ return (_jsxs(Box, { flexDirection: "column", width: "100%", height: "100%", children: [_jsx(Box, { padding: 1, borderStyle: "single", children: _jsx(Text, { children: "Mission Control - Multi-Panel Dashboard" }) }), _jsxs(Box, { flexDirection: "row", flexGrow: 1, children: [_jsxs(Box, { width: "50%", borderStyle: "single", padding: 1, children: [_jsx(Text, { bold: true, children: "Agents" }), _jsx(Text, { children: "Agent status will be displayed here" })] }), _jsxs(Box, { width: "50%", borderStyle: "single", padding: 1, children: [_jsx(Text, { bold: true, children: "Goals" }), _jsx(Text, { children: "Active goals will be displayed here" })] })] }), _jsxs(Box, { flexDirection: "row", height: 5, children: [_jsx(Box, { width: "33%", borderStyle: "single", padding: 1, children: _jsx(Text, { bold: true, children: "Metrics" }) }), _jsx(Box, { width: "33%", borderStyle: "single", padding: 1, children: _jsx(Text, { bold: true, children: "Tasks" }) }), _jsx(Box, { width: "34%", borderStyle: "single", padding: 1, children: _jsx(Text, { bold: true, children: "Alerts" }) })] })] }));
6
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Mode Manager for BASETREE V8
3
+ * Hot-swap between layout modes with transition animations
4
+ */
5
+ export class ModeManager {
6
+ currentMode = 'command';
7
+ modeHistory = ['command'];
8
+ transitionCallbacks = new Map();
9
+ /**
10
+ * Switch to a mode
11
+ */
12
+ switchMode(mode, animated = true) {
13
+ if (mode === this.currentMode) {
14
+ return;
15
+ }
16
+ const previousMode = this.currentMode;
17
+ this.currentMode = mode;
18
+ this.modeHistory.push(mode);
19
+ // Limit history size
20
+ if (this.modeHistory.length > 10) {
21
+ this.modeHistory.shift();
22
+ }
23
+ // Trigger transition callback
24
+ const callback = this.transitionCallbacks.get(mode);
25
+ if (callback) {
26
+ callback();
27
+ }
28
+ }
29
+ /**
30
+ * Get current mode
31
+ */
32
+ getCurrentMode() {
33
+ return this.currentMode;
34
+ }
35
+ /**
36
+ * Get previous mode
37
+ */
38
+ getPreviousMode() {
39
+ return this.modeHistory.length > 1
40
+ ? this.modeHistory[this.modeHistory.length - 2]
41
+ : null;
42
+ }
43
+ /**
44
+ * Go back to previous mode
45
+ */
46
+ goBack() {
47
+ if (this.modeHistory.length > 1) {
48
+ this.modeHistory.pop(); // Remove current
49
+ const previous = this.modeHistory.pop();
50
+ if (previous) {
51
+ this.switchMode(previous);
52
+ }
53
+ }
54
+ }
55
+ /**
56
+ * Register transition callback
57
+ */
58
+ onModeTransition(mode, callback) {
59
+ this.transitionCallbacks.set(mode, callback);
60
+ }
61
+ /**
62
+ * Get mode history
63
+ */
64
+ getModeHistory() {
65
+ return [...this.modeHistory];
66
+ }
67
+ }
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ import { PlanetaryMetrics } from '../../observability/planetaryMetrics.js';
4
+ import { PlanetaryDashboard } from '../../observability/planetaryDashboard.js';
5
+ export function ObservatoryMode({ modeManager, themeEngine, terminalOS }) {
6
+ const theme = themeEngine.getTheme();
7
+ const metrics = new PlanetaryMetrics();
8
+ const dashboard = new PlanetaryDashboard(metrics);
9
+ return (_jsxs(Box, { flexDirection: "column", width: "100%", height: "100%", children: [_jsx(Box, { padding: 1, borderStyle: "single", children: _jsx(Text, { children: "Observatory Mode - Planetary Metrics" }) }), _jsx(Box, { flexGrow: 1, padding: 1, children: _jsx(Text, { children: dashboard.render() }) }), _jsxs(Box, { flexDirection: "row", height: 5, children: [_jsx(Box, { width: "33%", borderStyle: "single", padding: 1, children: _jsx(Text, { bold: true, children: "Compute" }) }), _jsx(Box, { width: "33%", borderStyle: "single", padding: 1, children: _jsx(Text, { bold: true, children: "Economic" }) }), _jsx(Box, { width: "34%", borderStyle: "single", padding: 1, children: _jsx(Text, { bold: true, children: "Risk" }) })] })] }));
10
+ }
@@ -0,0 +1,27 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Timeline Mode for BASETREE V8
4
+ * Execution replay with time-travel navigation
5
+ */
6
+ import { useState } from 'react';
7
+ import { Box, Text, useInput } from 'ink';
8
+ export function TimelineMode({ modeManager, themeEngine, terminalOS, runId }) {
9
+ const [currentTime, setCurrentTime] = useState(0);
10
+ const [maxTime, setMaxTime] = useState(100);
11
+ const [playing, setPlaying] = useState(false);
12
+ useInput((input, key) => {
13
+ if (key.leftArrow) {
14
+ setCurrentTime((t) => Math.max(0, t - 1));
15
+ }
16
+ if (key.rightArrow) {
17
+ setCurrentTime((t) => Math.min(maxTime, t + 1));
18
+ }
19
+ if (input === ' ') {
20
+ setPlaying((p) => !p);
21
+ }
22
+ if (input === 'r') {
23
+ setCurrentTime(0);
24
+ }
25
+ });
26
+ return (_jsxs(Box, { flexDirection: "column", width: "100%", height: "100%", children: [_jsx(Box, { padding: 1, borderStyle: "single", children: _jsxs(Text, { children: ["Timeline Mode - Run: ", runId || 'No run selected'] }) }), _jsxs(Box, { flexGrow: 1, padding: 1, children: [_jsx(Text, { children: "Timeline visualization will be rendered here" }), _jsxs(Text, { children: ["Time: ", currentTime, " / ", maxTime] }), _jsxs(Text, { children: ["Status: ", playing ? 'Playing' : 'Paused'] })] }), _jsx(Box, { padding: 1, children: _jsx(Text, { children: "[\u2190\u2192] Navigate [Space] Play/Pause [r] Reset" }) })] }));
27
+ }
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Terminal OS Layer for BASETREE V8
3
+ * Virtual screen manager with viewport abstraction, panels, overlays, modals, tabs
4
+ */
5
+ export class TerminalOS {
6
+ panels = new Map();
7
+ overlays = new Map();
8
+ activeTab = 'default';
9
+ tabs = new Map();
10
+ screenWidth = 80;
11
+ screenHeight = 24;
12
+ focusedPanelId = null;
13
+ constructor() {
14
+ this.tabs.set('default', new Set());
15
+ }
16
+ /**
17
+ * Set screen dimensions
18
+ */
19
+ setScreenSize(width, height) {
20
+ this.screenWidth = width;
21
+ this.screenHeight = height;
22
+ this.recalculateLayouts();
23
+ }
24
+ /**
25
+ * Get screen dimensions
26
+ */
27
+ getScreenSize() {
28
+ return { width: this.screenWidth, height: this.screenHeight };
29
+ }
30
+ /**
31
+ * Create a new panel
32
+ */
33
+ createPanel(id, viewport, zIndex = 0) {
34
+ const panel = {
35
+ id,
36
+ viewport: { ...viewport },
37
+ zIndex,
38
+ visible: true,
39
+ focused: false,
40
+ };
41
+ this.panels.set(id, panel);
42
+ const currentTab = this.tabs.get(this.activeTab);
43
+ if (currentTab) {
44
+ currentTab.add(id);
45
+ }
46
+ return panel;
47
+ }
48
+ /**
49
+ * Get panel by ID
50
+ */
51
+ getPanel(id) {
52
+ return this.panels.get(id);
53
+ }
54
+ /**
55
+ * Update panel viewport
56
+ */
57
+ updatePanel(id, viewport) {
58
+ const panel = this.panels.get(id);
59
+ if (!panel) {
60
+ return;
61
+ }
62
+ panel.viewport = { ...panel.viewport, ...viewport };
63
+ }
64
+ /**
65
+ * Show/hide panel
66
+ */
67
+ setPanelVisible(id, visible) {
68
+ const panel = this.panels.get(id);
69
+ if (panel) {
70
+ panel.visible = visible;
71
+ }
72
+ }
73
+ /**
74
+ * Focus a panel
75
+ */
76
+ focusPanel(id) {
77
+ // Unfocus all panels
78
+ for (const panel of this.panels.values()) {
79
+ panel.focused = false;
80
+ }
81
+ const panel = this.panels.get(id);
82
+ if (panel) {
83
+ panel.focused = true;
84
+ panel.zIndex = Math.max(...Array.from(this.panels.values()).map((p) => p.zIndex)) + 1;
85
+ this.focusedPanelId = id;
86
+ }
87
+ }
88
+ /**
89
+ * Get focused panel
90
+ */
91
+ getFocusedPanel() {
92
+ return this.focusedPanelId ? this.panels.get(this.focusedPanelId) || null : null;
93
+ }
94
+ /**
95
+ * Create overlay
96
+ */
97
+ createOverlay(id, viewport, modal = false) {
98
+ const overlay = {
99
+ id,
100
+ viewport: { ...viewport },
101
+ zIndex: 1000 + this.overlays.size,
102
+ modal,
103
+ };
104
+ this.overlays.set(id, overlay);
105
+ return overlay;
106
+ }
107
+ /**
108
+ * Remove overlay
109
+ */
110
+ removeOverlay(id) {
111
+ this.overlays.delete(id);
112
+ }
113
+ /**
114
+ * Get all visible panels (sorted by z-index)
115
+ */
116
+ getVisiblePanels() {
117
+ return Array.from(this.panels.values())
118
+ .filter((p) => p.visible)
119
+ .sort((a, b) => a.zIndex - b.zIndex);
120
+ }
121
+ /**
122
+ * Get all overlays (sorted by z-index)
123
+ */
124
+ getOverlays() {
125
+ return Array.from(this.overlays.values()).sort((a, b) => a.zIndex - b.zIndex);
126
+ }
127
+ /**
128
+ * Create a new tab
129
+ */
130
+ createTab(tabId) {
131
+ if (!this.tabs.has(tabId)) {
132
+ this.tabs.set(tabId, new Set());
133
+ }
134
+ }
135
+ /**
136
+ * Switch to a tab
137
+ */
138
+ switchTab(tabId) {
139
+ if (this.tabs.has(tabId)) {
140
+ this.activeTab = tabId;
141
+ // Hide panels not in this tab
142
+ for (const [panelId, panel] of this.panels.entries()) {
143
+ const tabPanels = this.tabs.get(tabId);
144
+ panel.visible = tabPanels?.has(panelId) || false;
145
+ }
146
+ }
147
+ }
148
+ /**
149
+ * Add panel to tab
150
+ */
151
+ addPanelToTab(panelId, tabId) {
152
+ const tab = this.tabs.get(tabId);
153
+ if (tab) {
154
+ tab.add(panelId);
155
+ }
156
+ }
157
+ /**
158
+ * Remove panel
159
+ */
160
+ removePanel(id) {
161
+ this.panels.delete(id);
162
+ for (const tab of this.tabs.values()) {
163
+ tab.delete(id);
164
+ }
165
+ if (this.focusedPanelId === id) {
166
+ this.focusedPanelId = null;
167
+ }
168
+ }
169
+ /**
170
+ * Recalculate layouts after screen size change
171
+ */
172
+ recalculateLayouts() {
173
+ // In production, would trigger layout recalculation
174
+ // For now, just ensure viewports are within bounds
175
+ for (const panel of this.panels.values()) {
176
+ panel.viewport.width = Math.min(panel.viewport.width, this.screenWidth - panel.viewport.x);
177
+ panel.viewport.height = Math.min(panel.viewport.height, this.screenHeight - panel.viewport.y);
178
+ }
179
+ }
180
+ }
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Theme Engine for BASETREE V8
3
+ * 24-bit color support, theme system, adaptive typography
4
+ */
5
+ export class ThemeEngine {
6
+ currentTheme = 'dark';
7
+ themes = new Map();
8
+ constructor() {
9
+ this.initializeThemes();
10
+ }
11
+ /**
12
+ * Initialize built-in themes
13
+ */
14
+ initializeThemes() {
15
+ // Dark theme
16
+ this.themes.set('dark', {
17
+ name: 'dark',
18
+ background: { r: 10, g: 10, b: 10 },
19
+ foreground: { r: 224, g: 224, b: 224 },
20
+ primary: { r: 33, g: 150, b: 243 },
21
+ secondary: { r: 156, g: 39, b: 176 },
22
+ success: { r: 76, g: 175, b: 80 },
23
+ warning: { r: 255, g: 152, b: 0 },
24
+ error: { r: 244, g: 67, b: 54 },
25
+ info: { r: 3, g: 169, b: 244 },
26
+ border: { r: 51, g: 51, b: 51 },
27
+ muted: { r: 136, g: 136, b: 136 },
28
+ });
29
+ // Neon theme
30
+ this.themes.set('neon', {
31
+ name: 'neon',
32
+ background: { r: 0, g: 0, b: 0 },
33
+ foreground: { r: 0, g: 255, b: 255 },
34
+ primary: { r: 255, g: 0, b: 255 },
35
+ secondary: { r: 0, g: 255, b: 0 },
36
+ success: { r: 0, g: 255, b: 128 },
37
+ warning: { r: 255, g: 255, b: 0 },
38
+ error: { r: 255, g: 0, b: 0 },
39
+ info: { r: 0, g: 128, b: 255 },
40
+ border: { r: 128, g: 0, b: 255 },
41
+ muted: { r: 128, g: 128, b: 128 },
42
+ });
43
+ // Minimal theme
44
+ this.themes.set('minimal', {
45
+ name: 'minimal',
46
+ background: { r: 255, g: 255, b: 255 },
47
+ foreground: { r: 0, g: 0, b: 0 },
48
+ primary: { r: 0, g: 0, b: 0 },
49
+ secondary: { r: 128, g: 128, b: 128 },
50
+ success: { r: 0, g: 128, b: 0 },
51
+ warning: { r: 255, g: 165, b: 0 },
52
+ error: { r: 255, g: 0, b: 0 },
53
+ info: { r: 0, g: 0, b: 255 },
54
+ border: { r: 200, g: 200, b: 200 },
55
+ muted: { r: 160, g: 160, b: 160 },
56
+ });
57
+ // Cinematic theme
58
+ this.themes.set('cinematic', {
59
+ name: 'cinematic',
60
+ background: { r: 18, g: 18, b: 18 },
61
+ foreground: { r: 245, g: 245, b: 245 },
62
+ primary: { r: 255, g: 215, b: 0 },
63
+ secondary: { r: 192, g: 192, b: 192 },
64
+ success: { r: 34, g: 139, b: 34 },
65
+ warning: { r: 255, g: 140, b: 0 },
66
+ error: { r: 220, g: 20, b: 60 },
67
+ info: { r: 135, g: 206, b: 250 },
68
+ border: { r: 64, g: 64, b: 64 },
69
+ muted: { r: 128, g: 128, b: 128 },
70
+ });
71
+ // Matrix theme
72
+ this.themes.set('matrix', {
73
+ name: 'matrix',
74
+ background: { r: 0, g: 0, b: 0 },
75
+ foreground: { r: 0, g: 255, b: 0 },
76
+ primary: { r: 0, g: 255, b: 0 },
77
+ secondary: { r: 0, g: 200, b: 0 },
78
+ success: { r: 0, g: 255, b: 0 },
79
+ warning: { r: 255, g: 255, b: 0 },
80
+ error: { r: 255, g: 0, b: 0 },
81
+ info: { r: 0, g: 200, b: 255 },
82
+ border: { r: 0, g: 128, b: 0 },
83
+ muted: { r: 0, g: 100, b: 0 },
84
+ });
85
+ // Blueprint theme
86
+ this.themes.set('blueprint', {
87
+ name: 'blueprint',
88
+ background: { r: 25, g: 25, b: 112 },
89
+ foreground: { r: 135, g: 206, b: 250 },
90
+ primary: { r: 0, g: 191, b: 255 },
91
+ secondary: { r: 70, g: 130, b: 180 },
92
+ success: { r: 0, g: 255, b: 127 },
93
+ warning: { r: 255, g: 215, b: 0 },
94
+ error: { r: 255, g: 99, b: 71 },
95
+ info: { r: 135, g: 206, b: 250 },
96
+ border: { r: 65, g: 105, b: 225 },
97
+ muted: { r: 100, g: 149, b: 237 },
98
+ });
99
+ // Paper theme
100
+ this.themes.set('paper', {
101
+ name: 'paper',
102
+ background: { r: 250, g: 250, b: 245 },
103
+ foreground: { r: 30, g: 30, b: 30 },
104
+ primary: { r: 33, g: 33, b: 33 },
105
+ secondary: { r: 100, g: 100, b: 100 },
106
+ success: { r: 46, g: 125, b: 50 },
107
+ warning: { r: 237, g: 108, b: 2 },
108
+ error: { r: 198, g: 40, b: 40 },
109
+ info: { r: 25, g: 118, b: 210 },
110
+ border: { r: 224, g: 224, b: 224 },
111
+ muted: { r: 158, g: 158, b: 158 },
112
+ });
113
+ }
114
+ /**
115
+ * Set current theme
116
+ */
117
+ setTheme(themeName) {
118
+ if (this.themes.has(themeName)) {
119
+ this.currentTheme = themeName;
120
+ }
121
+ }
122
+ /**
123
+ * Get current theme
124
+ */
125
+ getTheme() {
126
+ return this.themes.get(this.currentTheme) || this.themes.get('dark');
127
+ }
128
+ /**
129
+ * Get color as ANSI 24-bit color code
130
+ */
131
+ colorToAnsi(color, foreground = true) {
132
+ const code = foreground ? 38 : 48;
133
+ return `\x1b[${code};2;${color.r};${color.g};${color.b}m`;
134
+ }
135
+ /**
136
+ * Reset ANSI color
137
+ */
138
+ resetColor() {
139
+ return '\x1b[0m';
140
+ }
141
+ /**
142
+ * Get theme color as ANSI
143
+ */
144
+ getColor(key, foreground = true) {
145
+ const theme = this.getTheme();
146
+ const color = theme[key];
147
+ return this.colorToAnsi(color, foreground);
148
+ }
149
+ /**
150
+ * Create gradient between two colors
151
+ */
152
+ createGradient(color1, color2, steps) {
153
+ const gradient = [];
154
+ for (let i = 0; i < steps; i++) {
155
+ const t = i / (steps - 1);
156
+ gradient.push({
157
+ r: Math.round(color1.r + (color2.r - color1.r) * t),
158
+ g: Math.round(color1.g + (color2.g - color1.g) * t),
159
+ b: Math.round(color1.b + (color2.b - color1.b) * t),
160
+ });
161
+ }
162
+ return gradient;
163
+ }
164
+ }