@infodb/p3 0.12.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.
Files changed (219) hide show
  1. package/README.md +33 -35
  2. package/bin/p3.mjs +3 -2
  3. package/dist/web/assets/CompletionReview-BD7d6Yzt.js +1 -0
  4. package/dist/web/assets/ImprovementDialog-BoAZN1KR.js +1 -0
  5. package/dist/web/assets/Outputs-D-ZouoxF.js +1 -0
  6. package/dist/web/assets/RequestStatus-Bl3fdSbM.js +1 -0
  7. package/dist/web/assets/Tabs-CxeceOL-.js +1 -0
  8. package/dist/web/assets/TagInput-CeAbmGRR.js +1 -0
  9. package/dist/web/assets/TaskDrawer-BCriSnhe.js +6 -0
  10. package/dist/web/assets/_requestId-CZKMe_mC.js +1 -0
  11. package/dist/web/assets/_requestId-Fx4lLkFo.js +1 -0
  12. package/dist/web/assets/appCtx-BdxbkSZa.js +1 -0
  13. package/dist/web/assets/archive-D5IIxcSV.js +1 -0
  14. package/dist/web/assets/board-p6R9KMqd.js +1 -0
  15. package/dist/web/assets/done-BTOF188x.js +1 -0
  16. package/dist/web/assets/draft-BWYpm3PD.js +2 -0
  17. package/dist/web/assets/index-DFbY8NAR.css +2 -0
  18. package/dist/web/assets/index-Dpqi2dcC.js +12 -0
  19. package/dist/web/assets/link-D481whDt.js +1 -0
  20. package/dist/web/assets/metrics-CAzP6V8I.js +1 -0
  21. package/dist/web/assets/new-C65IJJg3.js +1 -0
  22. package/dist/web/assets/outputs-CXqnjSqV.js +1 -0
  23. package/dist/web/assets/preflightInput-ClKwkp8R.js +2 -0
  24. package/dist/web/assets/preload-helper-_dAYMct_.js +1 -0
  25. package/dist/web/assets/{quality-Pu6EISAM.js → quality-RFd-7k3r.js} +1 -1
  26. package/dist/web/assets/release-notes-Dtif8xsQ.js +5 -0
  27. package/dist/web/assets/requestData-SPc36t8Q.js +1 -0
  28. package/dist/web/assets/routes-DJj8CWuk.js +6 -0
  29. package/dist/web/assets/settings-DKJd7CLe.js +1 -0
  30. package/dist/web/assets/ui-CbEOnPnF.js +1 -0
  31. package/dist/web/assets/workTarget-DavxMs-c.js +30 -0
  32. package/dist/web/index.html +6 -4
  33. package/docs/architecture.md +430 -72
  34. package/docs/chatgpt-sign-in.md +2 -2
  35. package/docs/development.md +141 -64
  36. package/docs/feature-inventory.md +139 -0
  37. package/docs/how-to-use.md +389 -31
  38. package/docs/installation.md +261 -147
  39. package/docs/publishing.md +33 -14
  40. package/docs/refactoring.md +332 -0
  41. package/lib/cli/agentsStatus.js +198 -0
  42. package/lib/cli/guide.js +27 -0
  43. package/lib/cli/guide.md +217 -0
  44. package/lib/cli/help.js +45 -7
  45. package/lib/cli/main.js +58 -207
  46. package/lib/cli/project.js +34 -294
  47. package/lib/core/projectRegistry.js +2 -2
  48. package/lib/kit/appInfo.js +13 -0
  49. package/lib/kit/usage.js +27 -0
  50. package/lib/server/api/projectsRoutes.js +5 -5
  51. package/lib/server/server.js +7 -4
  52. package/lib/{cli → tasks/cli}/args.js +73 -9
  53. package/lib/{cli → tasks/cli}/chatgpt.js +1 -1
  54. package/lib/{cli → tasks/cli}/codex.js +1 -1
  55. package/lib/{cli → tasks/cli}/output.js +12 -2
  56. package/lib/{cli → tasks/cli}/preflightCommands.js +1 -1
  57. package/lib/tasks/cli/readOnly.js +75 -0
  58. package/lib/{cli → tasks/cli}/render.js +1 -1
  59. package/lib/{cli → tasks/cli}/requestCommands.js +24 -7
  60. package/lib/tasks/cli/showView.js +279 -0
  61. package/lib/{cli → tasks/cli}/taskCommands.js +55 -21
  62. package/lib/tasks/cli/tasksCli.js +149 -0
  63. package/lib/{core → tasks/core}/context.js +6 -9
  64. package/lib/tasks/core/errorOutcome.js +125 -0
  65. package/lib/{core → tasks/core}/hierarchy.js +1 -1
  66. package/lib/{core → tasks/core}/ops.js +17 -2
  67. package/lib/{core → tasks/core}/preflight/carryover.js +5 -1
  68. package/lib/{core → tasks/core}/preflight/codexEngine.js +36 -28
  69. package/lib/{core → tasks/core}/preflight/diagnose.js +4 -9
  70. package/lib/{core → tasks/core}/preflight/engine.js +9 -0
  71. package/lib/tasks/core/preflight/hostPaths.js +299 -0
  72. package/lib/{core → tasks/core}/preflight/input.js +33 -5
  73. package/lib/{core → tasks/core}/preflight/instructions.js +19 -2
  74. package/lib/{core → tasks/core}/preflight/mockEngine.js +27 -8
  75. package/lib/{core → tasks/core}/preflight/render.js +22 -3
  76. package/lib/{core → tasks/core}/preflight/service.js +86 -11
  77. package/lib/{core → tasks/core}/preflight/uiRender.js +5 -2
  78. package/lib/{core → tasks/core}/requestOps.js +214 -17
  79. package/lib/{core → tasks/core}/reviewRuns.js +127 -22
  80. package/lib/{core → tasks/core}/store/attachments.js +3 -2
  81. package/lib/{core → tasks/core}/store/collection.js +21 -2
  82. package/lib/tasks/core/store/fieldGroups.js +30 -0
  83. package/lib/tasks/core/store/jsonRecord.js +30 -0
  84. package/lib/{core → tasks/core}/store/normalize.js +15 -10
  85. package/lib/{core → tasks/core}/store/noteStore.js +2 -2
  86. package/lib/{core → tasks/core}/store/preflightStore.js +59 -22
  87. package/lib/{core → tasks/core}/store/projectFile.js +1 -1
  88. package/lib/{core → tasks/core}/store/workspace.js +28 -6
  89. package/lib/{core → tasks/core}/userConfig.js +1 -1
  90. package/lib/{core → tasks/core}/workTargets.js +1 -1
  91. package/lib/tasks/features/metrics/cli/metricsCommands.js +77 -0
  92. package/lib/tasks/features/metrics/core/definitions.js +445 -0
  93. package/lib/tasks/features/metrics/core/index.js +112 -0
  94. package/lib/tasks/features/metrics/core/manual.js +179 -0
  95. package/lib/tasks/features/metrics/server/metricsRoutes.js +8 -0
  96. package/lib/tasks/features/metrics/shared/metrics.js +42 -0
  97. package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/code.js +2 -11
  98. package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/material.js +5 -6
  99. package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/review.js +2 -2
  100. package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/service.js +38 -100
  101. package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/store.js +3 -3
  102. package/lib/{server/api → tasks/features/milestoneReview/server}/milestoneReviewRoutes.js +7 -13
  103. package/lib/{cli → tasks/features/quality/cli}/qualityCommands.js +36 -11
  104. package/lib/{core → tasks/features/quality/core}/qualityImprovement.js +16 -15
  105. package/lib/tasks/features/records/cli/revisitCommands.js +73 -0
  106. package/lib/tasks/features/records/core/completionRefs.js +46 -0
  107. package/lib/tasks/features/records/core/reviewCandidates.js +76 -0
  108. package/lib/tasks/features/records/shared/completionRecord.js +329 -0
  109. package/lib/tasks/features/records/shared/reviewCandidate.js +313 -0
  110. package/lib/tasks/features/records/shared/reworkHistory.js +86 -0
  111. package/lib/{cli → tasks/features/releaseNotes/cli}/releaseNotesCommands.js +7 -7
  112. package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/completeRequests.js +5 -6
  113. package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/generate.js +3 -14
  114. package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/material.js +3 -4
  115. package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/service.js +1 -1
  116. package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/store.js +2 -2
  117. package/lib/{server/api → tasks/features/releaseNotes/server}/releaseNoteRoutes.js +11 -20
  118. package/lib/tasks/features/requirements/cli/requirementCommands.js +289 -0
  119. package/lib/{shared → tasks/features/requirements/shared}/acceptance.js +292 -18
  120. package/lib/tasks/features/requirements/shared/requirementSource.js +635 -0
  121. package/lib/tasks/features/retro/cli/retroCommands.js +106 -0
  122. package/lib/tasks/features/retro/core/retrospective.js +197 -0
  123. package/lib/tasks/features/retro/shared/retrospective.js +286 -0
  124. package/lib/tasks/features/settings/cli/projectSettings.js +245 -0
  125. package/lib/{cli → tasks/features/settings/cli}/userConfig.js +50 -3
  126. package/lib/{core → tasks/features/settings/core}/machineSettingsEdit.js +2 -2
  127. package/lib/{core → tasks/features/settings/core}/repoAdmin.js +3 -3
  128. package/lib/{core → tasks/features/settings/core}/userTheme.js +2 -2
  129. package/lib/{server/api → tasks/features/settings/server}/repoRoutes.js +2 -2
  130. package/lib/{server/api → tasks/features/settings/server}/userThemeRoutes.js +3 -3
  131. package/lib/{cli → tasks/features/taskReview/cli}/taskReviewCommands.js +5 -5
  132. package/lib/{core/taskReview → tasks/features/taskReview/core}/material.js +13 -7
  133. package/lib/{core/taskReview → tasks/features/taskReview/core}/review.js +10 -3
  134. package/lib/{core/taskReview → tasks/features/taskReview/core}/service.js +24 -85
  135. package/lib/{core/taskReview → tasks/features/taskReview/core}/store.js +4 -4
  136. package/lib/{server/api → tasks/features/taskReview/server}/taskReviewRoutes.js +7 -14
  137. package/lib/{server → tasks/server}/api/manifest.js +51 -3
  138. package/lib/{server → tasks/server}/api/routes.js +134 -65
  139. package/lib/tasks/shared/commitRefs.js +10 -0
  140. package/lib/{shared → tasks/shared}/preflightInput.js +1 -1
  141. package/package.json +1 -43
  142. package/skills/p3/SKILL.md +9 -181
  143. package/dist/web/assets/ImprovementDialog-kQaVBGWH.js +0 -1
  144. package/dist/web/assets/Outputs-_nU_p3nu.js +0 -1
  145. package/dist/web/assets/RequestStatus-RG-OVQYY.js +0 -1
  146. package/dist/web/assets/Tabs-ew9i5SKX.js +0 -1
  147. package/dist/web/assets/TagInput-BtlJTF7i.js +0 -1
  148. package/dist/web/assets/TaskDrawer-DW8GyJqI.js +0 -6
  149. package/dist/web/assets/_requestId-6Nb727dD.js +0 -1
  150. package/dist/web/assets/_requestId-BykTgPax.js +0 -1
  151. package/dist/web/assets/appCtx-CxDdXABS.js +0 -1
  152. package/dist/web/assets/archive-Ckh295Xe.js +0 -1
  153. package/dist/web/assets/board-BVAIjK-Y.js +0 -1
  154. package/dist/web/assets/done-BGfA-3MA.js +0 -1
  155. package/dist/web/assets/draft-CfJeyLOl.js +0 -1
  156. package/dist/web/assets/index-CgRU744I.css +0 -2
  157. package/dist/web/assets/index-DacQ0yl4.js +0 -12
  158. package/dist/web/assets/new-DVygWvVc.js +0 -1
  159. package/dist/web/assets/outputs-B6xDsLZf.js +0 -1
  160. package/dist/web/assets/preflightInput-BAeEJYUK.js +0 -2
  161. package/dist/web/assets/preload-helper-DyCqp21K.js +0 -1
  162. package/dist/web/assets/release-notes-CCpzyiNf.js +0 -5
  163. package/dist/web/assets/requestData-D5vBnuMh.js +0 -1
  164. package/dist/web/assets/routes-Q91zvNc0.js +0 -4
  165. package/dist/web/assets/settings-BzRgcmUm.js +0 -1
  166. package/dist/web/assets/workTarget-C9c57JAO.js +0 -30
  167. package/lib/cli/readOnly.js +0 -38
  168. package/lib/cli/showView.js +0 -166
  169. /package/lib/{core/store → kit}/frontmatter.js +0 -0
  170. /package/lib/{core/store → kit}/fsutil.js +0 -0
  171. /package/lib/{cli → tasks/cli}/format.js +0 -0
  172. /package/lib/{core → tasks/core}/chatgpt.js +0 -0
  173. /package/lib/{core → tasks/core}/machineSettings.js +0 -0
  174. /package/lib/{core → tasks/core}/preflight/codexImage.js +0 -0
  175. /package/lib/{core → tasks/core}/preflight/docker.js +0 -0
  176. /package/lib/{core → tasks/core}/preflight/launch.js +0 -0
  177. /package/lib/{core → tasks/core}/preflight/launcher.mjs +0 -0
  178. /package/lib/{core → tasks/core}/preflight/mock-ui.html +0 -0
  179. /package/lib/{core → tasks/core}/preflight/mock-ui.png +0 -0
  180. /package/lib/{core → tasks/core}/preflight/owner.js +0 -0
  181. /package/lib/{core → tasks/core}/preflight/render-image/Dockerfile +0 -0
  182. /package/lib/{core → tasks/core}/preflight/render-image/fonts-ja.conf +0 -0
  183. /package/lib/{core → tasks/core}/preflight/render-image/render.mjs +0 -0
  184. /package/lib/{core → tasks/core}/preflight/split.js +0 -0
  185. /package/lib/{core → tasks/core}/preflight/uiMaterials.js +0 -0
  186. /package/lib/{core → tasks/core}/preflight/wireframe.js +0 -0
  187. /package/lib/{core → tasks/core}/preflight/xlsx.js +0 -0
  188. /package/lib/{core → tasks/core}/redact.js +0 -0
  189. /package/lib/{core → tasks/core}/repoRefs.js +0 -0
  190. /package/lib/{core → tasks/core}/requestStatus.js +0 -0
  191. /package/lib/{core → tasks/core}/store/archivedTasks.js +0 -0
  192. /package/lib/{core → tasks/core}/store/dataWatcher.js +0 -0
  193. /package/lib/{core → tasks/core}/store/locate.js +0 -0
  194. /package/lib/{core → tasks/core}/supersede.js +0 -0
  195. /package/lib/{core/milestoneReview → tasks/features/milestoneReview/core}/mockReviewer.js +0 -0
  196. /package/lib/{shared → tasks/features/milestoneReview/shared}/milestoneReview.js +0 -0
  197. /package/lib/{core → tasks/features/quality/core}/quality.js +0 -0
  198. /package/lib/{shared → tasks/features/quality/shared}/quality.js +0 -0
  199. /package/lib/{shared → tasks/features/quality/shared}/qualityImprovement.js +0 -0
  200. /package/lib/{shared → tasks/features/quality/shared}/qualityTemplates.js +0 -0
  201. /package/lib/{core/releaseNotes → tasks/features/releaseNotes/core}/mockSummarizer.js +0 -0
  202. /package/lib/{core/taskReview → tasks/features/taskReview/core}/mockReviewer.js +0 -0
  203. /package/lib/{core/taskReview → tasks/features/taskReview/core}/paths.js +0 -0
  204. /package/lib/{shared → tasks/features/taskReview/shared}/taskReview.js +0 -0
  205. /package/lib/{server → tasks/server}/api/chatgptRoutes.js +0 -0
  206. /package/lib/{server → tasks/server}/api/local.js +0 -0
  207. /package/lib/{shared → tasks/shared}/dates.js +0 -0
  208. /package/lib/{shared → tasks/shared}/directTask.js +0 -0
  209. /package/lib/{shared → tasks/shared}/hierarchy.js +0 -0
  210. /package/lib/{shared → tasks/shared}/milestoneGoals.js +0 -0
  211. /package/lib/{shared → tasks/shared}/milestoneOrder.js +0 -0
  212. /package/lib/{shared → tasks/shared}/preflightRunner.js +0 -0
  213. /package/lib/{shared → tasks/shared}/refs.js +0 -0
  214. /package/lib/{shared → tasks/shared}/repos.js +0 -0
  215. /package/lib/{shared → tasks/shared}/scopeView.js +0 -0
  216. /package/lib/{shared → tasks/shared}/tags.js +0 -0
  217. /package/lib/{shared → tasks/shared}/taskBlock.js +0 -0
  218. /package/lib/{shared → tasks/shared}/types.js +0 -0
  219. /package/lib/{shared → tasks/shared}/workTarget.js +0 -0
@@ -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,14 +1,59 @@
1
- import { THEMES } from "../shared/types.js";
1
+ import { resolve } from "node:path";
2
+ import { THEMES } from "../../../shared/types.js";
3
+ import { resolveMachineSettings } from "../../../core/machineSettings.js";
4
+ import { originText, resolveHostPaths } from "../../../core/preflight/hostPaths.js";
2
5
  import { describeSettings, parseSettingChange, SETTING_KEY_LIST, SettingsInputError, writeMachineSettings } from "../core/machineSettingsEdit.js";
3
- import { loadUserConfig, UserConfigError, userConfigPath } from "../core/userConfig.js";
6
+ import { loadUserConfig, UserConfigError, userConfigPath } from "../../../core/userConfig.js";
4
7
  import { readTheme, ThemeInputError, writeTheme } from "../core/userTheme.js";
5
- import { UsageError } from "./project.js";
8
+ import { UsageError } from "../../../../kit/usage.js";
6
9
  const USAGE = [
7
10
  "p3 user-config 個人設定の値と出どころ(環境変数 / 個人設定 / 既定)",
8
11
  `p3 user-config set キー=値 ... ui.theme=${THEMES.join("|")} / ${SETTING_KEY_LIST.filter((k) => k !== "codex.pathMap").join(" ")}(キー= で消す)`,
9
12
  "p3 user-config set codex.pathMap+=<このマシンのパス>=<Docker デーモンから見たパス> パスの対応を足す",
10
13
  "p3 user-config set codex.pathMap-=<このマシンのパス> パスの対応を外す(codex.pathMap= で全部)",
14
+ "p3 user-config paths <このマシンのパス> ... Docker にマウントするときのホストのパスと決め方(変えない)",
11
15
  ].join("\n");
16
+ /** 動いている場所の説明(このマシンの CLI の出力だけ。共有の記録には残さない) */
17
+ function environmentText(r) {
18
+ const e = r.environment;
19
+ if (e.kind === "direct")
20
+ return "コンテナの外(パスはそのまま渡します。手で書いた対応があればそれを使います)";
21
+ if (e.kind === "container")
22
+ return `コンテナの中(自分のコンテナ ${e.containerId.slice(0, 12)} を Docker で確かめました。マウントから決めます)`;
23
+ return `コンテナの中(自分のコンテナを確かめられません: ${e.detail})`;
24
+ }
25
+ /**
26
+ * p3 user-config paths: Preflight・描画と同じ設定と決め方で、このマシンのパスが Docker のホストのどこに当たるかを見せる。
27
+ * 読むだけで、個人設定とデータは変えない。実際のパスはこの出力だけに出す
28
+ */
29
+ async function pathsCommand(paths, env, path) {
30
+ if (!paths.length)
31
+ throw new UsageError("p3 user-config paths <このマシンのパス> ...(例: p3 user-config paths . ~/p3-data/myapp)");
32
+ const user = await loadUserConfig(path).catch((e) => {
33
+ if (e instanceof UserConfigError)
34
+ throw new UsageError(e.message);
35
+ throw e;
36
+ });
37
+ let pathMap;
38
+ try {
39
+ pathMap = resolveMachineSettings(user, env).codex.pathMap;
40
+ }
41
+ catch (e) {
42
+ throw new UsageError(e.message);
43
+ }
44
+ const locals = paths.map((p) => resolve(p));
45
+ const r = await resolveHostPaths(locals, { pathMap });
46
+ const lines = [`p3 が動いている場所: ${environmentText(r)}`, ""];
47
+ for (const p of r.paths) {
48
+ lines.push(p.local);
49
+ if (p.ok)
50
+ lines.push(` → ${p.host} ${originText(p, pathMap.length)}${p.origin === "auto" && p.destination ? `(マウント ${p.destination})` : ""}`);
51
+ else
52
+ lines.push(` × 決められません: ${p.detail}`, ` 次にすること: ${p.next}`);
53
+ }
54
+ lines.push("", r.ok ? "全部決まりました(Preflight と描画でこのとおりにマウントします)" : "決まらないものがあります。Preflight と描画は、このフォルダを使うときコンテナを起こさずに止まります");
55
+ return { data: r, text: lines.join("\n") };
56
+ }
12
57
  /**
13
58
  * p3 user-config [set ...]。個人設定(このマシン・この人)のうち、画面のテーマとマシンごとの設定(codex / preflight / serve)を
14
59
  * 見せ・変える。プロジェクトの登録は p3 project、プロジェクトの設定は p3 config。プロジェクトを決める前に動く。
@@ -35,6 +80,8 @@ export async function userConfigCommand(args, env = process.env) {
35
80
  ].join("\n");
36
81
  return { data: { ui: { theme }, settings: rows, ...(error ? { error } : {}), path }, text };
37
82
  }
83
+ if (sub === "paths")
84
+ return pathsCommand(pairs, env, path);
38
85
  if (sub !== "set" || !pairs.length)
39
86
  throw new UsageError(USAGE);
40
87
  let theme;
@@ -1,6 +1,6 @@
1
1
  import YAML from "yaml";
2
- import { DEFAULT_SETTINGS, resolveMachineSettings, SETTING_KEYS, SettingsError } from "./machineSettings.js";
3
- import { normalizeUserConfig, updateUserConfig, userConfigPath } from "./userConfig.js";
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 "../shared/repos.js";
4
- import { writeRepoEntry } from "./store/projectFile.js";
5
- import { setProjectNode, updateUserConfig } from "./userConfig.js";
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件だけを書く。コメント・ほかの項目は残す)
@@ -1,5 +1,5 @@
1
- import { isTheme, THEMES } from "../shared/types.js";
2
- import { loadUserConfig, setThemeNode, updateUserConfig, userConfigPath } from "./userConfig.js";
1
+ import { isTheme, THEMES } from "../../../shared/types.js";
2
+ import { loadUserConfig, setThemeNode, updateUserConfig, userConfigPath } from "../../../core/userConfig.js";
3
3
  /**
4
4
  * 画面のテーマ(個人設定の ui.theme)。保存先はここだけで、CLI(p3 user-config)と画面(/api/user-theme)が使う。
5
5
  * このマシン・この人の設定なので、すべてのプロジェクトで共通。
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
2
  import { z } from "zod";
3
- import { addRepo, checkFolder, removeRepo, setLocalRepoPath, updateRepo } from "../../core/repoAdmin.js";
4
- import { localOnly } from "./local.js";
3
+ import { addRepo, checkFolder, removeRepo, setLocalRepoPath, updateRepo } from "../core/repoAdmin.js";
4
+ import { localOnly } from "../../../server/api/local.js";
5
5
  const mapEntry = z.object({ path: z.string(), role: z.string(), entry: z.string().optional() });
6
6
  const repoPatch = z
7
7
  .object({ role: z.string(), readFirst: z.boolean(), writable: z.boolean(), map: z.array(mapEntry) })
@@ -1,8 +1,8 @@
1
1
  import { Hono } from "hono";
2
2
  import { z } from "zod";
3
- import { THEMES } from "../../shared/types.js";
4
- import { readTheme, writeTheme } from "../../core/userTheme.js";
5
- import { localOnly } from "./local.js";
3
+ import { THEMES } from "../../../shared/types.js";
4
+ import { readTheme, writeTheme } from "../core/userTheme.js";
5
+ import { localOnly } from "../../../server/api/local.js";
6
6
  /**
7
7
  * /api/user-theme。個人設定のテーマだけを読み書きする(ほかの個人設定は返さない・変えない)。
8
8
  * GET → { theme }
@@ -1,9 +1,9 @@
1
- import { resolveRequestId } from "../core/ops.js";
2
- import { NotFoundError } from "../core/store/collection.js";
3
- import { normalizeTaskId } from "../shared/refs.js";
1
+ import { resolveRequestId } from "../../../core/ops.js";
2
+ import { NotFoundError } from "../../../core/store/collection.js";
3
+ import { normalizeTaskId } from "../../../shared/refs.js";
4
4
  import { previewOf, QUALITY_VERDICT_LABELS, TASK_REVIEW_SCOPE, TASK_REVIEW_VERDICT_LABELS, TASK_REVIEW_VERDICTS } from "../shared/taskReview.js";
5
- import { table } from "./format.js";
6
- import { UsageError } from "./project.js";
5
+ import { table } from "../../../cli/format.js";
6
+ import { UsageError } from "../../../../kit/usage.js";
7
7
  /**
8
8
  * タスクの AI レビュー(core/taskReview。画面と同じサービス)。
9
9
  * review <T> [--target ...] [--viewpoint ...] [--engine codex|mock] [--preview] 材料を固定して始め、終わるまで待つ(進み具合は stderr、
@@ -3,11 +3,12 @@ import { createHash } from "node:crypto";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { join } from "node:path";
5
5
  import YAML from "yaml";
6
- import { acceptanceStatus } from "../../shared/acceptance.js";
7
- import { qualitySnapshot, standardsFor, taskQualityDiff } from "../../shared/quality.js";
8
- import { commitsInOutput } from "../milestoneReview/code.js";
9
- import { NotFoundError } from "../store/collection.js";
10
- import { Workspace } from "../store/workspace.js";
6
+ import { acceptanceStatus } from "../../requirements/shared/acceptance.js";
7
+ import { criteriaSourceView } from "../../requirements/shared/requirementSource.js";
8
+ import { qualitySnapshot, standardsFor, taskQualityDiff } from "../../quality/shared/quality.js";
9
+ import { commitsInOutput } from "../../../shared/commitRefs.js";
10
+ import { NotFoundError } from "../../../core/store/collection.js";
11
+ import { Workspace } from "../../../core/store/workspace.js";
11
12
  import { safeRelPath } from "./paths.js";
12
13
  export { safeRelPath };
13
14
  /**
@@ -80,8 +81,7 @@ export function bodyItems(body) {
80
81
  */
81
82
  export async function extractTaskReview(dataDir, rid, tid, refs, opts = {}) {
82
83
  const extractedAt = new Date().toISOString();
83
- const snap = new Workspace(dataDir);
84
- await snap.load();
84
+ const snap = await Workspace.snapshot(dataDir);
85
85
  const request = snap.requests.get(rid);
86
86
  if (!request)
87
87
  throw new NotFoundError(rid);
@@ -210,6 +210,7 @@ export async function extractTaskReview(dataDir, rid, tid, refs, opts = {}) {
210
210
  ...(task.acceptanceCriteria?.length ? { criteria: task.acceptanceCriteria } : {}),
211
211
  ...(task.acceptanceEvidence?.length ? { evidence: task.acceptanceEvidence } : {}),
212
212
  ...(acc?.items.length ? { evidenceStates: acc.items.map((i) => ({ id: i.id, state: i.state })) } : {}),
213
+ ...(task.acceptanceSources?.length ? { sources: sourcesForReview(task, request ? (request.requirementSources ?? []).map((x) => x.id) : undefined) } : {}),
213
214
  ...(task.acceptanceProblems?.length ? { acceptanceProblems: task.acceptanceProblems } : {}),
214
215
  },
215
216
  items,
@@ -224,6 +225,11 @@ export async function extractTaskReview(dataDir, rid, tid, refs, opts = {}) {
224
225
  * 材料の識別子(抽出の日時は入れない)。比較対象の出典(成果物の文字列か、指定した文字列か)も入れない
225
226
  * (同じ SHA を比べていれば、指定の仕方によらず同じ材料)
226
227
  */
228
+ /** 基準ごとの要求の根拠の記録と状態(材料のスナップショットに入れ、hash にも入る) */
229
+ function sourcesForReview(task, requestSourceIds) {
230
+ const view = criteriaSourceView(task.acceptanceCriteria, task.acceptanceSources, requestSourceIds);
231
+ return [...view.items.flatMap((i) => i.sources), ...view.orphans];
232
+ }
227
233
  export function taskReviewInputHash(i) {
228
234
  const targets = i.targets.map(({ sources: _s, ...t }) => t);
229
235
  const notes = i.notes.filter((n) => n.code !== "pr_unresolved");
@@ -1,5 +1,6 @@
1
+ import { evidenceBasisOf } from "../../requirements/shared/acceptance.js";
1
2
  import { CONTAINER_WORKSPACE } from "@infodb/codex-workspace";
2
- import { QUALITY_VERDICTS, TASK_REVIEW_VERDICTS, } from "../../shared/taskReview.js";
3
+ import { QUALITY_VERDICTS, TASK_REVIEW_VERDICTS, } from "../shared/taskReview.js";
3
4
  /**
4
5
  * タスクの AI レビューの依頼文と、結果の確かめ方(Codex にもテストの偽物にも同じものを使う)。
5
6
  *
@@ -29,8 +30,14 @@ export function taskReviewMaterial(input) {
29
30
  record: input.task.record ?? null,
30
31
  outputs: input.task.outputs,
31
32
  // 作業した側の申告(判定ではない)
32
- workerEvidence: (input.task.evidence ?? []).map((e) => ({ criterion: e.criterionId, result: e.result, evidence: e.evidence })),
33
+ // basis は根拠の種類(作業した側の申告。basisRecorded: false は根拠を記録する前の古い証拠で、申告のみと読む)
34
+ workerEvidence: (input.task.evidence ?? []).map((e) => {
35
+ const { basis, recorded } = evidenceBasisOf(e);
36
+ return { criterion: e.criterionId, result: e.result, evidence: e.evidence, basis, basisRecorded: recorded };
37
+ }),
33
38
  evidenceStates: input.task.evidenceStates ?? [],
39
+ // 基準ごとの要求の根拠(要望者の申告。確認記録ありも P3 の保証ではない。レビューの判定を確かめた人として書かない)
40
+ requirementSources: (input.task.sources ?? []).map((s) => ({ criterion: s.criterionId, id: s.id, state: s.state, target: s.target ?? null, source: s.source ?? null, basis: s.basis ?? null, confirmed: s.confirmed ? { by: s.confirmed.by, on: s.confirmed.on } : null })),
34
41
  acceptanceProblems: input.task.acceptanceProblems ?? [],
35
42
  },
36
43
  items: input.items,
@@ -91,7 +98,7 @@ export function taskReviewPrompt(input) {
91
98
  const instructions = `あなたはタスクのレビュー係です。完了したタスクの本文・受け入れ基準(比較項目)が、比較対象の変更(固定したコミットの差分と、その前後のコード)で満たされているかを確かめ、日本語で評価します。
92
99
  これは作業した人や AI の能力・成績の評価ではありません。「依頼された基準が成果物で満たされているか」だけを確かめます。
93
100
  - 読めるのは ${materialPath} の固定した材料だけです(差分の本文 patch と、変わったファイルの前後の中身 before / after)。リポジトリそのものはマウントしていません。材料に無いファイルは読めないので、判断できないことは undetermined にしてください。
94
- - 作業した側の証拠(workerEvidence)・変更の記録・成果物は自己申告です。どこを見るかの手がかりに使い、書いてあることを事実として扱わないでください。
101
+ - 作業した側の証拠(workerEvidence)・変更の記録・成果物は自己申告です。どこを見るかの手がかりに使い、書いてあることを事実として扱わないでください。根拠(basis)の「検査結果あり(machine)」「読んで確認(read)」も作業した側の記録で、P3 は検査を実行していません。要求の根拠(requirementSources)は要望者が残した出典と確認の記録で、確認記録あり(confirmed)も申告です。あなたの判定で確認したことにしないでください。
95
102
  - 比較項目ごとに、差分と前後のコードを読み、項目を満たす実装になっているか、抜け・食い違いが無いかを判断してください。
96
103
  - 本文には基準に無い要件が書かれていることがあります。見落とさず、基準と本文・基準どうしの矛盾は直さずに checks(人が確かめる点)に書いてください。
97
104
  - 意図しない変更: 比較項目・本文のどれにも当たらない変更や、既存の動作を変えてしまう変更を unplanned に挙げてください。commits の otherTasks があるコミットは別のタスクの作業が混ざっている可能性があるので、このタスクの範囲と分けて読んでください。