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.
Files changed (208) hide show
  1. package/.agent-meta/_inhibitors.ndjson +1287 -0
  2. package/.agent-meta/_quarantine.json +45 -0
  3. package/.agent-meta/config.json +9 -0
  4. package/.agent-meta/tasks/_active.json +4 -0
  5. package/.agent-meta/tasks/task_0657b028-05a0-4b0c-b0b9-a4eae3d66cd9.json +168 -0
  6. package/.claude/memory.db +0 -0
  7. package/.claude/settings.local.json +4 -1
  8. package/README.md +85 -233
  9. package/SECURITY.md +145 -0
  10. package/dist/agent/task-worker.d.ts +11 -0
  11. package/dist/agent/task-worker.d.ts.map +1 -0
  12. package/dist/agent/task-worker.js +173 -0
  13. package/dist/agent/task-worker.js.map +1 -0
  14. package/dist/agent/worker.d.ts +8 -0
  15. package/dist/agent/worker.d.ts.map +1 -0
  16. package/dist/agent/worker.js +97 -0
  17. package/dist/agent/worker.js.map +1 -0
  18. package/dist/bin.d.ts +7 -0
  19. package/dist/bin.d.ts.map +1 -0
  20. package/dist/bin.js +11 -0
  21. package/dist/bin.js.map +1 -0
  22. package/dist/cli/cost.d.ts +10 -0
  23. package/dist/cli/cost.d.ts.map +1 -0
  24. package/dist/cli/cost.js +163 -0
  25. package/dist/cli/cost.js.map +1 -0
  26. package/dist/cli/gc.d.ts +10 -0
  27. package/dist/cli/gc.d.ts.map +1 -0
  28. package/dist/cli/gc.js +108 -0
  29. package/dist/cli/gc.js.map +1 -0
  30. package/dist/cli/gradients.d.ts +10 -0
  31. package/dist/cli/gradients.d.ts.map +1 -0
  32. package/dist/cli/gradients.js +70 -0
  33. package/dist/cli/gradients.js.map +1 -0
  34. package/dist/cli/grow.d.ts +17 -0
  35. package/dist/cli/grow.d.ts.map +1 -0
  36. package/dist/cli/grow.js +373 -0
  37. package/dist/cli/grow.js.map +1 -0
  38. package/dist/cli/index.d.ts +17 -0
  39. package/dist/cli/index.d.ts.map +1 -0
  40. package/dist/cli/index.js +74 -0
  41. package/dist/cli/index.js.map +1 -0
  42. package/dist/cli/init.d.ts +11 -0
  43. package/dist/cli/init.d.ts.map +1 -0
  44. package/dist/cli/init.js +97 -0
  45. package/dist/cli/init.js.map +1 -0
  46. package/dist/cli/status.d.ts +10 -0
  47. package/dist/cli/status.d.ts.map +1 -0
  48. package/dist/cli/status.js +191 -0
  49. package/dist/cli/status.js.map +1 -0
  50. package/dist/coordination/file-locks.d.ts +42 -0
  51. package/dist/coordination/file-locks.d.ts.map +1 -0
  52. package/dist/coordination/file-locks.js +269 -0
  53. package/dist/coordination/file-locks.js.map +1 -0
  54. package/dist/coordination/index.d.ts +4 -0
  55. package/dist/coordination/index.d.ts.map +1 -1
  56. package/dist/coordination/index.js +4 -0
  57. package/dist/coordination/index.js.map +1 -1
  58. package/dist/coordination/inhibitors.d.ts +84 -0
  59. package/dist/coordination/inhibitors.d.ts.map +1 -0
  60. package/dist/coordination/inhibitors.js +290 -0
  61. package/dist/coordination/inhibitors.js.map +1 -0
  62. package/dist/coordination/process-manager.d.ts +73 -0
  63. package/dist/coordination/process-manager.d.ts.map +1 -0
  64. package/dist/coordination/process-manager.js +144 -0
  65. package/dist/coordination/process-manager.js.map +1 -0
  66. package/dist/core/agent-executor.d.ts +4 -1
  67. package/dist/core/agent-executor.d.ts.map +1 -1
  68. package/dist/core/agent-executor.js +38 -12
  69. package/dist/core/agent-executor.js.map +1 -1
  70. package/dist/core/change-applier.d.ts +29 -5
  71. package/dist/core/change-applier.d.ts.map +1 -1
  72. package/dist/core/change-applier.js +254 -24
  73. package/dist/core/change-applier.js.map +1 -1
  74. package/dist/core/signals/churn.d.ts.map +1 -1
  75. package/dist/core/signals/churn.js +6 -4
  76. package/dist/core/signals/churn.js.map +1 -1
  77. package/dist/core/signals/debt.d.ts.map +1 -1
  78. package/dist/core/signals/debt.js +4 -3
  79. package/dist/core/signals/debt.js.map +1 -1
  80. package/dist/cost/cost-tracker.d.ts.map +1 -1
  81. package/dist/cost/cost-tracker.js +2 -0
  82. package/dist/cost/cost-tracker.js.map +1 -1
  83. package/dist/gc/index.d.ts +17 -0
  84. package/dist/gc/index.d.ts.map +1 -0
  85. package/dist/gc/index.js +17 -0
  86. package/dist/gc/index.js.map +1 -0
  87. package/dist/gc/runner.d.ts +39 -0
  88. package/dist/gc/runner.d.ts.map +1 -0
  89. package/dist/gc/runner.js +277 -0
  90. package/dist/gc/runner.js.map +1 -0
  91. package/dist/gc/trace-compactor.d.ts +31 -0
  92. package/dist/gc/trace-compactor.d.ts.map +1 -0
  93. package/dist/gc/trace-compactor.js +162 -0
  94. package/dist/gc/trace-compactor.js.map +1 -0
  95. package/dist/index.d.ts +5 -1
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +6 -1
  98. package/dist/index.js.map +1 -1
  99. package/dist/prompts/index.d.ts +2 -1
  100. package/dist/prompts/index.d.ts.map +1 -1
  101. package/dist/prompts/index.js.map +1 -1
  102. package/dist/quarantine/explorer.d.ts +65 -0
  103. package/dist/quarantine/explorer.d.ts.map +1 -0
  104. package/dist/quarantine/explorer.js +175 -0
  105. package/dist/quarantine/explorer.js.map +1 -0
  106. package/dist/quarantine/index.d.ts +7 -0
  107. package/dist/quarantine/index.d.ts.map +1 -0
  108. package/dist/quarantine/index.js +7 -0
  109. package/dist/quarantine/index.js.map +1 -0
  110. package/dist/quarantine/manager.d.ts +75 -0
  111. package/dist/quarantine/manager.d.ts.map +1 -0
  112. package/dist/quarantine/manager.js +275 -0
  113. package/dist/quarantine/manager.js.map +1 -0
  114. package/dist/task/acceptance.d.ts +29 -0
  115. package/dist/task/acceptance.d.ts.map +1 -0
  116. package/dist/task/acceptance.js +228 -0
  117. package/dist/task/acceptance.js.map +1 -0
  118. package/dist/task/agent-coordinator.d.ts +40 -0
  119. package/dist/task/agent-coordinator.d.ts.map +1 -0
  120. package/dist/task/agent-coordinator.js +168 -0
  121. package/dist/task/agent-coordinator.js.map +1 -0
  122. package/dist/task/executor.d.ts +37 -0
  123. package/dist/task/executor.d.ts.map +1 -0
  124. package/dist/task/executor.js +462 -0
  125. package/dist/task/executor.js.map +1 -0
  126. package/dist/task/index.d.ts +12 -0
  127. package/dist/task/index.d.ts.map +1 -0
  128. package/dist/task/index.js +12 -0
  129. package/dist/task/index.js.map +1 -0
  130. package/dist/task/planner.d.ts +21 -0
  131. package/dist/task/planner.d.ts.map +1 -0
  132. package/dist/task/planner.js +253 -0
  133. package/dist/task/planner.js.map +1 -0
  134. package/dist/task/storage.d.ts +46 -0
  135. package/dist/task/storage.d.ts.map +1 -0
  136. package/dist/task/storage.js +266 -0
  137. package/dist/task/storage.js.map +1 -0
  138. package/dist/trace/trace-event.d.ts +2 -18
  139. package/dist/trace/trace-event.d.ts.map +1 -1
  140. package/dist/trace/trace-event.js +6 -6
  141. package/dist/trace/trace-event.js.map +1 -1
  142. package/dist/utils/file-utils.d.ts.map +1 -1
  143. package/dist/utils/file-utils.js +54 -15
  144. package/dist/utils/file-utils.js.map +1 -1
  145. package/docs/PHASE5_IMPLEMENTATION.md +237 -0
  146. package/docs/PHASES-3-7-COMPLETE.md +177 -0
  147. package/docs/PHASE_4_COMPLETE.md +135 -0
  148. package/docs/PHASE_7_DELIVERABLES.md +295 -0
  149. package/docs/PHASE_7_IMPLEMENTATION.md +306 -0
  150. package/docs/PHASE_7_SUMMARY.txt +195 -0
  151. package/docs/RELEASE-NOTES-v2.1.md +213 -0
  152. package/docs/ROADMAP.md +194 -107
  153. package/docs/SECURITY-AUDIT.md +387 -0
  154. package/docs/SNAPSHOT.md +59 -32
  155. package/docs/implementation/phase3-summary.md +220 -0
  156. package/package.json +27 -11
  157. package/src/agent/task-worker.ts +196 -0
  158. package/src/agent/worker.ts +111 -0
  159. package/src/bin.ts +13 -0
  160. package/src/cli/cost.ts +210 -0
  161. package/src/cli/gc.ts +138 -0
  162. package/src/cli/gradients.ts +97 -0
  163. package/src/cli/grow.ts +416 -0
  164. package/src/cli/index.ts +81 -0
  165. package/src/cli/init.ts +139 -0
  166. package/src/cli/status.ts +218 -0
  167. package/src/coordination/file-locks.ts +300 -0
  168. package/src/coordination/index.ts +4 -0
  169. package/src/coordination/inhibitors.ts +345 -0
  170. package/src/coordination/process-manager.ts +199 -0
  171. package/src/core/agent-executor.ts +37 -8
  172. package/src/core/signals/churn.ts +8 -5
  173. package/src/core/signals/debt.ts +4 -3
  174. package/src/cost/cost-tracker.ts +2 -0
  175. package/src/gc/index.ts +17 -0
  176. package/src/gc/runner.ts +314 -0
  177. package/src/gc/trace-compactor.ts +187 -0
  178. package/src/index.ts +7 -1
  179. package/src/prompts/index.ts +2 -1
  180. package/src/quarantine/explorer.ts +234 -0
  181. package/src/quarantine/index.ts +7 -0
  182. package/src/quarantine/manager.ts +336 -0
  183. package/src/task/acceptance.ts +267 -0
  184. package/src/task/agent-coordinator.ts +220 -0
  185. package/src/task/executor.ts +543 -0
  186. package/src/task/index.ts +38 -0
  187. package/src/task/planner.ts +294 -0
  188. package/src/task/storage.ts +332 -0
  189. package/src/trace/trace-event.ts +7 -26
  190. package/src/utils/file-utils.ts +61 -15
  191. package/tests/cli/gc.test.ts +206 -0
  192. package/tests/cli/init.test.ts +181 -0
  193. package/tests/cli/status.test.ts +282 -0
  194. package/tests/coordination/file-locks.test.ts +196 -0
  195. package/tests/coordination/inhibitors.test.ts +459 -0
  196. package/tests/coordination/integration.test.ts +195 -0
  197. package/tests/coordination/process-manager.test.ts +165 -0
  198. package/tests/gc/trace-compactor.test.ts +245 -0
  199. package/tests/integration/phase-7.test.ts +145 -0
  200. package/tests/quarantine/explorer.test.ts +381 -0
  201. package/tests/quarantine/manager.test.ts +399 -0
  202. package/tests/security/command-injection.test.ts +88 -0
  203. package/tests/security/path-traversal.test.ts +103 -0
  204. package/tests/task/acceptance.test.ts +411 -0
  205. package/tests/task/executor.test.ts +421 -0
  206. package/tests/task/planner.test.ts +359 -0
  207. package/tests/trace/trace-event.test.ts +62 -20
  208. 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
  [![npm version](https://img.shields.io/npm/v/claude-mycelium.svg)](https://www.npmjs.com/package/claude-mycelium)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Tests](https://img.shields.io/badge/tests-289%2F292-brightgreen.svg)](https://github.com/ruvnet/claude-mycelium)
5
+ [![Tests](https://img.shields.io/badge/tests-458%20passing-brightgreen.svg)](https://github.com/camplight/claude-mycelium)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg)](https://www.typescriptlang.org/)
7
7
 
8
- > **Self-Learning AI Code Evolution System** - Automated code quality improvement through intelligent gradient-based optimization and autonomous agent orchestration.
8
+ > **Autonomous AI agents that improve your codebase** - Multi-agent swarm intelligence for continuous code evolution.
9
9
 
10
- Claude Mycelium is an autonomous AI agent system that continuously learns and improves your codebase using gradient-based signals, inhibitor-based learning, and LLM-powered code transformations. Like a mycelium network, it spreads intelligence throughout your codebase, connecting patterns and optimizing quality.
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
- ### Prerequisites
20
+ ### Setup
44
21
 
45
- - Node.js 20+
46
- - TypeScript 5.0+
47
- - Anthropic API Key
22
+ ```bash
23
+ # Initialize in your project
24
+ npx claude-mycelium init
48
25
 
49
- ### Basic Usage
26
+ # Set your Anthropic API key
27
+ export ANTHROPIC_API_KEY=sk-ant-...
28
+ ```
50
29
 
51
- ```typescript
52
- import { executeAgent } from 'claude-mycelium';
30
+ ### CLI Commands
53
31
 
54
- // Set your API key
55
- process.env.ANTHROPIC_API_KEY = 'sk-ant-...';
32
+ ```bash
33
+ # Interactive mode - chat with mycelium to spawn agents
34
+ npx claude-mycelium grow
56
35
 
57
- // Run the agent on a file
58
- const result = await executeAgent(
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
- console.log(`Changes: ${result.changes}`);
65
- console.log(`Cost: $${result.cost.toFixed(4)}`);
66
- console.log(`Efficiency: ${result.trace.metabolic_efficiency.toFixed(3)}`);
67
- ```
39
+ # View system status
40
+ npx claude-mycelium status
68
41
 
69
- ### Calculate Gradient Scores
42
+ # Check API costs
43
+ npx claude-mycelium cost
70
44
 
71
- ```typescript
72
- import { calculateGradient } from 'claude-mycelium';
45
+ # Run garbage collection
46
+ npx claude-mycelium gc
73
47
 
74
- const gradient = await calculateGradient('src/my-file.ts');
75
- console.log(`Overall Score: ${gradient.score.toFixed(2)}`);
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
- ### Agent Modes
81
-
82
- ```typescript
83
- // Error Reducer - Adds error handling and validation
84
- await executeAgent('src/api.ts', 'error_reducer');
52
+ ## Features
85
53
 
86
- // Complexity Reducer - Simplifies complex functions
87
- await executeAgent('src/utils.ts', 'complexity_reducer');
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
- // Debt Payer - Fixes linting issues and code smells
90
- await executeAgent('src/legacy.ts', 'debt_payer');
61
+ ## 🎯 How It Works
91
62
 
92
- // Stabilizer - Reduces file churn and improves stability
93
- await executeAgent('src/volatile.ts', 'stabilizer');
94
- ```
63
+ Claude Mycelium treats code improvement as gradient descent:
95
64
 
96
- ## 📊 Architecture
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
- ANTHROPIC_API_KEY=sk-ant-...
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
- ### API Options
82
+ ### Project Config
136
83
 
137
- ```typescript
138
- interface ExecuteOptions {
139
- dryRun?: boolean; // Validate without applying
140
- maxRetries?: number; // LLM retry attempts
141
- createBackup?: boolean; // Backup before changes
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
- ## 📈 How It Works
98
+ ## 📊 Current Status
146
99
 
147
- ### The 10-Step Execution Loop
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
- 1. **Calculate Gradient** - Measure current code quality
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
- ### Gradient-Based Optimization
161
-
162
- Claude Mycelium treats code quality as a mathematical optimization problem:
112
+ ## 🔒 Safety Features
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
+ - **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
- ## 🎓 Advanced Usage
120
+ ## 📦 Programmatic API
176
121
 
177
- ### Custom Signal Weights
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
- ### Batch Processing
127
+ // Calculate quality gradient
128
+ const gradient = await calculateGradient('src/app.ts');
129
+ console.log(`Score: ${gradient.score}`);
194
130
 
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);
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
- ## 📦 What's Included
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/ruvnet/claude-mycelium/issues)
297
- - **Discussions**: [GitHub Discussions](https://github.com/ruvnet/claude-mycelium/discussions)
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"}