@pecot/workflow-mcp 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +80 -22
  3. package/cli/dist/cli.js +6 -1
  4. package/cli/dist/commands/board-add.d.ts +3 -0
  5. package/cli/dist/commands/board-add.js +59 -0
  6. package/cli/dist/commands/board-judgment.d.ts +60 -0
  7. package/cli/dist/commands/board-judgment.js +144 -0
  8. package/cli/dist/commands/board-move.d.ts +3 -0
  9. package/cli/dist/commands/board-move.js +57 -0
  10. package/cli/dist/commands/board-readiness.d.ts +34 -0
  11. package/cli/dist/commands/board-readiness.js +108 -0
  12. package/cli/dist/commands/board-show.d.ts +3 -0
  13. package/cli/dist/commands/board-show.js +72 -0
  14. package/cli/dist/commands/board-sync.d.ts +3 -0
  15. package/cli/dist/commands/board-sync.js +111 -0
  16. package/cli/dist/commands/{project-info.d.ts → board-view.d.ts} +21 -7
  17. package/cli/dist/commands/{project-info.js → board-view.js} +22 -12
  18. package/cli/dist/commands/board.d.ts +3 -0
  19. package/cli/dist/commands/board.js +12 -0
  20. package/cli/dist/commands/branch.d.ts +3 -0
  21. package/cli/dist/commands/branch.js +100 -0
  22. package/cli/dist/commands/command-binding.js +4 -0
  23. package/cli/dist/commands/command-definition.d.ts +20 -6
  24. package/cli/dist/commands/command-definition.js +11 -7
  25. package/cli/dist/commands/command-help.js +2 -2
  26. package/cli/dist/commands/command-hint.d.ts +5 -0
  27. package/cli/dist/commands/command-hint.js +13 -0
  28. package/cli/dist/commands/command-stop.d.ts +5 -3
  29. package/cli/dist/commands/command-stop.js +7 -6
  30. package/cli/dist/commands/failure-kind.d.ts +3 -0
  31. package/cli/dist/commands/failure-kind.js +34 -0
  32. package/cli/dist/commands/failure.d.ts +6 -0
  33. package/cli/dist/commands/failure.js +29 -3
  34. package/cli/dist/commands/github-client.d.ts +6 -2
  35. package/cli/dist/commands/github-client.js +13 -3
  36. package/cli/dist/commands/help.js +8 -13
  37. package/cli/dist/commands/issue-board.d.ts +33 -0
  38. package/cli/dist/commands/issue-board.js +61 -1
  39. package/cli/dist/commands/issue-comment.js +47 -28
  40. package/cli/dist/commands/issue-create.js +548 -91
  41. package/cli/dist/commands/issue-dependency.d.ts +3 -0
  42. package/cli/dist/commands/issue-dependency.js +282 -0
  43. package/cli/dist/commands/issue-readiness.d.ts +94 -0
  44. package/cli/dist/commands/issue-readiness.js +218 -0
  45. package/cli/dist/commands/issue-reopen.d.ts +3 -0
  46. package/cli/dist/commands/issue-reopen.js +115 -0
  47. package/cli/dist/commands/issue-shared.d.ts +32 -19
  48. package/cli/dist/commands/issue-shared.js +82 -75
  49. package/cli/dist/commands/issue-show.d.ts +3 -0
  50. package/cli/dist/commands/issue-show.js +169 -0
  51. package/cli/dist/commands/issue.d.ts +0 -1
  52. package/cli/dist/commands/issue.js +6 -8
  53. package/cli/dist/commands/names.d.ts +33 -0
  54. package/cli/dist/commands/names.js +62 -0
  55. package/cli/dist/commands/output.d.ts +14 -2
  56. package/cli/dist/commands/output.js +14 -7
  57. package/cli/dist/commands/pr-waiting.d.ts +20 -0
  58. package/cli/dist/commands/pr-waiting.js +106 -0
  59. package/cli/dist/commands/pr.d.ts +19 -0
  60. package/cli/dist/commands/pr.js +242 -323
  61. package/cli/dist/commands/project-sync.d.ts +2 -1
  62. package/cli/dist/commands/project-sync.js +18 -9
  63. package/cli/dist/commands/project.d.ts +3 -2
  64. package/cli/dist/commands/project.js +212 -175
  65. package/cli/dist/commands/registry.js +13 -10
  66. package/cli/dist/commands/release.d.ts +2 -2
  67. package/cli/dist/commands/release.js +53 -114
  68. package/cli/dist/commands/renamed-commands.d.ts +26 -0
  69. package/cli/dist/commands/renamed-commands.js +53 -0
  70. package/cli/dist/commands/repository-match.js +3 -2
  71. package/cli/dist/commands/session-finish.d.ts +3 -0
  72. package/cli/dist/commands/session-finish.js +267 -0
  73. package/cli/dist/commands/session-start.d.ts +3 -0
  74. package/cli/dist/commands/{repository.js → session-start.js} +99 -128
  75. package/cli/dist/commands/session.d.ts +3 -0
  76. package/cli/dist/commands/session.js +82 -29
  77. package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
  78. package/cli/dist/commands/{dependabot.js → tracker-sync-dependabot.js} +57 -66
  79. package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
  80. package/cli/dist/commands/{security.js → tracker-sync-security.js} +50 -61
  81. package/cli/dist/commands/tracker-sync.d.ts +7 -0
  82. package/cli/dist/commands/tracker-sync.js +3 -6
  83. package/cli/dist/commands/tracker.d.ts +3 -0
  84. package/cli/dist/commands/tracker.js +18 -0
  85. package/cli/dist/commands/usage-error.d.ts +4 -0
  86. package/cli/dist/commands/usage-error.js +6 -0
  87. package/cli/dist/commands/work-target.d.ts +12 -3
  88. package/cli/dist/commands/work-target.js +46 -5
  89. package/cli/dist/commands/worktree.js +32 -28
  90. package/cli/dist/domain/batch-plan.d.ts +73 -0
  91. package/cli/dist/domain/batch-plan.js +114 -0
  92. package/cli/dist/domain/blocked-by-change.d.ts +99 -0
  93. package/cli/dist/domain/blocked-by-change.js +101 -0
  94. package/cli/dist/domain/board-move.d.ts +90 -0
  95. package/cli/dist/domain/board-move.js +92 -0
  96. package/cli/dist/domain/branch-name.js +1 -1
  97. package/cli/dist/domain/command-hint.d.ts +85 -0
  98. package/cli/dist/domain/command-hint.js +148 -0
  99. package/cli/dist/domain/config.d.ts +4 -0
  100. package/cli/dist/domain/config.js +11 -1
  101. package/cli/dist/domain/dependabot.js +1 -1
  102. package/cli/dist/domain/errors.d.ts +5 -0
  103. package/cli/dist/domain/errors.js +5 -0
  104. package/cli/dist/domain/format.d.ts +51 -4
  105. package/cli/dist/domain/format.js +72 -6
  106. package/cli/dist/domain/frontmatter.d.ts +18 -3
  107. package/cli/dist/domain/frontmatter.js +38 -12
  108. package/cli/dist/domain/issue-order.d.ts +55 -0
  109. package/cli/dist/domain/issue-order.js +65 -0
  110. package/cli/dist/domain/issue-readout.d.ts +36 -0
  111. package/cli/dist/domain/pull-request.d.ts +71 -4
  112. package/cli/dist/domain/pull-request.js +59 -10
  113. package/cli/dist/domain/readiness.d.ts +27 -0
  114. package/cli/dist/domain/readiness.js +114 -3
  115. package/cli/dist/domain/reference-parser.d.ts +3 -1
  116. package/cli/dist/domain/reference-parser.js +6 -2
  117. package/cli/dist/domain/release.d.ts +7 -3
  118. package/cli/dist/domain/release.js +5 -12
  119. package/cli/dist/domain/repository-policy.d.ts +9 -3
  120. package/cli/dist/domain/repository-policy.js +8 -7
  121. package/cli/dist/domain/repository-resolver.js +4 -1
  122. package/cli/dist/domain/security-alerts.js +1 -1
  123. package/cli/dist/domain/state.d.ts +30 -0
  124. package/cli/dist/domain/state.js +39 -0
  125. package/cli/dist/domain/work-start.d.ts +34 -0
  126. package/cli/dist/domain/work-start.js +49 -0
  127. package/cli/dist/infra/authored-notes.d.ts +1 -1
  128. package/cli/dist/infra/authored-notes.js +10 -4
  129. package/cli/dist/infra/config-store.d.ts +4 -0
  130. package/cli/dist/infra/config-store.js +13 -0
  131. package/cli/dist/infra/git.d.ts +12 -0
  132. package/cli/dist/infra/git.js +13 -1
  133. package/cli/dist/infra/github/client.d.ts +5 -0
  134. package/cli/dist/infra/github/client.js +10 -7
  135. package/cli/dist/infra/github/errors.d.ts +18 -0
  136. package/cli/dist/infra/github/errors.js +22 -0
  137. package/cli/dist/infra/github/issues.d.ts +39 -3
  138. package/cli/dist/infra/github/issues.js +178 -23
  139. package/cli/dist/infra/github/projects.d.ts +35 -0
  140. package/cli/dist/infra/github/projects.js +89 -8
  141. package/cli/dist/infra/github/pulls.d.ts +24 -0
  142. package/cli/dist/infra/github/pulls.js +56 -0
  143. package/cli/dist/infra/github/queries.d.ts +12 -4
  144. package/cli/dist/infra/github/queries.js +156 -8
  145. package/cli/dist/infra/github/readout.d.ts +5 -1
  146. package/cli/dist/infra/github/readout.js +11 -0
  147. package/cli/dist/infra/github/repos.d.ts +18 -0
  148. package/cli/dist/infra/github/repos.js +31 -0
  149. package/cli/dist/infra/nx-scope.d.ts +1 -1
  150. package/cli/dist/infra/nx-scope.js +1 -1
  151. package/cli/dist/infra/state-store.d.ts +10 -1
  152. package/cli/dist/infra/state-store.js +14 -2
  153. package/cli/dist/infra/worktree-links.d.ts +3 -0
  154. package/cli/dist/infra/worktree-links.js +8 -1
  155. package/cli/dist/infra/worktree.d.ts +12 -1
  156. package/cli/dist/infra/worktree.js +40 -23
  157. package/cli/dist/mcp/result.d.ts +34 -6
  158. package/cli/dist/mcp/result.js +62 -18
  159. package/cli/dist/mcp/server.d.ts +2 -2
  160. package/cli/dist/mcp/server.js +24 -10
  161. package/cli/templates/comment/plan.md +14 -0
  162. package/cli/templates/issue/bug.md +1 -1
  163. package/cli/templates/issue/task-implement.md +13 -6
  164. package/cli/templates/issue/task.md +1 -1
  165. package/cli/templates/workflow/pecot-board-sync.yml +84 -0
  166. package/npm-shrinkwrap.json +2 -2
  167. package/package.json +1 -1
  168. package/cli/dist/commands/dependabot.d.ts +0 -3
  169. package/cli/dist/commands/issue-project.d.ts +0 -3
  170. package/cli/dist/commands/issue-project.js +0 -176
  171. package/cli/dist/commands/issue-quick.d.ts +0 -3
  172. package/cli/dist/commands/issue-quick.js +0 -126
  173. package/cli/dist/commands/issue-read.d.ts +0 -3
  174. package/cli/dist/commands/issue-read.js +0 -80
  175. package/cli/dist/commands/repository.d.ts +0 -5
  176. package/cli/dist/commands/security.d.ts +0 -3
@@ -142,6 +142,33 @@ export declare function planProgression(phases: readonly PlannedPhase[]): Progre
142
142
  stack の積む先をたどった木の、根から葉までの道を、下から並べて返す。stack の無い根は道を作らないので、1 段だけの道は出ない
143
143
  */
144
144
  export declare function stackChains(progressions: ReadonlyMap<string, Progression>): readonly (readonly string[])[];
145
+ /**
146
+ target から前提をたどって届く部分のグラフに findCycle をかけ、輪が target を含むときだけ返す。
147
+ 別の Issue の輪に行き当たっただけの Issue には、輪を付けない
148
+ */
149
+ export declare function cycleThrough(target: string, edges: ReadonlyMap<string, readonly string[]>): readonly string[] | undefined;
150
+ /**
151
+ 判定の一覧(Issue のキー → 判定)から、stackChains に渡す進め方を作る。
152
+ stackable は積む先の Issue の上に積み、それ以外は単独として扱う
153
+ */
154
+ export declare function progressionsFromReadiness(readiness: ReadonlyMap<string, Readiness>): ReadonlyMap<string, Progression>;
155
+ /**
156
+ メッセージに出す Issue の表記。home と同じリポジトリは `#N`、別のリポジトリは `owner/repo#N`。home が無ければ常に `owner/repo#N`
157
+ */
158
+ export declare function displayReference(reference: IssueReference, home?: RepositoryReference): string;
159
+ /**
160
+ 前提 1 件の状態の文。`done`・`closed without merge`・`in review`・`wait: merge — <理由>`、または積めない理由(not started など)
161
+ */
162
+ export declare function describePrerequisiteState(prerequisite: Readonly<Prerequisite>): string;
163
+ /**
164
+ 判定を 1 行の文にする。`startable`・`stackable on #N`・`blocked by #N, #M (<理由>)`。
165
+ blocked by の後には、済んでいない前提をすべて並べる。別のリポジトリの Issue は `owner/repo#N`
166
+ */
167
+ export declare function describeReadiness(readiness: Readiness, prerequisites: readonly Prerequisite[], targetRepository: RepositoryReference): string;
168
+ /**
169
+ 読めなかった Issue の表示。列と札は動かさない
170
+ */
171
+ export declare function describeUnknown(reason: string): string;
145
172
  export interface FactsMismatch {
146
173
  readonly ref: IssueReference;
147
174
  readonly reason: string;
@@ -1,7 +1,7 @@
1
1
  // Issue の着手の可否の判定と、フェーズの進め方(specs/024 の data-model.md の 2〜4)。I/O を持たない純関数だけを置く。
2
2
  import { isEpicIssue } from './issue-kind.js';
3
3
  import { issueReferenceKey } from './reference-parser.js';
4
- import { isSameRepository } from './repository-resolver.js';
4
+ import { isSameRepository, repositoryFullName } from './repository-resolver.js';
5
5
  export const PENDING_COLUMN = 'Pending';
6
6
  export const NEEDS_ATTENTION_LABEL = 'Needs Attention';
7
7
  export const TRACKER_TITLE_PREFIX = '[Tracker]';
@@ -55,12 +55,14 @@ function headsToDevelopment(start, byHead, developmentBranch) {
55
55
  return reached;
56
56
  }
57
57
  // 済んでいない前提はすべて PR 中なので、open の PR がちょうど 1 本ある
58
+ // 辿る PR も、対象と同じリポのものだけにする
58
59
  function findStackTarget(unfinished, input) {
60
+ const targetRepository = input.target.ref.repository;
59
61
  const entries = unfinished.flatMap(({ issue }) => {
60
62
  const [pullRequest] = openPullRequests(issue);
61
63
  return pullRequest === undefined ? [] : { issue: issue.ref, pullRequest };
62
64
  });
63
- const byHead = new Map([...input.pullRequestsByHead].filter(([, pullRequest]) => isStackBase(pullRequest)));
65
+ const byHead = new Map([...input.pullRequestsByHead].filter(([, pullRequest]) => isStackBase(pullRequest) && isSameRepository(pullRequest.repository, targetRepository)));
64
66
  for (const { pullRequest } of entries)
65
67
  byHead.set(pullRequest.headRefName, pullRequest);
66
68
  for (const start of entries) {
@@ -99,7 +101,9 @@ export function judgeReadiness(input) {
99
101
  }
100
102
  if (unfinished.length === 0)
101
103
  return result('startable', { needsReview: isNeedsReview, attention });
102
- const otherRepository = unfinished.filter(({ issue }) => !isSameRepository(issue.ref.repository, target.ref.repository));
104
+ // 前提の Issue か、その PR が別のリポにあると、積む先のブランチを対象のリポで引けない
105
+ const otherRepository = unfinished.filter(({ issue }) => !isSameRepository(issue.ref.repository, target.ref.repository)
106
+ || (isInReview(issue) && openPullRequests(issue).some(pullRequest => !isSameRepository(pullRequest.repository, target.ref.repository))));
103
107
  if (otherRepository.length > 0)
104
108
  return blocked({ code: 'other-repository', issues: otherRepository.map(({ issue }) => issue.ref) });
105
109
  const notInReview = unfinished.filter(({ issue }) => !isStackable(issue));
@@ -208,6 +212,113 @@ export function stackChains(progressions) {
208
212
  };
209
213
  return roots.flatMap(root => walk(root, [root]));
210
214
  }
215
+ /**
216
+ target から前提をたどって届く部分のグラフに findCycle をかけ、輪が target を含むときだけ返す。
217
+ 別の Issue の輪に行き当たっただけの Issue には、輪を付けない
218
+ */
219
+ export function cycleThrough(target, edges) {
220
+ const reached = new Set([target]);
221
+ const pending = [target];
222
+ for (let key = pending.pop(); key !== undefined; key = pending.pop()) {
223
+ const nextKeys = edges.get(key) ?? [];
224
+ for (const next of nextKeys) {
225
+ if (reached.has(next))
226
+ continue;
227
+ reached.add(next);
228
+ pending.push(next);
229
+ }
230
+ }
231
+ const subgraph = new Map([...reached].map(key => [key, edges.get(key) ?? []]));
232
+ const cycle = findCycle(subgraph);
233
+ return cycle?.includes(target) === true ? cycle : undefined;
234
+ }
235
+ /**
236
+ 判定の一覧(Issue のキー → 判定)から、stackChains に渡す進め方を作る。
237
+ stackable は積む先の Issue の上に積み、それ以外は単独として扱う
238
+ */
239
+ export function progressionsFromReadiness(readiness) {
240
+ return new Map([...readiness].map(([key, judged]) => [
241
+ key,
242
+ judged.kind === 'stackable' && judged.stackOn !== undefined
243
+ ? { kind: 'stack', on: issueReferenceKey(judged.stackOn.issue) }
244
+ : { kind: 'alone' },
245
+ ]));
246
+ }
247
+ /**
248
+ メッセージに出す Issue の表記。home と同じリポジトリは `#N`、別のリポジトリは `owner/repo#N`。home が無ければ常に `owner/repo#N`
249
+ */
250
+ export function displayReference(reference, home) {
251
+ const number = `#${String(reference.number)}`;
252
+ return home !== undefined && isSameRepository(reference.repository, home) ? number : `${repositoryFullName(reference.repository)}${number}`;
253
+ }
254
+ const NOT_IN_REVIEW_TEXT = new Map([
255
+ ['not-started', 'not started'],
256
+ ['started-without-pr', 'no PR'],
257
+ ['multiple-prs', 'multiple PRs'],
258
+ ['fork-pr', 'PR from fork'],
259
+ ['pending', 'in Pending'],
260
+ ]);
261
+ /**
262
+ 前提 1 件の状態の文。`done`・`closed without merge`・`in review`・`wait: merge — <理由>`、または積めない理由(not started など)
263
+ */
264
+ export function describePrerequisiteState(prerequisite) {
265
+ const { issue, wait, reason } = prerequisite;
266
+ if (isDone(issue))
267
+ return 'done';
268
+ if (issue.state === 'closed')
269
+ return 'closed without merge';
270
+ if (wait === 'merge')
271
+ return reason === undefined ? 'wait: merge' : `wait: merge — ${reason}`;
272
+ const state = notInReviewState(issue);
273
+ return isStackable(issue) ? 'in review' : (NOT_IN_REVIEW_TEXT.get(state) ?? state);
274
+ }
275
+ function describeReason(reason, targetRepository) {
276
+ const show = (reference) => displayReference(reference, targetRepository);
277
+ switch (reason.code) {
278
+ case 'unreadable': {
279
+ return 'unreadable';
280
+ }
281
+ case 'waits-merge': {
282
+ return 'waits for merge';
283
+ }
284
+ case 'diverged': {
285
+ return 'not in one chain';
286
+ }
287
+ case 'closed-unmerged': {
288
+ return `closed without merge: ${reason.issues.map(issue => show(issue)).join(', ')}`;
289
+ }
290
+ case 'other-repository': {
291
+ return `other repository: ${reason.issues.map(issue => show(issue)).join(', ')}`;
292
+ }
293
+ case 'not-in-review': {
294
+ return `not in review: ${reason.issues.map(({ issue, state }) => `${show(issue)} (${NOT_IN_REVIEW_TEXT.get(state) ?? state})`).join(', ')}`;
295
+ }
296
+ case 'cycle': {
297
+ const prefix = `${repositoryFullName(targetRepository).toLowerCase()}#`;
298
+ return `cycle: ${reason.cycle.map(key => (key.startsWith(prefix) ? `#${key.slice(prefix.length)}` : key)).join(' -> ')}`;
299
+ }
300
+ }
301
+ }
302
+ /**
303
+ 判定を 1 行の文にする。`startable`・`stackable on #N`・`blocked by #N, #M (<理由>)`。
304
+ blocked by の後には、済んでいない前提をすべて並べる。別のリポジトリの Issue は `owner/repo#N`
305
+ */
306
+ export function describeReadiness(readiness, prerequisites, targetRepository) {
307
+ if (readiness.kind === 'startable')
308
+ return 'startable';
309
+ if (readiness.kind === 'stackable') {
310
+ return readiness.stackOn === undefined ? 'stackable' : `stackable on ${displayReference(readiness.stackOn.issue, targetRepository)}`;
311
+ }
312
+ const unfinished = prerequisites.filter(({ issue }) => !isDone(issue)).map(({ issue }) => displayReference(issue.ref, targetRepository));
313
+ const reason = readiness.reason === undefined ? '' : ` (${describeReason(readiness.reason, targetRepository)})`;
314
+ return `blocked${unfinished.length === 0 ? '' : ` by ${unfinished.join(', ')}`}${reason}`;
315
+ }
316
+ /**
317
+ 読めなかった Issue の表示。列と札は動かさない
318
+ */
319
+ export function describeUnknown(reason) {
320
+ return `unknown (${reason})`;
321
+ }
211
322
  const LOWER_STATE = { OPEN: 'open', MERGED: 'merged', CLOSED: 'closed' };
212
323
  function toPullRequest(readout) {
213
324
  return {
@@ -1,3 +1,4 @@
1
+ import type { HintedText } from './command-hint.js';
1
2
  import { PecotError } from './errors.js';
2
3
  import type { RepositoryReference } from './repository-resolver.js';
3
4
  /**
@@ -5,7 +6,8 @@ import type { RepositoryReference } from './repository-resolver.js';
5
6
  */
6
7
  export declare class ReferenceParseError extends PecotError {
7
8
  readonly reference: string;
8
- constructor(message: string, reference: string, options?: Readonly<ErrorOptions>);
9
+ readonly hintedText: HintedText | undefined;
10
+ constructor(message: string | HintedText, reference: string, options?: Readonly<ErrorOptions>);
9
11
  }
10
12
  export interface IssueReference {
11
13
  readonly repository: RepositoryReference;
@@ -2,6 +2,7 @@
2
2
  //
3
3
  // `owner/repo/N` 形式を IssueReference にする。短縮形 `N` は基準リポ(baseRepository)で補う。
4
4
  // 参照の形式が不正なときの文は、Python の CLI が出していた文に揃える。
5
+ import { formatHinted, globalRepositoryHint, hinted, placeholder } from './command-hint.js';
5
6
  import { PecotError, InvalidValueError } from './errors.js';
6
7
  import { parsePythonInteger, ValidationFailure } from './python-format.js';
7
8
  import { createRepositoryReference, parseOwnerRepository, repositoryFullName } from './repository-resolver.js';
@@ -10,9 +11,12 @@ import { createRepositoryReference, parseOwnerRepository, repositoryFullName } f
10
11
  */
11
12
  export class ReferenceParseError extends PecotError {
12
13
  reference;
14
+ hintedText;
15
+ // message は CLI の形。出し先の形は hintedText から描き直す
13
16
  constructor(message, reference, options) {
14
- super(message, options);
17
+ super(formatHinted(message, 'cli'), options);
15
18
  this.reference = reference;
19
+ this.hintedText = typeof message === 'string' ? undefined : message;
16
20
  }
17
21
  }
18
22
  /**
@@ -57,7 +61,7 @@ export function parseIssueReference(raw, baseRepository, { repositoryFlag = fals
57
61
  if (/^\d+$/u.test(raw)) {
58
62
  if (baseRepository === undefined) {
59
63
  throw new ReferenceParseError(repositoryFlag
60
- ? 'the short form \'N\' needs a base_repo: pass --repo <owner/repo> or use the full form \'owner/repo/N\''
64
+ ? hinted `the short form 'N' needs a base_repo: pass ${globalRepositoryHint(placeholder('owner/repo'))} or use the full form 'owner/repo/N'`
61
65
  : 'the short form \'N\' is not accepted here: use the full form \'owner/repo/N\'', raw);
62
66
  }
63
67
  return createIssueReference(baseRepository, integerOf(raw));
@@ -36,14 +36,18 @@ export interface PreflightOptions {
36
36
  */
37
37
  readonly tagPrefix: string | undefined;
38
38
  /**
39
- ls-remote・fetch・差分確認に使う remote 名。省略すると origin
39
+ ls-remote と文に使う remote 名。省略すると origin
40
40
  */
41
41
  readonly remote?: string | undefined;
42
42
  }
43
43
  /**
44
+ base より head が進んでいる commit の数。GitHub の compare で数え、手元の ref は動かさない
45
+ */
46
+ export type CountCommitsAhead = (base: string, head: string) => Promise<number>;
47
+ /**
44
48
  リリース前チェックを実行する。
45
49
  1. CHANGELOG.md の存在、2. バージョンの検出または検証、3. タグが無いこと(ローカル・リモート)、
46
- 4. release→develop の差分、5. リリースノートの抽出、の順に確かめる。失敗は ReleaseError
50
+ 4. release→develop の差分(countAhead)、5. リリースノートの抽出、の順に確かめる。失敗は ReleaseError
47
51
  */
48
- export declare function runPreflight(options: PreflightOptions, git: GitRunner): PreflightResult;
52
+ export declare function runPreflight(options: PreflightOptions, git: GitRunner, countAhead: CountCommitsAhead): Promise<PreflightResult>;
49
53
  //# sourceMappingURL=release.d.ts.map
@@ -1,7 +1,7 @@
1
1
  // リリース前チェック(preflight)。git は GitRunner を受けて呼ぶ。CHANGELOG は内容(文字列)を受ける。
2
2
  import { changelogFileName, changelogNotFoundMessage, extractVersionReleaseNotes, getLatestVersion, validateSemver, VersionNotFoundError } from './changelog.js';
3
- import { PecotError, InvalidValueError } from './errors.js';
4
- import { parsePythonInteger, pythonStringRepr, pythonStrip } from './python-format.js';
3
+ import { PecotError } from './errors.js';
4
+ import { pythonStrip } from './python-format.js';
5
5
  export class ReleaseError extends PecotError {
6
6
  }
7
7
  /**
@@ -28,18 +28,12 @@ function determineVersion(options, changelogContent) {
28
28
  validateSemver(options.version);
29
29
  return options.version;
30
30
  }
31
- function countDifference(output) {
32
- const count = parsePythonInteger(output);
33
- if (count === undefined)
34
- throw new InvalidValueError(`invalid literal for int() with base 10: ${pythonStringRepr(output)}`);
35
- return count;
36
- }
37
31
  /**
38
32
  リリース前チェックを実行する。
39
33
  1. CHANGELOG.md の存在、2. バージョンの検出または検証、3. タグが無いこと(ローカル・リモート)、
40
- 4. release→develop の差分、5. リリースノートの抽出、の順に確かめる。失敗は ReleaseError
34
+ 4. release→develop の差分(countAhead)、5. リリースノートの抽出、の順に確かめる。失敗は ReleaseError
41
35
  */
42
- export function runPreflight(options, git) {
36
+ export async function runPreflight(options, git, countAhead) {
43
37
  const { changelogContent, developBranch, releaseBranch } = options;
44
38
  if (changelogContent === undefined)
45
39
  throw new ReleaseError(changelogNotFoundMessage(options.changelogPath));
@@ -52,8 +46,7 @@ export function runPreflight(options, git) {
52
46
  const remoteTags = runGit(git, ['ls-remote', '--tags', remote, `refs/tags/${tagName}`]);
53
47
  if (remoteTags !== '')
54
48
  throw new ReleaseError(`tag already exists on the remote: ${tagName}`);
55
- runGit(git, ['fetch', remote, releaseBranch, developBranch]);
56
- const diffCount = countDifference(runGit(git, ['rev-list', '--count', `${remote}/${releaseBranch}..${remote}/${developBranch}`]));
49
+ const diffCount = await countAhead(releaseBranch, developBranch);
57
50
  if (diffCount === 0) {
58
51
  throw new ReleaseError(`no difference between ${remote}/${releaseBranch} and ${remote}/${developBranch}: `
59
52
  + 'there is nothing to release');
@@ -1,3 +1,4 @@
1
+ import type { HintedText } from './command-hint.js';
1
2
  import type { RepositoryReference, ResolvedRepository } from './repository-resolver.js';
2
3
  export type PolicyMode = 'reject' | 'warn';
3
4
  export interface PolicyInput {
@@ -12,20 +13,25 @@ export interface PolicyInput {
12
13
  readonly mode: PolicyMode;
13
14
  }
14
15
  /**
15
- 結果の種類は kind で判別する。stderr は改行を含まない行の並びで、呼ぶ側が 1 行ずつ出す。
16
+ 結果の種類は kind で判別する。stderr は改行を含まない行の並びで、呼ぶ側が出し先の形にして 1 行ずつ出す。
16
17
  - proceed は、続行する。adopted は明示値から採用したリポジトリ(--repo が無ければ undefined)。
17
18
  - exit は、stderr を出して指定の終了コードで終わる。
18
19
  */
19
20
  export type PolicyOutcome = {
20
21
  readonly kind: 'proceed';
21
22
  readonly adopted: RepositoryReference | undefined;
22
- readonly stderr: readonly string[];
23
+ readonly stderr: readonly (string | HintedText)[];
23
24
  } | {
24
25
  readonly kind: 'exit';
25
26
  readonly exitCode: 1;
26
- readonly stderr: readonly string[];
27
+ readonly failure: PolicyFailure;
28
+ readonly stderr: readonly (string | HintedText)[];
27
29
  };
28
30
  /**
31
+ 止める原因の名前。commands の FailureKind の一部
32
+ */
33
+ export type PolicyFailure = 'git-unresolved' | 'invalid-input' | 'repo-mismatch';
34
+ /**
29
35
  `--repo` とカレント Git remote の不一致時の方針を判定する
30
36
  */
31
37
  export declare function applyRepositoryPolicy(input: PolicyInput): PolicyOutcome;
@@ -1,6 +1,6 @@
1
1
  // `--repo` 不一致方針(FR-009a / FR-009b)の判定。
2
2
  //
3
- // ローカル Git を破壊する操作系(worktree・create-branch・delete-branch など)は reject にする。
3
+ // ローカル Git を破壊する操作系(worktree・session start・branch delete など)は reject にする。
4
4
  // GitHub API 側への操作が中心のもの(release など)は warn にする。
5
5
  // 判定だけを純粋な関数にする。stderr への出力と終了は、呼ぶ側(commands 層)が行う。
6
6
  //
@@ -15,11 +15,12 @@
15
15
  // - 不一致で reject は終了コード 1、warn は警告を出して明示値を採用して続行する。
16
16
  //
17
17
  // 文言は contracts/cli-commands.md の固定文言と一致させる(stderr を e2e で確かめるため)。
18
+ import { globalRepositoryHint, hinted, placeholder } from './command-hint.js';
18
19
  import { InvalidValueError } from './errors.js';
19
20
  import { pythonStringRepr } from './python-format.js';
20
21
  import { parseOwnerRepository, repositoryFullName } from './repository-resolver.js';
21
- function exitWith(...stderr) {
22
- return { kind: 'exit', exitCode: 1, stderr };
22
+ function exitWith(failure, ...stderr) {
23
+ return { kind: 'exit', exitCode: 1, failure, stderr };
23
24
  }
24
25
  function parseExplicit(explicit) {
25
26
  try {
@@ -38,12 +39,12 @@ export function applyRepositoryPolicy(input) {
38
39
  const { explicit, resolved, mode } = input;
39
40
  if (explicit === undefined) {
40
41
  return resolved === undefined
41
- ? exitWith('error: the repository is ambiguous', ' give --repo <owner/repo>')
42
+ ? exitWith('git-unresolved', 'error: the repository is ambiguous', hinted ` give ${globalRepositoryHint(placeholder('owner/repo'))}`)
42
43
  : { kind: 'proceed', adopted: undefined, stderr: [] };
43
44
  }
44
45
  const explicitReference = parseExplicit(explicit);
45
46
  if (explicitReference === undefined)
46
- return exitWith(`error: --repo has an invalid form: ${pythonStringRepr(explicit)}`);
47
+ return exitWith('invalid-input', hinted `error: ${globalRepositoryHint()} has an invalid form: ${pythonStringRepr(explicit)}`);
47
48
  // Git 外 / remote 不在は比較対象が無いので、明示値を採用する
48
49
  if (resolved?.source !== 'current-git')
49
50
  return { kind: 'proceed', adopted: explicitReference, stderr: [] };
@@ -54,12 +55,12 @@ export function applyRepositoryPolicy(input) {
54
55
  const explicitName = repositoryFullName(explicitReference);
55
56
  const currentName = repositoryFullName(current);
56
57
  if (mode === 'reject') {
57
- return exitWith(`error: --repo ${explicitName} differs from the current Git remote (${currentName})`, ' this command works only on the repository of the current Git remote');
58
+ return exitWith('repo-mismatch', hinted `error: ${globalRepositoryHint()} ${explicitName} differs from the current Git remote (${currentName})`, ' this command works only on the repository of the current Git remote');
58
59
  }
59
60
  return {
60
61
  kind: 'proceed',
61
62
  adopted: explicitReference,
62
- stderr: [`warning: using --repo ${explicitName} (current Git remote: ${currentName})`],
63
+ stderr: [hinted `warning: using ${globalRepositoryHint()} ${explicitName} (current Git remote: ${currentName})`],
63
64
  };
64
65
  }
65
66
  //# sourceMappingURL=repository-policy.js.map
@@ -8,6 +8,7 @@
8
8
  //
9
9
  // 検証エラーの文は、Python の CLI の書式に揃える。
10
10
  // 表題は元のクラス名(RepoRef・ResolvedRepo)を使う。
11
+ import { formatHinted, globalRepositoryHint, hinted, placeholder } from './command-hint.js';
11
12
  import { PecotError, InvalidValueError } from './errors.js';
12
13
  import { parseRemoteUrl } from './git-url.js';
13
14
  import { pythonStringRepr, ValidationFailure } from './python-format.js';
@@ -114,6 +115,8 @@ export function resolveRepository(explicit, git) {
114
115
  if (detected !== undefined) {
115
116
  return createResolvedRepository({ repository: detected.repository, source: 'current-git', remoteName: detected.remoteName });
116
117
  }
117
- throw new AmbiguousRepositoryError('repository is ambiguous: pass --repo <owner/repo>');
118
+ // 文を出すのは CLI の最上位(src/cli.ts)だけ。ほかの呼び手は捕まえて undefined にする
119
+ const repositoryHint = globalRepositoryHint(placeholder('owner/repo'));
120
+ throw new AmbiguousRepositoryError(formatHinted(hinted `repository is ambiguous: pass ${repositoryHint}`, 'cli'));
118
121
  }
119
122
  //# sourceMappingURL=repository-resolver.js.map
@@ -1,4 +1,4 @@
1
- // security alert の種類と、種類ごとの open の alert の取得、code scanning・secret scanning の状態判定。`release preflight` と `security sync` が使う。
1
+ // security alert の種類と、種類ごとの open の alert の取得、code scanning・secret scanning の状態判定。`release check` と `tracker sync security` が使う。
2
2
  // 取得は ScanAlertSource と DependabotSource に任せる。
3
3
  import { describeApiError } from './api-error-detail.js';
4
4
  import { PecotError } from './errors.js';
@@ -1,5 +1,7 @@
1
+ import type { IssueReference } from './reference-parser.js';
1
2
  export declare const FLAG_PECOT_ACTIVE = ".pecot-active";
2
3
  export declare const FLAG_PECOT_SESSION_TITLE = ".pecot-session-title";
4
+ export declare const FLAG_PECOT_BASE = ".pecot-base";
3
5
  export declare const FLAG_PECOT_QUICK_MODE = ".pecot-quick-mode";
4
6
  export declare const FLAG_WIP_BRANCH_LINKED = ".wip-branch-linked";
5
7
  export declare const FLAG_PR_CREATE_SLASH_PENDING = "pr-create-slash-pending";
@@ -26,4 +28,32 @@ export interface WorkTarget {
26
28
  作業対象として書く内容(.pecot-active と .pecot-session-title)を決める。参照の末尾が整数でなければ InvalidValueError
27
29
  */
28
30
  export declare function planWorkTarget(issueReference: string, title: string): WorkTarget;
31
+ export interface BaseRecord {
32
+ readonly branch: string;
33
+ readonly sha: string;
34
+ /**
35
+ 積んだ先の Issue。開発ブランチから着手したときは undefined
36
+ */
37
+ readonly stackedOn: IssueReference | undefined;
38
+ }
39
+ export type BaseReading = {
40
+ readonly kind: 'development';
41
+ readonly record: BaseRecord | undefined;
42
+ } | {
43
+ readonly kind: 'stacked';
44
+ readonly record: BaseRecord;
45
+ readonly stackedOn: IssueReference;
46
+ } | {
47
+ readonly kind: 'malformed';
48
+ readonly content: string;
49
+ };
50
+ /**
51
+ .pecot-base の 1 行。`<branch> <sha>` に、積んだときは ` <owner/repo#N>` を続ける
52
+ */
53
+ export declare function formatBaseRecord(record: Readonly<BaseRecord>): string;
54
+ /**
55
+ .pecot-base の内容を読む。ファイルが無いのは、この機能の前に着手したものも含めて、開発ブランチから着手したものとして扱う。
56
+ 形が誤っていれば malformed
57
+ */
58
+ export declare function interpretBaseRecord(content: string | undefined): BaseReading;
29
59
  //# sourceMappingURL=state.d.ts.map
@@ -1,10 +1,14 @@
1
1
  // フック状態の規則(フラグ名・セッション名・作業ディレクトリ名)。ファイルの読み書きは infra/state-store.ts が行う。
2
2
  import { InvalidValueError } from './errors.js';
3
3
  import { parsePythonInteger, pythonRightStrip, pythonStrip, pythonStringRepr, truncateCodePoints } from './python-format.js';
4
+ import { createIssueReference, issueReferenceToString } from './reference-parser.js';
5
+ import { createRepositoryReference } from './repository-resolver.js';
4
6
  // フラグファイル名
5
7
  export const FLAG_PECOT_ACTIVE = '.pecot-active';
6
8
  // セッション名(hooks の session-title.sh が Claude Code の sessionTitle に流す)。.pecot-active と同じタイミングで書く
7
9
  export const FLAG_PECOT_SESSION_TITLE = '.pecot-session-title';
10
+ // 着手のときに選んだ base(ブランチ・位置・積んだ先の Issue)。session start が書き、session finish が消す
11
+ export const FLAG_PECOT_BASE = '.pecot-base';
8
12
  export const FLAG_PECOT_QUICK_MODE = '.pecot-quick-mode';
9
13
  export const FLAG_WIP_BRANCH_LINKED = '.wip-branch-linked';
10
14
  // スラッシュコマンド起点の外部反映免除フラグ。
@@ -53,4 +57,39 @@ export function planWorkTarget(issueReference, title) {
53
57
  throw new InvalidValueError(`invalid literal for int() with base 10: ${pythonStringRepr(text)}`);
54
58
  return { active: issueReference, sessionTitle: formatSessionTitle(number, title) };
55
59
  }
60
+ // ブランチ名に空白は入らないので、空白で区切る
61
+ const BASE_SHA_PATTERN = /^(?:[\da-f]{40}|[\da-f]{64})$/u;
62
+ const BASE_ISSUE_PATTERN = /^([^\s#/]+)\/([^\s#/]+)#(\d+)$/u;
63
+ /**
64
+ .pecot-base の 1 行。`<branch> <sha>` に、積んだときは ` <owner/repo#N>` を続ける
65
+ */
66
+ export function formatBaseRecord(record) {
67
+ const fields = [record.branch, record.sha];
68
+ if (record.stackedOn !== undefined)
69
+ fields.push(issueReferenceToString(record.stackedOn));
70
+ return fields.join(' ');
71
+ }
72
+ function parseStackedOn(text) {
73
+ const match = BASE_ISSUE_PATTERN.exec(text);
74
+ const [, owner, repository, digits] = match ?? [];
75
+ if (owner === undefined || repository === undefined || digits === undefined)
76
+ return undefined;
77
+ const number = Number(digits);
78
+ return number > 0 ? createIssueReference(createRepositoryReference(owner, repository), number) : undefined;
79
+ }
80
+ /**
81
+ .pecot-base の内容を読む。ファイルが無いのは、この機能の前に着手したものも含めて、開発ブランチから着手したものとして扱う。
82
+ 形が誤っていれば malformed
83
+ */
84
+ export function interpretBaseRecord(content) {
85
+ if (content === undefined)
86
+ return { kind: 'development', record: undefined };
87
+ const [branch, sha, issue, ...rest] = content.split(' ');
88
+ if (branch === undefined || branch === '' || sha === undefined || !BASE_SHA_PATTERN.test(sha) || rest.length > 0)
89
+ return { kind: 'malformed', content };
90
+ if (issue === undefined)
91
+ return { kind: 'development', record: { branch, sha, stackedOn: undefined } };
92
+ const stackedOn = parseStackedOn(issue);
93
+ return stackedOn === undefined ? { kind: 'malformed', content } : { kind: 'stacked', record: { branch, sha, stackedOn }, stackedOn };
94
+ }
56
95
  //# sourceMappingURL=state.js.map
@@ -0,0 +1,34 @@
1
+ import type { HintedText } from './command-hint.js';
2
+ import type { PullRequestReadout } from './issue-readout.js';
3
+ import type { Prerequisite, Readiness } from './readiness.js';
4
+ import type { IssueReference } from './reference-parser.js';
5
+ export type StartDecision = {
6
+ readonly kind: 'start';
7
+ } | {
8
+ readonly kind: 'stack';
9
+ readonly branch: string;
10
+ readonly issue: IssueReference;
11
+ } | {
12
+ readonly kind: 'blocked';
13
+ readonly message: HintedText;
14
+ };
15
+ /**
16
+ 判定から着手の仕方を決める。stackable は積む先のブランチから、blocked は止める。
17
+ startable と、判定を持たない Epic・Tracker(undefined)は、今までどおり
18
+ */
19
+ export declare function decideStart(readiness: Readiness | undefined, prerequisites: readonly Prerequisite[], target: IssueReference): StartDecision;
20
+ /**
21
+ --base が、判定で選んだ積む先と違うときの文。stackable のときだけ比べる
22
+ */
23
+ export declare function describeBaseMismatch(base: string | undefined, decision: Exclude<StartDecision, {
24
+ kind: 'blocked';
25
+ }>, target: IssueReference): HintedText | undefined;
26
+ /**
27
+ base のブランチを head に持つ PR のうち、表に出す 1 本。fork でない open のもの、無ければ fork でない最新のもの(新しい順に渡す)
28
+ */
29
+ export declare function pickBasePullRequest(pullRequests: readonly PullRequestReadout[]): PullRequestReadout | undefined;
30
+ /**
31
+ session show の `- base:` の行。PR が無ければ `no PR`、読めなければ `PR unknown`
32
+ */
33
+ export declare function describeStackBase(branch: string, issue: IssueReference, pullRequest: Readonly<PullRequestReadout> | undefined | 'unknown'): string;
34
+ //# sourceMappingURL=work-start.d.ts.map
@@ -0,0 +1,49 @@
1
+ // 着手の判定から、base の選び方・止める文・積んだ先の表示を決める。I/O を持たない。
2
+ import { commandHint, hinted, inputHint, joinHinted } from './command-hint.js';
3
+ import { describePrerequisiteState, describeReadiness, displayReference, isDone } from './readiness.js';
4
+ import { issueReferenceToCliReference } from './reference-parser.js';
5
+ function blockedMessage(target, readiness, prerequisites) {
6
+ const home = target.repository;
7
+ const unfinished = prerequisites.filter(({ issue }) => !isDone(issue));
8
+ const subject = issueReferenceToCliReference(target);
9
+ const waitsMerge = readiness.reason?.code === 'waits-merge' ? readiness.reason.issues : [];
10
+ return joinHinted([
11
+ `${displayReference(target, home)} is ${describeReadiness(readiness, prerequisites, home)}`,
12
+ ...unfinished.map(prerequisite => `- ${displayReference(prerequisite.issue.ref, home)}: ${describePrerequisiteState(prerequisite)}`),
13
+ ...unfinished.map(({ issue }) => hinted `to remove the prerequisite: ${commandHint(['issue', 'unblock'], { issue_ref: subject, by: issueReferenceToCliReference(issue.ref) })}`),
14
+ ...waitsMerge.map(({ issue }) => hinted `to stack on it instead of waiting for merge: ${commandHint(['issue', 'block'], { issue_ref: subject, by: issueReferenceToCliReference(issue), wait: 'stack' })}`),
15
+ ]);
16
+ }
17
+ /**
18
+ 判定から着手の仕方を決める。stackable は積む先のブランチから、blocked は止める。
19
+ startable と、判定を持たない Epic・Tracker(undefined)は、今までどおり
20
+ */
21
+ export function decideStart(readiness, prerequisites, target) {
22
+ if (readiness?.kind === 'blocked')
23
+ return { kind: 'blocked', message: blockedMessage(target, readiness, prerequisites) };
24
+ if (readiness?.kind === 'stackable' && readiness.stackOn !== undefined)
25
+ return { kind: 'stack', branch: readiness.stackOn.branch, issue: readiness.stackOn.issue };
26
+ return { kind: 'start' };
27
+ }
28
+ /**
29
+ --base が、判定で選んだ積む先と違うときの文。stackable のときだけ比べる
30
+ */
31
+ export function describeBaseMismatch(base, decision, target) {
32
+ const isDifferent = base !== undefined && base !== '' && decision.kind === 'stack' && base !== decision.branch;
33
+ return isDifferent ? hinted `${inputHint(['session', 'start'], 'base', base)} differs from the base chosen by readiness: ${decision.branch} (stacked on ${displayReference(decision.issue, target.repository)})` : undefined;
34
+ }
35
+ /**
36
+ base のブランチを head に持つ PR のうち、表に出す 1 本。fork でない open のもの、無ければ fork でない最新のもの(新しい順に渡す)
37
+ */
38
+ export function pickBasePullRequest(pullRequests) {
39
+ const own = pullRequests.filter(pullRequest => !pullRequest.isCrossRepository);
40
+ return own.find(pullRequest => pullRequest.state === 'OPEN') ?? own[0];
41
+ }
42
+ /**
43
+ session show の `- base:` の行。PR が無ければ `no PR`、読めなければ `PR unknown`
44
+ */
45
+ export function describeStackBase(branch, issue, pullRequest) {
46
+ const pr = pullRequest === 'unknown' ? 'PR unknown' : (pullRequest === undefined ? 'no PR' : `PR #${String(pullRequest.number)} ${pullRequest.state}`);
47
+ return `- base: ${branch} (#${String(issue.number)}, ${pr})`;
48
+ }
49
+ //# sourceMappingURL=work-start.js.map
@@ -30,7 +30,7 @@ export type NotesResult = {
30
30
  readonly reason: string;
31
31
  };
32
32
  /**
33
- ID(`PW-CREATE-BRANCH`)の項目の details・constraints・examples・default_notes を読む。
33
+ ID(`PW-SESSION-START`)の項目の details・constraints・examples・default_notes を読む。
34
34
  ファイルが無い・YAML として読めない・項目が無い・欄の形が違うときは、場所と理由を持つ unreadable を返す
35
35
  */
36
36
  export declare function readAuthoredNotes(id: string, root?: string): NotesResult;
@@ -12,11 +12,16 @@ const DEPENDENCY_SCHEMA = z.object({ requires: z.record(z.string(), NAMES_SCHEMA
12
12
  const CONSTRAINT_SCHEMA = z.union([CONFLICTS_SCHEMA, DEPENDENCY_SCHEMA]);
13
13
  const EXAMPLE_SCHEMA = z.object({ run: z.string(), note: z.string() });
14
14
  const FILE_SCHEMA = z.object({ entries: z.record(z.string(), z.unknown()) });
15
- const ENTRY_SCHEMA = z.object({
15
+ const PROSE_SHAPE = {
16
16
  details: NAMES_SCHEMA,
17
- constraints: z.array(CONSTRAINT_SCHEMA),
18
17
  examples: z.array(EXAMPLE_SCHEMA),
19
18
  default_notes: z.record(z.string(), z.string()),
19
+ };
20
+ // help は --help に出す英語の文。日本語で書いた定義書では、同じ名前の 3 つの欄の代わりに読む
21
+ const ENTRY_SCHEMA = z.object({
22
+ ...PROSE_SHAPE,
23
+ constraints: z.array(CONSTRAINT_SCHEMA),
24
+ help: z.object(PROSE_SHAPE).optional(),
20
25
  });
21
26
  /**
22
27
  authored.yaml の置き場所。pluginRoot() の下の interface/
@@ -31,7 +36,7 @@ function isMissingFile(error) {
31
36
  return error instanceof Error && 'code' in error && error.code === 'ENOENT';
32
37
  }
33
38
  /**
34
- ID(`PW-CREATE-BRANCH`)の項目の details・constraints・examples・default_notes を読む。
39
+ ID(`PW-SESSION-START`)の項目の details・constraints・examples・default_notes を読む。
35
40
  ファイルが無い・YAML として読めない・項目が無い・欄の形が違うときは、場所と理由を持つ unreadable を返す
36
41
  */
37
42
  export function readAuthoredNotes(id, root = pluginRoot()) {
@@ -60,7 +65,8 @@ export function readAuthoredNotes(id, root = pluginRoot()) {
60
65
  const parsed = ENTRY_SCHEMA.safeParse(entry);
61
66
  if (!parsed.success)
62
67
  return unreadable(file, `the fields of ${id} have the wrong shape`);
63
- const { details, constraints, examples, default_notes: defaultNotes } = parsed.data;
68
+ const { constraints } = parsed.data;
69
+ const { details, examples, default_notes: defaultNotes } = parsed.data.help ?? parsed.data;
64
70
  return { kind: 'read', notes: { details, constraints, examples, defaultNotes: new Map(Object.entries(defaultNotes)) } };
65
71
  }
66
72
  //# sourceMappingURL=authored-notes.js.map