claude-mycelium 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent-meta/_inhibitors.ndjson +1287 -0
- package/.agent-meta/_quarantine.json +45 -0
- package/.agent-meta/config.json +9 -0
- package/.claude/memory.db +0 -0
- package/.claude/settings.local.json +4 -1
- package/README.md +81 -235
- package/SECURITY.md +145 -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 +69 -0
- package/dist/cli/gradients.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 +72 -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.map +1 -1
- package/dist/core/agent-executor.js +28 -10
- 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/executor.d.ts +30 -0
- package/dist/task/executor.d.ts.map +1 -0
- package/dist/task/executor.js +429 -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 +64 -57
- package/docs/SECURITY-AUDIT.md +387 -0
- package/docs/SNAPSHOT.md +59 -32
- package/docs/implementation/phase3-summary.md +220 -0
- package/package.json +19 -11
- 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 +95 -0
- package/src/cli/index.ts +79 -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 +20 -4
- 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/executor.ts +538 -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/tsconfig.json +2 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"updated_at": "2026-01-31T10:22:23.991Z",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"file": "file2.ts",
|
|
6
|
+
"quarantined_at": "2026-01-31T10:22:10.098Z",
|
|
7
|
+
"reason": "Test 2",
|
|
8
|
+
"attempts_before_quarantine": 10,
|
|
9
|
+
"explorer_attempts": 3,
|
|
10
|
+
"max_explorer_attempts": 3
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"file": "file3.ts",
|
|
14
|
+
"quarantined_at": "2026-01-31T10:22:10.104Z",
|
|
15
|
+
"reason": "Test 3",
|
|
16
|
+
"attempts_before_quarantine": 10,
|
|
17
|
+
"explorer_attempts": 3,
|
|
18
|
+
"max_explorer_attempts": 3
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"file": "file1.ts",
|
|
22
|
+
"quarantined_at": "2026-01-31T10:22:10.106Z",
|
|
23
|
+
"reason": "Test 1",
|
|
24
|
+
"attempts_before_quarantine": 10,
|
|
25
|
+
"explorer_attempts": 3,
|
|
26
|
+
"max_explorer_attempts": 3
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"file": "quarantined.ts",
|
|
30
|
+
"quarantined_at": "2026-01-31T10:22:17.612Z",
|
|
31
|
+
"reason": "Test",
|
|
32
|
+
"attempts_before_quarantine": 10,
|
|
33
|
+
"explorer_attempts": 3,
|
|
34
|
+
"max_explorer_attempts": 3
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"file": "exhausted.ts",
|
|
38
|
+
"quarantined_at": "2026-01-31T10:22:17.650Z",
|
|
39
|
+
"reason": "Test",
|
|
40
|
+
"attempts_before_quarantine": 10,
|
|
41
|
+
"explorer_attempts": 3,
|
|
42
|
+
"max_explorer_attempts": 3
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
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,133 @@
|
|
|
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
|
-
-
|
|
48
|
-
|
|
49
|
-
### Basic Usage
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
import { executeAgent } from 'claude-mycelium';
|
|
22
|
+
```bash
|
|
23
|
+
# Initialize in your project
|
|
24
|
+
npx claude-mycelium init
|
|
53
25
|
|
|
54
|
-
|
|
55
|
-
|
|
26
|
+
# Set your Anthropic API key
|
|
27
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
28
|
+
```
|
|
56
29
|
|
|
57
|
-
|
|
58
|
-
const result = await executeAgent(
|
|
59
|
-
'src/my-file.ts',
|
|
60
|
-
'error_reducer',
|
|
61
|
-
{ dryRun: false }
|
|
62
|
-
);
|
|
30
|
+
### CLI Commands
|
|
63
31
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
```
|
|
32
|
+
```bash
|
|
33
|
+
# Check code quality scores
|
|
34
|
+
npx claude-mycelium gradients ./src
|
|
68
35
|
|
|
69
|
-
|
|
36
|
+
# View system status
|
|
37
|
+
npx claude-mycelium status
|
|
70
38
|
|
|
71
|
-
|
|
72
|
-
|
|
39
|
+
# Check API costs
|
|
40
|
+
npx claude-mycelium cost
|
|
73
41
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
console.log(`Complexity: ${gradient.signals.complexity.value}`);
|
|
77
|
-
console.log(`Technical Debt: ${gradient.signals.debt.value}`);
|
|
42
|
+
# Run garbage collection
|
|
43
|
+
npx claude-mycelium gc
|
|
78
44
|
```
|
|
79
45
|
|
|
80
|
-
|
|
46
|
+
## ✨ Features
|
|
81
47
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
48
|
+
- **5 Quality Signals** - Complexity, churn, technical debt, error rate, centrality
|
|
49
|
+
- **4 Agent Modes** - Error Reducer, Complexity Reducer, Debt Payer, Stabilizer
|
|
50
|
+
- **Swarm Coordination** - Multi-agent parallel execution with file locking
|
|
51
|
+
- **Learning System** - Inhibitors and quarantine prevent repeated failures
|
|
52
|
+
- **Automatic Rollback** - Reverts changes if tests fail
|
|
53
|
+
- **Cost Tracking** - Monitor LLM API usage and efficiency
|
|
85
54
|
|
|
86
|
-
|
|
87
|
-
await executeAgent('src/utils.ts', 'complexity_reducer');
|
|
55
|
+
## 🎯 How It Works
|
|
88
56
|
|
|
89
|
-
|
|
90
|
-
await executeAgent('src/legacy.ts', 'debt_payer');
|
|
57
|
+
Claude Mycelium treats code improvement as gradient descent:
|
|
91
58
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
59
|
+
1. **Measure** - Calculate quality gradients (complexity, debt, errors)
|
|
60
|
+
2. **Prioritize** - Find files with highest improvement potential
|
|
61
|
+
3. **Execute** - Spawn agents to make improvements in parallel
|
|
62
|
+
4. **Validate** - Run tests and check for regressions
|
|
63
|
+
5. **Learn** - Record outcomes to improve future decisions
|
|
95
64
|
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
```
|
|
65
|
+
Agents coordinate through **inhibitor signals** - files with repeated failures get quarantined, preventing wasted resources.
|
|
120
66
|
|
|
121
67
|
## 🛠️ Configuration
|
|
122
68
|
|
|
123
69
|
### Environment Variables
|
|
124
70
|
|
|
125
71
|
```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
|
|
72
|
+
ANTHROPIC_API_KEY=sk-ant-... # Required
|
|
73
|
+
LOG_LEVEL=info # Optional: debug, info, warn, error
|
|
133
74
|
```
|
|
134
75
|
|
|
135
|
-
###
|
|
76
|
+
### Project Config
|
|
136
77
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
78
|
+
Create `.agent-meta/config.json`:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"weights": {
|
|
83
|
+
"complexity": 0.3,
|
|
84
|
+
"churn": 0.2,
|
|
85
|
+
"debt": 0.3,
|
|
86
|
+
"error": 0.1,
|
|
87
|
+
"centrality": 0.1
|
|
88
|
+
}
|
|
142
89
|
}
|
|
143
90
|
```
|
|
144
91
|
|
|
145
|
-
##
|
|
92
|
+
## 📊 Current Status
|
|
146
93
|
|
|
147
|
-
|
|
94
|
+
- **Phase 1** ✅ - Signal system and gradient calculation
|
|
95
|
+
- **Phase 2** ✅ - LLM integration and agent execution
|
|
96
|
+
- **Phase 3** ✅ - Concurrency and file locking
|
|
97
|
+
- **Phase 4** ✅ - Inhibitors and quarantine system
|
|
98
|
+
- **Phase 5** ✅ - Task planning and execution
|
|
99
|
+
- **Phase 7** ✅ - CLI and garbage collection
|
|
100
|
+
- **Phase 6** 🚧 - Watch mode (coming soon)
|
|
101
|
+
- **Phase 8** 📋 - Multi-file orchestration
|
|
102
|
+
- **Phase 9** 📋 - Distributed coordination
|
|
148
103
|
|
|
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
|
|
104
|
+
**90% Complete** - Meta-circular development ready (system can improve itself)
|
|
159
105
|
|
|
160
|
-
|
|
106
|
+
## 🔒 Safety Features
|
|
161
107
|
|
|
162
|
-
|
|
108
|
+
- **Atomic File Locks** - Prevents concurrent modifications
|
|
109
|
+
- **Backup System** - Automatic backups before changes
|
|
110
|
+
- **Test Validation** - Automatic rollback on test failures
|
|
111
|
+
- **Quarantine** - Isolates problematic files after repeated failures
|
|
112
|
+
- **Path Safety** - Protects .git/ and node_modules/
|
|
163
113
|
|
|
164
|
-
|
|
165
|
-
Gradient = Σ(weight_i × signal_i)
|
|
166
|
-
|
|
167
|
-
Where:
|
|
168
|
-
- signal_complexity: Cyclomatic complexity
|
|
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
|
+
## 📦 Programmatic API
|
|
174
115
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
### Custom Signal Weights
|
|
116
|
+
For advanced use cases, you can use the TypeScript API:
|
|
178
117
|
|
|
179
118
|
```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
|
-
```
|
|
192
|
-
|
|
193
|
-
### Batch Processing
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
import { executeAgent } from 'claude-mycelium';
|
|
197
|
-
import { glob } from 'glob';
|
|
198
|
-
|
|
199
|
-
const files = await glob('src/**/*.ts');
|
|
200
|
-
|
|
201
|
-
for (const file of files) {
|
|
202
|
-
const gradient = await calculateGradient(file);
|
|
119
|
+
import { executeAgent, calculateGradient } from 'claude-mycelium';
|
|
203
120
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Learning from Traces
|
|
121
|
+
// Calculate quality gradient
|
|
122
|
+
const gradient = await calculateGradient('src/app.ts');
|
|
123
|
+
console.log(`Score: ${gradient.score}`);
|
|
212
124
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const efficiency = await getRecentEfficiency('src/app.ts', 10);
|
|
218
|
-
console.log(`Historical efficiency: ${efficiency}`);
|
|
125
|
+
// Execute agent
|
|
126
|
+
const result = await executeAgent('src/app.ts', 'complexity_reducer', {
|
|
127
|
+
dryRun: false
|
|
128
|
+
});
|
|
219
129
|
```
|
|
220
130
|
|
|
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
|
|
131
|
+
See [API Documentation](docs/API.md) for details.
|
|
279
132
|
|
|
280
133
|
## 🤝 Contributing
|
|
281
134
|
|
|
@@ -283,19 +136,12 @@ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guid
|
|
|
283
136
|
|
|
284
137
|
## 📄 License
|
|
285
138
|
|
|
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
|
|
139
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
293
140
|
|
|
294
141
|
## 📞 Support
|
|
295
142
|
|
|
296
|
-
- **Issues**: [GitHub Issues](https://github.com/
|
|
297
|
-
- **Discussions**: [GitHub Discussions](https://github.com/
|
|
298
|
-
- **Email**: support@claude-mycelium.dev
|
|
143
|
+
- **Issues**: [GitHub Issues](https://github.com/camplight/claude-mycelium/issues)
|
|
144
|
+
- **Discussions**: [GitHub Discussions](https://github.com/camplight/claude-mycelium/discussions)
|
|
299
145
|
|
|
300
146
|
---
|
|
301
147
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/agent/worker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|