@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.
- package/.env.example +10 -0
- package/README.md +369 -0
- package/dist/agents/alignmentAgent.js +68 -0
- package/dist/agents/governanceOrchestrator.js +152 -0
- package/dist/agents/planet/climateAgent.js +39 -0
- package/dist/agents/planet/diplomacyAgent.js +52 -0
- package/dist/agents/planet/discoveryAgent.js +41 -0
- package/dist/agents/planet/economicAgent.js +64 -0
- package/dist/agents/planet/educationAgent.js +41 -0
- package/dist/agents/planet/governanceCouncilAgent.js +76 -0
- package/dist/agents/planet/healthcareAgent.js +42 -0
- package/dist/agents/planet/infrastructureAgent.js +49 -0
- package/dist/agents/planet/planetAgent.js +5 -0
- package/dist/agents/planet/riskStabilityAgent.js +84 -0
- package/dist/agents/planet/urbanSystemsAgent.js +42 -0
- package/dist/agents/policyAgent.js +31 -0
- package/dist/agents/promptGenomeAgent.js +120 -0
- package/dist/agents/reasoningOptimizerAgent.js +72 -0
- package/dist/agents/regressionAgent.js +162 -0
- package/dist/agents/reinforcementLearnerAgent.js +108 -0
- package/dist/agents/riskEvaluationAgent.js +131 -0
- package/dist/agents/rollbackAgent.js +53 -0
- package/dist/agents/stabilityAgent.js +90 -0
- package/dist/agents/strategyMutationAgent.js +74 -0
- package/dist/agents/systemIntrospectionAgent.js +274 -0
- package/dist/agents/upgradeExecutorAgent.js +146 -0
- package/dist/agents/upgradePlannerAgent.js +80 -0
- package/dist/agents/venture/businessModelAgent.js +81 -0
- package/dist/agents/venture/growthAgent.js +82 -0
- package/dist/agents/venture/ideationAgent.js +89 -0
- package/dist/agents/venture/investorAgent.js +90 -0
- package/dist/agents/venture/legalAgent.js +112 -0
- package/dist/agents/venture/marketResearchAgent.js +80 -0
- package/dist/agents/venture/productAgent.js +96 -0
- package/dist/agents/venture/revenueAgent.js +63 -0
- package/dist/agents/venture/validationAgent.js +189 -0
- package/dist/bootstrap.js +200 -0
- package/dist/cli.js +453 -0
- package/dist/cognitiveGraph/cognitiveGraphEngine.js +180 -0
- package/dist/cognitiveGraph/graphStore.js +81 -0
- package/dist/cognitiveGraph/reasoningStreamBus.js +190 -0
- package/dist/config/config.js +76 -0
- package/dist/core/agent/AdaptivePlanner.js +49 -0
- package/dist/core/agent/AutoFixEngine.js +37 -0
- package/dist/core/agent/ExecutorAgent.js +79 -0
- package/dist/core/agent/LearningMemoryAgent.js +67 -0
- package/dist/core/agent/MemoryAgent.js +35 -0
- package/dist/core/agent/MetaCognitionAgent.js +38 -0
- package/dist/core/agent/PlannerAgent.js +59 -0
- package/dist/core/agent/ReflectionLoop.js +34 -0
- package/dist/core/agent/ReviewerAgent.js +34 -0
- package/dist/core/agent/VerificationAgent.js +20 -0
- package/dist/core/agent/specialists/SpecializedAgents.js +43 -0
- package/dist/core/ai/GeminiProvider.js +113 -0
- package/dist/core/ai/listModels.js +73 -0
- package/dist/core/monitor/PerformanceMonitor.js +18 -0
- package/dist/core/swarm/AgentSwarm.js +56 -0
- package/dist/core/swarm/ReasoningBus.js +26 -0
- package/dist/core/swarm/SwarmOrchestrator.js +36 -0
- package/dist/discovery/experimentOrchestrator.js +75 -0
- package/dist/discovery/hypothesisEngine.js +79 -0
- package/dist/discovery/knowledgeSynthesizer.js +83 -0
- package/dist/discovery/simulationPipeline.js +57 -0
- package/dist/experiments/experimentationEngine.js +174 -0
- package/dist/index.js +67 -0
- package/dist/kernel/eventBus.js +89 -0
- package/dist/kernel/kernel.js +146 -0
- package/dist/llm/tokenEfficiencyOptimizer.js +91 -0
- package/dist/memory/civilizationMemory.js +147 -0
- package/dist/memory/globalVectorMemory.js +87 -0
- package/dist/mesh/crossOrgProtocol.js +110 -0
- package/dist/mesh/globalReasoningBus.js +99 -0
- package/dist/observability/businessDashboard.js +103 -0
- package/dist/observability/businessMetrics.js +105 -0
- package/dist/observability/cognitiveMetrics.js +119 -0
- package/dist/observability/failureSurfaceMapper.js +135 -0
- package/dist/observability/metricsCollector.js +94 -0
- package/dist/observability/planetaryDashboard.js +97 -0
- package/dist/observability/planetaryMetrics.js +127 -0
- package/dist/observability/reportRenderer.js +100 -0
- package/dist/performance/memoryProfiler.js +107 -0
- package/dist/performance/profiler.js +130 -0
- package/dist/pipelines/evolvePipeline.js +150 -0
- package/dist/pipelines/governanceReviewPipeline.js +68 -0
- package/dist/pipelines/introspectPipeline.js +73 -0
- package/dist/pipelines/venture/growPipeline.js +51 -0
- package/dist/pipelines/venture/launchPipeline.js +55 -0
- package/dist/pipelines/venture/monetizePipeline.js +46 -0
- package/dist/pipelines/venture/shutdownPipeline.js +40 -0
- package/dist/pipelines/venture/startupPipeline.js +145 -0
- package/dist/pipelines/venture/validatePipeline.js +40 -0
- package/dist/planet/controlPlane.js +131 -0
- package/dist/planet/executionEngine.js +142 -0
- package/dist/planet/globalTypes.js +5 -0
- package/dist/planet/regionManager.js +114 -0
- package/dist/quality/codeQualityAuditor.js +161 -0
- package/dist/safety/containmentProtocols.js +87 -0
- package/dist/safety/integrityChecker.js +110 -0
- package/dist/safety/kernelGuard.js +57 -0
- package/dist/safety/killSwitch.js +100 -0
- package/dist/safety/planetaryKernel.js +92 -0
- package/dist/safety/policyEngine.js +129 -0
- package/dist/safety/rollbackManager.js +141 -0
- package/dist/safety/sandbox.js +143 -0
- package/dist/server/mindmapServer.js +102 -0
- package/dist/state/distributedState.js +241 -0
- package/dist/state/fileStateStore.js +264 -0
- package/dist/state/snapshotter.js +96 -0
- package/dist/state/stateStore.js +5 -0
- package/dist/tools/FileTools.js +25 -0
- package/dist/tools/GitTools.js +16 -0
- package/dist/tools/ShellTools.js +24 -0
- package/dist/types/architecture.js +5 -0
- package/dist/types/core.js +35 -0
- package/dist/types/governance.js +5 -0
- package/dist/types/venture.js +5 -0
- package/dist/ui/App.js +32 -0
- package/dist/ui/animation/AnimationEngine.js +117 -0
- package/dist/ui/animation/Easing.js +61 -0
- package/dist/ui/cli.js +50 -0
- package/dist/ui/command/ActionPreview.js +47 -0
- package/dist/ui/command/CommandPalette.js +55 -0
- package/dist/ui/command/NaturalLanguageBar.js +77 -0
- package/dist/ui/emotion/AnimationSequences.js +59 -0
- package/dist/ui/emotion/EmotionalUXEngine.js +86 -0
- package/dist/ui/integration/BackendAdapter.js +50 -0
- package/dist/ui/integration/WebSocketAdapter.js +90 -0
- package/dist/ui/intelligence/AdaptiveUIEngine.js +75 -0
- package/dist/ui/intelligence/UserBehaviorTracker.js +88 -0
- package/dist/ui/layout/LayoutEngine.js +115 -0
- package/dist/ui/mindmap/CognitiveMindmapRenderer.js +53 -0
- package/dist/ui/mindmap/EdgeRenderer.js +35 -0
- package/dist/ui/mindmap/GraphLayout.js +137 -0
- package/dist/ui/mindmap/MindmapControls.js +53 -0
- package/dist/ui/mindmap/NodeRenderer.js +53 -0
- package/dist/ui/modes/CognitiveMode.js +31 -0
- package/dist/ui/modes/CommandMode.js +6 -0
- package/dist/ui/modes/GovernanceMode.js +6 -0
- package/dist/ui/modes/MissionControlMode.js +6 -0
- package/dist/ui/modes/ModeManager.js +67 -0
- package/dist/ui/modes/ObservatoryMode.js +10 -0
- package/dist/ui/modes/TimelineMode.js +27 -0
- package/dist/ui/terminalOS.js +180 -0
- package/dist/ui/theme/ThemeEngine.js +164 -0
- package/dist/ui/visual/ColorGradient.js +91 -0
- package/dist/ui/visual/Typography.js +128 -0
- package/dist/ui/visual/UnicodeRenderer.js +86 -0
- package/dist/venture/ventureMemory.js +62 -0
- package/package.json +70 -0
package/.env.example
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Required: your Gemini API key (get one at https://aistudio.google.com/apikey)
|
|
2
|
+
GEMINI_API_KEY=AIzaSyCKZLHXtSXgfwv8mDWa9aAub1fVD0Km9yY
|
|
3
|
+
|
|
4
|
+
# Optional: model for chat/generation. If empty or unset, ListModels is called
|
|
5
|
+
# and an available default (e.g. gemini-2.0-flash, gemini-1.5-flash) is used.
|
|
6
|
+
# Embedding model is also chosen from ListModels when not specified.
|
|
7
|
+
# GEMINI_MODEL=
|
|
8
|
+
|
|
9
|
+
BASE_DIRECTORY=.
|
|
10
|
+
DEBUG=false
|
package/README.md
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
# 🌳 BASETREE V6: Autonomous Startup Builder Intelligence
|
|
2
|
+
|
|
3
|
+
BASETREE V6 extends V5's self-evolution capabilities into a full-stack autonomous venture creation system. It can ideate, validate, build, launch, grow, and monetize startups autonomously.
|
|
4
|
+
|
|
5
|
+
**BASETREE is no longer just building software — it now builds companies.**
|
|
6
|
+
|
|
7
|
+
## 🚀 V6: Autonomous Startup Builder
|
|
8
|
+
|
|
9
|
+
### Venture Intelligence Layer
|
|
10
|
+
- **Ideation Agent**: Generates startup ideas based on market gaps
|
|
11
|
+
- **Market Research Agent**: Competitive analysis, TAM/SAM/SOM estimation
|
|
12
|
+
- **Validation Agent**: Landing pages, surveys, A/B testing
|
|
13
|
+
- **Business Model Agent**: Pricing, monetization, unit economics
|
|
14
|
+
- **Product Agent**: MVP definition & roadmap
|
|
15
|
+
- **Growth Agent**: SEO, funnels, virality loops
|
|
16
|
+
- **Revenue Agent**: Monetization experiments
|
|
17
|
+
- **Legal Agent**: Compliance, privacy, ToS generation
|
|
18
|
+
- **Investor Agent**: Pitch decks, financial projections
|
|
19
|
+
|
|
20
|
+
### Autonomous Venture Loop
|
|
21
|
+
The complete startup lifecycle:
|
|
22
|
+
1. **Ideation**: Generate and refine startup ideas
|
|
23
|
+
2. **Market Research**: Analyze market size and competition
|
|
24
|
+
3. **Validation**: Create landing pages and run experiments
|
|
25
|
+
4. **MVP Build**: Define and build minimum viable product
|
|
26
|
+
5. **Launch**: Deploy and go live
|
|
27
|
+
6. **Growth**: Run growth experiments and optimize
|
|
28
|
+
7. **Monetization**: Test pricing and revenue models
|
|
29
|
+
8. **Evolution**: Continuous iteration and learning
|
|
30
|
+
|
|
31
|
+
### Venture Memory System
|
|
32
|
+
- Stores market patterns across ventures
|
|
33
|
+
- Records failure lessons for future reference
|
|
34
|
+
- Captures successful traction models
|
|
35
|
+
- Enables cross-venture learning
|
|
36
|
+
|
|
37
|
+
### Experimentation Engine
|
|
38
|
+
- Landing page generation with A/B testing
|
|
39
|
+
- Pricing elasticity experiments
|
|
40
|
+
- Feature gate testing
|
|
41
|
+
- Conversion funnel optimization
|
|
42
|
+
|
|
43
|
+
### Business Observability
|
|
44
|
+
- **MRR Tracking**: Monthly recurring revenue
|
|
45
|
+
- **CAC/LTV Analysis**: Customer acquisition cost and lifetime value
|
|
46
|
+
- **Retention Metrics**: User retention tracking
|
|
47
|
+
- **Activation Funnels**: Conversion funnel analysis
|
|
48
|
+
- **Growth Velocity**: Growth rate tracking
|
|
49
|
+
- **Experiment Success Rates**: A/B test outcomes
|
|
50
|
+
|
|
51
|
+
## 📖 V6 Usage
|
|
52
|
+
|
|
53
|
+
### Create a New Venture
|
|
54
|
+
```bash
|
|
55
|
+
basetree startup "AI tutor for rural students"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This will:
|
|
59
|
+
1. Generate a structured startup idea
|
|
60
|
+
2. Research the market (TAM/SAM/SOM)
|
|
61
|
+
3. Design business model and pricing
|
|
62
|
+
4. Define MVP features
|
|
63
|
+
5. Create validation experiments
|
|
64
|
+
6. Set up venture structure
|
|
65
|
+
|
|
66
|
+
### Validate Your Venture
|
|
67
|
+
```bash
|
|
68
|
+
basetree validate <venture-id>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Creates landing page variants and validation experiments.
|
|
72
|
+
|
|
73
|
+
### Launch Your Venture
|
|
74
|
+
```bash
|
|
75
|
+
basetree launch <venture-id>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Builds and deploys the MVP.
|
|
79
|
+
|
|
80
|
+
### Grow Your Venture
|
|
81
|
+
```bash
|
|
82
|
+
basetree grow <venture-id>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Runs growth experiments, SEO optimization, and funnel design.
|
|
86
|
+
|
|
87
|
+
### Monetize Your Venture
|
|
88
|
+
```bash
|
|
89
|
+
basetree monetize <venture-id>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Tests pricing models and optimizes revenue.
|
|
93
|
+
|
|
94
|
+
### View Business Metrics
|
|
95
|
+
```bash
|
|
96
|
+
basetree metrics --venture <venture-id>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Shows MRR, CAC/LTV, retention, funnels, and experiment results.
|
|
100
|
+
|
|
101
|
+
### Shutdown a Venture
|
|
102
|
+
```bash
|
|
103
|
+
basetree shutdown <venture-id> --reason "Market conditions"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Gracefully shuts down and records lessons learned.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 🧬 V5: Self-Architecting Engineering Intelligence
|
|
111
|
+
|
|
112
|
+
BASETREE V5 is a self-evolving engineering intelligence system that can design, evolve, refactor, and optimize its own internal architecture, reasoning systems, and execution strategies autonomously.
|
|
113
|
+
|
|
114
|
+
**BASETREE V5 builds and evolves itself.**
|
|
115
|
+
|
|
116
|
+
## 🧬 Core Features
|
|
117
|
+
|
|
118
|
+
### Self-Architecture Engine
|
|
119
|
+
- **System Introspection Agent**: Analyzes BASETREE's internal modules, agent flows, performance bottlenecks
|
|
120
|
+
- **Upgrade Proposals**: Generates architectural upgrade proposals based on introspection
|
|
121
|
+
- **Self-Modification**: Can propose and implement PRs to its own codebase
|
|
122
|
+
|
|
123
|
+
### Continuous Self-Refactoring
|
|
124
|
+
- **Automatic Code Quality Audits**: ESLint/TypeScript integration, cyclomatic complexity checks
|
|
125
|
+
- **Performance Profiling**: Runtime hotspot detection, memory leak detection
|
|
126
|
+
- **Token Efficiency Tuning**: Analyzes and optimizes LLM token usage
|
|
127
|
+
|
|
128
|
+
### Meta-Agent Governance
|
|
129
|
+
- **Policy Agent**: Enforces high-level policies (kernel protection, risk thresholds)
|
|
130
|
+
- **Stability Agent**: Ensures system stability (blast radius, dependency analysis)
|
|
131
|
+
- **Alignment Agent**: Checks alignment with project objectives and safety constraints
|
|
132
|
+
- **Risk Evaluation Agent**: Assigns risk scores based on impact, uncertainty, historical failures
|
|
133
|
+
- **Governance Orchestrator**: Coordinates all governance agents for final decisions
|
|
134
|
+
|
|
135
|
+
### Self-Safety Framework
|
|
136
|
+
- **Immutable Core Kernel**: Protected kernel modules cannot be modified
|
|
137
|
+
- **Sandboxed Execution**: All upgrades run in isolated sandbox workspaces
|
|
138
|
+
- **Cryptographic Integrity**: Hash-based verification of code changes
|
|
139
|
+
- **Rollback System**: Automatic rollback on regression failures
|
|
140
|
+
|
|
141
|
+
### Cognitive Evolution Layer
|
|
142
|
+
- **Reasoning Optimizer**: Adjusts reasoning depth and strategies based on performance
|
|
143
|
+
- **Strategy Mutation**: A/B testing of execution strategies
|
|
144
|
+
- **Prompt Genome**: Evolves prompt templates using reinforcement learning
|
|
145
|
+
- **Reinforcement Learner**: Learns from execution outcomes to improve decisions
|
|
146
|
+
|
|
147
|
+
### Self-Observability Plane
|
|
148
|
+
- **Cognitive Drift Metrics**: Tracks architectural changes over time
|
|
149
|
+
- **Architectural Entropy**: Measures system complexity and organization
|
|
150
|
+
- **Learning Velocity**: Tracks improvement rate and success trends
|
|
151
|
+
- **Failure Surface Mapping**: Identifies failure hotspots and patterns
|
|
152
|
+
|
|
153
|
+
## 🚀 Installation
|
|
154
|
+
|
|
155
|
+
1. Clone the repository:
|
|
156
|
+
```bash
|
|
157
|
+
git clone <repo-url>
|
|
158
|
+
cd Basetree
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
2. Install dependencies:
|
|
162
|
+
```bash
|
|
163
|
+
npm install
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
3. Build the project:
|
|
167
|
+
```bash
|
|
168
|
+
npm run build
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Install as global CLI (npm)
|
|
172
|
+
|
|
173
|
+
Once published to npm, you (or other users) can install BASETREE as a global CLI:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
npm install -g basetree # or your final npm package name
|
|
177
|
+
basetree --help
|
|
178
|
+
basetree chat
|
|
179
|
+
basetree ui
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## 📖 Usage
|
|
183
|
+
|
|
184
|
+
### Self-Evolution Pipeline
|
|
185
|
+
|
|
186
|
+
Run the full self-evolution cycle:
|
|
187
|
+
```bash
|
|
188
|
+
npm run evolve
|
|
189
|
+
# or
|
|
190
|
+
basetree evolve
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
This will:
|
|
194
|
+
1. Snapshot current system state
|
|
195
|
+
2. Run system introspection
|
|
196
|
+
3. Generate upgrade proposals
|
|
197
|
+
4. Evaluate proposals through governance
|
|
198
|
+
5. Apply approved upgrades in sandbox
|
|
199
|
+
6. Run regression tests
|
|
200
|
+
7. Apply to main workspace if tests pass
|
|
201
|
+
|
|
202
|
+
### Dry Run Mode
|
|
203
|
+
|
|
204
|
+
See what would be done without applying changes:
|
|
205
|
+
```bash
|
|
206
|
+
basetree evolve --dry-run
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### System Introspection
|
|
210
|
+
|
|
211
|
+
Run introspection alone to see system analysis:
|
|
212
|
+
```bash
|
|
213
|
+
basetree introspect
|
|
214
|
+
# or with JSON output
|
|
215
|
+
basetree introspect --output json
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Governance Review
|
|
219
|
+
|
|
220
|
+
Review and evaluate proposals:
|
|
221
|
+
```bash
|
|
222
|
+
# Review all pending proposals
|
|
223
|
+
basetree govern --all-pending
|
|
224
|
+
|
|
225
|
+
# Review specific proposal
|
|
226
|
+
basetree govern --proposal-id <id>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Metrics Dashboard
|
|
230
|
+
|
|
231
|
+
View observability metrics:
|
|
232
|
+
```bash
|
|
233
|
+
basetree metrics
|
|
234
|
+
# or JSON format
|
|
235
|
+
basetree metrics --format json
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## 🏗️ Architecture
|
|
239
|
+
|
|
240
|
+
### V6 Venture Structure
|
|
241
|
+
|
|
242
|
+
Each venture is a self-contained project in `ventures/<slug>/`:
|
|
243
|
+
```
|
|
244
|
+
ventures/
|
|
245
|
+
<slug>/
|
|
246
|
+
package.json # Project dependencies
|
|
247
|
+
src/ # Source code
|
|
248
|
+
landing/ # Landing page variants
|
|
249
|
+
experiments/ # Experiment configs
|
|
250
|
+
README.md # Venture documentation
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Core Components
|
|
254
|
+
|
|
255
|
+
- **Kernel**: Immutable core runtime with event bus, agent registry, state store
|
|
256
|
+
- **Event Bus**: Typed event system for system-wide communication
|
|
257
|
+
- **State Store**: Versioned storage for snapshots, proposals, runs, metrics, ventures, experiments
|
|
258
|
+
- **Safety Layer**: Sandbox, kernel guard, integrity checker, rollback manager
|
|
259
|
+
- **Venture Memory**: Cross-venture learning and pattern storage
|
|
260
|
+
|
|
261
|
+
### Agents
|
|
262
|
+
|
|
263
|
+
- **System Introspection Agent**: Analyzes codebase architecture
|
|
264
|
+
- **Governance Agents**: Policy, Stability, Alignment, Risk evaluation
|
|
265
|
+
- **Upgrade Agents**: Planner and Executor for implementing changes
|
|
266
|
+
- **Regression Agent**: Runs tests and validates upgrades
|
|
267
|
+
- **Cognitive Evolution Agents**: Reasoning optimizer, strategy mutation, prompt genome, RL learner
|
|
268
|
+
|
|
269
|
+
### Pipelines
|
|
270
|
+
|
|
271
|
+
- **Evolve Pipeline**: Full self-evolution cycle
|
|
272
|
+
- **Introspect Pipeline**: System analysis and reporting
|
|
273
|
+
- **Governance Review Pipeline**: Proposal evaluation
|
|
274
|
+
|
|
275
|
+
## 🛡️ Safety Guarantees
|
|
276
|
+
|
|
277
|
+
1. **Kernel Protection**: Core kernel modules are immutable and cannot be modified
|
|
278
|
+
2. **Sandboxed Execution**: All upgrades run in isolated workspaces
|
|
279
|
+
3. **Governance Approval**: All changes require approval from meta-agents
|
|
280
|
+
4. **Regression Testing**: Full test suite runs before applying changes
|
|
281
|
+
5. **Automatic Rollback**: Failed upgrades are automatically rolled back
|
|
282
|
+
6. **Integrity Verification**: Cryptographic hashes verify code integrity
|
|
283
|
+
|
|
284
|
+
## 📊 Observability
|
|
285
|
+
|
|
286
|
+
BASETREE V5 provides comprehensive observability:
|
|
287
|
+
|
|
288
|
+
- **Cognitive Drift**: Track how architecture evolves over time
|
|
289
|
+
- **Architectural Entropy**: Measure system complexity and organization
|
|
290
|
+
- **Learning Velocity**: Monitor improvement rate and success trends
|
|
291
|
+
- **Failure Surface**: Identify failure hotspots and common patterns
|
|
292
|
+
- **Metrics Dashboard**: Real-time metrics on all system operations
|
|
293
|
+
|
|
294
|
+
## 🔧 Configuration
|
|
295
|
+
|
|
296
|
+
Create `basetree-v5.config.json` in your workspace root:
|
|
297
|
+
|
|
298
|
+
```json
|
|
299
|
+
{
|
|
300
|
+
"safety": {
|
|
301
|
+
"kernelGuardEnabled": true,
|
|
302
|
+
"protectedPaths": ["src/kernel", "src/safety"],
|
|
303
|
+
"maxRiskLevel": "medium",
|
|
304
|
+
"requireGovernanceApproval": true
|
|
305
|
+
},
|
|
306
|
+
"thresholds": {
|
|
307
|
+
"maxComplexity": 50,
|
|
308
|
+
"maxBlastRadius": 10,
|
|
309
|
+
"maxRiskScore": 0.7,
|
|
310
|
+
"minStabilityScore": 0.6,
|
|
311
|
+
"minAlignmentScore": 0.7
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## 🧪 Testing
|
|
317
|
+
|
|
318
|
+
Run the test suite:
|
|
319
|
+
```bash
|
|
320
|
+
npm test
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## 📝 Development
|
|
324
|
+
|
|
325
|
+
### Project Structure
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
src/
|
|
329
|
+
├── agents/ # All agent implementations
|
|
330
|
+
├── kernel/ # Core kernel and event bus
|
|
331
|
+
├── safety/ # Safety framework
|
|
332
|
+
├── state/ # State store and snapshotter
|
|
333
|
+
├── pipelines/ # Pipeline implementations
|
|
334
|
+
├── observability/ # Metrics and reporting
|
|
335
|
+
├── quality/ # Code quality analyzers
|
|
336
|
+
├── performance/ # Performance profilers
|
|
337
|
+
├── llm/ # LLM optimization
|
|
338
|
+
├── types/ # TypeScript type definitions
|
|
339
|
+
├── config/ # Configuration loader
|
|
340
|
+
├── cli.ts # CLI interface
|
|
341
|
+
├── bootstrap.ts # System bootstrap
|
|
342
|
+
└── index.ts # Main entry point
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## 🎯 How It Works
|
|
346
|
+
|
|
347
|
+
1. **Introspection**: System analyzes its own codebase, identifying bottlenecks and improvement opportunities
|
|
348
|
+
2. **Proposal Generation**: Creates structured upgrade proposals with risk assessments
|
|
349
|
+
3. **Governance Review**: Meta-agents evaluate proposals for safety, stability, alignment, and risk
|
|
350
|
+
4. **Sandboxed Execution**: Approved proposals are applied in isolated sandbox workspaces
|
|
351
|
+
5. **Regression Testing**: Full test suite validates that upgrades don't break functionality
|
|
352
|
+
6. **Safe Application**: If tests pass, upgrades are applied to main workspace
|
|
353
|
+
7. **Rollback on Failure**: Any failures trigger automatic rollback to previous state
|
|
354
|
+
8. **Learning**: System learns from outcomes to improve future proposals
|
|
355
|
+
|
|
356
|
+
## 🔮 Future Enhancements
|
|
357
|
+
|
|
358
|
+
- Web-based dashboard for observability metrics
|
|
359
|
+
- Integration with external LLM providers for code generation
|
|
360
|
+
- Advanced AST-based code transformations
|
|
361
|
+
- Multi-agent collaboration for complex refactorings
|
|
362
|
+
- Continuous monitoring and auto-evolution
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
Built with ❤️ by the BASETREE team
|
|
367
|
+
|
|
368
|
+
**Version**: 6.0.0
|
|
369
|
+
**Status**: Self-Evolving 🧬 | Building Companies 🚀
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alignment Agent for BASETREE V5
|
|
3
|
+
* Checks that proposals align with project objectives and safety constraints
|
|
4
|
+
*/
|
|
5
|
+
import { getConfig } from '../config/config.js';
|
|
6
|
+
import { KernelGuard } from '../safety/kernelGuard.js';
|
|
7
|
+
export class AlignmentAgent {
|
|
8
|
+
config = getConfig();
|
|
9
|
+
kernelGuard = new KernelGuard();
|
|
10
|
+
/**
|
|
11
|
+
* Evaluate alignment of a proposal
|
|
12
|
+
*/
|
|
13
|
+
async evaluate(proposal) {
|
|
14
|
+
const constraints = [];
|
|
15
|
+
// Check kernel protection alignment
|
|
16
|
+
const kernelCheck = this.kernelGuard.checkProposal(proposal);
|
|
17
|
+
constraints.push({
|
|
18
|
+
name: 'kernel_protection',
|
|
19
|
+
passed: kernelCheck.allowed,
|
|
20
|
+
message: kernelCheck.allowed
|
|
21
|
+
? 'Proposal respects kernel protection boundaries'
|
|
22
|
+
: kernelCheck.reason || 'Kernel protection violation',
|
|
23
|
+
});
|
|
24
|
+
// Check risk level alignment
|
|
25
|
+
const riskOrder = {
|
|
26
|
+
safe: 0,
|
|
27
|
+
low: 1,
|
|
28
|
+
medium: 2,
|
|
29
|
+
high: 3,
|
|
30
|
+
critical: 4,
|
|
31
|
+
};
|
|
32
|
+
const proposalRisk = riskOrder[proposal.riskLevel] || 0;
|
|
33
|
+
const maxRisk = riskOrder[this.config.safety.maxRiskLevel] || 2;
|
|
34
|
+
constraints.push({
|
|
35
|
+
name: 'risk_threshold',
|
|
36
|
+
passed: proposalRisk <= maxRisk,
|
|
37
|
+
message: proposalRisk <= maxRisk
|
|
38
|
+
? `Risk level ${proposal.riskLevel} is within acceptable range`
|
|
39
|
+
: `Risk level ${proposal.riskLevel} exceeds maximum ${this.config.safety.maxRiskLevel}`,
|
|
40
|
+
});
|
|
41
|
+
// Check that proposal has clear objectives
|
|
42
|
+
constraints.push({
|
|
43
|
+
name: 'clear_objectives',
|
|
44
|
+
passed: proposal.description.length > 20 && proposal.title.length > 5,
|
|
45
|
+
message: proposal.description.length > 20 && proposal.title.length > 5
|
|
46
|
+
? 'Proposal has clear objectives'
|
|
47
|
+
: 'Proposal lacks clear objectives',
|
|
48
|
+
});
|
|
49
|
+
// Check safety compliance
|
|
50
|
+
const safetyCompliant = constraints.every((c) => c.name === 'kernel_protection' || c.passed);
|
|
51
|
+
const alignsWithObjectives = constraints.filter((c) => c.passed).length >= constraints.length * 0.7;
|
|
52
|
+
// Calculate alignment score
|
|
53
|
+
const passedConstraints = constraints.filter((c) => c.passed).length;
|
|
54
|
+
const alignmentScore = constraints.length > 0 ? passedConstraints / constraints.length : 0;
|
|
55
|
+
return {
|
|
56
|
+
alignsWithObjectives,
|
|
57
|
+
safetyCompliant,
|
|
58
|
+
constraints,
|
|
59
|
+
alignmentScore,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get agent ID
|
|
64
|
+
*/
|
|
65
|
+
getId() {
|
|
66
|
+
return 'alignment-agent';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Governance Orchestrator for BASETREE V5
|
|
3
|
+
* Orchestrates meta-agents to produce final governance decision
|
|
4
|
+
*/
|
|
5
|
+
import { GovernanceDecision } from '../types/core.js';
|
|
6
|
+
import { PolicyAgent } from './policyAgent.js';
|
|
7
|
+
import { StabilityAgent } from './stabilityAgent.js';
|
|
8
|
+
import { AlignmentAgent } from './alignmentAgent.js';
|
|
9
|
+
import { RiskEvaluationAgent } from './riskEvaluationAgent.js';
|
|
10
|
+
import { getKernel } from '../kernel/kernel.js';
|
|
11
|
+
import { getEventBus } from '../kernel/eventBus.js';
|
|
12
|
+
import { getConfig } from '../config/config.js';
|
|
13
|
+
export class GovernanceOrchestrator {
|
|
14
|
+
policyAgent;
|
|
15
|
+
stabilityAgent;
|
|
16
|
+
alignmentAgent;
|
|
17
|
+
riskAgent;
|
|
18
|
+
kernel = getKernel();
|
|
19
|
+
eventBus = getEventBus();
|
|
20
|
+
config = getConfig();
|
|
21
|
+
constructor() {
|
|
22
|
+
this.policyAgent = new PolicyAgent();
|
|
23
|
+
this.stabilityAgent = new StabilityAgent();
|
|
24
|
+
this.alignmentAgent = new AlignmentAgent();
|
|
25
|
+
this.riskAgent = new RiskEvaluationAgent();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Evaluate proposal through all governance agents
|
|
29
|
+
*/
|
|
30
|
+
async evaluate(proposal) {
|
|
31
|
+
// Run all agents in parallel
|
|
32
|
+
const [policyResult, stabilityCheck, alignmentCheck, riskAssessment] = await Promise.all([
|
|
33
|
+
this.policyAgent.isAllowed(proposal),
|
|
34
|
+
this.stabilityAgent.evaluate(proposal),
|
|
35
|
+
this.alignmentAgent.evaluate(proposal),
|
|
36
|
+
this.riskAgent.evaluate(proposal),
|
|
37
|
+
]);
|
|
38
|
+
// Determine decision
|
|
39
|
+
const decision = this.makeDecision({
|
|
40
|
+
policyResult,
|
|
41
|
+
stabilityCheck,
|
|
42
|
+
alignmentCheck,
|
|
43
|
+
riskAssessment,
|
|
44
|
+
});
|
|
45
|
+
// Generate rationale
|
|
46
|
+
const rationale = this.generateRationale({
|
|
47
|
+
policyResult,
|
|
48
|
+
stabilityCheck,
|
|
49
|
+
alignmentCheck,
|
|
50
|
+
riskAssessment,
|
|
51
|
+
decision,
|
|
52
|
+
});
|
|
53
|
+
// Check for conditions
|
|
54
|
+
const conditions = this.extractConditions({
|
|
55
|
+
policyResult,
|
|
56
|
+
stabilityCheck,
|
|
57
|
+
alignmentCheck,
|
|
58
|
+
riskAssessment,
|
|
59
|
+
decision,
|
|
60
|
+
});
|
|
61
|
+
const verdict = {
|
|
62
|
+
decision,
|
|
63
|
+
rationale,
|
|
64
|
+
agentDecisions: {
|
|
65
|
+
policy: policyResult.evaluations,
|
|
66
|
+
stability: stabilityCheck,
|
|
67
|
+
alignment: alignmentCheck,
|
|
68
|
+
risk: riskAssessment,
|
|
69
|
+
},
|
|
70
|
+
conditions: conditions.length > 0 ? conditions : undefined,
|
|
71
|
+
timestamp: new Date(),
|
|
72
|
+
};
|
|
73
|
+
// Emit event
|
|
74
|
+
await this.eventBus.emit({
|
|
75
|
+
type: 'GovernanceDecision',
|
|
76
|
+
timestamp: verdict.timestamp,
|
|
77
|
+
proposalId: proposal.id,
|
|
78
|
+
decision,
|
|
79
|
+
});
|
|
80
|
+
return verdict;
|
|
81
|
+
}
|
|
82
|
+
makeDecision(context) {
|
|
83
|
+
// Block if policy violations
|
|
84
|
+
if (!context.policyResult.allowed) {
|
|
85
|
+
const blockingViolations = context.policyResult.evaluations.filter((e) => !e.passed && (e.severity === 'block' || e.severity === 'error'));
|
|
86
|
+
if (blockingViolations.length > 0) {
|
|
87
|
+
return GovernanceDecision.REJECT;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Check stability threshold
|
|
91
|
+
if (context.stabilityCheck.stabilityScore < this.config.thresholds.minStabilityScore) {
|
|
92
|
+
return GovernanceDecision.NEEDS_REVISION;
|
|
93
|
+
}
|
|
94
|
+
// Check alignment threshold
|
|
95
|
+
if (context.alignmentCheck.alignmentScore < this.config.thresholds.minAlignmentScore) {
|
|
96
|
+
return GovernanceDecision.NEEDS_REVISION;
|
|
97
|
+
}
|
|
98
|
+
// Check risk threshold
|
|
99
|
+
if (context.riskAssessment.riskScore > this.config.thresholds.maxRiskScore) {
|
|
100
|
+
return GovernanceDecision.NEEDS_REVISION;
|
|
101
|
+
}
|
|
102
|
+
// Check if risk level exceeds config
|
|
103
|
+
const riskOrder = {
|
|
104
|
+
safe: 0,
|
|
105
|
+
low: 1,
|
|
106
|
+
medium: 2,
|
|
107
|
+
high: 3,
|
|
108
|
+
critical: 4,
|
|
109
|
+
};
|
|
110
|
+
const proposalRisk = riskOrder[context.riskAssessment.riskLevel] || 0;
|
|
111
|
+
const maxRisk = riskOrder[this.config.safety.maxRiskLevel] || 2;
|
|
112
|
+
if (proposalRisk > maxRisk) {
|
|
113
|
+
return GovernanceDecision.REJECT;
|
|
114
|
+
}
|
|
115
|
+
// All checks passed
|
|
116
|
+
return GovernanceDecision.APPROVE;
|
|
117
|
+
}
|
|
118
|
+
generateRationale(context) {
|
|
119
|
+
const parts = [];
|
|
120
|
+
parts.push(`Decision: ${context.decision}`);
|
|
121
|
+
if (!context.policyResult.allowed) {
|
|
122
|
+
const violations = context.policyResult.evaluations.filter((e) => !e.passed);
|
|
123
|
+
parts.push(`Policy violations: ${violations.length} issue(s) found`);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
parts.push('Policy checks passed');
|
|
127
|
+
}
|
|
128
|
+
parts.push(`Stability score: ${(context.stabilityCheck.stabilityScore * 100).toFixed(0)}% (blast radius: ${context.stabilityCheck.blastRadius})`);
|
|
129
|
+
parts.push(`Alignment score: ${(context.alignmentCheck.alignmentScore * 100).toFixed(0)}%`);
|
|
130
|
+
parts.push(`Risk assessment: ${context.riskAssessment.riskLevel} (score: ${(context.riskAssessment.riskScore * 100).toFixed(0)}%)`);
|
|
131
|
+
return parts.join('. ');
|
|
132
|
+
}
|
|
133
|
+
extractConditions(context) {
|
|
134
|
+
const conditions = [];
|
|
135
|
+
if (context.decision === GovernanceDecision.APPROVE) {
|
|
136
|
+
// Add conditions for approval
|
|
137
|
+
if (context.stabilityCheck.stabilityScore < 0.8) {
|
|
138
|
+
conditions.push('Monitor stability metrics closely after deployment');
|
|
139
|
+
}
|
|
140
|
+
if (context.riskAssessment.riskScore > 0.5) {
|
|
141
|
+
conditions.push('Require additional testing before production deployment');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return conditions;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get agent ID
|
|
148
|
+
*/
|
|
149
|
+
getId() {
|
|
150
|
+
return 'governance-orchestrator';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Climate Agent for BASETREE V7
|
|
3
|
+
* Handles climate-related simulations and optimization tasks
|
|
4
|
+
*/
|
|
5
|
+
import { getKernel } from '../../kernel/kernel.js';
|
|
6
|
+
export class ClimateAgent {
|
|
7
|
+
id = 'climate-agent';
|
|
8
|
+
name = 'Climate Agent';
|
|
9
|
+
kernel = getKernel();
|
|
10
|
+
async handleGlobalEvent(event) {
|
|
11
|
+
// Monitor climate-related events
|
|
12
|
+
if (event.type.includes('climate') || event.type.includes('carbon')) {
|
|
13
|
+
await this.processClimateEvent(event);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async handleGoal(goal) {
|
|
17
|
+
// Check carbon constraints
|
|
18
|
+
if (goal.constraints.maxCarbon) {
|
|
19
|
+
// Validate carbon budget
|
|
20
|
+
return {
|
|
21
|
+
accepted: true,
|
|
22
|
+
reasoning: `Carbon constraint: ${goal.constraints.maxCarbon}kg CO2 maximum`,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
accepted: true,
|
|
27
|
+
reasoning: 'Climate agent will optimize for low-carbon execution',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async processClimateEvent(event) {
|
|
31
|
+
// Process climate events (carbon usage, optimization opportunities)
|
|
32
|
+
}
|
|
33
|
+
async initialize() {
|
|
34
|
+
// Initialize climate models
|
|
35
|
+
}
|
|
36
|
+
async shutdown() {
|
|
37
|
+
// Save climate data
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diplomacy Agent for BASETREE V7
|
|
3
|
+
* Handles cross-org negotiation using crossOrgProtocol
|
|
4
|
+
*/
|
|
5
|
+
import { getKernel } from '../../kernel/kernel.js';
|
|
6
|
+
import { CrossOrgProtocol } from '../../mesh/crossOrgProtocol.js';
|
|
7
|
+
export class DiplomacyAgent {
|
|
8
|
+
id = 'diplomacy-agent';
|
|
9
|
+
name = 'Diplomacy Agent';
|
|
10
|
+
kernel = getKernel();
|
|
11
|
+
crossOrgProtocol = new CrossOrgProtocol();
|
|
12
|
+
async handleGlobalEvent(event) {
|
|
13
|
+
// Monitor for cross-org events
|
|
14
|
+
if (event.type.includes('proposal') || event.type.includes('agreement')) {
|
|
15
|
+
await this.processDiplomaticEvent(event);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async handleGoal(goal) {
|
|
19
|
+
// If goal involves multiple orgs, coordinate negotiation
|
|
20
|
+
if (goal.orgId) {
|
|
21
|
+
// Check if goal requires cross-org collaboration
|
|
22
|
+
const requiresCollaboration = goal.description.toLowerCase().includes('collaborate') ||
|
|
23
|
+
goal.description.toLowerCase().includes('negotiate');
|
|
24
|
+
if (requiresCollaboration) {
|
|
25
|
+
return {
|
|
26
|
+
accepted: true,
|
|
27
|
+
reasoning: 'Goal requires cross-org collaboration - will initiate diplomatic protocol',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
accepted: true,
|
|
33
|
+
reasoning: 'Diplomacy agent monitoring for cross-org opportunities',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async processDiplomaticEvent(event) {
|
|
37
|
+
// Process diplomatic events (proposals, agreements, disputes)
|
|
38
|
+
const payload = event.payload;
|
|
39
|
+
if (payload?.type === 'proposal') {
|
|
40
|
+
// Handle proposal
|
|
41
|
+
}
|
|
42
|
+
else if (payload?.type === 'agreement') {
|
|
43
|
+
// Handle agreement
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async initialize() {
|
|
47
|
+
// Initialize diplomatic protocols
|
|
48
|
+
}
|
|
49
|
+
async shutdown() {
|
|
50
|
+
// Save diplomatic state
|
|
51
|
+
}
|
|
52
|
+
}
|