@infodb/p3 0.11.0 → 0.13.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 +33 -33
- package/dist/web/assets/CompletionReview-gZKZrDu_.js +1 -0
- package/dist/web/assets/ImprovementDialog-Dno6dPnG.js +1 -0
- package/dist/web/assets/Outputs-BgHalMGb.js +1 -0
- package/dist/web/assets/RequestStatus-hZcBUUIu.js +1 -0
- package/dist/web/assets/Tabs-C3NmwCc3.js +1 -0
- package/dist/web/assets/TagInput-B2b862qn.js +1 -0
- package/dist/web/assets/TaskDrawer-4BQBELXa.js +6 -0
- package/dist/web/assets/_requestId-BMAG1t3o.js +1 -0
- package/dist/web/assets/_requestId-tbg2pA2S.js +1 -0
- package/dist/web/assets/archive-DMl6WyOe.js +1 -0
- package/dist/web/assets/board-BMTcHKyt.js +1 -0
- package/dist/web/assets/done-CL6Nlsua.js +1 -0
- package/dist/web/assets/draft-BvGxfD7v.js +2 -0
- package/dist/web/assets/index-Dp7Fc4VI.css +2 -0
- package/dist/web/assets/index-KdlgMitg.js +12 -0
- package/dist/web/assets/metrics-Cu7gJ7Rk.js +1 -0
- package/dist/web/assets/new-DTXWHuFO.js +1 -0
- package/dist/web/assets/outputs-CXqnjSqV.js +1 -0
- package/dist/web/assets/preflightInput-ClKwkp8R.js +2 -0
- package/dist/web/assets/preload-helper-oLCrNCwz.js +1 -0
- package/dist/web/assets/quality-RFd-7k3r.js +1 -0
- package/dist/web/assets/release-notes-Bpdi6RdY.js +5 -0
- package/dist/web/assets/requestData-CbFxwW5w.js +1 -0
- package/dist/web/assets/routes-BIt8bExF.js +6 -0
- package/dist/web/assets/settings-CsCqF_1B.js +1 -0
- package/dist/web/assets/taskReview-_WCgnQit.js +1 -0
- package/dist/web/assets/ui-BGK72r3u.js +1 -0
- package/dist/web/assets/workTarget-CySfKyfB.js +30 -0
- package/dist/web/index.html +4 -4
- package/docs/architecture.md +610 -33
- package/docs/development.md +61 -17
- package/docs/how-to-use.md +554 -17
- package/docs/installation.md +235 -144
- package/docs/publishing.md +1 -1
- package/lib/cli/agentsStatus.js +197 -0
- package/lib/cli/args.js +111 -2
- package/lib/cli/guide.js +27 -0
- package/lib/cli/guide.md +214 -0
- package/lib/cli/help.js +74 -1
- package/lib/cli/main.js +97 -17
- package/lib/cli/metricsCommands.js +77 -0
- package/lib/cli/output.js +19 -1
- package/lib/cli/preflightCommands.js +7 -1
- package/lib/cli/project.js +13 -24
- package/lib/cli/qualityCommands.js +188 -0
- package/lib/cli/readOnly.js +17 -0
- package/lib/cli/requestCommands.js +33 -4
- package/lib/cli/requirementCommands.js +288 -0
- package/lib/cli/retroCommands.js +106 -0
- package/lib/cli/revisitCommands.js +73 -0
- package/lib/cli/showView.js +183 -4
- package/lib/cli/taskCommands.js +341 -20
- package/lib/cli/taskReviewCommands.js +178 -0
- package/lib/cli/userConfig.js +47 -0
- package/lib/core/completionRefs.js +46 -0
- package/lib/core/context.js +4 -1
- package/lib/core/metrics/definitions.js +434 -0
- package/lib/core/metrics/index.js +88 -0
- package/lib/core/metrics/manual.js +180 -0
- package/lib/core/milestoneReview/material.js +11 -1
- package/lib/core/milestoneReview/mockReviewer.js +1 -0
- package/lib/core/milestoneReview/review.js +70 -6
- package/lib/core/milestoneReview/service.js +29 -93
- package/lib/core/milestoneReview/store.js +12 -62
- package/lib/core/ops.js +23 -3
- package/lib/core/preflight/carryover.js +6 -2
- package/lib/core/preflight/codexEngine.js +34 -17
- package/lib/core/preflight/diagnose.js +4 -9
- package/lib/core/preflight/engine.js +15 -0
- package/lib/core/preflight/hostPaths.js +260 -0
- package/lib/core/preflight/input.js +33 -5
- package/lib/core/preflight/instructions.js +36 -2
- package/lib/core/preflight/mockEngine.js +24 -2
- package/lib/core/preflight/render.js +22 -3
- package/lib/core/preflight/service.js +99 -8
- package/lib/core/preflight/uiRender.js +3 -0
- 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 +294 -11
- package/lib/core/retrospective.js +208 -0
- package/lib/core/reviewCandidates.js +56 -0
- package/lib/core/reviewRuns.js +205 -0
- package/lib/core/store/archivedTasks.js +74 -0
- package/lib/core/store/collection.js +32 -3
- package/lib/core/store/normalize.js +35 -2
- package/lib/core/store/preflightStore.js +23 -1
- package/lib/core/store/projectFile.js +10 -0
- package/lib/core/store/workspace.js +49 -3
- package/lib/core/taskReview/material.js +459 -0
- package/lib/core/taskReview/mockReviewer.js +30 -0
- package/lib/core/taskReview/paths.js +15 -0
- package/lib/core/taskReview/review.js +312 -0
- package/lib/core/taskReview/service.js +187 -0
- package/lib/core/taskReview/store.js +214 -0
- package/lib/server/api/manifest.js +104 -5
- package/lib/server/api/milestoneReviewRoutes.js +4 -3
- package/lib/server/api/routes.js +265 -17
- package/lib/server/api/taskReviewRoutes.js +66 -0
- package/lib/server/server.js +2 -2
- package/lib/shared/acceptance.js +618 -0
- package/lib/shared/completionRecord.js +327 -0
- package/lib/shared/metrics.js +42 -0
- package/lib/shared/milestoneReview.js +2 -1
- package/lib/shared/preflightInput.js +1 -1
- package/lib/shared/quality.js +391 -0
- package/lib/shared/qualityImprovement.js +1 -0
- package/lib/shared/qualityTemplates.js +31 -0
- package/lib/shared/requirementSource.js +635 -0
- package/lib/shared/retrospective.js +286 -0
- package/lib/shared/reviewCandidate.js +308 -0
- package/lib/shared/reworkHistory.js +81 -0
- package/lib/shared/taskBlock.js +142 -0
- package/lib/shared/taskReview.js +56 -0
- package/package.json +3 -2
- package/skills/p3/SKILL.md +9 -152
- package/dist/web/assets/Outputs-ddwte0jj.js +0 -1
- package/dist/web/assets/RequestStatus-Bg1OLbRc.js +0 -1
- package/dist/web/assets/Tabs-DTmggzgg.js +0 -1
- package/dist/web/assets/TagInput-BHAgjLP7.js +0 -1
- package/dist/web/assets/TaskDrawer-Dz_5c2NH.js +0 -3
- package/dist/web/assets/_requestId-D9-gtIcG.js +0 -1
- package/dist/web/assets/_requestId-DzCNYvqf.js +0 -30
- package/dist/web/assets/appCtx-Cm24VpAf.js +0 -1
- package/dist/web/assets/board-MCHcZ-PU.js +0 -1
- package/dist/web/assets/done-zq10Bt08.js +0 -1
- package/dist/web/assets/draft-CfJeyLOl.js +0 -1
- package/dist/web/assets/index-Ce0ndpne.js +0 -12
- package/dist/web/assets/index-D68mkSnw.css +0 -2
- package/dist/web/assets/new-9TKiNT4O.js +0 -1
- package/dist/web/assets/preflightInput-BAeEJYUK.js +0 -2
- package/dist/web/assets/preload-helper-FBLw7u7x.js +0 -1
- package/dist/web/assets/release-notes-hK5XezLW.js +0 -5
- package/dist/web/assets/requestData-BnN7mctX.js +0 -1
- package/dist/web/assets/routes-usHwrrA0.js +0 -3
- package/dist/web/assets/settings-BVZDnL6O.js +0 -1
- package/dist/web/assets/workTarget-Cijqq4yH.js +0 -1
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { lstat, mkdir, readdir, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
4
|
+
import { REQUEST_ID, TASK_ID } from "../../shared/refs.js";
|
|
5
|
+
import { TASK_REVIEW_STATUSES, } from "../../shared/taskReview.js";
|
|
6
|
+
import { dirs, finishRunFile, readJson, ReviewStoreError, runStamp, updateRunFile, writeJson } from "../reviewRuns.js";
|
|
7
|
+
import { withFileLock } from "../store/fsutil.js";
|
|
8
|
+
import { safeRelPath } from "./paths.js";
|
|
9
|
+
/**
|
|
10
|
+
* タスクの AI レビューの履歴(要望のフォルダの中。要望をアーカイブすれば一緒に動き、タスクをアーカイブしても残る)。
|
|
11
|
+
*
|
|
12
|
+
* requests/<要望ID>/task-reviews/<タスクID>/<run>/input.json 固定した材料(作ったら変えない)
|
|
13
|
+
* requests/<要望ID>/task-reviews/<タスクID>/<run>/material/ 材料のファイル(差分・前後のコード。作ったら変えない)
|
|
14
|
+
* requests/<要望ID>/task-reviews/<タスクID>/<run>/run.json 実行の記録
|
|
15
|
+
* requests/<要望ID>/task-reviews/<タスクID>/<run>/review.json 結果(completed のときだけ。書き終えてから completed にする)
|
|
16
|
+
* requests/<要望ID>/task-reviews/.locks/<タスクID>.lock 状態を変えるときのロック(プロセス間。タスクごと)
|
|
17
|
+
*
|
|
18
|
+
* - キーは "<要望ID>/<タスクID>"。ID の形を確かめ、保存先の外を指すものは断る。同じ run は作り直さない
|
|
19
|
+
* - 保存・終わり・取消の規則はマイルストーンレビューと共通(reviewRuns.ts)
|
|
20
|
+
* - 結果はタスクのファイル(本文・証拠)には書かない。同じ OS の権限でファイルを直接書き換えることは防がない
|
|
21
|
+
*/
|
|
22
|
+
export const TASK_REVIEWS_DIR = "task-reviews";
|
|
23
|
+
const RUN_ID = /^TR-\d{8}-\d{6}-[0-9a-f]{4}$/;
|
|
24
|
+
export function newTaskReviewRunId(now = new Date()) {
|
|
25
|
+
return `TR-${runStamp(now)}-${randomBytes(2).toString("hex")}`;
|
|
26
|
+
}
|
|
27
|
+
export function checkTaskReviewRunId(id) {
|
|
28
|
+
if (!RUN_ID.test(id))
|
|
29
|
+
throw new ReviewStoreError("bad_id", `タスクのレビューの run の ID ではありません: ${JSON.stringify(id)}(TR-YYYYMMDD-HHMMSS-xxxx)`);
|
|
30
|
+
}
|
|
31
|
+
/** キー(<要望ID>/<タスクID>)を分けて確かめる */
|
|
32
|
+
export function parseTaskReviewKey(key) {
|
|
33
|
+
const [rid, tid, extra] = key.split("/");
|
|
34
|
+
if (extra !== undefined || !rid || !tid || !REQUEST_ID.test(rid) || !TASK_ID.test(tid))
|
|
35
|
+
throw new ReviewStoreError("bad_id", `タスクの参照に使えません: ${JSON.stringify(key)}(<要望ID>/T001)`);
|
|
36
|
+
return { rid, tid };
|
|
37
|
+
}
|
|
38
|
+
export class TaskReviewStore {
|
|
39
|
+
requestsDir;
|
|
40
|
+
/** requestsDir: <data>/requests */
|
|
41
|
+
constructor(requestsDir) {
|
|
42
|
+
this.requestsDir = requestsDir;
|
|
43
|
+
}
|
|
44
|
+
within(...parts) {
|
|
45
|
+
const root = resolve(this.requestsDir);
|
|
46
|
+
const p = resolve(root, ...parts);
|
|
47
|
+
if (!p.startsWith(root + sep))
|
|
48
|
+
throw new ReviewStoreError("bad_id", `保存先の外を指します: ${parts.join("/")}`);
|
|
49
|
+
return p;
|
|
50
|
+
}
|
|
51
|
+
reviewsDir(rid) {
|
|
52
|
+
parseTaskReviewKey(`${rid}/T001`);
|
|
53
|
+
return this.within(rid, TASK_REVIEWS_DIR);
|
|
54
|
+
}
|
|
55
|
+
taskDir(key) {
|
|
56
|
+
const { rid, tid } = parseTaskReviewKey(key);
|
|
57
|
+
return this.within(rid, TASK_REVIEWS_DIR, tid);
|
|
58
|
+
}
|
|
59
|
+
runDir(key, run) {
|
|
60
|
+
checkTaskReviewRunId(run);
|
|
61
|
+
return join(this.taskDir(key), run);
|
|
62
|
+
}
|
|
63
|
+
materialDir(key, run) {
|
|
64
|
+
return join(this.runDir(key, run), "material");
|
|
65
|
+
}
|
|
66
|
+
/** タスクの状態を変えるときのロック(ほかのプロセスの開始・終わり・取消と1つずつにする。別のタスクは独立) */
|
|
67
|
+
withLock(key, fn) {
|
|
68
|
+
const { rid, tid } = parseTaskReviewKey(key);
|
|
69
|
+
return withFileLock(join(this.reviewsDir(rid), ".locks", `${tid}.lock`), fn, {
|
|
70
|
+
busyMessage: `${key} のレビューの記録を変えられませんでした(別のプロセスが使っています。少し待ってやり直してください)`,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** run の ID(新しい順) */
|
|
74
|
+
async runIds(key) {
|
|
75
|
+
return (await dirs(this.taskDir(key))).filter((r) => RUN_ID.test(r)).sort().reverse();
|
|
76
|
+
}
|
|
77
|
+
async hasHistory(key) {
|
|
78
|
+
return (await this.runIds(key)).length > 0;
|
|
79
|
+
}
|
|
80
|
+
/** 履歴のあるタスク(アーカイブしたタスクも含む) */
|
|
81
|
+
async tasksWithHistory(rid) {
|
|
82
|
+
const out = [];
|
|
83
|
+
for (const d of await dirs(this.reviewsDir(rid)))
|
|
84
|
+
if (TASK_ID.test(d) && (await this.hasHistory(`${rid}/${d}`)))
|
|
85
|
+
out.push(d);
|
|
86
|
+
return out.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 新しい run を作る(材料のファイル・input.json・running の run.json)。同じ ID が既にあれば exists で断る(上書きしない)。
|
|
90
|
+
* 呼ぶ側がロックの中で呼ぶ(同じタスクで実行中の run を2つ作らないため)
|
|
91
|
+
*/
|
|
92
|
+
async create(input, files, run) {
|
|
93
|
+
const key = `${run.request}/${run.task}`;
|
|
94
|
+
const dir = this.runDir(key, run.id);
|
|
95
|
+
const material = join(dir, "material");
|
|
96
|
+
// 書く前に全部のパスを確かめる(途中で断って作りかけを残さない)
|
|
97
|
+
const targets = [...files].map(([rel, data]) => {
|
|
98
|
+
const path = resolve(material, rel);
|
|
99
|
+
if (!safeRelPath(rel) || !path.startsWith(resolve(material) + sep))
|
|
100
|
+
throw new ReviewStoreError("bad_id", `材料のファイルのパスに使えません: ${JSON.stringify(rel)}`);
|
|
101
|
+
return { path, data };
|
|
102
|
+
});
|
|
103
|
+
await mkdir(this.taskDir(key), { recursive: true });
|
|
104
|
+
try {
|
|
105
|
+
await mkdir(dir);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
if (e.code === "EEXIST")
|
|
109
|
+
throw new ReviewStoreError("exists", `既にある run です: ${key}/${run.id}`);
|
|
110
|
+
throw e;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
for (const { path, data } of targets) {
|
|
114
|
+
await mkdir(dirname(path), { recursive: true });
|
|
115
|
+
// 作ったばかりのフォルダの中だけに書く(途中がシンボリックリンクなら断る。新しいファイルとしてだけ作る)
|
|
116
|
+
await assertNoLinks(material, path);
|
|
117
|
+
await writeFile(path, data, { flag: "wx" });
|
|
118
|
+
}
|
|
119
|
+
await writeJson(join(dir, "input.json"), input);
|
|
120
|
+
await writeJson(join(dir, "run.json"), run);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
// 作りかけの run は残さない(一覧に壊れた記録として出さない)
|
|
124
|
+
await rm(dir, { recursive: true, force: true });
|
|
125
|
+
throw e;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async readRun(key, run) {
|
|
129
|
+
return readJson(join(this.runDir(key, run), "run.json"), `${key}/${run}`, checkRunShape);
|
|
130
|
+
}
|
|
131
|
+
async readInput(key, run) {
|
|
132
|
+
return readJson(join(this.runDir(key, run), "input.json"), `${key}/${run} の input.json`, (x) => {
|
|
133
|
+
const i = x;
|
|
134
|
+
if (!i.task || !Array.isArray(i.items) || !Array.isArray(i.targets) || typeof i.hash !== "string")
|
|
135
|
+
throw new Error("形が違います");
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
async readResult(key, run) {
|
|
139
|
+
return readJson(join(this.runDir(key, run), "review.json"), `${key}/${run} の review.json`, (x) => {
|
|
140
|
+
const r = x;
|
|
141
|
+
if (typeof r.overall !== "string" || !Array.isArray(r.items))
|
|
142
|
+
throw new Error("形が違います");
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/** 1回分(無ければ not_found、どれかが読めなければ broken) */
|
|
146
|
+
async get(key, run) {
|
|
147
|
+
const r = await this.readRun(key, run);
|
|
148
|
+
const input = await this.readInput(key, run);
|
|
149
|
+
const result = r.status === "completed" ? await this.readResult(key, run) : undefined;
|
|
150
|
+
return { run: r, input, ...(result ? { result } : {}) };
|
|
151
|
+
}
|
|
152
|
+
/** 一覧(新しい順)。読めない記録も broken として出す(隠さない) */
|
|
153
|
+
async list(key) {
|
|
154
|
+
const out = [];
|
|
155
|
+
for (const id of await this.runIds(key)) {
|
|
156
|
+
try {
|
|
157
|
+
const rec = await this.get(key, id);
|
|
158
|
+
const verdicts = {};
|
|
159
|
+
for (const i of rec.result?.items ?? [])
|
|
160
|
+
verdicts[i.verdict] = (verdicts[i.verdict] ?? 0) + 1;
|
|
161
|
+
out.push({ state: "ok", run: rec.run, inputHash: rec.input.hash, items: rec.input.items.length, ...(rec.result ? { verdicts } : {}) });
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
out.push({ state: "broken", id, error: e.message });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const at = (x) => (x.state === "ok" ? x.run.startedAt.replace(/[-:]/g, "").replace("T", "-") : x.id.slice(3, 18));
|
|
168
|
+
return out.sort((a, b) => (at(a) < at(b) ? 1 : at(a) > at(b) ? -1 : 0));
|
|
169
|
+
}
|
|
170
|
+
async updateRunning(key, run, fn) {
|
|
171
|
+
return updateRunFile(`${key}/${run}`, await this.readRun(key, run), fn, (r) => writeJson(join(this.runDir(key, run), "run.json"), r));
|
|
172
|
+
}
|
|
173
|
+
async finish(key, run, patch, result) {
|
|
174
|
+
const dir = this.runDir(key, run);
|
|
175
|
+
return finishRunFile(`${key}/${run}`, await this.readRun(key, run), patch, result, {
|
|
176
|
+
writeRun: (r) => writeJson(join(dir, "run.json"), r),
|
|
177
|
+
writeResult: (r) => writeJson(join(dir, "review.json"), r),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/** 材料のファイルの一覧(材料のフォルダからの相対パス。シンボリックリンクは含めない) */
|
|
181
|
+
async materialFiles(key, run) {
|
|
182
|
+
const root = this.materialDir(key, run);
|
|
183
|
+
const out = [];
|
|
184
|
+
const walk = async (d, rel) => {
|
|
185
|
+
for (const e of await readdir(d, { withFileTypes: true }).catch(() => [])) {
|
|
186
|
+
const r = rel ? `${rel}/${e.name}` : e.name;
|
|
187
|
+
if (e.isDirectory())
|
|
188
|
+
await walk(join(d, e.name), r);
|
|
189
|
+
else if (e.isFile())
|
|
190
|
+
out.push(r);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
await walk(root, "");
|
|
194
|
+
return out.sort();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/** root から path までの途中(root を除く)にシンボリックリンクが無いこと */
|
|
198
|
+
async function assertNoLinks(root, path) {
|
|
199
|
+
const parts = path.slice(resolve(root).length + 1).split(sep);
|
|
200
|
+
let cur = resolve(root);
|
|
201
|
+
for (const p of parts.slice(0, -1)) {
|
|
202
|
+
cur = join(cur, p);
|
|
203
|
+
if ((await lstat(cur)).isSymbolicLink())
|
|
204
|
+
throw new ReviewStoreError("bad_id", `材料のフォルダの中にシンボリックリンクがあります: ${cur}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function checkRunShape(x) {
|
|
208
|
+
const r = x;
|
|
209
|
+
if (typeof r.id !== "string" || typeof r.request !== "string" || typeof r.task !== "string" || !TASK_REVIEW_STATUSES.includes(r.status) || typeof r.startedAt !== "string") {
|
|
210
|
+
throw new Error("形が違います");
|
|
211
|
+
}
|
|
212
|
+
if (!Array.isArray(r.log))
|
|
213
|
+
throw new Error("log がありません");
|
|
214
|
+
}
|
|
@@ -22,6 +22,32 @@ export const AI_MANIFEST = {
|
|
|
22
22
|
"ここに無い API は /api/projects/:project/... の下に置く(通常の serve の /api/... と同じ)。変える操作には x-p3-project-generation が要る(無ければ 428、違えば 409 code: changed)。" +
|
|
23
23
|
"プロジェクトを書かないデータの API は 404 code: project_required。/api/chatgpt(engine は null)・/api/user-theme・/api/events(一覧・テーマ・接続の変更)はプロジェクトを選ばずに使える",
|
|
24
24
|
},
|
|
25
|
+
{
|
|
26
|
+
method: "GET|POST",
|
|
27
|
+
path: "/api/quality",
|
|
28
|
+
desc: "品質基準(project.yaml の quality)。GET は {quality: {state: unset | set | invalid, ...}, version, diffs(採用したテンプレートの改版の差分), templates}。" +
|
|
29
|
+
"POST {ops: [{op: init | adopt | upgrade | add | replace | edit | remove | exempt | unexempt, ...}], version?} で操作を順に当てて quality だけを書く(version が違えば 409 quality_conflict、" +
|
|
30
|
+
"規則に合わなければ 400 quality_invalid、読めない設定は 400 quality_unreadable。設定の保存 PUT /api/project は quality を書かない)。コマンドは実行しない",
|
|
31
|
+
},
|
|
32
|
+
{ method: "GET", path: "/api/requests/:rid/tasks/:tid/quality-diff", desc: "タスクの受け入れ基準と今の品質基準の差分 {quality, version, diff: [{kind: add | change | remove | exempt | edited, quality, criterion?, text?, reason?}]}(読むだけ)" },
|
|
33
|
+
{
|
|
34
|
+
method: "POST",
|
|
35
|
+
path: "/api/requests/:rid/tasks/:tid/quality-import",
|
|
36
|
+
desc: "差分を明示して受け入れ基準に取り込む {keys?: [\"<kind>:<品質 ID>\"], rev?}(add は足す、change は文と出典を直す(証拠は再確認が必要になる)、remove・exempt は消す)。POST tasks の quality: auto | none | [ID] で作るときにも取り込む",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
method: "POST",
|
|
40
|
+
path: "/api/quality/improvements/preview",
|
|
41
|
+
desc: "品質の不足の診断と改善要望の原稿 {source: {type: project} | {type: task-review, request, task, run} | {type: milestone-review, milestone, run}, keys?}。" +
|
|
42
|
+
"{findings: [{key, kind: unset | invalid | violated | undetermined | exempt, ...}], hash, registered, picked, draft?}(読むだけ。除外は既定で選ばない)",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
method: "POST",
|
|
46
|
+
path: "/api/quality/improvements",
|
|
47
|
+
desc: "改善要望を明示して登録する {source, keys, title, body, hash, reopenClosed?}(201 {request, keys})。診断が変わっていれば 409 diagnosis_changed、開いている登録先があれば 409 existing(existing.request)、" +
|
|
48
|
+
"閉じた要望で扱った不足は reopenClosed が無ければ 409 closed_existing。不足ごとの登録先は quality-improvements.json に残す",
|
|
49
|
+
},
|
|
50
|
+
{ method: "GET", path: "/api/quality/templates/:id[?version=]", desc: "同梱の品質基準のテンプレートの中身(版つきの例。業界の標準への認証ではない)" },
|
|
25
51
|
{ method: "GET", path: "/api/project", desc: "プロジェクト設定と milestonesVersion(マイルストーンの版)" },
|
|
26
52
|
{
|
|
27
53
|
method: "PUT",
|
|
@@ -41,12 +67,54 @@ export const AI_MANIFEST = {
|
|
|
41
67
|
desc: "参照先(共有の定義)。GET は読めたかの状態と、ローカルの画面にだけこのマシンのパス。POST {name, role?, readFirst?, writable?, map?, path?}",
|
|
42
68
|
},
|
|
43
69
|
{ method: "PUT|DELETE", path: "/api/repos/:name/path", desc: "参照先のこのマシンのパス(個人設定)。このマシンのローカルの画面(Origin)からだけ" },
|
|
44
|
-
{ method: "GET", path: "/api/requests[?parent=<要望ID>]", desc: "要望の一覧と進捗(更新の新しい順。parent
|
|
70
|
+
{ method: "GET", path: "/api/requests[?parent=<要望ID>]", desc: "要望の一覧と進捗(更新の新しい順。parent で直下の子だけを親の表示順に)。止まっている自分のタスクの数 blocked と配下の数 subtree.blocked(作業中にも数える)、タスクの印に停止の今の値 block と証拠の概要 evidence({met, total, declarationOnly, metByBasis, problems}。本文は載せない。基準も証拠も無ければ省く)・完了したタスクの見直しの状態 review、要望ごとの見直し候補の数 review: {self?, tasks, below}(below は自分を除く配下)" },
|
|
45
71
|
{ method: "POST", path: "/api/requests", desc: "要望の作成(parent で子の要望にする。省いた期限・マイルストーン・タグは親から写す)" },
|
|
46
72
|
{
|
|
47
73
|
method: "GET",
|
|
48
74
|
path: "/api/requests/:rid",
|
|
49
|
-
desc: "要望・タスク・Preflight・置き換えられたタスクの印(superseded)・対応済なのに未完了のタスクがあるときの知らせ(issue)・親子(parent・ancestors・children・hierarchyIssues)・対応済にできるか(completion: blocker・見送りで対象外の子 excluded
|
|
75
|
+
desc: "要望・タスク・Preflight・置き換えられたタスクの印(superseded)・対応済なのに未完了のタスクがあるときの知らせ(issue)・親子(parent・ancestors・children・hierarchyIssues)・対応済にできるか(completion: blocker・見送りで対象外の子 excluded)・" +
|
|
76
|
+
"要求の出典と確認(requirement: {state, sources, answers, problems}。state は unrecorded / unconfirmed / confirmed / reconfirm / unlinked。申告の記録で P3 の保証ではない)・" +
|
|
77
|
+
"見直しが必要(候補)(review: {self?(対応済・完了済のときの要望自身の診断), tasks(タスクごとの概要), counts: {tasks, below}})",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
method: "GET|POST",
|
|
81
|
+
path: "/api/requests/:rid/premises",
|
|
82
|
+
desc: "前提の変更(外部の規則の変更など。要望の premiseChanges に追記)。POST {op: \"add\", targets: [要望 ID|タスク ID|要望の根拠の ID], reason, condition, rev?} / {op: \"ack\", id, target, condition, rev?}(変更を確かめたことを残す)。" +
|
|
83
|
+
"基点の完了の記録より後の変更で、確認の無い対象は見直し候補の理由になる。過去の完了の記録・状態・済みは変えない。対象が無い・規則に合わなければ 400 premise_invalid、rev が違えば 409(何も書かない)",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
method: "GET|POST",
|
|
87
|
+
path: "/api/requests/:rid/retrospective[/target]",
|
|
88
|
+
desc: "要望の振り返り。GET は {version, target?(今の対象), targets(確定と訂正の履歴), candidates(採用を終えた run: {run, kind: tasks|split|legacy, latest, basis: [{key?, target, state}], risks}), none?}。" +
|
|
89
|
+
"POST /target {run, reason?, version?} で対象を確定する(候補の run だけ。評価の版とリスクの原文を写す。2回目からの訂正は reason が要る)。候補でない・理由が無い → 400 retro_invalid、版が違う → 409 retro_conflict(何も書かない)。" +
|
|
90
|
+
"GET は今の対象のリスクと確認 risks: [{index, text, state, judgment?, history}]・三状態の件数 counts・全部の確認 judgments・根拠の今の照合 checks(ok|changed|missing|manual)も返す。" +
|
|
91
|
+
"POST /judgments {risk(0 から), state: occurred|not_occurred|unchecked, facts?, scope?, reason?, evidence: [{kind: task_review, task, run, section, index?} | {kind: milestone_review, milestone, run, section, index?, reason?} | {kind: rework, task, history} | {kind: manual, reference, note?}], version?} でリスクの確認を追記する(人の判断。起きた → facts と根拠、起きなかった → scope と根拠、判断を変える → reason。範囲外の根拠は 400)",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
method: "GET",
|
|
95
|
+
path: "/api/metrics[?milestone=<ID>]",
|
|
96
|
+
desc: "開発の指標(p3 metrics と同じ)。範囲は省けばプロジェクト全体(マイルストーンなしを含む)、milestone は登録済みのマイルストーンに直接属する要望(見送り・アーカイブは除く。登録に無い ID は 400 metrics_invalid)。" +
|
|
97
|
+
"{scope, scopeLabel, scopeRule, metrics: [{id, label, kind: record|manual, unit: hours|count|amount, source, target, method, missingRule, recordHint?, state: ok|no_targets|no_data|not_reached|unrecorded, value(ok 以外は null。manual は1行のときだけ), targets, observed, missing, denominator?, breakdown, missingItems, rows?(manual: 範囲が一致する人の記録 {id, from, to, value, unit, source, note?, rev, ...}。合算しない)}], notices(broken_request|manual_unreadable|manual_orphan), scopes}。" +
|
|
98
|
+
"記録の欠けは 0 にせず missing に数える。読むだけ(レビューは実行しない。人の記録を書くのは CLI の p3 metrics record だけ)",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
method: "GET",
|
|
102
|
+
path: "/api/revisit[?request=<要望ID>]",
|
|
103
|
+
desc: "見直しが必要(候補)の一覧(完了したタスクと対応済・完了済の要望。完了済みも含む)。各項目は {target, state, record, qualityVersion, reasons: [{code, target, was?, now?, related?}], unreadable?}。" +
|
|
104
|
+
"品質は作業先に当てはまる項目の差だけを見て、設定全体の版の違い・参照先の HEAD の更新では候補にしない。読むだけでファイルを書かない。タスクの一覧は ?review=true で候補だけに絞れる",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
method: "POST",
|
|
108
|
+
path: "/api/requests/:rid/sources",
|
|
109
|
+
desc: "要求の根拠の記録を変える {ops: [{op:\"add\", target?, source?, basis?, confirm?:{by, on}} | {op:\"edit\", id, target?, source?, basis?, confirm?} | {op:\"confirm\", id, by, on} | {op:\"remove\", id}], rev?}(CLI の p3 source と同じ。結果は {request, requirement})。" +
|
|
110
|
+
"確認には出典・根拠・確かめた人(役割名・アクター名)・YYYY-MM-DD の日が要る。題・本文・記録の内容が変わると確認は再確認が必要になる(元に戻しても戻らない)。" +
|
|
111
|
+
"規則に合わなければ 400 code: requirement_invalid、rev が違えば 409 rev_conflict(どちらも何も書かない)。要望の根拠・回答は評価対象に入る(変えるとその評価からは採用しない)",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
method: "POST",
|
|
115
|
+
path: "/api/requests/:rid/answers",
|
|
116
|
+
desc: "Preflight の確認事項(run の assessment.clarifications)に回答する {run, question, answer(null で消す), by?, on?, source?, basis?, links?: [根拠の記録の ID], rev?}(CLI の p3 answer と同じ)。" +
|
|
117
|
+
"回答は要望の clarifyAnswers に残し、過去の run は書き換えない。回答しただけでは根拠の記録を確認記録ありにしない。再評価は別に明示して始める",
|
|
50
118
|
},
|
|
51
119
|
{
|
|
52
120
|
method: "PATCH",
|
|
@@ -62,8 +130,23 @@ export const AI_MANIFEST = {
|
|
|
62
130
|
"重複・無い要望・直下の子でない・足りないは 409 code: child_order_invalid(reason・ids・今の並び children。子が変わっていれば読み直す)、rev が違えば 409 code: rev_conflict。" +
|
|
63
131
|
"表示の順で、実行の順・着手できるかは表さない",
|
|
64
132
|
},
|
|
65
|
-
{ method: "GET|POST", path: "/api/requests/:rid/tasks", desc: "
|
|
66
|
-
{ method: "GET|PATCH|DELETE", path: "/api/requests/:rid/tasks/:tid", desc: "タスク(GET は置き換えの印 superseded
|
|
133
|
+
{ method: "GET|POST", path: "/api/requests/:rid/tasks", desc: "要望のタスク(GET の ?blocked=true で止まっているものだけ(status・area・q と AND)。POST の criteria: [文] で受け入れ基準を付ける(ID は p3 が振る)。対応済の要望に未完了のタスクを足すと進行中に戻し reopened を返す。対応済の祖先も戻して reopenedAncestors、完了済の祖先は warnings の ancestor_done)" },
|
|
134
|
+
{ method: "GET|PATCH|DELETE", path: "/api/requests/:rid/tasks/:tid", desc: "タスク(GET は置き換えの印 superseded と受け入れ基準の状態 acceptance(不足 shortfalls。基準なしは null)も返す。PATCH は rev で楽観ロック、null で項目を消す。置き換えられたタスクを作業中にすると warnings を添える。" +
|
|
135
|
+
"受け入れ基準・証拠は PATCH の acceptance: [{op: add|edit|remove|order|record|unrecord|source, ...}] で順に当て(source は {op:\"source\", id: 基準の ID, source: 要求の根拠への操作}。POST sources と同じ操作で、from で要望の記録を写す)、規則に合わなければ何も書かず 400 code: acceptance_invalid。" +
|
|
136
|
+
"record の basis は根拠 {kind: unverified|declaration} / {kind: read, reference} / {kind: machine, command, result, target}(作業した側の申告。P3 は検査を実行しない)。" +
|
|
137
|
+
"省くと同じ結果の前の証拠の根拠を引き継ぎ、無ければ unverified は未確認・ほかは申告のみ。met / unmet に未確認、unverified にほかの根拠は付けられない。" +
|
|
138
|
+
"acceptance には根拠ごとの met の件数 metByBasis と申告のみの基準 declarationOnly も入る。" +
|
|
139
|
+
"済みのタスクの基準・証拠の中身が変わると済みを外し checkCleared を返す。" +
|
|
140
|
+
"完了・済みにすると、そのときの条件の写しを completionRecords に追記する(要望の PATCH の対応済・完了済も同じ。記録の値は受け付けない。記録が読めず足せなければ completionSkipped)。" +
|
|
141
|
+
"GET は見直しの診断 review(完了したタスクだけ。state: no_record|unreadable|none|candidate、基点の record、reasons: [{code, target, was?, now?, related?}]。状態は変えない)も返す。" +
|
|
142
|
+
"止まっている理由(停止)は PATCH の blockOp: {op: set, reason, decision?}(作業中だけ。内容を直しても since は変えない)/ {op: clear, resolution}(解除。状態は変えない)で変え、" +
|
|
143
|
+
"日時・履歴は受け付けない。規則に合わなければ 400 block_invalid / block_not_doing、止まったまま未着手・完了へ動かすと 409 blocked(解除と移動を同じ PATCH に書けば一緒に保存する))" },
|
|
144
|
+
{
|
|
145
|
+
method: "GET",
|
|
146
|
+
path: "/api/requests/:rid/archived-tasks[/:tid]",
|
|
147
|
+
desc: "アーカイブしたタスク(読むだけ。各タスクに archived: true)。一覧は {request, tasks, errors}(ID の数値順。壊れたファイルは errors)、" +
|
|
148
|
+
"1件は {task}。無い → 404、読めない → 500 code: archive_unreadable。通常の tasks・進捗・対応済の判定には入らない。DELETE /tasks/:tid がアーカイブする",
|
|
149
|
+
},
|
|
67
150
|
{ method: "POST", path: "/api/requests/:rid/preflight", desc: "Preflight の実行 {engine?: codex|mock, note?: メモ}。前回の結果とまだ渡していないメモを引き継ぐ" },
|
|
68
151
|
{ method: "GET|POST", path: "/api/requests/:rid/notes", desc: "Preflight へのメモ(GET は渡し済みか・次に引き継ぐ前回の run も返す。POST {body})" },
|
|
69
152
|
{
|
|
@@ -103,7 +186,10 @@ export const AI_MANIFEST = {
|
|
|
103
186
|
{
|
|
104
187
|
method: "PATCH",
|
|
105
188
|
path: "/api/requests/:rid/preflight/:run/drafts/:key",
|
|
106
|
-
desc: "タスク案を直す {title?, description?, include?, repo?, expectedTitle?}。
|
|
189
|
+
desc: "タスク案を直す {title?, description?, include?, repo?, acceptanceCriteria?, expectedTitle?, expectedCriteria?}。" +
|
|
190
|
+
"acceptanceCriteria は受け入れ基準の並び全体 [{id?, text}](id は残し、無い項目に振る。空で基準なし)で、expectedCriteria(編集を始めたときの基準)が要る。違えば 409 rev_conflict。" +
|
|
191
|
+
"sourceOps: 基準ごとの要求の根拠への操作 [{id: 基準の ID, source: 上の sources と同じ操作(add は from: 要望の記録の ID で写せる)}]。expectedSources(編集を始めたときの acceptanceSources)が要り、違えば 409 rev_conflict。" +
|
|
192
|
+
"expectedTitle(編集を始めたときの題。制御用で案には書かない)を渡すと、" +
|
|
107
193
|
"案のファイルを読み直した今の題と比べ、違えば 409 code: rev_conflict(current に今の案)で書かない。画面から題を変えるときは必ず渡す",
|
|
108
194
|
},
|
|
109
195
|
{
|
|
@@ -153,6 +239,19 @@ export const AI_MANIFEST = {
|
|
|
153
239
|
path: "/api/release-generations/:id[/cancel]",
|
|
154
240
|
desc: "生成1件 {status: running|completed|failed|cancelled, failure?, items(文と出典), markdown(本文の案), warnings, materialChanged, log} / 取り消し",
|
|
155
241
|
},
|
|
242
|
+
{
|
|
243
|
+
method: "POST",
|
|
244
|
+
path: "/api/requests/:rid/tasks/:tid/review-preview",
|
|
245
|
+
desc: "タスクの AI レビューの今の材料の要約と hash {targets?, viewpoint?}(比較項目・作業した側の証拠の状態・比較対象・観点の出典・注意・engineRequired。何も書かない)",
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
method: "GET|POST",
|
|
249
|
+
path: "/api/requests/:rid/tasks/:tid/reviews",
|
|
250
|
+
desc: "タスクの AI レビューの履歴(新しい順。読めない記録も broken)/ 始める(202。{targets?, viewpoint?, engine?, expectedHash?}。完了したタスクだけ。" +
|
|
251
|
+
"材料が変わっていれば 409 material_changed、実行中なら 409 running、Preflight の担当が agent で engine を明示していなければ 400 engine_required)。結果はタスクの状態・済み・基準・証拠を変えない",
|
|
252
|
+
},
|
|
253
|
+
{ method: "GET", path: "/api/requests/:rid/tasks/:tid/reviews/:run", desc: "タスクの AI レビューの1回分(固定した材料・結果。実行中は所有者の状態 owner)。結果を直す口は無い" },
|
|
254
|
+
{ method: "POST", path: "/api/requests/:rid/tasks/:tid/reviews/:run/cancel", desc: "タスクの AI レビューを取り消す {acknowledgeStopped?}(マイルストーンレビューと同じ規則)" },
|
|
156
255
|
{ method: "GET", path: "/api/milestone-reviews", desc: "レビューの履歴のあるマイルストーン {milestones}(project.yaml に無い孤立も。履歴のあるマイルストーンは消せず ID も変えられない)" },
|
|
157
256
|
{ method: "GET", path: "/api/milestones/:mid/review-preview", desc: "マイルストーンレビューの今の材料(比較単位・目的・要望の件数と状態・参照先のコード・範囲・警告・hash)。何も書かない" },
|
|
158
257
|
{
|
|
@@ -24,7 +24,7 @@ export function milestoneReviewRoutes(ctx) {
|
|
|
24
24
|
return c.json({ error: err.message, code: err.code }, status);
|
|
25
25
|
}
|
|
26
26
|
if (err instanceof ReviewRejected) {
|
|
27
|
-
const status = err.code === "running" ? 409 : err.code === "unknown_milestone" ? 404 : 400;
|
|
27
|
+
const status = err.code === "running" || err.code === "material_changed" ? 409 : err.code === "unknown_milestone" ? 404 : 400;
|
|
28
28
|
return c.json({ error: err.message, code: err.code, ...(err.running ? { run: err.running } : {}) }, status);
|
|
29
29
|
}
|
|
30
30
|
if (err instanceof ReviewCancelRefused)
|
|
@@ -50,6 +50,7 @@ export function milestoneReviewRoutes(ctx) {
|
|
|
50
50
|
context: i.context.length,
|
|
51
51
|
code: i.code ?? [],
|
|
52
52
|
warnings: i.warnings,
|
|
53
|
+
...(i.quality ? { quality: { state: i.quality.state, version: i.quality.version, standards: (i.quality.standards ?? []).map((q) => ({ id: q.id, text: q.text, exempt: q.exempt?.reason })) } } : {}),
|
|
53
54
|
scope: i.scope,
|
|
54
55
|
hash: i.hash,
|
|
55
56
|
extractedAt: i.extractedAt,
|
|
@@ -57,8 +58,8 @@ export function milestoneReviewRoutes(ctx) {
|
|
|
57
58
|
});
|
|
58
59
|
app.get("/milestones/:mid/reviews", async (c) => c.json({ items: await svc().list(c.req.param("mid")) }));
|
|
59
60
|
app.post("/milestones/:mid/reviews", async (c) => {
|
|
60
|
-
const { engine } = z.object({ engine: z.enum(["codex", "mock"]).optional() }).parse(await c.req.json().catch(() => ({})));
|
|
61
|
-
return c.json(await svc().start(c.req.param("mid"), actorOf(c), engine), 202);
|
|
61
|
+
const { engine, expectedHash } = z.object({ engine: z.enum(["codex", "mock"]).optional(), expectedHash: z.string().optional() }).parse(await c.req.json().catch(() => ({})));
|
|
62
|
+
return c.json(await svc().start(c.req.param("mid"), actorOf(c), engine, { expectedHash }), 202);
|
|
62
63
|
});
|
|
63
64
|
app.get("/milestones/:mid/reviews/:run", async (c) => c.json(await svc().get(c.req.param("mid"), c.req.param("run"))));
|
|
64
65
|
app.post("/milestones/:mid/reviews/:run/cancel", async (c) => {
|