docs(sdlc-fix): 第一步先看 PR 現況,再定位工作樹

補上 #14 沒有的工作樹概念:它預設在當前目錄處理留言,而留言要改的程式碼在那顆工作包
自己的工作樹裡。新的第一步先問 pr-watch 現況——PR 已經合併或關閉就停下來,在一棵該被
清掉的工作樹上處理留言是白做工——再用 worktree-ensure 定位,不在就重建。

邊界同時擋住兩件事:不回主工作區處理留言(它可能停在別的分支上),以及推導路徑上有
別的東西時不自己刪。原有的五個步驟整體往後移一號,內容不變。

議題 #42

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-17 17:33:44 +08:00
co-authored by Claude Opus 5
parent 2562555058
commit 0dd8d7b7bb
2 changed files with 76 additions and 8 deletions
+35 -2
View File
@@ -11,6 +11,39 @@ import { assertNeutralPrompt, readPrompt } from './helpers/prompt-doc.js';
const prompt = readPrompt('sdlc-fix');
const steps = prompt.slice(prompt.indexOf('## 1.'), prompt.indexOf('## 邊界'));
/** 定位那一步,與後面處理留言的步驟分開看 */
const locate = steps.slice(0, steps.indexOf('## 2.'));
test('第一步先看 PR 現況,終止狀態就停下來不白做工', () => {
assert.match(locate, /pr-watch\.js/);
assert.match(locate, /terminal/);
assert.match(locate, /白做工/, '要說明為什麼停:那棵工作樹已經該被清掉了');
});
test('工作樹由工作包推導,不要求使用者自己切目錄', () => {
assert.match(locate, /worktree-ensure\.js/);
assert.match(locate, /branch/, '輸入是 pr-watch 給的分支名');
assert.match(locate, /不必也不該由使用者自己去記/);
assert.match(locate, /都在那棵工作樹裡做/);
});
test('不存在就重建,並說明那是常態不是例外', () => {
assert.match(locate, /常態不是例外/);
assert.match(locate, /換一台機器/, '要說明為什麼工作樹常常不在');
assert.match(locate, /同一套建立方式/, '重建不另寫一套');
});
test('兩種擋下來的情況各自寫明處置,且不替使用者決定', () => {
assert.match(locate, /BRANCH_NOT_FOUND/);
assert.match(locate, /WORKTREE_PATH_TAKEN/);
assert.match(locate, /不要自己刪/);
});
test('邊界擋住「回主工作區處理留言」與「PR 結束了還繼續改」', () => {
const boundary = prompt.slice(prompt.indexOf('## 邊界'));
assert.match(boundary, /不在主工作區處理留言/);
assert.match(boundary, /已經合併或關閉時不繼續處理留言/);
});
test('正本平台中立,description 前綴正確', () => {
assertNeutralPrompt(prompt, 'sdlc-fix');
@@ -71,7 +104,7 @@ test('一次問一題,選項含手動輸入', () => {
});
test('該問的情況有列舉,不是一句「不確定就問」', () => {
const section = steps.slice(steps.indexOf('## 3.'), steps.indexOf('## 4.'));
const section = steps.slice(steps.indexOf('## 4.'), steps.indexOf('## 5.'));
const bullets = section.match(/^- /gm) ?? [];
assert.ok(bullets.length >= 3, `該問的情況要列得出來,只找到 ${bullets.length} 條`);
assert.match(section, /推了新 commit/, '位置對不上是最常見的一種,要點名');
@@ -112,7 +145,7 @@ test('寫入前要求先試跑', () => {
// ── 摘要 ───────────────────────────────────────────────────────────
test('摘要要逐則列出,並單獨點出沒有記號的那幾則', () => {
const section = steps.slice(steps.indexOf('## 5.'));
const section = steps.slice(steps.indexOf('## 6.'));
assert.match(section, /逐則一行/);
assert.match(section, /沒有留下記號的那幾則/);
assert.match(section, /以為它們被跳過/, '要說出為什麼得單獨列');