@liangjie559567/ultrapower 5.3.2 → 5.4.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.
@@ -8,11 +8,11 @@
8
8
  {
9
9
  "name": "ultrapower",
10
10
  "description": "Disciplined multi-agent orchestration: workflow enforcement + parallel execution",
11
- "version": "5.3.2",
11
+ "version": "5.4.0",
12
12
  "source": {
13
13
  "source": "npm",
14
14
  "package": "@liangjie559567/ultrapower",
15
- "version": "5.3.2"
15
+ "version": "5.4.0"
16
16
  },
17
17
  "author": {
18
18
  "name": "liangjie559567"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ultrapower",
3
3
  "description": "Disciplined multi-agent orchestration: workflow enforcement + parallel execution. Combines superpowers' TDD/debugging discipline with OMC's multi-agent execution capabilities.",
4
- "version": "5.3.2",
4
+ "version": "5.4.0",
5
5
  "author": {
6
6
  "name": "liangjie559567"
7
7
  },
@@ -0,0 +1,148 @@
1
+ # Nexus Self-Evolution System Enhancement Plan (v2 — Post-Review)
2
+
3
+ > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
4
+
5
+ **Goal:** 将 nexus-daemon 从单维模式检测升级为多维智能自进化系统,覆盖模式挖掘、健康评估、异常检测、推荐引擎、LLM 自反思和知识图谱。
6
+
7
+ **Architecture:** 分 4 个优先级阶段(P0→P1→P2→P3)递进实现。P0 为纯 Python 数据分析层(无 LLM 依赖),构建数据基础;P1 引入 LLM 和语义能力;P2 增加安全沙箱和强化学习;P3 为长期愿景。
8
+
9
+ **Tech Stack:** Python 3.11+, pytest, aiohttp, collections.Counter, dataclasses, math, json, pathlib
10
+
11
+ **Review History:**
12
+ - v1: 初始计划 (T1-T12)
13
+ - v2: 经 Architect + Critic 两轮评审,融合 6 项强制修正
14
+
15
+ ---
16
+
17
+ ## Review Consensus (Architect + Critic)
18
+
19
+ ### 6 项强制修正
20
+
21
+ 1. **T2 向后兼容接口**: SelfEvaluator 必须同时支持 `repo_path: Path` 和 `events: list[dict]` 两种初始化方式,不破坏 daemon.py 现有调用
22
+ 2. **T4 Strategy 模式**: 异常检测必须使用 CompositeDetector + 可插拔检测器接口,P0 仅实现 ZScoreDetector
23
+ 3. **T6 God Class 重构**: daemon.py NexusDaemon 拆分为 GitSync、EventProcessor、ImprovementManager、HealthReporter、ModuleRegistry 五个职责类
24
+ 4. **T6 用户可见输出**: P0 必须产出 `consciousness/status.md` 最小状态摘要
25
+ 5. **T6 渐进式 Schema**: 事件验证采用渐进式(warn-only),不作为独立阻塞任务
26
+ 6. **T17 重定义**: 不删除,重定义为"跨 Agent 经验传播",移至 P1
27
+
28
+ ---
29
+
30
+ ## Task Queue
31
+
32
+ ### P0 — 数据基础层(纯 Python,无 LLM 依赖)
33
+
34
+ | ID | Name | Dependencies | Parallel Group | Estimated |
35
+ |----|------|-------------|----------------|-----------|
36
+ | T1 | Multi-dim pattern detection (evolution_engine.py) | none | G1 | 2-3h |
37
+ | T2 | 6-dim health evaluation (self_evaluator.py) | none | G1 | 3h |
38
+ | T4 | Anomaly detection — Strategy pattern (anomaly_detector.py) | T2 | G2 | 2h |
39
+ | T5 | Recommendation engine + Thompson Sampling (recommendation_engine.py) | T2, T4 | G3 | 3h |
40
+ | T6 | Daemon integration + God Class refactor + status output | T1, T2, T4, T5 | G4 | 3h |
41
+
42
+ ### P1 — LLM + 语义能力
43
+
44
+ | ID | Name | Dependencies | Parallel Group | Estimated |
45
+ |----|------|-------------|----------------|-----------|
46
+ | T7 | LLM self-reflection Reflexion framework (consciousness_loop.py) | T6 | G5 | 3-4h |
47
+ | T8 | Knowledge graph — chromadb + networkx (knowledge_graph.py) | T6 | G5 | 4-5h |
48
+ | T17 | Cross-agent experience propagation (experience_sharing.py) | T8 | G5 | 2-3h |
49
+
50
+ ### P2 — 安全沙箱 + 强化学习
51
+
52
+ | ID | Name | Dependencies | Parallel Group | Estimated |
53
+ |----|------|-------------|----------------|-----------|
54
+ | T9 | Sandbox + canary release (self_modifier.py) | T6 | G6 | 3-4h |
55
+ | T15 | Code health scorer — radon MI + complexity (code_health_scorer.py) | T2 | G6 | 2h |
56
+ | T14 | Bottleneck analyzer (bottleneck_analyzer.py) | T6 | G6 | 2h |
57
+
58
+ ### P3 — 集成 + 可视化
59
+
60
+ | ID | Name | Dependencies | Parallel Group | Estimated |
61
+ |----|------|-------------|----------------|-----------|
62
+ | T10 | RL feedback loop (prompt_optimizer.py) | T7, T9 | G7 | 3-4h |
63
+ | T11 | 4-layer memory model (memory_model.py) | T8 | G7 | 3-4h |
64
+ | T12 | Final integration + CI Gate | T1-T11 | G8 | 1h |
65
+ | T18 | Evolution dashboard (evolution_dashboard.py) | T14 | G8 | 2h |
66
+
67
+ ---
68
+
69
+ ## P0 Task Details
70
+
71
+ ### Task 1: Multi-dimensional Pattern Detection (evolution_engine.py)
72
+
73
+ **Files:**
74
+ - Modify: `nexus-daemon/evolution_engine.py`
75
+ - Test: `nexus-daemon/tests/test_evolution_engine.py`
76
+
77
+ **Context:** 当前 `detect_patterns()` 只检测 `mode_usage` 一个维度。扩展为 5 个维度:mode_usage、tool_sequence、agent_cooccurrence、error_pattern、skill_chain。
78
+
79
+ **Implementation:** 保留现有 `mode_usage` 逻辑,追加 `_detect_tool_sequences()`、`_detect_agent_cooccurrence()`、`_detect_error_patterns()` 三个私有函数,在 `detect_patterns()` 末尾调用。使用滑动窗口 n-gram 提取 tool sequence,使用 `itertools.combinations` 提取 agent 共现对。
80
+
81
+ ---
82
+
83
+ ### Task 2: Six-Dimension Health Evaluation (self_evaluator.py)
84
+
85
+ **Files:**
86
+ - Modify: `nexus-daemon/self_evaluator.py`
87
+ - Test: `nexus-daemon/tests/test_self_evaluator.py`
88
+
89
+ **Context:** 当前 `SelfEvaluator` 只做 skill 触发计数和僵尸检测。扩展为 6 维健康评估。
90
+
91
+ **强制约束 — 向后兼容接口:**
92
+ ```python
93
+ class SelfEvaluator:
94
+ def __init__(self, repo_path: Path | None = None, *,
95
+ events: list[dict] | None = None,
96
+ zombie_threshold: int = 10):
97
+ # 支持两种模式:
98
+ # 1. repo_path 模式(daemon.py 现有调用)
99
+ # 2. events 模式(新的直接传入事件)
100
+ ```
101
+
102
+ 保留 `generate_report()` 方法不变(向后兼容),新增 `generate_health_report()` 返回含 `dimension_scores` 的增强报告。
103
+
104
+ ---
105
+
106
+ ### Task 4: Anomaly Detection — Strategy Pattern (anomaly_detector.py)
107
+
108
+ **Files:**
109
+ - Create: `nexus-daemon/anomaly_detector.py`
110
+ - Test: `nexus-daemon/tests/test_anomaly_detector.py`
111
+
112
+ **强制约束 — Strategy 模式接口:**
113
+ ```python
114
+ class AnomalyDetector(ABC):
115
+ @abstractmethod
116
+ def detect(self, values: list[float]) -> list[AnomalyRecord]: ...
117
+
118
+ class ZScoreDetector(AnomalyDetector): ... # P0 唯一实现
119
+ class CompositeDetector(AnomalyDetector): # 组合多个检测器
120
+ def __init__(self, detectors: list[AnomalyDetector]): ...
121
+ ```
122
+
123
+ P0 仅实现 ZScoreDetector。IQR 和 EWMA 留给后续迭代。
124
+
125
+ ---
126
+
127
+ ### Task 5: Recommendation Engine + Thompson Sampling (recommendation_engine.py)
128
+
129
+ **Files:**
130
+ - Create: `nexus-daemon/recommendation_engine.py`
131
+ - Test: `nexus-daemon/tests/test_recommendation_engine.py`
132
+
133
+ **Context:** 基于使用模式推荐最优 agent/skill 组合。合并原 T5 和 T16,使用 Thompson Sampling (`θ ~ Beta(α_success, β_failure)`) 实现探索-利用平衡。
134
+
135
+ ---
136
+
137
+ ### Task 6: Daemon Integration + God Class Refactor + Status Output
138
+
139
+ **Files:**
140
+ - Modify: `nexus-daemon/daemon.py`
141
+ - Create: `nexus-daemon/module_registry.py`
142
+ - Test: `nexus-daemon/tests/test_daemon.py`
143
+
144
+ **强制约束:**
145
+ 1. **God Class 拆分**: NexusDaemon 拆为 GitSync、EventProcessor、ImprovementManager、HealthReporter + ModuleRegistry 协调
146
+ 2. **渐进式 Schema**: 事件加载时 warn-only 验证,不阻塞处理
147
+ 3. **状态输出**: 每次 run_once 后写入 `consciousness/status.md`
148
+ 4. **Circuit Breaker**: 模块连续失败 3 次后熔断,不影响其他模块
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liangjie559567/ultrapower",
3
- "version": "5.3.2",
3
+ "version": "5.4.0",
4
4
  "description": "Disciplined multi-agent orchestration: workflow enforcement + parallel execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",