speccore 8.3.303 → 8.3.304

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.
@@ -556,24 +556,9 @@ async function executeWithProgress(tasks, iteration, base, skip, options) {
556
556
  // ── 分支策略:懒创建 + 依赖合并 ──
557
557
  // 每个任务的分支在执行前才创建,确保依赖任务的代码已存在
558
558
  // 有依赖的任务会 merge 依赖分支,拿到前序任务的代码
559
- // v8.3.87+: 检测默认分支时使用 PROJECT.yaml 中的 code_path(支持 speccore 与工程分离)
560
- let defaultGitCwd = process.cwd();
561
- try {
562
- const pc = await (0, unified_config_1.loadProjectConfig)();
563
- const firstPlatformWithPath = pc.platforms.find((p) => p.code_path);
564
- if (firstPlatformWithPath?.code_path) {
565
- defaultGitCwd = (0, path_1.isAbsolute)(firstPlatformWithPath.code_path)
566
- ? firstPlatformWithPath.code_path
567
- : (0, path_1.join)(process.cwd(), firstPlatformWithPath.code_path);
568
- }
569
- else if (pc.code_scope?.[0]) {
570
- defaultGitCwd = (0, path_1.isAbsolute)(pc.code_scope[0])
571
- ? pc.code_scope[0]
572
- : (0, path_1.join)(process.cwd(), pc.code_scope[0]);
573
- }
574
- }
575
- catch { }
576
- const defaultBase = base || (0, git_integration_1.detectDefaultBranch)(iteration, defaultGitCwd);
559
+ // v8.3.304: base 解析链(任务级 git-config > 迭代级 > PROJECT.yaml source/default_base > git 检测)
560
+ // 下沉到 prepareTaskBranch 内按任务类型解析,此处仅保留显式 --base
561
+ const defaultBase = base;
577
562
  const createdBranches = new Map(); // taskId → branchName
578
563
  // ── Agent mode: output optimized context for external AI ──
579
564
  if (options?.agent) {
@@ -1529,23 +1514,7 @@ async function prepareTaskBranch(task, iteration, defaultBase, createdBranches)
1529
1514
  catch {
1530
1515
  // 推断失败时使用 process.cwd()
1531
1516
  }
1532
- const base = defaultBase || 'HEAD';
1533
- // 1. 切回 base 分支(允许从保护分支拉分支,但 hook 会阻止直接 commit)
1534
- // v8.3.300: 改用合并版保护分支判定(含 PROJECT.yaml 全局/端级配置)
1535
- if (defaultBase && await (0, git_integration_1.isProtectedBranchAsync)(defaultBase)) {
1536
- logger_1.logger.info(` ℹ️ base 分支 '${defaultBase}' 受保护,任务分支将独立工作`);
1537
- }
1538
- try {
1539
- (0, child_process_1.execSync)(`git checkout "${base}"`, { cwd: gitCwd, stdio: 'pipe' });
1540
- }
1541
- catch {
1542
- // base 分支不存在时从 HEAD 创建
1543
- try {
1544
- (0, child_process_1.execSync)('git checkout -', { cwd: gitCwd, stdio: 'pipe' });
1545
- }
1546
- catch { }
1547
- }
1548
- // 2. 查找任务目录 + 读取任务类型(用于子任务级 git 配置 + 分支类型映射)
1517
+ // 1. 查找任务目录 + 读取任务类型(base 解析依赖 taskType → branch_types source 映射)
1549
1518
  const iterDir = await (0, context_1.getIterationDir)(iteration);
1550
1519
  const taskDir = await resolveTaskDir(iterDir, task.id);
1551
1520
  let taskType;
@@ -1556,7 +1525,7 @@ async function prepareTaskBranch(task, iteration, defaultBase, createdBranches)
1556
1525
  }
1557
1526
  }
1558
1527
  catch { }
1559
- // v8.3.207+: bugfix 关联功能模块时,从该模块的任务分支拉(默认仍从 main)
1528
+ // 2. v8.3.207+: bugfix 关联功能模块时,从该模块的任务分支拉(最高优先级)
1560
1529
  let bugfixBase;
1561
1530
  if (taskType === 'bugfix') {
1562
1531
  try {
@@ -1574,8 +1543,27 @@ async function prepareTaskBranch(task, iteration, defaultBase, createdBranches)
1574
1543
  }
1575
1544
  catch { }
1576
1545
  }
1577
- // 3. 创建任务分支(传入 taskDir + taskType + cwd 支持子任务级 git 配置 + 工程目录分离)
1578
- const branch = (0, git_integration_1.createTaskBranch)(task.id, task.name || task.id, bugfixBase, iteration, taskDir, taskType, gitCwd);
1546
+ // 3. 解析 base 分支:bugfix 关联 > 显式 --base > 配置链 > git 检测
1547
+ // v8.3.304: 配置链接入 PROJECT.yaml(branch_types[{type}].source → git.default_base),
1548
+ // 此前该主配置从未参与 execute 拉分支判定,用户配置 source 不生效
1549
+ const base = bugfixBase || defaultBase || await (0, git_integration_1.resolveTaskBaseBranch)(taskType, iteration, taskDir, gitCwd) || 'HEAD';
1550
+ // 4. 切回 base 分支(允许从保护分支拉分支,但 hook 会阻止直接 commit)
1551
+ // v8.3.300: 改用合并版保护分支判定(含 PROJECT.yaml 全局/端级配置)
1552
+ if (base !== 'HEAD' && await (0, git_integration_1.isProtectedBranchAsync)(base)) {
1553
+ logger_1.logger.info(` ℹ️ base 分支 '${base}' 受保护,任务分支将独立工作`);
1554
+ }
1555
+ try {
1556
+ (0, child_process_1.execSync)(`git checkout "${base}"`, { cwd: gitCwd, stdio: 'pipe' });
1557
+ }
1558
+ catch {
1559
+ // base 分支不存在时从 HEAD 创建
1560
+ try {
1561
+ (0, child_process_1.execSync)('git checkout -', { cwd: gitCwd, stdio: 'pipe' });
1562
+ }
1563
+ catch { }
1564
+ }
1565
+ // 5. 创建任务分支(传入解析后的 base + taskDir + taskType + cwd,保证两处 checkout 一致)
1566
+ const branch = (0, git_integration_1.createTaskBranch)(task.id, task.name || task.id, base !== 'HEAD' ? base : undefined, iteration, taskDir, taskType, gitCwd);
1579
1567
  if (!branch)
1580
1568
  return null;
1581
1569
  createdBranches.set(task.id, branch);