@pecot/workflow-mcp 6.0.0 → 7.0.1-dev.19
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/.claude-plugin/plugin.json +1 -1
- package/README.md +5 -58
- package/cli/dist/commands/board-add.js +11 -1
- package/cli/dist/commands/board-judgment.d.ts +12 -3
- package/cli/dist/commands/board-judgment.js +12 -6
- package/cli/dist/commands/board-move.js +9 -1
- package/cli/dist/commands/board-readiness.d.ts +3 -3
- package/cli/dist/commands/board-show.js +5 -2
- package/cli/dist/commands/board-sync.js +14 -5
- package/cli/dist/commands/board-view.d.ts +94 -5
- package/cli/dist/commands/board-view.js +119 -17
- package/cli/dist/commands/branch.js +11 -17
- package/cli/dist/commands/command-definition.d.ts +19 -2
- package/cli/dist/commands/command-definition.js +9 -0
- package/cli/dist/commands/failure-kind.d.ts +1 -1
- package/cli/dist/commands/failure-kind.js +1 -0
- package/cli/dist/commands/issue-board.d.ts +31 -3
- package/cli/dist/commands/issue-board.js +28 -4
- package/cli/dist/commands/issue-comment.js +19 -2
- package/cli/dist/commands/issue-create.js +96 -17
- package/cli/dist/commands/issue-dependency.js +51 -14
- package/cli/dist/commands/issue-readiness.d.ts +30 -2
- package/cli/dist/commands/issue-readiness.js +35 -0
- package/cli/dist/commands/issue-reopen.js +18 -3
- package/cli/dist/commands/issue-shared.d.ts +11 -5
- package/cli/dist/commands/issue-shared.js +25 -6
- package/cli/dist/commands/issue-show.js +78 -8
- package/cli/dist/commands/names.d.ts +1 -1
- package/cli/dist/commands/names.js +3 -3
- package/cli/dist/commands/output.d.ts +18 -2
- package/cli/dist/commands/output.js +16 -3
- package/cli/dist/commands/pr-merge.d.ts +3 -0
- package/cli/dist/commands/pr-merge.js +225 -0
- package/cli/dist/commands/pr-reference.d.ts +8 -0
- package/cli/dist/commands/pr-reference.js +30 -0
- package/cli/dist/commands/pr-restack.d.ts +6 -0
- package/cli/dist/commands/pr-restack.js +231 -0
- package/cli/dist/commands/pr-waiting.d.ts +41 -2
- package/cli/dist/commands/pr-waiting.js +74 -37
- package/cli/dist/commands/pr.d.ts +10 -6
- package/cli/dist/commands/pr.js +214 -111
- package/cli/dist/commands/project-sync.d.ts +10 -2
- package/cli/dist/commands/project-sync.js +7 -6
- package/cli/dist/commands/project.js +174 -17
- package/cli/dist/commands/registry.js +2 -0
- package/cli/dist/commands/release.js +67 -18
- package/cli/dist/commands/renamed-commands.js +0 -1
- package/cli/dist/commands/repository-match.js +7 -2
- package/cli/dist/commands/restack-reading.d.ts +45 -0
- package/cli/dist/commands/restack-reading.js +29 -0
- package/cli/dist/commands/session-finish.js +132 -28
- package/cli/dist/commands/session-start.js +31 -60
- package/cli/dist/commands/session.js +119 -135
- package/cli/dist/commands/tracker-sync-dependabot.js +21 -4
- package/cli/dist/commands/tracker-sync-security.js +22 -4
- package/cli/dist/commands/tracker-sync.d.ts +30 -0
- package/cli/dist/commands/tracker-sync.js +15 -0
- package/cli/dist/commands/tracker.js +2 -0
- package/cli/dist/commands/work-target.d.ts +14 -9
- package/cli/dist/commands/work-target.js +19 -19
- package/cli/dist/commands/worktree.js +71 -5
- package/cli/dist/domain/branch-name.d.ts +7 -0
- package/cli/dist/domain/branch-name.js +23 -1
- package/cli/dist/domain/command-hint.d.ts +1 -1
- package/cli/dist/domain/issue-readout.d.ts +0 -4
- package/cli/dist/domain/pull-request.d.ts +20 -3
- package/cli/dist/domain/pull-request.js +25 -9
- package/cli/dist/domain/readiness.d.ts +17 -0
- package/cli/dist/domain/readiness.js +39 -2
- package/cli/dist/domain/restack.d.ts +66 -0
- package/cli/dist/domain/restack.js +57 -0
- package/cli/dist/domain/state.d.ts +41 -12
- package/cli/dist/domain/state.js +30 -14
- package/cli/dist/domain/work-start.d.ts +0 -4
- package/cli/dist/domain/work-start.js +0 -7
- package/cli/dist/infra/git.d.ts +69 -0
- package/cli/dist/infra/git.js +117 -0
- package/cli/dist/infra/github/pulls.d.ts +81 -2
- package/cli/dist/infra/github/pulls.js +116 -5
- package/cli/dist/infra/github/queries.d.ts +4 -1
- package/cli/dist/infra/github/queries.js +47 -32
- package/cli/dist/infra/github/readout.js +0 -33
- package/cli/dist/infra/paths.d.ts +1 -3
- package/cli/dist/infra/paths.js +2 -45
- package/cli/dist/infra/state-store.d.ts +3 -8
- package/cli/dist/infra/state-store.js +6 -24
- package/cli/dist/mcp/result.d.ts +63 -16
- package/cli/dist/mcp/result.js +106 -30
- package/cli/dist/mcp/server.js +37 -4
- package/cli/templates/comment/plan.md +2 -2
- package/cli/templates/comment/review-findings.md +3 -2
- package/cli/templates/issue/bug.md +13 -4
- package/cli/templates/issue/task.md +13 -4
- package/cli/templates/workflow/pecot-board-sync.yml +3 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -227,7 +227,7 @@ function loadExistingConfig(configPath) {
|
|
|
227
227
|
return existsSync(configPath) ? loadConfig(configPath) : undefined;
|
|
228
228
|
}
|
|
229
229
|
/**
|
|
230
|
-
GitHub Projects V2
|
|
230
|
+
GitHub Projects V2 の情報から設定ファイルを作るか更新し、アクティブにする。設定ファイルのパスと、行に出した扱いを返す。
|
|
231
231
|
pecot-workflow に合うプロジェクトだけを扱う。suffix はその名前の workflow フィールドを使う。
|
|
232
232
|
skipIfUnchanged は、設定ファイルの内容が同じなら何も書かない。isDryRun は読むだけで、書く操作を planned で出す
|
|
233
233
|
*/
|
|
@@ -265,18 +265,19 @@ export async function syncProjectConfig(out, client, target) {
|
|
|
265
265
|
const normalized = parseProjectConfig(parseJsonText(serializeProjectConfig(config)));
|
|
266
266
|
if (skipIfUnchanged && existing !== undefined && serializeProjectConfig(existing) === serializeProjectConfig(normalized)) {
|
|
267
267
|
out.planned({ verb: 'unchanged', target: `config file ${configPath}` });
|
|
268
|
-
return configPath;
|
|
268
|
+
return { configPath, change: 'unchanged', activeProject: undefined };
|
|
269
269
|
}
|
|
270
270
|
const verb = existing === undefined ? 'create' : 'update';
|
|
271
|
+
const activeProject = path.parse(configPath).name;
|
|
271
272
|
if (target.isDryRun === true) {
|
|
272
273
|
out.planned({ verb, target: `config file ${configPath}` });
|
|
273
|
-
out.planned({ verb: 'set', target: `active project to ${
|
|
274
|
-
return configPath;
|
|
274
|
+
out.planned({ verb: 'set', target: `active project to ${activeProject}` });
|
|
275
|
+
return { configPath, change: verb, activeProject };
|
|
275
276
|
}
|
|
276
277
|
saveConfig(config, configPath);
|
|
277
278
|
out.done({ verb, target: `config file ${configPath}` });
|
|
278
279
|
setActiveConfig(configPath);
|
|
279
|
-
out.done({ verb: 'set', target: `active project to ${
|
|
280
|
-
return configPath;
|
|
280
|
+
out.done({ verb: 'set', target: `active project to ${activeProject}` });
|
|
281
|
+
return { configPath, change: verb, activeProject };
|
|
281
282
|
}
|
|
282
283
|
//# sourceMappingURL=project-sync.js.map
|
|
@@ -17,9 +17,15 @@ import { commandHint, hinted, inputHint, inputNameHint, placeholder } from './co
|
|
|
17
17
|
import { requireActiveConfig, stopWith } from './command-stop.js';
|
|
18
18
|
import { kindOfFailure } from './failure.js';
|
|
19
19
|
import { createGitHubClient } from './github-client.js';
|
|
20
|
-
import { createOutput } from './output.js';
|
|
20
|
+
import { createOutput, DRY_RUN_FIELD } from './output.js';
|
|
21
21
|
import { BLOCKED_SPEC, NEEDS_ATTENTION_SPEC, PRIORITY_FIELD_OPTIONS, SIZE_FIELD_OPTIONS, STATUS_FIELD_NAME, WORKFLOW_FIELD_OPTIONS, buildRepository, failApi, fieldNodesOf, findProjectByTitle, hasWorkflowField, lastFieldNamed, missingRequiredOptions, stopMissingOptions, syncProjectConfig, textOf, } from './project-sync.js';
|
|
22
22
|
const DEFAULT_HOST = 'github.com';
|
|
23
|
+
function linkChange(existing) {
|
|
24
|
+
return existing === undefined ? 'create' : 'update';
|
|
25
|
+
}
|
|
26
|
+
function setChange(hasPrevious) {
|
|
27
|
+
return hasPrevious ? 'update' : 'create';
|
|
28
|
+
}
|
|
23
29
|
const dryRunInput = z.boolean().default(false).describe('Show what would change without writing anything');
|
|
24
30
|
const AGGREGATION_REPOSITORY_PATTERN = /^[\w.-]+\/[\w.-]+$/u;
|
|
25
31
|
const MISSING_PATH_CODES = new Set(['ENOENT', 'ENOTDIR', 'ELOOP']);
|
|
@@ -78,10 +84,18 @@ function validated(config) {
|
|
|
78
84
|
return parseProjectConfig(parseJsonText(serializeProjectConfig(config)));
|
|
79
85
|
}
|
|
80
86
|
// project list
|
|
87
|
+
const LIST_ROW = z.strictObject({
|
|
88
|
+
name: z.string().describe('Name of the project config (the file name without .json)'),
|
|
89
|
+
active: z.boolean().describe('Whether this config is the active project'),
|
|
90
|
+
});
|
|
91
|
+
const LIST_OUTPUT = z.strictObject({
|
|
92
|
+
projects: z.array(LIST_ROW).describe('Project configs under the projects directory (an empty array when there is none)'),
|
|
93
|
+
});
|
|
81
94
|
const listCommand = defineCommand({
|
|
82
95
|
path: ['project', 'list'],
|
|
83
96
|
description: 'List available projects',
|
|
84
97
|
input: z.strictObject({}),
|
|
98
|
+
output: LIST_OUTPUT,
|
|
85
99
|
positional: [],
|
|
86
100
|
interactive: false,
|
|
87
101
|
run: (_input, io) => {
|
|
@@ -92,18 +106,32 @@ const listCommand = defineCommand({
|
|
|
92
106
|
if (files.length === 0) {
|
|
93
107
|
lines.push(' none');
|
|
94
108
|
out.data(lines.join('\n'));
|
|
109
|
+
out.result({ projects: [] });
|
|
95
110
|
return Promise.resolve(0);
|
|
96
111
|
}
|
|
97
112
|
const active = getActiveConfigPath();
|
|
113
|
+
const projects = [];
|
|
98
114
|
for (const file of files) {
|
|
99
115
|
const isActive = active !== undefined && resolveRealPath(path.join(directory, file)) === resolveRealPath(active);
|
|
100
116
|
lines.push(` ${path.parse(file).name}${isActive ? ' [ACTIVE]' : ''}`);
|
|
117
|
+
projects.push({ name: path.parse(file).name, active: isActive });
|
|
101
118
|
}
|
|
102
119
|
out.data(lines.join('\n'));
|
|
120
|
+
out.result({ projects });
|
|
103
121
|
return Promise.resolve(0);
|
|
104
122
|
},
|
|
105
123
|
});
|
|
106
124
|
// project search
|
|
125
|
+
const SEARCH_ROW = z.strictObject({
|
|
126
|
+
number: z.int().optional().describe('Project number (omitted when GitHub did not return it)'),
|
|
127
|
+
title: z.string().optional().describe('Project title (omitted when GitHub did not return it)'),
|
|
128
|
+
url: z.string().optional().describe('Project URL (omitted when GitHub did not return it)'),
|
|
129
|
+
});
|
|
130
|
+
const SEARCH_OUTPUT = z.strictObject({
|
|
131
|
+
owner: z.string().describe('Project owner that was searched'),
|
|
132
|
+
host: z.string().describe('GitHub host that was searched'),
|
|
133
|
+
projects: z.array(SEARCH_ROW).describe('Projects of the owner'),
|
|
134
|
+
});
|
|
107
135
|
const searchCommand = defineCommand({
|
|
108
136
|
path: ['project', 'search'],
|
|
109
137
|
description: 'Search projects through the GitHub API',
|
|
@@ -111,6 +139,7 @@ const searchCommand = defineCommand({
|
|
|
111
139
|
owner: z.string().describe('Project owner'),
|
|
112
140
|
host: z.string().default(DEFAULT_HOST).describe('GitHub host'),
|
|
113
141
|
}),
|
|
142
|
+
output: SEARCH_OUTPUT,
|
|
114
143
|
positional: ['owner'],
|
|
115
144
|
shortFlags: { host: '-h' },
|
|
116
145
|
interactive: false,
|
|
@@ -129,6 +158,11 @@ const searchCommand = defineCommand({
|
|
|
129
158
|
lines.push(`${padEndCodePoints(number, 4)} ${padEndCodePoints(title, SEARCH_TITLE_WIDTH)} ${project['url'] === undefined ? '' : textOf(project['url'])}`);
|
|
130
159
|
}
|
|
131
160
|
out.data(lines.join('\n'));
|
|
161
|
+
out.result({ owner, host, projects: projects.map(project => ({
|
|
162
|
+
...typeof project['number'] === 'number' && { number: project['number'] },
|
|
163
|
+
...typeof project['title'] === 'string' && { title: project['title'] },
|
|
164
|
+
...typeof project['url'] === 'string' && { url: project['url'] },
|
|
165
|
+
})) });
|
|
132
166
|
});
|
|
133
167
|
return 0;
|
|
134
168
|
},
|
|
@@ -146,8 +180,22 @@ function optionInputsOf(field) {
|
|
|
146
180
|
};
|
|
147
181
|
});
|
|
148
182
|
}
|
|
183
|
+
// フィールドごとの結果を溜め、進むたびに全体を渡す。
|
|
184
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- data の型が可変の配列
|
|
185
|
+
function fieldReporter(publish) {
|
|
186
|
+
const entries = new Map();
|
|
187
|
+
return (name, change, addedOption) => {
|
|
188
|
+
const entry = entries.get(name) ?? { name, change, addedOptions: [] };
|
|
189
|
+
entry.change = change;
|
|
190
|
+
if (addedOption !== undefined)
|
|
191
|
+
entry.addedOptions.push(addedOption);
|
|
192
|
+
entries.set(name, entry);
|
|
193
|
+
publish?.(Array.from(entries.values(), report => ({ ...report, addedOptions: [...report.addedOptions] })));
|
|
194
|
+
};
|
|
195
|
+
}
|
|
149
196
|
// 既にあるフィールドに選択肢を 1 つ足す。足した(予行では、足す予定の)数(0 か 1)を返す
|
|
150
|
-
async function addFieldOption(out, client, field, spec,
|
|
197
|
+
async function addFieldOption(out, client, field, spec, run) {
|
|
198
|
+
const { isDryRun, mark } = run;
|
|
151
199
|
const { option } = spec;
|
|
152
200
|
const fieldName = textOf(field['name']);
|
|
153
201
|
const existing = optionInputsOf(field);
|
|
@@ -156,11 +204,13 @@ async function addFieldOption(out, client, field, spec, isDryRun) {
|
|
|
156
204
|
const unchanged = { verb: 'unchanged', target: `option ${option.name} in field ${fieldName}` };
|
|
157
205
|
out.planned(unchanged);
|
|
158
206
|
out.done(unchanged);
|
|
207
|
+
mark(fieldName, 'unchanged');
|
|
159
208
|
return 0;
|
|
160
209
|
}
|
|
161
210
|
const added = { verb: 'add', target: `option ${option.name} to field ${fieldName}` };
|
|
162
211
|
if (isDryRun) {
|
|
163
212
|
out.planned(added);
|
|
213
|
+
mark(fieldName, 'update', option.name);
|
|
164
214
|
return 1;
|
|
165
215
|
}
|
|
166
216
|
try {
|
|
@@ -171,22 +221,25 @@ async function addFieldOption(out, client, field, spec, isDryRun) {
|
|
|
171
221
|
throw error;
|
|
172
222
|
// 選択肢の id を拒む GHES などで足せなくても、作ったフィールドと設定ファイルの同期は進める
|
|
173
223
|
out.warning(`could not add option ${option.name} to field ${fieldName}: ${error.message}`);
|
|
224
|
+
mark(fieldName, 'unchanged');
|
|
174
225
|
return 0;
|
|
175
226
|
}
|
|
176
227
|
out.done(added);
|
|
228
|
+
mark(fieldName, 'update', option.name);
|
|
177
229
|
return 1;
|
|
178
230
|
}
|
|
179
231
|
// 既にあるフィールドに足す選択肢。fields は作る前の状態なので、作ったばかりの進行の欄は「無い」扱いで何も出さない(created の行が出ている)
|
|
180
232
|
// 足した(予行では、足す予定の)選択肢の数を返す
|
|
181
|
-
async function addMissingOptions(out, client, fields, workflowFieldName,
|
|
233
|
+
async function addMissingOptions(out, client, fields, workflowFieldName, run) {
|
|
182
234
|
const workflowField = lastFieldNamed(fields, workflowFieldName);
|
|
183
|
-
const blocked = workflowField === undefined ? 0 : await addFieldOption(out, client, workflowField, BLOCKED_SPEC,
|
|
235
|
+
const blocked = workflowField === undefined ? 0 : await addFieldOption(out, client, workflowField, BLOCKED_SPEC, run);
|
|
184
236
|
const statusField = lastFieldNamed(fields, STATUS_FIELD_NAME);
|
|
185
237
|
if (statusField === undefined) {
|
|
186
238
|
skipped(out, `field ${STATUS_FIELD_NAME} (not found)`);
|
|
239
|
+
run.mark(STATUS_FIELD_NAME, 'skip');
|
|
187
240
|
return blocked;
|
|
188
241
|
}
|
|
189
|
-
return blocked + await addFieldOption(out, client, statusField, NEEDS_ATTENTION_SPEC,
|
|
242
|
+
return blocked + await addFieldOption(out, client, statusField, NEEDS_ATTENTION_SPEC, run);
|
|
190
243
|
}
|
|
191
244
|
function skipped(out, target) {
|
|
192
245
|
out.planned({ verb: 'skip', target });
|
|
@@ -194,8 +247,9 @@ function skipped(out, target) {
|
|
|
194
247
|
}
|
|
195
248
|
// フィールドを作り、既にあるフィールドには足りない選択肢を足す。既にある進行の欄の必須の値が欠けていれば、何も書かずに止める。
|
|
196
249
|
// 作る・足す(予行では、その予定の)フィールドと選択肢の数を返す
|
|
197
|
-
async function initializeFields(out, client, target,
|
|
250
|
+
async function initializeFields(out, client, target, run) {
|
|
198
251
|
const { owner, name, suffix } = target;
|
|
252
|
+
const { isDryRun, mark } = run;
|
|
199
253
|
const project = await findProjectByTitle(out, client, owner, name);
|
|
200
254
|
const projectId = requireString(project['id'], 'project.id');
|
|
201
255
|
const projectInfo = await client.getProjectFields(owner, requireNumber(project['number'], 'project.number'));
|
|
@@ -218,18 +272,31 @@ async function initializeFields(out, client, target, isDryRun) {
|
|
|
218
272
|
for (const [fieldName, options] of wanted) {
|
|
219
273
|
if (fields.some(field => jsonField(field, 'name') === fieldName)) {
|
|
220
274
|
skipped(out, `field ${fieldName} (already exists)`);
|
|
275
|
+
mark(fieldName, 'unchanged');
|
|
221
276
|
continue;
|
|
222
277
|
}
|
|
223
278
|
newFieldCount += 1;
|
|
224
279
|
if (isDryRun) {
|
|
225
280
|
out.planned({ verb: 'create', target: `field ${fieldName}` });
|
|
281
|
+
mark(fieldName, 'create');
|
|
226
282
|
continue;
|
|
227
283
|
}
|
|
228
284
|
const created = await client.createProjectField(projectId, fieldName, options);
|
|
229
285
|
out.done({ verb: 'create', target: `field ${fieldName} (ID: ${requireString(created['id'], 'field.id')})` });
|
|
286
|
+
mark(fieldName, 'create');
|
|
230
287
|
}
|
|
231
|
-
return newFieldCount + await addMissingOptions(out, client, fields, workflowFieldName,
|
|
288
|
+
return newFieldCount + await addMissingOptions(out, client, fields, workflowFieldName, run);
|
|
232
289
|
}
|
|
290
|
+
const FIELD_CHANGES = z.enum(['create', 'update', 'unchanged', 'skip']);
|
|
291
|
+
const INIT_ROW = z.strictObject({
|
|
292
|
+
name: z.string().describe('Name of the project field'),
|
|
293
|
+
change: FIELD_CHANGES.describe('create: the field was created; update: options were added to it; unchanged: nothing to do; skip: the field was not found'),
|
|
294
|
+
addedOptions: z.array(z.string()).describe('Names of the options added to the field (empty when none)'),
|
|
295
|
+
});
|
|
296
|
+
const INIT_OUTPUT = z.strictObject({
|
|
297
|
+
fields: z.array(INIT_ROW).describe('The workflow, priority and size fields, plus the Status field when its options were looked at'),
|
|
298
|
+
dryRun: DRY_RUN_FIELD,
|
|
299
|
+
});
|
|
233
300
|
const initCommand = defineCommand({
|
|
234
301
|
path: ['project', 'init'],
|
|
235
302
|
description: 'Add pecot-workflow fields to an existing project, and add the Blocked and Needs Attention options to the fields that already exist',
|
|
@@ -240,6 +307,7 @@ const initCommand = defineCommand({
|
|
|
240
307
|
suffix: z.string().describe('Suffix of the workflow field'),
|
|
241
308
|
dry_run: dryRunInput,
|
|
242
309
|
}),
|
|
310
|
+
output: INIT_OUTPUT,
|
|
243
311
|
positional: ['owner', 'name'],
|
|
244
312
|
shortFlags: { host: '-h', suffix: '-s', dry_run: '-n' },
|
|
245
313
|
interactive: false,
|
|
@@ -247,7 +315,12 @@ const initCommand = defineCommand({
|
|
|
247
315
|
const out = createOutput(input.dry_run, io);
|
|
248
316
|
const { owner, name, host, suffix } = input;
|
|
249
317
|
const client = createGitHubClient(out, host);
|
|
250
|
-
|
|
318
|
+
if (input.dry_run)
|
|
319
|
+
out.result({});
|
|
320
|
+
const mark = fieldReporter((fields) => {
|
|
321
|
+
out.result({ fields });
|
|
322
|
+
});
|
|
323
|
+
const changeCount = await guarded(out, 'initialize project fields', async () => await initializeFields(out, client, input, { isDryRun: input.dry_run, mark }));
|
|
251
324
|
// 設定ファイルは作るフィールドと選択肢の ID を書くので、予行では作る前の設定を出さない
|
|
252
325
|
if (changeCount > 0 && input.dry_run)
|
|
253
326
|
return 0;
|
|
@@ -258,6 +331,13 @@ const initCommand = defineCommand({
|
|
|
258
331
|
},
|
|
259
332
|
});
|
|
260
333
|
// project create
|
|
334
|
+
const CREATE_OUTPUT = z.strictObject({
|
|
335
|
+
number: z.int().optional().describe('Number of the created project (omitted on dry_run)'),
|
|
336
|
+
url: z.string().optional().describe('URL of the created project (omitted on dry_run)'),
|
|
337
|
+
title: z.string().describe('Title of the project'),
|
|
338
|
+
owner: z.string().describe('Project owner'),
|
|
339
|
+
dryRun: DRY_RUN_FIELD,
|
|
340
|
+
});
|
|
261
341
|
const projectCreationCommand = defineCommand({
|
|
262
342
|
path: ['project', 'create'],
|
|
263
343
|
description: 'Create a new project (to add the fields to an existing project, use project init)',
|
|
@@ -268,6 +348,7 @@ const projectCreationCommand = defineCommand({
|
|
|
268
348
|
suffix: z.string().describe('Suffix of the workflow field'),
|
|
269
349
|
dry_run: dryRunInput,
|
|
270
350
|
}),
|
|
351
|
+
output: CREATE_OUTPUT,
|
|
271
352
|
positional: ['owner', 'title'],
|
|
272
353
|
shortFlags: { host: '-h', suffix: '-s', dry_run: '-n' },
|
|
273
354
|
interactive: false,
|
|
@@ -292,12 +373,19 @@ const projectCreationCommand = defineCommand({
|
|
|
292
373
|
// フィールドと設定ファイルは作ったプロジェクトの ID を使うので、予行ではプロジェクトの行だけ出す
|
|
293
374
|
if (input.dry_run) {
|
|
294
375
|
out.planned({ verb: 'create', target: `project ${title} for ${owner}` });
|
|
376
|
+
out.result({ title, owner });
|
|
295
377
|
return;
|
|
296
378
|
}
|
|
297
379
|
const created = await client.createProject(ownerId, title);
|
|
298
380
|
out.done({ verb: 'create', target: `project #${textOf(created['number'])} ${textOf(created['url'])}` });
|
|
381
|
+
out.result({
|
|
382
|
+
title,
|
|
383
|
+
owner,
|
|
384
|
+
...typeof created['number'] === 'number' && { number: created['number'] },
|
|
385
|
+
...typeof created['url'] === 'string' && { url: created['url'] },
|
|
386
|
+
});
|
|
299
387
|
await guarded(out, 'initialize project fields', async () => {
|
|
300
|
-
await initializeFields(out, client, { owner, name: title, suffix }, false);
|
|
388
|
+
await initializeFields(out, client, { owner, name: title, suffix }, { isDryRun: false, mark: fieldReporter(undefined) });
|
|
301
389
|
});
|
|
302
390
|
await guarded(out, 'sync project config', async () => {
|
|
303
391
|
await syncProjectConfig(out, client, { owner, name: title, host, suffix });
|
|
@@ -336,7 +424,7 @@ async function activateFromConfigFile(out, configPath, host, isDryRun) {
|
|
|
336
424
|
const title = projectInfo['title'];
|
|
337
425
|
if (typeof title !== 'string' || title === '')
|
|
338
426
|
stopWith(out, `could not read the title of project #${String(config.project.number)}`, 'project-not-found');
|
|
339
|
-
await syncProjectConfig(out, client, { owner: config.owner, name: title, host: config.host, isDryRun });
|
|
427
|
+
reportSynced(out, await syncProjectConfig(out, client, { owner: config.owner, name: title, host: config.host, suffix: config.workflow_suffix, isDryRun }));
|
|
340
428
|
});
|
|
341
429
|
}
|
|
342
430
|
async function resolveActivationOwner(out, client, owner) {
|
|
@@ -371,15 +459,20 @@ async function echoInitializedProjects(out, client, host, owner) {
|
|
|
371
459
|
if (initialized.length === 0) {
|
|
372
460
|
lines.push(' none');
|
|
373
461
|
out.data(lines.join('\n'));
|
|
462
|
+
out.result({ candidates: [] });
|
|
374
463
|
return;
|
|
375
464
|
}
|
|
376
465
|
const activeNumber = activeProjectNumber(host, owner);
|
|
466
|
+
const candidates = [];
|
|
377
467
|
for (const project of initialized) {
|
|
378
468
|
const number = jsonField(project, 'number');
|
|
379
469
|
const title = jsonField(project, 'title');
|
|
380
|
-
|
|
470
|
+
const isActive = activeNumber === number;
|
|
471
|
+
lines.push(` #${textOf(number)}: ${title === undefined ? '(untitled)' : textOf(title)}${isActive ? ' [ACTIVE]' : ''}`);
|
|
472
|
+
candidates.push({ ...typeof number === 'number' && { number }, ...typeof title === 'string' && { title }, active: isActive });
|
|
381
473
|
}
|
|
382
474
|
out.data(lines.join('\n'));
|
|
475
|
+
out.result({ candidates });
|
|
383
476
|
}
|
|
384
477
|
function activeProjectNumber(host, owner) {
|
|
385
478
|
const activePath = getActiveConfigPath();
|
|
@@ -413,10 +506,26 @@ async function activateByReference(out, client, target) {
|
|
|
413
506
|
if (!hasWorkflowField(asArray(jsonField(info['fields'], 'nodes')))) {
|
|
414
507
|
stopWith(out, hinted `project "${title}" is not initialized\nrun: ${commandHint(['project', 'init'], { owner, name: title, host, suffix: placeholder('suffix') })}`, 'not-initialized');
|
|
415
508
|
}
|
|
416
|
-
await syncProjectConfig(out, client, { owner, name: title, host, isDryRun });
|
|
509
|
+
reportSynced(out, await syncProjectConfig(out, client, { owner, name: title, host, isDryRun }));
|
|
417
510
|
}
|
|
418
511
|
const ACTIVATE_PATH = ['project', 'activate'];
|
|
419
512
|
const LINK_PATH = ['project', 'link'];
|
|
513
|
+
const CANDIDATE_ROW = z.strictObject({
|
|
514
|
+
number: z.int().optional().describe('Project number'),
|
|
515
|
+
title: z.string().optional().describe('Project title'),
|
|
516
|
+
active: z.boolean().describe('Whether this project is the active one'),
|
|
517
|
+
});
|
|
518
|
+
const ACTIVATE_OUTPUT = z.strictObject({
|
|
519
|
+
project: z.string().optional().describe('Name of the project config that was (on dry_run, would be) made active'),
|
|
520
|
+
configPath: z.string().optional().describe('Path of the project config file'),
|
|
521
|
+
change: z.enum(['create', 'update', 'unchanged']).optional().describe('What happened to the config file'),
|
|
522
|
+
candidates: z.array(CANDIDATE_ROW).optional().describe('Initialized projects of the owner, given only when no project was named (nothing was activated)'),
|
|
523
|
+
dryRun: DRY_RUN_FIELD,
|
|
524
|
+
});
|
|
525
|
+
// 設定ファイルの結果を data に渡す
|
|
526
|
+
function reportSynced(out, synced) {
|
|
527
|
+
out.result({ ...synced.activeProject !== undefined && { project: synced.activeProject }, configPath: synced.configPath, change: synced.change });
|
|
528
|
+
}
|
|
420
529
|
const activateCommand = defineCommand({
|
|
421
530
|
path: ['project', 'activate'],
|
|
422
531
|
description: 'Activate an initialized project',
|
|
@@ -426,6 +535,7 @@ const activateCommand = defineCommand({
|
|
|
426
535
|
host: z.string().optional().describe('GitHub host'),
|
|
427
536
|
dry_run: dryRunInput,
|
|
428
537
|
}),
|
|
538
|
+
output: ACTIVATE_OUTPUT,
|
|
429
539
|
positional: ['project'],
|
|
430
540
|
shortFlags: { owner: '-o', host: '-h', dry_run: '-n' },
|
|
431
541
|
interactive: false,
|
|
@@ -447,8 +557,9 @@ example: ${commandHint(ACTIVATE_PATH, { project: 'ghes.example.com_example-org_e
|
|
|
447
557
|
}
|
|
448
558
|
const client = createGitHubClient(out, host);
|
|
449
559
|
const owner = await resolveActivationOwner(out, client, input.owner);
|
|
560
|
+
// 一覧は書き込まないので、dry_run でも data に dryRun を足さない
|
|
450
561
|
if (project === undefined)
|
|
451
|
-
await echoInitializedProjects(
|
|
562
|
+
await echoInitializedProjects(createOutput(false, io), client, host, owner);
|
|
452
563
|
else
|
|
453
564
|
await activateByReference(out, client, { host, owner, project, isDryRun: input.dry_run });
|
|
454
565
|
});
|
|
@@ -518,7 +629,7 @@ async function linkRepository(out, config, repositoryOwner, repositoryName) {
|
|
|
518
629
|
return await createGitHubClient(out, config.host).linkRepositoryToProject(config.owner, config.project.number, repositoryOwner, repositoryName);
|
|
519
630
|
}
|
|
520
631
|
catch (error) {
|
|
521
|
-
// API の失敗の文は、Python と同じく message
|
|
632
|
+
// API の失敗の文は、Python と同じく message をそのまま使う
|
|
522
633
|
if (error instanceof GitHubAPIError)
|
|
523
634
|
return { status: 'failed', detail: error.message };
|
|
524
635
|
throw error;
|
|
@@ -537,6 +648,13 @@ async function plannedLink(out, config, repositoryOwner, repositoryName) {
|
|
|
537
648
|
throw error;
|
|
538
649
|
}
|
|
539
650
|
}
|
|
651
|
+
const LINK_OUTPUT = z.strictObject({
|
|
652
|
+
repository: z.string().describe('Repository in owner/repo form'),
|
|
653
|
+
projectNumber: z.int().describe('Number of the active project'),
|
|
654
|
+
change: z.enum(['create', 'update']).describe('create: the repository was added to the config; update: its entry was changed'),
|
|
655
|
+
configPath: z.string().describe('Path of the project config file'),
|
|
656
|
+
dryRun: DRY_RUN_FIELD,
|
|
657
|
+
});
|
|
540
658
|
const projectLinkCommand = defineCommand({
|
|
541
659
|
path: ['project', 'link'],
|
|
542
660
|
hasOwnRepo: true,
|
|
@@ -552,6 +670,7 @@ const projectLinkCommand = defineCommand({
|
|
|
552
670
|
release_type: z.string().optional().describe('Declare the release method explicitly; the w-release skill picks its procedure from it. single (1 CHANGELOG) / multi (packages) / nx (Nx Release). When omitted, it is inferred from the packages (with packages: multi, without: single)'),
|
|
553
671
|
dry_run: dryRunInput,
|
|
554
672
|
}),
|
|
673
|
+
output: LINK_OUTPUT,
|
|
555
674
|
positional: ['repo'],
|
|
556
675
|
shortFlags: { develop_branch: '-b', dry_run: '-n' },
|
|
557
676
|
interactive: false,
|
|
@@ -600,15 +719,39 @@ const projectLinkCommand = defineCommand({
|
|
|
600
719
|
}
|
|
601
720
|
const checked = validated(next);
|
|
602
721
|
out.planned(saved);
|
|
603
|
-
|
|
722
|
+
const reported = { repository: `${owner}/${name}`, projectNumber: config.project.number, change: linkChange(existing), configPath };
|
|
723
|
+
if (input.dry_run) {
|
|
724
|
+
out.result(reported);
|
|
604
725
|
return 0;
|
|
726
|
+
}
|
|
605
727
|
saveConfig(checked, configPath);
|
|
606
728
|
out.done(saved);
|
|
729
|
+
out.result(reported);
|
|
607
730
|
return 0;
|
|
608
731
|
},
|
|
609
732
|
});
|
|
610
733
|
// 設定のキーの管理。今のキーは aggregation_repo だけ
|
|
611
734
|
const CONFIG_KEY = z.enum(['aggregation_repo']).describe('Key of the project config (aggregation_repo: the Epic aggregation repository)');
|
|
735
|
+
const CONFIG_KEY_FIELD = z.enum(['aggregation_repo']).describe('Key of the project config');
|
|
736
|
+
const GET_OUTPUT = z.strictObject({
|
|
737
|
+
key: CONFIG_KEY_FIELD,
|
|
738
|
+
value: z.string().optional().describe('Value of the key (omitted when it is not set)'),
|
|
739
|
+
});
|
|
740
|
+
const SET_OUTPUT = z.strictObject({
|
|
741
|
+
key: CONFIG_KEY_FIELD,
|
|
742
|
+
value: z.string().describe('Value of the key after the command (on dry_run, after it would run)'),
|
|
743
|
+
previous: z.string().optional().describe('Value before the command (omitted when the key was not set)'),
|
|
744
|
+
change: z.enum(['create', 'update', 'unchanged']).describe('create: the key was not set; update: its value was replaced; unchanged: it already had the value'),
|
|
745
|
+
configPath: z.string().describe('Path of the project config file'),
|
|
746
|
+
dryRun: DRY_RUN_FIELD,
|
|
747
|
+
});
|
|
748
|
+
const UNSET_OUTPUT = z.strictObject({
|
|
749
|
+
key: CONFIG_KEY_FIELD,
|
|
750
|
+
previous: z.string().optional().describe('Value before the command (omitted when the key was not set)'),
|
|
751
|
+
change: z.enum(['delete', 'unchanged']).describe('delete: the key was cleared; unchanged: it was not set'),
|
|
752
|
+
configPath: z.string().describe('Path of the project config file'),
|
|
753
|
+
dryRun: DRY_RUN_FIELD,
|
|
754
|
+
});
|
|
612
755
|
function setAggregationRepository(out, value, options) {
|
|
613
756
|
if (!AGGREGATION_REPOSITORY_PATTERN.test(value))
|
|
614
757
|
stopWith(out, `give aggregation_repo as owner/repo: ${pythonStringRepr(value)}`, 'invalid-input');
|
|
@@ -618,11 +761,15 @@ function setAggregationRepository(out, value, options) {
|
|
|
618
761
|
const unchanged = { verb: 'unchanged', target: `aggregation_repo ${value}` };
|
|
619
762
|
out.planned(unchanged);
|
|
620
763
|
out.done(unchanged);
|
|
764
|
+
out.result({ key: 'aggregation_repo', value, previous: value, change: 'unchanged', configPath });
|
|
621
765
|
return;
|
|
622
766
|
}
|
|
623
767
|
const operation = { verb: 'set', target: `aggregation_repo to ${value}` };
|
|
768
|
+
const hasPrevious = current !== undefined && current !== '';
|
|
769
|
+
const reported = { key: 'aggregation_repo', value, ...hasPrevious && { previous: current }, change: setChange(hasPrevious), configPath };
|
|
624
770
|
if (options.isDryRun) {
|
|
625
771
|
out.planned(current === undefined || current === '' ? operation : { ...operation, target: `${operation.target} (was ${current})` });
|
|
772
|
+
out.result(reported);
|
|
626
773
|
return;
|
|
627
774
|
}
|
|
628
775
|
if (current !== undefined && current !== '') {
|
|
@@ -630,6 +777,7 @@ function setAggregationRepository(out, value, options) {
|
|
|
630
777
|
}
|
|
631
778
|
saveConfig(withAggregationRepository(config, value), configPath);
|
|
632
779
|
out.done(operation);
|
|
780
|
+
out.result(reported);
|
|
633
781
|
}
|
|
634
782
|
function unsetAggregationRepository(out, isDryRun) {
|
|
635
783
|
const { config, configPath } = requireActiveWithPath(out);
|
|
@@ -638,20 +786,26 @@ function unsetAggregationRepository(out, isDryRun) {
|
|
|
638
786
|
const unchanged = { verb: 'unchanged', target: 'aggregation_repo (not set)' };
|
|
639
787
|
out.planned(unchanged);
|
|
640
788
|
out.done(unchanged);
|
|
789
|
+
out.result({ key: 'aggregation_repo', change: 'unchanged', configPath });
|
|
641
790
|
return;
|
|
642
791
|
}
|
|
643
792
|
const operation = { verb: 'remove', target: `aggregation_repo (was ${previous})` };
|
|
644
793
|
out.planned(operation);
|
|
645
|
-
if (isDryRun)
|
|
794
|
+
if (isDryRun) {
|
|
795
|
+
out.result({ key: 'aggregation_repo', previous, change: 'delete', configPath });
|
|
646
796
|
return;
|
|
797
|
+
}
|
|
647
798
|
saveConfig(withAggregationRepository(config, undefined), configPath);
|
|
648
799
|
out.done(operation);
|
|
800
|
+
out.result({ key: 'aggregation_repo', previous, change: 'delete', configPath });
|
|
649
801
|
}
|
|
650
802
|
// キーを足したら、ここに操作を足さないと型の確認で止まる
|
|
651
803
|
const CONFIG_KEY_OPERATIONS = {
|
|
652
804
|
aggregation_repo: {
|
|
653
805
|
get: (out) => {
|
|
654
|
-
|
|
806
|
+
const value = requireActiveConfig(out).aggregation_repo;
|
|
807
|
+
out.data(value ?? 'none');
|
|
808
|
+
out.result({ key: 'aggregation_repo', ...value !== undefined && { value } });
|
|
655
809
|
},
|
|
656
810
|
set: setAggregationRepository,
|
|
657
811
|
unset: unsetAggregationRepository,
|
|
@@ -666,6 +820,7 @@ const projectSetCommand = defineCommand({
|
|
|
666
820
|
yes: z.boolean().default(false).describe('Overwrite an existing value without confirmation (a warning goes to stderr)'),
|
|
667
821
|
dry_run: dryRunInput,
|
|
668
822
|
}),
|
|
823
|
+
output: SET_OUTPUT,
|
|
669
824
|
positional: ['key', 'value'],
|
|
670
825
|
shortFlags: { yes: '-y', dry_run: '-n' },
|
|
671
826
|
interactive: false,
|
|
@@ -678,6 +833,7 @@ const projectUnsetCommand = defineCommand({
|
|
|
678
833
|
path: ['project', 'unset'],
|
|
679
834
|
description: 'Clear a key of the project config; without aggregation_repo, creating an Epic needs --repo',
|
|
680
835
|
input: z.strictObject({ key: CONFIG_KEY, dry_run: dryRunInput }),
|
|
836
|
+
output: UNSET_OUTPUT,
|
|
681
837
|
positional: ['key'],
|
|
682
838
|
shortFlags: { dry_run: '-n' },
|
|
683
839
|
interactive: false,
|
|
@@ -690,6 +846,7 @@ const projectGetCommand = defineCommand({
|
|
|
690
846
|
path: ['project', 'get'],
|
|
691
847
|
description: 'Show the value of a key of the project config (aggregation_repo: the Epic aggregation repository)',
|
|
692
848
|
input: z.strictObject({ key: CONFIG_KEY }),
|
|
849
|
+
output: GET_OUTPUT,
|
|
693
850
|
positional: ['key'],
|
|
694
851
|
interactive: false,
|
|
695
852
|
run: (input, io) => {
|
|
@@ -4,6 +4,7 @@ import { BOARD_COMMANDS } from './board.js';
|
|
|
4
4
|
import { BRANCH_COMMANDS } from './branch.js';
|
|
5
5
|
import { registerCommandHints } from './command-hint.js';
|
|
6
6
|
import { ISSUE_COMMANDS } from './issue.js';
|
|
7
|
+
import { PR_RESTACK_COMMANDS } from './pr-restack.js';
|
|
7
8
|
import { PR_COMMANDS } from './pr.js';
|
|
8
9
|
import { PROJECT_COMMANDS } from './project.js';
|
|
9
10
|
import { RELEASE_COMMANDS } from './release.js';
|
|
@@ -18,6 +19,7 @@ export const COMMANDS = [
|
|
|
18
19
|
...ISSUE_COMMANDS,
|
|
19
20
|
...SESSION_COMMANDS,
|
|
20
21
|
...PR_COMMANDS,
|
|
22
|
+
...PR_RESTACK_COMMANDS,
|
|
21
23
|
...RELEASE_COMMANDS,
|
|
22
24
|
...TRACKER_COMMANDS,
|
|
23
25
|
...WORKTREE_COMMANDS,
|