test(sdlc-analyze): 釘住四份清單與正本的結構
這一顆沒有腳本,交付的就是文件本身,所以驗的是文件的結構:四份清單各有足夠 的檢查項與提問指引、正本逐一指名它們且順序為架構→邏輯→資料→時程、一次一題、 兩個固定選項、共識摘要只印不寫,以及「不對 Gitea 寫入」有被寫成明確邊界。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,99 @@
|
|||||||
|
/**
|
||||||
|
* sdlc-analyze 的交付物:四份可行性檢查清單與流程正本。
|
||||||
|
* 這一段不寫入 Gitea,所以沒有腳本——交付的就是這些文件本身。
|
||||||
|
*/
|
||||||
|
import test from 'node:test';
|
||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { assertNeutralPrompt, 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('正本把「不對 Gitea 寫入」寫成明確邊界', () => {
|
||||||
|
const boundary = prompt.slice(prompt.indexOf('## 邊界'));
|
||||||
|
assert.match(boundary, /不對 Gitea 產生任何寫入/);
|
||||||
|
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, /能在程式碼裡查證的就自己去查/);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user