openmatrix 0.2.23 → 0.2.25

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.
@@ -166,7 +166,7 @@ async function loadResearchContext(researchContextPath, basePath, omPath) {
166
166
  /**
167
167
  * 合并研究上下文到 AI 解析的输入
168
168
  */
169
- function mergeResearchContext(tasksInput, researchContext, researchReport) {
169
+ function mergeResearchContext(tasksInput, researchContext) {
170
170
  const merged = { ...tasksInput };
171
171
  // goals: 研究的基础 goals + AI 补充的 goals(去重)
172
172
  const baseGoals = researchContext.goals || [];
@@ -189,14 +189,6 @@ function mergeResearchContext(tasksInput, researchContext, researchReport) {
189
189
  if (mergedDeliverables.length > 0) {
190
190
  merged.deliverables = mergedDeliverables;
191
191
  }
192
- // plan: 如果 AI 未提供 plan,使用研究报告内容
193
- if (!merged.plan && researchReport) {
194
- merged.plan = `# 领域研究: ${researchContext.domain}\n\n## 研究主题\n${researchContext.topic}\n\n${researchReport}`;
195
- }
196
- else if (researchReport) {
197
- // AI 已有 plan,将研究作为附录追加
198
- merged.plan = `${merged.plan}\n\n---\n\n# 领域研究背景: ${researchContext.domain}\n\n## 研究主题\n${researchContext.topic}\n\n${researchReport}`;
199
- }
200
192
  return merged;
201
193
  }
202
194
  /**
@@ -238,17 +230,25 @@ async function handleTasksJson(options, stateManager, state, omPath, basePath) {
238
230
  return;
239
231
  }
240
232
  // 加载并合并研究上下文
241
- const { context: researchContext, report: researchReport } = await loadResearchContext(options.researchContext, basePath, omPath);
233
+ const { context: researchContext } = await loadResearchContext(options.researchContext, basePath, omPath);
242
234
  let resolvedInput = tasksInput;
243
235
  if (researchContext) {
244
- resolvedInput = mergeResearchContext(tasksInput, researchContext, researchReport);
236
+ resolvedInput = mergeResearchContext(tasksInput, researchContext);
245
237
  if (!options.json) {
246
238
  console.log(`🔬 已加载研究领域: ${researchContext.domain}`);
247
239
  }
248
240
  }
249
- // 保存 AI 生成的执行计划
250
- if (resolvedInput.plan) {
251
- await fs.writeFile(path.join(omPath, 'plan.md'), resolvedInput.plan, 'utf-8');
241
+ // 读取独立的技术方案文档(plan.md)
242
+ let planContent;
243
+ const planPath = path.join(omPath, 'plan.md');
244
+ try {
245
+ planContent = await fs.readFile(planPath, 'utf-8');
246
+ if (!options.json) {
247
+ console.log(`📄 已加载技术方案: plan.md`);
248
+ }
249
+ }
250
+ catch {
251
+ // plan.md 不存在时继续(可能由 AI 后续生成或无 plan)
252
252
  }
253
253
  // 构建 ParsedTask
254
254
  const parsedTask = {
@@ -256,6 +256,7 @@ async function handleTasksJson(options, stateManager, state, omPath, basePath) {
256
256
  description: resolvedInput.description || '',
257
257
  goals: resolvedInput.goals,
258
258
  goalTypes: resolvedInput.goalTypes,
259
+ goalComplexity: resolvedInput.goalComplexity,
259
260
  constraints: resolvedInput.constraints || [],
260
261
  deliverables: resolvedInput.deliverables || [],
261
262
  rawContent: ''
@@ -281,7 +282,7 @@ async function handleTasksJson(options, stateManager, state, omPath, basePath) {
281
282
  }
282
283
  // 使用 TaskPlanner 拆分(保持原有拆分逻辑)
283
284
  const planner = new task_planner_js_1.TaskPlanner();
284
- const subTasks = planner.breakdown(parsedTask, extraAnswers, qualityConfig, resolvedInput.plan);
285
+ const subTasks = planner.breakdown(parsedTask, extraAnswers, qualityConfig, planContent);
285
286
  // 创建任务到状态管理器,并建立 ID 映射
286
287
  // TaskPlanner 生成的 taskId 和 StateManager 创建的 id 不同,
287
288
  // 需要映射后才能正确设置 dependencies
@@ -1,43 +1,4 @@
1
1
  import type { ParsedTask, QualityConfig } from '../types/index.js';
2
- /**
3
- * 从 plan 中解析出的结构化模块信息
4
- */
5
- export interface PlanModule {
6
- /** 模块名称,如 "用户域" */
7
- name: string;
8
- /** 模块描述 */
9
- description: string;
10
- /** 关联的表,如 ["users", "user_profiles"] */
11
- tables: string[];
12
- /** 模块类型 */
13
- type: 'domain' | 'feature' | 'infra' | 'system';
14
- /** 依赖的其他模块名称 */
15
- dependsOn: string[];
16
- /** 预估复杂度 */
17
- complexity: 'low' | 'medium' | 'high';
18
- }
19
- /**
20
- * 从 plan 中解析出的结构化信息
21
- */
22
- export interface ParsedPlan {
23
- /** 核心模块列表 */
24
- modules: PlanModule[];
25
- /** 技术栈摘要 */
26
- techStack: string[];
27
- /** 原始 plan 文本 */
28
- raw: string;
29
- }
30
- /** 从 plan 中提取的结构化信息(用于 fallback 时注入任务描述) */
31
- export interface PlanMetadata {
32
- /** 技术栈 */
33
- techStack: string[];
34
- /** 接口/API 定义 */
35
- interfaces: string[];
36
- /** 数据模型/表 */
37
- dataModels: string[];
38
- /** 关键决策 */
39
- keyDecisions: string[];
40
- }
41
2
  export interface TaskBreakdown {
42
3
  taskId: string;
43
4
  title: string;
@@ -66,14 +27,8 @@ export interface UserAnswers {
66
27
  /**
67
28
  * TaskPlanner - 任务拆解器
68
29
  *
69
- * 增强版特性:
70
- * 1. 更细粒度的任务拆分 (每个目标拆分为设计+实现+测试)
71
- * 2. 测试任务配对 (每个开发任务自动生成对应测试任务)
72
- * 3. 验收标准注入 (从用户回答中提取)
73
- * 4. 用户上下文注入 (将用户回答注入任务描述)
74
- * 5. 依赖关系分析 (自动分析任务间依赖)
75
- * 6. 并行执行 (独立任务互不依赖)
76
- * 7. 质量级别感知 (根据配置调整测试覆盖率)
30
+ * Plan 原文作为原始上下文透传给 AI Agent,由 AI 自行理解和提取
31
+ * 技术栈、数据模型、依赖关系等信息。CLI 层不做语义解析。
77
32
  */
78
33
  export declare class TaskPlanner {
79
34
  private userAnswers;
@@ -85,66 +40,20 @@ export declare class TaskPlanner {
85
40
  */
86
41
  setUserAnswers(answers: UserAnswers): void;
87
42
  /**
88
- * 解析 plan 文本,提取模块、技术栈、数据模型等结构化信息
89
- */
90
- parsePlan(planText: string): ParsedPlan;
91
- /**
92
- * 从 plan 中提取结构化信息(用于 fallback 时注入任务描述)
93
- * 即使无法解析模块,也能保留关键技术信息
94
- */
95
- extractPlanMetadata(plan: string): PlanMetadata;
96
- /**
97
- * 从 goals 推断模块结构(当 plan 无法解析模块时使用)
98
- */
99
- inferModulesFromGoals(parsedTask: ParsedTask): PlanModule[];
100
- /**
101
- * 分析模块间依赖关系
102
- *
103
- * 策略:从 plan 文本中提取 AI 明确写的依赖信息,不做架构猜测。
104
- * 如果 plan 中没有指定依赖,模块之间并行执行。
105
- */
106
- private analyzeModuleDependencies;
107
- /**
108
- * 从 plan 文本中提取某个模块相关的上下文段落
109
- */
110
- private extractModuleContext;
111
- /**
112
- * 预估模块复杂度 — 基于通用架构特征,不依赖具体业务领域
43
+ * 任务拆解 — 唯一路径:按目标拆分,plan 作为原始上下文透传
113
44
  */
114
- private estimateModuleComplexity;
115
45
  breakdown(parsedTask: ParsedTask, answers: Record<string, string>, qualityConfig?: QualityConfig, plan?: string): TaskBreakdown[];
116
46
  /**
117
- * 基于 plan 解析出的模块做细粒度任务拆分
118
- */
119
- private breakdownByModules;
120
- /**
121
- * 为模块任务添加 phase 级别的跨阶段依赖
122
- */
123
- private enforcePhaseDependenciesForModule;
124
- /**
125
- * 确定模块任务优先级
126
- */
127
- private determineModulePriority;
128
- /**
129
- * 为模块生成验收标准
130
- */
131
- private generateModuleAcceptanceCriteria;
132
- /**
133
- * 按目标拆分的传统方式(fallback)
47
+ * 按目标拆分子任务
134
48
  */
135
49
  private breakdownByGoals;
136
- /**
137
- * 判断是否需要设计阶段
138
- *
139
- * 条件: 多个 goal,或 goal 包含复杂关键词
140
- */
141
50
  private needsDesignPhase;
142
51
  /**
143
52
  * 获取测试覆盖率目标
144
53
  */
145
54
  private getCoverageTarget;
146
55
  /**
147
- * 提取用户上下文
56
+ * 提取用户上下文 — 使用 translateBrainstormAnswers 映射后的规范化键
148
57
  */
149
58
  private extractUserContext;
150
59
  private parseArrayAnswer;
@@ -161,14 +70,6 @@ export declare class TaskPlanner {
161
70
  private generateTaskId;
162
71
  private determinePriority;
163
72
  private estimateComplexity;
164
- /**
165
- * 分类目标类型
166
- * - development: 需要编写代码的功能实现 → 拆分为实现+测试对
167
- * - testing: 已明确是测试任务 → 单个测试任务
168
- * - documentation: 文档编写 → 单个文档任务
169
- * - other: 其他类型(配置、优化、部署等) → 单个任务
170
- */
171
- private classifyGoal;
172
73
  /**
173
74
  * 检测顺序阶段目标(如 "Phase 1 基础架构"、"Phase 2 AI创作核心")
174
75
  * 返回按阶段排序的索引列表