@pecot/workflow-mcp 0.0.0-stage → 5.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.
- package/.claude-plugin/plugin.json +8 -0
- package/LICENSE +21 -0
- package/README.md +126 -2
- package/bin/pecot-workflow-mcp.mjs +10 -0
- package/cli/dist/cli.d.ts +26 -0
- package/cli/dist/cli.js +222 -0
- package/cli/dist/commands/cell-table.d.ts +3 -0
- package/cli/dist/commands/cell-table.js +495 -0
- package/cli/dist/commands/command-binding.d.ts +26 -0
- package/cli/dist/commands/command-binding.js +266 -0
- package/cli/dist/commands/command-definition.d.ts +136 -0
- package/cli/dist/commands/command-definition.js +101 -0
- package/cli/dist/commands/command-help.d.ts +8 -0
- package/cli/dist/commands/command-help.js +173 -0
- package/cli/dist/commands/command-stop.d.ts +19 -0
- package/cli/dist/commands/command-stop.js +30 -0
- package/cli/dist/commands/dependabot.d.ts +3 -0
- package/cli/dist/commands/dependabot.js +165 -0
- package/cli/dist/commands/directory-option.d.ts +7 -0
- package/cli/dist/commands/directory-option.js +48 -0
- package/cli/dist/commands/failure.d.ts +13 -0
- package/cli/dist/commands/failure.js +33 -0
- package/cli/dist/commands/fuzzy.d.ts +7 -0
- package/cli/dist/commands/fuzzy.js +79 -0
- package/cli/dist/commands/github-client.d.ts +12 -0
- package/cli/dist/commands/github-client.js +23 -0
- package/cli/dist/commands/global-options.d.ts +25 -0
- package/cli/dist/commands/global-options.js +83 -0
- package/cli/dist/commands/help-layout.d.ts +40 -0
- package/cli/dist/commands/help-layout.js +117 -0
- package/cli/dist/commands/help.d.ts +8 -0
- package/cli/dist/commands/help.js +55 -0
- package/cli/dist/commands/input-schema.d.ts +14 -0
- package/cli/dist/commands/input-schema.js +56 -0
- package/cli/dist/commands/issue-board.d.ts +38 -0
- package/cli/dist/commands/issue-board.js +62 -0
- package/cli/dist/commands/issue-comment.d.ts +3 -0
- package/cli/dist/commands/issue-comment.js +196 -0
- package/cli/dist/commands/issue-create.d.ts +3 -0
- package/cli/dist/commands/issue-create.js +329 -0
- package/cli/dist/commands/issue-project.d.ts +3 -0
- package/cli/dist/commands/issue-project.js +176 -0
- package/cli/dist/commands/issue-quick.d.ts +3 -0
- package/cli/dist/commands/issue-quick.js +126 -0
- package/cli/dist/commands/issue-read.d.ts +3 -0
- package/cli/dist/commands/issue-read.js +80 -0
- package/cli/dist/commands/issue-shared.d.ts +159 -0
- package/cli/dist/commands/issue-shared.js +419 -0
- package/cli/dist/commands/issue.d.ts +4 -0
- package/cli/dist/commands/issue.js +15 -0
- package/cli/dist/commands/names.d.ts +9 -0
- package/cli/dist/commands/names.js +16 -0
- package/cli/dist/commands/output.d.ts +78 -0
- package/cli/dist/commands/output.js +187 -0
- package/cli/dist/commands/pr.d.ts +3 -0
- package/cli/dist/commands/pr.js +933 -0
- package/cli/dist/commands/project-info.d.ts +48 -0
- package/cli/dist/commands/project-info.js +181 -0
- package/cli/dist/commands/project-sync.d.ts +91 -0
- package/cli/dist/commands/project-sync.js +273 -0
- package/cli/dist/commands/project.d.ts +5 -0
- package/cli/dist/commands/project.js +677 -0
- package/cli/dist/commands/registry.d.ts +6 -0
- package/cli/dist/commands/registry.js +27 -0
- package/cli/dist/commands/release.d.ts +10 -0
- package/cli/dist/commands/release.js +414 -0
- package/cli/dist/commands/repository-display.d.ts +3 -0
- package/cli/dist/commands/repository-display.js +7 -0
- package/cli/dist/commands/repository-match.d.ts +14 -0
- package/cli/dist/commands/repository-match.js +33 -0
- package/cli/dist/commands/repository.d.ts +5 -0
- package/cli/dist/commands/repository.js +265 -0
- package/cli/dist/commands/rich-panel.d.ts +22 -0
- package/cli/dist/commands/rich-panel.js +295 -0
- package/cli/dist/commands/security.d.ts +3 -0
- package/cli/dist/commands/security.js +164 -0
- package/cli/dist/commands/session.d.ts +3 -0
- package/cli/dist/commands/session.js +161 -0
- package/cli/dist/commands/tracker-sync.d.ts +58 -0
- package/cli/dist/commands/tracker-sync.js +53 -0
- package/cli/dist/commands/usage-error.d.ts +47 -0
- package/cli/dist/commands/usage-error.js +72 -0
- package/cli/dist/commands/value-types.d.ts +46 -0
- package/cli/dist/commands/value-types.js +94 -0
- package/cli/dist/commands/work-target.d.ts +13 -0
- package/cli/dist/commands/work-target.js +41 -0
- package/cli/dist/commands/worktree.d.ts +3 -0
- package/cli/dist/commands/worktree.js +335 -0
- package/cli/dist/domain/api-error-detail.d.ts +10 -0
- package/cli/dist/domain/api-error-detail.js +25 -0
- package/cli/dist/domain/branch-name.d.ts +5 -0
- package/cli/dist/domain/branch-name.js +10 -0
- package/cli/dist/domain/changelog.d.ts +43 -0
- package/cli/dist/domain/changelog.js +107 -0
- package/cli/dist/domain/config.d.ts +215 -0
- package/cli/dist/domain/config.js +300 -0
- package/cli/dist/domain/dependabot-pull-requests.d.ts +82 -0
- package/cli/dist/domain/dependabot-pull-requests.js +338 -0
- package/cli/dist/domain/dependabot-source.d.ts +51 -0
- package/cli/dist/domain/dependabot-source.js +4 -0
- package/cli/dist/domain/dependabot.d.ts +47 -0
- package/cli/dist/domain/dependabot.js +88 -0
- package/cli/dist/domain/errors.d.ts +19 -0
- package/cli/dist/domain/errors.js +31 -0
- package/cli/dist/domain/field-options.d.ts +31 -0
- package/cli/dist/domain/field-options.js +44 -0
- package/cli/dist/domain/format.d.ts +47 -0
- package/cli/dist/domain/format.js +168 -0
- package/cli/dist/domain/frontmatter.d.ts +122 -0
- package/cli/dist/domain/frontmatter.js +264 -0
- package/cli/dist/domain/git-runner.d.ts +10 -0
- package/cli/dist/domain/git-runner.js +4 -0
- package/cli/dist/domain/git-url.d.ts +17 -0
- package/cli/dist/domain/git-url.js +30 -0
- package/cli/dist/domain/issue-kind.d.ts +16 -0
- package/cli/dist/domain/issue-kind.js +16 -0
- package/cli/dist/domain/issue-readout.d.ts +107 -0
- package/cli/dist/domain/issue-readout.js +4 -0
- package/cli/dist/domain/json-null.d.ts +2 -0
- package/cli/dist/domain/json-null.js +5 -0
- package/cli/dist/domain/json.d.ts +21 -0
- package/cli/dist/domain/json.js +47 -0
- package/cli/dist/domain/prerequisites.d.ts +32 -0
- package/cli/dist/domain/prerequisites.js +192 -0
- package/cli/dist/domain/pull-request.d.ts +134 -0
- package/cli/dist/domain/pull-request.js +232 -0
- package/cli/dist/domain/python-format.d.ts +105 -0
- package/cli/dist/domain/python-format.js +304 -0
- package/cli/dist/domain/readiness.d.ts +172 -0
- package/cli/dist/domain/readiness.js +280 -0
- package/cli/dist/domain/reference-parser.d.ts +49 -0
- package/cli/dist/domain/reference-parser.js +119 -0
- package/cli/dist/domain/release.d.ts +49 -0
- package/cli/dist/domain/release.js +72 -0
- package/cli/dist/domain/repository-policy.d.ts +32 -0
- package/cli/dist/domain/repository-policy.js +65 -0
- package/cli/dist/domain/repository-resolver.d.ts +57 -0
- package/cli/dist/domain/repository-resolver.js +119 -0
- package/cli/dist/domain/sections.d.ts +69 -0
- package/cli/dist/domain/sections.js +514 -0
- package/cli/dist/domain/security-alerts-source.d.ts +29 -0
- package/cli/dist/domain/security-alerts-source.js +4 -0
- package/cli/dist/domain/security-alerts.d.ts +52 -0
- package/cli/dist/domain/security-alerts.js +107 -0
- package/cli/dist/domain/security-tracker.d.ts +115 -0
- package/cli/dist/domain/security-tracker.js +353 -0
- package/cli/dist/domain/state.d.ts +29 -0
- package/cli/dist/domain/state.js +56 -0
- package/cli/dist/domain/tracker-body.d.ts +70 -0
- package/cli/dist/domain/tracker-body.js +65 -0
- package/cli/dist/domain/yaml-document.d.ts +5 -0
- package/cli/dist/domain/yaml-document.js +206 -0
- package/cli/dist/infra/authored-notes.d.ts +37 -0
- package/cli/dist/infra/authored-notes.js +66 -0
- package/cli/dist/infra/changelog-file.d.ts +19 -0
- package/cli/dist/infra/changelog-file.js +43 -0
- package/cli/dist/infra/child-stdin.d.ts +4 -0
- package/cli/dist/infra/child-stdin.js +8 -0
- package/cli/dist/infra/config-store.d.ts +49 -0
- package/cli/dist/infra/config-store.js +121 -0
- package/cli/dist/infra/diagnostics.d.ts +9 -0
- package/cli/dist/infra/diagnostics.js +2 -0
- package/cli/dist/infra/file-kind.d.ts +9 -0
- package/cli/dist/infra/file-kind.js +26 -0
- package/cli/dist/infra/frontmatter-file.d.ts +14 -0
- package/cli/dist/infra/frontmatter-file.js +30 -0
- package/cli/dist/infra/git.d.ts +74 -0
- package/cli/dist/infra/git.js +133 -0
- package/cli/dist/infra/github/auth.d.ts +60 -0
- package/cli/dist/infra/github/auth.js +158 -0
- package/cli/dist/infra/github/client.d.ts +173 -0
- package/cli/dist/infra/github/client.js +576 -0
- package/cli/dist/infra/github/dependabot-source.d.ts +13 -0
- package/cli/dist/infra/github/dependabot-source.js +33 -0
- package/cli/dist/infra/github/errors.d.ts +47 -0
- package/cli/dist/infra/github/errors.js +42 -0
- package/cli/dist/infra/github/index.d.ts +13 -0
- package/cli/dist/infra/github/index.js +19 -0
- package/cli/dist/infra/github/issues.d.ts +129 -0
- package/cli/dist/infra/github/issues.js +273 -0
- package/cli/dist/infra/github/payload.d.ts +44 -0
- package/cli/dist/infra/github/payload.js +80 -0
- package/cli/dist/infra/github/projects.d.ts +108 -0
- package/cli/dist/infra/github/projects.js +303 -0
- package/cli/dist/infra/github/pulls.d.ts +80 -0
- package/cli/dist/infra/github/pulls.js +161 -0
- package/cli/dist/infra/github/queries.d.ts +36 -0
- package/cli/dist/infra/github/queries.js +883 -0
- package/cli/dist/infra/github/readout.d.ts +18 -0
- package/cli/dist/infra/github/readout.js +156 -0
- package/cli/dist/infra/github/repos.d.ts +68 -0
- package/cli/dist/infra/github/repos.js +137 -0
- package/cli/dist/infra/github/rest-path.d.ts +14 -0
- package/cli/dist/infra/github/rest-path.js +31 -0
- package/cli/dist/infra/github/security-alerts-source.d.ts +15 -0
- package/cli/dist/infra/github/security-alerts-source.js +73 -0
- package/cli/dist/infra/gitignore-spec.d.ts +36 -0
- package/cli/dist/infra/gitignore-spec.js +235 -0
- package/cli/dist/infra/nx-scope.d.ts +51 -0
- package/cli/dist/infra/nx-scope.js +182 -0
- package/cli/dist/infra/os-error.d.ts +24 -0
- package/cli/dist/infra/os-error.js +38 -0
- package/cli/dist/infra/paths.d.ts +88 -0
- package/cli/dist/infra/paths.js +234 -0
- package/cli/dist/infra/state-store.d.ts +45 -0
- package/cli/dist/infra/state-store.js +118 -0
- package/cli/dist/infra/template-store.d.ts +15 -0
- package/cli/dist/infra/template-store.js +34 -0
- package/cli/dist/infra/text-file.d.ts +12 -0
- package/cli/dist/infra/text-file.js +33 -0
- package/cli/dist/infra/worktree-copy.d.ts +24 -0
- package/cli/dist/infra/worktree-copy.js +95 -0
- package/cli/dist/infra/worktree-links.d.ts +139 -0
- package/cli/dist/infra/worktree-links.js +433 -0
- package/cli/dist/infra/worktree-setup.d.ts +21 -0
- package/cli/dist/infra/worktree-setup.js +41 -0
- package/cli/dist/infra/worktree.d.ts +174 -0
- package/cli/dist/infra/worktree.js +567 -0
- package/cli/dist/mcp/result.d.ts +33 -0
- package/cli/dist/mcp/result.js +52 -0
- package/cli/dist/mcp/serve.d.ts +51 -0
- package/cli/dist/mcp/serve.js +183 -0
- package/cli/dist/mcp/server.d.ts +21 -0
- package/cli/dist/mcp/server.js +128 -0
- package/cli/dist/mcp/session-directory.d.ts +26 -0
- package/cli/dist/mcp/session-directory.js +84 -0
- package/cli/dist/package.json +1 -0
- package/cli/dist/version.d.ts +17 -0
- package/cli/dist/version.js +42 -0
- package/cli/templates/comment/merge-diff.md +34 -0
- package/cli/templates/comment/plan.md +181 -0
- package/cli/templates/comment/precede-notify.md +33 -0
- package/cli/templates/comment/review-findings.md +42 -0
- package/cli/templates/comment/review-resolution.md +48 -0
- package/cli/templates/issue/bug.md +63 -0
- package/cli/templates/issue/epic.md +54 -0
- package/cli/templates/issue/task-implement.md +67 -0
- package/cli/templates/issue/task.md +48 -0
- package/cli/templates/issue/tracker.md +48 -0
- package/cli/templates/pr/create.md +123 -0
- package/cli/templates/pr/release.md +56 -0
- package/hooks/lib/core/pecot-gitignore-ensure.sh +48 -0
- package/npm-shrinkwrap.json +83 -0
- package/package.json +22 -4
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- 引数の型は readonly にできない */
|
|
2
|
+
// issue 系のコマンドが共有する関数と定数。cli/commands/issue.py の移植。
|
|
3
|
+
// typer.Exit(n) に当たるのは、error の行を出して止める stopWith(output, 文, n)。
|
|
4
|
+
// 行を別の関数が先に出した後は、throw new CommandExit(n) で止める。
|
|
5
|
+
// BadParameter は、run の本体を包む runWithExit が受ける。
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { aggregationRepositoryReference, isRepositoryInProject } from '../domain/config.js';
|
|
9
|
+
import { BaseError } from '../domain/errors.js';
|
|
10
|
+
import { CommandExit } from './command-definition.js';
|
|
11
|
+
import { pythonStrip } from '../domain/python-format.js';
|
|
12
|
+
import { issueReferenceToCliReference, parseIssueReference, ReferenceParseError } from '../domain/reference-parser.js';
|
|
13
|
+
import { AmbiguousRepositoryError, createRepositoryReference, resolveRepository } from '../domain/repository-resolver.js';
|
|
14
|
+
import { CLOSED_HEADINGS_BY_TEMPLATE, FOLD_SUMMARY_BY_TEMPLATE, validateBodyStyle, validateClosedHeadings, validateFoldBalance, validateFoldSummaries, validateHeadingSummaries, validateSections, } from '../domain/sections.js';
|
|
15
|
+
import { gitRunnerFor } from '../infra/git.js';
|
|
16
|
+
import { GitHubAPIError } from '../infra/github/errors.js';
|
|
17
|
+
import { requireNumber, requireString } from '../infra/github/payload.js';
|
|
18
|
+
import { readTemplateSections, templateFile } from '../infra/template-store.js';
|
|
19
|
+
import { stopWith } from './command-stop.js';
|
|
20
|
+
import { createGitHubClient } from './github-client.js';
|
|
21
|
+
import { addIssueToBoard, createIssue, setIssueField } from './issue-board.js';
|
|
22
|
+
import { USAGE_EXIT_CODE, UsageError } from './usage-error.js';
|
|
23
|
+
/**
|
|
24
|
+
issue comment のテンプレ検証失敗の終了コード。通信失敗・設定なし・引数不足の 1 と区別し、hooks がこの値で分岐する
|
|
25
|
+
*/
|
|
26
|
+
export const COMMENT_VALIDATION_EXIT_CODE = 3;
|
|
27
|
+
/**
|
|
28
|
+
Issue 種別の入力。issue create と issue quick が共有する
|
|
29
|
+
*/
|
|
30
|
+
export const ISSUE_TYPE_SCHEMA = z.enum(['task', 'bug', 'epic', 'tracker']).default('task').describe('Issue type (task/bug/epic/tracker)');
|
|
31
|
+
export const PARENT_EPIC_DESCRIPTION = 'Parent Epic reference: an integer (relative to aggregation_repo) or the primary form \'owner/repo/N\'';
|
|
32
|
+
export const ISSUE_REF_DESCRIPTION = 'Issue reference (`owner/repo/N`, or the short form `N` in the repository of `--repo`, or else of the git remote of the current directory)';
|
|
33
|
+
export const VALID_STATUSES = new Set(['backlog', 'pending', 'blocked', 'ready', 'active', 'in_review', 'archived']);
|
|
34
|
+
/**
|
|
35
|
+
Issue 種別 → タイトルの接頭辞
|
|
36
|
+
*/
|
|
37
|
+
const TYPE_PREFIX_MAP = new Map([
|
|
38
|
+
['task', '[Task]'],
|
|
39
|
+
['bug', '[Bug]'],
|
|
40
|
+
['epic', '[Epic]'],
|
|
41
|
+
['tracker', '[Tracker]'],
|
|
42
|
+
]);
|
|
43
|
+
/**
|
|
44
|
+
起票時の status は、型対応テンプレートの既定値だけを受ける。pending / archived への配置はボード上の手動操作
|
|
45
|
+
*/
|
|
46
|
+
export const TYPE_DEFAULT_STATUS = { epic: 'backlog', tracker: 'backlog', task: 'ready', bug: 'ready' };
|
|
47
|
+
/**
|
|
48
|
+
Backlog に置く型(quick の status / size / quick フラグの扱いが Epic と同じ)
|
|
49
|
+
*/
|
|
50
|
+
export const BACKLOG_TYPES = new Set(['epic', 'tracker']);
|
|
51
|
+
// --- 終了の表し方 ---
|
|
52
|
+
/**
|
|
53
|
+
引数の値が不正。Python の typer.BadParameter。呼ぶ側が受けない場合は、runWithExit が使い方の誤り(終了コード 2)にする
|
|
54
|
+
*/
|
|
55
|
+
class BadParameterError extends BaseError {
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
run の本体を包む。終わったら 0 を返す。BadParameterError は使い方の誤りにして伝える。
|
|
59
|
+
それ以外の例外はそのまま伝える。CommandExit は defineCommand が受けて終了コードにする
|
|
60
|
+
*/
|
|
61
|
+
export async function runWithExit(body) {
|
|
62
|
+
try {
|
|
63
|
+
await body();
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof BadParameterError)
|
|
68
|
+
throw new UsageError(`Invalid value: ${error.message}`);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// --- Issue 参照 ---
|
|
73
|
+
/**
|
|
74
|
+
`owner/repo/N` の表記。エラー文と done の行の対象に使う
|
|
75
|
+
*/
|
|
76
|
+
export function issuePath(owner, repository, number) {
|
|
77
|
+
return `${owner}/${repository}/${String(number)}`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
グローバルの --repo(run の入力の repo)か、カレントの git から base のリポジトリを決める。
|
|
81
|
+
曖昧なら undefined(`owner/repo/N` の主軸形を使う利用者のため)。--repo の形式が不正なら InvalidValueError を伝える
|
|
82
|
+
*/
|
|
83
|
+
function resolveBaseRepository(repository) {
|
|
84
|
+
try {
|
|
85
|
+
return resolveRepository(repository, gitRunnerFor()).repository;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error instanceof AmbiguousRepositoryError)
|
|
89
|
+
return undefined;
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
Issue 参照(`owner/repo/N` または短縮形 `N`)を分ける。不正、または base が決まらない短縮形なら BadParameterError
|
|
95
|
+
*/
|
|
96
|
+
function parseIssueReferenceFromContext(repository, raw) {
|
|
97
|
+
const base = resolveBaseRepository(repository);
|
|
98
|
+
try {
|
|
99
|
+
const reference = parseIssueReference(raw, base, { repositoryFlag: true });
|
|
100
|
+
return { owner: reference.repository.owner, repository: reference.repository.repository, number: reference.number };
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (error instanceof ReferenceParseError)
|
|
104
|
+
throw new BadParameterError(error.message);
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
parseIssueReferenceFromContext の失敗を、error の行と終了コード 2 にしたもの
|
|
110
|
+
*/
|
|
111
|
+
export function parseIssueReferenceOrExit(output, repository, raw) {
|
|
112
|
+
try {
|
|
113
|
+
return parseIssueReferenceFromContext(repository, raw);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
if (!(error instanceof BadParameterError))
|
|
117
|
+
throw error;
|
|
118
|
+
return stopWith(output, error.message, USAGE_EXIT_CODE);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// --- status ---
|
|
122
|
+
/**
|
|
123
|
+
不正な status と、有効な値を出して終了コード 1
|
|
124
|
+
*/
|
|
125
|
+
export function exitInvalidStatus(output, status) {
|
|
126
|
+
return stopWith(output, `invalid status: ${status}\nvalid values: backlog/pending/blocked/ready/active/in_review/archived`);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
起票時の status が、型対応テンプレートの既定値と一致するか確かめる。違えば終了コード 1。
|
|
130
|
+
enum 外の値(`--status foo`)と、型に合わない別テンプレートの既定値(`--type bug --status backlog`)は文を分ける
|
|
131
|
+
*/
|
|
132
|
+
export function validateStatusForType(output, issueType, status) {
|
|
133
|
+
if (!VALID_STATUSES.has(status))
|
|
134
|
+
exitInvalidStatus(output, status);
|
|
135
|
+
// eslint-disable-next-line security/detect-object-injection -- issueType は列挙型
|
|
136
|
+
const expected = TYPE_DEFAULT_STATUS[issueType];
|
|
137
|
+
if (status === expected)
|
|
138
|
+
return;
|
|
139
|
+
stopWith(output, `the status at creation for type '${issueType}' is only '${expected}' (given: ${status})\nhint: move it to pending or another status on the board after creation`);
|
|
140
|
+
}
|
|
141
|
+
// --- parent_epic・タイトル・order ---
|
|
142
|
+
/**
|
|
143
|
+
CLI のオプションで来た parent_epic。空・空白だけなら undefined、数字だけなら整数(安全な整数を超えるなら数字の文字列)、それ以外は文字列
|
|
144
|
+
*/
|
|
145
|
+
export function normalizeParentEpicCli(raw) {
|
|
146
|
+
if (raw === undefined)
|
|
147
|
+
return undefined;
|
|
148
|
+
const stripped = pythonStrip(raw);
|
|
149
|
+
if (stripped === '')
|
|
150
|
+
return undefined;
|
|
151
|
+
if (!/^\d+$/u.test(stripped))
|
|
152
|
+
return stripped;
|
|
153
|
+
const value = Number(stripped);
|
|
154
|
+
// 安全な整数に収まらない数字は、丸めずに文字列のまま返す(先頭の 0 は Python の int() と同じく落とす)
|
|
155
|
+
return Number.isSafeInteger(value) ? value : stripped.replace(/^0+(?=\d)/u, '');
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
parent_epic を Issue 参照にする。整数は aggregation_repo の Issue(未設定なら task のリポジトリ)、`owner/repo/N` はそのまま。
|
|
159
|
+
解決できなければ BadParameterError。番号が安全な整数を超える参照は、丸めずに解決できない参照として扱う
|
|
160
|
+
*/
|
|
161
|
+
export function resolveParentEpicReference(raw, config, taskOwner, taskRepository) {
|
|
162
|
+
const base = aggregationRepositoryReference(config) ?? createRepositoryReference(taskOwner, taskRepository);
|
|
163
|
+
try {
|
|
164
|
+
if (typeof raw === 'string' && /^\d+$/u.test(raw) && !Number.isSafeInteger(Number(raw))) {
|
|
165
|
+
throw new ReferenceParseError(`the number is too large: ${raw}`, raw);
|
|
166
|
+
}
|
|
167
|
+
return parseIssueReference(String(raw), base);
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
if (!(error instanceof ReferenceParseError))
|
|
171
|
+
throw error;
|
|
172
|
+
throw new BadParameterError(`could not resolve parent_epic: ${error.message}\naccepted forms: an integer (Issue number in aggregation_repo) or the primary form 'owner/repo/N'`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
Epic を作るリポジトリを、aggregation_repo の方針で決める。
|
|
177
|
+
repository が空で aggregation_repo も未設定なら、決められないので終了コード 2
|
|
178
|
+
*/
|
|
179
|
+
export function resolveEpicTargetRepository(output, repository, config) {
|
|
180
|
+
const stripped = repository === undefined ? '' : pythonStrip(repository);
|
|
181
|
+
const explicit = stripped === '' ? undefined : stripped;
|
|
182
|
+
const aggregation = config.aggregation_repo;
|
|
183
|
+
if (explicit === undefined) {
|
|
184
|
+
if (aggregation === undefined) {
|
|
185
|
+
stopWith(output, 'cannot decide where to create the Epic\ndeclare aggregation_repo in the project config, or pass --repo', USAGE_EXIT_CODE);
|
|
186
|
+
}
|
|
187
|
+
return { repository: aggregation, needsWarning: false };
|
|
188
|
+
}
|
|
189
|
+
return { repository: explicit, needsWarning: aggregation !== undefined && explicit !== aggregation };
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
Epic の作成先が aggregation_repo と違うときの警告
|
|
193
|
+
*/
|
|
194
|
+
export function warnEpicRepositoryException(output, resolvedRepository, config) {
|
|
195
|
+
output.warning(`--repo ${resolvedRepository} differs from aggregation_repo (${String(config.aggregation_repo)})\ncontinuing as an exception for an Epic in an implementation repo`);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
タイトルに接頭辞と、Epic 番号・order(・枝の文字)を付ける。例は `[Task] #353-04a: タイトル`
|
|
199
|
+
*/
|
|
200
|
+
export function buildIssueTitle(issueType, title, options = {}) {
|
|
201
|
+
const prefix = TYPE_PREFIX_MAP.get(issueType) ?? '';
|
|
202
|
+
const hasPrefix = prefix !== '' && title.startsWith(prefix);
|
|
203
|
+
const baseTitle = hasPrefix ? pythonStrip(title.slice(prefix.length)) : title;
|
|
204
|
+
if (options.parentEpic !== undefined && options.order !== undefined) {
|
|
205
|
+
const number = `#${String(options.parentEpic)}-${orderLabel(options.order, options.parallel)}`;
|
|
206
|
+
return prefix === '' ? `${number}: ${baseTitle}` : `${prefix} ${number}: ${baseTitle}`;
|
|
207
|
+
}
|
|
208
|
+
return prefix === '' || hasPrefix ? title : `${prefix} ${title}`;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
エラー文に出す番号。2 桁の order に、枝の文字を続ける
|
|
212
|
+
*/
|
|
213
|
+
function orderLabel(order, parallel = '') {
|
|
214
|
+
return `${String(order).padStart(2, '0')}${parallel}`;
|
|
215
|
+
}
|
|
216
|
+
// タイトルの `#123-01:` と `#123-01a:` から、Epic 番号・段・枝を取る
|
|
217
|
+
const ORDER_PATTERN = /#(\d+)-(\d+)([a-z])?:/u;
|
|
218
|
+
const LOWERCASE_LETTERS = Array.from({ length: 26 }, (_, index) => String.fromCodePoint(97 + index));
|
|
219
|
+
function usedOrdersOf(subIssues, parentEpic) {
|
|
220
|
+
const orders = [];
|
|
221
|
+
const values = [];
|
|
222
|
+
for (const sub of subIssues) {
|
|
223
|
+
const [, epic, stage, letter] = ORDER_PATTERN.exec(sub.title) ?? [];
|
|
224
|
+
if (epic === undefined || stage === undefined || Number(epic) !== parentEpic)
|
|
225
|
+
continue;
|
|
226
|
+
values.push(Number(stage));
|
|
227
|
+
orders.push({ ...sub, stage: Number(stage), parallel: letter });
|
|
228
|
+
}
|
|
229
|
+
return { orders, values };
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
同じ Epic に、同じ(段, 枝の文字)の Issue が無いことを確かめる。OPEN でも CLOSED でも、一度使った番号は再利用できない。
|
|
233
|
+
同じ段では、枝ありと枝なしも重複。最初の一致を error にして終了コード 1。Epic を取れなければ warning だけで続ける
|
|
234
|
+
*/
|
|
235
|
+
export async function checkDuplicateOrder(output, client, owner, repository, parentEpic, order, parallel) {
|
|
236
|
+
let subIssues;
|
|
237
|
+
try {
|
|
238
|
+
const slim = await client.getIssueSlim(owner, repository, parentEpic, 0);
|
|
239
|
+
subIssues = slim.sub_issues;
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
if (!(error instanceof GitHubAPIError))
|
|
243
|
+
throw error;
|
|
244
|
+
output.warning(`could not fetch the parent Epic #${String(parentEpic)}: ${error.message}`);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const used = usedOrdersOf(subIssues, parentEpic);
|
|
248
|
+
const sameOrder = used.orders.filter(sub => sub.stage === order);
|
|
249
|
+
const duplicate = sameOrder.find(sub => sub.parallel === undefined || parallel === undefined || sub.parallel === parallel);
|
|
250
|
+
if (duplicate === undefined)
|
|
251
|
+
return;
|
|
252
|
+
const usedValues = new Set(used.values);
|
|
253
|
+
let nextOrder = 1;
|
|
254
|
+
while (usedValues.has(nextOrder))
|
|
255
|
+
nextOrder += 1;
|
|
256
|
+
let conflict;
|
|
257
|
+
let suggestion;
|
|
258
|
+
if (parallel === undefined && duplicate.parallel === undefined) {
|
|
259
|
+
conflict = `an Issue with order=${String(order)}`;
|
|
260
|
+
suggestion = `next available order: ${String(nextOrder)}`;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
const usedLetters = new Set(sameOrder.map(sub => sub.parallel));
|
|
264
|
+
const letter = LOWERCASE_LETTERS.find(candidate => !usedLetters.has(candidate));
|
|
265
|
+
suggestion = letter === undefined || usedLetters.has(undefined)
|
|
266
|
+
? `next available order: ${String(Math.max(...usedValues) + 1)}`
|
|
267
|
+
: `next available number: ${orderLabel(order, letter)}`;
|
|
268
|
+
conflict = `an Issue (${orderLabel(order, duplicate.parallel)}) that conflicts with order=${orderLabel(order, parallel)}`;
|
|
269
|
+
}
|
|
270
|
+
const stateLabel = duplicate.state === 'OPEN' ? 'OPEN' : 'CLOSED';
|
|
271
|
+
stopWith(output, `Epic #${String(parentEpic)} already has ${conflict} (${stateLabel})\n#${String(duplicate.number)} ${duplicate.title}\n${suggestion}`);
|
|
272
|
+
}
|
|
273
|
+
// --- Issue の作成・ボード・親 Epic ---
|
|
274
|
+
/**
|
|
275
|
+
Issue を作り、`created:` の行を出して API の応答を返す。失敗は error の行と終了コード 1。
|
|
276
|
+
source は作成元のファイル名(`from <source>` として行の末尾に付く)
|
|
277
|
+
*/
|
|
278
|
+
export async function createIssueOrExit(output, client, owner, repository, title, body, labels, source) {
|
|
279
|
+
let issue;
|
|
280
|
+
try {
|
|
281
|
+
issue = await createIssue(client, owner, repository, title, body, labels);
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
if (!(error instanceof GitHubAPIError))
|
|
285
|
+
throw error;
|
|
286
|
+
return stopWith(output, `could not create an Issue in ${owner}/${repository}: ${error.message}`);
|
|
287
|
+
}
|
|
288
|
+
const target = `Issue ${issuePath(owner, repository, requireNumber(issue['number'], 'number'))}`;
|
|
289
|
+
output.done({ verb: 'create', target: source === undefined || source === '' ? target : `${target} from ${source}` });
|
|
290
|
+
return issue;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
Issue の作成の応答から、番号・URL・node id を取る
|
|
294
|
+
*/
|
|
295
|
+
export function summarizeCreatedIssue(issue) {
|
|
296
|
+
const nodeId = issue['node_id'];
|
|
297
|
+
return {
|
|
298
|
+
number: requireNumber(issue['number'], 'number'),
|
|
299
|
+
url: requireString(issue['html_url'], 'html_url'),
|
|
300
|
+
nodeId: typeof nodeId === 'string' ? nodeId : undefined,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
Issue をボードへ追加する。失敗は warning と Issue の URL を出して undefined
|
|
305
|
+
*/
|
|
306
|
+
export async function addToBoardOrWarn(output, client, config, owner, repository, issueNumber, issueNodeId, issueUrl) {
|
|
307
|
+
let added;
|
|
308
|
+
try {
|
|
309
|
+
added = await addIssueToBoard(client, config, owner, repository, issueNumber, issueNodeId);
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
if (!(error instanceof GitHubAPIError))
|
|
313
|
+
throw error;
|
|
314
|
+
output.warning(`could not add Issue ${issuePath(owner, repository, issueNumber)} to project: ${error.message}`);
|
|
315
|
+
output.data(issueUrl);
|
|
316
|
+
return undefined;
|
|
317
|
+
}
|
|
318
|
+
output.done({ verb: 'add', target: `Issue ${issuePath(owner, repository, issueNumber)} to project` });
|
|
319
|
+
return added;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
カスタムフィールドを順に設定し、設定できた分を 1 行の set にする。失敗したフィールドは、何も出さずに飛ばす
|
|
323
|
+
*/
|
|
324
|
+
export async function setIssueFields(output, client, config, itemId, target, fields) {
|
|
325
|
+
const labels = [];
|
|
326
|
+
for (const { fieldName, optionName, label } of fields) {
|
|
327
|
+
try {
|
|
328
|
+
if (await setIssueField(client, config, itemId, fieldName, optionName))
|
|
329
|
+
labels.push(label);
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
if (!(error instanceof GitHubAPIError))
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (labels.length > 0)
|
|
337
|
+
output.done({ verb: 'set', target: `${target} ${labels.join(', ')}` });
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
親 Epic のサブ Issue にする。失敗は Issue の URL、error の行の順に出して終了コード 1
|
|
341
|
+
*/
|
|
342
|
+
export async function linkToParentEpic(output, client, target, parentReference, issueNodeId, issueUrl) {
|
|
343
|
+
const parent = issueReferenceToCliReference(parentReference);
|
|
344
|
+
try {
|
|
345
|
+
const parentNodeId = await client.getIssueNodeId(parentReference.repository.owner, parentReference.repository.repository, parentReference.number);
|
|
346
|
+
await client.addSubIssue(parentNodeId, issueNodeId);
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
if (!(error instanceof GitHubAPIError))
|
|
350
|
+
throw error;
|
|
351
|
+
output.data(issueUrl);
|
|
352
|
+
stopWith(output, `could not add ${target} as sub-issue of ${parent}: ${error.message}`);
|
|
353
|
+
}
|
|
354
|
+
output.done({ verb: 'add', target: `${target} as sub-issue of ${parent}` });
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
リポジトリがプロジェクトにリンクされていなければ、message を error に出して終了コード 1
|
|
358
|
+
*/
|
|
359
|
+
export async function ensureRepositoryInProject(output, config, client, owner, repository, message) {
|
|
360
|
+
if (await isRepositoryInProject(config, owner, repository, client))
|
|
361
|
+
return;
|
|
362
|
+
stopWith(output, message);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
起票用のクライアントを作り、リポジトリのリンクと、親 Epic のリポジトリでの order の重複を確かめる
|
|
366
|
+
*/
|
|
367
|
+
export async function clientForIssueCreate(output, config, owner, repository, display, parentReference, order, parallel) {
|
|
368
|
+
const client = createGitHubClient(output, config.host);
|
|
369
|
+
await ensureRepositoryInProject(output, config, client, owner, repository, `${display} is not linked to the project`);
|
|
370
|
+
if (parentReference !== undefined && order !== undefined) {
|
|
371
|
+
await checkDuplicateOrder(output, client, parentReference.repository.owner, parentReference.repository.repository, parentReference.number, order, parallel);
|
|
372
|
+
}
|
|
373
|
+
return client;
|
|
374
|
+
}
|
|
375
|
+
// --- テンプレートの検証 ---
|
|
376
|
+
/**
|
|
377
|
+
本文をテンプレートと比べ、違反を 1 つの error にして出す。違反があれば true。
|
|
378
|
+
1 行目はテンプレートのパス。続く行に、違反のある種類だけを並べる
|
|
379
|
+
*/
|
|
380
|
+
export function hasReportedTemplateViolations(output, body, templatePath, options = {}) {
|
|
381
|
+
const required = readTemplateSections(templatePath);
|
|
382
|
+
const missing = required.length > 0 ? validateSections(body, required) : [];
|
|
383
|
+
const summaryErrors = required.length > 0 ? validateHeadingSummaries(body, required) : [];
|
|
384
|
+
const styleErrors = validateBodyStyle(body);
|
|
385
|
+
const stem = path.basename(templatePath, path.extname(templatePath));
|
|
386
|
+
const closedGuidance = CLOSED_HEADINGS_BY_TEMPLATE.get(stem);
|
|
387
|
+
const foldErrors = closedGuidance === undefined ? [] : [...validateFoldBalance(body)];
|
|
388
|
+
const extraHeadings = closedGuidance !== undefined && required.length > 0 ? validateClosedHeadings(body, required) : [];
|
|
389
|
+
const foldSummary = FOLD_SUMMARY_BY_TEMPLATE.get(stem);
|
|
390
|
+
if (foldSummary !== undefined)
|
|
391
|
+
foldErrors.push(...validateFoldSummaries(body, foldSummary));
|
|
392
|
+
if (missing.length === 0 && summaryErrors.length === 0 && styleErrors.length === 0 && foldErrors.length === 0 && extraHeadings.length === 0)
|
|
393
|
+
return false;
|
|
394
|
+
const lines = [`the body does not follow the template ${templatePath}`];
|
|
395
|
+
if (missing.length > 0) {
|
|
396
|
+
lines.push(`missing sections: ${missing.join(', ')}`);
|
|
397
|
+
if (options.emDashHint === true && missing.some(section => section.includes(' — <'))) {
|
|
398
|
+
lines.push('hint: the em dash must be U+2014; hyphen-minus (-) and EN DASH (U+2013) are not allowed');
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (summaryErrors.length > 0)
|
|
402
|
+
lines.push(`heading summary rule violations: ${summaryErrors.join(', ')}`);
|
|
403
|
+
if (styleErrors.length > 0)
|
|
404
|
+
lines.push(`unusable notation: ${styleErrors.join(', ')}`);
|
|
405
|
+
if (foldErrors.length > 0)
|
|
406
|
+
lines.push(`collapse rule violations: ${foldErrors.join(', ')}`);
|
|
407
|
+
if (extraHeadings.length > 0)
|
|
408
|
+
lines.push(`headings not in the template: ${extraHeadings.join(', ')} (${String(closedGuidance)})`);
|
|
409
|
+
output.error(lines.join('\n'));
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
Issue 本文を種別のテンプレートと比べる。違反があれば error を出して終了コード 1
|
|
414
|
+
*/
|
|
415
|
+
export function validateIssueTemplate(output, templateType, body) {
|
|
416
|
+
if (hasReportedTemplateViolations(output, body, templateFile('issue', templateType), { emDashHint: true }))
|
|
417
|
+
throw new CommandExit(1);
|
|
418
|
+
}
|
|
419
|
+
//# sourceMappingURL=issue-shared.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ISSUE_COMMENT_COMMANDS } from './issue-comment.js';
|
|
2
|
+
import { ISSUE_CREATE_COMMANDS } from './issue-create.js';
|
|
3
|
+
import { ISSUE_QUICK_COMMANDS } from './issue-quick.js';
|
|
4
|
+
import { ISSUE_PROJECT_COMMANDS } from './issue-project.js';
|
|
5
|
+
import { ISSUE_READ_COMMANDS } from './issue-read.js';
|
|
6
|
+
// 並びは Python の登録順(help の一覧に出る順)にそろえる
|
|
7
|
+
export const ISSUE_BOARD_COMMANDS = ISSUE_PROJECT_COMMANDS.filter(command => command.path.length === 1);
|
|
8
|
+
export const ISSUE_COMMANDS = [
|
|
9
|
+
...ISSUE_CREATE_COMMANDS,
|
|
10
|
+
...ISSUE_QUICK_COMMANDS,
|
|
11
|
+
...ISSUE_READ_COMMANDS,
|
|
12
|
+
...ISSUE_COMMENT_COMMANDS,
|
|
13
|
+
...ISSUE_PROJECT_COMMANDS.filter(command => command.path.length !== 1),
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=issue.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
入力名を長いオプションの形にする。`force_overwrite_active` は `--force-overwrite-active`
|
|
3
|
+
*/
|
|
4
|
+
export declare function flagOf(name: string): string;
|
|
5
|
+
/**
|
|
6
|
+
文字列を名前の順(コードユニットの順)に並べる比較関数
|
|
7
|
+
*/
|
|
8
|
+
export declare function byName(left: string, right: string): number;
|
|
9
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// コマンドの名前まわりの小さな関数。help・バインド・定義書の書き出しが同じものを使う。
|
|
2
|
+
/**
|
|
3
|
+
入力名を長いオプションの形にする。`force_overwrite_active` は `--force-overwrite-active`
|
|
4
|
+
*/
|
|
5
|
+
export function flagOf(name) {
|
|
6
|
+
return `--${name.replaceAll('_', '-')}`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
文字列を名前の順(コードユニットの順)に並べる比較関数
|
|
10
|
+
*/
|
|
11
|
+
export function byName(left, right) {
|
|
12
|
+
if (left < right)
|
|
13
|
+
return -1;
|
|
14
|
+
return left > right ? 1 : 0;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { CommandIo } from './registry.js';
|
|
3
|
+
/**
|
|
4
|
+
操作の動詞。自由な文字列を受け取らない
|
|
5
|
+
*/
|
|
6
|
+
export declare const VerbSchema: z.ZodEnum<{
|
|
7
|
+
add: "add";
|
|
8
|
+
close: "close";
|
|
9
|
+
create: "create";
|
|
10
|
+
delete: "delete";
|
|
11
|
+
merge: "merge";
|
|
12
|
+
move: "move";
|
|
13
|
+
remove: "remove";
|
|
14
|
+
reopen: "reopen";
|
|
15
|
+
set: "set";
|
|
16
|
+
skip: "skip";
|
|
17
|
+
unchanged: "unchanged";
|
|
18
|
+
update: "update";
|
|
19
|
+
}>;
|
|
20
|
+
export type Verb = z.infer<typeof VerbSchema>;
|
|
21
|
+
/**
|
|
22
|
+
plan と result の元になる操作
|
|
23
|
+
*/
|
|
24
|
+
export interface Operation {
|
|
25
|
+
readonly verb: Verb;
|
|
26
|
+
readonly target: string;
|
|
27
|
+
}
|
|
28
|
+
export interface Output {
|
|
29
|
+
/**
|
|
30
|
+
dry-run のときだけ、実行する操作を stderr に出す
|
|
31
|
+
*/
|
|
32
|
+
readonly planned: (operation: Operation) => void;
|
|
33
|
+
/**
|
|
34
|
+
dry-run でないときだけ、実行した操作を stderr に出す
|
|
35
|
+
*/
|
|
36
|
+
readonly done: (operation: Operation) => void;
|
|
37
|
+
readonly warning: (message: string) => void;
|
|
38
|
+
readonly error: (message: string) => void;
|
|
39
|
+
/**
|
|
40
|
+
value が未設定なら `unknown` と出す
|
|
41
|
+
*/
|
|
42
|
+
readonly count: (label: string, value: number | undefined) => void;
|
|
43
|
+
/**
|
|
44
|
+
結果の本体を stdout にそのまま出す。末尾に改行が無ければ 1 つ足す
|
|
45
|
+
*/
|
|
46
|
+
readonly data: (text: string) => void;
|
|
47
|
+
}
|
|
48
|
+
export declare function createOutput(isDryRun: boolean, io: CommandIo): Output;
|
|
49
|
+
/**
|
|
50
|
+
fd から buffer へ読んだバイト数。0 は終端
|
|
51
|
+
*/
|
|
52
|
+
export type ReadBytes = (fd: number, buffer: Uint8Array) => number;
|
|
53
|
+
/**
|
|
54
|
+
1 バイトずつ読むのは、次の行を先読みして取りこぼさず、process.stdin に触れないため。read と wait はテスト用の差し替え口
|
|
55
|
+
*/
|
|
56
|
+
export declare function createLineReader(fd: number, read?: ReadBytes, wait?: () => void): () => string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
process.stdout・process.stderr に書き、fd(既定は標準入力)から読む CommandIo。src/cli.ts の main が使う
|
|
59
|
+
*/
|
|
60
|
+
export declare function createProcessIo(fd?: number): CommandIo;
|
|
61
|
+
/**
|
|
62
|
+
確認の途中で入力が終わった(Python の click の Abort)。
|
|
63
|
+
code を持たせない(link の処理は code を持つ例外を握るため、これは握られずに最上位まで届く)
|
|
64
|
+
*/
|
|
65
|
+
export declare class AbortedError extends Error {
|
|
66
|
+
constructor();
|
|
67
|
+
}
|
|
68
|
+
export declare const ABORTED_EXIT_CODE = 1;
|
|
69
|
+
/**
|
|
70
|
+
中止を stderr に出して、終了コードを返す。`Aborted.` の前に改行は入らない
|
|
71
|
+
*/
|
|
72
|
+
export declare function reportAborted(io: CommandIo): number;
|
|
73
|
+
/**
|
|
74
|
+
末尾の空白 1 つを stdout に出すのは、既存の CLI の出力(問いは stderr、空白だけ stdout)を変えないため。
|
|
75
|
+
readLine が無い(MCP)か入力が終わると AbortedError を投げる
|
|
76
|
+
*/
|
|
77
|
+
export declare function isConfirmed(io: CommandIo, text: string): boolean;
|
|
78
|
+
//# sourceMappingURL=output.d.ts.map
|