claude-mycelium 2.0.0 → 2.2.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/.agent-meta/_inhibitors.ndjson +1287 -0
- package/.agent-meta/_quarantine.json +45 -0
- package/.agent-meta/config.json +9 -0
- package/.agent-meta/tasks/_active.json +4 -0
- package/.agent-meta/tasks/task_0657b028-05a0-4b0c-b0b9-a4eae3d66cd9.json +168 -0
- package/.claude/memory.db +0 -0
- package/.claude/settings.local.json +4 -1
- package/README.md +85 -233
- package/SECURITY.md +145 -0
- package/dist/agent/task-worker.d.ts +11 -0
- package/dist/agent/task-worker.d.ts.map +1 -0
- package/dist/agent/task-worker.js +173 -0
- package/dist/agent/task-worker.js.map +1 -0
- package/dist/agent/worker.d.ts +8 -0
- package/dist/agent/worker.d.ts.map +1 -0
- package/dist/agent/worker.js +97 -0
- package/dist/agent/worker.js.map +1 -0
- package/dist/bin.d.ts +7 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +11 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli/cost.d.ts +10 -0
- package/dist/cli/cost.d.ts.map +1 -0
- package/dist/cli/cost.js +163 -0
- package/dist/cli/cost.js.map +1 -0
- package/dist/cli/gc.d.ts +10 -0
- package/dist/cli/gc.d.ts.map +1 -0
- package/dist/cli/gc.js +108 -0
- package/dist/cli/gc.js.map +1 -0
- package/dist/cli/gradients.d.ts +10 -0
- package/dist/cli/gradients.d.ts.map +1 -0
- package/dist/cli/gradients.js +70 -0
- package/dist/cli/gradients.js.map +1 -0
- package/dist/cli/grow.d.ts +17 -0
- package/dist/cli/grow.d.ts.map +1 -0
- package/dist/cli/grow.js +373 -0
- package/dist/cli/grow.js.map +1 -0
- package/dist/cli/index.d.ts +17 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +74 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +11 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +97 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/status.d.ts +10 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +191 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/coordination/file-locks.d.ts +42 -0
- package/dist/coordination/file-locks.d.ts.map +1 -0
- package/dist/coordination/file-locks.js +269 -0
- package/dist/coordination/file-locks.js.map +1 -0
- package/dist/coordination/index.d.ts +4 -0
- package/dist/coordination/index.d.ts.map +1 -1
- package/dist/coordination/index.js +4 -0
- package/dist/coordination/index.js.map +1 -1
- package/dist/coordination/inhibitors.d.ts +84 -0
- package/dist/coordination/inhibitors.d.ts.map +1 -0
- package/dist/coordination/inhibitors.js +290 -0
- package/dist/coordination/inhibitors.js.map +1 -0
- package/dist/coordination/process-manager.d.ts +73 -0
- package/dist/coordination/process-manager.d.ts.map +1 -0
- package/dist/coordination/process-manager.js +144 -0
- package/dist/coordination/process-manager.js.map +1 -0
- package/dist/core/agent-executor.d.ts +4 -1
- package/dist/core/agent-executor.d.ts.map +1 -1
- package/dist/core/agent-executor.js +38 -12
- package/dist/core/agent-executor.js.map +1 -1
- package/dist/core/change-applier.d.ts +29 -5
- package/dist/core/change-applier.d.ts.map +1 -1
- package/dist/core/change-applier.js +254 -24
- package/dist/core/change-applier.js.map +1 -1
- package/dist/core/signals/churn.d.ts.map +1 -1
- package/dist/core/signals/churn.js +6 -4
- package/dist/core/signals/churn.js.map +1 -1
- package/dist/core/signals/debt.d.ts.map +1 -1
- package/dist/core/signals/debt.js +4 -3
- package/dist/core/signals/debt.js.map +1 -1
- package/dist/cost/cost-tracker.d.ts.map +1 -1
- package/dist/cost/cost-tracker.js +2 -0
- package/dist/cost/cost-tracker.js.map +1 -1
- package/dist/gc/index.d.ts +17 -0
- package/dist/gc/index.d.ts.map +1 -0
- package/dist/gc/index.js +17 -0
- package/dist/gc/index.js.map +1 -0
- package/dist/gc/runner.d.ts +39 -0
- package/dist/gc/runner.d.ts.map +1 -0
- package/dist/gc/runner.js +277 -0
- package/dist/gc/runner.js.map +1 -0
- package/dist/gc/trace-compactor.d.ts +31 -0
- package/dist/gc/trace-compactor.d.ts.map +1 -0
- package/dist/gc/trace-compactor.js +162 -0
- package/dist/gc/trace-compactor.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/prompts/index.d.ts +2 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js.map +1 -1
- package/dist/quarantine/explorer.d.ts +65 -0
- package/dist/quarantine/explorer.d.ts.map +1 -0
- package/dist/quarantine/explorer.js +175 -0
- package/dist/quarantine/explorer.js.map +1 -0
- package/dist/quarantine/index.d.ts +7 -0
- package/dist/quarantine/index.d.ts.map +1 -0
- package/dist/quarantine/index.js +7 -0
- package/dist/quarantine/index.js.map +1 -0
- package/dist/quarantine/manager.d.ts +75 -0
- package/dist/quarantine/manager.d.ts.map +1 -0
- package/dist/quarantine/manager.js +275 -0
- package/dist/quarantine/manager.js.map +1 -0
- package/dist/task/acceptance.d.ts +29 -0
- package/dist/task/acceptance.d.ts.map +1 -0
- package/dist/task/acceptance.js +228 -0
- package/dist/task/acceptance.js.map +1 -0
- package/dist/task/agent-coordinator.d.ts +40 -0
- package/dist/task/agent-coordinator.d.ts.map +1 -0
- package/dist/task/agent-coordinator.js +168 -0
- package/dist/task/agent-coordinator.js.map +1 -0
- package/dist/task/executor.d.ts +37 -0
- package/dist/task/executor.d.ts.map +1 -0
- package/dist/task/executor.js +462 -0
- package/dist/task/executor.js.map +1 -0
- package/dist/task/index.d.ts +12 -0
- package/dist/task/index.d.ts.map +1 -0
- package/dist/task/index.js +12 -0
- package/dist/task/index.js.map +1 -0
- package/dist/task/planner.d.ts +21 -0
- package/dist/task/planner.d.ts.map +1 -0
- package/dist/task/planner.js +253 -0
- package/dist/task/planner.js.map +1 -0
- package/dist/task/storage.d.ts +46 -0
- package/dist/task/storage.d.ts.map +1 -0
- package/dist/task/storage.js +266 -0
- package/dist/task/storage.js.map +1 -0
- package/dist/trace/trace-event.d.ts +2 -18
- package/dist/trace/trace-event.d.ts.map +1 -1
- package/dist/trace/trace-event.js +6 -6
- package/dist/trace/trace-event.js.map +1 -1
- package/dist/utils/file-utils.d.ts.map +1 -1
- package/dist/utils/file-utils.js +54 -15
- package/dist/utils/file-utils.js.map +1 -1
- package/docs/PHASE5_IMPLEMENTATION.md +237 -0
- package/docs/PHASES-3-7-COMPLETE.md +177 -0
- package/docs/PHASE_4_COMPLETE.md +135 -0
- package/docs/PHASE_7_DELIVERABLES.md +295 -0
- package/docs/PHASE_7_IMPLEMENTATION.md +306 -0
- package/docs/PHASE_7_SUMMARY.txt +195 -0
- package/docs/RELEASE-NOTES-v2.1.md +213 -0
- package/docs/ROADMAP.md +194 -107
- package/docs/SECURITY-AUDIT.md +387 -0
- package/docs/SNAPSHOT.md +59 -32
- package/docs/implementation/phase3-summary.md +220 -0
- package/package.json +27 -11
- package/src/agent/task-worker.ts +196 -0
- package/src/agent/worker.ts +111 -0
- package/src/bin.ts +13 -0
- package/src/cli/cost.ts +210 -0
- package/src/cli/gc.ts +138 -0
- package/src/cli/gradients.ts +97 -0
- package/src/cli/grow.ts +416 -0
- package/src/cli/index.ts +81 -0
- package/src/cli/init.ts +139 -0
- package/src/cli/status.ts +218 -0
- package/src/coordination/file-locks.ts +300 -0
- package/src/coordination/index.ts +4 -0
- package/src/coordination/inhibitors.ts +345 -0
- package/src/coordination/process-manager.ts +199 -0
- package/src/core/agent-executor.ts +37 -8
- package/src/core/signals/churn.ts +8 -5
- package/src/core/signals/debt.ts +4 -3
- package/src/cost/cost-tracker.ts +2 -0
- package/src/gc/index.ts +17 -0
- package/src/gc/runner.ts +314 -0
- package/src/gc/trace-compactor.ts +187 -0
- package/src/index.ts +7 -1
- package/src/prompts/index.ts +2 -1
- package/src/quarantine/explorer.ts +234 -0
- package/src/quarantine/index.ts +7 -0
- package/src/quarantine/manager.ts +336 -0
- package/src/task/acceptance.ts +267 -0
- package/src/task/agent-coordinator.ts +220 -0
- package/src/task/executor.ts +543 -0
- package/src/task/index.ts +38 -0
- package/src/task/planner.ts +294 -0
- package/src/task/storage.ts +332 -0
- package/src/trace/trace-event.ts +7 -26
- package/src/utils/file-utils.ts +61 -15
- package/tests/cli/gc.test.ts +206 -0
- package/tests/cli/init.test.ts +181 -0
- package/tests/cli/status.test.ts +282 -0
- package/tests/coordination/file-locks.test.ts +196 -0
- package/tests/coordination/inhibitors.test.ts +459 -0
- package/tests/coordination/integration.test.ts +195 -0
- package/tests/coordination/process-manager.test.ts +165 -0
- package/tests/gc/trace-compactor.test.ts +245 -0
- package/tests/integration/phase-7.test.ts +145 -0
- package/tests/quarantine/explorer.test.ts +381 -0
- package/tests/quarantine/manager.test.ts +399 -0
- package/tests/security/command-injection.test.ts +88 -0
- package/tests/security/path-traversal.test.ts +103 -0
- package/tests/task/acceptance.test.ts +411 -0
- package/tests/task/executor.test.ts +421 -0
- package/tests/task/planner.test.ts +359 -0
- package/tests/trace/trace-event.test.ts +62 -20
- package/tsconfig.json +2 -2
|
Binary file
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
"Bash(npm run build:*)",
|
|
5
5
|
"Bash(npm test:*)",
|
|
6
6
|
"Bash(find:*)",
|
|
7
|
-
"Bash(npx @claude-flow/cli@latest swarm init:*)"
|
|
7
|
+
"Bash(npx @claude-flow/cli@latest swarm init:*)",
|
|
8
|
+
"Bash(npx @claude-flow/cli@latest hooks session-start:*)",
|
|
9
|
+
"Bash(npm run cli:*)",
|
|
10
|
+
"Bash(node:*)"
|
|
8
11
|
]
|
|
9
12
|
},
|
|
10
13
|
"enableAllProjectMcpServers": true,
|
package/README.md
CHANGED
|
@@ -2,280 +2,139 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/claude-mycelium)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://github.com/camplight/claude-mycelium)
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
7
7
|
|
|
8
|
-
> **
|
|
8
|
+
> **Autonomous AI agents that improve your codebase** - Multi-agent swarm intelligence for continuous code evolution.
|
|
9
9
|
|
|
10
|
-
Claude Mycelium
|
|
11
|
-
|
|
12
|
-
## ✨ Features
|
|
13
|
-
|
|
14
|
-
### 🎯 Intelligent Signal System
|
|
15
|
-
- **Complexity Signal** - Detects cyclomatic complexity hotspots
|
|
16
|
-
- **Churn Signal** - Identifies frequently modified files
|
|
17
|
-
- **Centrality Signal** - Maps dependency relationships
|
|
18
|
-
- **Technical Debt Signal** - Tracks code quality issues
|
|
19
|
-
- **Error Signal** - Monitors runtime error patterns
|
|
20
|
-
|
|
21
|
-
### 🤖 Autonomous Agent System
|
|
22
|
-
- **4 Agent Modes** - Error Reducer, Complexity Reducer, Debt Payer, Stabilizer
|
|
23
|
-
- **Gradient-Based Optimization** - Mathematical gradient descent for code quality
|
|
24
|
-
- **Inhibitor-Based Learning** - Learns from failures through mycelium-inspired signals
|
|
25
|
-
- **Automatic Rollback** - Reverts changes if tests fail
|
|
26
|
-
- **Cost Tracking** - Monitors LLM API usage and efficiency
|
|
27
|
-
|
|
28
|
-
### 🔬 Phase 2 Complete
|
|
29
|
-
- ✅ **LLM Integration** - Anthropic Claude with streaming support
|
|
30
|
-
- ✅ **Agent Execution** - 10-step orchestration loop
|
|
31
|
-
- ✅ **Change Application** - Safe code modification with backup/rollback
|
|
32
|
-
- ✅ **Trace System** - JSONL-based learning foundation
|
|
33
|
-
- ✅ **Cost Tracking** - Multi-model pricing and budget monitoring
|
|
10
|
+
Claude Mycelium coordinates autonomous AI agents to improve code quality through gradient-based optimization. Like a mycelium network, agents communicate through signals, learn from failures, and self-organize to reduce complexity, fix bugs, and pay down technical debt.
|
|
34
11
|
|
|
35
12
|
## 🚀 Quick Start
|
|
36
13
|
|
|
37
14
|
### Installation
|
|
38
15
|
|
|
39
16
|
```bash
|
|
40
|
-
npm install claude-mycelium
|
|
17
|
+
npm install -g claude-mycelium
|
|
41
18
|
```
|
|
42
19
|
|
|
43
|
-
###
|
|
20
|
+
### Setup
|
|
44
21
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
-
|
|
22
|
+
```bash
|
|
23
|
+
# Initialize in your project
|
|
24
|
+
npx claude-mycelium init
|
|
48
25
|
|
|
49
|
-
|
|
26
|
+
# Set your Anthropic API key
|
|
27
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
28
|
+
```
|
|
50
29
|
|
|
51
|
-
|
|
52
|
-
import { executeAgent } from 'claude-mycelium';
|
|
30
|
+
### CLI Commands
|
|
53
31
|
|
|
54
|
-
|
|
55
|
-
|
|
32
|
+
```bash
|
|
33
|
+
# Interactive mode - chat with mycelium to spawn agents
|
|
34
|
+
npx claude-mycelium grow
|
|
56
35
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
'src/my-file.ts',
|
|
60
|
-
'error_reducer',
|
|
61
|
-
{ dryRun: false }
|
|
62
|
-
);
|
|
36
|
+
# Check code quality scores
|
|
37
|
+
npx claude-mycelium gradients ./src
|
|
63
38
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
console.log(`Efficiency: ${result.trace.metabolic_efficiency.toFixed(3)}`);
|
|
67
|
-
```
|
|
39
|
+
# View system status
|
|
40
|
+
npx claude-mycelium status
|
|
68
41
|
|
|
69
|
-
|
|
42
|
+
# Check API costs
|
|
43
|
+
npx claude-mycelium cost
|
|
70
44
|
|
|
71
|
-
|
|
72
|
-
|
|
45
|
+
# Run garbage collection
|
|
46
|
+
npx claude-mycelium gc
|
|
73
47
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
console.log(`Complexity: ${gradient.signals.complexity.value}`);
|
|
77
|
-
console.log(`Technical Debt: ${gradient.signals.debt.value}`);
|
|
48
|
+
# Single task mode
|
|
49
|
+
npx claude-mycelium grow --task "fix bugs in src/api.ts"
|
|
78
50
|
```
|
|
79
51
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
// Error Reducer - Adds error handling and validation
|
|
84
|
-
await executeAgent('src/api.ts', 'error_reducer');
|
|
52
|
+
## ✨ Features
|
|
85
53
|
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
- **5 Quality Signals** - Complexity, churn, technical debt, error rate, centrality
|
|
55
|
+
- **4 Agent Modes** - Error Reducer, Complexity Reducer, Debt Payer, Stabilizer
|
|
56
|
+
- **Swarm Coordination** - Multi-agent parallel execution with file locking
|
|
57
|
+
- **Learning System** - Inhibitors and quarantine prevent repeated failures
|
|
58
|
+
- **Automatic Rollback** - Reverts changes if tests fail
|
|
59
|
+
- **Cost Tracking** - Monitor LLM API usage and efficiency
|
|
88
60
|
|
|
89
|
-
|
|
90
|
-
await executeAgent('src/legacy.ts', 'debt_payer');
|
|
61
|
+
## 🎯 How It Works
|
|
91
62
|
|
|
92
|
-
|
|
93
|
-
await executeAgent('src/volatile.ts', 'stabilizer');
|
|
94
|
-
```
|
|
63
|
+
Claude Mycelium treats code improvement as gradient descent:
|
|
95
64
|
|
|
96
|
-
|
|
65
|
+
1. **Measure** - Calculate quality gradients (complexity, debt, errors)
|
|
66
|
+
2. **Prioritize** - Find files with highest improvement potential
|
|
67
|
+
3. **Execute** - Spawn agents to make improvements in parallel
|
|
68
|
+
4. **Validate** - Run tests and check for regressions
|
|
69
|
+
5. **Learn** - Record outcomes to improve future decisions
|
|
97
70
|
|
|
98
|
-
|
|
99
|
-
┌─────────────────────────────────────────────────────────┐
|
|
100
|
-
│ Claude Mycelium - Self-Learning Code Evolution │
|
|
101
|
-
└─────────────────────────────────────────────────────────┘
|
|
102
|
-
│
|
|
103
|
-
┌────────────────┼────────────────┐
|
|
104
|
-
│ │ │
|
|
105
|
-
[Signals] [Gradient] [Agents]
|
|
106
|
-
│ │ │
|
|
107
|
-
5 dimensions Mathematical 4 modes
|
|
108
|
-
of quality optimization of action
|
|
109
|
-
│ │ │
|
|
110
|
-
└────────────────┼────────────────┘
|
|
111
|
-
│
|
|
112
|
-
┌──────────┴──────────┐
|
|
113
|
-
│ │
|
|
114
|
-
[LLM Layer] [Learning Layer]
|
|
115
|
-
│ │
|
|
116
|
-
Anthropic Claude Trace System
|
|
117
|
-
Cost Tracking Efficiency Metrics
|
|
118
|
-
Retry Logic Pattern Recognition
|
|
119
|
-
```
|
|
71
|
+
Agents coordinate through **inhibitor signals** - files with repeated failures get quarantined, preventing wasted resources.
|
|
120
72
|
|
|
121
73
|
## 🛠️ Configuration
|
|
122
74
|
|
|
123
75
|
### Environment Variables
|
|
124
76
|
|
|
125
77
|
```bash
|
|
126
|
-
# Required
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
# Optional
|
|
130
|
-
LOG_LEVEL=info # debug, info, warn, error
|
|
131
|
-
MAX_RETRIES=3 # LLM retry attempts
|
|
132
|
-
DRY_RUN=false # Simulate without changes
|
|
78
|
+
ANTHROPIC_API_KEY=sk-ant-... # Required
|
|
79
|
+
LOG_LEVEL=info # Optional: debug, info, warn, error
|
|
133
80
|
```
|
|
134
81
|
|
|
135
|
-
###
|
|
82
|
+
### Project Config
|
|
136
83
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
84
|
+
Create `.agent-meta/config.json`:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"weights": {
|
|
89
|
+
"complexity": 0.3,
|
|
90
|
+
"churn": 0.2,
|
|
91
|
+
"debt": 0.3,
|
|
92
|
+
"error": 0.1,
|
|
93
|
+
"centrality": 0.1
|
|
94
|
+
}
|
|
142
95
|
}
|
|
143
96
|
```
|
|
144
97
|
|
|
145
|
-
##
|
|
98
|
+
## 📊 Current Status
|
|
146
99
|
|
|
147
|
-
|
|
100
|
+
- **Phase 1** ✅ - Signal system and gradient calculation
|
|
101
|
+
- **Phase 2** ✅ - LLM integration and agent execution
|
|
102
|
+
- **Phase 3** ✅ - Concurrency and file locking
|
|
103
|
+
- **Phase 4** ✅ - Inhibitors and quarantine system
|
|
104
|
+
- **Phase 5** ✅ - Task planning and execution
|
|
105
|
+
- **Phase 7** ✅ - CLI and garbage collection
|
|
106
|
+
- **Phase 6** 🚧 - Watch mode (coming soon)
|
|
107
|
+
- **Phase 8** 📋 - Multi-file orchestration
|
|
108
|
+
- **Phase 9** 📋 - Distributed coordination
|
|
148
109
|
|
|
149
|
-
|
|
150
|
-
2. **Select Mode** - Choose optimal agent strategy
|
|
151
|
-
3. **Generate Prompt** - Create context-aware instructions
|
|
152
|
-
4. **Call LLM** - Request code improvements
|
|
153
|
-
5. **Parse Response** - Extract code changes
|
|
154
|
-
6. **Validate** - Check TypeScript syntax
|
|
155
|
-
7. **Apply Changes** - Safely modify files
|
|
156
|
-
8. **Run Tests** - Verify correctness
|
|
157
|
-
9. **Calculate New Gradient** - Measure improvement
|
|
158
|
-
10. **Record Trace** - Learn from outcome
|
|
110
|
+
**90% Complete** - Meta-circular development ready (system can improve itself)
|
|
159
111
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
Claude Mycelium treats code quality as a mathematical optimization problem:
|
|
112
|
+
## 🔒 Safety Features
|
|
163
113
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
-
|
|
169
|
-
- signal_churn: File modification frequency
|
|
170
|
-
- signal_debt: Technical debt indicators
|
|
171
|
-
- signal_error: Error rate patterns
|
|
172
|
-
- signal_centrality: Dependency coupling
|
|
173
|
-
```
|
|
114
|
+
- **Atomic File Locks** - Prevents concurrent modifications
|
|
115
|
+
- **Backup System** - Automatic backups before changes
|
|
116
|
+
- **Test Validation** - Automatic rollback on test failures
|
|
117
|
+
- **Quarantine** - Isolates problematic files after repeated failures
|
|
118
|
+
- **Path Safety** - Protects .git/ and node_modules/
|
|
174
119
|
|
|
175
|
-
##
|
|
120
|
+
## 📦 Programmatic API
|
|
176
121
|
|
|
177
|
-
|
|
122
|
+
For advanced use cases, you can use the TypeScript API:
|
|
178
123
|
|
|
179
124
|
```typescript
|
|
180
|
-
import { calculateGradient } from 'claude-mycelium';
|
|
181
|
-
|
|
182
|
-
const gradient = await calculateGradient('src/app.ts', {
|
|
183
|
-
weights: {
|
|
184
|
-
complexity: 0.3,
|
|
185
|
-
churn: 0.2,
|
|
186
|
-
debt: 0.3,
|
|
187
|
-
error: 0.1,
|
|
188
|
-
centrality: 0.1,
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
```
|
|
125
|
+
import { executeAgent, calculateGradient } from 'claude-mycelium';
|
|
192
126
|
|
|
193
|
-
|
|
127
|
+
// Calculate quality gradient
|
|
128
|
+
const gradient = await calculateGradient('src/app.ts');
|
|
129
|
+
console.log(`Score: ${gradient.score}`);
|
|
194
130
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const files = await glob('src/**/*.ts');
|
|
200
|
-
|
|
201
|
-
for (const file of files) {
|
|
202
|
-
const gradient = await calculateGradient(file);
|
|
203
|
-
|
|
204
|
-
if (gradient.score > 0.7) {
|
|
205
|
-
// High complexity - needs improvement
|
|
206
|
-
await executeAgent(file, 'complexity_reducer');
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Learning from Traces
|
|
212
|
-
|
|
213
|
-
```typescript
|
|
214
|
-
import { getRecentEfficiency } from 'claude-mycelium';
|
|
215
|
-
|
|
216
|
-
// Get efficiency of last 10 changes
|
|
217
|
-
const efficiency = await getRecentEfficiency('src/app.ts', 10);
|
|
218
|
-
console.log(`Historical efficiency: ${efficiency}`);
|
|
131
|
+
// Execute agent
|
|
132
|
+
const result = await executeAgent('src/app.ts', 'complexity_reducer', {
|
|
133
|
+
dryRun: false
|
|
134
|
+
});
|
|
219
135
|
```
|
|
220
136
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
- `src/core/` - Agent execution and orchestration
|
|
224
|
-
- `src/signals/` - 5 quality measurement systems
|
|
225
|
-
- `src/gradient/` - Mathematical optimization
|
|
226
|
-
- `src/llm/` - Anthropic Claude integration
|
|
227
|
-
- `src/trace/` - Learning and efficiency tracking
|
|
228
|
-
- `src/cost/` - Budget monitoring and reporting
|
|
229
|
-
|
|
230
|
-
## 🔒 Safety Features
|
|
231
|
-
|
|
232
|
-
- **Backup System** - Creates backups before any changes
|
|
233
|
-
- **Automatic Rollback** - Reverts on test failures
|
|
234
|
-
- **TypeScript Validation** - Syntax checking before apply
|
|
235
|
-
- **Path Safety** - Prevents modification of .git/ and node_modules/
|
|
236
|
-
- **File Size Limits** - Protects against large file issues
|
|
237
|
-
- **Dry Run Mode** - Test without applying changes
|
|
238
|
-
|
|
239
|
-
## 📊 Performance
|
|
240
|
-
|
|
241
|
-
- **Test Coverage**: 289/292 tests passing (99%)
|
|
242
|
-
- **LLM Models**: Claude Sonnet 4.5, Opus 4.5, Haiku 3.5
|
|
243
|
-
- **Retry Logic**: Exponential backoff for rate limits
|
|
244
|
-
- **Cost Tracking**: Per-file and aggregate metrics
|
|
245
|
-
- **Efficiency**: Gradient improvement per dollar spent
|
|
246
|
-
|
|
247
|
-
## 🗺️ Roadmap
|
|
248
|
-
|
|
249
|
-
### Phase 1 ✅ Complete
|
|
250
|
-
- Signal system (5 dimensions)
|
|
251
|
-
- Gradient calculation
|
|
252
|
-
- Mode selection
|
|
253
|
-
- Caching and optimization
|
|
254
|
-
|
|
255
|
-
### Phase 2 ✅ Complete
|
|
256
|
-
- LLM integration (Anthropic Claude)
|
|
257
|
-
- Agent execution loop
|
|
258
|
-
- Change application with rollback
|
|
259
|
-
- Trace system and learning foundation
|
|
260
|
-
- Cost tracking and efficiency metrics
|
|
261
|
-
|
|
262
|
-
### Phase 3 🔄 Next
|
|
263
|
-
- Concurrency & coordination
|
|
264
|
-
- File locks (atomic operations)
|
|
265
|
-
- Process spawning and IPC
|
|
266
|
-
- Multi-agent coordination
|
|
267
|
-
|
|
268
|
-
### Phase 4 📋 Planned
|
|
269
|
-
- Inhibitor signals (ADR-002)
|
|
270
|
-
- Quarantine system
|
|
271
|
-
- Explorer mode
|
|
272
|
-
- Learning from failures
|
|
273
|
-
|
|
274
|
-
### Phase 5-9 📋 Future
|
|
275
|
-
- Multi-file orchestration
|
|
276
|
-
- Task planning and execution
|
|
277
|
-
- CLI and watch mode
|
|
278
|
-
- Distributed swarm coordination
|
|
137
|
+
See [API Documentation](docs/API.md) for details.
|
|
279
138
|
|
|
280
139
|
## 🤝 Contributing
|
|
281
140
|
|
|
@@ -283,19 +142,12 @@ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guid
|
|
|
283
142
|
|
|
284
143
|
## 📄 License
|
|
285
144
|
|
|
286
|
-
MIT License - see [LICENSE](LICENSE) for details
|
|
287
|
-
|
|
288
|
-
## 🙏 Acknowledgments
|
|
289
|
-
|
|
290
|
-
- Built with [Anthropic Claude](https://www.anthropic.com/claude)
|
|
291
|
-
- Inspired by gradient descent optimization
|
|
292
|
-
- Named after mycelium networks in nature
|
|
145
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
293
146
|
|
|
294
147
|
## 📞 Support
|
|
295
148
|
|
|
296
|
-
- **Issues**: [GitHub Issues](https://github.com/
|
|
297
|
-
- **Discussions**: [GitHub Discussions](https://github.com/
|
|
298
|
-
- **Email**: support@claude-mycelium.dev
|
|
149
|
+
- **Issues**: [GitHub Issues](https://github.com/camplight/claude-mycelium/issues)
|
|
150
|
+
- **Discussions**: [GitHub Discussions](https://github.com/camplight/claude-mycelium/discussions)
|
|
299
151
|
|
|
300
152
|
---
|
|
301
153
|
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting Security Vulnerabilities
|
|
4
|
+
|
|
5
|
+
If you discover a security vulnerability in Claude Mycelium, please email:
|
|
6
|
+
|
|
7
|
+
**security@camplight.net**
|
|
8
|
+
|
|
9
|
+
**Please do not open public GitHub issues for security vulnerabilities.**
|
|
10
|
+
|
|
11
|
+
### What to Include
|
|
12
|
+
|
|
13
|
+
- Description of the vulnerability
|
|
14
|
+
- Steps to reproduce
|
|
15
|
+
- Potential impact
|
|
16
|
+
- Suggested fix (if available)
|
|
17
|
+
|
|
18
|
+
We will respond within 48 hours and work with you to address the issue.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Security Audit Status
|
|
23
|
+
|
|
24
|
+
**Last Audit**: 2026-01-31
|
|
25
|
+
**Status**: 🟡 MODERATE RISK - Critical fixes needed before v2.1.0 release
|
|
26
|
+
|
|
27
|
+
See [docs/SECURITY-AUDIT.md](docs/SECURITY-AUDIT.md) for full audit report.
|
|
28
|
+
|
|
29
|
+
### Critical Issues (Must Fix Before Release)
|
|
30
|
+
|
|
31
|
+
1. **Command Injection** in `src/core/signals/debt.ts` and `churn.ts`
|
|
32
|
+
- Use `execFile()` instead of `exec()` with shell interpolation
|
|
33
|
+
- CVSS: 9.8 (Critical)
|
|
34
|
+
|
|
35
|
+
2. **Path Traversal** in `src/utils/file-utils.ts`
|
|
36
|
+
- Add path validation to all file operations
|
|
37
|
+
- CVSS: 8.6 (High)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Supported Versions
|
|
42
|
+
|
|
43
|
+
| Version | Supported |
|
|
44
|
+
| ------- | ------------------ |
|
|
45
|
+
| 2.1.x | :white_check_mark: |
|
|
46
|
+
| 2.0.x | :white_check_mark: |
|
|
47
|
+
| < 2.0 | :x: |
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Security Best Practices for Users
|
|
52
|
+
|
|
53
|
+
### 1. API Key Security
|
|
54
|
+
|
|
55
|
+
- **Never commit** API keys to git
|
|
56
|
+
- Use `.env` files with `.gitignore`
|
|
57
|
+
- Use restricted API keys (not account-level keys)
|
|
58
|
+
- Rotate keys regularly
|
|
59
|
+
|
|
60
|
+
### 2. File System Permissions
|
|
61
|
+
|
|
62
|
+
- Run with **minimal permissions** (not root/admin)
|
|
63
|
+
- Review file changes before applying
|
|
64
|
+
- Keep backups of important code
|
|
65
|
+
|
|
66
|
+
### 3. Cost Control
|
|
67
|
+
|
|
68
|
+
- Set `MAX_DAILY_COST` environment variable
|
|
69
|
+
- Monitor API usage regularly
|
|
70
|
+
- Review changes before they're applied
|
|
71
|
+
|
|
72
|
+
### 4. Network Security
|
|
73
|
+
|
|
74
|
+
- Review LLM prompts for sensitive data
|
|
75
|
+
- Don't include credentials in code comments
|
|
76
|
+
- Use firewall rules to restrict outbound connections
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Known Security Limitations
|
|
81
|
+
|
|
82
|
+
### 1. LLM Prompt Injection
|
|
83
|
+
|
|
84
|
+
Claude Mycelium uses LLM-generated code. While we have safeguards:
|
|
85
|
+
- File content could influence LLM output
|
|
86
|
+
- Always review changes before applying
|
|
87
|
+
- Run in sandboxed environments for untrusted codebases
|
|
88
|
+
|
|
89
|
+
### 2. Dependency Vulnerabilities
|
|
90
|
+
|
|
91
|
+
We actively monitor dependencies but:
|
|
92
|
+
- Use `npm audit` to check your installation
|
|
93
|
+
- Some dev dependencies have moderate vulnerabilities
|
|
94
|
+
- Production dependencies are secure
|
|
95
|
+
|
|
96
|
+
### 3. File System Access
|
|
97
|
+
|
|
98
|
+
The system requires broad file system access:
|
|
99
|
+
- Runs with your user's permissions
|
|
100
|
+
- Can modify any file in the project
|
|
101
|
+
- Use `.gitignore` to protect sensitive files
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Security Checklist for Contributors
|
|
106
|
+
|
|
107
|
+
Before submitting code:
|
|
108
|
+
|
|
109
|
+
- [ ] Run security tests: `npm test tests/security/`
|
|
110
|
+
- [ ] Check for secrets: `git secrets --scan`
|
|
111
|
+
- [ ] Validate all user inputs
|
|
112
|
+
- [ ] Use `execFile()` not `exec()` for commands
|
|
113
|
+
- [ ] Validate file paths before operations
|
|
114
|
+
- [ ] Add security tests for new features
|
|
115
|
+
- [ ] Update this document if needed
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Security Tools
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Run security audit
|
|
123
|
+
npm audit
|
|
124
|
+
|
|
125
|
+
# Run security tests
|
|
126
|
+
npm test tests/security/
|
|
127
|
+
|
|
128
|
+
# Check for outdated packages
|
|
129
|
+
npm outdated
|
|
130
|
+
|
|
131
|
+
# Scan for secrets (if git-secrets installed)
|
|
132
|
+
git secrets --scan
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Contact
|
|
138
|
+
|
|
139
|
+
- **Security Issues**: security@camplight.net
|
|
140
|
+
- **General Issues**: https://github.com/camplight/claude-mycelium/issues
|
|
141
|
+
- **Discussions**: https://github.com/camplight/claude-mycelium/discussions
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
**Last Updated**: 2026-01-31
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task Worker Process
|
|
3
|
+
*
|
|
4
|
+
* Independent agent process spawned for a specific task step.
|
|
5
|
+
* Integrates with the full mycelium system: file locks, inhibitors,
|
|
6
|
+
* quarantine, and the complete executeAgent() RALPH cycle.
|
|
7
|
+
*
|
|
8
|
+
* This runs as a separate Node.js process via child_process.fork()
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=task-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-worker.d.ts","sourceRoot":"","sources":["../../src/agent/task-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|