diff --git a/app/index.js b/app/index.js index bc05f69..164709d 100644 --- a/app/index.js +++ b/app/index.js @@ -138,13 +138,17 @@ function fallbackSummary({ source, target, commitMessages, diffStat }) { return { title, description }; } +// 解衝突分支主體最大長度;連同前綴 `resolve-conflict/` 與 runId 後綴, +// 總長度仍遠低於 Git 對 ref 名稱的限制(約 255)。 +const MAX_BRANCH_STEM_LENGTH = 180; + /** 解衝突分支名稱。 */ function buildResolveBranchName(target, source) { const runId = process.env.GITHUB_RUN_NUMBER || process.env.GITHUB_RUN_ID || ''; const safe = (s) => s.replace(/[^a-zA-Z0-9._/-]/g, '-'); const suffix = runId ? `-${runId}` : ''; // 截斷主體長度,避免 target/source 過長使分支名稱超出 Git 限制 - const stem = `${safe(target)}-into-${safe(source)}`.slice(0, 180); + const stem = `${safe(target)}-into-${safe(source)}`.slice(0, MAX_BRANCH_STEM_LENGTH); return `resolve-conflict/${stem}${suffix}`; } diff --git a/app/lib/opencode.js b/app/lib/opencode.js index 0d3870f..43f312e 100644 --- a/app/lib/opencode.js +++ b/app/lib/opencode.js @@ -92,7 +92,11 @@ export class OpenCode { ); if (result.status !== 0) { - log.warn(`opencode 執行失敗 (${result.status}):${maskSecrets(result.stderr).slice(0, 500)}`); + const stderr = maskSecrets(result.stderr); + const shown = stderr.length > 2000 + ? `${stderr.slice(0, 2000)}\n…(錯誤訊息過長,已截斷,僅顯示前 2000 字元)` + : stderr; + log.warn(`opencode 執行失敗 (${result.status}):${shown}`); return null; }