@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,304 @@
|
|
|
1
|
+
// Python の CLI が出していた文言を作る関数。
|
|
2
|
+
// 前後比較で文言を揃えるため、Python と同じ書式を写す。
|
|
3
|
+
//
|
|
4
|
+
// 持つもの:
|
|
5
|
+
// - JSON 値の repr は pythonRepr。
|
|
6
|
+
// - str のメソッドに当たる関数は pythonStrip と parsePythonInteger。
|
|
7
|
+
// - HTTP クライアントの状態の文は formatHttpStatusError。
|
|
8
|
+
// - 検証ライブラリの ValidationError の文は formatValidationError。
|
|
9
|
+
// - OSError の文は formatOsError。
|
|
10
|
+
//
|
|
11
|
+
// JSON.parse は整数と実数を区別しない。そのため 2.0 は「2」と出る(Python は 2.0)。
|
|
12
|
+
// オブジェクトのキーは JS の順序(整数風のキーが先頭)になり、Python の挿入順とは違うことがある。
|
|
13
|
+
import { InvalidValueError } from './errors.js';
|
|
14
|
+
// Python の str.isspace() が真の文字。JS の trim() が落とす文字から U+FEFF を除き、U+001C〜U+001F と U+0085 を足したもの
|
|
15
|
+
function isPythonWhitespace(character) {
|
|
16
|
+
const code = character.codePointAt(0) ?? 0;
|
|
17
|
+
return (character.trim() === '' && code !== 0xFE_FF) || (code >= 0x1C && code <= 0x1F) || code === 0x85;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
universal newlines と同じ。`\r\n` と `\r` を `\n` に揃える(Python の text=True・read_text())
|
|
21
|
+
*/
|
|
22
|
+
export function normalizeNewlines(text) {
|
|
23
|
+
return text.replaceAll(/\r\n?/gu, '\n');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
sorted() の str の並べ方に使う比較。UTF-16 の単位順で比べる(BMP 内では Python のコードポイント順と同じ)
|
|
27
|
+
*/
|
|
28
|
+
export function compareStrings(a, b) {
|
|
29
|
+
if (a === b)
|
|
30
|
+
return 0;
|
|
31
|
+
return a < b ? -1 : 1;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
str.rstrip() と同じ
|
|
35
|
+
*/
|
|
36
|
+
export function pythonRightStrip(text) {
|
|
37
|
+
let end = text.length;
|
|
38
|
+
while (end > 0 && isPythonWhitespace(text.charAt(end - 1)))
|
|
39
|
+
end -= 1;
|
|
40
|
+
return text.slice(0, end);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
文字列をコードポイントに分ける。Python の len・スライスと同じ単位(UTF-16 の単位ではない)
|
|
44
|
+
*/
|
|
45
|
+
export function splitCodePoints(text) {
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-spread -- Python の len と同じコードポイント単位で数えるため
|
|
47
|
+
return [...text];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
text[:limit] と同じ。コードポイント単位で切る
|
|
51
|
+
*/
|
|
52
|
+
export function truncateCodePoints(text, limit) {
|
|
53
|
+
return splitCodePoints(text).slice(0, limit).join('');
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
str.strip() と同じ
|
|
57
|
+
*/
|
|
58
|
+
export function pythonStrip(text) {
|
|
59
|
+
let start = 0;
|
|
60
|
+
let end = text.length;
|
|
61
|
+
while (start < end && isPythonWhitespace(text.charAt(start)))
|
|
62
|
+
start += 1;
|
|
63
|
+
while (end > start && isPythonWhitespace(text.charAt(end - 1)))
|
|
64
|
+
end -= 1;
|
|
65
|
+
return text.slice(start, end);
|
|
66
|
+
}
|
|
67
|
+
const NON_PRINTABLE = /[\p{Cc}\p{Cf}\p{Cs}\p{Co}\p{Cn}\p{Zl}\p{Zp}\p{Zs}]/u;
|
|
68
|
+
function escapeCodePoint(character) {
|
|
69
|
+
const code = character.codePointAt(0) ?? 0;
|
|
70
|
+
if (code < 0x1_00)
|
|
71
|
+
return String.raw `\x${code.toString(16).padStart(2, '0')}`;
|
|
72
|
+
if (code < 0x1_00_00)
|
|
73
|
+
return String.raw `\u${code.toString(16).padStart(4, '0')}`;
|
|
74
|
+
return String.raw `\U${code.toString(16).padStart(8, '0')}`;
|
|
75
|
+
}
|
|
76
|
+
function escapeCharacter(character, quote) {
|
|
77
|
+
switch (character) {
|
|
78
|
+
case quote:
|
|
79
|
+
case '\\': {
|
|
80
|
+
return `\\${character}`;
|
|
81
|
+
}
|
|
82
|
+
case '\n': {
|
|
83
|
+
return String.raw `\n`;
|
|
84
|
+
}
|
|
85
|
+
case '\r': {
|
|
86
|
+
return String.raw `\r`;
|
|
87
|
+
}
|
|
88
|
+
case '\t': {
|
|
89
|
+
return String.raw `\t`;
|
|
90
|
+
}
|
|
91
|
+
case ' ': {
|
|
92
|
+
return character;
|
|
93
|
+
}
|
|
94
|
+
default: {
|
|
95
|
+
return NON_PRINTABLE.test(character) ? escapeCodePoint(character) : character;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
repr(str) と同じ。引用符は、' を含み " を含まないときだけ "
|
|
101
|
+
*/
|
|
102
|
+
export function pythonStringRepr(text) {
|
|
103
|
+
const quote = text.includes('\'') && !text.includes('"') ? '"' : '\'';
|
|
104
|
+
let result = '';
|
|
105
|
+
for (const character of splitCodePoints(text)) {
|
|
106
|
+
result += escapeCharacter(character, quote);
|
|
107
|
+
}
|
|
108
|
+
return `${quote}${result}${quote}`;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
repr(float) と同じ。指数表記になるのは、10 進の小数点位置が 16 を超える・-3 未満のとき
|
|
112
|
+
*/
|
|
113
|
+
export function pythonFloatRepr(value) {
|
|
114
|
+
if (Number.isNaN(value))
|
|
115
|
+
return 'nan';
|
|
116
|
+
if (!Number.isFinite(value))
|
|
117
|
+
return value > 0 ? 'inf' : '-inf';
|
|
118
|
+
if (value === 0)
|
|
119
|
+
return Object.is(value, -0) ? '-0.0' : '0.0';
|
|
120
|
+
const sign = value < 0 ? '-' : '';
|
|
121
|
+
const [mantissa = '', exponentText = '0'] = Math.abs(value).toExponential().split('e', 2);
|
|
122
|
+
const digits = mantissa.replace('.', '');
|
|
123
|
+
const exponent = Number(exponentText);
|
|
124
|
+
const pointPosition = exponent + 1;
|
|
125
|
+
if (pointPosition > -4 && pointPosition <= 16) {
|
|
126
|
+
if (pointPosition <= 0)
|
|
127
|
+
return `${sign}0.${'0'.repeat(-pointPosition)}${digits}`;
|
|
128
|
+
if (digits.length <= pointPosition)
|
|
129
|
+
return `${sign}${digits}${'0'.repeat(pointPosition - digits.length)}.0`;
|
|
130
|
+
return `${sign}${digits.slice(0, pointPosition)}.${digits.slice(pointPosition)}`;
|
|
131
|
+
}
|
|
132
|
+
const fraction = digits.length > 1 ? `.${digits.slice(1)}` : '';
|
|
133
|
+
const exponentSign = exponent < 0 ? '-' : '+';
|
|
134
|
+
return `${sign}${digits.slice(0, 1)}${fraction}e${exponentSign}${String(Math.abs(exponent)).padStart(2, '0')}`;
|
|
135
|
+
}
|
|
136
|
+
export function isJsonArray(value) {
|
|
137
|
+
return Array.isArray(value);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
JSON 値の repr。整数値の数は int、それ以外は float の書式にする
|
|
141
|
+
*/
|
|
142
|
+
export function pythonRepr(value) {
|
|
143
|
+
if (value === null)
|
|
144
|
+
return 'None';
|
|
145
|
+
if (typeof value === 'boolean')
|
|
146
|
+
return value ? 'True' : 'False';
|
|
147
|
+
if (typeof value === 'number')
|
|
148
|
+
return Number.isSafeInteger(value) ? String(value) : pythonFloatRepr(value);
|
|
149
|
+
if (typeof value === 'string')
|
|
150
|
+
return pythonStringRepr(value);
|
|
151
|
+
if (isJsonArray(value))
|
|
152
|
+
return `[${value.map(item => pythonRepr(item)).join(', ')}]`;
|
|
153
|
+
return `{${Object.entries(value).map(([key, item]) => `${pythonStringRepr(key)}: ${pythonRepr(item)}`).join(', ')}}`;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
type(value).__name__ に当たる名前
|
|
157
|
+
*/
|
|
158
|
+
export function pythonTypeName(value) {
|
|
159
|
+
if (value === null || value === undefined)
|
|
160
|
+
return 'NoneType';
|
|
161
|
+
if (typeof value === 'boolean')
|
|
162
|
+
return 'bool';
|
|
163
|
+
if (typeof value === 'number')
|
|
164
|
+
return Number.isSafeInteger(value) ? 'int' : 'float';
|
|
165
|
+
if (typeof value === 'string')
|
|
166
|
+
return 'str';
|
|
167
|
+
return isJsonArray(value) ? 'list' : 'dict';
|
|
168
|
+
}
|
|
169
|
+
// Unicode の Nd は 10 文字ずつの連続した並びで、先頭が 0。並びの先頭からの距離の 10 の剰余が数字の値になる
|
|
170
|
+
function decimalDigitValue(character) {
|
|
171
|
+
let distance = 0;
|
|
172
|
+
let code = (character.codePointAt(0) ?? 0) - 1;
|
|
173
|
+
while (code >= 0 && /^\p{Nd}$/u.test(String.fromCodePoint(code))) {
|
|
174
|
+
distance += 1;
|
|
175
|
+
code -= 1;
|
|
176
|
+
}
|
|
177
|
+
return distance % 10;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
int(text) と同じ。前後の空白・符号・数字の間の `_`・Unicode の 10 進数字を受ける。
|
|
181
|
+
不正なら Python と同じ文の InvalidValueError ではなく undefined を返す(呼び出し側が文言を作る)
|
|
182
|
+
*/
|
|
183
|
+
export function parsePythonInteger(text) {
|
|
184
|
+
const stripped = pythonStrip(text);
|
|
185
|
+
const isNegative = stripped.startsWith('-');
|
|
186
|
+
const body = isNegative || stripped.startsWith('+') ? stripped.slice(1) : stripped;
|
|
187
|
+
// 数字の間の `_` は 1 つだけ受ける。先頭・末尾・連続は不可
|
|
188
|
+
const groups = body.split('_');
|
|
189
|
+
if (groups.some(group => !/^\p{Nd}+$/u.test(group)))
|
|
190
|
+
return undefined;
|
|
191
|
+
const value = Number(groups.map(group => splitCodePoints(group).map(character => decimalDigitValue(character)).join('')).join(''));
|
|
192
|
+
return isNegative ? -value : value;
|
|
193
|
+
}
|
|
194
|
+
const STATUS_CLASS_LABELS = new Map([
|
|
195
|
+
[1, 'Informational response'],
|
|
196
|
+
[3, 'Redirect response'],
|
|
197
|
+
[4, 'Client error'],
|
|
198
|
+
[5, 'Server error'],
|
|
199
|
+
]);
|
|
200
|
+
const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
201
|
+
/**
|
|
202
|
+
2xx 以外の応答に対する、HTTP クライアントの raise_for_status の文
|
|
203
|
+
*/
|
|
204
|
+
export function formatHttpStatusError(failure) {
|
|
205
|
+
const { statusCode, url, location } = failure;
|
|
206
|
+
const reason = failure.statusText;
|
|
207
|
+
const label = STATUS_CLASS_LABELS.get(Math.trunc(statusCode / 100)) ?? 'Invalid status code';
|
|
208
|
+
const lines = [`${label} '${String(statusCode)} ${reason}' for url '${url}'`];
|
|
209
|
+
if (location !== undefined && REDIRECT_STATUSES.has(statusCode))
|
|
210
|
+
lines.push(`Redirect location: '${location}'`);
|
|
211
|
+
lines.push(`For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/${String(statusCode)}`);
|
|
212
|
+
return lines.join('\n');
|
|
213
|
+
}
|
|
214
|
+
const ERRNO_TABLE = new Map([
|
|
215
|
+
['EPERM', [1, 'Operation not permitted']],
|
|
216
|
+
['ENOENT', [2, 'No such file or directory']],
|
|
217
|
+
['EIO', [5, 'Input/output error']],
|
|
218
|
+
['EBADF', [9, 'Bad file descriptor']],
|
|
219
|
+
['EACCES', [13, 'Permission denied']],
|
|
220
|
+
['EBUSY', [16, 'Device or resource busy']],
|
|
221
|
+
['EEXIST', [17, 'File exists']],
|
|
222
|
+
['EXDEV', [18, 'Invalid cross-device link']],
|
|
223
|
+
['ENOTDIR', [20, 'Not a directory']],
|
|
224
|
+
['EISDIR', [21, 'Is a directory']],
|
|
225
|
+
['EINVAL', [22, 'Invalid argument']],
|
|
226
|
+
['EMFILE', [24, 'Too many open files']],
|
|
227
|
+
['ENOSPC', [28, 'No space left on device']],
|
|
228
|
+
['EROFS', [30, 'Read-only file system']],
|
|
229
|
+
['ENAMETOOLONG', [36, 'File name too long']],
|
|
230
|
+
['ENOTEMPTY', [39, 'Directory not empty']],
|
|
231
|
+
['ELOOP', [40, 'Too many levels of symbolic links']],
|
|
232
|
+
]);
|
|
233
|
+
/**
|
|
234
|
+
OSError の文(`[Errno 2] No such file or directory: 'x'`)。errno の code が表に無いときは undefined
|
|
235
|
+
*/
|
|
236
|
+
export function formatOsError(failure) {
|
|
237
|
+
const entry = failure.code === undefined ? undefined : ERRNO_TABLE.get(failure.code);
|
|
238
|
+
if (entry === undefined)
|
|
239
|
+
return undefined;
|
|
240
|
+
const [errno, text] = entry;
|
|
241
|
+
const head = `[Errno ${String(errno)}] ${text}`;
|
|
242
|
+
if (failure.path === undefined)
|
|
243
|
+
return head;
|
|
244
|
+
const destination = failure.dest === undefined ? '' : ` -> ${pythonStringRepr(failure.dest)}`;
|
|
245
|
+
return `${head}: ${pythonStringRepr(failure.path)}${destination}`;
|
|
246
|
+
}
|
|
247
|
+
// 検証ライブラリの案内 URL に入る版。Python の CLI が使っていた版に合わせる
|
|
248
|
+
const VALIDATION_DOCS_VERSION = '2.14';
|
|
249
|
+
// 入力値の repr の省略。UTF-8 のバイト長が 50 を超えたら、前 25 バイト・後ろ 24 バイトまでを文字単位で残す。
|
|
250
|
+
// 文字の途中でバイトが切れる位置では、入りきる文字だけを残す(どちらも内側へ寄せる)。
|
|
251
|
+
const REPRESENTATION_LIMIT_BYTES = 50;
|
|
252
|
+
const HEAD_BYTES = 25;
|
|
253
|
+
const TAIL_BYTES = 24;
|
|
254
|
+
function byteLength(text) {
|
|
255
|
+
return new TextEncoder().encode(text).length;
|
|
256
|
+
}
|
|
257
|
+
// 先頭から、バイト数の合計が limit に収まる文字までを取る
|
|
258
|
+
function takeWithinBytes(characters, limit) {
|
|
259
|
+
const taken = [];
|
|
260
|
+
let total = 0;
|
|
261
|
+
for (const item of characters) {
|
|
262
|
+
if (total + item.bytes > limit)
|
|
263
|
+
break;
|
|
264
|
+
taken.push(item);
|
|
265
|
+
total += item.bytes;
|
|
266
|
+
}
|
|
267
|
+
return taken;
|
|
268
|
+
}
|
|
269
|
+
function truncatedRepresentation(value) {
|
|
270
|
+
const text = value === undefined ? 'None' : pythonRepr(value);
|
|
271
|
+
if (byteLength(text) <= REPRESENTATION_LIMIT_BYTES)
|
|
272
|
+
return text;
|
|
273
|
+
const characters = splitCodePoints(text).map(character => ({ character, bytes: byteLength(character) }));
|
|
274
|
+
const head = takeWithinBytes(characters, HEAD_BYTES);
|
|
275
|
+
const tail = takeWithinBytes(characters.slice(head.length).toReversed(), TAIL_BYTES).toReversed();
|
|
276
|
+
return `${head.map(item => item.character).join('')}...${tail.map(item => item.character).join('')}`;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
ValidationError の文。表題(モデル名)の後に、エラーごとに 3 行(場所・本文・案内 URL)が続く。
|
|
280
|
+
入力値の repr は、UTF-8 のバイト長が 50 を超えると省略する。
|
|
281
|
+
前 25 バイトと後ろ 24 バイトに収まる文字だけを残し、間を `...` でつなぐ
|
|
282
|
+
*/
|
|
283
|
+
export function formatValidationError(title, issues) {
|
|
284
|
+
const lines = [`${String(issues.length)} validation error${issues.length === 1 ? '' : 's'} for ${title}`];
|
|
285
|
+
for (const issue of issues) {
|
|
286
|
+
if (issue.location.length > 0)
|
|
287
|
+
lines.push(issue.location.map(String).join('.'));
|
|
288
|
+
lines.push(` ${issue.message} [type=${issue.type}, input_value=${truncatedRepresentation(issue.input)}, input_type=${pythonTypeName(issue.input)}]`, ` For further information visit https://errors.pydantic.dev/${VALIDATION_DOCS_VERSION}/v/${issue.type}`);
|
|
289
|
+
}
|
|
290
|
+
return lines.join('\n');
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
ValidationError に当たる例外。メッセージは formatValidationError の文
|
|
294
|
+
*/
|
|
295
|
+
export class ValidationFailure extends InvalidValueError {
|
|
296
|
+
title;
|
|
297
|
+
issues;
|
|
298
|
+
constructor(title, issues) {
|
|
299
|
+
super(formatValidationError(title, issues));
|
|
300
|
+
this.title = title;
|
|
301
|
+
this.issues = issues;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=python-format.js.map
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { IssuePrerequisitesReadout } from './issue-readout.js';
|
|
2
|
+
import type { WaitsForMergeReadout } from './prerequisites.js';
|
|
3
|
+
import type { IssueReference } from './reference-parser.js';
|
|
4
|
+
import type { RepositoryReference } from './repository-resolver.js';
|
|
5
|
+
export type Wait = 'stack' | 'merge';
|
|
6
|
+
export type IssueWorkKind = 'task' | 'epic' | 'tracker';
|
|
7
|
+
export interface IssuePullRequest {
|
|
8
|
+
readonly repository: RepositoryReference;
|
|
9
|
+
readonly number: number;
|
|
10
|
+
readonly state: 'open' | 'merged' | 'closed';
|
|
11
|
+
readonly headRefName: string;
|
|
12
|
+
readonly baseRefName: string;
|
|
13
|
+
readonly isDraft: boolean;
|
|
14
|
+
readonly isCrossRepository: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface IssueFacts {
|
|
17
|
+
readonly ref: IssueReference;
|
|
18
|
+
readonly state: 'open' | 'closed';
|
|
19
|
+
/**
|
|
20
|
+
進行の欄の値。ボードに無ければ undefined
|
|
21
|
+
*/
|
|
22
|
+
readonly column: string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
Status の値(札)。ボードに無ければ undefined
|
|
25
|
+
*/
|
|
26
|
+
readonly label: string | undefined;
|
|
27
|
+
readonly kind: IssueWorkKind;
|
|
28
|
+
readonly branches: readonly string[];
|
|
29
|
+
readonly pullRequests: readonly IssuePullRequest[];
|
|
30
|
+
}
|
|
31
|
+
export interface Prerequisite {
|
|
32
|
+
readonly issue: IssueFacts;
|
|
33
|
+
readonly wait: Wait;
|
|
34
|
+
/**
|
|
35
|
+
wait が merge のときの理由。本文の節が読めないときは undefined
|
|
36
|
+
*/
|
|
37
|
+
readonly reason: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
export type PrerequisiteList = readonly Prerequisite[] | 'read-failed';
|
|
40
|
+
export type NotInReviewState = 'started-without-pr' | 'not-started' | 'multiple-prs' | 'fork-pr' | 'pending';
|
|
41
|
+
export type ReadinessReason = {
|
|
42
|
+
readonly code: 'unreadable';
|
|
43
|
+
} | {
|
|
44
|
+
readonly code: 'cycle';
|
|
45
|
+
readonly cycle: readonly string[];
|
|
46
|
+
} | {
|
|
47
|
+
readonly code: 'closed-unmerged' | 'other-repository' | 'diverged';
|
|
48
|
+
readonly issues: readonly IssueReference[];
|
|
49
|
+
} | {
|
|
50
|
+
readonly code: 'waits-merge';
|
|
51
|
+
readonly issues: readonly {
|
|
52
|
+
readonly issue: IssueReference;
|
|
53
|
+
readonly reason: string | undefined;
|
|
54
|
+
}[];
|
|
55
|
+
} | {
|
|
56
|
+
readonly code: 'not-in-review';
|
|
57
|
+
readonly issues: readonly {
|
|
58
|
+
readonly issue: IssueReference;
|
|
59
|
+
readonly state: NotInReviewState;
|
|
60
|
+
}[];
|
|
61
|
+
};
|
|
62
|
+
export interface StackTarget {
|
|
63
|
+
readonly branch: string;
|
|
64
|
+
readonly issue: IssueReference;
|
|
65
|
+
}
|
|
66
|
+
export interface Readiness {
|
|
67
|
+
readonly kind: 'startable' | 'stackable' | 'blocked';
|
|
68
|
+
readonly stackOn: StackTarget | undefined;
|
|
69
|
+
/**
|
|
70
|
+
blocked のときだけある
|
|
71
|
+
*/
|
|
72
|
+
readonly reason: ReadinessReason | undefined;
|
|
73
|
+
/**
|
|
74
|
+
閉じて済んでいない前提がある。当たった順とは独立に計算する
|
|
75
|
+
*/
|
|
76
|
+
readonly needsReview: boolean;
|
|
77
|
+
/**
|
|
78
|
+
札が Needs Attention の、済んでいない前提だけ。済んだ前提は含めず、blocked にも付く
|
|
79
|
+
*/
|
|
80
|
+
readonly attention: readonly IssueReference[];
|
|
81
|
+
}
|
|
82
|
+
export interface JudgeReadinessInput {
|
|
83
|
+
readonly target: IssueFacts;
|
|
84
|
+
readonly prerequisites: PrerequisiteList;
|
|
85
|
+
/**
|
|
86
|
+
findCycle の結果
|
|
87
|
+
*/
|
|
88
|
+
readonly cycle: readonly string[] | undefined;
|
|
89
|
+
/**
|
|
90
|
+
head のブランチ名から PR を引く。順 8 で base をたどるのに使い、open で fork からでない PR だけを通る
|
|
91
|
+
*/
|
|
92
|
+
readonly pullRequestsByHead: ReadonlyMap<string, IssuePullRequest>;
|
|
93
|
+
readonly developmentBranch: string;
|
|
94
|
+
}
|
|
95
|
+
export declare const PENDING_COLUMN = "Pending";
|
|
96
|
+
export declare const NEEDS_ATTENTION_LABEL = "Needs Attention";
|
|
97
|
+
export declare const TRACKER_TITLE_PREFIX = "[Tracker]";
|
|
98
|
+
export declare function isDone(issue: IssueFacts): boolean;
|
|
99
|
+
/**
|
|
100
|
+
open で、open の PR がちょうど 1 本あり、fork からでない。ドラフトも含む
|
|
101
|
+
*/
|
|
102
|
+
export declare function isInReview(issue: IssueFacts): boolean;
|
|
103
|
+
export declare function hasStarted(issue: IssueFacts): boolean;
|
|
104
|
+
/**
|
|
105
|
+
data-model.md の 3 の表を上から当てはめる。Epic と Tracker には判定を出さず undefined を返す
|
|
106
|
+
*/
|
|
107
|
+
export declare function judgeReadiness(input: JudgeReadinessInput): Readiness | undefined;
|
|
108
|
+
export interface PlannedPhase {
|
|
109
|
+
readonly key: string;
|
|
110
|
+
readonly prerequisites: readonly {
|
|
111
|
+
readonly key: string;
|
|
112
|
+
readonly wait: Wait;
|
|
113
|
+
}[];
|
|
114
|
+
}
|
|
115
|
+
export type Progression = {
|
|
116
|
+
readonly kind: 'alone';
|
|
117
|
+
} | {
|
|
118
|
+
readonly kind: 'wait-merge';
|
|
119
|
+
} | {
|
|
120
|
+
readonly kind: 'stack';
|
|
121
|
+
readonly on: string;
|
|
122
|
+
} | {
|
|
123
|
+
readonly kind: 'join';
|
|
124
|
+
};
|
|
125
|
+
export type ProgressionPlan = {
|
|
126
|
+
readonly kind: 'cycle';
|
|
127
|
+
readonly cycle: readonly string[];
|
|
128
|
+
} | {
|
|
129
|
+
readonly kind: 'planned';
|
|
130
|
+
readonly progressions: ReadonlyMap<string, Progression>;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
キーから前提のキーへの辺の表から、輪を 1 つ返す。始点を末尾にも置き、始点は輪のキーの最小にする。
|
|
134
|
+
キーと辺をソートして探すので、入力の順に依らない。自分自身への辺は長さ 1 の輪になる
|
|
135
|
+
*/
|
|
136
|
+
export declare function findCycle(edges: ReadonlyMap<string, readonly string[]>): readonly string[] | undefined;
|
|
137
|
+
/**
|
|
138
|
+
フェーズごとの進め方を、Issue の状態を見ずに前提の形と種類だけで決める。輪があれば進め方を出さず輪を返す
|
|
139
|
+
*/
|
|
140
|
+
export declare function planProgression(phases: readonly PlannedPhase[]): ProgressionPlan;
|
|
141
|
+
/**
|
|
142
|
+
stack の積む先をたどった木の、根から葉までの道を、下から並べて返す。stack の無い根は道を作らないので、1 段だけの道は出ない
|
|
143
|
+
*/
|
|
144
|
+
export declare function stackChains(progressions: ReadonlyMap<string, Progression>): readonly (readonly string[])[];
|
|
145
|
+
export interface FactsMismatch {
|
|
146
|
+
readonly ref: IssueReference;
|
|
147
|
+
readonly reason: string;
|
|
148
|
+
}
|
|
149
|
+
export interface ToIssueFactsResult {
|
|
150
|
+
readonly target: IssueFacts;
|
|
151
|
+
readonly prerequisites: PrerequisiteList;
|
|
152
|
+
/**
|
|
153
|
+
本文の節にあって blocked by に無い組。判定には使わない
|
|
154
|
+
*/
|
|
155
|
+
readonly mismatches: readonly FactsMismatch[];
|
|
156
|
+
}
|
|
157
|
+
export interface ToIssueFactsOptions {
|
|
158
|
+
/**
|
|
159
|
+
進行の欄のフィールド名(`pecot-workflow-<suffix>`)
|
|
160
|
+
*/
|
|
161
|
+
readonly columnFieldName: string;
|
|
162
|
+
/**
|
|
163
|
+
札のフィールド名。このフェーズでは `Status`
|
|
164
|
+
*/
|
|
165
|
+
readonly labelFieldName: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
infra の読み取り結果を、判定の入力(Issue の実態)にまとめる。
|
|
169
|
+
本文の節が malformed なら前提をすべて merge にし、節にあって blocked by に無い組は mismatches に返す
|
|
170
|
+
*/
|
|
171
|
+
export declare function toIssueFacts(readout: IssuePrerequisitesReadout, section: WaitsForMergeReadout, options: ToIssueFactsOptions): ToIssueFactsResult;
|
|
172
|
+
//# sourceMappingURL=readiness.d.ts.map
|