@infodb/p3 0.10.0 → 0.12.0
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.
- package/README.md +6 -1
- package/dist/web/assets/ImprovementDialog-kQaVBGWH.js +1 -0
- package/dist/web/assets/Outputs-_nU_p3nu.js +1 -0
- package/dist/web/assets/{RequestStatus-DGaoQoIa.js → RequestStatus-RG-OVQYY.js} +1 -1
- package/dist/web/assets/{Tabs-D16MqQxu.js → Tabs-ew9i5SKX.js} +1 -1
- package/dist/web/assets/TagInput-BtlJTF7i.js +1 -0
- package/dist/web/assets/TaskDrawer-DW8GyJqI.js +6 -0
- package/dist/web/assets/_requestId-6Nb727dD.js +1 -0
- package/dist/web/assets/_requestId-BykTgPax.js +1 -0
- package/dist/web/assets/appCtx-CxDdXABS.js +1 -0
- package/dist/web/assets/archive-Ckh295Xe.js +1 -0
- package/dist/web/assets/board-BVAIjK-Y.js +1 -0
- package/dist/web/assets/done-BGfA-3MA.js +1 -0
- package/dist/web/assets/index-CgRU744I.css +2 -0
- package/dist/web/assets/index-DacQ0yl4.js +12 -0
- package/dist/web/assets/{new-ChFzBoL2.js → new-DVygWvVc.js} +1 -1
- package/dist/web/assets/outputs-B6xDsLZf.js +1 -0
- package/dist/web/assets/preload-helper-DyCqp21K.js +1 -0
- package/dist/web/assets/quality-Pu6EISAM.js +1 -0
- package/dist/web/assets/release-notes-CCpzyiNf.js +5 -0
- package/dist/web/assets/requestData-D5vBnuMh.js +1 -0
- package/dist/web/assets/routes-Q91zvNc0.js +4 -0
- package/dist/web/assets/settings-BzRgcmUm.js +1 -0
- package/dist/web/assets/taskReview-_WCgnQit.js +1 -0
- package/dist/web/assets/workTarget-C9c57JAO.js +30 -0
- package/dist/web/index.html +4 -4
- package/docs/architecture.md +392 -3
- package/docs/development.md +1 -1
- package/docs/how-to-use.md +261 -5
- package/docs/installation.md +5 -5
- package/lib/cli/args.js +45 -0
- package/lib/cli/help.js +43 -1
- package/lib/cli/main.js +42 -4
- package/lib/cli/output.js +9 -1
- package/lib/cli/preflightCommands.js +7 -1
- package/lib/cli/project.js +3 -0
- package/lib/cli/qualityCommands.js +163 -0
- package/lib/cli/readOnly.js +2 -0
- package/lib/cli/requestCommands.js +219 -14
- package/lib/cli/showView.js +69 -3
- package/lib/cli/taskCommands.js +312 -17
- package/lib/cli/taskReviewCommands.js +178 -0
- package/lib/core/context.js +7 -1
- package/lib/core/milestoneReview/code.js +129 -0
- package/lib/core/milestoneReview/material.js +148 -0
- package/lib/core/milestoneReview/mockReviewer.js +28 -0
- package/lib/core/milestoneReview/review.js +325 -0
- package/lib/core/milestoneReview/service.js +214 -0
- package/lib/core/milestoneReview/store.js +176 -0
- package/lib/core/ops.js +9 -2
- package/lib/core/preflight/carryover.js +1 -1
- package/lib/core/preflight/codexEngine.js +20 -6
- package/lib/core/preflight/engine.js +6 -0
- package/lib/core/preflight/instructions.js +18 -1
- package/lib/core/preflight/mockEngine.js +4 -0
- package/lib/core/preflight/service.js +45 -4
- package/lib/core/projectRegistry.js +3 -3
- package/lib/core/quality.js +21 -0
- package/lib/core/qualityImprovement.js +221 -0
- package/lib/core/requestOps.js +101 -6
- package/lib/core/reviewRuns.js +205 -0
- package/lib/core/store/archivedTasks.js +74 -0
- package/lib/core/store/collection.js +12 -2
- package/lib/core/store/normalize.js +43 -2
- package/lib/core/store/preflightStore.js +9 -1
- package/lib/core/store/projectFile.js +18 -1
- package/lib/core/store/workspace.js +122 -14
- package/lib/core/taskReview/material.js +452 -0
- package/lib/core/taskReview/mockReviewer.js +30 -0
- package/lib/core/taskReview/paths.js +15 -0
- package/lib/core/taskReview/review.js +305 -0
- package/lib/core/taskReview/service.js +187 -0
- package/lib/core/taskReview/store.js +214 -0
- package/lib/server/api/manifest.js +74 -5
- package/lib/server/api/milestoneReviewRoutes.js +70 -0
- package/lib/server/api/routes.js +164 -20
- package/lib/server/api/taskReviewRoutes.js +66 -0
- package/lib/server/server.js +2 -2
- package/lib/shared/acceptance.js +378 -0
- package/lib/shared/milestoneGoals.js +57 -0
- package/lib/shared/milestoneReview.js +27 -0
- package/lib/shared/quality.js +391 -0
- package/lib/shared/qualityImprovement.js +1 -0
- package/lib/shared/qualityTemplates.js +31 -0
- package/lib/shared/taskBlock.js +142 -0
- package/lib/shared/taskReview.js +56 -0
- package/package.json +1 -1
- package/skills/p3/SKILL.md +31 -2
- package/dist/web/assets/Outputs-B4Tr7JzU.js +0 -1
- package/dist/web/assets/TagInput-pSYxm4bz.js +0 -1
- package/dist/web/assets/TaskDrawer-1Ev3RpRV.js +0 -3
- package/dist/web/assets/_requestId-BKhn019m.js +0 -1
- package/dist/web/assets/_requestId-Btpvuu7-.js +0 -30
- package/dist/web/assets/appCtx-D_Iaoh2e.js +0 -1
- package/dist/web/assets/board-DeHdxbN4.js +0 -1
- package/dist/web/assets/done-BFaHGt03.js +0 -1
- package/dist/web/assets/index-BF1xMdJo.css +0 -2
- package/dist/web/assets/index-CDWcKy1L.js +0 -12
- package/dist/web/assets/preload-helper-hSId95YD.js +0 -1
- package/dist/web/assets/release-notes-BWNDFDkH.js +0 -3
- package/dist/web/assets/requestData-B_320uxL.js +0 -1
- package/dist/web/assets/routes-BBD464IS.js +0 -3
- package/dist/web/assets/settings-D7PPrGjT.js +0 -1
- package/dist/web/assets/workTarget-Cijqq4yH.js +0 -1
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* プロジェクトの品質基準(project.yaml の quality)。プロジェクトとして守る最低限の水準(規約・構成・検証・文書など)を、
|
|
3
|
+
* 安定した ID の項目として持つ。CLI・API・画面で同じ規則を使う(保存は core/quality.ts)。
|
|
4
|
+
*
|
|
5
|
+
* - 状態: unset(quality が無い。初めて作るときの状態に任せている)/ set(設定済み。意図して空でもよい)/ invalid(読めない値がある)
|
|
6
|
+
* - 項目: { id: Q1.., text, repos?(無い・空は全部の参照先), check(machine: コマンドと成功の条件 / manual: 人が確かめる方法・参照の資料),
|
|
7
|
+
* exempt?(適用の除外。理由が要る), source?(採用したテンプレートの項目) }
|
|
8
|
+
* - ID は追加のときに振り、消した ID を別の内容に使い直さない(seq に振った最後の番号を残す)
|
|
9
|
+
* - P3 はコマンドを実行しない・依存を入れない。確認の方法は CI・手元の作業・外の自動化のどれでもよい(特定の製品・フォルダを必須にしない)
|
|
10
|
+
* - テンプレートは同梱の版つきの例で、業界の標準への認証ではない。採用すると編集できる実体に写す。テンプレートが改版しても採用済みの
|
|
11
|
+
* 内容は変わらない(差分を見て明示して当てる)
|
|
12
|
+
*/
|
|
13
|
+
export const QUALITY_LIMITS = {
|
|
14
|
+
standards: 100,
|
|
15
|
+
text: 1000,
|
|
16
|
+
command: 500,
|
|
17
|
+
success: 500,
|
|
18
|
+
reference: 1000,
|
|
19
|
+
reason: 500,
|
|
20
|
+
};
|
|
21
|
+
export function qualitySnapshot(state, version) {
|
|
22
|
+
const st = state ?? { state: "unset" };
|
|
23
|
+
if (st.state === "set")
|
|
24
|
+
return { state: "set", version: version ?? "", standards: structuredClone(st.config.standards) };
|
|
25
|
+
if (st.state === "invalid")
|
|
26
|
+
return { state: "invalid", version: version ?? "", problems: [...st.problems] };
|
|
27
|
+
return { state: "unset", version: version ?? "" };
|
|
28
|
+
}
|
|
29
|
+
export class QualityInputError extends Error {
|
|
30
|
+
code;
|
|
31
|
+
constructor(code, message) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.code = code;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export const QUALITY_ID_RE = /^Q\d+$/;
|
|
37
|
+
// --- 読む ---------------------------------------------------------------------
|
|
38
|
+
const str = (v) => (typeof v === "string" ? v.trim() : undefined);
|
|
39
|
+
function readCheck(v) {
|
|
40
|
+
if (!v || typeof v !== "object")
|
|
41
|
+
return "check がありません(kind: machine / manual)";
|
|
42
|
+
const o = v;
|
|
43
|
+
if (o.kind === "machine") {
|
|
44
|
+
const command = str(o.command);
|
|
45
|
+
const success = str(o.success);
|
|
46
|
+
if (!command || !success)
|
|
47
|
+
return "machine の check には command と success が要ります";
|
|
48
|
+
return { kind: "machine", command, success };
|
|
49
|
+
}
|
|
50
|
+
if (o.kind === "manual") {
|
|
51
|
+
const reference = str(o.reference);
|
|
52
|
+
if (!reference)
|
|
53
|
+
return "manual の check には reference(確かめ方・参照の資料)が要ります";
|
|
54
|
+
return { kind: "manual", reference };
|
|
55
|
+
}
|
|
56
|
+
return "check の kind は machine か manual です";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* project.yaml の quality を読む。無ければ unset、読めない値があれば invalid(理由つき。ファイルは書き換えない)。
|
|
60
|
+
* repoNames: 今の参照先(知らない参照先は警告にする。読める)
|
|
61
|
+
*/
|
|
62
|
+
export function readQuality(raw, repoNames = []) {
|
|
63
|
+
if (raw === undefined)
|
|
64
|
+
return { state: "unset" };
|
|
65
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
66
|
+
return { state: "invalid", problems: ["quality は standards を持つ対応(マップ)にしてください"] };
|
|
67
|
+
const o = raw;
|
|
68
|
+
const problems = [];
|
|
69
|
+
const warnings = [];
|
|
70
|
+
const list = o.standards ?? [];
|
|
71
|
+
if (!Array.isArray(list))
|
|
72
|
+
return { state: "invalid", problems: ["quality.standards が並びになっていません"] };
|
|
73
|
+
const standards = [];
|
|
74
|
+
for (const [i, x] of list.entries()) {
|
|
75
|
+
const s = x && typeof x === "object" ? x : {};
|
|
76
|
+
const id = str(s.id) ?? "";
|
|
77
|
+
const at = `品質基準 ${i + 1} 件目${id ? `(${id})` : ""}`;
|
|
78
|
+
if (!QUALITY_ID_RE.test(id)) {
|
|
79
|
+
problems.push(`${at} の id が読めません(Q1, Q2, ...)`);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (standards.some((x) => x.id === id)) {
|
|
83
|
+
problems.push(`品質基準の id が重複しています: ${id}`);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const text = str(s.text);
|
|
87
|
+
if (!text) {
|
|
88
|
+
problems.push(`${at} の text が空です`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const check = readCheck(s.check);
|
|
92
|
+
if (typeof check === "string") {
|
|
93
|
+
problems.push(`${at}: ${check}`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const repos = Array.isArray(s.repos) ? s.repos.map((r) => String(r).trim()).filter(Boolean) : undefined;
|
|
97
|
+
for (const r of repos ?? [])
|
|
98
|
+
if (repoNames.length && !repoNames.includes(r))
|
|
99
|
+
warnings.push(`${id} の対象の参照先 ${r} は登録されていません`);
|
|
100
|
+
let exempt;
|
|
101
|
+
if (s.exempt !== undefined && s.exempt !== null) {
|
|
102
|
+
const reason = s.exempt && typeof s.exempt === "object" ? str(s.exempt.reason) : undefined;
|
|
103
|
+
if (!reason) {
|
|
104
|
+
problems.push(`${at} の適用の除外に理由がありません(exempt.reason)`);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
exempt = { reason };
|
|
108
|
+
}
|
|
109
|
+
const src = s.source && typeof s.source === "object" ? s.source : undefined;
|
|
110
|
+
const source = src && str(src.template) && str(src.key) && Number.isInteger(src.version) ? { template: str(src.template), version: src.version, key: str(src.key) } : undefined;
|
|
111
|
+
standards.push({ id, text, ...(repos?.length ? { repos } : {}), check, ...(exempt ? { exempt } : {}), ...(source ? { source } : {}) });
|
|
112
|
+
}
|
|
113
|
+
if (standards.length > QUALITY_LIMITS.standards)
|
|
114
|
+
problems.push(`品質基準は ${QUALITY_LIMITS.standards} 件までです`);
|
|
115
|
+
const templates = Array.isArray(o.templates)
|
|
116
|
+
? o.templates.flatMap((t) => {
|
|
117
|
+
const x = t && typeof t === "object" ? t : {};
|
|
118
|
+
return str(x.id) && Number.isInteger(x.version) ? [{ id: str(x.id), version: x.version }] : [];
|
|
119
|
+
})
|
|
120
|
+
: undefined;
|
|
121
|
+
const seq = Number.isInteger(o.seq) && o.seq >= 0 ? o.seq : undefined;
|
|
122
|
+
if (problems.length)
|
|
123
|
+
return { state: "invalid", problems };
|
|
124
|
+
return { state: "set", config: { ...(templates?.length ? { templates } : {}), standards, ...(seq !== undefined ? { seq } : {}) }, ...(warnings.length ? { warnings } : {}) };
|
|
125
|
+
}
|
|
126
|
+
/** 書く形(読み直すと同じになる) */
|
|
127
|
+
export function qualityPlain(c) {
|
|
128
|
+
return {
|
|
129
|
+
...(c.templates?.length ? { templates: c.templates.map((t) => ({ id: t.id, version: t.version })) } : {}),
|
|
130
|
+
standards: c.standards.map((s) => ({
|
|
131
|
+
id: s.id,
|
|
132
|
+
text: s.text,
|
|
133
|
+
...(s.repos?.length ? { repos: [...s.repos] } : {}),
|
|
134
|
+
check: s.check.kind === "machine" ? { kind: "machine", command: s.check.command, success: s.check.success } : { kind: "manual", reference: s.check.reference },
|
|
135
|
+
...(s.exempt ? { exempt: { reason: s.exempt.reason } } : {}),
|
|
136
|
+
...(s.source ? { source: { ...s.source } } : {}),
|
|
137
|
+
})),
|
|
138
|
+
...(c.seq ? { seq: c.seq } : {}),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/** 品質の設定の版(中身の hash。無い・読めないは別の値)。保存の前に比べる */
|
|
142
|
+
export function qualityVersion(state, raw) {
|
|
143
|
+
const key = state.state === "set" ? JSON.stringify(qualityPlain(state.config)) : state.state === "unset" ? "unset" : `invalid:${JSON.stringify(raw ?? null)}`;
|
|
144
|
+
return fnv(key);
|
|
145
|
+
}
|
|
146
|
+
/** 依存を足さない短い hash(版の比較だけに使う) */
|
|
147
|
+
function fnv(s) {
|
|
148
|
+
let h1 = 0x811c9dc5;
|
|
149
|
+
let h2 = 0x01000193;
|
|
150
|
+
for (let i = 0; i < s.length; i++) {
|
|
151
|
+
const c = s.charCodeAt(i);
|
|
152
|
+
h1 = Math.imul(h1 ^ c, 0x01000193) >>> 0;
|
|
153
|
+
h2 = Math.imul(h2 ^ c, 0x85ebca6b) >>> 0;
|
|
154
|
+
}
|
|
155
|
+
return `${h1.toString(16).padStart(8, "0")}${h2.toString(16).padStart(8, "0")}`;
|
|
156
|
+
}
|
|
157
|
+
function clean(raw, label, max) {
|
|
158
|
+
const t = (raw ?? "").trim();
|
|
159
|
+
if (!t)
|
|
160
|
+
throw new QualityInputError("quality_invalid", `${label}を書いてください`);
|
|
161
|
+
if (t.length > max)
|
|
162
|
+
throw new QualityInputError("quality_invalid", `${label}は ${max} 文字までです(${t.length} 文字)`);
|
|
163
|
+
return t;
|
|
164
|
+
}
|
|
165
|
+
function cleanCheck(c) {
|
|
166
|
+
if (!c)
|
|
167
|
+
throw new QualityInputError("quality_invalid", "確認の方法(機械の検査か人の確認)を選んでください");
|
|
168
|
+
if (c.kind === "machine")
|
|
169
|
+
return { kind: "machine", command: clean(c.command, "検査のコマンド", QUALITY_LIMITS.command), success: clean(c.success, "成功の条件", QUALITY_LIMITS.success) };
|
|
170
|
+
if (c.kind === "manual")
|
|
171
|
+
return { kind: "manual", reference: clean(c.reference, "確かめ方・参照の資料", QUALITY_LIMITS.reference) };
|
|
172
|
+
throw new QualityInputError("quality_invalid", "確認の方法は machine か manual です");
|
|
173
|
+
}
|
|
174
|
+
function cleanRepos(repos, repoNames) {
|
|
175
|
+
const list = [...new Set((repos ?? []).map((r) => r.trim()).filter(Boolean))];
|
|
176
|
+
for (const r of list)
|
|
177
|
+
if (!repoNames.includes(r))
|
|
178
|
+
throw new QualityInputError("quality_invalid", `参照先 ${r} は登録されていません(${repoNames.join(", ") || "参照先なし"})`);
|
|
179
|
+
return list.length ? list : undefined;
|
|
180
|
+
}
|
|
181
|
+
function checkSource(src, templates) {
|
|
182
|
+
const t = templates.find((x) => x.id === src.template && x.version === src.version);
|
|
183
|
+
if (!t?.items.some((i) => i.key === src.key))
|
|
184
|
+
throw new QualityInputError("quality_invalid", `テンプレートの項目 ${src.template}@${src.version}:${src.key} はありません`);
|
|
185
|
+
return { template: src.template, version: src.version, key: src.key };
|
|
186
|
+
}
|
|
187
|
+
const lastSeq = (c) => c.standards.reduce((n, s) => Math.max(n, Number(s.id.slice(1))), c.seq ?? 0);
|
|
188
|
+
/** 操作を順に当てた後の設定(何も書かない。合わなければ QualityInputError で1件も当てない) */
|
|
189
|
+
export function applyQualityOps(state, ops, ctx) {
|
|
190
|
+
if (state.state === "invalid")
|
|
191
|
+
throw new QualityInputError("quality_unreadable", `project.yaml の quality が読めないため変えられません。ファイルを直してください: ${state.problems.join(" / ")}`);
|
|
192
|
+
let c = state.state === "set" ? structuredClone(state.config) : { standards: [] };
|
|
193
|
+
let seq = lastSeq(c);
|
|
194
|
+
const find = (id) => {
|
|
195
|
+
const s = c.standards.find((x) => x.id === id);
|
|
196
|
+
if (!s)
|
|
197
|
+
throw new QualityInputError("quality_invalid", `品質基準 ${id} はありません`);
|
|
198
|
+
return s;
|
|
199
|
+
};
|
|
200
|
+
for (const op of ops) {
|
|
201
|
+
switch (op.op) {
|
|
202
|
+
case "init":
|
|
203
|
+
break;
|
|
204
|
+
case "adopt": {
|
|
205
|
+
const t = ctx.templates.find((x) => x.id === op.template && (op.version === undefined || x.version === op.version));
|
|
206
|
+
if (!t)
|
|
207
|
+
throw new QualityInputError("quality_invalid", `テンプレート ${op.template}${op.version ? `@${op.version}` : ""} はありません(${ctx.templates.map((x) => `${x.id}@${x.version}`).join(", ")})`);
|
|
208
|
+
if (c.templates?.some((x) => x.id === t.id))
|
|
209
|
+
throw new QualityInputError("quality_invalid", `テンプレート ${t.id} は採用済みです(更新は差分を見て当ててください)`);
|
|
210
|
+
for (const item of t.items) {
|
|
211
|
+
seq += 1;
|
|
212
|
+
c.standards.push({ id: `Q${seq}`, text: item.text, check: structuredClone(item.check), source: { template: t.id, version: t.version, key: item.key } });
|
|
213
|
+
}
|
|
214
|
+
c.templates = [...(c.templates ?? []), { id: t.id, version: t.version }];
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
case "upgrade": {
|
|
218
|
+
const d = templateDiffs(c, ctx.templates).find((x) => x.template === op.template);
|
|
219
|
+
if (!d)
|
|
220
|
+
throw new QualityInputError("quality_invalid", `テンプレート ${op.template} に当てる差分はありません`);
|
|
221
|
+
const latest = ctx.templates.find((t) => t.id === d.template && t.version === d.to);
|
|
222
|
+
const at = (key) => latest.items.find((i) => i.key === key);
|
|
223
|
+
c = {
|
|
224
|
+
...c,
|
|
225
|
+
standards: c.standards.map((x) => {
|
|
226
|
+
if (x.source?.template !== d.template)
|
|
227
|
+
return x;
|
|
228
|
+
if (d.changed.some((ch) => ch.key === x.source.key))
|
|
229
|
+
return { ...x, text: at(x.source.key).text, check: structuredClone(at(x.source.key).check), source: { ...x.source, version: d.to } };
|
|
230
|
+
if (d.removed.some((r) => r.key === x.source.key))
|
|
231
|
+
return (({ source: _s, ...rest }) => rest)(x);
|
|
232
|
+
return { ...x, source: { ...x.source, version: d.to } };
|
|
233
|
+
}),
|
|
234
|
+
};
|
|
235
|
+
for (const a of d.added) {
|
|
236
|
+
seq += 1;
|
|
237
|
+
c.standards.push({ id: `Q${seq}`, text: a.text, check: structuredClone(at(a.key).check), source: { template: d.template, version: d.to, key: a.key } });
|
|
238
|
+
}
|
|
239
|
+
c.templates = (c.templates ?? []).map((t) => (t.id === d.template ? { id: t.id, version: d.to } : t));
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
case "replace": {
|
|
243
|
+
const seen = new Set();
|
|
244
|
+
const next = op.standards.map((row) => {
|
|
245
|
+
const cur = row.id ? find(row.id) : undefined;
|
|
246
|
+
if (row.id && seen.has(row.id))
|
|
247
|
+
throw new QualityInputError("quality_invalid", `品質基準 ${row.id} が2回あります`);
|
|
248
|
+
if (row.id)
|
|
249
|
+
seen.add(row.id);
|
|
250
|
+
const repos = cleanRepos(row.repos, ctx.repoNames);
|
|
251
|
+
const reason = row.exemptReason?.trim();
|
|
252
|
+
if (reason !== undefined && reason.length > QUALITY_LIMITS.reason)
|
|
253
|
+
throw new QualityInputError("quality_invalid", `適用の除外の理由は ${QUALITY_LIMITS.reason} 文字までです`);
|
|
254
|
+
const id = cur?.id ?? `Q${++seq}`;
|
|
255
|
+
return {
|
|
256
|
+
id,
|
|
257
|
+
text: clean(row.text, `品質基準 ${id} の文`, QUALITY_LIMITS.text),
|
|
258
|
+
...(repos ? { repos } : {}),
|
|
259
|
+
check: cleanCheck(row.check),
|
|
260
|
+
...(reason ? { exempt: { reason } } : {}),
|
|
261
|
+
...(cur?.source ? { source: cur.source } : row.source ? { source: checkSource(row.source, ctx.templates) } : {}),
|
|
262
|
+
};
|
|
263
|
+
});
|
|
264
|
+
const adopted = [...(c.templates ?? [])];
|
|
265
|
+
for (const t of op.templates ?? []) {
|
|
266
|
+
if (!ctx.templates.some((x) => x.id === t.id && x.version === t.version))
|
|
267
|
+
throw new QualityInputError("quality_invalid", `テンプレート ${t.id}@${t.version} はありません`);
|
|
268
|
+
if (!adopted.some((x) => x.id === t.id))
|
|
269
|
+
adopted.push({ id: t.id, version: t.version });
|
|
270
|
+
}
|
|
271
|
+
c = { ...c, standards: next, ...(adopted.length ? { templates: adopted } : {}) };
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
case "add": {
|
|
275
|
+
seq += 1;
|
|
276
|
+
c.standards.push({ id: `Q${seq}`, text: clean(op.standard.text, "品質基準の文", QUALITY_LIMITS.text), ...(cleanRepos(op.standard.repos, ctx.repoNames) ? { repos: cleanRepos(op.standard.repos, ctx.repoNames) } : {}), check: cleanCheck(op.standard.check) });
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
case "edit": {
|
|
280
|
+
const s = find(op.id);
|
|
281
|
+
const next = {
|
|
282
|
+
...s,
|
|
283
|
+
...(op.standard.text !== undefined ? { text: clean(op.standard.text, "品質基準の文", QUALITY_LIMITS.text) } : {}),
|
|
284
|
+
...(op.standard.check !== undefined ? { check: cleanCheck(op.standard.check) } : {}),
|
|
285
|
+
};
|
|
286
|
+
if (op.standard.repos !== undefined) {
|
|
287
|
+
const r = cleanRepos(op.standard.repos, ctx.repoNames);
|
|
288
|
+
if (r)
|
|
289
|
+
next.repos = r;
|
|
290
|
+
else
|
|
291
|
+
delete next.repos;
|
|
292
|
+
}
|
|
293
|
+
c = { ...c, standards: c.standards.map((x) => (x.id === s.id ? next : x)) };
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
case "remove":
|
|
297
|
+
find(op.id);
|
|
298
|
+
c = { ...c, standards: c.standards.filter((x) => x.id !== op.id) };
|
|
299
|
+
break;
|
|
300
|
+
case "exempt": {
|
|
301
|
+
const s = find(op.id);
|
|
302
|
+
const reason = clean(op.reason, "適用の除外の理由", QUALITY_LIMITS.reason);
|
|
303
|
+
c = { ...c, standards: c.standards.map((x) => (x.id === s.id ? { ...x, exempt: { reason } } : x)) };
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
case "unexempt": {
|
|
307
|
+
const s = find(op.id);
|
|
308
|
+
c = { ...c, standards: c.standards.map((x) => (x.id === s.id ? (({ exempt: _e, ...rest }) => rest)(x) : x)) };
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
default:
|
|
312
|
+
throw new QualityInputError("quality_invalid", `知らない操作です: ${String(op.op)}`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (c.standards.length > QUALITY_LIMITS.standards)
|
|
316
|
+
throw new QualityInputError("quality_invalid", `品質基準は ${QUALITY_LIMITS.standards} 件までです`);
|
|
317
|
+
return { ...c, ...(seq > 0 ? { seq } : {}) };
|
|
318
|
+
}
|
|
319
|
+
/** 参照先に当てはまる品質基準(除外したものは別に返す)。repo が null(作業先なし)なら全体の基準だけ */
|
|
320
|
+
export function standardsFor(config, repo) {
|
|
321
|
+
const hit = config.standards.filter((s) => !s.repos?.length || (repo ? s.repos.includes(repo) : false));
|
|
322
|
+
return { applies: hit.filter((s) => !s.exempt), exempt: hit.filter((s) => s.exempt) };
|
|
323
|
+
}
|
|
324
|
+
/** 確認の方法の一行 */
|
|
325
|
+
export const checkLine = (c) => (c.kind === "machine" ? `検査: ${c.command}(成功: ${c.success})` : `人の確認: ${c.reference}`);
|
|
326
|
+
export function templateDiffs(config, templates) {
|
|
327
|
+
const out = [];
|
|
328
|
+
for (const used of config.templates ?? []) {
|
|
329
|
+
const latest = templates.filter((t) => t.id === used.id).sort((a, b) => b.version - a.version)[0];
|
|
330
|
+
if (!latest || latest.version <= used.version)
|
|
331
|
+
continue;
|
|
332
|
+
const old = templates.find((t) => t.id === used.id && t.version === used.version);
|
|
333
|
+
const mine = config.standards.filter((s) => s.source?.template === used.id);
|
|
334
|
+
const idsOf = (key) => mine.filter((s) => s.source?.key === key).map((s) => s.id);
|
|
335
|
+
const added = latest.items.filter((i) => !old?.items.some((o) => o.key === i.key)).map((i) => ({ key: i.key, text: i.text }));
|
|
336
|
+
const changed = latest.items
|
|
337
|
+
.filter((i) => {
|
|
338
|
+
const o = old?.items.find((x) => x.key === i.key);
|
|
339
|
+
return o && JSON.stringify([o.text, o.check]) !== JSON.stringify([i.text, i.check]);
|
|
340
|
+
})
|
|
341
|
+
.map((i) => ({ key: i.key, ids: idsOf(i.key), text: i.text }));
|
|
342
|
+
const removed = (old?.items ?? []).filter((o) => !latest.items.some((i) => i.key === o.key)).map((o) => ({ key: o.key, ids: idsOf(o.key) }));
|
|
343
|
+
out.push({ template: used.id, from: used.version, to: latest.version, added, changed, removed });
|
|
344
|
+
}
|
|
345
|
+
return out;
|
|
346
|
+
}
|
|
347
|
+
// --- タスクの受け入れ基準への取り込み -----------------------------------------------
|
|
348
|
+
/** 項目の中身の hash(文・確認の方法・対象。取り込んだ後に変わったかを見る) */
|
|
349
|
+
export const standardHash = (s) => fnv(JSON.stringify([s.text, s.check, s.repos ?? []]));
|
|
350
|
+
/** 受け入れ基準に取り込むときの文(品質 ID と確認の方法を添える) */
|
|
351
|
+
export const qualityCriterionText = (s) => `[${s.id}] ${s.text}(${checkLine(s.check)})`;
|
|
352
|
+
/** 取り込む受け入れ基準(作業先に当てはまり、除外していない品質基準) */
|
|
353
|
+
export function qualityCriteria(config, version, opts) {
|
|
354
|
+
const list = opts.ids ? config.standards.filter((s) => opts.ids.includes(s.id) && !s.exempt) : standardsFor(config, opts.repo).applies;
|
|
355
|
+
if (opts.ids) {
|
|
356
|
+
const missing = opts.ids.filter((id) => !config.standards.some((s) => s.id === id));
|
|
357
|
+
if (missing.length)
|
|
358
|
+
throw new QualityInputError("quality_invalid", `品質基準 ${missing.join(", ")} はありません`);
|
|
359
|
+
}
|
|
360
|
+
return list.map((s) => ({ text: qualityCriterionText(s), quality: { id: s.id, hash: standardHash(s), version } }));
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* タスクの受け入れ基準と今の品質基準の差分(読むだけ。タスクは書き換えない)。作業先が無いタスクには、取り込み済みのもの以外を足す案を出さない
|
|
364
|
+
*/
|
|
365
|
+
export function taskQualityDiff(criteria, state, repo) {
|
|
366
|
+
if (!state || state.state !== "set")
|
|
367
|
+
return [];
|
|
368
|
+
const config = state.config;
|
|
369
|
+
const out = [];
|
|
370
|
+
const { applies, exempt } = standardsFor(config, repo);
|
|
371
|
+
for (const c of criteria) {
|
|
372
|
+
if (!c.quality)
|
|
373
|
+
continue;
|
|
374
|
+
const s = config.standards.find((x) => x.id === c.quality.id);
|
|
375
|
+
if (!s)
|
|
376
|
+
out.push({ kind: "remove", quality: c.quality.id, criterion: c.id, reason: "品質基準が消えました" });
|
|
377
|
+
else if (exempt.some((x) => x.id === s.id))
|
|
378
|
+
out.push({ kind: "exempt", quality: s.id, criterion: c.id, reason: `除外になりました: ${s.exempt.reason}` });
|
|
379
|
+
else if (!applies.some((x) => x.id === s.id))
|
|
380
|
+
out.push({ kind: "remove", quality: s.id, criterion: c.id, reason: "作業先に当てはまらなくなりました" });
|
|
381
|
+
else if (standardHash(s) !== c.quality.hash)
|
|
382
|
+
out.push({ kind: "change", quality: s.id, criterion: c.id, text: qualityCriterionText(s) });
|
|
383
|
+
else if (c.text !== qualityCriterionText(s))
|
|
384
|
+
out.push({ kind: "edited", quality: s.id, criterion: c.id, text: qualityCriterionText(s), reason: "タスクで文を直しています" });
|
|
385
|
+
}
|
|
386
|
+
if (repo)
|
|
387
|
+
for (const s of applies)
|
|
388
|
+
if (!criteria.some((c) => c.quality?.id === s.id))
|
|
389
|
+
out.push({ kind: "add", quality: s.id, text: qualityCriterionText(s) });
|
|
390
|
+
return out;
|
|
391
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 同梱の品質基準のテンプレート(版つきの例)。業界の標準への認証ではない。採用すると project.yaml に編集できる実体として写す。
|
|
3
|
+
* 中身を変えるときは版を上げて新しい項目として足す(採用済みのプロジェクトの内容は変わらず、差分を見て明示して当てる)。
|
|
4
|
+
* コマンドは例で、P3 は実行しない。CI・特定の製品・フォルダ名を必須にしない
|
|
5
|
+
*/
|
|
6
|
+
export const QUALITY_TEMPLATES = [
|
|
7
|
+
{
|
|
8
|
+
id: "basic",
|
|
9
|
+
version: 1,
|
|
10
|
+
title: "共通の基本",
|
|
11
|
+
description: "どの言語でも使える最低限の水準(規約・構成と依存の向き・検証・文書の更新)",
|
|
12
|
+
items: [
|
|
13
|
+
{ key: "conventions", text: "プロジェクトのコーディング規約(命名・書式・エラーの扱い)に従う", check: { kind: "manual", reference: "規約の文書(例: docs/development.md)と照らして確かめる" } },
|
|
14
|
+
{ key: "structure", text: "決めたフォルダの構成と依存の向きを崩さない(下の層から上の層を参照しない)", check: { kind: "manual", reference: "構成・依存の向きの文書と、変えたファイルの import を確かめる" } },
|
|
15
|
+
{ key: "verification", text: "変更に見合う自動テストを足し、プロジェクトの検証をすべて通してから完了にする", check: { kind: "manual", reference: "検証の手順(例: README・docs の「テスト」)を実行した結果を証拠に残す" } },
|
|
16
|
+
{ key: "docs", text: "使い方・設計が変わったら、同じ変更で文書を直す", check: { kind: "manual", reference: "変えた振る舞いを説明している文書の箇所を確かめる" } },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "typescript",
|
|
21
|
+
version: 1,
|
|
22
|
+
title: "TypeScript の例",
|
|
23
|
+
description: "TypeScript のプロジェクトでよく使う機械の検査(コマンドはプロジェクトに合わせて直す)",
|
|
24
|
+
items: [
|
|
25
|
+
{ key: "typecheck", text: "型検査が通る", check: { kind: "machine", command: "npm run typecheck(例: tsc --noEmit)", success: "終了コード 0・エラーなし" } },
|
|
26
|
+
{ key: "lint", text: "lint が警告なしで通る", check: { kind: "machine", command: "npm run lint", success: "終了コード 0・警告なし" } },
|
|
27
|
+
{ key: "test", text: "自動テストが通る", check: { kind: "machine", command: "npm test", success: "終了コード 0・失敗なし" } },
|
|
28
|
+
{ key: "build", text: "ビルドが通る", check: { kind: "machine", command: "npm run build", success: "終了コード 0" } },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 作業中のタスクの「止まっている理由」(停止)の規則。状態ではなく作業中のタスクの属性で、状態は 未着手 / 作業中 / 完了 のまま。
|
|
3
|
+
* CLI・API・画面で同じものを使う(保存は core/requestOps.ts の updateTask がこれで確かめる)。
|
|
4
|
+
*
|
|
5
|
+
* - 今の値 block: { reason, decision?, since, updatedAt, updatedBy? }。reason は何で止まったか(空白だけは不可)、decision は人に
|
|
6
|
+
* 決めてほしいこと(任意)。since は止まった時刻で、内容を直しても変えない。時刻は P3 が付ける
|
|
7
|
+
* - 履歴 blockHistory: [{ action: set | update | clear, at, by?, before?, after?, resolution? }] を追記する(直接上書きする入力の道は無い)。
|
|
8
|
+
* before / after はその時の今の値の写し。解除(clear)には回答・解決の内容(resolution)が要る
|
|
9
|
+
* - 付けるのと内容を直すのは作業中(doing)のタスクだけ。同じ内容の付け直し・付いていない解除は何もしない(履歴を増やさない)
|
|
10
|
+
* - 止まったまま未着手・完了へは動かさない(解除と移動を同じ更新で指定すれば、確かめてから一緒に保存する)。解除は状態・日時・
|
|
11
|
+
* 済み・要望の状態を変えない(自動では再開しない)
|
|
12
|
+
* - 直接編集で読めない値は黙って消さず、problems として知らせる(操作は断り、関係のない更新ではファイルの元の値を書き戻す)。
|
|
13
|
+
* 作業中でないのに停止が付いているのは読める値なので、解除で直せる(警告だけ)
|
|
14
|
+
* - 同じ OS の権限でファイルを直接書き換えることは防がない。完全な監査ログではない
|
|
15
|
+
*/
|
|
16
|
+
export const BLOCK_LIMITS = {
|
|
17
|
+
reason: 2000,
|
|
18
|
+
decision: 2000,
|
|
19
|
+
resolution: 4000,
|
|
20
|
+
};
|
|
21
|
+
/** ファイルに書く停止の項目(壊れていたら元の値のまま書き戻す) */
|
|
22
|
+
export const BLOCK_KEYS = ["block", "blockHistory"];
|
|
23
|
+
/** 入力が規則に合わない・状態と合わない(何も書いていない)。CLI は使い方の誤り、API は 400 */
|
|
24
|
+
export class BlockInputError extends Error {
|
|
25
|
+
code;
|
|
26
|
+
constructor(code, message) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.code = code;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// --- 読む ---------------------------------------------------------------------
|
|
32
|
+
const str = (v) => (typeof v === "string" ? v : undefined);
|
|
33
|
+
const iso = (v) => (v instanceof Date ? v.toISOString() : typeof v === "string" && v ? v : undefined);
|
|
34
|
+
function snapshotOf(v) {
|
|
35
|
+
if (!v || typeof v !== "object")
|
|
36
|
+
return undefined;
|
|
37
|
+
const o = v;
|
|
38
|
+
const reason = str(o.reason)?.trim();
|
|
39
|
+
const since = iso(o.since);
|
|
40
|
+
if (!reason || !since)
|
|
41
|
+
return undefined;
|
|
42
|
+
const decision = str(o.decision)?.trim();
|
|
43
|
+
return { reason, ...(decision ? { decision } : {}), since };
|
|
44
|
+
}
|
|
45
|
+
/** frontmatter の値を読む。読めない値は除いて problems に理由を足す(どちらも無ければ何も足さない) */
|
|
46
|
+
export function readBlock(d) {
|
|
47
|
+
const problems = [];
|
|
48
|
+
const out = {};
|
|
49
|
+
if (d.block !== undefined && d.block !== null) {
|
|
50
|
+
const o = typeof d.block === "object" ? d.block : undefined;
|
|
51
|
+
const snap = snapshotOf(d.block);
|
|
52
|
+
if (!o || !snap)
|
|
53
|
+
problems.push("block が読めません(reason と since が要ります)");
|
|
54
|
+
else {
|
|
55
|
+
const updatedAt = iso(o.updatedAt) ?? snap.since;
|
|
56
|
+
out.block = { ...snap, updatedAt, ...(str(o.updatedBy) ? { updatedBy: str(o.updatedBy) } : {}) };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (d.blockHistory !== undefined && d.blockHistory !== null) {
|
|
60
|
+
if (!Array.isArray(d.blockHistory))
|
|
61
|
+
problems.push("blockHistory が並びになっていません");
|
|
62
|
+
else {
|
|
63
|
+
const list = [];
|
|
64
|
+
for (const [i, raw] of d.blockHistory.entries()) {
|
|
65
|
+
const o = raw && typeof raw === "object" ? raw : {};
|
|
66
|
+
const action = o.action;
|
|
67
|
+
const at = iso(o.at);
|
|
68
|
+
if ((action !== "set" && action !== "update" && action !== "clear") || !at) {
|
|
69
|
+
problems.push(`blockHistory の ${i + 1} 件目が読めません(action と at が要ります)`);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const before = snapshotOf(o.before);
|
|
73
|
+
const after = snapshotOf(o.after);
|
|
74
|
+
const resolution = str(o.resolution)?.trim();
|
|
75
|
+
list.push({ action, at, ...(str(o.by) ? { by: str(o.by) } : {}), ...(before ? { before } : {}), ...(after ? { after } : {}), ...(resolution ? { resolution } : {}) });
|
|
76
|
+
}
|
|
77
|
+
out.blockHistory = list;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (problems.length)
|
|
81
|
+
out.blockProblems = problems;
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
// --- 変える -------------------------------------------------------------------
|
|
85
|
+
function clean(raw, label, max, required) {
|
|
86
|
+
const t = (raw ?? "").trim();
|
|
87
|
+
if (!t) {
|
|
88
|
+
if (required)
|
|
89
|
+
throw new BlockInputError("block_invalid", `${label}を書いてください(空白だけは不可)`);
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
if (t.length > max)
|
|
93
|
+
throw new BlockInputError("block_invalid", `${label}は ${max} 文字までです(${t.length} 文字)`);
|
|
94
|
+
return t;
|
|
95
|
+
}
|
|
96
|
+
const snap = (b) => ({ reason: b.reason, ...(b.decision ? { decision: b.decision } : {}), since: b.since });
|
|
97
|
+
/**
|
|
98
|
+
* 操作を当てた後の停止の値(何も書かない。規則に合わなければ BlockInputError)。status: 更新した後のタスクの状態。
|
|
99
|
+
* 変わらなければ undefined(同じ内容の付け直し・付いていない解除)
|
|
100
|
+
*/
|
|
101
|
+
export function applyBlockOp(state, op, at) {
|
|
102
|
+
if (state.blockProblems?.length) {
|
|
103
|
+
throw new BlockInputError("block_invalid", `停止の値がファイルで読めないため変えられません。タスクのファイルの block / blockHistory を直してください: ${state.blockProblems.join(" / ")}`);
|
|
104
|
+
}
|
|
105
|
+
const history = state.blockHistory ?? [];
|
|
106
|
+
const by = at.actor ? { by: at.actor } : {};
|
|
107
|
+
if (op.op === "set") {
|
|
108
|
+
const reason = clean(op.reason, "止まっている理由", BLOCK_LIMITS.reason, true);
|
|
109
|
+
const decision = clean(op.decision, "決めてほしいこと", BLOCK_LIMITS.decision, false);
|
|
110
|
+
if (at.status !== "doing")
|
|
111
|
+
throw new BlockInputError("block_not_doing", `停止は作業中のタスクだけに付けられます(今は ${at.status})`);
|
|
112
|
+
const cur = state.block;
|
|
113
|
+
if (cur && cur.reason === reason && (cur.decision ?? undefined) === decision)
|
|
114
|
+
return undefined;
|
|
115
|
+
const block = { reason, ...(decision ? { decision } : {}), since: cur?.since ?? at.now, updatedAt: at.now, ...(at.actor ? { updatedBy: at.actor } : {}) };
|
|
116
|
+
const entry = cur ? { action: "update", at: at.now, ...by, before: snap(cur), after: snap(block) } : { action: "set", at: at.now, ...by, after: snap(block) };
|
|
117
|
+
return { block, blockHistory: [...history, entry] };
|
|
118
|
+
}
|
|
119
|
+
if (op.op === "clear") {
|
|
120
|
+
const resolution = clean(op.resolution, "回答・解決の内容", BLOCK_LIMITS.resolution, true);
|
|
121
|
+
if (!state.block)
|
|
122
|
+
return undefined;
|
|
123
|
+
return { block: undefined, blockHistory: [...history, { action: "clear", at: at.now, ...by, before: snap(state.block), resolution }] };
|
|
124
|
+
}
|
|
125
|
+
throw new BlockInputError("block_invalid", `知らない操作です: ${String(op.op)}`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* 止まったままの状態の移動を断る(前と後の状態・更新した後の停止の値で)。既に作業中でないのに停止が付いている(直接編集)タスクの
|
|
129
|
+
* 関係のない更新は断らない(警告だけ。解除で直す)
|
|
130
|
+
*/
|
|
131
|
+
export function checkBlockedStatus(before, status, block, ref) {
|
|
132
|
+
if (block && status !== "doing" && status !== before) {
|
|
133
|
+
throw new BlockInputError("blocked", `${ref} は止まっています(${block.reason})。未着手・完了へ動かす前に、回答・解決の内容を添えて解除してください(p3 unblock ${ref} --resolution "...")`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/** 読み取りの注意(読めない値・作業中でないのに停止が付いている) */
|
|
137
|
+
export function blockWarnings(t) {
|
|
138
|
+
return [
|
|
139
|
+
...(t.blockProblems ?? []).map((p) => `停止の値が読めません: ${p}`),
|
|
140
|
+
...(t.block && t.status !== "doing" ? [`作業中でないのに停止が付いています(${t.status})。解除して直してください`] : []),
|
|
141
|
+
];
|
|
142
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* タスクの AI レビューの形(CLI・API・画面で共有する)。規則は core/taskReview/。
|
|
3
|
+
*
|
|
4
|
+
* レビューは、完了したタスクの本文・受け入れ基準に対して、比較対象(固定したコミットの差分と、その前後のコード)が基準を
|
|
5
|
+
* 満たしているかを、作業したのとは別の Codex のスレッドが読むだけで確かめる参考の記録。作業した AI の能力・成績の評価ではない。
|
|
6
|
+
* 作業した側の証拠(acceptanceEvidence)は申告として材料に入れるが、判定には変えない。結果はタスクの状態・済み・基準・証拠・
|
|
7
|
+
* 要望の状態を変えず、済みの条件にもしない(済みは人が決める)。
|
|
8
|
+
*/
|
|
9
|
+
/** 比較項目ごとの判定 */
|
|
10
|
+
export const TASK_REVIEW_VERDICTS = ["satisfied", "missing", "undetermined"];
|
|
11
|
+
export const TASK_REVIEW_VERDICT_LABELS = {
|
|
12
|
+
satisfied: "満たしている",
|
|
13
|
+
missing: "不足",
|
|
14
|
+
undetermined: "判断できない",
|
|
15
|
+
};
|
|
16
|
+
/** 固定した材料(input.json)。作ったら変えない */
|
|
17
|
+
/** 品質の判定(最新のプロジェクトの品質基準ごと) */
|
|
18
|
+
export const QUALITY_VERDICTS = ["satisfied", "violated", "undetermined", "not_applicable"];
|
|
19
|
+
export const QUALITY_VERDICT_LABELS = { satisfied: "満たす", violated: "違反", undetermined: "判断できない", not_applicable: "対象外(理由つき)" };
|
|
20
|
+
export const TASK_REVIEW_STATUSES = ["running", "completed", "failed", "cancelled"];
|
|
21
|
+
/** 評価の範囲(結果と一緒に出す) */
|
|
22
|
+
export const TASK_REVIEW_SCOPE = "完了したタスクの本文・受け入れ基準に対して、固定したコミットの差分とその前後のコード(抽出した材料)を読んで確かめた参考の記録です。" +
|
|
23
|
+
"作業した AI の能力や成績の評価ではありません。テストやアプリは動かしていません。作業した側の証拠は申告として読み、判定には変えていません。";
|
|
24
|
+
/** プレビューで返す材料の要約(材料のファイルの中身は返さない) */
|
|
25
|
+
export function previewOf(input) {
|
|
26
|
+
return {
|
|
27
|
+
task: { ref: input.task.ref, title: input.task.title, status: input.task.status, record: !!input.task.record, outputs: input.task.outputs },
|
|
28
|
+
items: input.items,
|
|
29
|
+
evidenceStates: input.task.evidenceStates ?? [],
|
|
30
|
+
acceptanceProblems: input.task.acceptanceProblems ?? [],
|
|
31
|
+
targets: input.targets.map((t) => ({
|
|
32
|
+
repo: t.repo,
|
|
33
|
+
kind: t.kind,
|
|
34
|
+
sources: t.sources,
|
|
35
|
+
commits: t.commits.map((c) => ({ sha: c.sha, subject: c.subject, otherTasks: c.otherTasks })),
|
|
36
|
+
...(t.range ? { range: t.range } : {}),
|
|
37
|
+
changes: t.diffs.reduce((n, d) => n + d.changes.length, 0),
|
|
38
|
+
})),
|
|
39
|
+
viewpoint: { source: input.viewpoint.source, ...(input.viewpoint.repo ? { repo: input.viewpoint.repo, sha: input.viewpoint.sha, path: input.viewpoint.path } : {}), hash: input.viewpoint.hash },
|
|
40
|
+
notes: input.notes,
|
|
41
|
+
...(input.quality ? { quality: { state: input.quality.latest.state, version: input.quality.latest.version, applies: input.quality.applies.map((q) => ({ id: q.id, text: q.text })), exempt: input.quality.exempt.map((q) => ({ id: q.id, reason: q.exempt?.reason ?? "" })), diff: input.quality.diff } } : {}),
|
|
42
|
+
files: input.files.length,
|
|
43
|
+
hash: input.hash,
|
|
44
|
+
extractedAt: input.extractedAt,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 過去の run と同じ比較対象・観点の指定(材料が変わったかを今の材料と比べる・同じ指定でレビューし直すため)。
|
|
49
|
+
* コミットは固定した SHA、範囲は指定したときの base・head の文字列(ブランチが進めば材料が変わる)、観点は固定した SHA のファイル
|
|
50
|
+
*/
|
|
51
|
+
export function rerunSpec(input) {
|
|
52
|
+
const targets = input.targets.map((t) => (t.kind === "range" && t.range ? `${t.repo}:${t.range.baseSpec}..${t.range.headSpec}` : `${t.repo}:${t.commits.map((c) => c.sha).join(",")}`));
|
|
53
|
+
const v = input.viewpoint;
|
|
54
|
+
const viewpoint = v.source === "file" && v.repo && v.sha && v.path ? `${v.repo}@${v.sha}:${v.path}` : v.source;
|
|
55
|
+
return { targets, viewpoint };
|
|
56
|
+
}
|