@infodb/p3 0.13.0 → 0.14.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 +1 -0
- package/bin/p3.mjs +3 -2
- package/dist/web/assets/{CompletionReview-gZKZrDu_.js → CompletionReview-BD7d6Yzt.js} +1 -1
- package/dist/web/assets/ImprovementDialog-BoAZN1KR.js +1 -0
- package/dist/web/assets/{Outputs-BgHalMGb.js → Outputs-D-ZouoxF.js} +1 -1
- package/dist/web/assets/{RequestStatus-hZcBUUIu.js → RequestStatus-Bl3fdSbM.js} +1 -1
- package/dist/web/assets/{Tabs-C3NmwCc3.js → Tabs-CxeceOL-.js} +1 -1
- package/dist/web/assets/{TagInput-B2b862qn.js → TagInput-CeAbmGRR.js} +1 -1
- package/dist/web/assets/TaskDrawer-BCriSnhe.js +6 -0
- package/dist/web/assets/_requestId-CZKMe_mC.js +1 -0
- package/dist/web/assets/_requestId-Fx4lLkFo.js +1 -0
- package/dist/web/assets/appCtx-BdxbkSZa.js +1 -0
- package/dist/web/assets/archive-D5IIxcSV.js +1 -0
- package/dist/web/assets/board-p6R9KMqd.js +1 -0
- package/dist/web/assets/done-BTOF188x.js +1 -0
- package/dist/web/assets/{draft-BvGxfD7v.js → draft-BWYpm3PD.js} +2 -2
- package/dist/web/assets/index-DFbY8NAR.css +2 -0
- package/dist/web/assets/index-Dpqi2dcC.js +12 -0
- package/dist/web/assets/link-D481whDt.js +1 -0
- package/dist/web/assets/metrics-CAzP6V8I.js +1 -0
- package/dist/web/assets/new-C65IJJg3.js +1 -0
- package/dist/web/assets/preload-helper-_dAYMct_.js +1 -0
- package/dist/web/assets/{release-notes-Bpdi6RdY.js → release-notes-Dtif8xsQ.js} +4 -4
- package/dist/web/assets/{requestData-CbFxwW5w.js → requestData-SPc36t8Q.js} +1 -1
- package/dist/web/assets/routes-DJj8CWuk.js +6 -0
- package/dist/web/assets/settings-DKJd7CLe.js +1 -0
- package/dist/web/assets/ui-CbEOnPnF.js +1 -0
- package/dist/web/assets/{workTarget-CySfKyfB.js → workTarget-DavxMs-c.js} +3 -3
- package/dist/web/index.html +6 -4
- package/docs/architecture.md +165 -71
- package/docs/chatgpt-sign-in.md +2 -2
- package/docs/development.md +87 -54
- package/docs/feature-inventory.md +139 -0
- package/docs/how-to-use.md +10 -5
- package/docs/installation.md +31 -8
- package/docs/publishing.md +32 -13
- package/docs/refactoring.md +332 -0
- package/lib/cli/agentsStatus.js +2 -1
- package/lib/cli/guide.md +4 -1
- package/lib/cli/help.js +1 -1
- package/lib/cli/main.js +33 -238
- package/lib/cli/project.js +21 -267
- package/lib/core/projectRegistry.js +2 -2
- package/lib/kit/appInfo.js +13 -0
- package/lib/kit/usage.js +27 -0
- package/lib/server/api/projectsRoutes.js +5 -5
- package/lib/server/server.js +7 -4
- package/lib/{cli → tasks/cli}/args.js +2 -2
- package/lib/{cli → tasks/cli}/chatgpt.js +1 -1
- package/lib/{cli → tasks/cli}/codex.js +1 -1
- package/lib/{cli → tasks/cli}/output.js +2 -2
- package/lib/{cli → tasks/cli}/preflightCommands.js +1 -1
- package/lib/tasks/cli/readOnly.js +75 -0
- package/lib/{cli → tasks/cli}/render.js +1 -1
- package/lib/{cli → tasks/cli}/requestCommands.js +6 -6
- package/lib/{cli → tasks/cli}/showView.js +4 -4
- package/lib/{cli → tasks/cli}/taskCommands.js +16 -8
- package/lib/tasks/cli/tasksCli.js +149 -0
- package/lib/{core → tasks/core}/context.js +6 -9
- package/lib/tasks/core/errorOutcome.js +125 -0
- package/lib/{core → tasks/core}/hierarchy.js +1 -1
- package/lib/{core → tasks/core}/ops.js +6 -4
- package/lib/{core → tasks/core}/preflight/codexEngine.js +2 -11
- package/lib/{core → tasks/core}/preflight/hostPaths.js +39 -0
- package/lib/{core → tasks/core}/preflight/input.js +1 -1
- package/lib/{core → tasks/core}/preflight/instructions.js +2 -2
- package/lib/{core → tasks/core}/preflight/mockEngine.js +8 -7
- package/lib/{core → tasks/core}/preflight/service.js +38 -13
- package/lib/{core → tasks/core}/preflight/uiRender.js +2 -2
- package/lib/{core → tasks/core}/requestOps.js +19 -14
- package/lib/{core → tasks/core}/reviewRuns.js +127 -22
- package/lib/{core → tasks/core}/store/attachments.js +3 -2
- package/lib/{core → tasks/core}/store/collection.js +2 -2
- package/lib/tasks/core/store/fieldGroups.js +30 -0
- package/lib/tasks/core/store/jsonRecord.js +30 -0
- package/lib/{core → tasks/core}/store/normalize.js +13 -26
- package/lib/{core → tasks/core}/store/noteStore.js +2 -2
- package/lib/{core → tasks/core}/store/preflightStore.js +44 -21
- package/lib/{core → tasks/core}/store/projectFile.js +1 -1
- package/lib/{core → tasks/core}/store/workspace.js +11 -5
- package/lib/{core → tasks/core}/userConfig.js +1 -1
- package/lib/{core → tasks/core}/workTargets.js +1 -1
- package/lib/{cli → tasks/features/metrics/cli}/metricsCommands.js +3 -3
- package/lib/{core/metrics → tasks/features/metrics/core}/definitions.js +19 -8
- package/lib/{core/metrics → tasks/features/metrics/core}/index.js +41 -17
- package/lib/{core/metrics → tasks/features/metrics/core}/manual.js +27 -28
- package/lib/tasks/features/metrics/server/metricsRoutes.js +8 -0
- package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/code.js +2 -11
- package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/material.js +5 -6
- package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/review.js +2 -2
- package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/service.js +38 -100
- package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/store.js +3 -3
- package/lib/{server/api → tasks/features/milestoneReview/server}/milestoneReviewRoutes.js +7 -13
- package/lib/{cli → tasks/features/quality/cli}/qualityCommands.js +3 -3
- package/lib/{core → tasks/features/quality/core}/qualityImprovement.js +16 -15
- package/lib/{cli → tasks/features/records/cli}/revisitCommands.js +2 -2
- package/lib/{core → tasks/features/records/core}/reviewCandidates.js +26 -6
- package/lib/{shared → tasks/features/records/shared}/completionRecord.js +5 -3
- package/lib/{shared → tasks/features/records/shared}/reviewCandidate.js +13 -8
- package/lib/{shared → tasks/features/records/shared}/reworkHistory.js +5 -0
- package/lib/{cli → tasks/features/releaseNotes/cli}/releaseNotesCommands.js +7 -7
- package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/completeRequests.js +5 -6
- package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/generate.js +3 -14
- package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/material.js +3 -4
- package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/service.js +1 -1
- package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/store.js +2 -2
- package/lib/{server/api → tasks/features/releaseNotes/server}/releaseNoteRoutes.js +11 -20
- package/lib/{cli → tasks/features/requirements/cli}/requirementCommands.js +8 -7
- package/lib/{shared → tasks/features/requirements/shared}/acceptance.js +41 -7
- package/lib/{cli → tasks/features/retro/cli}/retroCommands.js +1 -1
- package/lib/{core → tasks/features/retro/core}/retrospective.js +42 -53
- package/lib/tasks/features/settings/cli/projectSettings.js +245 -0
- package/lib/{cli → tasks/features/settings/cli}/userConfig.js +5 -5
- package/lib/{core → tasks/features/settings/core}/machineSettingsEdit.js +2 -2
- package/lib/{core → tasks/features/settings/core}/repoAdmin.js +3 -3
- package/lib/{core → tasks/features/settings/core}/userTheme.js +2 -2
- package/lib/{server/api → tasks/features/settings/server}/repoRoutes.js +2 -2
- package/lib/{server/api → tasks/features/settings/server}/userThemeRoutes.js +3 -3
- package/lib/{cli → tasks/features/taskReview/cli}/taskReviewCommands.js +5 -5
- package/lib/{core/taskReview → tasks/features/taskReview/core}/material.js +7 -8
- package/lib/{core/taskReview → tasks/features/taskReview/core}/review.js +2 -2
- package/lib/{core/taskReview → tasks/features/taskReview/core}/service.js +24 -85
- package/lib/{core/taskReview → tasks/features/taskReview/core}/store.js +4 -4
- package/lib/{server/api → tasks/features/taskReview/server}/taskReviewRoutes.js +7 -14
- package/lib/{server → tasks/server}/api/routes.js +24 -75
- package/lib/tasks/shared/commitRefs.js +10 -0
- package/package.json +1 -44
- package/dist/web/assets/ImprovementDialog-Dno6dPnG.js +0 -1
- package/dist/web/assets/TaskDrawer-4BQBELXa.js +0 -6
- package/dist/web/assets/_requestId-BMAG1t3o.js +0 -1
- package/dist/web/assets/_requestId-tbg2pA2S.js +0 -1
- package/dist/web/assets/archive-DMl6WyOe.js +0 -1
- package/dist/web/assets/board-BMTcHKyt.js +0 -1
- package/dist/web/assets/done-CL6Nlsua.js +0 -1
- package/dist/web/assets/index-Dp7Fc4VI.css +0 -2
- package/dist/web/assets/index-KdlgMitg.js +0 -12
- package/dist/web/assets/metrics-Cu7gJ7Rk.js +0 -1
- package/dist/web/assets/new-DTXWHuFO.js +0 -1
- package/dist/web/assets/preload-helper-oLCrNCwz.js +0 -1
- package/dist/web/assets/routes-BIt8bExF.js +0 -6
- package/dist/web/assets/settings-CsCqF_1B.js +0 -1
- package/dist/web/assets/ui-BGK72r3u.js +0 -1
- package/lib/cli/readOnly.js +0 -53
- /package/lib/{core/store → kit}/frontmatter.js +0 -0
- /package/lib/{core/store → kit}/fsutil.js +0 -0
- /package/lib/{cli → tasks/cli}/format.js +0 -0
- /package/lib/{core → tasks/core}/chatgpt.js +0 -0
- /package/lib/{core → tasks/core}/machineSettings.js +0 -0
- /package/lib/{core → tasks/core}/preflight/carryover.js +0 -0
- /package/lib/{core → tasks/core}/preflight/codexImage.js +0 -0
- /package/lib/{core → tasks/core}/preflight/diagnose.js +0 -0
- /package/lib/{core → tasks/core}/preflight/docker.js +0 -0
- /package/lib/{core → tasks/core}/preflight/engine.js +0 -0
- /package/lib/{core → tasks/core}/preflight/launch.js +0 -0
- /package/lib/{core → tasks/core}/preflight/launcher.mjs +0 -0
- /package/lib/{core → tasks/core}/preflight/mock-ui.html +0 -0
- /package/lib/{core → tasks/core}/preflight/mock-ui.png +0 -0
- /package/lib/{core → tasks/core}/preflight/owner.js +0 -0
- /package/lib/{core → tasks/core}/preflight/render-image/Dockerfile +0 -0
- /package/lib/{core → tasks/core}/preflight/render-image/fonts-ja.conf +0 -0
- /package/lib/{core → tasks/core}/preflight/render-image/render.mjs +0 -0
- /package/lib/{core → tasks/core}/preflight/render.js +0 -0
- /package/lib/{core → tasks/core}/preflight/split.js +0 -0
- /package/lib/{core → tasks/core}/preflight/uiMaterials.js +0 -0
- /package/lib/{core → tasks/core}/preflight/wireframe.js +0 -0
- /package/lib/{core → tasks/core}/preflight/xlsx.js +0 -0
- /package/lib/{core → tasks/core}/redact.js +0 -0
- /package/lib/{core → tasks/core}/repoRefs.js +0 -0
- /package/lib/{core → tasks/core}/requestStatus.js +0 -0
- /package/lib/{core → tasks/core}/store/archivedTasks.js +0 -0
- /package/lib/{core → tasks/core}/store/dataWatcher.js +0 -0
- /package/lib/{core → tasks/core}/store/locate.js +0 -0
- /package/lib/{core → tasks/core}/supersede.js +0 -0
- /package/lib/{shared → tasks/features/metrics/shared}/metrics.js +0 -0
- /package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/mockReviewer.js +0 -0
- /package/lib/{shared → tasks/features/milestoneReview/shared}/milestoneReview.js +0 -0
- /package/lib/{core → tasks/features/quality/core}/quality.js +0 -0
- /package/lib/{shared → tasks/features/quality/shared}/quality.js +0 -0
- /package/lib/{shared → tasks/features/quality/shared}/qualityImprovement.js +0 -0
- /package/lib/{shared → tasks/features/quality/shared}/qualityTemplates.js +0 -0
- /package/lib/{core → tasks/features/records/core}/completionRefs.js +0 -0
- /package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/mockSummarizer.js +0 -0
- /package/lib/{shared → tasks/features/requirements/shared}/requirementSource.js +0 -0
- /package/lib/{shared → tasks/features/retro/shared}/retrospective.js +0 -0
- /package/lib/{core/taskReview → tasks/features/taskReview/core}/mockReviewer.js +0 -0
- /package/lib/{core/taskReview → tasks/features/taskReview/core}/paths.js +0 -0
- /package/lib/{shared → tasks/features/taskReview/shared}/taskReview.js +0 -0
- /package/lib/{server → tasks/server}/api/chatgptRoutes.js +0 -0
- /package/lib/{server → tasks/server}/api/local.js +0 -0
- /package/lib/{server → tasks/server}/api/manifest.js +0 -0
- /package/lib/{shared → tasks/shared}/dates.js +0 -0
- /package/lib/{shared → tasks/shared}/directTask.js +0 -0
- /package/lib/{shared → tasks/shared}/hierarchy.js +0 -0
- /package/lib/{shared → tasks/shared}/milestoneGoals.js +0 -0
- /package/lib/{shared → tasks/shared}/milestoneOrder.js +0 -0
- /package/lib/{shared → tasks/shared}/preflightInput.js +0 -0
- /package/lib/{shared → tasks/shared}/preflightRunner.js +0 -0
- /package/lib/{shared → tasks/shared}/refs.js +0 -0
- /package/lib/{shared → tasks/shared}/repos.js +0 -0
- /package/lib/{shared → tasks/shared}/scopeView.js +0 -0
- /package/lib/{shared → tasks/shared}/tags.js +0 -0
- /package/lib/{shared → tasks/shared}/taskBlock.js +0 -0
- /package/lib/{shared → tasks/shared}/types.js +0 -0
- /package/lib/{shared → tasks/shared}/workTarget.js +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { apiError } from "../../../core/errorOutcome.js";
|
|
1
2
|
import { Hono } from "hono";
|
|
2
3
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { completeMilestoneRequests, CompletionRejected } from "../../core/releaseNotes/completeRequests.js";
|
|
4
|
+
import { exportReleaseNote, releaseNoteDetail, releaseOverview, saveReleaseNote, startGeneration } from "../core/service.js";
|
|
5
|
+
import { ReleaseNoteError } from "../core/store.js";
|
|
6
|
+
import { completeMilestoneRequests } from "../core/completeRequests.js";
|
|
7
7
|
/**
|
|
8
8
|
* リリースノート(画面のため)。規則と保存は core/releaseNotes(CLI の p3 release-notes と同じ)。
|
|
9
9
|
*
|
|
@@ -29,25 +29,16 @@ const saveInput = z.object({
|
|
|
29
29
|
const actorOf = (c) => c.req.header("x-p3-actor") ?? "human:web";
|
|
30
30
|
export function releaseNoteRoutes(ctx) {
|
|
31
31
|
const app = new Hono();
|
|
32
|
+
// エラーの状態と code は core/errorOutcome.ts の表。版の競合・既にあるときは今のノート(読めれば)を添える(画面は入力を残したまま見比べる)
|
|
32
33
|
app.onError(async (err, c) => {
|
|
33
|
-
if (err instanceof ReleaseNoteError) {
|
|
34
|
-
const mid = err.milestone;
|
|
35
|
-
if (err.code === "not_found")
|
|
36
|
-
return c.json({ error: err.message, code: "not_found" }, 404);
|
|
37
|
-
if (err.code === "bad_id")
|
|
38
|
-
return c.json({ error: err.message, code: "bad_id" }, 400);
|
|
39
|
-
if (err.code === "invalid")
|
|
40
|
-
return c.json({ error: err.message, code: "invalid" }, 422);
|
|
41
|
-
// 版の競合・既にある: 今のノート(読めれば)を添える。画面は入力を残したまま見比べる
|
|
42
|
-
const current = await ctx.ws.releaseNotes.read(mid).catch(() => null);
|
|
43
|
-
return c.json({ error: err.message, code: "rev_conflict", reason: err.code, current }, 409);
|
|
44
|
-
}
|
|
45
|
-
if (err instanceof CompletionRejected)
|
|
46
|
-
return c.json({ error: err.message, code: err.code, plan: err.plan }, 409);
|
|
47
|
-
if (err instanceof GenerationRejected)
|
|
48
|
-
return c.json({ error: err.message, code: err.code }, err.code === "running" ? 409 : 400);
|
|
49
34
|
if (err instanceof z.ZodError)
|
|
50
35
|
return c.json({ error: "invalid input", issues: err.issues }, 400);
|
|
36
|
+
const r = apiError(err);
|
|
37
|
+
if (r) {
|
|
38
|
+
if (err instanceof ReleaseNoteError && (err.code === "conflict" || err.code === "exists"))
|
|
39
|
+
r.body.current = await ctx.ws.releaseNotes.read(err.milestone).catch(() => null);
|
|
40
|
+
return c.json(r.body, r.status);
|
|
41
|
+
}
|
|
51
42
|
console.error(err);
|
|
52
43
|
return c.json({ error: err.message }, 400);
|
|
53
44
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { resolve as resolvePath } from "node:path";
|
|
3
3
|
import { ANSWER_STATE_LABEL, clarificationStates, criteriaSourceView, requestRequirementView, RequirementInputError, SOURCE_STATE_LABEL, } from "../shared/requirementSource.js";
|
|
4
|
-
import { resolveRequestId } from "
|
|
5
|
-
import { saveClarifyAnswer, updateRequirement, updateTask } from "
|
|
6
|
-
import { NotFoundError } from "
|
|
7
|
-
import { pickRun } from "
|
|
8
|
-
import { UsageError } from "
|
|
9
|
-
import { formatRequirement, sourceLines } from "
|
|
4
|
+
import { resolveRequestId } from "../../../core/ops.js";
|
|
5
|
+
import { saveClarifyAnswer, updateRequirement, updateTask } from "../../../core/requestOps.js";
|
|
6
|
+
import { NotFoundError } from "../../../core/store/collection.js";
|
|
7
|
+
import { pickRun } from "../../../cli/preflightCommands.js";
|
|
8
|
+
import { UsageError } from "../../../../kit/usage.js";
|
|
9
|
+
import { formatRequirement, sourceLines } from "../../../cli/showView.js";
|
|
10
10
|
/**
|
|
11
11
|
* 要求の根拠(出典・確かめた人・日・根拠)と、Preflight の確認事項への回答のコマンド(規則は shared/requirementSource.ts)。
|
|
12
12
|
*
|
|
@@ -18,7 +18,8 @@ import { formatRequirement, sourceLines } from "./showView.js";
|
|
|
18
18
|
* answer [<要望>] <Q> --body 回答|- [...] 確認事項に回答する(要望に残す。過去の run は書き換えない)
|
|
19
19
|
* answer [<要望>] <Q> rm 回答を消す
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
/** source の操作の語(対象・基準の ID と見分ける。読むだけの判定 readOnly.ts も使う) */
|
|
22
|
+
export const SOURCE_SUBS = new Set(["ls", "show", "add", "edit", "set", "confirm", "rm", "remove"]);
|
|
22
23
|
/** 標準入力(-)は1つの項目にだけ */
|
|
23
24
|
function readText(v, flag, used) {
|
|
24
25
|
if (v === undefined)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applySourceOps, criterionSubject, readCriterionSources, RequirementInputError, settleSources, sourcesKey } from "./requirementSource.js";
|
|
1
|
+
import { applySourceOps, criterionSubject, readCriterionSources, RequirementInputError, settleSources, sourceSeq, sourcesKey } from "./requirementSource.js";
|
|
2
2
|
/**
|
|
3
3
|
* タスクの受け入れ基準(acceptanceCriteria)と、作業した側が項目ごとに残す証拠(acceptanceEvidence)の規則。
|
|
4
4
|
* CLI・API・画面で同じものを使う(保存は core/requestOps.ts の createTask / updateTask がこれで確かめる)。
|
|
@@ -49,7 +49,7 @@ export const EVIDENCE_BASIS_HINT = {
|
|
|
49
49
|
};
|
|
50
50
|
export const BASIS_LIMITS = { reference: 1000, command: 1000, result: 2000, target: 300 };
|
|
51
51
|
/** ファイルに書く基準・証拠の項目(壊れていたら元の値のまま書き戻す) */
|
|
52
|
-
export const ACCEPTANCE_KEYS = ["acceptanceCriteria", "acceptanceEvidence", "acceptanceSeq", "acceptanceSources"];
|
|
52
|
+
export const ACCEPTANCE_KEYS = ["acceptanceCriteria", "acceptanceEvidence", "acceptanceSeq", "acceptanceSources", "acceptanceSourceSeq"];
|
|
53
53
|
/** 直接編集で書いたものも読めるよう、A<番号> 以外の英数字の id も受け付ける。新しく振るのは A<番号> だけ */
|
|
54
54
|
export const CRITERION_ID_RE = /^[A-Za-z0-9._-]{1,32}$/;
|
|
55
55
|
/** 入力が規則に合わない(何も書いていない)。CLI は使い方の誤り、API は 400 */
|
|
@@ -138,10 +138,30 @@ export function readAcceptance(d) {
|
|
|
138
138
|
const sources = readCriterionSources(d.acceptanceSources, problems);
|
|
139
139
|
if (sources)
|
|
140
140
|
out.acceptanceSources = sources;
|
|
141
|
+
const sourceSeqValue = readSourceSeq(d.acceptanceSourceSeq, problems);
|
|
142
|
+
if (sourceSeqValue !== undefined)
|
|
143
|
+
out.acceptanceSourceSeq = sourceSeqValue;
|
|
141
144
|
if (problems.length)
|
|
142
145
|
out.acceptanceProblems = problems;
|
|
143
146
|
return out;
|
|
144
147
|
}
|
|
148
|
+
/** 根拠に振った最後の番号(acceptanceSourceSeq)を読む。無ければ undefined、読めなければ problems に理由 */
|
|
149
|
+
export function readSourceSeq(v, problems) {
|
|
150
|
+
if (v === undefined || v === null)
|
|
151
|
+
return undefined;
|
|
152
|
+
const n = Number(v);
|
|
153
|
+
if (Number.isInteger(n) && n >= 0)
|
|
154
|
+
return n;
|
|
155
|
+
problems.push("acceptanceSourceSeq が読めません");
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 基準ごとの根拠の次の番号の起点(振った最後の番号): 保存した番号・今ある記録・floor(旧データの完了の記録の写しに残る番号など)の最大。
|
|
160
|
+
* 消して記録にも写しにも残っていない番号は分からない(使い直しうる)
|
|
161
|
+
*/
|
|
162
|
+
export function lastSourceSeq(s, floor = 0) {
|
|
163
|
+
return sourceSeq(s.acceptanceSources ?? [], Math.max(s.acceptanceSourceSeq ?? 0, floor));
|
|
164
|
+
}
|
|
145
165
|
/** ファイルの根拠を読む(読めなければ理由の文) */
|
|
146
166
|
function readBasis(v) {
|
|
147
167
|
try {
|
|
@@ -243,6 +263,7 @@ export function applyAcceptanceOps(state, ops, at) {
|
|
|
243
263
|
let evidence = [...(state.acceptanceEvidence ?? [])];
|
|
244
264
|
let sources = [...(state.acceptanceSources ?? [])];
|
|
245
265
|
let seq = lastSeq(state);
|
|
266
|
+
let sourceSeqNow = lastSourceSeq(state, at.sourceSeqFloor);
|
|
246
267
|
const subjectOf = (s) => {
|
|
247
268
|
const c = criteria.find((x) => x.id === s.criterionId);
|
|
248
269
|
return c ? criterionSubject(c.text) : undefined;
|
|
@@ -327,7 +348,9 @@ export function applyAcceptanceOps(state, ops, at) {
|
|
|
327
348
|
throw new AcceptanceInputError(`${c.id} に根拠の記録 ${target} はありません${sources.some((x) => x.criterionId === c.id) ? `(${sources.filter((x) => x.criterionId === c.id).map((x) => x.id).join(", ")})` : ""}`);
|
|
328
349
|
}
|
|
329
350
|
try {
|
|
330
|
-
|
|
351
|
+
const r = applySourceOps(sources, [op.source], { now: at.now, actor: at.actor, subjectOf, requestSources: at.requestSources ?? [], criterionId: c.id, seq: sourceSeqNow });
|
|
352
|
+
sources = r.list;
|
|
353
|
+
sourceSeqNow = r.seq;
|
|
331
354
|
}
|
|
332
355
|
catch (e) {
|
|
333
356
|
if (e instanceof RequirementInputError)
|
|
@@ -347,8 +370,16 @@ export function applyAcceptanceOps(state, ops, at) {
|
|
|
347
370
|
acceptanceEvidence: evidence.length ? evidence : undefined,
|
|
348
371
|
acceptanceSeq: seq > 0 ? seq : undefined,
|
|
349
372
|
acceptanceSources: sources.length ? sources : undefined,
|
|
373
|
+
acceptanceSourceSeq: sourceSeqNow > 0 ? sourceSeqNow : undefined,
|
|
350
374
|
};
|
|
351
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* 旧データの根拠の採番の下限: 完了の記録の写し(acceptance.sources)に残る番号。採番を保存する前のタスクで、消した記録の番号を
|
|
378
|
+
* 使い直さないため(写しにも残っていない番号は分からない)
|
|
379
|
+
*/
|
|
380
|
+
export const recordedSourceSeq = (records) => (records ?? []).reduce((n, r) => sourceSeq(r.acceptance?.sources ?? [], n), 0);
|
|
381
|
+
/** 採番(基準・根拠の振った最後の番号)が変わったか。中身(acceptanceChanged)とは別に保存するかを決める */
|
|
382
|
+
export const acceptanceSeqChanged = (a, b) => (a.acceptanceSeq ?? 0) !== (b.acceptanceSeq ?? 0) || (a.acceptanceSourceSeq ?? 0) !== (b.acceptanceSourceSeq ?? 0);
|
|
352
383
|
/** 保存した根拠の比較の鍵(項目の順によらない) */
|
|
353
384
|
const basisKey = (b) => (b ? JSON.stringify(Object.entries(b).sort(([x], [y]) => x.localeCompare(y))) : "");
|
|
354
385
|
const sameBasis = (a, b) => basisKey(a) === basisKey(b);
|
|
@@ -548,7 +579,7 @@ export const sameSources = (a, b) => sourcesKey(a) === sourcesKey(b);
|
|
|
548
579
|
* タスク案の基準からタスクの基準を作る(案の ID を残し、振った最後の番号を引き継ぐ)。要求の根拠の記録も写す: 要望の記録を参照した
|
|
549
580
|
* 記録(from)は、採用するときの要望の記録の内容を写し直す(内容が変われば確認は再確認が必要になる。要望の確認は引き継がない)
|
|
550
581
|
*/
|
|
551
|
-
export function criteriaForTask(criteria, sources, requestSources, now = new Date().toISOString()) {
|
|
582
|
+
export function criteriaForTask(criteria, sources, requestSources, now = new Date().toISOString(), sourceSeqSaved) {
|
|
552
583
|
if (!criteria?.length)
|
|
553
584
|
return {};
|
|
554
585
|
const ids = new Set(criteria.map((c) => c.id));
|
|
@@ -566,18 +597,21 @@ export function criteriaForTask(criteria, sources, requestSources, now = new Dat
|
|
|
566
597
|
return c ? criterionSubject(c.text) : undefined;
|
|
567
598
|
};
|
|
568
599
|
const settled = settleSources(copied, subjectOf, now);
|
|
600
|
+
// 根拠の番号は案で振った最後の番号を引き継ぐ(写さなかった記録・案で消した記録の番号も使い直さない)
|
|
601
|
+
const lastSource = lastSourceSeq({ acceptanceSources: [...(sources ?? [])], acceptanceSourceSeq: sourceSeqSaved });
|
|
569
602
|
return {
|
|
570
603
|
acceptanceCriteria: criteria.map((c) => ({ ...c })),
|
|
571
604
|
acceptanceSeq: lastSeq({ acceptanceCriteria: [...criteria] }) || undefined,
|
|
572
605
|
...(settled.length ? { acceptanceSources: settled } : {}),
|
|
606
|
+
...(lastSource > 0 ? { acceptanceSourceSeq: lastSource } : {}),
|
|
573
607
|
};
|
|
574
608
|
}
|
|
575
609
|
/**
|
|
576
610
|
* タスク案の基準ごとの要求の根拠への操作を当てる(案の基準の文を対象にする)。規則に合わなければ AcceptanceInputError
|
|
577
611
|
*/
|
|
578
|
-
export function applyDraftSourceOps(criteria, sources, ops, at) {
|
|
579
|
-
const next = applyAcceptanceOps({ acceptanceCriteria: [...(criteria ?? [])], acceptanceSources: [...(sources ?? [])] }, ops.map((o) => ({ op: "source", ...o })), at);
|
|
580
|
-
return next.acceptanceSources ?? [];
|
|
612
|
+
export function applyDraftSourceOps(criteria, sources, ops, at, sourceSeqSaved) {
|
|
613
|
+
const next = applyAcceptanceOps({ acceptanceCriteria: [...(criteria ?? [])], acceptanceSources: [...(sources ?? [])], acceptanceSourceSeq: sourceSeqSaved }, ops.map((o) => ({ op: "source", ...o })), at);
|
|
614
|
+
return { sources: next.acceptanceSources ?? [], seq: next.acceptanceSourceSeq ?? 0 };
|
|
581
615
|
}
|
|
582
616
|
/** タスク案の基準を直した後の根拠の記録(文を変えた基準の確認は効かなくなる。消した基準の記録は対応先不明として残す) */
|
|
583
617
|
export function settleDraftSources(criteria, sources, now) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { ADOPTION_KIND_LABEL, EVIDENCE_CHECK_LABEL, isRiskState, RETRO_EVIDENCE_LABEL, RISK_STATE_LABEL, RISK_STATES, } from "../shared/retrospective.js";
|
|
3
3
|
import { confirmRetrospectiveTarget, judgeRisk, retrospectiveView } from "../core/retrospective.js";
|
|
4
|
-
import { UsageError } from "
|
|
4
|
+
import { UsageError } from "../../../../kit/usage.js";
|
|
5
5
|
/**
|
|
6
6
|
* 要望の振り返り(Preflight で心配したリスクが実装の後に起きたか)のコマンド(規則は shared/retrospective.ts)。
|
|
7
7
|
*
|
|
@@ -1,35 +1,45 @@
|
|
|
1
|
-
import { readFile } from "node:fs/promises";
|
|
2
1
|
import { join } from "node:path";
|
|
3
|
-
import { reworkLine } from "
|
|
2
|
+
import { reworkLine } from "../../records/shared/reworkHistory.js";
|
|
3
|
+
/** タスク(今かアーカイブ)の手戻りの履歴の 1 件(根拠を保存するときと、保存した根拠を照らすときで同じ引き方) */
|
|
4
|
+
const reworkEntry = (t, id) => t?.reworkHistory?.find((e) => e.id === id);
|
|
4
5
|
import { addJudgment, assessmentVersion, JUDGMENT_LIMITS, latestJudgment, MILESTONE_REVIEW_SECTIONS, riskCounts, TASK_REVIEW_SECTIONS, confirmTarget, currentTarget, readRetrospective, retroCandidates, RetrospectiveError, } from "../shared/retrospective.js";
|
|
5
|
-
import { getArchivedTask, listArchivedTasks } from "
|
|
6
|
-
import { NotFoundError } from "
|
|
7
|
-
import { withFileLock
|
|
6
|
+
import { getArchivedTask, listArchivedTasks } from "../../../core/store/archivedTasks.js";
|
|
7
|
+
import { NotFoundError } from "../../../core/store/collection.js";
|
|
8
|
+
import { withFileLock } from "../../../../kit/fsutil.js";
|
|
9
|
+
import { readJsonRecord, writeJsonRecord } from "../../../core/store/jsonRecord.js";
|
|
8
10
|
/**
|
|
9
11
|
* 要望の振り返りの保存と読み取り(規則は shared/retrospective.ts)。記録は requests/<要望ID>/retrospective.json で、要望のロック
|
|
10
12
|
* (requestLock。要望・タスクの保存と同じ)の中で、読み直してから版を照らして書く。読み取りはファイルを書かない
|
|
11
13
|
*/
|
|
12
14
|
export const RETRO_FILE = "retrospective.json";
|
|
13
15
|
const pathOf = (ctx, rid) => join(ctx.ws.requestsDir, rid, RETRO_FILE);
|
|
14
|
-
/**
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
/** 記録を読む(無ければ空。JSON として読めなければ retro_unreadable、ほかの読めない理由はそのまま投げる) */
|
|
17
|
+
export function loadRetrospective(ctx, rid) {
|
|
18
|
+
return readJsonRecord(pathOf(ctx, rid), {
|
|
19
|
+
missing: () => ({ version: 0, targets: [] }),
|
|
20
|
+
invalidJson: (m) => {
|
|
21
|
+
throw new RetrospectiveError("retro_unreadable", `retrospective.json が JSON として読めません: ${m}(ファイルを直してください)`);
|
|
22
|
+
},
|
|
23
|
+
shape: readRetrospective,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 記録を変える(確定・訂正・リスクの確認で共通)。要望のロックの中で、要望があること(アーカイブで移した後のフォルダに書き戻さない)を確かめ、
|
|
28
|
+
* 読み直して版を照らし(違えば retro_conflict)、change が返した記録を置き換えで書く。書いた後に変更を知らせ、今の表示を返す
|
|
29
|
+
*/
|
|
30
|
+
async function changeRetrospective(ctx, rid, expectedVersion, change) {
|
|
31
|
+
ctx.ws.requests.require(rid);
|
|
32
|
+
await withFileLock(ctx.ws.requestLock(rid), async () => {
|
|
33
|
+
if ("missing" in (await ctx.ws.requests.peek(rid)))
|
|
34
|
+
throw new NotFoundError(rid);
|
|
35
|
+
const file = await loadRetrospective(ctx, rid);
|
|
36
|
+
if (expectedVersion !== undefined && expectedVersion !== file.version) {
|
|
37
|
+
throw new RetrospectiveError("retro_conflict", `振り返りの記録が他で変わりました(版 ${expectedVersion} → ${file.version})。読み直してからやり直してください`);
|
|
38
|
+
}
|
|
39
|
+
await writeJsonRecord(pathOf(ctx, rid), await change(file));
|
|
40
|
+
}, { busyMessage: "別のプロセスがこの要望を保存中です。少し待ってやり直してください" });
|
|
41
|
+
ctx.ws.emit({ type: "changed", kind: "request", request: rid });
|
|
42
|
+
return retrospectiveView(ctx, rid);
|
|
33
43
|
}
|
|
34
44
|
/** 候補(新しい順)。runs と照らすタスク・子の要望はディスクと読み込んだ値から */
|
|
35
45
|
export async function retrospectiveCandidates(ctx, rid) {
|
|
@@ -99,7 +109,7 @@ export async function resolveEvidence(ctx, rid, ref) {
|
|
|
99
109
|
const t = await taskOf(ctx, rid, ref.task);
|
|
100
110
|
if (!t)
|
|
101
111
|
throw bad(`${rid}/${ref.task} はこの要望のタスクにありません`);
|
|
102
|
-
const h = t
|
|
112
|
+
const h = reworkEntry(t, ref.history);
|
|
103
113
|
if (!h)
|
|
104
114
|
throw bad(`${t.id} の手戻りの履歴に ${ref.history} はありません`);
|
|
105
115
|
return { kind: "rework", request: rid, task: t.id, history: h.id, excerpt: clip(reworkLine(h)) };
|
|
@@ -149,7 +159,7 @@ export async function checkEvidence(ctx, e) {
|
|
|
149
159
|
if (e.kind === "manual")
|
|
150
160
|
return "manual";
|
|
151
161
|
if (e.kind === "rework")
|
|
152
|
-
return (await taskOf(ctx, e.request, e.task)
|
|
162
|
+
return reworkEntry(await taskOf(ctx, e.request, e.task), e.history) ? "ok" : "missing";
|
|
153
163
|
const rec = e.kind === "task_review" ? await ctx.ws.taskReviews.get(`${e.request}/${e.task}`, e.run).catch(() => undefined) : await ctx.ws.milestoneReviews.get(e.milestone, e.run).catch(() => undefined);
|
|
154
164
|
if (!rec?.result)
|
|
155
165
|
return "missing";
|
|
@@ -160,40 +170,22 @@ export async function checkEvidence(ctx, e) {
|
|
|
160
170
|
* expectedVersion が違えば retro_conflict、規則に合わない・範囲外の根拠は retro_invalid(どちらも何も書かない)
|
|
161
171
|
*/
|
|
162
172
|
export async function judgeRisk(ctx, rid, input, opts = {}) {
|
|
163
|
-
ctx.
|
|
164
|
-
await withFileLock(ctx.ws.requestLock(rid), async () => {
|
|
165
|
-
if ("missing" in (await ctx.ws.requests.peek(rid)))
|
|
166
|
-
throw new NotFoundError(rid);
|
|
167
|
-
const file = await loadRetrospective(ctx, rid);
|
|
168
|
-
if (opts.expectedVersion !== undefined && opts.expectedVersion !== file.version) {
|
|
169
|
-
throw new RetrospectiveError("retro_conflict", `振り返りの記録が他で変わりました(版 ${opts.expectedVersion} → ${file.version})。読み直してからやり直してください`);
|
|
170
|
-
}
|
|
173
|
+
return changeRetrospective(ctx, rid, opts.expectedVersion, async (file) => {
|
|
171
174
|
const evidence = [];
|
|
172
175
|
for (const ref of input.evidence)
|
|
173
176
|
evidence.push(await resolveEvidence(ctx, rid, ref));
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}, { busyMessage: "別のプロセスがこの要望を保存中です。少し待ってやり直してください" });
|
|
177
|
-
ctx.ws.emit({ type: "changed", kind: "request", request: rid });
|
|
178
|
-
return retrospectiveView(ctx, rid);
|
|
177
|
+
return addJudgment(file, { ...input, evidence }, { now: new Date().toISOString(), actor: opts.actor });
|
|
178
|
+
});
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
181
|
* 振り返りの対象を確定する(訂正は理由つきで追記)。expectedVersion が今の版と違えば retro_conflict、候補でない・評価が無いなどは
|
|
182
182
|
* retro_invalid(どちらも何も書かない)
|
|
183
183
|
*/
|
|
184
184
|
export async function confirmRetrospectiveTarget(ctx, rid, input, opts = {}) {
|
|
185
|
-
ctx.
|
|
186
|
-
await withFileLock(ctx.ws.requestLock(rid), async () => {
|
|
187
|
-
// ロックの中で要望があることを確かめる(アーカイブで移した後のフォルダに書き戻さない)
|
|
188
|
-
if ("missing" in (await ctx.ws.requests.peek(rid)))
|
|
189
|
-
throw new NotFoundError(rid);
|
|
190
|
-
const file = await loadRetrospective(ctx, rid);
|
|
191
|
-
if (opts.expectedVersion !== undefined && opts.expectedVersion !== file.version) {
|
|
192
|
-
throw new RetrospectiveError("retro_conflict", `振り返りの記録が他で変わりました(版 ${opts.expectedVersion} → ${file.version})。読み直してからやり直してください`);
|
|
193
|
-
}
|
|
185
|
+
return changeRetrospective(ctx, rid, opts.expectedVersion, async (file) => {
|
|
194
186
|
const { candidates, none, runs } = await retrospectiveCandidates(ctx, rid);
|
|
195
187
|
const runOf = (id) => runs.find((r) => r.id === id);
|
|
196
|
-
|
|
188
|
+
return confirmTarget(file, input, {
|
|
197
189
|
candidates,
|
|
198
190
|
none,
|
|
199
191
|
risksOf: (id) => runOf(id)?.assessment?.risks,
|
|
@@ -201,8 +193,5 @@ export async function confirmRetrospectiveTarget(ctx, rid, input, opts = {}) {
|
|
|
201
193
|
now: new Date().toISOString(),
|
|
202
194
|
actor: opts.actor,
|
|
203
195
|
});
|
|
204
|
-
|
|
205
|
-
}, { busyMessage: "別のプロセスがこの要望を保存中です。少し待ってやり直してください" });
|
|
206
|
-
ctx.ws.emit({ type: "changed", kind: "request", request: rid });
|
|
207
|
-
return retrospectiveView(ctx, rid);
|
|
196
|
+
});
|
|
208
197
|
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { userInfo } from "node:os";
|
|
2
|
+
import { join, relative, resolve } from "node:path";
|
|
3
|
+
import { REQUEST_ID } from "../../../shared/refs.js";
|
|
4
|
+
import { resolveRequestId } from "../../../core/ops.js";
|
|
5
|
+
import { repoNameProblem } from "../../../shared/repos.js";
|
|
6
|
+
import { addRepo, checkFolder, RepoAdminError, removeRepo, setLocalRepoPath, updateRepo } from "../core/repoAdmin.js";
|
|
7
|
+
import { requestWorkstreams } from "../../../shared/workTarget.js";
|
|
8
|
+
import { isPreflightRunner, PREFLIGHT_RUNNERS, RUNNER_LABEL, runnerView } from "../../../shared/preflightRunner.js";
|
|
9
|
+
import { sortMilestones } from "../../../shared/milestoneOrder.js";
|
|
10
|
+
import { git, resolvePath, UsageError } from "../../../../kit/usage.js";
|
|
11
|
+
/**
|
|
12
|
+
* tasks のプロジェクトの設定と作業の文脈(CLI): 変更者・今いる参照先・今の要望の判定、p3 config・p3 repo(project.yaml の共有の定義と
|
|
13
|
+
* このマシンのパス)。プロジェクトの登録・参加・AI 向けの入口は入口の project.ts
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* CLI の変更者。明示(--actor / P3_ACTOR。AI は ai:<名前>)→ human:<git の user.name> → OS のユーザー名。
|
|
17
|
+
*/
|
|
18
|
+
export function resolveActor(explicit, cwd) {
|
|
19
|
+
if (explicit)
|
|
20
|
+
return explicit;
|
|
21
|
+
return `human:${git(cwd, "config", "user.name") ?? process.env.USER ?? userInfo().username}`;
|
|
22
|
+
}
|
|
23
|
+
/** 今いる場所が、どの参照先(リポジトリ・フォルダ)か。参照先の中か、その git のリポジトリの作業ツリーの中なら当たる */
|
|
24
|
+
export function locateHere(ctx, cwd) {
|
|
25
|
+
const here = resolve(cwd);
|
|
26
|
+
const common = git(here, "rev-parse", "--path-format=absolute", "--git-common-dir");
|
|
27
|
+
const repos = ctx.ws
|
|
28
|
+
.refs()
|
|
29
|
+
.filter((r) => r.status === "ok" && r.local)
|
|
30
|
+
.filter((r) => {
|
|
31
|
+
if (inside(here, r.local))
|
|
32
|
+
return true;
|
|
33
|
+
// 要望の作業ツリーの中: 参照先と同じ git のリポジトリで、作業ツリーの中の同じ場所(サブフォルダなら同じ相対位置)より下
|
|
34
|
+
if (!common)
|
|
35
|
+
return false;
|
|
36
|
+
const theirs = git(r.local, "rev-parse", "--path-format=absolute", "--git-common-dir");
|
|
37
|
+
if (theirs !== common)
|
|
38
|
+
return false;
|
|
39
|
+
const top = git(here, "rev-parse", "--show-toplevel");
|
|
40
|
+
const theirTop = git(r.local, "rev-parse", "--show-toplevel");
|
|
41
|
+
return !!top && !!theirTop && inside(here, join(top, relative(theirTop, r.local)));
|
|
42
|
+
})
|
|
43
|
+
.map((r) => r.name);
|
|
44
|
+
const branch = common ? git(here, "symbolic-ref", "--quiet", "--short", "HEAD") : undefined;
|
|
45
|
+
return { repos, branch };
|
|
46
|
+
}
|
|
47
|
+
const inside = (path, dir) => path === dir || path.startsWith(dir.endsWith("/") ? dir : `${dir}/`);
|
|
48
|
+
/**
|
|
49
|
+
* 今の要望。明示(--req / P3_REQUEST)→ 今いる参照先のブランチ(その参照先の割当だけと照らす)→
|
|
50
|
+
* ブランチ名に要望 ID が入っている(detached HEAD などで決まらなければ --req で指定してもらう)。
|
|
51
|
+
* パスに要望 ID が入っているだけでは決めない。候補が複数なら --req を案内する。
|
|
52
|
+
* AI が要望の作業ツリーで作業していれば、`p3 new "..."` だけでその要望のタスクになる。
|
|
53
|
+
*/
|
|
54
|
+
export function currentRequest(ctx, explicit, cwd) {
|
|
55
|
+
if (explicit) {
|
|
56
|
+
const id = resolveRequestId(ctx, explicit);
|
|
57
|
+
if (!id)
|
|
58
|
+
throw new UsageError(`要望が見つかりません: ${explicit}`);
|
|
59
|
+
return id;
|
|
60
|
+
}
|
|
61
|
+
const { repos: hereRepos, branch } = locateHere(ctx, cwd);
|
|
62
|
+
const requests = ctx.ws.requests.list();
|
|
63
|
+
const pick = (ids, why) => {
|
|
64
|
+
const uniq = [...new Set(ids)];
|
|
65
|
+
if (uniq.length > 1)
|
|
66
|
+
throw new UsageError(`${why}が複数の要望に当たります: ${uniq.join(", ")}。--req <要望ID> で指定してください`);
|
|
67
|
+
return uniq[0];
|
|
68
|
+
};
|
|
69
|
+
if (branch) {
|
|
70
|
+
// 今いる参照先の割当だけと照らす(別のリポジトリの同じ名前のブランチと取り違えない)。参照先の外なら全部と照らす
|
|
71
|
+
const byBranch = requests
|
|
72
|
+
.filter((r) => Object.entries(requestWorkstreams(r)).some(([name, w]) => w.branch === branch && (!hereRepos.length || hereRepos.includes(name))))
|
|
73
|
+
.map((r) => r.id);
|
|
74
|
+
const hit = pick(byBranch, `ブランチ ${branch} `);
|
|
75
|
+
if (hit)
|
|
76
|
+
return hit;
|
|
77
|
+
}
|
|
78
|
+
if (branch) {
|
|
79
|
+
const m = new RegExp(REQUEST_ID.source.slice(1, -1)).exec(branch);
|
|
80
|
+
if (m && ctx.ws.requests.get(m[0]))
|
|
81
|
+
return m[0];
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const CONFIG_KEYS = ["name", "description", "branchPattern", "instructions", "preflight.runner"];
|
|
86
|
+
/** p3 config [set key=value ...] */
|
|
87
|
+
export async function config(ws, args) {
|
|
88
|
+
if (args[0] === "set") {
|
|
89
|
+
const patch = {};
|
|
90
|
+
for (const pair of args.slice(1)) {
|
|
91
|
+
const eq = pair.indexOf("=");
|
|
92
|
+
const key = pair.slice(0, eq);
|
|
93
|
+
const value = pair.slice(eq + 1).trim();
|
|
94
|
+
if (eq < 1 || !CONFIG_KEYS.includes(key))
|
|
95
|
+
throw new UsageError(`設定できるキー: ${CONFIG_KEYS.join(", ")}`);
|
|
96
|
+
if (key === "instructions")
|
|
97
|
+
patch.preflight = { ...patch.preflight, instructions: value };
|
|
98
|
+
else if (key === "preflight.runner") {
|
|
99
|
+
if (!isPreflightRunner(value))
|
|
100
|
+
throw new UsageError(`preflight.runner は ${PREFLIGHT_RUNNERS.join(" / ")} のどれか: ${value || "(空)"}`);
|
|
101
|
+
patch.preflight = { ...patch.preflight, runner: value };
|
|
102
|
+
}
|
|
103
|
+
else if (key === "branchPattern" && !value.includes("{id}"))
|
|
104
|
+
throw new UsageError("branchPattern には {id} を含めてください");
|
|
105
|
+
else if (key === "name" && !value)
|
|
106
|
+
throw new UsageError(`${key} は空にできません`);
|
|
107
|
+
else
|
|
108
|
+
patch[key] = value;
|
|
109
|
+
}
|
|
110
|
+
if (!Object.keys(patch).length)
|
|
111
|
+
throw new UsageError("p3 config set キー=値 ...");
|
|
112
|
+
const next = await ws.saveProject(patch);
|
|
113
|
+
const keys = args.slice(1).map((p) => p.slice(0, p.indexOf("=")));
|
|
114
|
+
return { data: next, text: `更新しました: ${keys.join(", ")}` };
|
|
115
|
+
}
|
|
116
|
+
const p = ws.project;
|
|
117
|
+
const text = [
|
|
118
|
+
`name ${p.name}`,
|
|
119
|
+
`description ${p.description || "(なし)"}`,
|
|
120
|
+
`repos ${p.repos.map((r) => r.name).join(", ") || "(なし)"} (p3 repo ls)`,
|
|
121
|
+
`milestones ${sortMilestones(p.milestones).map((m) => `${m.id}${m.due ? `(${m.due})` : ""}${m.done ? "[済]" : ""}`).join(", ") || "(なし)"}`,
|
|
122
|
+
`branchPattern ${p.branchPattern}`,
|
|
123
|
+
`instructions ${p.preflight.instructions || "(なし)"}`,
|
|
124
|
+
`preflight.runner ${runnerText(runnerView(p.preflight))}`,
|
|
125
|
+
"",
|
|
126
|
+
`ファイル: ${join(ws.dataDir, "project.yaml")}`,
|
|
127
|
+
].join("\n");
|
|
128
|
+
return { data: { ...p, preflightRunner: runnerView(p.preflight) }, text };
|
|
129
|
+
}
|
|
130
|
+
/** 担当の表示(config・whoami)。読めない値は理由を出す */
|
|
131
|
+
export function runnerText(v) {
|
|
132
|
+
if (!v.runner)
|
|
133
|
+
return `(読めません)${v.problem}`;
|
|
134
|
+
return `${v.runner}(${RUNNER_LABEL[v.runner]}${v.source === "default" ? "。未設定なので既定" : ""})`;
|
|
135
|
+
}
|
|
136
|
+
export function splitList(s) {
|
|
137
|
+
return s.split(",").map((x) => x.trim()).filter(Boolean);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* p3 repo: Preflight が読む参照先(リポジトリ・フォルダ)。共有の定義(project.yaml の repos)と、このマシンのパス
|
|
141
|
+
* (個人設定の projects.<プロジェクト>.repos)を分けて扱う。
|
|
142
|
+
*
|
|
143
|
+
* ls 一覧(このマシンのパスが無いものは登録の仕方を出す)
|
|
144
|
+
* add <名前> [<パス>] [キー=値 ...] 共有の定義を足す(パスを渡せばこのマシンのパスも登録する)
|
|
145
|
+
* set <名前> キー=値 ... 共有の定義を変える(role readFirst writable)
|
|
146
|
+
* path <名前> <パス> このマシンのパスだけを登録する(ほかの人が足した参照先に)
|
|
147
|
+
* rm <名前> [--local] 共有の定義とこのマシンのパスを消す(--local はこのマシンのパスだけ)
|
|
148
|
+
*/
|
|
149
|
+
export async function repoCommand(ws, projectName, cwd, args, o) {
|
|
150
|
+
const [sub = "ls", name, ...rest] = args;
|
|
151
|
+
const shared = () => ws.project.repos.find((r) => r.name === name);
|
|
152
|
+
const usage = "p3 repo [ls | add <名前> [<パス>] [role=… readFirst=true writable=true] | set <名前> キー=値 … | path <名前> <パス> | rm <名前> [--local]]";
|
|
153
|
+
const pairs = (list) => {
|
|
154
|
+
const patch = {};
|
|
155
|
+
for (const pair of list) {
|
|
156
|
+
const eq = pair.indexOf("=");
|
|
157
|
+
const key = pair.slice(0, eq);
|
|
158
|
+
const value = pair.slice(eq + 1).trim();
|
|
159
|
+
if (key === "role")
|
|
160
|
+
patch.role = value;
|
|
161
|
+
else if (key === "readFirst" || key === "writable") {
|
|
162
|
+
if (!["true", "false"].includes(value))
|
|
163
|
+
throw new UsageError(`${key} は true か false`);
|
|
164
|
+
patch[key] = value === "true";
|
|
165
|
+
}
|
|
166
|
+
else
|
|
167
|
+
throw new UsageError(`変えられるキー: role readFirst writable(主なフォルダ map は設定画面か project.yaml で)`);
|
|
168
|
+
}
|
|
169
|
+
return patch;
|
|
170
|
+
};
|
|
171
|
+
/** 共通の操作の失敗は使い方の誤りとして出す */
|
|
172
|
+
const run = async (f) => {
|
|
173
|
+
try {
|
|
174
|
+
return await f();
|
|
175
|
+
}
|
|
176
|
+
catch (e) {
|
|
177
|
+
if (e instanceof RepoAdminError)
|
|
178
|
+
throw new UsageError(e.message);
|
|
179
|
+
throw e;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
const folder = (raw) => resolvePath(cwd, raw);
|
|
183
|
+
if (sub === "ls") {
|
|
184
|
+
const refs = ws.refs();
|
|
185
|
+
const rows = refs.map((r) => ({ ...r, local: r.local ?? null }));
|
|
186
|
+
const text = [
|
|
187
|
+
...(!refs.length ? ["(参照先はまだありません。足すときは p3 repo add <名前> <パス> role=…)"] : []),
|
|
188
|
+
...refs.map((r) => {
|
|
189
|
+
const flags = [r.readFirst && "最初に読む", r.writable && "作業先候補"].filter(Boolean).join("・");
|
|
190
|
+
const where = r.status === "ok" ? r.local : r.status === "unregistered" ? `未登録 → p3 repo path ${r.name} <このマシンのパス>` : `${r.reason}`;
|
|
191
|
+
return `${r.name}${r.role ? `(${r.role})` : ""}${flags ? ` [${flags}]` : ""} /workspace/${r.mount}\n ${where}${r.map.length ? `\n 主なフォルダ: ${r.map.map((m) => (m.entry ? `${m.path}(入口 ${m.entry})` : m.path)).join(", ")}` : ""}`;
|
|
192
|
+
}),
|
|
193
|
+
].join("\n");
|
|
194
|
+
return { data: rows, text };
|
|
195
|
+
}
|
|
196
|
+
if (!name)
|
|
197
|
+
throw new UsageError(usage);
|
|
198
|
+
const problem = repoNameProblem(name);
|
|
199
|
+
if (problem && sub !== "rm")
|
|
200
|
+
throw new UsageError(`参照先の名前: ${problem}`);
|
|
201
|
+
if (sub === "add") {
|
|
202
|
+
const maybePath = rest[0] && !rest[0].includes("=") ? rest[0] : undefined;
|
|
203
|
+
const patch = pairs(maybePath ? rest.slice(1) : rest);
|
|
204
|
+
if (shared())
|
|
205
|
+
throw new UsageError(`「${name}」は既にあります。変えるときは p3 repo set ${name} キー=値、このマシンのパスは p3 repo path ${name} <パス>`);
|
|
206
|
+
const path = maybePath ? folder(maybePath) : undefined;
|
|
207
|
+
if (path)
|
|
208
|
+
await run(async () => checkFolder(path));
|
|
209
|
+
const entry = await run(() => addRepo(ws, name, patch));
|
|
210
|
+
if (path)
|
|
211
|
+
await run(() => setLocalRepoPath(ws, projectName, name, path));
|
|
212
|
+
return {
|
|
213
|
+
data: { ...entry, local: path ?? null },
|
|
214
|
+
text: `参照先を足しました: ${name}${entry.role ? `(${entry.role})` : ""}${path ? ` → ${path}` : `(このマシンのパスは未登録: p3 repo path ${name} <パス>)`}`,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
if (sub === "set") {
|
|
218
|
+
if (!shared())
|
|
219
|
+
throw new UsageError(`「${name}」はありません。足すときは p3 repo add ${name} <パス>`);
|
|
220
|
+
if (!rest.length)
|
|
221
|
+
throw new UsageError("キー=値 を指定してください(role readFirst writable)");
|
|
222
|
+
const next = await run(() => updateRepo(ws, name, pairs(rest)));
|
|
223
|
+
return { data: next, text: `参照先を変えました: ${name}` };
|
|
224
|
+
}
|
|
225
|
+
if (sub === "path") {
|
|
226
|
+
if (!shared())
|
|
227
|
+
throw new UsageError(`「${name}」は共有の参照先にありません(p3 repo ls)。足すときは p3 repo add ${name} <パス>`);
|
|
228
|
+
if (!rest[0])
|
|
229
|
+
throw new UsageError(`p3 repo path ${name} <このマシンのパス>`);
|
|
230
|
+
const path = folder(rest[0]);
|
|
231
|
+
await run(() => setLocalRepoPath(ws, projectName, name, path));
|
|
232
|
+
return { data: { name, local: path }, text: `このマシンのパスを登録しました: ${name} → ${path}(共有の定義は変えていません)` };
|
|
233
|
+
}
|
|
234
|
+
if (sub === "rm") {
|
|
235
|
+
if (o.local) {
|
|
236
|
+
await run(() => setLocalRepoPath(ws, projectName, name, null));
|
|
237
|
+
return { data: { name, local: null }, text: `このマシンのパスを外しました: ${name}(共有の定義は残しています。ほかの人には影響しません)` };
|
|
238
|
+
}
|
|
239
|
+
if (!shared())
|
|
240
|
+
throw new UsageError(`「${name}」は共有の参照先にありません。このマシンのパスだけを外すときは --local`);
|
|
241
|
+
await run(() => removeRepo(ws, projectName, name));
|
|
242
|
+
return { data: { name }, text: `参照先を消しました: ${name}(共有の定義。ほかの人の Preflight でも読まなくなります。ファイルやフォルダは消していません)` };
|
|
243
|
+
}
|
|
244
|
+
throw new UsageError(usage);
|
|
245
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
|
-
import { THEMES } from "
|
|
3
|
-
import { resolveMachineSettings } from "
|
|
4
|
-
import { originText, resolveHostPaths } from "
|
|
2
|
+
import { THEMES } from "../../../shared/types.js";
|
|
3
|
+
import { resolveMachineSettings } from "../../../core/machineSettings.js";
|
|
4
|
+
import { originText, resolveHostPaths } from "../../../core/preflight/hostPaths.js";
|
|
5
5
|
import { describeSettings, parseSettingChange, SETTING_KEY_LIST, SettingsInputError, writeMachineSettings } from "../core/machineSettingsEdit.js";
|
|
6
|
-
import { loadUserConfig, UserConfigError, userConfigPath } from "
|
|
6
|
+
import { loadUserConfig, UserConfigError, userConfigPath } from "../../../core/userConfig.js";
|
|
7
7
|
import { readTheme, ThemeInputError, writeTheme } from "../core/userTheme.js";
|
|
8
|
-
import { UsageError } from "
|
|
8
|
+
import { UsageError } from "../../../../kit/usage.js";
|
|
9
9
|
const USAGE = [
|
|
10
10
|
"p3 user-config 個人設定の値と出どころ(環境変数 / 個人設定 / 既定)",
|
|
11
11
|
`p3 user-config set キー=値 ... ui.theme=${THEMES.join("|")} / ${SETTING_KEY_LIST.filter((k) => k !== "codex.pathMap").join(" ")}(キー= で消す)`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import YAML from "yaml";
|
|
2
|
-
import { DEFAULT_SETTINGS, resolveMachineSettings, SETTING_KEYS, SettingsError } from "
|
|
3
|
-
import { normalizeUserConfig, updateUserConfig, userConfigPath } from "
|
|
2
|
+
import { DEFAULT_SETTINGS, resolveMachineSettings, SETTING_KEYS, SettingsError } from "../../../core/machineSettings.js";
|
|
3
|
+
import { normalizeUserConfig, updateUserConfig, userConfigPath } from "../../../core/userConfig.js";
|
|
4
4
|
/**
|
|
5
5
|
* 個人設定のマシンごとの設定(codex / preflight / serve)を変える(p3 user-config set)。
|
|
6
6
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync, statSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { repoNameProblem } from "
|
|
4
|
-
import { writeRepoEntry } from "
|
|
5
|
-
import { setProjectNode, updateUserConfig } from "
|
|
3
|
+
import { repoNameProblem } from "../../../shared/repos.js";
|
|
4
|
+
import { writeRepoEntry } from "../../../core/store/projectFile.js";
|
|
5
|
+
import { setProjectNode, updateUserConfig } from "../../../core/userConfig.js";
|
|
6
6
|
/**
|
|
7
7
|
* 参照先の登録・変更・削除(CLI の p3 repo と設定画面で共通)。
|
|
8
8
|
* 共有の定義は project.yaml の repos(その1件だけを書く。コメント・ほかの項目は残す)
|