@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,94 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types -- zod の型は readonly にできない */
|
|
2
|
+
// オプションと位置引数の型。zod のスキーマの形から、click と同じ型変換と誤りの文を決める。
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { parsePythonInteger, pythonFloatRepr, pythonStringRepr } from '../domain/python-format.js';
|
|
5
|
+
/**
|
|
6
|
+
包んでいる側のスキーマ。Optional・Default・Nullable・Readonly・Prefault・Catch・NonOptional は中を見る。
|
|
7
|
+
Pipe は、後段が transform なら前段を、そうでなければ後段を見る
|
|
8
|
+
*/
|
|
9
|
+
function innerSchemaOf(schema) {
|
|
10
|
+
if (schema instanceof z.ZodOptional || schema instanceof z.ZodDefault || schema instanceof z.ZodNullable
|
|
11
|
+
|| schema instanceof z.ZodReadonly || schema instanceof z.ZodPrefault || schema instanceof z.ZodCatch
|
|
12
|
+
|| schema instanceof z.ZodNonOptional)
|
|
13
|
+
return schema.unwrap();
|
|
14
|
+
if (schema instanceof z.ZodPipe)
|
|
15
|
+
return schema.out instanceof z.ZodTransform ? schema.in : schema.out;
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
function unwrapped(schema) {
|
|
19
|
+
let current = schema;
|
|
20
|
+
for (let inner = innerSchemaOf(current); inner !== undefined; inner = innerSchemaOf(current))
|
|
21
|
+
current = inner;
|
|
22
|
+
return current;
|
|
23
|
+
}
|
|
24
|
+
export function flagKindOf(schema) {
|
|
25
|
+
const current = unwrapped(schema);
|
|
26
|
+
if (current instanceof z.ZodBoolean)
|
|
27
|
+
return 'boolean';
|
|
28
|
+
return current instanceof z.ZodArray ? 'list' : 'value';
|
|
29
|
+
}
|
|
30
|
+
// z.int() は上下を安全な整数の端にする。範囲の指定とは見なさない
|
|
31
|
+
function boundOf(bound) {
|
|
32
|
+
return bound === null || Math.abs(bound) >= Number.MAX_SAFE_INTEGER ? undefined : bound;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
値 1 つの型。list は要素の型
|
|
36
|
+
*/
|
|
37
|
+
export function valueTypeOf(schema) {
|
|
38
|
+
const outer = unwrapped(schema);
|
|
39
|
+
const current = outer instanceof z.ZodArray ? unwrapped(outer.element) : outer;
|
|
40
|
+
if (current instanceof z.ZodNumber) {
|
|
41
|
+
const isInteger = (current.format ?? '').includes('int');
|
|
42
|
+
const range = { min: boundOf(current.minValue), max: boundOf(current.maxValue) };
|
|
43
|
+
return isInteger ? { type: 'integer', ...range } : { type: 'float', ...range };
|
|
44
|
+
}
|
|
45
|
+
return current instanceof z.ZodEnum ? { type: 'choice', choices: current.options.map(String) } : { type: 'string' };
|
|
46
|
+
}
|
|
47
|
+
const SPECIAL_FLOAT = /^[+-]?(?:inf|infinity|nan)$/iu;
|
|
48
|
+
const DECIMAL_CHARACTERS = /^[+-]?[\d.][\d.e+-]*$/iu;
|
|
49
|
+
/**
|
|
50
|
+
float(text) と同じ。前後の空白・数字の間の `_`・指数・inf・nan を受ける。不正なら undefined
|
|
51
|
+
*/
|
|
52
|
+
function parsePythonFloat(text) {
|
|
53
|
+
const lower = text.trim().toLowerCase().replaceAll(/(?<=\d)_(?=\d)/gu, '');
|
|
54
|
+
if (SPECIAL_FLOAT.test(lower)) {
|
|
55
|
+
if (lower.endsWith('nan'))
|
|
56
|
+
return NaN;
|
|
57
|
+
return lower.startsWith('-') ? -Infinity : Infinity;
|
|
58
|
+
}
|
|
59
|
+
if (!DECIMAL_CHARACTERS.test(lower))
|
|
60
|
+
return undefined;
|
|
61
|
+
const value = Number(lower);
|
|
62
|
+
return Number.isNaN(value) ? undefined : value;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
範囲の文。両側なら `0<=x<=20`、片側なら `x>=1` か `x<=9`
|
|
66
|
+
*/
|
|
67
|
+
export function describeRange(min, max) {
|
|
68
|
+
if (min !== undefined && max !== undefined)
|
|
69
|
+
return `${String(min)}<=x<=${String(max)}`;
|
|
70
|
+
return min === undefined ? `x<=${String(max)}` : `x>=${String(min)}`;
|
|
71
|
+
}
|
|
72
|
+
function isOutside(value, min, max) {
|
|
73
|
+
return (min !== undefined && value < min) || (max !== undefined && value > max);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
コマンドラインの文字列を、型に応じて変換する。誤りの文は typer 同梱の click と同じ
|
|
77
|
+
*/
|
|
78
|
+
export function convertValue(text, valueType) {
|
|
79
|
+
if (valueType.type === 'string')
|
|
80
|
+
return { isValid: true, value: text };
|
|
81
|
+
if (valueType.type === 'choice') {
|
|
82
|
+
return valueType.choices.includes(text) ? { isValid: true, value: text } : { isValid: false, message: `${pythonStringRepr(text)} is not one of ${valueType.choices.map(choice => pythonStringRepr(choice)).join(', ')}.` };
|
|
83
|
+
}
|
|
84
|
+
const { min, max } = valueType;
|
|
85
|
+
const name = `${valueType.type === 'float' ? 'float' : 'int'}${min === undefined && max === undefined ? '' : ' range'}`;
|
|
86
|
+
const value = valueType.type === 'float' ? parsePythonFloat(text) : parsePythonInteger(text);
|
|
87
|
+
if (value === undefined)
|
|
88
|
+
return { isValid: false, message: `${pythonStringRepr(text)} is not a valid ${name}.` };
|
|
89
|
+
if (!isOutside(value, min, max))
|
|
90
|
+
return { isValid: true, value };
|
|
91
|
+
const shown = valueType.type === 'float' ? pythonFloatRepr(value) : String(value);
|
|
92
|
+
return { isValid: false, message: `${shown} is not in the range ${describeRange(min, max)}.` };
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=value-types.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Output } from './output.js';
|
|
2
|
+
export interface RecordWorkTargetOptions {
|
|
3
|
+
/**
|
|
4
|
+
真なら、記録の失敗を warning ではなく error の行で出し、終了コード 1 で止める
|
|
5
|
+
*/
|
|
6
|
+
readonly failWithExit?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
.pecot-active と .pecot-session-title を書き、`set: work target ...` の行を出す。
|
|
10
|
+
失敗は warning の行にする。failWithExit なら error の行を出して CommandExit(1) を投げる
|
|
11
|
+
*/
|
|
12
|
+
export declare function recordWorkTarget(out: Readonly<Output>, owner: string, repository: string, issueNumber: number, title: string, options?: Readonly<RecordWorkTargetOptions>): void;
|
|
13
|
+
//# sourceMappingURL=work-target.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// 作業対象(.pecot-active と .pecot-session-title、作業ディレクトリ)を記録して、結果の行を出す。
|
|
2
|
+
import { InvalidValueError, ProjectRootNotFoundError } from '../domain/errors.js';
|
|
3
|
+
import { OsError, hasErrorCode, toOsError } from '../infra/os-error.js';
|
|
4
|
+
import { WORK_DIR } from '../infra/paths.js';
|
|
5
|
+
import { ensureWorkDirectory, writeWorkTarget } from '../infra/state-store.js';
|
|
6
|
+
import { stopWith } from './command-stop.js';
|
|
7
|
+
/**
|
|
8
|
+
記録の失敗として扱う例外か。OS の失敗・値の誤り・プロジェクトルート不明。プログラムの誤りは伝える
|
|
9
|
+
*/
|
|
10
|
+
function isRecordingFailure(error) {
|
|
11
|
+
return error instanceof OsError || error instanceof InvalidValueError || error instanceof ProjectRootNotFoundError || hasErrorCode(error);
|
|
12
|
+
}
|
|
13
|
+
function describeFailure(error) {
|
|
14
|
+
const converted = toOsError(error);
|
|
15
|
+
return converted instanceof Error ? converted.message : error.message;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
.pecot-active と .pecot-session-title を書き、`set: work target ...` の行を出す。
|
|
19
|
+
失敗は warning の行にする。failWithExit なら error の行を出して CommandExit(1) を投げる
|
|
20
|
+
*/
|
|
21
|
+
export function recordWorkTarget(out, owner, repository, issueNumber, title, options = {}) {
|
|
22
|
+
const issueReference = `${owner}/${repository}/${String(issueNumber)}`;
|
|
23
|
+
let target;
|
|
24
|
+
try {
|
|
25
|
+
writeWorkTarget(issueReference, title);
|
|
26
|
+
target = `work target ${issueReference}`;
|
|
27
|
+
if (ensureWorkDirectory(issueReference) !== undefined)
|
|
28
|
+
target += ` (work directory ${WORK_DIR}/${String(issueNumber)}/)`;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (!isRecordingFailure(error))
|
|
32
|
+
throw error;
|
|
33
|
+
if (options.failWithExit === true) {
|
|
34
|
+
stopWith(out, `could not record the work target: ${describeFailure(error)}`);
|
|
35
|
+
}
|
|
36
|
+
out.warning(`could not record the work target: ${describeFailure(error)}`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
out.done({ verb: 'set', target });
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=work-target.js.map
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/* eslint-disable security/detect-non-literal-fs-filename -- パスは検証済みの -D と、main worktree 配下の設定ファイル */
|
|
2
|
+
// worktree add / remove / init / link。4 個とも、本体の前に --repo と git の remote の食い違いを reject で止める。
|
|
3
|
+
import { mkdirSync, statSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { InvalidValueError } from '../domain/errors.js';
|
|
7
|
+
import { aggregationRepositoryReference, ConfigError } from '../domain/config.js';
|
|
8
|
+
import { loadActiveConfig } from '../infra/config-store.js';
|
|
9
|
+
import { gitToplevel } from '../infra/git.js';
|
|
10
|
+
import { hasErrorCode, OsError, toOsError } from '../infra/os-error.js';
|
|
11
|
+
import { resolveRealPath, WORKTREE_CONFIG_FILENAME, WORKTREE_IGNORE_FILENAME } from '../infra/paths.js';
|
|
12
|
+
import { createWorktree, detectProjectRoot, ensureDevcontainerEnvironment, findMainWorktree, findWorktreeConfigFile, getWorktreeDirectories, removeWorktree, WorktreeRuntimeError, } from '../infra/worktree.js';
|
|
13
|
+
import { createSymlinksSafe, DEFAULT_WORKTREEIGNORE_CONTENT, decideOverwrite, getDefaultConfig, loadConfig, planLink, saveConfig, WorktreeConfigError, } from '../infra/worktree-links.js';
|
|
14
|
+
import { createOutput, isConfirmed } from './output.js';
|
|
15
|
+
import { defineCommand } from './command-definition.js';
|
|
16
|
+
import { directorySchema } from './directory-option.js';
|
|
17
|
+
import { requireRepositoryMatch } from './repository-match.js';
|
|
18
|
+
const FAILURE = 1;
|
|
19
|
+
// click の realpath と同じく、解決できない所は字面のまま残して投げない
|
|
20
|
+
function lenientRealPath(value) {
|
|
21
|
+
try {
|
|
22
|
+
return resolveRealPath(value);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (!hasErrorCode(error))
|
|
26
|
+
throw error;
|
|
27
|
+
return path.resolve(value);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const dryRunInput = z.boolean().default(false).describe('Show what would happen without changing anything');
|
|
31
|
+
// WorktreeRuntimeError は最上位の網にかからないので、ここで error の行と終了コード 1 にする
|
|
32
|
+
function reportRuntimeError(out, error) {
|
|
33
|
+
if (!(error instanceof WorktreeRuntimeError))
|
|
34
|
+
throw error;
|
|
35
|
+
out.error(error.message);
|
|
36
|
+
return FAILURE;
|
|
37
|
+
}
|
|
38
|
+
function countLinkResults(results, out) {
|
|
39
|
+
out.count('symlinks created', results.filter(result => result.action === 'created').length);
|
|
40
|
+
const skipped = results.filter(result => result.action === 'skipped').length;
|
|
41
|
+
if (skipped > 0)
|
|
42
|
+
out.count('symlinks skipped', skipped);
|
|
43
|
+
const failed = results.filter(result => result.action === 'error').length;
|
|
44
|
+
if (failed > 0)
|
|
45
|
+
out.count('symlink errors', failed);
|
|
46
|
+
}
|
|
47
|
+
function countCopyResults(results, out) {
|
|
48
|
+
out.count('files copied', results.filter(result => result.action === 'copied').length);
|
|
49
|
+
const skipped = results.filter(result => result.action === 'skipped').length;
|
|
50
|
+
if (skipped > 0)
|
|
51
|
+
out.count('files skipped', skipped);
|
|
52
|
+
const failed = results.filter(result => result.action === 'error');
|
|
53
|
+
if (failed.length === 0)
|
|
54
|
+
return;
|
|
55
|
+
out.count('copy errors', failed.length);
|
|
56
|
+
for (const result of failed)
|
|
57
|
+
out.warning(`copy ${result.source}: ${result.message}`);
|
|
58
|
+
}
|
|
59
|
+
const worktreeAddInput = z.object({
|
|
60
|
+
directory: directorySchema,
|
|
61
|
+
base: z.string().optional().describe('Base branch (default: the develop_branch of the repository in the active project)'),
|
|
62
|
+
path: z.string().transform(lenientRealPath).optional().describe('Where to create the worktree (default: <project_root>/<auto-numbered>/<repository name>)'),
|
|
63
|
+
no_copy: z.boolean().default(false).describe('Skip copying untracked files'),
|
|
64
|
+
no_link: z.boolean().default(false).describe('Skip creating symlinks'),
|
|
65
|
+
setup: z.string().optional().describe('Command to run after creation'),
|
|
66
|
+
dry_run: dryRunInput,
|
|
67
|
+
allow_existing_branch: z.boolean().default(false).describe('Allow reusing an existing branch even if its upstream differs from develop_branch'),
|
|
68
|
+
});
|
|
69
|
+
const worktreeAddCommand = defineCommand({
|
|
70
|
+
path: ['worktree', 'add'],
|
|
71
|
+
description: 'Create a new worktree',
|
|
72
|
+
input: worktreeAddInput,
|
|
73
|
+
positional: [],
|
|
74
|
+
shortFlags: { directory: '-D' },
|
|
75
|
+
aliases: { allow_existing_branch: '--force' },
|
|
76
|
+
interactive: false,
|
|
77
|
+
run: (input, io) => Promise.resolve(runAdd(input, io)),
|
|
78
|
+
});
|
|
79
|
+
function runAdd(input, io) {
|
|
80
|
+
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
81
|
+
const out = createOutput(input.dry_run, io);
|
|
82
|
+
try {
|
|
83
|
+
ensureDevcontainerEnvironment();
|
|
84
|
+
const result = createWorktree(input.directory, out, {
|
|
85
|
+
baseBranch: input.base,
|
|
86
|
+
path: input.path,
|
|
87
|
+
shouldCopy: !input.no_copy,
|
|
88
|
+
shouldLink: !input.no_link,
|
|
89
|
+
setupCommand: input.setup,
|
|
90
|
+
isDryRun: input.dry_run,
|
|
91
|
+
isExistingBranchAllowed: input.allow_existing_branch,
|
|
92
|
+
});
|
|
93
|
+
const operation = { verb: 'create', target: `worktree ${result.name} at ${result.path} (branch ${result.branch} from ${result.baseBranch})` };
|
|
94
|
+
out.planned(operation);
|
|
95
|
+
out.done(operation);
|
|
96
|
+
out.data(result.path);
|
|
97
|
+
if (result.linkedFiles.length > 0)
|
|
98
|
+
countLinkResults(result.linkedFiles, out);
|
|
99
|
+
if (result.copiedFiles.length > 0)
|
|
100
|
+
countCopyResults(result.copiedFiles, out);
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return reportRuntimeError(out, error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const worktreeRemoveInput = z.object({
|
|
108
|
+
name: z.string().describe('Name of the worktree to remove (the recorded wtN, the wtN directory, or the branch name)'),
|
|
109
|
+
directory: directorySchema,
|
|
110
|
+
force: z.boolean().default(false).describe('Force removal even if there are changes'),
|
|
111
|
+
keep_branch: z.boolean().default(false).describe('Keep the branch'),
|
|
112
|
+
});
|
|
113
|
+
const worktreeRemoveCommand = defineCommand({
|
|
114
|
+
path: ['worktree', 'remove'],
|
|
115
|
+
description: 'Remove a worktree',
|
|
116
|
+
input: worktreeRemoveInput,
|
|
117
|
+
positional: ['name'],
|
|
118
|
+
shortFlags: { directory: '-D' },
|
|
119
|
+
interactive: false,
|
|
120
|
+
run: (input, io) => Promise.resolve(runRemove(input, io)),
|
|
121
|
+
});
|
|
122
|
+
function runRemove(input, io) {
|
|
123
|
+
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
124
|
+
const out = createOutput(false, io);
|
|
125
|
+
try {
|
|
126
|
+
ensureDevcontainerEnvironment();
|
|
127
|
+
const branchError = removeWorktree(input.directory, input.name, out, { isForced: input.force, shouldKeepBranch: input.keep_branch });
|
|
128
|
+
out.done({ verb: 'remove', target: `worktree ${input.name}` });
|
|
129
|
+
if (!input.keep_branch) {
|
|
130
|
+
if (branchError === undefined)
|
|
131
|
+
out.done({ verb: 'delete', target: `local branch ${input.name}` });
|
|
132
|
+
else
|
|
133
|
+
out.warning(`could not delete local branch ${input.name}: ${branchError}`);
|
|
134
|
+
}
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
return reportRuntimeError(out, error);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const worktreeInitInput = z.object({ directory: directorySchema });
|
|
142
|
+
const worktreeInitCommand = defineCommand({
|
|
143
|
+
path: ['worktree', 'init'],
|
|
144
|
+
description: 'Create the worktree config files in the main worktree',
|
|
145
|
+
input: worktreeInitInput,
|
|
146
|
+
positional: [],
|
|
147
|
+
shortFlags: { directory: '-D' },
|
|
148
|
+
interactive: false,
|
|
149
|
+
run: (input, io) => Promise.resolve(runInit(input, io)),
|
|
150
|
+
});
|
|
151
|
+
// 共有する 3 つのリンクの向き先は、アクティブなプロジェクトの aggregation_repo。無ければこのリポジトリ
|
|
152
|
+
function sharedLinkTarget(mainWorktree) {
|
|
153
|
+
const config = loadActiveConfig();
|
|
154
|
+
const aggregation = config === undefined ? undefined : aggregationRepositoryReference(config);
|
|
155
|
+
return aggregation === undefined ? path.basename(mainWorktree) : aggregation.repository;
|
|
156
|
+
}
|
|
157
|
+
function writeInitFiles(configFile, ignoreFile, config, out) {
|
|
158
|
+
try {
|
|
159
|
+
saveConfig(config, configFile);
|
|
160
|
+
out.done({ verb: 'create', target: `worktree config ${configFile}` });
|
|
161
|
+
mkdirSync(path.dirname(ignoreFile), { recursive: true });
|
|
162
|
+
writeFileSync(ignoreFile, DEFAULT_WORKTREEIGNORE_CONTENT);
|
|
163
|
+
out.done({ verb: 'create', target: `worktree ignore file ${ignoreFile}` });
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
throw hasErrorCode(error) ? toOsError(error) : error;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function runInit(input, io) {
|
|
170
|
+
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
171
|
+
const out = createOutput(false, io);
|
|
172
|
+
let mainWorktree;
|
|
173
|
+
try {
|
|
174
|
+
ensureDevcontainerEnvironment();
|
|
175
|
+
mainWorktree = findMainWorktree(input.directory);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
return reportRuntimeError(out, error);
|
|
179
|
+
}
|
|
180
|
+
const configFile = path.join(mainWorktree, WORKTREE_CONFIG_FILENAME);
|
|
181
|
+
const ignoreFile = path.join(mainWorktree, WORKTREE_IGNORE_FILENAME);
|
|
182
|
+
const existing = [configFile, ignoreFile].filter(file => isExistingFile(file));
|
|
183
|
+
if (existing.length > 0) {
|
|
184
|
+
out.error(['worktree config already exists', ...existing].join('\n'));
|
|
185
|
+
return FAILURE;
|
|
186
|
+
}
|
|
187
|
+
let targetRepository;
|
|
188
|
+
try {
|
|
189
|
+
targetRepository = sharedLinkTarget(mainWorktree);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
if (!(error instanceof InvalidValueError || error instanceof OsError || error instanceof ConfigError))
|
|
193
|
+
throw error;
|
|
194
|
+
out.error(`could not read the active config: ${error.message}`);
|
|
195
|
+
return FAILURE;
|
|
196
|
+
}
|
|
197
|
+
writeInitFiles(configFile, ignoreFile, getDefaultConfig(targetRepository, path.basename(mainWorktree)), out);
|
|
198
|
+
return 0;
|
|
199
|
+
}
|
|
200
|
+
function isMissingPath(error) {
|
|
201
|
+
return hasErrorCode(error) && (error.code === 'ENOENT' || error.code === 'ENOTDIR');
|
|
202
|
+
}
|
|
203
|
+
function isExistingFile(file) {
|
|
204
|
+
try {
|
|
205
|
+
statSync(file);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
if (isMissingPath(error))
|
|
210
|
+
return false;
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
const worktreeLinkInput = z.object({
|
|
215
|
+
directory: directorySchema,
|
|
216
|
+
force: z.boolean().default(false).describe('Overwrite real files and directories without asking'),
|
|
217
|
+
all: z.boolean().default(false).describe('Apply to all sub-worktrees'),
|
|
218
|
+
dry_run: dryRunInput,
|
|
219
|
+
});
|
|
220
|
+
const worktreeLinkCommand = defineCommand({
|
|
221
|
+
path: ['worktree', 'link'],
|
|
222
|
+
description: 'Apply or update symlinks in existing worktrees',
|
|
223
|
+
input: worktreeLinkInput,
|
|
224
|
+
positional: [],
|
|
225
|
+
shortFlags: { directory: '-D' },
|
|
226
|
+
interactive: true,
|
|
227
|
+
run: (input, io) => Promise.resolve(runLink(input, io)),
|
|
228
|
+
});
|
|
229
|
+
// 対象の worktree。--all はサブの全部(0 個もある)、無ければ -D を含む worktree のルート
|
|
230
|
+
function linkTargets(directory, mainWorktree, isAll) {
|
|
231
|
+
if (isAll)
|
|
232
|
+
return { kind: 'worktrees', directories: getWorktreeDirectories(directory) };
|
|
233
|
+
const resolvedDirectory = resolveRealPath(gitToplevel({ cwd: directory }) ?? directory);
|
|
234
|
+
return resolvedDirectory === resolveRealPath(mainWorktree) ? { kind: 'main-needs-all' } : { kind: 'worktrees', directories: [resolvedDirectory] };
|
|
235
|
+
}
|
|
236
|
+
function skipReason(plan) {
|
|
237
|
+
switch (plan) {
|
|
238
|
+
case 'skip-missing': {
|
|
239
|
+
return 'target does not exist';
|
|
240
|
+
}
|
|
241
|
+
case 'skip-dangling': {
|
|
242
|
+
return 'target is a dangling symlink';
|
|
243
|
+
}
|
|
244
|
+
case 'skip-real-file': {
|
|
245
|
+
return 'a real file exists';
|
|
246
|
+
}
|
|
247
|
+
case 'skip-tracked': {
|
|
248
|
+
return 'tracked by git';
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function plannedOperation(plan, symlinkPath, destination) {
|
|
253
|
+
if (plan === 'create')
|
|
254
|
+
return { verb: 'create', target: `symlink ${symlinkPath} -> ${destination}` };
|
|
255
|
+
if (plan === 'update')
|
|
256
|
+
return { verb: 'update', target: `symlink ${symlinkPath} -> ${destination}` };
|
|
257
|
+
if (plan === 'ask')
|
|
258
|
+
return { verb: 'update', target: `symlink ${symlinkPath} -> ${destination} (real file, asks first)` };
|
|
259
|
+
return { verb: 'skip', target: `symlink ${symlinkPath} (${skipReason(plan)})` };
|
|
260
|
+
}
|
|
261
|
+
function previewLinks(targets, config, projectRoot, options, out) {
|
|
262
|
+
const decision = decideOverwrite({ force: options.force, allWorktrees: options.all });
|
|
263
|
+
for (const target of targets) {
|
|
264
|
+
for (const link of config.links) {
|
|
265
|
+
const destination = path.join(projectRoot, 'base', link.target_repo, link.target_path);
|
|
266
|
+
out.planned(plannedOperation(planLink(link, projectRoot, target, decision), path.join(target, link.path), destination));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// 1 つの worktree にリンクを作り、(作った数, 飛ばした数, 失敗した数) を返す
|
|
271
|
+
function applyLinks(target, config, projectRoot, options, io, out) {
|
|
272
|
+
const decision = decideOverwrite({ force: options.force, allWorktrees: options.all });
|
|
273
|
+
const results = createSymlinksSafe(config, projectRoot, target, out, {
|
|
274
|
+
force: decision.force,
|
|
275
|
+
confirm: decision.ask ? symlinkPath => isConfirmed(io, `real file exists: ${symlinkPath}\noverwrite it?`) : undefined,
|
|
276
|
+
});
|
|
277
|
+
const created = results.filter(result => result.action === 'created');
|
|
278
|
+
const skipped = results.filter(result => result.action === 'skipped');
|
|
279
|
+
out.count(`symlinks created in ${target}`, created.length);
|
|
280
|
+
for (const result of skipped)
|
|
281
|
+
out.done({ verb: 'skip', target: `symlink ${result.symlinkPath} (${result.message})` });
|
|
282
|
+
return [created.length, skipped.length, results.filter(result => result.action === 'error').length];
|
|
283
|
+
}
|
|
284
|
+
function runLink(input, io) {
|
|
285
|
+
requireRepositoryMatch('reject', input.repo, io, process.cwd());
|
|
286
|
+
const out = createOutput(input.dry_run, io);
|
|
287
|
+
try {
|
|
288
|
+
ensureDevcontainerEnvironment();
|
|
289
|
+
const configFile = findWorktreeConfigFile(input.directory);
|
|
290
|
+
if (configFile === undefined) {
|
|
291
|
+
out.error('worktree config not found\nrun: pecot worktree init -D <directory>');
|
|
292
|
+
return FAILURE;
|
|
293
|
+
}
|
|
294
|
+
const config = loadConfig(configFile);
|
|
295
|
+
const mainWorktree = findMainWorktree(input.directory);
|
|
296
|
+
const projectRoot = detectProjectRoot(input.directory);
|
|
297
|
+
const resolved = linkTargets(input.directory, mainWorktree, input.all);
|
|
298
|
+
if (resolved.kind === 'main-needs-all') {
|
|
299
|
+
out.error('use --all in the main worktree');
|
|
300
|
+
return FAILURE;
|
|
301
|
+
}
|
|
302
|
+
const targets = resolved.directories;
|
|
303
|
+
if (targets.length === 0) {
|
|
304
|
+
out.count('sub-worktrees', 0);
|
|
305
|
+
return 0;
|
|
306
|
+
}
|
|
307
|
+
const options = { force: input.force, all: input.all };
|
|
308
|
+
if (input.dry_run) {
|
|
309
|
+
previewLinks(targets, config, projectRoot, options, out);
|
|
310
|
+
return 0;
|
|
311
|
+
}
|
|
312
|
+
let [created, skipped, failed] = [0, 0, 0];
|
|
313
|
+
for (const target of targets) {
|
|
314
|
+
const [targetCreated, targetSkipped, targetFailed] = applyLinks(target, config, projectRoot, options, io, out);
|
|
315
|
+
created += targetCreated;
|
|
316
|
+
skipped += targetSkipped;
|
|
317
|
+
failed += targetFailed;
|
|
318
|
+
}
|
|
319
|
+
if (targets.length > 1) {
|
|
320
|
+
out.count('symlinks created', created);
|
|
321
|
+
out.count('symlinks skipped', skipped);
|
|
322
|
+
out.count('symlink errors', failed);
|
|
323
|
+
}
|
|
324
|
+
return 0;
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
if (error instanceof WorktreeConfigError) {
|
|
328
|
+
out.error(error.message);
|
|
329
|
+
return FAILURE;
|
|
330
|
+
}
|
|
331
|
+
return reportRuntimeError(out, error);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
export const WORKTREE_COMMANDS = [worktreeAddCommand, worktreeRemoveCommand, worktreeInitCommand, worktreeLinkCommand];
|
|
335
|
+
//# sourceMappingURL=worktree.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
API の失敗の message に、応答本文の詳細を添える。GitHubAPIError と DependabotFailure をそのまま渡せる。
|
|
3
|
+
本文が JSON でない(HTML 等)か、添える文が無いときは message のまま返す。
|
|
4
|
+
422 では理由が errors[].message にだけ入ることがある
|
|
5
|
+
*/
|
|
6
|
+
export declare function describeApiError(failure: Readonly<{
|
|
7
|
+
message: string;
|
|
8
|
+
responseBody?: string | undefined;
|
|
9
|
+
}>): string;
|
|
10
|
+
//# sourceMappingURL=api-error-detail.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// API エラーの message に、応答本文 JSON の message と errors[].message を添える。GitHub API の失敗の説明の、唯一の実装。
|
|
2
|
+
import { isJsonObject, jsonField, tryParseJsonText } from './json.js';
|
|
3
|
+
import { pythonStrip } from './python-format.js';
|
|
4
|
+
function textOf(value) {
|
|
5
|
+
return typeof value === 'string' && pythonStrip(value) !== '' ? pythonStrip(value) : undefined;
|
|
6
|
+
}
|
|
7
|
+
function errorMessages(errors) {
|
|
8
|
+
if (!Array.isArray(errors))
|
|
9
|
+
return [];
|
|
10
|
+
const items = errors;
|
|
11
|
+
return items.map(item => textOf(jsonField(item, 'message')));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
API の失敗の message に、応答本文の詳細を添える。GitHubAPIError と DependabotFailure をそのまま渡せる。
|
|
15
|
+
本文が JSON でない(HTML 等)か、添える文が無いときは message のまま返す。
|
|
16
|
+
422 では理由が errors[].message にだけ入ることがある
|
|
17
|
+
*/
|
|
18
|
+
export function describeApiError(failure) {
|
|
19
|
+
const body = tryParseJsonText(failure.responseBody ?? '');
|
|
20
|
+
if (!isJsonObject(body))
|
|
21
|
+
return failure.message;
|
|
22
|
+
const details = [textOf(body['message']), ...errorMessages(body['errors'])].filter(detail => detail !== undefined);
|
|
23
|
+
return details.length === 0 ? failure.message : `${failure.message} ${details.join(' ')}`;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=api-error-detail.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// ブランチ名の読み取り。pecot create-branch が作る名前は、末尾が `/Issue番号` になる。
|
|
2
|
+
import { parsePythonInteger } from './python-format.js';
|
|
3
|
+
/**
|
|
4
|
+
ブランチ名の末尾の Issue 番号。末尾が数字だけの区切りでなければ undefined
|
|
5
|
+
*/
|
|
6
|
+
export function extractIssueNumberFromBranch(branch) {
|
|
7
|
+
const last = branch.split('/').at(-1) ?? '';
|
|
8
|
+
return /^\p{Nd}+$/u.test(last) ? parsePythonInteger(last) : undefined;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=branch-name.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PecotError, BaseError } from './errors.js';
|
|
2
|
+
export declare class ChangelogError extends PecotError {
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
セマンティックバージョニング形式(X.Y.Z)に準拠していない
|
|
6
|
+
*/
|
|
7
|
+
export declare class InvalidVersionError extends ChangelogError {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
CHANGELOG.md にバージョン情報が存在しない
|
|
11
|
+
*/
|
|
12
|
+
export declare class VersionNotFoundError extends ChangelogError {
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
CHANGELOG.md が存在しない。Python の FileNotFoundError に当たるので、PecotError ではない
|
|
16
|
+
*/
|
|
17
|
+
export declare class ChangelogFileNotFoundError extends BaseError {
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_CHANGELOG_FILE = "CHANGELOG.md";
|
|
20
|
+
export declare const CHANGELOG_FALLBACK_FILES: readonly string[];
|
|
21
|
+
/**
|
|
22
|
+
パス末尾のファイル名。エラー文に、実際に探したファイルの名前を出すために使う
|
|
23
|
+
*/
|
|
24
|
+
export declare function changelogFileName(changelogPath: string): string;
|
|
25
|
+
/**
|
|
26
|
+
CHANGELOG が無いときの文
|
|
27
|
+
*/
|
|
28
|
+
export declare function changelogNotFoundMessage(changelogPath: string): string;
|
|
29
|
+
/**
|
|
30
|
+
セマンティックバージョニング形式を検証する。形式違反は InvalidVersionError
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateSemver(version: string): void;
|
|
33
|
+
/**
|
|
34
|
+
## [X.Y.Z] 形式の最初のバージョンを返す。Unreleased は飛ばす。無ければ VersionNotFoundError。
|
|
35
|
+
fileName は、エラー文に出す CHANGELOG のファイル名
|
|
36
|
+
*/
|
|
37
|
+
export declare function getLatestVersion(content: string, fileName?: string): string;
|
|
38
|
+
/**
|
|
39
|
+
## [X.Y.Z] の次の行から次の `## ` セクションまでの内容を返す。無ければ VersionNotFoundError。
|
|
40
|
+
fileName は、エラー文に出す CHANGELOG のファイル名
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractVersionReleaseNotes(content: string, version: string, fileName?: string): string;
|
|
43
|
+
//# sourceMappingURL=changelog.d.ts.map
|