@infodb/p3 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +56 -2
- package/bin/p3.mjs +18 -0
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/assets/Outputs-Ni3pNuGU.js +1 -0
- package/dist/web/assets/RequestStatus-K8TZwpur.js +1 -0
- package/dist/web/assets/TagInput-BICKVH2x.js +1 -0
- package/dist/web/assets/TaskDrawer-BkDIstIN.js +3 -0
- package/dist/web/assets/_requestId-B5O_ytaq.js +1 -0
- package/dist/web/assets/_requestId-C66puEMO.js +30 -0
- package/dist/web/assets/action-CMjATXqv.js +1 -0
- package/dist/web/assets/board-CbfDjkls.js +1 -0
- package/dist/web/assets/copy-B1ZbihKL.js +2 -0
- package/dist/web/assets/done-CPQbCFHg.js +1 -0
- package/dist/web/assets/draft-dT3gLDIt.js +1 -0
- package/dist/web/assets/format-DuK6P1hb.js +1 -0
- package/dist/web/assets/index-BUcs2J6N.js +12 -0
- package/dist/web/assets/index-C3DkqwJ9.css +2 -0
- package/dist/web/assets/link-_s8ndNKS.js +1 -0
- package/dist/web/assets/new-T60RB7de.js +1 -0
- package/dist/web/assets/preload-helper-dXqN7N-I.js +1 -0
- package/dist/web/assets/release-notes-DxrPhDbt.js +3 -0
- package/dist/web/assets/requestData-D8ZiSZss.js +1 -0
- package/dist/web/assets/rolldown-runtime-hePW80VL.js +1 -0
- package/dist/web/assets/routes-D9ZxXoLk.js +2 -0
- package/dist/web/assets/search-CJ8MBKTz.js +1 -0
- package/dist/web/assets/settings-DsHVyqzJ.js +1 -0
- package/dist/web/assets/supersede-CLXlhCq0.js +1 -0
- package/dist/web/assets/ui-Cvke4y4X.js +1 -0
- package/dist/web/favicon.ico +0 -0
- package/dist/web/favicon.svg +12 -0
- package/dist/web/index.html +23 -0
- package/docs/architecture.md +588 -0
- package/docs/chatgpt-sign-in.md +163 -0
- package/docs/development.md +194 -0
- package/docs/how-to-use.md +524 -0
- package/docs/installation.md +275 -0
- package/docs/publishing.md +65 -0
- package/package.json +86 -3
- package/skills/p3/SKILL.md +95 -0
- package/src/cli/args.ts +179 -0
- package/src/cli/chatgpt.ts +74 -0
- package/src/cli/codex.ts +28 -0
- package/src/cli/format.ts +9 -0
- package/src/cli/help.ts +99 -0
- package/src/cli/main.ts +267 -0
- package/src/cli/output.ts +99 -0
- package/src/cli/preflightCommands.ts +237 -0
- package/src/cli/project.ts +501 -0
- package/src/cli/readOnly.ts +36 -0
- package/src/cli/releaseNotesCommands.ts +139 -0
- package/src/cli/render.ts +60 -0
- package/src/cli/requestCommands.ts +170 -0
- package/src/cli/showView.ts +110 -0
- package/src/cli/taskCommands.ts +167 -0
- package/src/cli/userConfig.ts +58 -0
- package/src/core/chatgpt.ts +33 -0
- package/src/core/context.ts +57 -0
- package/src/core/machineSettings.ts +207 -0
- package/src/core/machineSettingsEdit.ts +156 -0
- package/src/core/ops.ts +114 -0
- package/src/core/preflight/carryover.ts +133 -0
- package/src/core/preflight/codexEngine.ts +702 -0
- package/src/core/preflight/codexImage.ts +98 -0
- package/src/core/preflight/diagnose.ts +124 -0
- package/src/core/preflight/engine.ts +92 -0
- package/src/core/preflight/input.ts +65 -0
- package/src/core/preflight/launch.ts +86 -0
- package/src/core/preflight/launcher.mjs +75 -0
- package/src/core/preflight/mock-ui.html +24 -0
- package/src/core/preflight/mock-ui.png +0 -0
- package/src/core/preflight/mockEngine.ts +145 -0
- package/src/core/preflight/render-image/Dockerfile +23 -0
- package/src/core/preflight/render-image/render.mjs +53 -0
- package/src/core/preflight/render.ts +336 -0
- package/src/core/preflight/service.ts +690 -0
- package/src/core/preflight/uiMaterials.ts +272 -0
- package/src/core/preflight/uiRender.ts +84 -0
- package/src/core/preflight/wireframe.ts +69 -0
- package/src/core/preflight/xlsx.ts +328 -0
- package/src/core/redact.ts +31 -0
- package/src/core/releaseNotes/generate.ts +271 -0
- package/src/core/releaseNotes/material.ts +114 -0
- package/src/core/releaseNotes/mockSummarizer.ts +28 -0
- package/src/core/releaseNotes/service.ts +106 -0
- package/src/core/releaseNotes/store.ts +216 -0
- package/src/core/repoAdmin.ts +81 -0
- package/src/core/repoRefs.ts +90 -0
- package/src/core/requestOps.ts +140 -0
- package/src/core/requestStatus.ts +58 -0
- package/src/core/store/attachments.ts +228 -0
- package/src/core/store/collection.ts +282 -0
- package/src/core/store/frontmatter.ts +22 -0
- package/src/core/store/fsutil.ts +90 -0
- package/src/core/store/locate.ts +181 -0
- package/src/core/store/normalize.ts +155 -0
- package/src/core/store/noteStore.ts +56 -0
- package/src/core/store/preflightStore.ts +136 -0
- package/src/core/store/projectFile.ts +101 -0
- package/src/core/store/workspace.ts +328 -0
- package/src/core/supersede.ts +74 -0
- package/src/core/userConfig.ts +180 -0
- package/src/core/userTheme.ts +22 -0
- package/src/core/workTargets.ts +120 -0
- package/src/server/api/chatgptRoutes.ts +48 -0
- package/src/server/api/local.ts +33 -0
- package/src/server/api/manifest.ts +119 -0
- package/src/server/api/releaseNoteRoutes.ts +78 -0
- package/src/server/api/repoRoutes.ts +67 -0
- package/src/server/api/routes.ts +374 -0
- package/src/server/api/userThemeRoutes.ts +62 -0
- package/src/server/server.ts +49 -0
- package/src/shared/dates.ts +12 -0
- package/src/shared/preflightInput.ts +27 -0
- package/src/shared/refs.ts +55 -0
- package/src/shared/repos.ts +113 -0
- package/src/shared/scopeView.ts +48 -0
- package/src/shared/tags.ts +27 -0
- package/src/shared/types.ts +700 -0
- package/src/shared/workTarget.ts +44 -0
package/src/cli/args.ts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { basename, resolve as resolvePath } from "node:path";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
|
+
import { ATTACHMENT_LIMITS, AttachmentError, inspectAttachment } from "../core/store/attachments.ts";
|
|
6
|
+
import { type Task, TASK_STATUSES, isTaskStatus, type TaskStatus } from "../shared/types.ts";
|
|
7
|
+
import { type P3Context } from "../core/context.ts";
|
|
8
|
+
import { repoArg } from "../core/workTargets.ts";
|
|
9
|
+
import { UsageError } from "./project.ts";
|
|
10
|
+
import { Output } from "./output.ts";
|
|
11
|
+
|
|
12
|
+
/** CLI の入力の解釈(オプション・キー=値・本文・添付のファイル)と、コマンドに渡すもの(CommandEnv) */
|
|
13
|
+
|
|
14
|
+
const OPTIONS = {
|
|
15
|
+
dir: { type: "string" },
|
|
16
|
+
project: { type: "string" },
|
|
17
|
+
req: { type: "string" },
|
|
18
|
+
request: { type: "string" },
|
|
19
|
+
json: { type: "boolean" },
|
|
20
|
+
brief: { type: "boolean" },
|
|
21
|
+
actor: { type: "string" },
|
|
22
|
+
rev: { type: "string" },
|
|
23
|
+
help: { type: "boolean", short: "h" },
|
|
24
|
+
all: { type: "boolean" },
|
|
25
|
+
status: { type: "string" },
|
|
26
|
+
area: { type: "string", multiple: true },
|
|
27
|
+
label: { type: "string", multiple: true },
|
|
28
|
+
output: { type: "string", multiple: true },
|
|
29
|
+
"repo-output": { type: "string", multiple: true },
|
|
30
|
+
q: { type: "string", short: "q" },
|
|
31
|
+
due: { type: "string" },
|
|
32
|
+
milestone: { type: "string" },
|
|
33
|
+
tag: { type: "string", multiple: true },
|
|
34
|
+
attach: { type: "string", multiple: true },
|
|
35
|
+
title: { type: "string" },
|
|
36
|
+
done: { type: "boolean" },
|
|
37
|
+
off: { type: "boolean" },
|
|
38
|
+
body: { type: "string" },
|
|
39
|
+
record: { type: "string" },
|
|
40
|
+
note: { type: "string" },
|
|
41
|
+
engine: { type: "string" },
|
|
42
|
+
run: { type: "string" },
|
|
43
|
+
only: { type: "string" },
|
|
44
|
+
skip: { type: "string" },
|
|
45
|
+
name: { type: "string" },
|
|
46
|
+
repo: { type: "string" },
|
|
47
|
+
description: { type: "string" },
|
|
48
|
+
instructions: { type: "string" },
|
|
49
|
+
agents: { type: "boolean" },
|
|
50
|
+
"note-only": { type: "boolean" },
|
|
51
|
+
"archive-superseded": { type: "boolean" },
|
|
52
|
+
paste: { type: "boolean" },
|
|
53
|
+
"no-browser": { type: "boolean" },
|
|
54
|
+
forget: { type: "boolean" },
|
|
55
|
+
yes: { type: "boolean", short: "y" },
|
|
56
|
+
local: { type: "boolean" },
|
|
57
|
+
"repo-name": { type: "string" },
|
|
58
|
+
port: { type: "string" },
|
|
59
|
+
host: { type: "string" },
|
|
60
|
+
out: { type: "string" },
|
|
61
|
+
source: { type: "string" },
|
|
62
|
+
width: { type: "string" },
|
|
63
|
+
version: { type: "string" },
|
|
64
|
+
file: { type: "string" },
|
|
65
|
+
"based-on": { type: "string" },
|
|
66
|
+
} as const;
|
|
67
|
+
|
|
68
|
+
export const parse = (argv: string[]) => parseArgs({ args: joinValues(argv), options: OPTIONS, allowPositionals: true });
|
|
69
|
+
|
|
70
|
+
/** `--body "- 箇条書き"` のように値が - で始まっても受け取れるよう、`--body=...` の形にまとめる */
|
|
71
|
+
function joinValues(argv: string[]): string[] {
|
|
72
|
+
const out: string[] = [];
|
|
73
|
+
for (let i = 0; i < argv.length; i++) {
|
|
74
|
+
const name = /^--([a-z]+)$/.exec(argv[i])?.[1];
|
|
75
|
+
const opt = name ? (OPTIONS as Record<string, { type: string }>)[name] : undefined;
|
|
76
|
+
if (opt?.type === "string" && i + 1 < argv.length && !argv[i + 1].startsWith("--")) {
|
|
77
|
+
out.push(`${argv[i]}=${argv[++i]}`);
|
|
78
|
+
} else {
|
|
79
|
+
out.push(argv[i]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// --- 入力 -----------------------------------------------------------------
|
|
86
|
+
|
|
87
|
+
const TASK_KEYS = ["title", "status", "labels", "areas", "outputs", "repo", "repoOutputs"];
|
|
88
|
+
|
|
89
|
+
export function parseTaskAssignments(pairs: string[]): Partial<Task> {
|
|
90
|
+
const patch: Record<string, unknown> = {};
|
|
91
|
+
for (const pair of pairs) {
|
|
92
|
+
const [key, raw] = splitPair(pair);
|
|
93
|
+
if (!TASK_KEYS.includes(key)) throw new UsageError(`変更できるキー: ${TASK_KEYS.join(", ")}`);
|
|
94
|
+
if (key === "repo") {
|
|
95
|
+
// repo=<名前> / repo=none・repo= は作業先なし
|
|
96
|
+
patch.repo = repoArg(raw);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (key === "repoOutputs") {
|
|
100
|
+
if (raw !== "") throw new UsageError("repoOutputs= は空で全部外すだけ。足すときは --repo-output <名前>=<成果物>");
|
|
101
|
+
patch.repoOutputs = [];
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (raw === "") {
|
|
105
|
+
patch[key] = key === "labels" || key === "areas" || key === "outputs" ? [] : undefined;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (key === "labels" || key === "areas" || key === "outputs") patch[key] = list(raw);
|
|
109
|
+
else if (key === "status") {
|
|
110
|
+
checkStatus(raw);
|
|
111
|
+
patch[key] = raw;
|
|
112
|
+
} else patch[key] = raw;
|
|
113
|
+
}
|
|
114
|
+
return patch;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function splitPair(pair: string): [string, string] {
|
|
118
|
+
const eq = pair.indexOf("=");
|
|
119
|
+
if (eq < 1) throw new UsageError(`キー=値 の形で指定してください: ${pair}`);
|
|
120
|
+
return [pair.slice(0, eq), pair.slice(eq + 1).trim()];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function checkStatus(status: string | undefined): asserts status is TaskStatus {
|
|
124
|
+
if (!isTaskStatus(status)) throw new UsageError(`ステータスは ${TASK_STATUSES.join(", ")} のいずれか`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const list = (s: string) => s.split(",").map((x) => x.trim()).filter(Boolean);
|
|
128
|
+
|
|
129
|
+
export function num(v: string, name: string) {
|
|
130
|
+
const n = Number(v);
|
|
131
|
+
if (!Number.isFinite(n)) throw new UsageError(`${name} は数値で指定してください`);
|
|
132
|
+
return n;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function date(v: string) {
|
|
136
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(v)) throw new UsageError(`日付は YYYY-MM-DD: ${v}`);
|
|
137
|
+
return v;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function readBody(v: string | undefined): string {
|
|
141
|
+
if (v === undefined) return "";
|
|
142
|
+
return v === "-" ? readFileSync(0, "utf8") : v;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** request new --attach のファイルを読み、要望を作る前に全部確かめる(1つでもだめなら作らない) */
|
|
146
|
+
export async function readAttachFiles(paths: string[]): Promise<{ path: string; data: Buffer }[]> {
|
|
147
|
+
if (paths.length > ATTACHMENT_LIMITS.count) throw new UsageError(`添付は1つの要望に ${ATTACHMENT_LIMITS.count} 件までです`);
|
|
148
|
+
const files = [];
|
|
149
|
+
for (const path of paths) {
|
|
150
|
+
const data = await readFile(resolvePath(process.cwd(), path)).catch(() => {
|
|
151
|
+
throw new UsageError(`ファイルが読めません: ${path}`);
|
|
152
|
+
});
|
|
153
|
+
try {
|
|
154
|
+
inspectAttachment(data, basename(path));
|
|
155
|
+
} catch (e) {
|
|
156
|
+
throw e instanceof AttachmentError ? new UsageError(`${path}: ${e.message}(要望は作っていません)`) : e;
|
|
157
|
+
}
|
|
158
|
+
files.push({ path, data });
|
|
159
|
+
}
|
|
160
|
+
const total = files.reduce((n, f) => n + f.data.length, 0);
|
|
161
|
+
if (total > ATTACHMENT_LIMITS.totalBytes) throw new UsageError(`添付の合計が上限(${ATTACHMENT_LIMITS.totalBytes} バイト)を超えます(要望は作っていません)`);
|
|
162
|
+
return files;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** コマンドに渡すもの(main がプロジェクト・変更者・今の要望を決めてから渡す) */
|
|
166
|
+
export interface CommandEnv {
|
|
167
|
+
ctx: P3Context;
|
|
168
|
+
out: Output;
|
|
169
|
+
args: string[];
|
|
170
|
+
o: ReturnType<typeof parse>["values"];
|
|
171
|
+
actor: string;
|
|
172
|
+
current: string | undefined;
|
|
173
|
+
expectedRev: number | undefined;
|
|
174
|
+
requestArg: (raw: string | undefined) => string;
|
|
175
|
+
taskArg: (raw: string | undefined) => string;
|
|
176
|
+
split: (ref: string) => { col: ReturnType<P3Context["ws"]["tasksOf"]>; rid: string; tid: string };
|
|
177
|
+
cwd: string;
|
|
178
|
+
target: { name?: string; dataDir: string };
|
|
179
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createInterface } from "node:readline";
|
|
3
|
+
import { chatgptAccount, signInFailure, type ChatGptStatus } from "../core/chatgpt.ts";
|
|
4
|
+
import { UsageError } from "./project.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* p3 chatgpt login | status | logout。プロジェクトを決める前に動く(どのプロジェクトにも属さない、このマシンの接続)。
|
|
8
|
+
* 設計: docs/chatgpt-sign-in.md
|
|
9
|
+
*/
|
|
10
|
+
export async function chatgptCommand(
|
|
11
|
+
args: string[],
|
|
12
|
+
o: { port?: string; paste?: boolean; "no-browser"?: boolean; forget?: boolean },
|
|
13
|
+
account = chatgptAccount(),
|
|
14
|
+
): Promise<{ data: unknown; text: string; code?: number }> {
|
|
15
|
+
const [sub = "status"] = args;
|
|
16
|
+
switch (sub) {
|
|
17
|
+
case "status": {
|
|
18
|
+
const s = await account.status();
|
|
19
|
+
return { data: s, text: describe(s) };
|
|
20
|
+
}
|
|
21
|
+
case "login": {
|
|
22
|
+
const attempt = await account.startLogin({ port: o.port ? Number(o.port) : undefined });
|
|
23
|
+
process.stderr.write(
|
|
24
|
+
[
|
|
25
|
+
"ブラウザで ChatGPT にサインインし、プランの利用に同意してください:",
|
|
26
|
+
` ${attempt.url}`,
|
|
27
|
+
`(${attempt.redirectUri} で待っています。5分で取り消します)`,
|
|
28
|
+
o.paste
|
|
29
|
+
? "ブラウザが「接続できません」になったら、そのときのアドレスバーの URL をここに貼って Enter:"
|
|
30
|
+
: "DevContainer などでブラウザがコールバックに届かないときは、--paste を付けてやり直してください",
|
|
31
|
+
"",
|
|
32
|
+
].join("\n"),
|
|
33
|
+
);
|
|
34
|
+
if (!o["no-browser"] && !o.paste) openBrowser(attempt.url);
|
|
35
|
+
let s: ChatGptStatus;
|
|
36
|
+
try {
|
|
37
|
+
if (o.paste) {
|
|
38
|
+
const rl = createInterface({ input: process.stdin });
|
|
39
|
+
const line = new Promise<string>((res) => rl.once("line", res));
|
|
40
|
+
s = await Promise.race([attempt.done, line.then((url) => attempt.submit(url))]).finally(() => rl.close());
|
|
41
|
+
} else {
|
|
42
|
+
s = await attempt.done;
|
|
43
|
+
}
|
|
44
|
+
} catch (e) {
|
|
45
|
+
throw signInFailure(e);
|
|
46
|
+
}
|
|
47
|
+
return { data: s, text: `サインインしました: ${describe(s)}`, code: s.planAllowed ? 0 : 1 };
|
|
48
|
+
}
|
|
49
|
+
case "logout": {
|
|
50
|
+
const r = await account.logout({ forget: o.forget });
|
|
51
|
+
return { data: { ...r, status: await account.status() }, text: r.message };
|
|
52
|
+
}
|
|
53
|
+
default:
|
|
54
|
+
throw new UsageError("p3 chatgpt login | status | logout");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function describe(s: ChatGptStatus): string {
|
|
59
|
+
if (!s.connected) return s.registered ? "接続していません(このマシンは登録済み。p3 chatgpt login でサインイン)" : "接続していません(p3 chatgpt login でサインイン)";
|
|
60
|
+
const plan = s.planAllowed ? "ChatGPT プランを使います" : "プランの利用が許可されていません(もう一度サインインして同意してください)";
|
|
61
|
+
return `${s.email ?? "(アカウント不明)"} ${plan} トークンの期限 ${s.expiresAt?.slice(0, 16).replace("T", " ")}(使うときに更新)`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** ブラウザを開く(DevContainer では VS Code が BROWSER にホストで開く仕組みを入れる)。開けなくても URL は表示済み */
|
|
65
|
+
function openBrowser(url: string) {
|
|
66
|
+
const cmd = process.env.BROWSER || (process.platform === "darwin" ? "open" : process.platform === "win32" ? "explorer" : "xdg-open");
|
|
67
|
+
try {
|
|
68
|
+
const p = spawn(cmd, [url], { stdio: "ignore", detached: true });
|
|
69
|
+
p.on("error", () => {});
|
|
70
|
+
p.unref();
|
|
71
|
+
} catch {
|
|
72
|
+
// URL は表示してある
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/cli/codex.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CodexImageError, updateCodexImage, type ImageUpdate } from "../core/preflight/codexImage.ts";
|
|
2
|
+
import { UsageError } from "./project.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* p3 codex update。Codex を動かすイメージを今すぐ作り直し、入った Codex の版を表示する。
|
|
6
|
+
* プロジェクトを決める前に動く(このマシンの Docker のもの。プロジェクト・認証・個人設定の自動更新の停止に関係しない)。
|
|
7
|
+
* 進み具合は stderr に出し、--json の stdout は結果だけにする。
|
|
8
|
+
*/
|
|
9
|
+
export async function codexCommand(args: string[], docker = "docker"): Promise<{ data: unknown; text: string; code?: number }> {
|
|
10
|
+
const [sub] = args;
|
|
11
|
+
if (sub !== "update") throw new UsageError("p3 codex update(Codex のイメージを今すぐ作り直して、最新の Codex を入れる)");
|
|
12
|
+
let r: ImageUpdate;
|
|
13
|
+
try {
|
|
14
|
+
r = await updateCodexImage({ docker, onProgress: (t) => process.stderr.write(`${t}\n`) });
|
|
15
|
+
} catch (e) {
|
|
16
|
+
if (!(e instanceof CodexImageError)) throw e;
|
|
17
|
+
return {
|
|
18
|
+
data: { ok: false, step: e.step, error: e.message, detail: e.detail ?? null },
|
|
19
|
+
text: `更新できませんでした: ${e.message}${e.detail ? `\n ${e.detail}` : ""}`,
|
|
20
|
+
code: 1,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const change = r.previous && r.previous !== r.version ? `(${r.previous} から)` : r.previous ? "(変わらず。これが最新)" : "";
|
|
24
|
+
return {
|
|
25
|
+
data: { ok: true, ...r },
|
|
26
|
+
text: `Codex を更新しました: ${r.version}${change}\n イメージ ${r.image}${r.createdAt ? `(${r.createdAt.slice(0, 19).replace("T", " ")} 作成)` : ""}`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** 表示幅(全角は2)を考慮して列を揃える */
|
|
2
|
+
export function table(rows: string[][]): string {
|
|
3
|
+
const width = (s: string) => Array.from(s).reduce((w, ch) => w + (/[ᄀ-ᅟ⺀-가-힣豈-︰-﹏-⦆¢-₩]/.test(ch) ? 2 : 1), 0);
|
|
4
|
+
const cols = Math.max(0, ...rows.map((r) => r.length));
|
|
5
|
+
const max = Array.from({ length: cols - 1 }, (_, i) => Math.min(48, Math.max(...rows.map((r) => width(r[i] ?? "")))));
|
|
6
|
+
return rows
|
|
7
|
+
.map((r) => r.map((c, i) => (i < cols - 1 ? c + " ".repeat(Math.max(0, max[i] - width(c))) : c)).join(" ").trimEnd())
|
|
8
|
+
.join("\n");
|
|
9
|
+
}
|
package/src/cli/help.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { RELATION_TYPES, REQUEST_STATUSES, relationTypes } from "../shared/types.ts";
|
|
2
|
+
|
|
3
|
+
/** p3 help */
|
|
4
|
+
|
|
5
|
+
export const HELP = `p3(infodb p3)— 要望ごとにフォルダを分けて管理するファイルベースのタスク管理
|
|
6
|
+
|
|
7
|
+
使い方: p3 <コマンド> [引数] [オプション]
|
|
8
|
+
|
|
9
|
+
プロジェクト
|
|
10
|
+
init 管理したいリポジトリの中で実行。データのフォルダを作り(既にあれば参加し)、個人設定に登録する。
|
|
11
|
+
このリポジトリを本体の参照先として登録する
|
|
12
|
+
--project 名前 --dir フォルダ --repo-name 参照先の名前(既定はフォルダ名)--description
|
|
13
|
+
--instructions 観点 --agents --yes
|
|
14
|
+
project [ls | add <名前> <フォルダ> | rm <名前>] 個人設定のプロジェクト
|
|
15
|
+
config [set キー=値 ...] 設定の表示・変更(name description branchPattern instructions)
|
|
16
|
+
repo [ls | add | set | path | rm] Preflight が読む参照先(リポジトリ・フォルダ。数と名前は自由)
|
|
17
|
+
add <名前> [<パス>] [role=… readFirst=true writable=true] 共有の定義を足す
|
|
18
|
+
set <名前> キー=値 … 共有の定義を変える / path <名前> <パス> このマシンのパスだけ登録
|
|
19
|
+
rm <名前> 共有の定義ごと消す(--local はこのマシンのパスだけ)
|
|
20
|
+
user-config [set キー=値 ...] 個人設定(このマシン・この人。全プロジェクト共通)の値と出どころ(環境変数 / 個人設定 / 既定)
|
|
21
|
+
set ui.theme=system|light|dark / codex.auth / codex.authVolume / codex.authFile / codex.model
|
|
22
|
+
codex.effort / codex.ensureImage / preflight.engine / serve.host / serve.port(キー= で消す)
|
|
23
|
+
set codex.pathMap+=<このマシンのパス>=<Docker デーモンから見たパス> パスの対応を足す
|
|
24
|
+
set codex.pathMap-=<このマシンのパス> 外す(codex.pathMap= で全部外す)
|
|
25
|
+
progress 要望ごとの進捗(マイルストーンごと。--all で完了・見送りも。既定でも対応済を出す)
|
|
26
|
+
milestone [ls | add <id> | set <id> | rm <id>] マイルストーン(リリース) --title 名前 --due YYYY-MM-DD --done
|
|
27
|
+
release-notes [ls] マイルストーンごとのリリースノートの有無と要望の数
|
|
28
|
+
release-notes show <id> 保存したノート(本文・版)と、対象の要望(収録 / 対象外)・警告(未完了・記録なし など)
|
|
29
|
+
release-notes generate <id> 変更の記録から機能の要約を Codex で生成し、本文の案を stdout に出す(保存しない。進み具合と出典は stderr。
|
|
30
|
+
Ctrl-C で取り消す。材料が無ければ Codex を呼ばずに断る)--engine codex|mock(mock は要約しない試し用)
|
|
31
|
+
release-notes save <id> 本文を保存する --body 本文|- / --file 本文.md --based-on <材料の hash>(生成の案を元にしたとき)
|
|
32
|
+
既にあるノートの更新は --version <版>(show で見る。違えば競合で終了コード 3)
|
|
33
|
+
release-notes export <id> 保存した本文だけを stdout に出す(出典・frontmatter は出さない)
|
|
34
|
+
例: p3 release-notes generate v0.2 > draft.md → 直す → p3 release-notes save v0.2 --file draft.md
|
|
35
|
+
p3 release-notes export v0.2 > RELEASE.md
|
|
36
|
+
whoami 操作するプロジェクト・変更者・今の要望
|
|
37
|
+
serve [--port] [--host] ブラウザ用のビューアを起動(既定は個人設定の serve.port / serve.host か $P3_PORT / $P3_HOST)
|
|
38
|
+
chatgpt login | status | logout Preflight に使う ChatGPT プランの接続(このマシン。プロジェクトに属さない)
|
|
39
|
+
login: --paste(コールバックに届かないとき URL を貼る)--no-browser --port 1455
|
|
40
|
+
logout: --forget(このマシンの登録ごと消す)
|
|
41
|
+
codex update Codex のイメージを今すぐ作り直し、入った Codex の版を表示(Docker が要る。認証は要らない)
|
|
42
|
+
Preflight の前は、作ってから1日より古いときだけ作り直す
|
|
43
|
+
render <原稿.html> 自己完結した HTML / CSS を PNG にする(画面イメージと同じ描画。Docker が要る)
|
|
44
|
+
--out 画像.png --width 1280。render update で描画のイメージを作り直す
|
|
45
|
+
|
|
46
|
+
要望
|
|
47
|
+
request new <タイトル> --body 本文|- --area パス --due YYYY-MM-DD --milestone id --tag 値(外部 ID・分類。繰り返し可)
|
|
48
|
+
--attach ファイル(PNG / JPEG / xlsx。繰り返し可。作る前に全部確かめ、だめなら要望を作らない)
|
|
49
|
+
request ls 一覧(--status draft,active ... --milestone id --tag 値。繰り返すとどれか)
|
|
50
|
+
request show [<要望>] --brief 作業に要る項目だけ(本文・状態・ブランチ・タスクの一覧)
|
|
51
|
+
request set [<要望>] キー=値 title status due milestone tags areas(status: ${REQUEST_STATUSES.join(" ")})
|
|
52
|
+
--body 本文|- 本文を書き換える(- は標準入力。どの状態でも書き換えられる。--rev で楽観ロック)
|
|
53
|
+
例: p3 request show <要望> --brief --json で rev を見て
|
|
54
|
+
p3 request set <要望> --body - --rev 3 < body.md
|
|
55
|
+
評価のあとでタイトル・本文を変えると、その評価からはタスク化できない(もう一度 preflight)
|
|
56
|
+
--tag 値 ... タグをこの値の並びに置き換える(カンマで分けない。tags=a,b はカンマで分ける)
|
|
57
|
+
request archive <要望>
|
|
58
|
+
|
|
59
|
+
タスク(今の要望の中。--req <要望> で指定、要望の作業ツリーの中なら省略可)
|
|
60
|
+
ls 一覧 --status s1,s2 --area パス -q 語句 --repo <参照先>|none(作業先) --all(全要望)
|
|
61
|
+
show <T003|要望|語句> 詳細と関係(依存・置き換え)
|
|
62
|
+
--brief 作業に要る項目だけ(本文・状態・依存とその状態・置き換えの注意・成果物・rev)
|
|
63
|
+
new <タイトル> --body 本文|- --area a --label l --status --output 成果物(繰り返し可)
|
|
64
|
+
--repo <参照先>|none 作業先(作業先にできる参照先だけ。足りないブランチは割り当てる)
|
|
65
|
+
set <T003> キー=値 ... title status labels areas outputs repo(空で消す。outputs= はカンマ区切りで置き換える。repo=none は作業先なし)
|
|
66
|
+
--repo-output <参照先>=<成果物> リポジトリごとの成果物を足す(repoOutputs= で全部外す)
|
|
67
|
+
move <T003> <ステータス> --output URL・文章・パス(成果物を足す。繰り返し可。カンマで分けない)
|
|
68
|
+
--repo-output <参照先>=<URL> リポジトリごとの成果物(最後のタスクに全リポジトリの PR を残す)
|
|
69
|
+
--record 本文|- 変更の記録(何を変えたか・なぜ・入れた決まり・やめたもの。AI が完了にするときは必須。set でも直せる)
|
|
70
|
+
check <T003> [--off] 完了したタスクを人が確認して「済み」にする(--off で外す)
|
|
71
|
+
archive <T003> .archive/ へ移す
|
|
72
|
+
find <語句> 参照・タイトルで探す
|
|
73
|
+
|
|
74
|
+
Preflight
|
|
75
|
+
preflight [<要望>] 評価・細分化を実行し、完了まで待つ --engine codex|mock
|
|
76
|
+
前回の結果とまだ渡していないメモを引き継ぐ
|
|
77
|
+
--note 本文|- メモ(確認事項への回答・方針の変更)を書き足してから実行 --note-only 書くだけ
|
|
78
|
+
notes [<要望>] メモの一覧(次の Preflight に渡すもの・渡し済み)
|
|
79
|
+
attach [ls] 要望の添付(PNG / JPEG / xlsx)の一覧。要望は --req(要望の作業ツリーの中なら省略可)
|
|
80
|
+
attach add <ファイル> 添付を足す --description 説明 --source 出典。次の Preflight を始めるときに run に固定して渡す
|
|
81
|
+
attach get <A-ID> / rm <A-ID> 原本を書き出す(--out ファイル、--run PF-... でその run に固定した原本)/ 外す
|
|
82
|
+
drafts [<要望>] 最新の評価とタスク案 --run PF-...(評価対象が今の要望と同じか: inputMatch)
|
|
83
|
+
accept [<要望>] タスク案をタスク化 --run PF-... --only D1,D2 --skip D3
|
|
84
|
+
評価のあとでタイトル・本文が変わった run からはしない(code: stale_input。再評価する)
|
|
85
|
+
置き換えられる既存タスクを表示して残す。--archive-superseded でアーカイブ
|
|
86
|
+
|
|
87
|
+
共通オプション
|
|
88
|
+
--project 名前 操作するプロジェクト(既定: 今いるリポジトリに登録したもの → 登録が1つならそれ。
|
|
89
|
+
登録が1つだけで決まったときは読むだけ。変える操作は --project か、リポジトリの中で)
|
|
90
|
+
--dir パス データのフォルダを直接指す
|
|
91
|
+
--req 要望 今の要望(既定: $P3_REQUEST → 要望の作業ツリー)。ID の一部(k7m3x)でもよい
|
|
92
|
+
--json JSON で出力(AI 向け)
|
|
93
|
+
--actor 名前 変更者(既定: $P3_ACTOR → human:<git の user.name>)
|
|
94
|
+
--rev 番号 楽観ロック。指定した rev でなければ更新しない(set / move)
|
|
95
|
+
|
|
96
|
+
タスクの関係(同じ要望の中だけ。Preflight のタスク化が張り、手では張らない。A → B のとき A には「相手の役割 B」、B には「相手の役割 A」と出る):
|
|
97
|
+
${relationTypes.map((t) => ` ${t.padEnd(13)} ${RELATION_TYPES[t].verb} →「${RELATION_TYPES[t].label}」/ 逆「${RELATION_TYPES[t].inverse}」`).join("\n")}
|
|
98
|
+
`;
|
|
99
|
+
|
package/src/cli/main.ts
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { renderCommand } from "./render.ts";
|
|
2
|
+
import { daysUntil, localToday } from "../shared/dates.ts";
|
|
3
|
+
import { openProject } from "../core/context.ts";
|
|
4
|
+
import { machineSettingsSource, resolveMachineSettings, SettingsError } from "../core/machineSettings.ts";
|
|
5
|
+
import { progress, resolveRef, resolveRequestId, titleOf } from "../core/ops.ts";
|
|
6
|
+
import { OpRuleError } from "../core/requestOps.ts";
|
|
7
|
+
import { startServer } from "../server/server.ts";
|
|
8
|
+
import { ConflictError, NotFoundError } from "../core/store/collection.ts";
|
|
9
|
+
import { DataDirError, onlyRegistrationNotice, ProjectNotResolvedError, resolveProject, VIA_LABEL } from "../core/store/locate.ts";
|
|
10
|
+
import { loadUserConfig, UserConfigError } from "../core/userConfig.ts";
|
|
11
|
+
import { codexCommand } from "./codex.ts";
|
|
12
|
+
import { userConfigCommand } from "./userConfig.ts";
|
|
13
|
+
import { chatgptCommand } from "./chatgpt.ts";
|
|
14
|
+
import { table } from "./format.ts";
|
|
15
|
+
import { config, currentRequest, init, locateHere, projectCommand, repoCommand, resolveActor, UsageError } from "./project.ts";
|
|
16
|
+
import { HELP } from "./help.ts";
|
|
17
|
+
import { readsOnly } from "./readOnly.ts";
|
|
18
|
+
import { parse, type CommandEnv } from "./args.ts";
|
|
19
|
+
import { Output, bar } from "./output.ts";
|
|
20
|
+
import { requestCommand, milestoneCommand } from "./requestCommands.ts";
|
|
21
|
+
import { taskCommand } from "./taskCommands.ts";
|
|
22
|
+
import { preflightCommand } from "./preflightCommands.ts";
|
|
23
|
+
import { releaseNotesCommand } from "./releaseNotesCommands.ts";
|
|
24
|
+
import { ReleaseNoteError } from "../core/releaseNotes/store.ts";
|
|
25
|
+
import { GenerationRejected } from "../core/releaseNotes/generate.ts";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* p3 CLI。人も AI エージェントも使う。
|
|
29
|
+
*
|
|
30
|
+
* サーバを経由せず、プロジェクトのデータのフォルダのファイルを直接読み書きする。
|
|
31
|
+
* 操作するプロジェクトは --project、今いる場所(登録したリポジトリの中か)、個人設定から決める(store/locate.ts)。
|
|
32
|
+
* だから認証は要らず、サーバが動いていれば変更は監視経由でそのまま画面に反映される。
|
|
33
|
+
* AI は `--json` で機械可読な出力を得て、`P3_ACTOR=ai:<name>` で変更者を名乗る。
|
|
34
|
+
*
|
|
35
|
+
* 作業の単位は要望。タスクの操作は「今の要望」に対して行う。今の要望は --req、P3_REQUEST、
|
|
36
|
+
* または要望の作業ツリー(ブランチ req/<要望ID>-...)から決まる。
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
async function main(argv: string[]): Promise<number> {
|
|
40
|
+
const { values: o, positionals } = parse(argv);
|
|
41
|
+
const [cmd, ...args] = positionals;
|
|
42
|
+
if (!cmd || o.help || cmd === "help") {
|
|
43
|
+
process.stdout.write(HELP);
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
const cwd = process.cwd();
|
|
47
|
+
const out = new Output(o.json ?? false);
|
|
48
|
+
|
|
49
|
+
if (cmd === "init") {
|
|
50
|
+
console.log(
|
|
51
|
+
await init({
|
|
52
|
+
cwd,
|
|
53
|
+
project: o.project,
|
|
54
|
+
dir: o.dir,
|
|
55
|
+
name: o.name,
|
|
56
|
+
description: o.description,
|
|
57
|
+
instructions: o.instructions,
|
|
58
|
+
agents: o.agents,
|
|
59
|
+
yes: o.yes,
|
|
60
|
+
repoName: o["repo-name"],
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ChatGPT との接続はこのマシンのもの(どのプロジェクトにも属さない)なので、プロジェクトを決める前に扱う
|
|
67
|
+
if (cmd === "chatgpt") {
|
|
68
|
+
const r = await chatgptCommand(args, o);
|
|
69
|
+
out.result(r.data, () => r.text);
|
|
70
|
+
return r.code ?? 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Codex のイメージはこのマシンの Docker のもの。プロジェクト・認証が無くても更新できる
|
|
74
|
+
if (cmd === "codex") {
|
|
75
|
+
const r = await codexCommand(args);
|
|
76
|
+
out.result(r.data, () => r.text);
|
|
77
|
+
return r.code ?? 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 描画はこのマシンの Docker のもの。プロジェクトが決まらなくても使える(パスの対応は個人設定から)
|
|
81
|
+
if (cmd === "render") {
|
|
82
|
+
const r = await renderCommand(args, o, resolveMachineSettings(await loadUserConfig(), process.env));
|
|
83
|
+
out.result(r.data, () => r.text);
|
|
84
|
+
return r.code ?? 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 個人設定(このマシン・この人)。プロジェクトが決まらなくても使える
|
|
88
|
+
if (cmd === "user-config") {
|
|
89
|
+
const r = await userConfigCommand(args);
|
|
90
|
+
return out.result(r.data, () => r.text);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const user = await loadUserConfig();
|
|
94
|
+
if (cmd === "project") {
|
|
95
|
+
let current: string | undefined;
|
|
96
|
+
try {
|
|
97
|
+
current = resolveProject({ cwd, dir: o.dir, project: o.project, user }).name;
|
|
98
|
+
} catch {
|
|
99
|
+
// 決まらなくても一覧は出す
|
|
100
|
+
}
|
|
101
|
+
const r = await projectCommand(cwd, args, o, current);
|
|
102
|
+
return out.result(r.data, () => r.text);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const target = resolveProject({ cwd, dir: o.dir, project: o.project, user });
|
|
106
|
+
// 登録が1つだけで決まった(今いる場所では決まっていない)なら、変える操作は何も読み書きする前に止め、読むだけなら警告する
|
|
107
|
+
if (target.via === "only") {
|
|
108
|
+
const write = !readsOnly(cmd, args);
|
|
109
|
+
if (write) throw new ProjectNotResolvedError(onlyRegistrationNotice(target, true));
|
|
110
|
+
process.stderr.write(`${onlyRegistrationNotice(target, false)}\n`);
|
|
111
|
+
}
|
|
112
|
+
// マシンごとの設定は環境変数と個人設定から(.env は読まない)
|
|
113
|
+
const settings = resolveMachineSettings(user, process.env, { port: o.port, host: o.host });
|
|
114
|
+
|
|
115
|
+
if (cmd === "serve") {
|
|
116
|
+
// 待ち受け(host / port)は起動のときに決める。Codex と Preflight の設定は Preflight を始めるたびに個人設定から読み直す
|
|
117
|
+
const source = machineSettingsSource({ cli: { port: o.port, host: o.host } });
|
|
118
|
+
await startServer({ dataDir: target.dataDir, repos: target.repos, projectName: target.name, port: settings.serve.port, host: settings.serve.host, static: true, settings: source });
|
|
119
|
+
return await new Promise<number>(() => {}); // 終了まで動き続ける
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const ctx = await openProject(target.dataDir, { repos: target.repos, settings, projectName: target.name });
|
|
123
|
+
const actor = resolveActor(o.actor ?? process.env.P3_ACTOR, cwd);
|
|
124
|
+
const current = currentRequest(ctx, o.req ?? o.request ?? process.env.P3_REQUEST, cwd);
|
|
125
|
+
const expectedRev = o.rev !== undefined ? Number(o.rev) : undefined;
|
|
126
|
+
|
|
127
|
+
/** 要望の引数(省略時は今の要望) */
|
|
128
|
+
const requestArg = (raw: string | undefined): string => {
|
|
129
|
+
if (raw) {
|
|
130
|
+
const id = resolveRequestId(ctx, raw);
|
|
131
|
+
if (!id) throw new NotFoundError(raw);
|
|
132
|
+
return id;
|
|
133
|
+
}
|
|
134
|
+
if (!current) throw new UsageError("要望を指定してください(引数か --req。要望の作業ツリーの中なら省略可)");
|
|
135
|
+
return current;
|
|
136
|
+
};
|
|
137
|
+
/** タスクの引数(T003 は今の要望の中) */
|
|
138
|
+
const taskArg = (raw: string | undefined): string => {
|
|
139
|
+
if (!raw) throw new UsageError("タスクを指定してください(T003 / <要望>/T003)");
|
|
140
|
+
const ref = resolveRef(ctx, raw, current);
|
|
141
|
+
if (ref?.includes("/")) return ref;
|
|
142
|
+
if (!ref && !raw.includes("/") && !current) throw new UsageError(`${raw}: 要望を --req で指定してください`);
|
|
143
|
+
throw new NotFoundError(raw);
|
|
144
|
+
};
|
|
145
|
+
const split = (ref: string) => {
|
|
146
|
+
const [rid, tid] = ref.split("/");
|
|
147
|
+
return { col: ctx.ws.tasksOf(rid), rid, tid };
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const env: CommandEnv = { ctx, out, args, o, actor, current, expectedRev, requestArg, taskArg, split, cwd, target };
|
|
151
|
+
const handled = (await taskCommand(cmd, env)) ?? (await preflightCommand(cmd, env));
|
|
152
|
+
if (handled !== undefined) return handled;
|
|
153
|
+
|
|
154
|
+
switch (cmd) {
|
|
155
|
+
case "config": {
|
|
156
|
+
const r = await config(ctx.ws, args);
|
|
157
|
+
return out.result(r.data, () => r.text);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
case "repo": {
|
|
161
|
+
const r = await repoCommand(ctx.ws, target.name, cwd, args, { local: o.local });
|
|
162
|
+
return out.result(r.data, () => r.text);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
case "whoami": {
|
|
166
|
+
const here = locateHere(ctx, cwd);
|
|
167
|
+
return out.result({ project: target.name ?? null, dataDir: target.dataDir, via: target.via, here: here.repos, branch: here.branch ?? null, actor, request: current ?? null }, () =>
|
|
168
|
+
[
|
|
169
|
+
`プロジェクト ${target.name ?? "(未登録)"} ${target.dataDir}`,
|
|
170
|
+
`決まり方 ${target.via}(${VIA_LABEL[target.via]})`,
|
|
171
|
+
`今いる参照先 ${here.repos.length ? here.repos.join(", ") : "(どの参照先の中でもない。p3 repo ls)"}${here.branch ? ` ブランチ ${here.branch}` : ""}`,
|
|
172
|
+
`変更者 ${actor}`,
|
|
173
|
+
`要望 ${current ? `${current} ${titleOf(ctx, current)}` : "(なし)"}`,
|
|
174
|
+
].join("\n"),
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
case "progress": {
|
|
179
|
+
const ps = progress(ctx).filter((p) => o.all || !["done", "rejected"].includes(p.request.status));
|
|
180
|
+
const today = localToday();
|
|
181
|
+
return out.result(ps, () => {
|
|
182
|
+
const groups = [
|
|
183
|
+
...ctx.ws.project.milestones.map((m) => ({ m, ps: ps.filter((p) => p.request.milestone === m.id) })),
|
|
184
|
+
{ m: undefined, ps: ps.filter((p) => !p.request.milestone) },
|
|
185
|
+
];
|
|
186
|
+
return (
|
|
187
|
+
groups
|
|
188
|
+
.filter((g) => g.ps.length)
|
|
189
|
+
.map((g) => {
|
|
190
|
+
const done = g.ps.reduce((n, p) => n + p.done, 0);
|
|
191
|
+
const total = g.ps.reduce((n, p) => n + p.total, 0);
|
|
192
|
+
const head = g.m
|
|
193
|
+
? `■ ${g.m.title}(${g.m.id}${g.m.due ? ` · ${g.m.due}` : ""}${g.m.done ? " · リリース済み" : ""}) タスク ${done}/${total}`
|
|
194
|
+
: "■ マイルストーンなし";
|
|
195
|
+
const rows = g.ps.map((p) => [
|
|
196
|
+
` ${p.request.id}`,
|
|
197
|
+
p.request.status,
|
|
198
|
+
`${bar(p.total ? p.done / p.total : 0)} ${p.done}/${p.total}`,
|
|
199
|
+
p.request.due
|
|
200
|
+
? `${p.request.due}${daysUntil(p.request.due, today) < 0 && !["done", "rejected"].includes(p.request.status) ? " 超過" : ""}`
|
|
201
|
+
: "",
|
|
202
|
+
p.request.tags.map((t) => `#${t}`).join(" "),
|
|
203
|
+
p.request.title,
|
|
204
|
+
]);
|
|
205
|
+
return `${head}\n${table(rows)}`;
|
|
206
|
+
})
|
|
207
|
+
.join("\n\n") || "要望はありません"
|
|
208
|
+
);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
case "milestone":
|
|
213
|
+
case "milestones":
|
|
214
|
+
return milestoneCommand(ctx, out, args, o);
|
|
215
|
+
|
|
216
|
+
case "release-notes":
|
|
217
|
+
case "release-note":
|
|
218
|
+
return releaseNotesCommand(env);
|
|
219
|
+
|
|
220
|
+
// --- 要望 ---------------------------------------------------------------
|
|
221
|
+
case "request":
|
|
222
|
+
case "req":
|
|
223
|
+
return requestCommand(ctx, out, args, o, actor, requestArg, expectedRev);
|
|
224
|
+
|
|
225
|
+
default:
|
|
226
|
+
throw new UsageError(`不明なコマンド: ${cmd}(p3 help)`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
main(process.argv.slice(2)).then(
|
|
231
|
+
(code) => process.exit(code),
|
|
232
|
+
(e: unknown) => {
|
|
233
|
+
if (e instanceof ConflictError) {
|
|
234
|
+
process.stderr.write(`競合: ${e.message}。最新を取得してやり直してください\n`);
|
|
235
|
+
process.exit(3);
|
|
236
|
+
}
|
|
237
|
+
if (e instanceof UserConfigError) {
|
|
238
|
+
process.stderr.write(`${e.message}\n`);
|
|
239
|
+
process.exit(1);
|
|
240
|
+
}
|
|
241
|
+
if (e instanceof SettingsError) {
|
|
242
|
+
process.stderr.write(`設定: ${e.message}\n`);
|
|
243
|
+
process.exit(1);
|
|
244
|
+
}
|
|
245
|
+
if (e instanceof ProjectNotResolvedError || e instanceof DataDirError) {
|
|
246
|
+
process.stderr.write(`${e.message}\n`);
|
|
247
|
+
process.exit(1);
|
|
248
|
+
}
|
|
249
|
+
// リリースノート: 無い → 2、版の競合・既にある → 3、読めない・ID が使えない → 1
|
|
250
|
+
if (e instanceof ReleaseNoteError) {
|
|
251
|
+
process.stderr.write(`${e.code === "conflict" ? "競合: " : ""}${e.message}\n`);
|
|
252
|
+
process.exit(e.code === "not_found" ? 2 : e.code === "conflict" || e.code === "exists" ? 3 : 1);
|
|
253
|
+
}
|
|
254
|
+
// 生成を始められない(材料が無い・上限・実行中)。Codex は呼んでいない
|
|
255
|
+
if (e instanceof GenerationRejected) {
|
|
256
|
+
process.stderr.write(`${e.message}\n`);
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
if (e instanceof NotFoundError) {
|
|
260
|
+
process.stderr.write(`見つかりません: ${e.id}\n`);
|
|
261
|
+
process.exit(2);
|
|
262
|
+
}
|
|
263
|
+
process.stderr.write(`${e instanceof UsageError || e instanceof OpRuleError ? "" : "エラー: "}${(e as Error).message}\n`);
|
|
264
|
+
process.exit(1);
|
|
265
|
+
},
|
|
266
|
+
);
|
|
267
|
+
|