@pecot/workflow-mcp 8.0.1-dev.51 → 8.0.1-dev.52

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 (39) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/cli/dist/commands/board-add.js +5 -4
  3. package/cli/dist/commands/board-move.js +4 -3
  4. package/cli/dist/commands/board-sync.js +2 -26
  5. package/cli/dist/commands/branch.js +3 -2
  6. package/cli/dist/commands/command-stop.d.ts +13 -2
  7. package/cli/dist/commands/command-stop.js +31 -8
  8. package/cli/dist/commands/field-write-failure.d.ts +2 -1
  9. package/cli/dist/commands/field-write-failure.js +7 -11
  10. package/cli/dist/commands/issue-board.js +2 -2
  11. package/cli/dist/commands/issue-comment.js +8 -5
  12. package/cli/dist/commands/issue-create.js +49 -11
  13. package/cli/dist/commands/issue-dependency.js +7 -4
  14. package/cli/dist/commands/issue-reopen.js +4 -3
  15. package/cli/dist/commands/issue-shared.js +1 -1
  16. package/cli/dist/commands/issue-show.js +3 -2
  17. package/cli/dist/commands/pr-merge.js +3 -2
  18. package/cli/dist/commands/pr-restack.js +3 -2
  19. package/cli/dist/commands/pr.js +38 -24
  20. package/cli/dist/commands/release.js +11 -8
  21. package/cli/dist/commands/session-finish.js +3 -2
  22. package/cli/dist/commands/session-start.js +5 -4
  23. package/cli/dist/commands/session.js +10 -7
  24. package/cli/dist/commands/tracker-sync-dependabot.js +1 -1
  25. package/cli/dist/commands/tracker-sync-security.js +1 -1
  26. package/cli/dist/commands/tracker-sync.d.ts +3 -3
  27. package/cli/dist/commands/tracker-sync.js +4 -5
  28. package/cli/dist/commands/tracker.js +2 -0
  29. package/cli/dist/commands/worktree.js +4 -2
  30. package/cli/dist/domain/config.d.ts +0 -8
  31. package/cli/dist/domain/config.js +1 -15
  32. package/cli/dist/infra/config-store.d.ts +62 -15
  33. package/cli/dist/infra/config-store.js +99 -38
  34. package/cli/dist/infra/remote-config.d.ts +22 -0
  35. package/cli/dist/infra/remote-config.js +48 -0
  36. package/cli/dist/infra/worktree.d.ts +5 -1
  37. package/cli/dist/infra/worktree.js +16 -53
  38. package/npm-shrinkwrap.json +2 -2
  39. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pecot-w",
3
- "version": "8.0.1-dev.51",
3
+ "version": "8.0.1-dev.52",
4
4
  "description": "pecot-w (pecot-workflow) workflow automation plugin for Claude Code - skills, hooks, agents, and commands for AI-assisted development",
5
5
  "author": {
6
6
  "name": "pecot"
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
3
  import { GitHubAPIError } from '../infra/github/errors.js';
4
4
  import { defineCommand } from './command-definition.js';
5
5
  import { addIssueToBoard, isStatusConfigured, setIssueField } from './issue-board.js';
6
- import { stopWith, requireActiveConfigPlain } from './command-stop.js';
6
+ import { stopWith, requireConfigFor, PROJECT_INPUT } from './command-stop.js';
7
7
  import { kindOfFailure } from './failure.js';
8
8
  import { fieldWriteFailure } from './field-write-failure.js';
9
9
  import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
@@ -20,6 +20,7 @@ const BOARD_ADD = defineCommand({
20
20
  input: z.object({
21
21
  issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
22
22
  status: z.string().default('ready').describe('Initial status (backlog/pending/blocked/ready/active/in_review/archived)'),
23
+ project: PROJECT_INPUT,
23
24
  dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
24
25
  }),
25
26
  output: BOARD_ADD_OUTPUT,
@@ -32,11 +33,11 @@ const BOARD_ADD = defineCommand({
32
33
  const { status } = input;
33
34
  if (status !== '' && !VALID_STATUSES.has(status))
34
35
  exitInvalidStatus(output, status);
35
- const config = requireActiveConfigPlain(output);
36
+ const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
37
+ const { config } = requireConfigFor(output, { owner, repository }, input.project, ['board', 'add']);
36
38
  if (status !== '' && !isStatusConfigured(config, status)) {
37
39
  stopWith(output, notConfiguredMessage(status), 'status-not-configured');
38
40
  }
39
- const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
40
41
  const target = `Issue ${issuePath(owner, repository, number)}`;
41
42
  try {
42
43
  const client = await connectToProject(output, config, owner, repository);
@@ -61,7 +62,7 @@ const BOARD_ADD = defineCommand({
61
62
  if (!(error instanceof GitHubAPIError))
62
63
  throw error;
63
64
  // 追加は済んでいるので、追加の失敗とは別の文で止める
64
- stopWith(output, fieldWriteFailure(`could not set ${target} status ${status}: ${error.message}`, error), kindOfFailure(error));
65
+ stopWith(output, fieldWriteFailure(`could not set ${target} status ${status}: ${error.message}`, error, config), kindOfFailure(error));
65
66
  }
66
67
  output.done({ verb: 'set', target: `${target} status ${status}` });
67
68
  output.result({ status });
@@ -4,7 +4,7 @@ import { GitHubAPIError } from '../infra/github/errors.js';
4
4
  import { defineCommand } from './command-definition.js';
5
5
  import { isStatusConfigured, setIssueField } from './issue-board.js';
6
6
  import { commandHint, hinted } from './command-hint.js';
7
- import { stopWith, requireActiveConfigPlain } from './command-stop.js';
7
+ import { stopWith, requireConfigFor, PROJECT_INPUT } from './command-stop.js';
8
8
  import { kindOfFailure } from './failure.js';
9
9
  import { fieldWriteFailure } from './field-write-failure.js';
10
10
  import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
@@ -20,6 +20,7 @@ const BOARD_MOVE = defineCommand({
20
20
  input: z.object({
21
21
  issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
22
22
  status: z.string().describe('Status (backlog/pending/blocked/ready/active/in_review/archived)'),
23
+ project: PROJECT_INPUT,
23
24
  dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
24
25
  }),
25
26
  output: BOARD_MOVE_OUTPUT,
@@ -32,8 +33,8 @@ const BOARD_MOVE = defineCommand({
32
33
  const { status } = input;
33
34
  if (!VALID_STATUSES.has(status))
34
35
  exitInvalidStatus(output, status);
35
- const config = requireActiveConfigPlain(output);
36
36
  const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
37
+ const { config } = requireConfigFor(output, { owner, repository }, input.project, ['board', 'move']);
37
38
  const target = `Issue ${issuePath(owner, repository, number)}`;
38
39
  try {
39
40
  const client = await connectToProject(output, config, owner, repository);
@@ -55,7 +56,7 @@ const BOARD_MOVE = defineCommand({
55
56
  catch (error) {
56
57
  if (!(error instanceof GitHubAPIError))
57
58
  throw error;
58
- stopWith(output, fieldWriteFailure(`could not set ${target} status ${status}: ${error.message}`, error), kindOfFailure(error));
59
+ stopWith(output, fieldWriteFailure(`could not set ${target} status ${status}: ${error.message}`, error, config), kindOfFailure(error));
59
60
  }
60
61
  if (!isSet)
61
62
  stopWith(output, notConfiguredMessage(status), 'status-not-configured');
@@ -1,15 +1,12 @@
1
1
  /* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
2
2
  // board sync。ボードの Ready・Blocked・Active・In Review の Issue を判定に合わせて、列と札を直す。
3
- import path from 'node:path';
4
3
  import { z } from 'zod';
5
4
  import { homeRepositoryOf } from '../domain/config.js';
6
- import { loadActiveConfig, listProjectConfigNames, loadConfig, projectsDirectory } from '../infra/config-store.js';
7
5
  import { GitHubAPIError } from '../infra/github/errors.js';
8
6
  import { applyJudgedMoves, judgeBoard, SYNCED_COLUMNS } from './board-judgment.js';
9
7
  import { BOARD_MOVE_JSON, moveJson } from './issue-board.js';
10
8
  import { CommandExit, defineCommand } from './command-definition.js';
11
- import { commandHint, hinted, placeholder } from './command-hint.js';
12
- import { NO_ACTIVE_PROJECT, stopWith } from './command-stop.js';
9
+ import { requireBoardConfig } from './command-stop.js';
13
10
  import { makeClient } from './github-client.js';
14
11
  import { createOutput, DRY_RUN_FIELD } from './output.js';
15
12
  import { pruneArchivedItems, readBoard } from './board-view.js';
@@ -39,27 +36,6 @@ async function syncBoard(context, read, isDryRun) {
39
36
  }
40
37
  return await applyJudgedMoves(context, judged, isDryRun);
41
38
  }
42
- function availableNames() {
43
- return listProjectConfigNames().join(', ');
44
- }
45
- // --project、次にアクティブ設定。どちらも無く設定が 1 つだけなら、それを使う
46
- function resolveConfig(out, project) {
47
- if (project !== undefined) {
48
- // 一覧は projects/ の *.json の名前なので、一致すれば ../ などの外のパスにならない
49
- const name = project.endsWith('.json') ? project.slice(0, -'.json'.length) : project;
50
- return listProjectConfigNames().includes(name) ? loadConfig(path.join(projectsDirectory(), `${name}.json`)) : stopWith(out, `project config not found: ${project}\navailable: ${availableNames()}`, 'project-not-found');
51
- }
52
- const active = loadActiveConfig();
53
- if (active !== undefined)
54
- return active;
55
- const names = listProjectConfigNames();
56
- const [only] = names;
57
- if (only === undefined)
58
- return stopWith(out, NO_ACTIVE_PROJECT, 'no-active-project');
59
- if (names.length === 1)
60
- return loadConfig(path.join(projectsDirectory(), `${only}.json`));
61
- return stopWith(out, hinted `no active project, and ${String(names.length)} project configs exist\nrun: ${commandHint(['board', 'sync'], { project: placeholder('NAME') })}\navailable: ${names.join(', ')}`, 'no-active-project');
62
- }
63
39
  // 窓が途中で切り替わると前後の used を比べられないので、使用量の行を省く
64
40
  function reportPoints(out, before, after) {
65
41
  if (before === undefined || after === undefined)
@@ -87,7 +63,7 @@ const boardSyncCommand = defineCommand({
87
63
  interactive: false,
88
64
  run: async (input, io) => {
89
65
  const out = createOutput(input.dry_run, io);
90
- const config = resolveConfig(out, input.project);
66
+ const config = requireBoardConfig(out, input.project, ['board', 'sync']);
91
67
  const client = makeClient(out, config);
92
68
  const before = await client.getGraphqlRateLimit();
93
69
  let read;
@@ -5,7 +5,7 @@ import { compareStrings } from '../domain/python-format.js';
5
5
  import { ReferenceParseError, parseRepositoryReference } from '../domain/reference-parser.js';
6
6
  import { GitHubAPIError } from '../infra/github/errors.js';
7
7
  import { defineCommand } from './command-definition.js';
8
- import { requireActiveConfig, stopWith } from './command-stop.js';
8
+ import { PROJECT_INPUT, requireConfigFor, stopWith } from './command-stop.js';
9
9
  import { kindOfFailure } from './failure.js';
10
10
  import { createGitHubClient } from './github-client.js';
11
11
  import { createOutput, DRY_RUN_FIELD } from './output.js';
@@ -26,6 +26,7 @@ const branchDeleteCommand = defineCommand({
26
26
  repo: z.string().describe('Repository reference (owner/repo)'),
27
27
  branch: z.string().describe('Name of the branch to delete'),
28
28
  dry_run: z.boolean().default(false).describe('Show what would be deleted without deleting anything'),
29
+ project: PROJECT_INPUT,
29
30
  }),
30
31
  output: BRANCH_DELETE_OUTPUT,
31
32
  positional: ['repo', 'branch'],
@@ -47,7 +48,7 @@ const branchDeleteCommand = defineCommand({
47
48
  }
48
49
  const { owner, repository } = target;
49
50
  // 2. 設定取得
50
- const config = requireActiveConfig(out);
51
+ const config = requireConfigFor(out, target, input.project, ['branch', 'delete']).config;
51
52
  // 3. 保護ブランチ収集(設定の develop_branch・release_branch と、API の既定ブランチ)
52
53
  const protectedBranches = new Set();
53
54
  const repositoryConfig = findRepository(config, owner, repository);
@@ -1,4 +1,7 @@
1
+ import { z } from 'zod';
1
2
  import type { ProjectConfig } from '../domain/config.js';
3
+ import type { RepositoryReference } from '../domain/repository-resolver.js';
4
+ import type { FoundConfig } from '../infra/config-store.js';
2
5
  import type { HintedText } from './command-hint.js';
3
6
  import type { FailureKind } from './failure-kind.js';
4
7
  import type { Output } from './output.js';
@@ -15,7 +18,15 @@ export declare function stopWith(out: Readonly<Output>, message: string | Hinted
15
18
  */
16
19
  export declare function requireActiveConfig(out: Readonly<Output>): ProjectConfig;
17
20
  /**
18
- requireActiveConfig の、案内を添えない形。無ければ NO_ACTIVE_PROJECT_PLAIN を error の行にして止める
21
+ 対象のリポから設定を選ぶ `project` の入力。board sync の `project` と同じ名前の読み方
19
22
  */
20
- export declare function requireActiveConfigPlain(out: Readonly<Output>): ProjectConfig;
23
+ export declare const PROJECT_INPUT: z.ZodOptional<z.ZodString>;
24
+ /**
25
+ 対象のリポから設定を選ぶ(findConfigFor)。選べなければ、configLookupFailure の文を error の行にして止める
26
+ */
27
+ export declare function requireConfigFor(out: Readonly<Output>, target: Readonly<RepositoryReference>, project: string | undefined, commandPath: readonly string[]): FoundConfig;
28
+ /**
29
+ 対象のリポを持たない、ボード全体の操作の設定。project、次にアクティブ設定。どちらも無く設定が 1 つだけなら、それを使う
30
+ */
31
+ export declare function requireBoardConfig(out: Readonly<Output>, project: string | undefined, commandPath: readonly string[]): ProjectConfig;
21
32
  //# sourceMappingURL=command-stop.d.ts.map
@@ -1,11 +1,9 @@
1
- import { loadActiveConfig } from '../infra/config-store.js';
1
+ // コマンドが error の行を出して止める処理と、対象のリポから設定を選ぶ処理。全コマンドが共有する。
2
+ import { z } from 'zod';
3
+ import { ambiguousMessage, configLookupFailure, findConfigFor, listProjectConfigNames, loadActiveConfig, loadNamedConfig, unknownProjectMessage } from '../infra/config-store.js';
2
4
  import { CommandExit } from './command-definition.js';
3
5
  import { commandHint, hinted, placeholder } from './command-hint.js';
4
6
  /**
5
- アクティブなプロジェクトが無いときの、案内を添えない文
6
- */
7
- const NO_ACTIVE_PROJECT_PLAIN = 'no active project';
8
- /**
9
7
  アクティブなプロジェクトが無いときの案内
10
8
  */
11
9
  export const NO_ACTIVE_PROJECT = hinted `no active project\nrun: ${commandHint(['project', 'activate'], { project: placeholder('PROJECT') })}`;
@@ -23,9 +21,34 @@ export function requireActiveConfig(out) {
23
21
  return loadActiveConfig() ?? stopWith(out, NO_ACTIVE_PROJECT, 'no-active-project');
24
22
  }
25
23
  /**
26
- requireActiveConfig の、案内を添えない形。無ければ NO_ACTIVE_PROJECT_PLAIN を error の行にして止める
24
+ 対象のリポから設定を選ぶ `project` の入力。board sync の `project` と同じ名前の読み方
25
+ */
26
+ export const PROJECT_INPUT = z.string().optional().describe('Name of the project config under .pecot/config/projects (without .json). Without it, the config that includes the target repository; when several do, the active one among them');
27
+ /**
28
+ 対象のリポから設定を選ぶ(findConfigFor)。選べなければ、configLookupFailure の文を error の行にして止める
29
+ */
30
+ export function requireConfigFor(out, target, project, commandPath) {
31
+ const lookup = findConfigFor(target, project);
32
+ if (lookup.kind === 'found')
33
+ return lookup.found;
34
+ const { message, kind } = configLookupFailure(lookup, target, commandPath);
35
+ return stopWith(out, message, kind);
36
+ }
37
+ /**
38
+ 対象のリポを持たない、ボード全体の操作の設定。project、次にアクティブ設定。どちらも無く設定が 1 つだけなら、それを使う
27
39
  */
28
- export function requireActiveConfigPlain(out) {
29
- return loadActiveConfig() ?? stopWith(out, NO_ACTIVE_PROJECT_PLAIN, 'no-active-project');
40
+ export function requireBoardConfig(out, project, commandPath) {
41
+ if (project !== undefined)
42
+ return loadNamedConfig(project)?.config ?? stopWith(out, unknownProjectMessage(project), 'project-not-found');
43
+ const active = loadActiveConfig();
44
+ if (active !== undefined)
45
+ return active;
46
+ const names = listProjectConfigNames();
47
+ const [only] = names;
48
+ if (only === undefined)
49
+ return stopWith(out, NO_ACTIVE_PROJECT, 'no-active-project');
50
+ if (names.length === 1)
51
+ return loadNamedConfig(only)?.config ?? stopWith(out, NO_ACTIVE_PROJECT, 'no-active-project');
52
+ return stopWith(out, ambiguousMessage(`no active project, and ${String(names.length)} project configs exist`, names, commandPath), 'no-active-project');
30
53
  }
31
54
  //# sourceMappingURL=command-stop.js.map
@@ -1,3 +1,4 @@
1
+ import type { ProjectConfig } from '../domain/config.js';
1
2
  import type { GitHubAPIError } from '../infra/github/errors.js';
2
3
  import type { HintedText } from './command-hint.js';
3
4
  /**
@@ -10,5 +11,5 @@ export interface FieldHintState {
10
11
  選択肢の書き込みの失敗の文。古い ID で落ちたとき(VALIDATION)だけ、ID を読み直す案内を添える。
11
12
  hintState を渡すと案内は 1 回だけ、省くと毎回添える
12
13
  */
13
- export declare function fieldWriteFailure(message: string, error: Readonly<GitHubAPIError>, hintState?: FieldHintState): string | HintedText;
14
+ export declare function fieldWriteFailure(message: string, error: Readonly<GitHubAPIError>, config: ProjectConfig, hintState?: FieldHintState): string | HintedText;
14
15
  //# sourceMappingURL=field-write-failure.d.ts.map
@@ -1,13 +1,9 @@
1
- // ボードの選択肢の書き込みの失敗の文。issue-board.ts と issue-shared.ts の両方が使うので、どちらにも置かない(循環 import を避ける)
2
- import path from 'node:path';
3
- import { getActiveConfigPath, projectsDirectory } from '../infra/config-store.js';
1
+ import { configSourcePath, projectNameOf } from '../infra/config-store.js';
4
2
  import { commandHint, hinted, joinHinted, placeholder } from './command-hint.js';
5
- function rereadOptionsHint() {
6
- const configPath = getActiveConfigPath();
7
- // projects/ の外の config は、ファイル名では project activate が見つけられない
8
- const project = configPath === undefined
9
- ? placeholder('PROJECT')
10
- : (path.dirname(configPath) === projectsDirectory() ? path.basename(configPath, '.json') : configPath);
3
+ // 書いた設定のファイルの名前で案内する。.active は、書いた設定と違うことがある
4
+ function rereadOptionsHint(config) {
5
+ const configPath = configSourcePath(config);
6
+ const project = configPath === undefined ? placeholder('PROJECT') : projectNameOf(configPath);
11
7
  return hinted `hint: if the board options were recreated, run ${commandHint(['project', 'activate'], { project })} to read their IDs again`;
12
8
  }
13
9
  /**
@@ -15,11 +11,11 @@ function rereadOptionsHint() {
15
11
  hintState を渡すと案内は 1 回だけ、省くと毎回添える
16
12
  */
17
13
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types -- 出したことを hintState に書く
18
- export function fieldWriteFailure(message, error, hintState) {
14
+ export function fieldWriteFailure(message, error, config, hintState) {
19
15
  if (error.errorType !== 'VALIDATION' || hintState?.hasHinted === true)
20
16
  return message;
21
17
  if (hintState !== undefined)
22
18
  hintState.hasHinted = true;
23
- return joinHinted([message, rereadOptionsHint()]);
19
+ return joinHinted([message, rereadOptionsHint(config)]);
24
20
  }
25
21
  //# sourceMappingURL=field-write-failure.js.map
@@ -79,7 +79,7 @@ export async function putOnBoard(out, client, config, owner, repository, issueNu
79
79
  catch (error) {
80
80
  if (!(error instanceof GitHubAPIError))
81
81
  throw error;
82
- out.error(fieldWriteFailure(`could not set ${label} ${option} of Tracker #${String(issueNumber)}: ${error.message}`, error, hintState));
82
+ out.error(fieldWriteFailure(`could not set ${label} ${option} of Tracker #${String(issueNumber)}: ${error.message}`, error, config, hintState));
83
83
  failures += 1;
84
84
  }
85
85
  }
@@ -138,7 +138,7 @@ export async function applyBoardMove(out, client, config, itemId, target, move,
138
138
  catch (error) {
139
139
  if (!(error instanceof GitHubAPIError))
140
140
  throw error;
141
- out.warning(fieldWriteFailure(`could not move ${name}: ${error.message}`, error, hintState));
141
+ out.warning(fieldWriteFailure(`could not move ${name}: ${error.message}`, error, config, hintState));
142
142
  hasFailed = true;
143
143
  }
144
144
  const written = column === undefined && label === undefined ? undefined : { issue: name, column, label, reason: text };
@@ -16,7 +16,7 @@ import { readTextFile } from '../infra/text-file.js';
16
16
  import { templateFile } from '../infra/template-store.js';
17
17
  import { defineCommand, CommandExit } from './command-definition.js';
18
18
  import { commandHint, hinted, inputNameHint, placeholder } from './command-hint.js';
19
- import { stopWith, requireActiveConfigPlain } from './command-stop.js';
19
+ import { stopWith, requireConfigFor, PROJECT_INPUT } from './command-stop.js';
20
20
  import { kindOfFailure } from './failure.js';
21
21
  import { createGitHubClient } from './github-client.js';
22
22
  import { COMMENT_VALIDATION_EXIT_CODE, hasReportedTemplateViolations, issuePath, parseIssueReferenceOrExit, runWithExit, } from './issue-shared.js';
@@ -131,7 +131,7 @@ async function updateComment(output, client, target, commentId, commentUrl, body
131
131
  output.done({ verb: 'update', target: `comment on ${display}` });
132
132
  output.data(updatedUrl);
133
133
  }
134
- async function postFromFile(output, config, repository, file, isDryRun) {
134
+ async function postFromFile(output, project, repository, file, isDryRun) {
135
135
  let parsed;
136
136
  try {
137
137
  parsed = parseCommentFile(file);
@@ -143,6 +143,7 @@ async function postFromFile(output, config, repository, file, isDryRun) {
143
143
  }
144
144
  const { frontmatter, body } = parsed;
145
145
  const target = parseIssueReferenceOrExit(output, repository, frontmatter.issue_ref);
146
+ const { config } = requireConfigFor(output, target, project, COMMENT_PATH);
146
147
  if (frontmatter.template === undefined) {
147
148
  return stopWith(output, `specify template in the frontmatter (${TEMPLATE_CHOICES})`, 'content-invalid');
148
149
  }
@@ -172,8 +173,9 @@ async function postFromFile(output, config, repository, file, isDryRun) {
172
173
  if (createdUrl !== '')
173
174
  writeBackCommentUrl(output, file, createdUrl);
174
175
  }
175
- async function postDirect(output, config, repository, issueReference, message, template, isDryRun) {
176
+ async function postDirect(output, project, repository, issueReference, message, template, isDryRun) {
176
177
  const target = parseIssueReferenceOrExit(output, repository, issueReference);
178
+ const { config } = requireConfigFor(output, target, project, COMMENT_PATH);
177
179
  if (hasReportedTemplateViolations(output, message, templateFile('comment', template)))
178
180
  throw new CommandExit(COMMENT_VALIDATION_EXIT_CODE, 'content-invalid');
179
181
  if (isDryRun) {
@@ -193,6 +195,7 @@ const ISSUE_COMMENT = defineCommand({
193
195
  issue_ref: z.string().optional().describe('Issue reference (owner/repo/123 form, required with -m)'),
194
196
  prepare: z.boolean().default(false).describe('Copy a template to the work directory'),
195
197
  template: TEMPLATE_SCHEMA.optional().describe('Template type (required with --prepare and -m; plan/merge-diff/review-findings/review-resolution/precede-notify)'),
198
+ project: PROJECT_INPUT,
196
199
  dry_run: z.boolean().default(false).describe('Show what would be posted or written without changing anything'),
197
200
  }),
198
201
  output: ISSUE_COMMENT_OUTPUT,
@@ -211,14 +214,14 @@ const ISSUE_COMMENT = defineCommand({
211
214
  return;
212
215
  }
213
216
  if (file !== undefined) {
214
- await postFromFile(output, requireActiveConfigPlain(output), input.repo, file, input.dry_run);
217
+ await postFromFile(output, input.project, input.repo, file, input.dry_run);
215
218
  return;
216
219
  }
217
220
  if (message !== undefined && template !== undefined) {
218
221
  if (issue === undefined || issue === '') {
219
222
  stopWith(output, hinted `${inputNameHint(COMMENT_PATH, 'issue_ref')} (Issue reference) is required with ${inputNameHint(COMMENT_PATH, 'message')}`, 'invalid-input');
220
223
  }
221
- await postDirect(output, requireActiveConfigPlain(output), input.repo, issue, message, template, input.dry_run);
224
+ await postDirect(output, input.project, input.repo, issue, message, template, input.dry_run);
222
225
  return;
223
226
  }
224
227
  stopWith(output, hinted `missing arguments
@@ -16,6 +16,7 @@ import { PYTHON_LINE_BREAK, compareStrings, pythonRightStrip, pythonStrip, pytho
16
16
  import { createIssueReference, issueReferenceKey, issueReferenceToCliReference } from '../domain/reference-parser.js';
17
17
  import { describeReadiness, displayReference, hasStarted, stackChains } from '../domain/readiness.js';
18
18
  import { parseIssueFile } from '../infra/frontmatter-file.js';
19
+ import { configSourcePath, projectNameOf } from '../infra/config-store.js';
19
20
  import { DependenciesUnsupportedError, GitHubAPIError } from '../infra/github/errors.js';
20
21
  import { DEPENDENCIES_UNSUPPORTED } from '../infra/github/issues.js';
21
22
  import { OutputPathReservationError, normalizePath, outputDirectory, resolveRealPath, withReservedOutputPath } from '../infra/paths.js';
@@ -23,7 +24,7 @@ import { templateFile } from '../infra/template-store.js';
23
24
  import { readTextFile } from '../infra/text-file.js';
24
25
  import { CommandExit, defineCommand } from './command-definition.js';
25
26
  import { commandHint, hinted, inputHint, inputNameHint, joinHinted, placeholder } from './command-hint.js';
26
- import { stopWith, requireActiveConfigPlain } from './command-stop.js';
27
+ import { PROJECT_INPUT, requireBoardConfig, requireConfigFor, stopWith } from './command-stop.js';
27
28
  import { kindOfFailure } from './failure.js';
28
29
  import { createGitHubClient } from './github-client.js';
29
30
  import { applyBoardMove } from './issue-board.js';
@@ -504,10 +505,45 @@ async function ensureDependenciesSupported(output, client, locals) {
504
505
  }
505
506
  stopWith(output, DEPENDENCIES_UNSUPPORTED, 'dependency-rejected');
506
507
  }
508
+ // 作成先のリポから設定を選ぶ。repository が無い(Epic の既定)ときは対象のリポが無いので、board sync と同じくボード全体の決め方で選ぶ
509
+ function configForCreate(output, repository, project) {
510
+ const given = repository === undefined ? '' : pythonStrip(repository);
511
+ if (given === '')
512
+ return requireBoardConfig(output, project, CREATE_PATH);
513
+ const [owner, name] = validateRepositoryShape(output, given);
514
+ return requireConfigFor(output, { owner, repository: name }, project, CREATE_PATH).config;
515
+ }
516
+ // 一括作成の設定。ファイルごとに作成先のリポで選び、ファイルの間で分かれたら 1 件も作らずに止める
517
+ function configForFiles(output, files, project) {
518
+ const chosen = files.map((file) => {
519
+ let repository;
520
+ try {
521
+ const { frontmatter } = parseIssueFile(file);
522
+ repository = frontmatter.repository;
523
+ // Epic だけが repository を省ける(git remote のリポで設定を選び、aggregation_repo に作る)
524
+ if ((frontmatter.type !== 'epic' || pythonStrip(repository) !== '') && splitOwnerRepository(pythonStrip(repository)) === undefined)
525
+ stopWith(output, `invalid repository format in the frontmatter: ${pythonStringRepr(repository)}`, 'content-invalid');
526
+ }
527
+ catch (error) {
528
+ if (!(error instanceof FrontmatterError))
529
+ throw error;
530
+ return stopForFrontmatter(output, error, path.basename(file));
531
+ }
532
+ const config = configForCreate(output, repository, project);
533
+ return { file: path.basename(file), config, source: configSourcePath(config) ?? '' };
534
+ });
535
+ const [first] = chosen;
536
+ if (first === undefined)
537
+ throw new InternalError('no file to post');
538
+ if (chosen.some(entry => entry.source !== first.source)) {
539
+ stopWith(output, `the files belong to different project configs: ${chosen.map(entry => `${entry.file} (${projectNameOf(entry.source)})`).join(', ')}\npost them separately`, 'invalid-input');
540
+ }
541
+ return first.config;
542
+ }
507
543
  // 1 件も投稿しないうちに確かめられることをすべて確かめ、投稿に要るものをそろえる
508
- async function prepareBatch(output, files) {
544
+ async function prepareBatch(output, files, project) {
509
545
  validatePlaceholders(output, files);
510
- const config = requireActiveConfigPlain(output);
546
+ const config = configForFiles(output, files, project);
511
547
  const locals = files.map(file => readLocalFile(output, config, file));
512
548
  const [first] = locals;
513
549
  if (first === undefined)
@@ -653,8 +689,8 @@ async function postFiles(output, context) {
653
689
  function isBatchReference(reference, posted) {
654
690
  return posted.some(entry => entry !== undefined && issueReferenceKey(entry.reference) === issueReferenceKey(reference));
655
691
  }
656
- async function createFromFiles(output, files, isDryRun) {
657
- const context = await prepareBatch(output, files);
692
+ async function createFromFiles(output, files, project, isDryRun) {
693
+ const context = await prepareBatch(output, files, project);
658
694
  if (isDryRun) {
659
695
  // 番号は投稿まで決まらないので、本番の created の行から番号を除いた対象にする
660
696
  for (const local of context.locals)
@@ -677,8 +713,8 @@ async function createDirect(output, options, loadedConfig, isDryRun) {
677
713
  validateStatusForType(output, issueType, options.status);
678
714
  status = options.status;
679
715
  }
680
- const config = loadedConfig ?? requireActiveConfigPlain(output);
681
716
  const [owner, repository] = validateRepositoryShape(output, options.repository);
717
+ const config = loadedConfig ?? requireConfigFor(output, { owner, repository }, options.project, CREATE_PATH).config;
682
718
  const parentReference = parentReferenceOf(normalizeParentEpicCli(options.parentEpic), config, owner, repository);
683
719
  const title = buildIssueTitle(issueType, options.title, { parentEpic: parentReference?.number, order: options.order });
684
720
  validateIssueTemplate(output, issueType, options.message);
@@ -707,14 +743,14 @@ async function createDirect(output, options, loadedConfig, isDryRun) {
707
743
  });
708
744
  }
709
745
  // -m の作成先。epic 以外は --repo が要る。epic は aggregation_repo の方針で決める
710
- function messageModeTarget(output, issueType, repository) {
746
+ function messageModeTarget(output, issueType, repository, project) {
711
747
  if (issueType !== 'epic') {
712
748
  if (repository === undefined || repository === '') {
713
749
  stopWith(output, hinted `${inputNameHint(CREATE_PATH, 'repo')} is required with ${inputNameHint(CREATE_PATH, 'message')}`, 'invalid-input');
714
750
  }
715
751
  return { repository, config: undefined };
716
752
  }
717
- const config = requireActiveConfigPlain(output);
753
+ const config = configForCreate(output, repository, project);
718
754
  const target = resolveEpicTargetRepository(output, repository, config);
719
755
  if (target.needsWarning)
720
756
  warnEpicRepositoryException(output, target.repository, config);
@@ -761,7 +797,7 @@ async function createFreeform(output, input, isDryRun) {
761
797
  status = input.status;
762
798
  }
763
799
  const [owner, repository] = validateRepositoryShape(output, repo);
764
- const config = requireActiveConfigPlain(output);
800
+ const { config } = requireConfigFor(output, { owner, repository }, input.project, CREATE_PATH);
765
801
  const parentReference = parentReferenceOf(normalizeParentEpicCli(input.parent_epic), config, owner, repository);
766
802
  const [firstLine = ''] = pythonStrip(message).split(PYTHON_LINE_BREAK);
767
803
  const cleaned = pythonStrip(truncateCodePoints(firstLine, FREEFORM_TITLE_LENGTH).replaceAll(PYTHON_WHITESPACE_RUN, ' '));
@@ -792,7 +828,7 @@ async function createFromMessage(output, input, message, isDryRun) {
792
828
  if (input.title === undefined || input.title === '') {
793
829
  stopWith(output, hinted `${inputNameHint(CREATE_PATH, 'title')} is required with ${inputNameHint(CREATE_PATH, 'message')}`, 'invalid-input');
794
830
  }
795
- const target = messageModeTarget(output, input.type, input.repo);
831
+ const target = messageModeTarget(output, input.type, input.repo, input.project);
796
832
  await createDirect(output, {
797
833
  message,
798
834
  title: input.title,
@@ -804,6 +840,7 @@ async function createFromMessage(output, input, message, isDryRun) {
804
840
  parentEpic: input.parent_epic,
805
841
  labels: input.label,
806
842
  order: input.order,
843
+ project: input.project,
807
844
  }, target.config, isDryRun);
808
845
  }
809
846
  const ISSUE_CREATE = defineCommand({
@@ -828,6 +865,7 @@ const ISSUE_CREATE = defineCommand({
828
865
  prepare: z.boolean().default(false).describe('Copy a template to the work directory'),
829
866
  template: TEMPLATE_SCHEMA,
830
867
  suffix: z.string().optional().describe('Suffix of the output file name (only with --prepare)'),
868
+ project: PROJECT_INPUT,
831
869
  }),
832
870
  output: ISSUE_CREATE_OUTPUT,
833
871
  positional: ['files'],
@@ -847,7 +885,7 @@ const ISSUE_CREATE = defineCommand({
847
885
  prepareTemplate(output, input.template, input.repo, input.suffix, input.dry_run);
848
886
  }
849
887
  else if (hasFiles) {
850
- await createFromFiles(output, input.files ?? [], input.dry_run);
888
+ await createFromFiles(output, input.files ?? [], input.project, input.dry_run);
851
889
  }
852
890
  else if (input.message === undefined) {
853
891
  stopWith(output, USAGE_TEXT, 'invalid-input');
@@ -10,7 +10,7 @@ import { createRepositoryReference } from '../domain/repository-resolver.js';
10
10
  import { MAX_BLOCKED_BY } from '../infra/github/issues.js';
11
11
  import { defineCommand } from './command-definition.js';
12
12
  import { commandHint, hinted, inputHint, inputNameHint, joinHinted } from './command-hint.js';
13
- import { requireActiveConfigPlain, stopWith } from './command-stop.js';
13
+ import { PROJECT_INPUT, requireConfigFor, stopWith } from './command-stop.js';
14
14
  import { kindOfFailure } from './failure.js';
15
15
  import { apiFailureMessage, createGitHubClient } from './github-client.js';
16
16
  import { applyBoardMove, BOARD_MOVE_JSON, moveJson } from './issue-board.js';
@@ -22,6 +22,7 @@ const CONTENT_EXIT_CODE = 3;
22
22
  // たどる Issue の数の上限。大きな連鎖で止まらないことより、確かめずに付けないことを優先する
23
23
  const MAX_CYCLE_ISSUES = 200;
24
24
  const BLOCK_PATH = ['issue', 'block'];
25
+ const UNBLOCK_PATH = ['issue', 'unblock'];
25
26
  const ISSUE_FIELD = z.string().describe('The waiting Issue (owner/repo/N)');
26
27
  const BY_FIELD = z.string().describe('The prerequisite Issue (owner/repo/N)');
27
28
  const MOVES_FIELD = z.array(BOARD_MOVE_JSON).optional().describe('The waiting Issue when its column or Status was written (at most one; empty when nothing was written; omitted on dry_run)');
@@ -161,9 +162,9 @@ async function checkNoCycle(context, byId) {
161
162
  stopWith(out, `could not check blocked-by cycle of ${displayReference(target, home)}: ${result.reason}`, 'dependency-unreadable');
162
163
  }
163
164
  async function runBlock(out, input) {
164
- const config = requireActiveConfigPlain(out);
165
165
  const targetIssue = parseIssueReferenceOrExit(out, input.repo, input.issue_ref);
166
166
  const byIssue = parseIssueReferenceOrExit(out, input.repo, input.by);
167
+ const { config } = requireConfigFor(out, targetIssue, input.project, BLOCK_PATH);
167
168
  const target = toReference(targetIssue);
168
169
  const by = toReference(byIssue);
169
170
  const reason = checkBlockUsage(out, input, target, by);
@@ -226,9 +227,9 @@ async function runBlock(out, input) {
226
227
  out.result({ moves: movesOf(written) });
227
228
  }
228
229
  async function runUnblock(out, input) {
229
- const config = requireActiveConfigPlain(out);
230
230
  const targetIssue = parseIssueReferenceOrExit(out, input.repo, input.issue_ref);
231
231
  const byIssue = parseIssueReferenceOrExit(out, input.repo, input.by);
232
+ const { config } = requireConfigFor(out, targetIssue, input.project, UNBLOCK_PATH);
232
233
  const target = toReference(targetIssue);
233
234
  const by = toReference(byIssue);
234
235
  const client = createGitHubClient(out, config.host);
@@ -285,6 +286,7 @@ const ISSUE_BLOCK = defineCommand({
285
286
  by: z.string().describe('The Issue to wait for (`owner/repo/N`; another repository is allowed)'),
286
287
  wait: z.enum(['stack', 'merge']).default('stack').describe('stack (build on its branch) or merge (wait until it is merged)'),
287
288
  reason: z.string().optional().describe('Why it waits for the merge (required with --wait merge)'),
289
+ project: PROJECT_INPUT,
288
290
  dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
289
291
  }),
290
292
  output: ISSUE_BLOCK_OUTPUT,
@@ -298,11 +300,12 @@ const ISSUE_BLOCK = defineCommand({
298
300
  },
299
301
  });
300
302
  const ISSUE_UNBLOCK = defineCommand({
301
- path: ['issue', 'unblock'],
303
+ path: UNBLOCK_PATH,
302
304
  description: 'Remove a blocked-by (prerequisite) from an Issue',
303
305
  input: z.object({
304
306
  issue_ref: z.string().describe(`The waiting Issue. ${ISSUE_REF_DESCRIPTION}`),
305
307
  by: z.string().describe('The prerequisite Issue to remove (`owner/repo/N`; another repository is allowed)'),
308
+ project: PROJECT_INPUT,
306
309
  dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
307
310
  }),
308
311
  output: ISSUE_UNBLOCK_OUTPUT,
@@ -6,7 +6,7 @@ import { GitHubAPIError } from '../infra/github/errors.js';
6
6
  import { defineCommand } from './command-definition.js';
7
7
  import { hinted, inputNameHint } from './command-hint.js';
8
8
  import { isStatusConfigured, setIssueField } from './issue-board.js';
9
- import { stopWith, requireActiveConfigPlain } from './command-stop.js';
9
+ import { stopWith, requireConfigFor, PROJECT_INPUT } from './command-stop.js';
10
10
  import { kindOfFailure } from './failure.js';
11
11
  import { fieldWriteFailure } from './field-write-failure.js';
12
12
  import { connectToProject, exitInvalidStatus, ISSUE_REF_DESCRIPTION, issuePath, notConfiguredMessage, parseIssueReferenceOrExit, runWithExit, VALID_STATUSES, } from './issue-shared.js';
@@ -78,7 +78,7 @@ async function setReopenedStatus(output, client, config, item, status) {
78
78
  catch (error) {
79
79
  if (!(error instanceof GitHubAPIError))
80
80
  throw error;
81
- output.warning(fieldWriteFailure(`could not set ${target} status ${status}: ${error.message}`, error));
81
+ output.warning(fieldWriteFailure(`could not set ${target} status ${status}: ${error.message}`, error, config));
82
82
  return;
83
83
  }
84
84
  if (!isSet) {
@@ -147,6 +147,7 @@ const ISSUE_REOPEN = defineCommand({
147
147
  input: z.object({
148
148
  issue_ref: z.string().describe(ISSUE_REF_DESCRIPTION),
149
149
  status: z.string().default('ready').describe('Status after reopening (backlog/pending/blocked/ready/active/in_review/archived)'),
150
+ project: PROJECT_INPUT,
150
151
  comment: z.string().optional().describe('Reason for reopening (posted as a comment)'),
151
152
  dry_run: z.boolean().default(false).describe('Show what would change without writing anything'),
152
153
  }),
@@ -164,8 +165,8 @@ const ISSUE_REOPEN = defineCommand({
164
165
  if (comment !== undefined && comment !== '' && comment.trim() === '') {
165
166
  stopWith(output, hinted `${inputNameHint(REOPEN_PATH, 'comment')} is blank: give a reason or omit it`, 'invalid-input');
166
167
  }
167
- const config = requireActiveConfigPlain(output);
168
168
  const { owner, repository, number } = parseIssueReferenceOrExit(output, input.repo, input.issue_ref);
169
+ const { config } = requireConfigFor(output, { owner, repository }, input.project, REOPEN_PATH);
169
170
  const target = `Issue ${issuePath(owner, repository, number)}`;
170
171
  try {
171
172
  const client = await connectToProject(output, config, owner, repository);
@@ -308,7 +308,7 @@ export async function setIssueFields(output, client, config, itemId, target, fie
308
308
  catch (error) {
309
309
  if (!(error instanceof GitHubAPIError))
310
310
  throw error;
311
- output.warning(fieldWriteFailure(`could not set ${label} of ${target}: ${error.message}`, error, hintState));
311
+ output.warning(fieldWriteFailure(`could not set ${label} of ${target}: ${error.message}`, error, config, hintState));
312
312
  }
313
313
  }
314
314
  if (labels.length > 0)