@infodb/p3 0.8.0 → 0.10.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 +4 -2
- package/dist/web/assets/{Outputs-CQi0oba1.js → Outputs-B4Tr7JzU.js} +1 -1
- package/dist/web/assets/{RequestStatus-grC0F_SQ.js → RequestStatus-DGaoQoIa.js} +1 -1
- package/dist/web/assets/{Tabs-BJRGzidj.js → Tabs-D16MqQxu.js} +1 -1
- package/dist/web/assets/{TagInput-cIIwXAHA.js → TagInput-pSYxm4bz.js} +1 -1
- package/dist/web/assets/{TaskDrawer-CSZ7Z0JC.js → TaskDrawer-1Ev3RpRV.js} +1 -1
- package/dist/web/assets/{_requestId-Z3CBhTIL.js → _requestId-BKhn019m.js} +1 -1
- package/dist/web/assets/_requestId-Btpvuu7-.js +30 -0
- package/dist/web/assets/{appCtx-DCiGJFAe.js → appCtx-D_Iaoh2e.js} +1 -1
- package/dist/web/assets/{board-DyfGX5h0.js → board-DeHdxbN4.js} +1 -1
- package/dist/web/assets/{directTask-Dk3H5Q2B.js → directTask-C1NWDkZp.js} +1 -1
- package/dist/web/assets/{done-Bhxqy7bH.js → done-BFaHGt03.js} +1 -1
- package/dist/web/assets/{index-Bt13tvIX.js → index-CDWcKy1L.js} +3 -3
- package/dist/web/assets/{new-BRsIUNIb.js → new-ChFzBoL2.js} +1 -1
- package/dist/web/assets/{preload-helper-B40dBmwL.js → preload-helper-hSId95YD.js} +1 -1
- package/dist/web/assets/{release-notes-C3FdiM36.js → release-notes-BWNDFDkH.js} +1 -1
- package/dist/web/assets/{requestData-w6fhCYmh.js → requestData-B_320uxL.js} +1 -1
- package/dist/web/assets/{routes-QNgQHe48.js → routes-BBD464IS.js} +1 -1
- package/dist/web/assets/{settings-CoKJahEe.js → settings-D7PPrGjT.js} +1 -1
- package/dist/web/index.html +3 -3
- package/docs/architecture.md +95 -6
- package/docs/development.md +21 -5
- package/docs/how-to-use.md +99 -1
- package/docs/installation.md +30 -12
- package/docs/publishing.md +5 -1
- package/lib/cli/args.js +5 -0
- package/lib/cli/help.js +10 -1
- package/lib/cli/main.js +12 -3
- package/lib/cli/preflightCommands.js +98 -3
- package/lib/cli/project.js +31 -8
- package/lib/core/context.js +1 -1
- package/lib/core/preflight/codexEngine.js +63 -220
- package/lib/core/preflight/codexImage.js +49 -19
- package/lib/core/preflight/docker.js +149 -0
- package/lib/core/preflight/instructions.js +263 -0
- package/lib/core/preflight/owner.js +118 -0
- package/lib/core/preflight/render-image/Dockerfile +1 -1
- package/lib/core/preflight/service.js +516 -84
- package/lib/core/preflight/uiRender.js +1 -1
- package/lib/core/projectRegistry.js +2 -1
- package/lib/core/store/dataWatcher.js +122 -0
- package/lib/core/store/normalize.js +9 -1
- package/lib/core/store/preflightStore.js +20 -2
- package/lib/core/store/projectFile.js +6 -1
- package/lib/core/store/workspace.js +20 -37
- package/lib/server/api/manifest.js +10 -1
- package/lib/server/api/routes.js +18 -5
- package/lib/server/server.js +3 -1
- package/lib/shared/directTask.js +2 -2
- package/lib/shared/preflightRunner.js +18 -0
- package/lib/shared/scopeView.js +3 -2
- package/package.json +2 -2
- package/skills/p3/SKILL.md +45 -7
- package/dist/web/assets/_requestId-C8WYk2kC.js +0 -30
package/lib/cli/main.js
CHANGED
|
@@ -13,7 +13,7 @@ import { codexCommand } from "./codex.js";
|
|
|
13
13
|
import { userConfigCommand } from "./userConfig.js";
|
|
14
14
|
import { chatgptCommand } from "./chatgpt.js";
|
|
15
15
|
import { table } from "./format.js";
|
|
16
|
-
import { config, currentRequest, init, isAgentChoice, joinProject, locateHere, placeAgents, projectCommand, repoCommand, repoRoot, resolveActor, UsageError } from "./project.js";
|
|
16
|
+
import { config, currentRequest, init, isAgentChoice, joinProject, locateHere, placeAgents, projectCommand, repoCommand, repoRoot, resolveActor, runnerText, UsageError } from "./project.js";
|
|
17
17
|
import { HELP } from "./help.js";
|
|
18
18
|
import { readsOnly } from "./readOnly.js";
|
|
19
19
|
import { parse } from "./args.js";
|
|
@@ -24,6 +24,7 @@ import { preflightCommand } from "./preflightCommands.js";
|
|
|
24
24
|
import { releaseNotesCommand } from "./releaseNotesCommands.js";
|
|
25
25
|
import { ReleaseNoteError } from "../core/releaseNotes/store.js";
|
|
26
26
|
import { sortMilestones } from "../shared/milestoneOrder.js";
|
|
27
|
+
import { isPreflightRunner, PREFLIGHT_RUNNERS, runnerView } from "../shared/preflightRunner.js";
|
|
27
28
|
import { GenerationRejected } from "../core/releaseNotes/generate.js";
|
|
28
29
|
/**
|
|
29
30
|
* p3 CLI。人も AI エージェントも使う。
|
|
@@ -109,7 +110,7 @@ async function main(argv) {
|
|
|
109
110
|
// 参加は個人設定に登録するだけ。AI 向けのファイルと、作るときだけの項目は受け付けない(黙って無視しない)
|
|
110
111
|
if (o.agents !== undefined)
|
|
111
112
|
throw new UsageError("join は AI 向けのファイルを置きません(--agents は使えません)。置く・最新にするなら p3 agents claude|codex|both");
|
|
112
|
-
const createOnly = ["name", "description", "instructions"].filter((k) => o[k] !== undefined);
|
|
113
|
+
const createOnly = ["name", "description", "instructions", "preflight-runner"].filter((k) => o[k] !== undefined);
|
|
113
114
|
if (createOnly.length)
|
|
114
115
|
throw new UsageError(`join では ${createOnly.map((k) => `--${k}`).join("・")} は使えません(共有の定義は変えません。変えるなら p3 config set)`);
|
|
115
116
|
if (args.length)
|
|
@@ -122,6 +123,9 @@ async function main(argv) {
|
|
|
122
123
|
throw new UsageError(`--agents は claude / codex / both のどれか(値を省くと both): ${o.agents || "(空)"}`);
|
|
123
124
|
if (args.length)
|
|
124
125
|
throw new UsageError(`init は位置引数を取りません: ${args.join(" ")}`);
|
|
126
|
+
const runner = o["preflight-runner"];
|
|
127
|
+
if (runner !== undefined && !isPreflightRunner(runner))
|
|
128
|
+
throw new UsageError(`--preflight-runner は ${PREFLIGHT_RUNNERS.join(" / ")} のどれか: ${runner || "(空)"}`);
|
|
125
129
|
console.log(await init({
|
|
126
130
|
cwd,
|
|
127
131
|
project: o.project,
|
|
@@ -129,6 +133,7 @@ async function main(argv) {
|
|
|
129
133
|
name: o.name,
|
|
130
134
|
description: o.description,
|
|
131
135
|
instructions: o.instructions,
|
|
136
|
+
runner,
|
|
132
137
|
agents: o.agents,
|
|
133
138
|
yes: o.yes,
|
|
134
139
|
repoName: o["repo-name"],
|
|
@@ -231,12 +236,16 @@ async function main(argv) {
|
|
|
231
236
|
}
|
|
232
237
|
case "whoami": {
|
|
233
238
|
const here = locateHere(ctx, cwd);
|
|
234
|
-
|
|
239
|
+
// Preflight の担当(AI 向けの手順が読む。読めなければ runner: null と problem。agent と推測しない)
|
|
240
|
+
const pf = runnerView(ctx.ws.project.preflight);
|
|
241
|
+
const preflight = { runner: pf.runner, source: pf.source, ...(pf.problem ? { problem: pf.problem } : {}) };
|
|
242
|
+
return out.result({ project: target.name ?? null, dataDir: target.dataDir, via: target.via, here: here.repos, branch: here.branch ?? null, actor, request: current ?? null, preflight }, () => [
|
|
235
243
|
`プロジェクト ${target.name ?? "(未登録)"} ${target.dataDir}`,
|
|
236
244
|
`決まり方 ${target.via}(${VIA_LABEL[target.via]})`,
|
|
237
245
|
`今いる参照先 ${here.repos.length ? here.repos.join(", ") : "(どの参照先の中でもない。p3 repo ls)"}${here.branch ? ` ブランチ ${here.branch}` : ""}`,
|
|
238
246
|
`変更者 ${actor}`,
|
|
239
247
|
`要望 ${current ? `${current} ${titleOf(ctx, current)}` : "(なし)"}`,
|
|
248
|
+
`Preflight ${runnerText(pf)}`,
|
|
240
249
|
].join("\n"));
|
|
241
250
|
}
|
|
242
251
|
case "progress": {
|
|
@@ -11,7 +11,7 @@ import { StaleInputError, staleMessage } from "../core/preflight/input.js";
|
|
|
11
11
|
import { changedLabel, isMaterialized } from "../shared/preflightInput.js";
|
|
12
12
|
import { readBody } from "./args.js";
|
|
13
13
|
import { deps, directTaskHint, indent } from "./output.js";
|
|
14
|
-
import { PreflightBusyError } from "../core/preflight/service.js";
|
|
14
|
+
import { LocalResultError, PreflightBusyError } from "../core/preflight/service.js";
|
|
15
15
|
import { preflightFailed } from "../shared/directTask.js";
|
|
16
16
|
/** Preflight のコマンド(preflight / attach / notes / drafts / accept)。扱わないコマンドは undefined */
|
|
17
17
|
export async function preflightCommand(cmd, env) {
|
|
@@ -25,6 +25,9 @@ export async function preflightCommand(cmd, env) {
|
|
|
25
25
|
throw new UsageError("--note-only には --note でメモを渡してください");
|
|
26
26
|
if (o["note-only"] && engine)
|
|
27
27
|
throw new UsageError("--note-only は実行しないので --engine は使えません");
|
|
28
|
+
const local = localMode(o);
|
|
29
|
+
if (local)
|
|
30
|
+
return localPreflight(env, rid, local);
|
|
28
31
|
const note = o.note === undefined ? undefined : await ctx.preflight.addNote(rid, readBody(o.note), actor);
|
|
29
32
|
if (o["note-only"])
|
|
30
33
|
return out.result(note, () => `メモ ${note.id} を書き足しました(次の Preflight に渡します)`);
|
|
@@ -124,7 +127,8 @@ export async function preflightCommand(cmd, env) {
|
|
|
124
127
|
// タスク化の前なら、置き換えられる既存タスクも見せる(分割の run には無い)
|
|
125
128
|
const supersedes = run.materialized?.length || run.children ? [] : (await ctx.preflight.previewMaterialize(rid, run.id)).candidates;
|
|
126
129
|
const inputMatch = await ctx.preflight.inputMatch(rid, run);
|
|
127
|
-
|
|
130
|
+
const next = runNext(rid, run);
|
|
131
|
+
return out.result({ ...run, inputMatch, supersedes, ...(next ? { next } : {}) }, () => [
|
|
128
132
|
formatRun(ctx, rid, run),
|
|
129
133
|
inputMatchLine(rid, run, inputMatch),
|
|
130
134
|
supersedes.length
|
|
@@ -170,6 +174,79 @@ export async function preflightCommand(cmd, env) {
|
|
|
170
174
|
}
|
|
171
175
|
return undefined;
|
|
172
176
|
}
|
|
177
|
+
/** 手元のエージェントの Preflight の操作(--prepare / --complete / --cancel)。どれでもなければ undefined。曖昧な組み合わせは何も書かずに断る */
|
|
178
|
+
function localMode(o) {
|
|
179
|
+
const modes = ["prepare", "complete", "cancel"].filter((m) => o[m]);
|
|
180
|
+
if (o["acknowledge-stopped"] && !o.cancel)
|
|
181
|
+
throw new UsageError("--acknowledge-stopped は --cancel --run <PF-...> と一緒に使います(止まっていることを確かめた run を中断にする)");
|
|
182
|
+
if (!modes.length) {
|
|
183
|
+
if (o.run !== undefined)
|
|
184
|
+
throw new UsageError("p3 preflight の --run は --complete / --cancel と一緒に使います(結果を見るなら p3 drafts <要望> --run <PF-...>)");
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
if (modes.length > 1)
|
|
188
|
+
throw new UsageError(`--${modes.join(" と --")} は一緒に使えません`);
|
|
189
|
+
const mode = modes[0];
|
|
190
|
+
if (o.engine !== undefined)
|
|
191
|
+
throw new UsageError(mode === "cancel" ? "--cancel に --engine は使えません(指定した run を中断します)" : `--${mode} は手元のエージェントの評価なので --engine は使えません`);
|
|
192
|
+
if (o["note-only"])
|
|
193
|
+
throw new UsageError(`--${mode} と --note-only は一緒に使えません`);
|
|
194
|
+
if (mode === "prepare" && o.run !== undefined)
|
|
195
|
+
throw new UsageError("--prepare は新しい run を作るので --run は使えません");
|
|
196
|
+
if (mode !== "prepare" && o.run === undefined) {
|
|
197
|
+
throw new UsageError(`--${mode} には --run <PF-...> で run を指定してください(${mode === "cancel" ? "p3 drafts <要望> の最新の run か、--prepare が返した ID" : "--prepare が返した ID"})`);
|
|
198
|
+
}
|
|
199
|
+
if (mode !== "prepare" && o.note !== undefined)
|
|
200
|
+
throw new UsageError(`--${mode} に --note は使えません(メモは次の Preflight に渡すものです)`);
|
|
201
|
+
return mode;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* 手元の対話エージェント(Claude Code など)での Preflight。P3 はモデルを呼ばない:
|
|
205
|
+
* --prepare 評価対象などを固定し、指示のファイルと成果物のパスを返して終わる(エージェントが指示を読んで成果物を書く)
|
|
206
|
+
* --complete 指定した run の成果物を確かめて取り込む(問題があれば何も確定せず、直してやり直せる)
|
|
207
|
+
* --cancel 指定した run を中断する(手元のエージェントの run も Codex / Mock の run も。cancelRun)
|
|
208
|
+
*/
|
|
209
|
+
async function localPreflight(env, rid, mode) {
|
|
210
|
+
const { ctx, out, o, actor } = env;
|
|
211
|
+
if (mode === "prepare") {
|
|
212
|
+
const note = o.note === undefined ? undefined : await ctx.preflight.addNote(rid, readBody(o.note), actor);
|
|
213
|
+
const p = await ctx.preflight.prepare(rid, { actor }).catch((e) => {
|
|
214
|
+
if (note)
|
|
215
|
+
e.message += `(メモ ${note.id} は保存済みです。書き直さずに p3 preflight ${rid} --prepare でやり直せます)`;
|
|
216
|
+
throw e;
|
|
217
|
+
});
|
|
218
|
+
const next = { complete: `p3 preflight ${rid} --complete --run ${p.run.id}`, cancel: `p3 preflight ${rid} --cancel --run ${p.run.id}` };
|
|
219
|
+
out.result({ request: rid, run: p.run.id, status: p.run.status, engine: p.run.engine, runDir: p.runDir, instructions: p.instructions, outputs: p.outputs, ...(note ? { note: note.id } : {}), next }, () => [
|
|
220
|
+
`preflight ${p.run.id} を準備しました(手元のエージェントの評価を待っています)`,
|
|
221
|
+
`指示: ${p.instructions}`,
|
|
222
|
+
`書く成果物(run のフォルダ ${p.runDir}/ の中だけ):`,
|
|
223
|
+
...p.outputs.map((x) => ` ${x}`),
|
|
224
|
+
`書き終えたら: ${next.complete}`,
|
|
225
|
+
`やめるなら: ${next.cancel}`,
|
|
226
|
+
].join("\n"));
|
|
227
|
+
return 0;
|
|
228
|
+
}
|
|
229
|
+
const runId = o.run;
|
|
230
|
+
if (mode === "cancel") {
|
|
231
|
+
// state: cancelled(中断した)/ requested(中断を頼んだ。まだ running。止まったら p3 drafts に出る)/ already(既に終わっている)
|
|
232
|
+
const r = await ctx.preflight.cancelRun(rid, runId, { acknowledgeStopped: o["acknowledge-stopped"], actor });
|
|
233
|
+
out.result({ ...r.run, state: r.state, message: r.message, already: r.state === "already" }, () => r.message);
|
|
234
|
+
return 0;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
const r = await ctx.preflight.complete(rid, runId);
|
|
238
|
+
const inputMatch = await ctx.preflight.inputMatch(rid, r.run);
|
|
239
|
+
out.result({ ...r.run, already: r.already, inputMatch }, () => [r.already ? `${runId} は取り込み済みです(何も変えていません)` : `${runId} を取り込みました`, formatRun(ctx, rid, r.run), inputMatchLine(rid, r.run, inputMatch)].join("\n"));
|
|
240
|
+
return 0;
|
|
241
|
+
}
|
|
242
|
+
catch (e) {
|
|
243
|
+
if (!(e instanceof LocalResultError) || !o.json)
|
|
244
|
+
throw e;
|
|
245
|
+
// --json では問題を機械可読で返す(終了コードは 1。run は評価を待ったまま)
|
|
246
|
+
out.result({ error: e.message, code: "invalid_result", request: rid, run: runId, problems: e.problems }, () => "");
|
|
247
|
+
return 1;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
173
250
|
/**
|
|
174
251
|
* 分割の run の採用: 選んだ子の案から子の要望を作る(子のタスク化・Preflight はしない)。途中で失敗したら作った・失敗・未実行を出し、
|
|
175
252
|
* 同じ accept でやり直せる(作った子は作り直さない)。終了コード: 全部作れたら 0、失敗があれば 1
|
|
@@ -207,6 +284,16 @@ async function adoptChildren(ctx, out, rid, run, only, skip, actor, json) {
|
|
|
207
284
|
.join("\n"));
|
|
208
285
|
return r.failed.length ? 1 : 0;
|
|
209
286
|
}
|
|
287
|
+
const NEXT_LABEL = { rerun: "始め直す", cancel: "中断する", acknowledge: "止まっていると確かめたら" };
|
|
288
|
+
/** run の状態から次に使うコマンド(drafts の表示と --json の next)。完了した run は無し */
|
|
289
|
+
function runNext(rid, run) {
|
|
290
|
+
if (run.status === "failed")
|
|
291
|
+
return { rerun: `p3 preflight ${rid}` };
|
|
292
|
+
if (run.status !== "running" || run.engine === "local")
|
|
293
|
+
return undefined;
|
|
294
|
+
const cancel = `p3 preflight ${rid} --cancel --run ${run.id}`;
|
|
295
|
+
return run.cancelRequested ? { acknowledge: `${cancel} --acknowledge-stopped` } : { cancel };
|
|
296
|
+
}
|
|
210
297
|
/** 評価対象と今の要望の比較(drafts の表示) */
|
|
211
298
|
function inputMatchLine(rid, run, m) {
|
|
212
299
|
if (m.status === "same")
|
|
@@ -230,6 +317,14 @@ function formatRun(ctx, rid, run) {
|
|
|
230
317
|
}
|
|
231
318
|
if (run.error)
|
|
232
319
|
lines.push(`エラー: ${run.error}`);
|
|
320
|
+
if (run.interrupted) {
|
|
321
|
+
lines.push(`中断: ${run.interrupted.at} ${run.interrupted.acknowledgedBy ? `止まっていることを ${run.interrupted.acknowledgedBy} が確かめた` : "実行していたプロセスが終わっていた"}(${run.interrupted.reason})`);
|
|
322
|
+
}
|
|
323
|
+
if (run.cancelRequested)
|
|
324
|
+
lines.push(`中断を頼んでいます: ${run.cancelRequested.at}${run.cancelRequested.by ? `(${run.cancelRequested.by})` : ""}。実行しているプロセスが止めるまで running のままです`);
|
|
325
|
+
const next = runNext(rid, run);
|
|
326
|
+
if (next)
|
|
327
|
+
lines.push(...Object.entries(next).map(([k, v]) => `${NEXT_LABEL[k]}: ${v}`));
|
|
233
328
|
const a = run.assessment;
|
|
234
329
|
if (a) {
|
|
235
330
|
lines.push("", `判定: ${a.verdict} 妥当性 ${a.validity.score} / 実現可能性 ${a.feasibility.score}`, indent(a.summary));
|
|
@@ -238,7 +333,7 @@ function formatRun(ctx, rid, run) {
|
|
|
238
333
|
if (a.questions.length)
|
|
239
334
|
lines.push("", "確認事項:", ...a.questions.map((x) => ` - ${x}`));
|
|
240
335
|
}
|
|
241
|
-
lines.push("", ...scopeLines(run.scope));
|
|
336
|
+
lines.push("", ...scopeLines(run.scope, { local: run.engine === "local" }));
|
|
242
337
|
if (a)
|
|
243
338
|
lines.push("", ...evidenceLines(a.evidence));
|
|
244
339
|
if (run.scope?.some((s) => s.status === "unregistered"))
|
package/lib/cli/project.js
CHANGED
|
@@ -13,6 +13,7 @@ import { repoNameProblem } from "../shared/repos.js";
|
|
|
13
13
|
import { addRepo, checkFolder, RepoAdminError, removeRepo, setLocalRepoPath, updateRepo } from "../core/repoAdmin.js";
|
|
14
14
|
import { normalizeProject } from "../core/store/normalize.js";
|
|
15
15
|
import { requestWorkstreams } from "../shared/workTarget.js";
|
|
16
|
+
import { DEFAULT_PREFLIGHT_RUNNER, isPreflightRunner, PREFLIGHT_RUNNERS, RUNNER_LABEL, runnerView } from "../shared/preflightRunner.js";
|
|
16
17
|
import { DATA_DIR_NAME } from "../core/store/locate.js";
|
|
17
18
|
import { sortMilestones } from "../shared/milestoneOrder.js";
|
|
18
19
|
import { loadUserConfig, PROJECT_NAME, setProjectNode, updateUserConfig, userConfigPath } from "../core/userConfig.js";
|
|
@@ -130,16 +131,18 @@ export function agentsSnippet(kinds) {
|
|
|
130
131
|
- 作業の単位は要望。タスクは \`p3\` CLI(入っていなければ \`pnpx @infodb/p3\`)で操作し、\`--json\` で結果を読むこと(データのフォルダを直接編集しない)。
|
|
131
132
|
詳しい手順はスキル ${skills}
|
|
132
133
|
- 変更するときは環境変数 \`P3_ACTOR=ai:<エージェント名>\` を付ける
|
|
133
|
-
- 操作する要望は \`--req <要望ID>\` で指定する(要望の作業ツリーの中なら省ける)。まず \`p3 whoami --json\`
|
|
134
|
+
- 操作する要望は \`--req <要望ID>\` で指定する(要望の作業ツリーの中なら省ける)。まず \`p3 whoami --json\` で確かめる(Preflight の担当 \`preflight.runner\` も出る)
|
|
134
135
|
- \`whoami\` の \`via\`(プロジェクトの決まり方)が \`cwd\` でなければ(\`dir\` / \`project\` / \`legacy\` / \`only\`)、それ以上 p3 を操作せず、対象のプロジェクトでよいか人に確かめる(推測した \`--project\` / \`--dir\` で避けない。人が指定・確認した後はその対象のまま続ける)
|
|
135
136
|
- プロジェクトが無い・未登録のときは \`p3 init\` / \`p3 join\` を自分から実行せず、新しく作る(\`init\`)のか共有されたものに参加する(\`join\`)のかを人に確かめる
|
|
136
137
|
- 新しい作業を頼まれたら \`p3 request new "<タイトル>" --body "..."\` で要望を登録し、ID を伝えて終える。
|
|
137
|
-
Preflight(\`preflight
|
|
138
|
+
Preflight(\`preflight\`)は自分から始めない(勧めない・尋ねない)。タスク化(\`accept\`)は人が行う(結果を \`p3 drafts\` で読むのと、頼まれたメモの保存 \`--note-only\` はよい)
|
|
139
|
+
- Preflight を頼まれたら、担当(\`whoami --json\` の \`preflight.runner\`)で分ける。\`codex\`: 人が \`p3 preflight\` か画面で実行する(AI は \`--prepare\` の無い \`p3 preflight\` をしない)。人がチャットで対象の要望の手元の評価を明示的に頼んだときだけ手元で評価し、「Preflight して」とだけなら、人が実行するのか手元で評価するのかを確かめる。\`agent\`: 人に「Preflight して」と頼まれたら手元で評価する(「このチャットで」は求めない)。\`null\`(読めない): \`agent\` と推測せず \`problem\` を伝え、\`codex\` と同じ扱い。子の要望も同じ。対象の要望が分からなければ確かめる
|
|
140
|
+
- 手元の評価: \`p3 preflight <要望ID> --prepare --json\` → 返った指示のファイル(\`instructions\`)を最後まで読み、書くのは返った run の成果物(\`outputs\`)だけ → \`p3 preflight <要望ID> --complete --run <run> --json\` → \`p3 drafts\` の結果を伝えて終える(自分から始めない。タスク化 \`accept\` と着手はしない)
|
|
138
141
|
- 着手する前に \`p3 show T003 --brief --json\` で本文・依存とその状態(\`dependencies\`)・置き換えの注意(\`warnings\`)を読む
|
|
139
142
|
- 着手する前に、\`--brief --json\` の \`work\`(作業先のリポジトリとブランチ)を見て、そのリポジトリでブランチに入る(作業先なしなら移動しない)
|
|
140
143
|
- 着手するときは \`p3 move T003 doing\`。テストを通したら、コミットする前に \`p3 move T003 done --output <今ある成果物(変えたファイルや説明)> --record -\` で完了にする(変更の記録は必須: 何を変えたか・なぜ・入れた決まり・やめたもの を標準入力から Markdown で。まだ無い URL は書かない)
|
|
141
144
|
- 要望のタスクを全部終えたら、コミットする前に \`p3 request set <要望ID> status=resolved\`(対応済)にする。完了済(done)・見送り(rejected)とタスクの済み(check)は人が決める
|
|
142
|
-
- 子の要望(\`parent\` のある要望)は、親とは別の要望として子ごとのタスクとブランチで作業する(親のタスクにしない)。分割の案の採用(\`accept
|
|
145
|
+
- 子の要望(\`parent\` のある要望)は、親とは別の要望として子ごとのタスクとブランチで作業する(親のタスクにしない)。分割の案の採用(\`accept\`)は人が行う。子の Preflight は親と同じ担当で、頼まれたときだけ(分割の採用・子の作成から自分で評価へ進まない)。親を対応済にするのは、親のタスクと見送り以外の子(\`request show <親> --brief --json\` の \`children\`)が全部終わってから
|
|
143
146
|
- データのフォルダがこの作業ツリーの中で git 管理されているなら、要望のフォルダ(\`requests/<要望ID>/\`)の変更も実装と同じコミットに入れる(後のレビューで要望とやったことを精査するため。子なら祖先の要望のフォルダ、親を対応済にするときは子孫の要望のフォルダ(見送りの子など)のまだ入っていない変更も入れ、ほかの要望・関係ない変更は入れない。外・無視・worktree のときは入らないので、移動や \`git add -f\` はしない)。push に失敗したら完了の記録は残し、公開できていないことを伝える。要望のフォルダは、マージするまで要望のブランチにしか無い。既定のブランチに切り替えると、その要望(子なら親の子の一覧からも)が消えたように見えるが、データはブランチにある(作り直したり、別のブランチから写したりしない)
|
|
144
147
|
- コミットや PR の URL は後から \`p3 move T003 done --output <URL>\` で足す(完了・記録はそのまま。データをコミットしているなら追記もコミットして push)。複数のリポジトリにまたがるときは最後のタスクに \`--repo-output <参照先>=<PR の URL>\` で全部の PR を残す
|
|
145
148
|
- 置き換えられたタスク(\`p3 ls\` の \`※置換\`、\`--json\` の \`superseded\`)からは始めない。\`move\` が \`warnings\` を返したら止めて人に確かめる
|
|
@@ -314,6 +317,11 @@ export async function init(o) {
|
|
|
314
317
|
return { path: d, role: "ドキュメント", ...(entry ? { entry } : {}) };
|
|
315
318
|
});
|
|
316
319
|
const instructions = await ask("Preflight で重視する観点・制約(任意)", o.instructions ?? "");
|
|
320
|
+
// 担当: codex は人が p3 から実行する(Codex と ChatGPT のプランが要る)。agent は Codex を使えない環境で、手元の AI エージェントに頼む
|
|
321
|
+
const runnerAnswer = o.runner ?? (await ask("Preflight を実行するのは(codex: 人が p3 から Codex で実行 / agent: 頼まれた手元の AI エージェントが評価)", DEFAULT_PREFLIGHT_RUNNER));
|
|
322
|
+
if (!isPreflightRunner(runnerAnswer))
|
|
323
|
+
throw new UsageError(`Preflight の担当は ${PREFLIGHT_RUNNERS.join(" / ")} のどれか: ${runnerAnswer}`);
|
|
324
|
+
const runner = runnerAnswer;
|
|
317
325
|
// 既にある AGENTS.md / CLAUDE.md からは推測しない(Enter は置かない)
|
|
318
326
|
let agents = o.agents;
|
|
319
327
|
if (agents === undefined && interactive) {
|
|
@@ -331,7 +339,7 @@ export async function init(o) {
|
|
|
331
339
|
repos: [{ name: refName, role: "本体", readFirst: true, writable: true, map }],
|
|
332
340
|
milestones: [],
|
|
333
341
|
branchPattern: "req/{id}-{slug}",
|
|
334
|
-
preflight: { instructions },
|
|
342
|
+
preflight: { instructions, runner },
|
|
335
343
|
};
|
|
336
344
|
await mkdir(join(dir, "requests"), { recursive: true });
|
|
337
345
|
await writeProjectFile(join(dir, "project.yaml"), cfg);
|
|
@@ -343,9 +351,12 @@ export async function init(o) {
|
|
|
343
351
|
` 参照先 ${refName}(本体) → ${root}`,
|
|
344
352
|
` 主なフォルダ ${map.map((m) => m.path).join(", ") || "(なし。設定画面で足せます)"}`,
|
|
345
353
|
` 個人設定 ${userConfigPath()} に登録しました`,
|
|
354
|
+
` Preflight ${runner}(${RUNNER_LABEL[runner]}。変える: p3 config set preflight.runner=${runner === "codex" ? "agent" : "codex"})`,
|
|
346
355
|
...agentLines,
|
|
347
356
|
"",
|
|
348
|
-
|
|
357
|
+
runner === "agent"
|
|
358
|
+
? "次に: p3 request new \"<やりたいこと>\" --body \"...\" → 手元の AI エージェントに「要望 <要望ID> の Preflight をして」と頼む → p3 serve"
|
|
359
|
+
: "次に: p3 request new \"<やりたいこと>\" --body \"...\" → p3 preflight <要望ID> → p3 serve",
|
|
349
360
|
cfg.description ? "" : "※ description が空です。p3 config set description=\"...\" で設定してください(Preflight の精度に効きます)",
|
|
350
361
|
]
|
|
351
362
|
.filter((l, i, a) => l !== "" || (i > 0 && a[i - 1] !== ""))
|
|
@@ -498,7 +509,7 @@ export async function projectCommand(cwd, args, o, current) {
|
|
|
498
509
|
/** 入力されたパス。対話式の入力ではシェルが ~ を展開しないので、ここで展開する */
|
|
499
510
|
export const resolvePath = (cwd, p) => resolve(cwd, p === "~" ? homedir() : p.startsWith("~/") ? join(homedir(), p.slice(2)) : p);
|
|
500
511
|
const slugifyName = (s) => s.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^[-._]+|-+$/g, "") || undefined;
|
|
501
|
-
const CONFIG_KEYS = ["name", "description", "branchPattern", "instructions"];
|
|
512
|
+
const CONFIG_KEYS = ["name", "description", "branchPattern", "instructions", "preflight.runner"];
|
|
502
513
|
/** p3 config [set key=value ...] */
|
|
503
514
|
export async function config(ws, args) {
|
|
504
515
|
if (args[0] === "set") {
|
|
@@ -510,7 +521,12 @@ export async function config(ws, args) {
|
|
|
510
521
|
if (eq < 1 || !CONFIG_KEYS.includes(key))
|
|
511
522
|
throw new UsageError(`設定できるキー: ${CONFIG_KEYS.join(", ")}`);
|
|
512
523
|
if (key === "instructions")
|
|
513
|
-
patch.preflight = { instructions: value };
|
|
524
|
+
patch.preflight = { ...patch.preflight, instructions: value };
|
|
525
|
+
else if (key === "preflight.runner") {
|
|
526
|
+
if (!isPreflightRunner(value))
|
|
527
|
+
throw new UsageError(`preflight.runner は ${PREFLIGHT_RUNNERS.join(" / ")} のどれか: ${value || "(空)"}`);
|
|
528
|
+
patch.preflight = { ...patch.preflight, runner: value };
|
|
529
|
+
}
|
|
514
530
|
else if (key === "branchPattern" && !value.includes("{id}"))
|
|
515
531
|
throw new UsageError("branchPattern には {id} を含めてください");
|
|
516
532
|
else if (key === "name" && !value)
|
|
@@ -532,10 +548,17 @@ export async function config(ws, args) {
|
|
|
532
548
|
`milestones ${sortMilestones(p.milestones).map((m) => `${m.id}${m.due ? `(${m.due})` : ""}${m.done ? "[済]" : ""}`).join(", ") || "(なし)"}`,
|
|
533
549
|
`branchPattern ${p.branchPattern}`,
|
|
534
550
|
`instructions ${p.preflight.instructions || "(なし)"}`,
|
|
551
|
+
`preflight.runner ${runnerText(runnerView(p.preflight))}`,
|
|
535
552
|
"",
|
|
536
553
|
`ファイル: ${join(ws.dataDir, "project.yaml")}`,
|
|
537
554
|
].join("\n");
|
|
538
|
-
return { data: p, text };
|
|
555
|
+
return { data: { ...p, preflightRunner: runnerView(p.preflight) }, text };
|
|
556
|
+
}
|
|
557
|
+
/** 担当の表示(config・whoami)。読めない値は理由を出す */
|
|
558
|
+
export function runnerText(v) {
|
|
559
|
+
if (!v.runner)
|
|
560
|
+
return `(読めません)${v.problem}`;
|
|
561
|
+
return `${v.runner}(${RUNNER_LABEL[v.runner]}${v.source === "default" ? "。未設定なので既定" : ""})`;
|
|
539
562
|
}
|
|
540
563
|
function splitList(s) {
|
|
541
564
|
return s.split(",").map((x) => x.trim()).filter(Boolean);
|
package/lib/core/context.js
CHANGED
|
@@ -34,7 +34,7 @@ export async function openProject(dataDir, opts = {}) {
|
|
|
34
34
|
const preflight = new PreflightService(ws, engines, {
|
|
35
35
|
initial: initial?.preflight.engine ?? "codex",
|
|
36
36
|
load: async () => (await source.get()).preflight.engine,
|
|
37
|
-
});
|
|
37
|
+
}, { pathMap: async () => (await source.get()).codex.pathMap });
|
|
38
38
|
// 要約の生成も Preflight と同じ接続と既定のエンジン(preflight.engine)を使う
|
|
39
39
|
const releaseGenerator = new ReleaseGenerator(ws, { codex, mock: new MockSummarizer() }, { engine: async () => (await source.get()).preflight.engine });
|
|
40
40
|
return { ws, preflight, releaseGenerator, chatgpt, projectName: opts.projectName };
|