起錶與停錶寫在同一份正本裡成對出現,讀的人一眼看得出這段計時涵蓋到哪;兩份各加一節 「計時範圍」把兩端指出來。 sdlc-plan 記兩段:議題建立之前那段在第一步記下開始時間、議題建立之後以補登記上去; 之後起錶,回報那一步停錶。補登排在議題建立之後、起錶之前,順序反過來的話補登會被 time-log 當成「這一步做過了」而跳過。 sdlc-analyze 在它分析的那顆需求議題上起錶,起點放在第一段開頭——分析最耗時的正是 共識之前那一段,從第二段才起的話那段時間永遠是零。因此「共識摘要之前不對 Gitea 產生任何寫入」改寫成「不寫入任何**內容**」,並把碼錶明文除外、寫上理由:它記的是 工時,不是內容。這一條與 repo 擁有者確認過。 sdlc-feat 的「碼錶一律由使用者自己停」收斂成「**別顆議題上的**錶一律由使用者自己停」 ——它原本讀起來像全域規則,而現在每道指令都會停自己起的那一支。 正本之間改以步驟**名稱**互指,不用編號:編號會整批位移,名字不會。測試跟著改用新的 promptStep 輔助函式,以名字框出某一步的內容,別人插一步時不會無聲地框到另一段上。 議題 #57 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
151 lines
6.8 KiB
JavaScript
151 lines
6.8 KiB
JavaScript
/**
|
|
* sdlc-analyze 的交付物:四份可行性檢查清單與流程正本。
|
|
* 這一段不寫入 Gitea,所以沒有腳本——交付的就是這些文件本身。
|
|
*/
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { assertNeutralPrompt, promptStep, readPrompt, readReference } from './helpers/prompt-doc.js';
|
|
|
|
const prompt = readPrompt('sdlc-analyze');
|
|
|
|
/** 四類檢查,順序即提問順序 */
|
|
const CHECKS = [
|
|
{ kind: '架構', file: 'feasibility-architecture' },
|
|
{ kind: '邏輯', file: 'feasibility-logic' },
|
|
{ kind: '資料', file: 'feasibility-data' },
|
|
{ kind: '時程', file: 'feasibility-schedule' },
|
|
];
|
|
|
|
// ── 規則正本 ───────────────────────────────────────────────────────
|
|
|
|
test('四份可行性檢查清單各自存在且有檢查項', () => {
|
|
for (const { kind, file } of CHECKS) {
|
|
const reference = readReference(file);
|
|
const items = [...reference.matchAll(/^\d+\.\s+\*\*(.+?)\*\*/gm)];
|
|
assert.ok(items.length >= 4, `${kind}清單至少要有四條檢查項,目前 ${items.length} 條`);
|
|
}
|
|
});
|
|
|
|
test('每份清單都交代了「問題怎麼問」,不只列檢查項', () => {
|
|
for (const { kind, file } of CHECKS) {
|
|
assert.match(readReference(file), /## 問題怎麼問/, `${kind}清單缺少提問指引`);
|
|
}
|
|
});
|
|
|
|
test('各清單涵蓋議題點名的重點', () => {
|
|
assert.match(readReference('feasibility-architecture'), /循環相依/);
|
|
assert.match(readReference('feasibility-logic'), /既有功能/);
|
|
assert.match(readReference('feasibility-data'), /schema/);
|
|
assert.match(readReference('feasibility-data'), /遷移/);
|
|
assert.match(readReference('feasibility-data'), /交易邊界/);
|
|
assert.match(readReference('feasibility-schedule'), /最長路徑/);
|
|
assert.match(readReference('feasibility-schedule'), /未知數最大/);
|
|
});
|
|
|
|
// ── 流程正本 ───────────────────────────────────────────────────────
|
|
|
|
test('正本平台中立,description 前綴正確', () => {
|
|
assertNeutralPrompt(prompt, 'sdlc-analyze');
|
|
});
|
|
|
|
test('正本逐一指名四份規則正本,且順序為架構→邏輯→資料→時程', () => {
|
|
const positions = CHECKS.map(({ file }) => prompt.indexOf(`references/${file}.md`));
|
|
assert.equal(positions.every((p) => p >= 0), true, '四份清單都要被正本指名讀取');
|
|
assert.deepEqual([...positions].sort((a, b) => a - b), positions, '指名順序需為架構→邏輯→資料→時程');
|
|
});
|
|
|
|
test('正本明令一次只問一題', () => {
|
|
assert.match(prompt, /一次問一題/);
|
|
assert.match(prompt, /不要一次丟出/);
|
|
});
|
|
|
|
test('正本規定每題固定兩個選項:建議(含理由)與手動輸入', () => {
|
|
assert.match(prompt, /\*\*建議\*\*/);
|
|
assert.match(prompt, /理由/);
|
|
assert.match(prompt, /\*\*手動輸入\*\*/);
|
|
assert.match(prompt, /不被選項限制/);
|
|
});
|
|
|
|
test('正本要求前一類問完才進下一類', () => {
|
|
assert.match(prompt, /前一類的問題全部清空才進入下一類/);
|
|
});
|
|
|
|
test('正本規定最後輸出共識摘要,且摘要只印不寫', () => {
|
|
assert.match(prompt, /共識摘要/);
|
|
assert.match(prompt, /只印在終端/);
|
|
assert.match(prompt, /不寫回議題/);
|
|
});
|
|
|
|
test('正本把「共識摘要之前不寫入」寫成明確邊界', () => {
|
|
const boundary = prompt.slice(prompt.indexOf('## 邊界'));
|
|
assert.match(boundary, /共識摘要之前不對 Gitea 寫入任何內容/);
|
|
assert.match(boundary, /不建議題/);
|
|
assert.match(boundary, /不留留言/);
|
|
});
|
|
|
|
test('第一段在共識摘要之前不寫入任何內容,碼錶是唯一的例外', () => {
|
|
const analysis = prompt.slice(prompt.indexOf('## 第一段'), prompt.indexOf('## 第二段'));
|
|
for (const writer of ['issue-create', 'issue-update', 'issue-link', 'project-add']) {
|
|
assert.equal(analysis.includes(writer), false, `第一段不該出現寫入型腳本 ${writer}`);
|
|
}
|
|
assert.match(analysis, /timer\.js/, '錶要起在第一段開頭,分析最耗時的正是共識之前那一段');
|
|
});
|
|
|
|
// ── 計時 ───────────────────────────────────────────────────────────
|
|
|
|
test('起錶排在第一段開頭,停錶排在最後的回報,兩者成對出現', () => {
|
|
const 起 = prompt.indexOf(promptStep(prompt, '起錶'));
|
|
assert.ok(起 > prompt.indexOf(promptStep(prompt, '讀議題')), '讀完議題確認它存在之後才起');
|
|
assert.ok(起 < prompt.indexOf('## 第二段'), '起錶要在第一段之內:分析最耗時的是共識之前那一段');
|
|
assert.match(promptStep(prompt, '停錶並回報'), /--stop/, '停錶與最後的回報寫在同一步');
|
|
});
|
|
|
|
test('起錶與停錶指的都是同一顆需求議題', () => {
|
|
const 計時段 = [...prompt.matchAll(/node scripts\/timer\.js[^\n]*/g)].map((m) => m[0]);
|
|
assert.ok(計時段.length >= 2, '起錶與停錶都要寫在正本裡');
|
|
for (const line of 計時段) {
|
|
assert.match(line, /--index <需求議題編號>/, `錶要起停在需求議題上:${line}`);
|
|
}
|
|
});
|
|
|
|
test('正本寫出這段計時涵蓋到哪,讀的人不必自己推', () => {
|
|
assert.match(prompt, /## 計時範圍/);
|
|
assert.match(prompt, /錶不跨階段跑/);
|
|
});
|
|
|
|
test('正本交代錶已經跑在同一顆上時不重起,不把累積時間切成兩段', () => {
|
|
assert.match(prompt, /切成兩段/);
|
|
});
|
|
|
|
test('正本明令不代停別顆議題上的錶', () => {
|
|
assert.match(prompt, /請他自己去停/);
|
|
assert.match(prompt, /不停別顆議題上的錶/);
|
|
});
|
|
|
|
test('邊界把碼錶從「不寫入」裡明文除外,並寫出理由', () => {
|
|
const boundary = prompt.slice(prompt.indexOf('## 邊界'));
|
|
assert.match(boundary, /碼錶除外/);
|
|
assert.match(boundary, /工時/, '要說清楚碼錶記的是工時不是內容,否則下一個人會把它刪掉');
|
|
});
|
|
|
|
test('正本要求先看未處理留言數,不是 0 就提示先整併', () => {
|
|
assert.match(prompt, /未處理留言數/);
|
|
assert.match(prompt, /sdlc-sync/);
|
|
assert.match(prompt, /先停下來|先整併/);
|
|
});
|
|
|
|
test('正本指名由 issue-extract 讀議題,而不是自己讀全文', () => {
|
|
assert.match(prompt, /issue-extract/);
|
|
assert.match(prompt, /不必再讀整份議題全文/);
|
|
});
|
|
|
|
test('正本要求能自己查證的就不要拿去問使用者', () => {
|
|
assert.match(prompt, /能在程式碼裡查證的就自己去查/);
|
|
});
|
|
|
|
test('時程清單交代了「這階段還沒有工作包」該怎麼估', () => {
|
|
// 相依鏈最長路徑預設了一份拆法,而分析階段還沒有工作包可依
|
|
assert.match(readReference('feasibility-schedule'), /暫定拆法/);
|
|
assert.match(readReference('feasibility-schedule'), /還沒有工作包/);
|
|
});
|