speccore 8.3.165 → 8.3.167

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.
@@ -820,6 +820,7 @@ async function processBatch(tasks, state, iteration) {
820
820
  await generateTaskSkeleton(task, iteration);
821
821
  completed.push(task.id);
822
822
  // 写入任务摘要到 execution-state(文件即记忆)
823
+ // v8.3.166+: 包含 agent 角色,供跨 Agent 状态共享
823
824
  const taskSummary = {
824
825
  taskId: task.id,
825
826
  taskName: task.name || task.id,
@@ -829,6 +830,7 @@ async function processBatch(tasks, state, iteration) {
829
830
  outputs: ['00-specs/', '{platform}/(子任务)/'],
830
831
  dependencies: task.dependencies || [],
831
832
  completedAt: new Date().toISOString(),
833
+ agent: 'spec-executor',
832
834
  };
833
835
  (0, execution_state_1.addTaskSummary)(state, taskSummary);
834
836
  logger_1.logger.info(` ✅ ${task.id || task} completed`);
@@ -1561,6 +1563,7 @@ async function prepareTaskBranch(task, iteration, defaultBase, createdBranches)
1561
1563
  }
1562
1564
  // 4b. 合并依赖任务分支
1563
1565
  // 查找顺序:1. 当前会话 createdBranches 2. git-mapping.json 3. git branch 列表
1566
+ const mergedBranches = [];
1564
1567
  for (const depId of depTaskIds) {
1565
1568
  let depBranch = createdBranches.get(depId);
1566
1569
  let source = '当前会话';
@@ -1572,6 +1575,7 @@ async function prepareTaskBranch(task, iteration, defaultBase, createdBranches)
1572
1575
  try {
1573
1576
  (0, child_process_1.execSync)(`git merge "${depBranch}" --no-edit --no-ff`, { cwd: gitCwd, stdio: 'pipe' });
1574
1577
  logger_1.logger.info(` 🔗 合并依赖分支 [${source}]: ${depBranch}`);
1578
+ mergedBranches.push(depBranch);
1575
1579
  }
1576
1580
  catch (e) {
1577
1581
  logger_1.logger.warn(` ⚠️ 合并 ${depBranch} 冲突,需要手动解决`);
@@ -1582,6 +1586,40 @@ async function prepareTaskBranch(task, iteration, defaultBase, createdBranches)
1582
1586
  logger_1.logger.warn(` 可能原因:1) 依赖任务尚未执行 2) 分支在另一会话创建 3) 分支已被删除`);
1583
1587
  }
1584
1588
  }
1589
+ // v8.3.166+: 更新 execution-state,记录分支信息供跨 Agent 共享
1590
+ try {
1591
+ const { loadExecutionState, saveExecutionState } = await Promise.resolve().then(() => __importStar(require('../core/execution-state')));
1592
+ const state = loadExecutionState();
1593
+ if (state && branch) {
1594
+ const existing = state.taskSummaries[task.id];
1595
+ if (existing) {
1596
+ existing.branchName = branch;
1597
+ existing.branchBase = base;
1598
+ if (mergedBranches.length > 0)
1599
+ existing.mergedBranches = mergedBranches;
1600
+ }
1601
+ else {
1602
+ state.taskSummaries[task.id] = {
1603
+ taskId: task.id,
1604
+ taskName: task.name || task.id,
1605
+ type: task.type || 'feature',
1606
+ status: 'completed',
1607
+ summary: '分支已创建',
1608
+ outputs: [],
1609
+ dependencies: depTaskIds,
1610
+ completedAt: new Date().toISOString(),
1611
+ branchName: branch,
1612
+ branchBase: base,
1613
+ mergedBranches: mergedBranches.length > 0 ? mergedBranches : undefined,
1614
+ };
1615
+ }
1616
+ saveExecutionState(state);
1617
+ // 同时更新上下文摘要文件(供新会话 Agent 读取)
1618
+ const { writeContextSummaryFile } = await Promise.resolve().then(() => __importStar(require('../core/execution-state')));
1619
+ await writeContextSummaryFile(state);
1620
+ }
1621
+ }
1622
+ catch { /* ignore state update errors */ }
1585
1623
  return branch;
1586
1624
  }
1587
1625
  /**
@@ -2135,12 +2173,43 @@ async function runPromptMode(iteration, options) {
2135
2173
  platform: options.platform,
2136
2174
  withCode: options.withCode,
2137
2175
  });
2138
- // 在 prompt 中追加分支信息(告诉 AI 在哪个分支上工作)
2176
+ // v8.3.166+: 注入跨 Agent 执行状态(让当前 Agent 知道之前 Agent 的分支和进度)
2139
2177
  let promptText = (0, prompt_builder_1.formatPrompt)(prompt);
2178
+ // 读取 execution-summary.md(之前 Agent 的执行状态和分支记录)
2179
+ let agentStateContext = '';
2180
+ try {
2181
+ const summaryPath = (0, path_1.join)('.speccore', 'local', 'execution-summary.md');
2182
+ if (await (0, fs_extra_1.pathExists)(summaryPath)) {
2183
+ const summary = await (0, fs_extra_1.readFile)(summaryPath, 'utf-8');
2184
+ if (summary.trim().length > 0) {
2185
+ agentStateContext = `\n\n## 🤖 跨 Agent 执行状态\n`;
2186
+ agentStateContext += `> 以下信息来自之前 Agent 的执行记录,供你参考依赖关系和分支状态\n\n`;
2187
+ agentStateContext += summary.slice(0, 2000); // 限制长度,避免溢出
2188
+ agentStateContext += '\n';
2189
+ }
2190
+ }
2191
+ }
2192
+ catch { /* ignore */ }
2193
+ if (agentStateContext) {
2194
+ promptText += agentStateContext;
2195
+ }
2196
+ // 在 prompt 中追加分支信息(告诉 AI 在哪个分支上工作)
2140
2197
  if (branchName) {
2141
2198
  promptText += `\n\n## 🔀 Git 分支\n`;
2142
2199
  promptText += `当前已切换到任务分支: \`${branchName}\`\n`;
2143
2200
  promptText += `请在此分支上编写代码。\n`;
2201
+ // v8.3.166+: 如果有依赖分支已合并,提示 AI
2202
+ const mergedBranches = [];
2203
+ for (const [depId, depBranch] of createdBranches) {
2204
+ if (depId !== task)
2205
+ mergedBranches.push(`${depId} → ${depBranch}`);
2206
+ }
2207
+ if (mergedBranches.length > 0) {
2208
+ promptText += `\n**已合并的依赖分支**:\n`;
2209
+ for (const mb of mergedBranches)
2210
+ promptText += `- ${mb}\n`;
2211
+ promptText += `这些分支的代码已合并到当前分支,可以直接使用。\n`;
2212
+ }
2144
2213
  }
2145
2214
  // v8.2.0+: 注入相邻任务上下文(同一 Task 的其他端 + 契约)
2146
2215
  try {
@@ -2218,8 +2287,28 @@ async function runPromptMode(iteration, options) {
2218
2287
  promptText += `\n✅ 所有任务已完成!\n`;
2219
2288
  }
2220
2289
  }
2290
+ // v8.3.166+: 推断任务平台(端),输出端级 subagent 标记
2291
+ let platformSubagent = 'spec-executor';
2292
+ try {
2293
+ const entries = await (0, fs_extra_1.readdir)(taskDir, { withFileTypes: true });
2294
+ const platformNames = entries
2295
+ .filter((e) => e.isDirectory() && !e.name.startsWith('.') && e.name !== '00-specs' && e.name !== '_shared')
2296
+ .map((e) => e.name);
2297
+ if (platformNames.length === 1) {
2298
+ platformSubagent = `spec-executor-${platformNames[0]}`;
2299
+ }
2300
+ }
2301
+ catch { /* ignore */ }
2221
2302
  // 输出到 stdout(Skill 通过 execute_command 捕获)
2222
- process.stdout.write(promptText);
2303
+ // v8.3.166+: 在 prompt 前输出 subagent 标记
2304
+ const finalOutput = [
2305
+ `[SPECCORE_SUBAGENT: ${platformSubagent}]`,
2306
+ `[SPECCORE_CONTEXT_BUDGET: 12000]`,
2307
+ `[SPECCORE_CONTEXT_TYPE: ${options.platform ? 'platform-only' : 'full'}]`,
2308
+ ``,
2309
+ promptText,
2310
+ ].join('\n');
2311
+ process.stdout.write(finalOutput);
2223
2312
  // 退出码 10: 表示等待 AI 处理
2224
2313
  process.exitCode = 10;
2225
2314
  }