specdojo 0.5.0 → 0.6.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/.github/agents/specdojo-orchestrator.md +2 -0
- package/CHANGELOG.md +60 -0
- package/dist/catalog/generate.js +144 -13
- package/dist/commands/init.js +1 -0
- package/dist/deliverable/deliverable.js +77 -4
- package/dist/exec/core.js +1 -0
- package/dist/exec/parent-validation.js +7 -0
- package/dist/exec/plans-core.js +46 -1
- package/dist/exec/plans-generation.js +39 -3
- package/dist/exec/plans-planning.js +1 -1
- package/dist/exec/plans-storage.js +1 -0
- package/dist/exec/product-branch-records.js +105 -0
- package/dist/exec/product-branches.js +52 -0
- package/dist/exec/register-product-message.js +50 -0
- package/dist/exec/register.js +6 -0
- package/dist/exec/repo-integration-sync.js +4 -2
- package/dist/exec/repo-integration.js +41 -4
- package/dist/exec/repo-trace.js +2 -0
- package/dist/exec/results.js +9 -5
- package/dist/exec/run/register-command.js +16 -0
- package/dist/exec/run/register-resume.js +11 -1
- package/dist/exec/run/register-worktree.js +29 -8
- package/dist/exec/run/schedule-prepare.js +7 -3
- package/dist/exec/strategy.js +2 -1
- package/dist/exec/task-repos.js +78 -16
- package/dist/exec/worktree-command.js +2 -2
- package/dist/exec/worktree.js +3 -3
- package/dist/register/core.js +5 -0
- package/dist/register/create-commands.js +54 -2
- package/dist/register/deliverable-target.js +24 -17
- package/dist/register/event-merge.js +4 -0
- package/dist/register/events.js +6 -0
- package/dist/register/external-project.js +2 -0
- package/dist/register/input.js +168 -0
- package/dist/register/item.js +61 -0
- package/dist/register/register.js +2 -2
- package/dist/register/renumber.js +4 -0
- package/dist/register/update.js +6 -0
- package/dist/schedule/approach.js +9 -0
- package/dist/schedule/strategy-profiles.js +22 -2
- package/dist/shared/agent-types.js +4 -1
- package/dist/shared/branch-template.js +26 -0
- package/dist/shared/commit-message-template.js +38 -0
- package/dist/shared/commit-types.js +15 -0
- package/dist/shared/specdojo-config.js +35 -4
- package/docs/ja/specdojo/exec-templates/xep-draft-template.md +93 -0
- package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +9 -2
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +2 -0
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +2 -0
- package/docs/ja/specdojo/exec-templates/xer-human-bootstrap-finalize-template.md +2 -0
- package/docs/ja/specdojo/exec-templates/xer-human-draft-template.md +23 -0
- package/docs/ja/specdojo/exec-templates/xer-human-finalize-template.md +2 -0
- package/docs/ja/specdojo/exec-templates/xrp-fully-guided-template.md +7 -4
- package/docs/ja/specdojo/guides/exec-config-guide.md +3 -1
- package/docs/ja/specdojo/guides/exec-operation-guide.md +96 -2
- package/docs/ja/specdojo/guides/register-operation-guide.md +14 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +1 -1
- package/docs/ja/specdojo/guides/ryu-guide.md +114 -23
- package/docs/ja/specdojo/guides/schedule-design-guide.md +31 -4
- package/docs/ja/specdojo/recipes/exec-human-finalize-recipe.md +1 -0
- package/docs/ja/specdojo/recipes/tsd-recipe.md +20 -12
- package/docs/ja/specdojo/references/command-reference.md +44 -11
- package/docs/ja/specdojo/references/specdojo-config-reference.md +69 -8
- package/docs/ja/specdojo/rulebooks/dct-rulebook.md +8 -0
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +4 -0
- package/docs/ja/specdojo/rulebooks/sch-rulebook.md +3 -1
- package/docs/ja/specdojo/samples/dct-sample.yaml +5 -1
- package/docs/ja/specdojo/standards/document-metadata-standard.md +16 -0
- package/docs/ja/specdojo/standards/exec-human-finalize-standard.md +1 -0
- package/docs/ja/specdojo/standards/guide-authoring-standard.md +2 -1
- package/docs/ja/specdojo/standards/philosophy-authoring-standard.md +1 -0
- package/docs/ja/specdojo/standards/recipe-authoring-standard.md +2 -1
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -1
- package/docs/ja/specdojo/standards/standard-authoring-standard.md +2 -1
- package/docs/ja/specdojo/templates/pjr-change-request-template.md +10 -4
- package/docs/ja/specdojo/templates/pjr-issue-template.md +10 -4
- package/docs/ja/specdojo/templates/pjr-question-template.md +11 -5
- package/docs/ja/specdojo/templates/pjr-risk-template.md +10 -4
- package/docs/ja/specdojo/templates/pjr-todo-template.md +10 -4
- package/docs/specdojo/schemas/v1/dct.schema.yaml +9 -0
- package/docs/specdojo/schemas/v1/exec-common.schema.yaml +2 -1
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +1 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +35 -0
- package/docs/specdojo/schemas/v1/sch-strategy.schema.yaml +1 -0
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +40 -2
- package/package.json +3 -2
- package/templates/antigravity/orchestrator.md +2 -0
- package/templates/claude/agents/specdojo-orchestrator.md +2 -0
- package/templates/codex/agents/specdojo-orchestrator.toml +2 -0
- package/templates/codex/orchestrator.md +2 -0
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +14 -8
- package/templates/opencode/agents/specdojo-orchestrator.md +2 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { unified } from "unified";
|
|
2
|
+
import remarkParse from "remark-parse";
|
|
3
|
+
import { escapeMarkdownInline } from "../shared/text.js";
|
|
4
|
+
function isHeadingNode(node) {
|
|
5
|
+
return (node.type === "heading" &&
|
|
6
|
+
node.position?.start.offset !== undefined &&
|
|
7
|
+
node.position?.end.offset !== undefined);
|
|
8
|
+
}
|
|
9
|
+
function headingTitle(body, node) {
|
|
10
|
+
return body
|
|
11
|
+
.slice(node.position.start.offset, node.position.end.offset)
|
|
12
|
+
.replace(/^#+\s+/, "")
|
|
13
|
+
.replace(/\s+#+\s*$/, "")
|
|
14
|
+
.trim();
|
|
15
|
+
}
|
|
16
|
+
// 本文の見出しだけを探す。コード例・引用内の「入力」は節として扱わない。
|
|
17
|
+
function findInputSection(content) {
|
|
18
|
+
const prefix = content.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/)?.[0] ?? "";
|
|
19
|
+
const body = content.slice(prefix.length);
|
|
20
|
+
if (!/^##\s+(?:\d+\.\s*)?入力(?:\s|$)/m.test(body))
|
|
21
|
+
return undefined;
|
|
22
|
+
const nodes = unified().use(remarkParse).parse(body).children;
|
|
23
|
+
const index = nodes.findIndex((node) => isHeadingNode(node) &&
|
|
24
|
+
node.depth === 2 &&
|
|
25
|
+
/^(?:\d+\.\s*)?入力$/.test(headingTitle(body, node)));
|
|
26
|
+
if (index < 0)
|
|
27
|
+
return undefined;
|
|
28
|
+
const heading = nodes[index];
|
|
29
|
+
if (!isHeadingNode(heading))
|
|
30
|
+
return undefined;
|
|
31
|
+
const title = headingTitle(body, heading);
|
|
32
|
+
const isNumbered = /^\d+\.\s*入力$/.test(title);
|
|
33
|
+
const next = nodes.slice(index + 1).findIndex((node) => isHeadingNode(node) && node.depth <= 2);
|
|
34
|
+
const endIndex = next < 0 ? nodes.length : index + 1 + next;
|
|
35
|
+
return {
|
|
36
|
+
body,
|
|
37
|
+
nodes: nodes.slice(index + 1, endIndex),
|
|
38
|
+
isNumbered,
|
|
39
|
+
sectionStart: prefix.length + heading.position.start.offset,
|
|
40
|
+
start: prefix.length + heading.position.end.offset,
|
|
41
|
+
end: prefix.length + (nodes[endIndex]?.position?.start.offset ?? body.length),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function readRegisterInput(content) {
|
|
45
|
+
const section = findInputSection(content);
|
|
46
|
+
if (!section)
|
|
47
|
+
return undefined;
|
|
48
|
+
const inputs = section.nodes
|
|
49
|
+
.flatMap((node) => node.type === "list"
|
|
50
|
+
? node.children.map((item) => section.body
|
|
51
|
+
.slice(item.position.start.offset, item.position.end.offset)
|
|
52
|
+
.replace(/^(?:[-*+]|\d+[.)])\s+/, "")
|
|
53
|
+
.replace(/\r?\n {2}/g, "\n")
|
|
54
|
+
.trim())
|
|
55
|
+
: [])
|
|
56
|
+
.filter((value) => value !== "" && value !== "-");
|
|
57
|
+
return inputs.length > 0 ? inputs : undefined;
|
|
58
|
+
}
|
|
59
|
+
export function normalizeRegisterInput(values, allowRemove = false) {
|
|
60
|
+
if (values === undefined)
|
|
61
|
+
return undefined;
|
|
62
|
+
const inputs = values.map((value) => value.replace(/\r\n/g, "\n").trim());
|
|
63
|
+
if (inputs.includes("-")) {
|
|
64
|
+
if (!allowRemove)
|
|
65
|
+
throw new Error("--input - is only valid with register update");
|
|
66
|
+
if (inputs.length !== 1)
|
|
67
|
+
throw new Error("--input - cannot be combined with other inputs");
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
if (inputs.some((value) => value === ""))
|
|
71
|
+
throw new Error("--input must contain non-empty text");
|
|
72
|
+
return inputs;
|
|
73
|
+
}
|
|
74
|
+
export function registerInputMarkdown(inputs) {
|
|
75
|
+
return inputs
|
|
76
|
+
.map((input) => `- ${escapeMarkdownInline(input).replace(/\n/g, "\n ")}`)
|
|
77
|
+
.join("\n");
|
|
78
|
+
}
|
|
79
|
+
export function setRegisterInput(content, inputs) {
|
|
80
|
+
const existingSection = findInputSection(content);
|
|
81
|
+
const text = inputs.length > 0 ? registerInputMarkdown(inputs) : "-";
|
|
82
|
+
// すでに番号付きの入力章がある場合は、既存の位置・番号のまま中身を置換する
|
|
83
|
+
if (existingSection && existingSection.isNumbered) {
|
|
84
|
+
const tail = content.slice(existingSection.end);
|
|
85
|
+
return `${content.slice(0, existingSection.start)}\n\n${text}\n${tail ? `\n${tail}` : ""}`;
|
|
86
|
+
}
|
|
87
|
+
// 番号なしの「## 入力」がある場合は一旦除去する
|
|
88
|
+
let cleanContent = content;
|
|
89
|
+
if (existingSection && !existingSection.isNumbered) {
|
|
90
|
+
if (existingSection.end >= content.length) {
|
|
91
|
+
cleanContent = `${content.slice(0, existingSection.sectionStart).trimEnd()}\n`;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const before = content.slice(0, existingSection.sectionStart).trimEnd();
|
|
95
|
+
const after = content.slice(existingSection.end).trimStart();
|
|
96
|
+
cleanContent = `${before}\n\n${after}`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const prefix = cleanContent.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/)?.[0] ?? "";
|
|
100
|
+
const body = cleanContent.slice(prefix.length);
|
|
101
|
+
const nodes = unified().use(remarkParse).parse(body).children;
|
|
102
|
+
const h2Nodes = nodes.filter((node) => isHeadingNode(node) && node.depth === 2);
|
|
103
|
+
// H2 見出しが 1 つもない場合
|
|
104
|
+
if (h2Nodes.length === 0) {
|
|
105
|
+
return `${cleanContent.trimEnd()}\n\n## 1. 入力\n\n${text}\n`;
|
|
106
|
+
}
|
|
107
|
+
const firstH2 = h2Nodes[0];
|
|
108
|
+
const firstTitle = headingTitle(body, firstH2);
|
|
109
|
+
const firstMatch = firstTitle.match(/^(\d+)\./);
|
|
110
|
+
const inputNum = firstMatch ? parseInt(firstMatch[1], 10) + 1 : 2;
|
|
111
|
+
const inputSectionText = `## ${inputNum}. 入力\n\n${text}\n\n`;
|
|
112
|
+
// 第1章のみで、第2章以降がない場合
|
|
113
|
+
if (h2Nodes.length === 1) {
|
|
114
|
+
return `${prefix}${body.trimEnd()}\n\n## ${inputNum}. 入力\n\n${text}\n`;
|
|
115
|
+
}
|
|
116
|
+
// 第2章以降がある場合: 第2章の直前に挿入し、以降の見出し番号を繰り下げる
|
|
117
|
+
const splitOffset = h2Nodes[1].position.start.offset;
|
|
118
|
+
const head = `${body.slice(0, splitOffset).trimEnd()}\n\n`;
|
|
119
|
+
const tail = body.slice(splitOffset);
|
|
120
|
+
const edits = [];
|
|
121
|
+
let currentOldH2Num;
|
|
122
|
+
for (const node of nodes) {
|
|
123
|
+
if (!isHeadingNode(node) || node.position.start.offset < splitOffset)
|
|
124
|
+
continue;
|
|
125
|
+
const startInTail = node.position.start.offset - splitOffset;
|
|
126
|
+
const endInTail = node.position.end.offset - splitOffset;
|
|
127
|
+
const raw = tail.slice(startInTail, endInTail);
|
|
128
|
+
if (node.depth === 2) {
|
|
129
|
+
const match = raw.match(/^(##\s+)(\d+)(\..*)$/);
|
|
130
|
+
if (match) {
|
|
131
|
+
const oldNum = parseInt(match[2], 10);
|
|
132
|
+
const newNum = oldNum + 1;
|
|
133
|
+
currentOldH2Num = oldNum;
|
|
134
|
+
edits.push({
|
|
135
|
+
start: startInTail,
|
|
136
|
+
end: endInTail,
|
|
137
|
+
replacement: `${match[1]}${newNum}${match[3]}`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
currentOldH2Num = undefined;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else if (node.depth > 2 && currentOldH2Num !== undefined) {
|
|
145
|
+
const subMatch = raw.match(/^(#{3,6}\s+)(\d+)(\..*)$/);
|
|
146
|
+
if (subMatch && parseInt(subMatch[2], 10) === currentOldH2Num) {
|
|
147
|
+
const newNum = currentOldH2Num + 1;
|
|
148
|
+
edits.push({
|
|
149
|
+
start: startInTail,
|
|
150
|
+
end: endInTail,
|
|
151
|
+
replacement: `${subMatch[1]}${newNum}${subMatch[3]}`,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// 後ろから適用してオフセットのズレを防ぐ
|
|
157
|
+
edits.sort((a, b) => b.start - a.start);
|
|
158
|
+
let updatedTail = tail;
|
|
159
|
+
for (const edit of edits) {
|
|
160
|
+
updatedTail = updatedTail.slice(0, edit.start) + edit.replacement + updatedTail.slice(edit.end);
|
|
161
|
+
}
|
|
162
|
+
return `${prefix}${head}${inputSectionText}${updatedTail}`;
|
|
163
|
+
}
|
|
164
|
+
export function registerInputSection(inputs) {
|
|
165
|
+
return inputs?.length
|
|
166
|
+
? `## 個票の入力(前提)\n\n次の入力を作業の前提として参照する。完了条件は別節に従う。\n\n${registerInputMarkdown(inputs)}\n`
|
|
167
|
+
: "";
|
|
168
|
+
}
|
package/dist/register/item.js
CHANGED
|
@@ -7,6 +7,7 @@ import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { dump, load } from "../shared/yaml.js";
|
|
9
9
|
import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
10
|
+
import { readRegisterInput } from "./input.js";
|
|
10
11
|
import { registerDateFromTimestamp } from "./date.js";
|
|
11
12
|
export const VALID_STATUSES = [
|
|
12
13
|
"open",
|
|
@@ -30,6 +31,17 @@ export const VALID_TYPES = [
|
|
|
30
31
|
];
|
|
31
32
|
export const VALID_PRIORITIES = ["high", "medium", "low"];
|
|
32
33
|
export const VALID_DIFFICULTIES = ["hard", "medium", "easy"];
|
|
34
|
+
export { VALID_COMMIT_TYPES, COMMIT_SCOPE_RE } from "../shared/commit-types.js";
|
|
35
|
+
export const DEFAULT_ITEM_TYPE_COMMIT_TYPE_MAP = {
|
|
36
|
+
issue: "fix",
|
|
37
|
+
todo: "feat",
|
|
38
|
+
"change-request": "feat",
|
|
39
|
+
decision: "docs",
|
|
40
|
+
note: "docs",
|
|
41
|
+
question: "docs",
|
|
42
|
+
risk: "docs",
|
|
43
|
+
epic: "feat",
|
|
44
|
+
};
|
|
33
45
|
export const TERMINAL_STATUSES_SET = new Set(["done", "decided", "rejected", "deferred"]);
|
|
34
46
|
// PJR-ID の乱数部分に使う 32 文字セット。曖昧文字(`I` / `L` / `O` / `U`)を除いた
|
|
35
47
|
// 英大文字(単一ケース)と数字で構成し、目視・手入力時の誤読を避ける。
|
|
@@ -71,6 +83,8 @@ const SPECDOJO_KEY_ORDER = [
|
|
|
71
83
|
"derived_from",
|
|
72
84
|
"depends_on",
|
|
73
85
|
"autopilot",
|
|
86
|
+
"commit_type",
|
|
87
|
+
"commit_scope",
|
|
74
88
|
"approach",
|
|
75
89
|
"targets",
|
|
76
90
|
"sources",
|
|
@@ -235,12 +249,16 @@ export function readRegisterItemContent(content, filename) {
|
|
|
235
249
|
? fields.depends_on.filter((value) => typeof value === "string" && value.trim() !== "")
|
|
236
250
|
: undefined;
|
|
237
251
|
const autopilot = fields.autopilot === "approved" ? "approved" : undefined;
|
|
252
|
+
const commitType = asString(fields.commit_type);
|
|
253
|
+
const commitScope = asString(fields.commit_scope);
|
|
238
254
|
const difficulty = asString(fields.difficulty);
|
|
255
|
+
const inputs = readRegisterInput(content);
|
|
239
256
|
const item = {
|
|
240
257
|
id,
|
|
241
258
|
status: asString(fields.item_status) ?? "open",
|
|
242
259
|
title: titleFromBody(body, id),
|
|
243
260
|
description: descriptionFromBody(body),
|
|
261
|
+
...(inputs ? { inputs } : {}),
|
|
244
262
|
type: asString(fields.item_type) ?? CELL_TODO,
|
|
245
263
|
...(asString(fields.track) ? { track: asString(fields.track) } : {}),
|
|
246
264
|
priority: asString(fields.priority) ?? "medium",
|
|
@@ -264,6 +282,8 @@ export function readRegisterItemContent(content, filename) {
|
|
|
264
282
|
...(derivedFrom && derivedFrom.length > 0 ? { derivedFrom } : {}),
|
|
265
283
|
...(dependsOn && dependsOn.length > 0 ? { dependsOn } : {}),
|
|
266
284
|
...(autopilot ? { autopilot } : {}),
|
|
285
|
+
...(commitType ? { commitType } : {}),
|
|
286
|
+
...(commitScope ? { commitScope } : {}),
|
|
267
287
|
};
|
|
268
288
|
return {
|
|
269
289
|
id,
|
|
@@ -393,6 +413,8 @@ export function registerItemFieldsFromItem(item) {
|
|
|
393
413
|
...(item.derivedFrom && item.derivedFrom.length > 0 ? { derived_from: item.derivedFrom } : {}),
|
|
394
414
|
...(item.dependsOn && item.dependsOn.length > 0 ? { depends_on: item.dependsOn } : {}),
|
|
395
415
|
...(item.autopilot ? { autopilot: item.autopilot } : {}),
|
|
416
|
+
...(item.commitType ? { commit_type: item.commitType } : {}),
|
|
417
|
+
...(item.commitScope ? { commit_scope: item.commitScope } : {}),
|
|
396
418
|
};
|
|
397
419
|
}
|
|
398
420
|
function orderSpecdojoKeys(fields) {
|
|
@@ -557,3 +579,42 @@ export function formatRegisterItemFields(updates) {
|
|
|
557
579
|
})
|
|
558
580
|
.join("\n");
|
|
559
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* 登録項目の commit の type と scope を解決する。
|
|
584
|
+
* 後続の項目(PJR-Z7GX・PJR-M1DH)から 1 つの関数で引ける共通関数。
|
|
585
|
+
*
|
|
586
|
+
* 解決優先順序:
|
|
587
|
+
* 1. 個票の `commit_type` / `commit_scope`(指定があれば最優先)
|
|
588
|
+
* 2. プロダクトリポジトリ設定(`repoConfig.commit_types`)
|
|
589
|
+
* 3. プロジェクト設定(`projectConfig.commit_types`)
|
|
590
|
+
* 4. 既定の対応マッピング(issue -> fix, todo -> feat, change-request -> feat 等)
|
|
591
|
+
* 5. 上記に該当しない未知の type は "chore"
|
|
592
|
+
*/
|
|
593
|
+
export function resolveItemCommitTypeAndScope(item, options) {
|
|
594
|
+
const scope = item.commitScope?.trim() ? item.commitScope.trim() : undefined;
|
|
595
|
+
// 1. 個票の明示指定
|
|
596
|
+
if (item.commitType && item.commitType.trim() !== "") {
|
|
597
|
+
return { type: item.commitType.trim(), ...(scope ? { scope } : {}) };
|
|
598
|
+
}
|
|
599
|
+
// 2. repoConfig の指定
|
|
600
|
+
const repoTypes = options?.repoConfig?.commit_types;
|
|
601
|
+
const repoType = repoTypes && Object.hasOwn(repoTypes, item.type) ? repoTypes[item.type] : undefined;
|
|
602
|
+
if (repoType && repoType.trim() !== "") {
|
|
603
|
+
return { type: repoType.trim(), ...(scope ? { scope } : {}) };
|
|
604
|
+
}
|
|
605
|
+
// 3. projectConfig の指定
|
|
606
|
+
const projectTypes = options?.projectConfig?.commit_types;
|
|
607
|
+
const projectType = projectTypes && Object.hasOwn(projectTypes, item.type) ? projectTypes[item.type] : undefined;
|
|
608
|
+
if (projectType && projectType.trim() !== "") {
|
|
609
|
+
return { type: projectType.trim(), ...(scope ? { scope } : {}) };
|
|
610
|
+
}
|
|
611
|
+
// 4. 既定マッピング
|
|
612
|
+
const defaultType = Object.hasOwn(DEFAULT_ITEM_TYPE_COMMIT_TYPE_MAP, item.type)
|
|
613
|
+
? DEFAULT_ITEM_TYPE_COMMIT_TYPE_MAP[item.type]
|
|
614
|
+
: undefined;
|
|
615
|
+
if (defaultType) {
|
|
616
|
+
return { type: defaultType, ...(scope ? { scope } : {}) };
|
|
617
|
+
}
|
|
618
|
+
// 5. フォールバック
|
|
619
|
+
return { type: "chore", ...(scope ? { scope } : {}) };
|
|
620
|
+
}
|
|
@@ -10,7 +10,7 @@ import { validateRegisterDependencyDocs } from "./dependency.js";
|
|
|
10
10
|
import { validateDerivedFromDocs } from "./derivation.js";
|
|
11
11
|
import { appendRegisterEvent, deterministicRegisterEventId, readEmbeddedRegisterEvents, readRegisterEventsFromContent, registerEventFilePath, removeEmbeddedRegisterEvents, serializeRegisterEvents, validateRegisterEventDocs, } from "./events.js";
|
|
12
12
|
import { collectRegisterHistoryEvents } from "./history.js";
|
|
13
|
-
import { loadRegisterItemDocs, PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, toCell, validateRegisterItemDocs, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, } from "./item.js";
|
|
13
|
+
import { loadRegisterItemDocs, PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, toCell, validateRegisterItemDocs, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, VALID_COMMIT_TYPES, COMMIT_SCOPE_RE, DEFAULT_ITEM_TYPE_COMMIT_TYPE_MAP, resolveItemCommitTypeAndScope, } from "./item.js";
|
|
14
14
|
import { registerMaintenanceCommands } from "./maintenance-commands.js";
|
|
15
15
|
import { applyRegisterMigrationPlan, planRegisterMigration } from "./migration.js";
|
|
16
16
|
import { planRenumber, planRetopic, renumberPjrItem, retopicPjrItem, ticketTopicFromFilename, } from "./renumber.js";
|
|
@@ -20,7 +20,7 @@ import { generateDerivedViewFiles, loadRegisterItems, VALID_BUILD_SCOPES, writeD
|
|
|
20
20
|
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
21
21
|
import { registerLifecyclePoolPath } from "./lifecycle-lock.js";
|
|
22
22
|
import { inCrossProjectWorktree, resolveCrossProjectMutationTarget } from "./cross-project.js";
|
|
23
|
-
export { PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, toCell, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, };
|
|
23
|
+
export { PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, toCell, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, VALID_COMMIT_TYPES, COMMIT_SCOPE_RE, DEFAULT_ITEM_TYPE_COMMIT_TYPE_MAP, resolveItemCommitTypeAndScope, };
|
|
24
24
|
export { REGISTER_TOPIC_RE, VALID_TICKET_STATUSES, buildRegisterItemContent, extractTableHeading, findMarkdownReferenceFiles, generatePjrId, injectRegisterRows, parsePjrIndex, resolveRegisterPaths, } from "./core.js";
|
|
25
25
|
export { applyRegisterMigrationPlan, planRegisterMigration, } from "./migration.js";
|
|
26
26
|
export { findItemById, findRegisterItem, generateDerivedViewFiles, injectViewSlots, loadRegisterItems, sortByRegisteredDesc, } from "./views.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setRegisterInput } from "./input.js";
|
|
1
2
|
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
2
3
|
import { basename, join } from "node:path";
|
|
3
4
|
import { atomicWriteFile, findMarkdownReferenceFiles, formatTableRow, isTableSeparator, parsePjrIndex, parseTableCells, prepareRegisterEventFile, REGISTER_SECTION_RE, REGISTER_TOPIC_RE, } from "./core.js";
|
|
@@ -170,6 +171,9 @@ export function retopicPjrItem(opts) {
|
|
|
170
171
|
if (opts.description !== undefined) {
|
|
171
172
|
ticketWrite.content = setRegisterItemDescription(ticketWrite.content, opts.description);
|
|
172
173
|
}
|
|
174
|
+
if (opts.inputs !== undefined) {
|
|
175
|
+
ticketWrite.content = setRegisterInput(ticketWrite.content, opts.inputs);
|
|
176
|
+
}
|
|
173
177
|
ticketWrite.content = applyRegisterItemFields(ticketWrite.content, {
|
|
174
178
|
...registerItemFieldsFromItem(opts.updated),
|
|
175
179
|
...(opts.updated.status === "waiting" ? {} : { block_reason: REMOVE_REGISTER_ITEM_FIELD }),
|
package/dist/register/update.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setRegisterInput } from "./input.js";
|
|
1
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { basename, join } from "node:path";
|
|
3
4
|
import { atomicWriteFile, prepareRegisterEventFile } from "./core.js";
|
|
@@ -59,6 +60,9 @@ export function applyItemUpdate(opts) {
|
|
|
59
60
|
lines.push(` title: ${opts.title}`);
|
|
60
61
|
if (opts.description !== undefined)
|
|
61
62
|
lines.push(` description: ${opts.description}`);
|
|
63
|
+
if (opts.inputs !== undefined) {
|
|
64
|
+
lines.push(` input: ${opts.inputs.length ? JSON.stringify(opts.inputs) : "-"}`);
|
|
65
|
+
}
|
|
62
66
|
lines.push(formatRegisterItemFields(updates));
|
|
63
67
|
process.stdout.write(`${lines.join("\n")}\n`);
|
|
64
68
|
return;
|
|
@@ -70,6 +74,8 @@ export function applyItemUpdate(opts) {
|
|
|
70
74
|
if (opts.description !== undefined) {
|
|
71
75
|
content = setRegisterItemDescription(content, opts.description);
|
|
72
76
|
}
|
|
77
|
+
if (opts.inputs !== undefined)
|
|
78
|
+
content = setRegisterInput(content, opts.inputs);
|
|
73
79
|
content = applyRegisterItemFields(content, updates);
|
|
74
80
|
const event = buildRegisterEvent({
|
|
75
81
|
beforeContent,
|
|
@@ -182,11 +182,20 @@ export function resolveRecommendedApproach(input) {
|
|
|
182
182
|
reasons: [`Kata 一式を初期整備する(成果物実在: ${input.deliverableExists})`],
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
+
case "draft-with-context":
|
|
185
186
|
case "author-deliverable": {
|
|
186
187
|
const required = KATA_KINDS.filter((kind) => input.usability[kind] !== "not-needed");
|
|
187
188
|
const unknown = required.filter((kind) => input.usability[kind] === "unknown");
|
|
188
189
|
if (unknown.length)
|
|
189
190
|
return { approach: "undecided", reasons: [`grade がない Kata: ${unknown.join(", ")}`] };
|
|
191
|
+
if (input.intent === "draft-with-context") {
|
|
192
|
+
return required.every((kind) => input.usability[kind] === "usable")
|
|
193
|
+
? { approach: "draft", reasons: ["人が雛形へ文脈を記入してから下書きする"] }
|
|
194
|
+
: {
|
|
195
|
+
approach: "undecided",
|
|
196
|
+
reasons: ["draft-with-context には必要な Kata がすべて利用可能であることが必要"],
|
|
197
|
+
};
|
|
198
|
+
}
|
|
190
199
|
if (required.every((kind) => input.usability[kind] === "usable"))
|
|
191
200
|
return { approach: "fully-guided", reasons: ["必要な Kata がすべて利用可能"] };
|
|
192
201
|
if (input.usability.recipe === "usable")
|
|
@@ -50,6 +50,20 @@ export const STRATEGY_PHASE_SETS = {
|
|
|
50
50
|
"無条件に合わせず result に記録する。",
|
|
51
51
|
},
|
|
52
52
|
],
|
|
53
|
+
"context-pass": [
|
|
54
|
+
{
|
|
55
|
+
id: "context",
|
|
56
|
+
name: "雛形作成・文脈の記入",
|
|
57
|
+
task_suffix: "010",
|
|
58
|
+
duration_days: 0.25,
|
|
59
|
+
execution: "human",
|
|
60
|
+
mode: "edit",
|
|
61
|
+
approach: "draft",
|
|
62
|
+
description: "人が exec claim で着手を記録し、deliverable scaffold --project <project-id> --target <doc-id> で" +
|
|
63
|
+
"雛形を作成する。既存成果物は上書きせず、本文に `_CONTEXT_:` を付けて固定前提、制約、調査・選定を" +
|
|
64
|
+
"任せる範囲を記入する。result に対象と記入内容を記録し、exec complete で draft へ渡す。",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
53
67
|
"guided-pass": [
|
|
54
68
|
{
|
|
55
69
|
id: "draft",
|
|
@@ -58,7 +72,7 @@ export const STRATEGY_PHASE_SETS = {
|
|
|
58
72
|
duration_days: 0.5,
|
|
59
73
|
execution: "agent",
|
|
60
74
|
mode: "edit",
|
|
61
|
-
approach: "
|
|
75
|
+
approach: "draft",
|
|
62
76
|
pipeline: NORMAL_PIPELINE,
|
|
63
77
|
description: "必要と宣言され、整備済みの rulebook / recipe / sample / template に沿って草案を作成する。" +
|
|
64
78
|
"利用可能な実践の型を正本とし、根拠を確認できない内容は書かずに result へ確認事項として残す。",
|
|
@@ -157,6 +171,7 @@ export const STRATEGY_PHASE_SETS = {
|
|
|
157
171
|
export const PHASE_SET_ORDER = [
|
|
158
172
|
"bootstrap-pass",
|
|
159
173
|
"retrofit-pass",
|
|
174
|
+
"context-pass",
|
|
160
175
|
"guided-pass",
|
|
161
176
|
"recipe-guided-pass",
|
|
162
177
|
"freeform-pass",
|
|
@@ -200,6 +215,11 @@ export const STRATEGY_PROFILES = {
|
|
|
200
215
|
phase_sets: ["guided-pass", "refine-pass", "review-pass", "finalize-pass"],
|
|
201
216
|
finalize_approach: "finalize",
|
|
202
217
|
},
|
|
218
|
+
draft: {
|
|
219
|
+
approach: "draft",
|
|
220
|
+
phase_sets: ["context-pass", "guided-pass", "refine-pass", "review-pass", "finalize-pass"],
|
|
221
|
+
finalize_approach: "finalize",
|
|
222
|
+
},
|
|
203
223
|
"recipe-guided": {
|
|
204
224
|
approach: "recipe-guided",
|
|
205
225
|
phase_sets: ["recipe-guided-pass", "refine-pass", "review-pass", "finalize-pass"],
|
|
@@ -250,7 +270,7 @@ export const STRATEGY_PROFILES = {
|
|
|
250
270
|
};
|
|
251
271
|
export function profileFor(approach) {
|
|
252
272
|
if (!(approach in STRATEGY_PROFILES)) {
|
|
253
|
-
throw new Error(`Approach "${approach}" has no schedule strategy profile;
|
|
273
|
+
throw new Error(`Approach "${approach}" has no schedule strategy profile; declare phases explicitly or select a supported generated profile`);
|
|
254
274
|
}
|
|
255
275
|
return STRATEGY_PROFILES[approach];
|
|
256
276
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
//
|
|
1
|
+
// タスクの進め方プロファイル。draft は文脈で任された範囲を調べて下書きし、
|
|
2
|
+
// fully-guided は宣言された参照だけで既存成果物を磨き込む。
|
|
3
|
+
// fully-guided / recipe-guided / freeform は参考資料をどの程度参照するかを表し、
|
|
2
4
|
// <kind>-maintenance は成果物や finding が指す規範を根拠に対象の参考資料を見直す進め方
|
|
3
5
|
// (参照の向きが逆転する)。
|
|
4
6
|
// bootstrap は成果物とその参考資料一式(rulebook/recipe/sample/template)を一貫した一組として
|
|
@@ -9,6 +11,7 @@
|
|
|
9
11
|
// bootstrap-finalize は bootstrap と対になり、成果物と参考資料一式をまとめて確定する進め方。
|
|
10
12
|
// catalog-planning / strategy-planning は register の domain / track 単位で計画を生成する。
|
|
11
13
|
export const APPROACHES = [
|
|
14
|
+
"draft",
|
|
12
15
|
"fully-guided",
|
|
13
16
|
"recipe-guided",
|
|
14
17
|
"freeform",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { gitResult } from "./git.js";
|
|
2
|
+
import { validateCommitMessageTemplate } from "./commit-message-template.js";
|
|
3
|
+
export const DEFAULT_BRANCH_TEMPLATE = "exec/{project}-{id}";
|
|
4
|
+
export function isValidBranchName(cwd, branch) {
|
|
5
|
+
return (gitResult(cwd, ["check-ref-format", "--branch", branch]).status === 0 &&
|
|
6
|
+
gitResult(cwd, ["check-ref-format", `refs/heads/${branch}`]).status === 0);
|
|
7
|
+
}
|
|
8
|
+
export function validateBranchTemplate(value, at, cwd) {
|
|
9
|
+
if (value === undefined)
|
|
10
|
+
return [];
|
|
11
|
+
const errors = validateCommitMessageTemplate(value, at);
|
|
12
|
+
if (typeof value !== "string")
|
|
13
|
+
return errors;
|
|
14
|
+
if (!/\{(?:id|topic)\}/.test(value))
|
|
15
|
+
errors.push(`${at} must contain {id} or {topic}`);
|
|
16
|
+
if (/\{(?:branch|target)\}/.test(value))
|
|
17
|
+
errors.push(`${at}: {branch} and {target} are not supported`);
|
|
18
|
+
const sample = value.replace(/\{[^{}]*\}/g, "value");
|
|
19
|
+
if (!isValidBranchName(cwd, sample)) {
|
|
20
|
+
errors.push(`${at} is not a valid Git branch template`);
|
|
21
|
+
}
|
|
22
|
+
return errors;
|
|
23
|
+
}
|
|
24
|
+
export function expandBranchTemplate(template, variables) {
|
|
25
|
+
return template.replace(/\{([^{}]+)\}/g, (_placeholder, key) => variables[key]);
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Variables shared by product commit and merge message templates. */
|
|
2
|
+
export const COMMIT_MESSAGE_VARIABLES = [
|
|
3
|
+
"id",
|
|
4
|
+
"project",
|
|
5
|
+
"topic",
|
|
6
|
+
"type",
|
|
7
|
+
"scope",
|
|
8
|
+
"title",
|
|
9
|
+
"branch",
|
|
10
|
+
"target",
|
|
11
|
+
];
|
|
12
|
+
/** Validate before a run starts; braces are reserved for the supported placeholders. */
|
|
13
|
+
export function validateCommitMessageTemplate(value, at) {
|
|
14
|
+
if (value === undefined)
|
|
15
|
+
return [];
|
|
16
|
+
if (typeof value !== "string" || !value.trim())
|
|
17
|
+
return [`${at} must be a non-empty string`];
|
|
18
|
+
if (value.includes("\0"))
|
|
19
|
+
return [`${at} must not contain NUL`];
|
|
20
|
+
const errors = [];
|
|
21
|
+
const rest = value.replace(/\{([^{}]*)\}/g, (placeholder, key) => {
|
|
22
|
+
if (!COMMIT_MESSAGE_VARIABLES.includes(key)) {
|
|
23
|
+
errors.push(`${at}: unknown variable ${placeholder}`);
|
|
24
|
+
}
|
|
25
|
+
return "";
|
|
26
|
+
});
|
|
27
|
+
if (/[{}]/.test(rest))
|
|
28
|
+
errors.push(`${at}: malformed placeholder`);
|
|
29
|
+
return errors;
|
|
30
|
+
}
|
|
31
|
+
/** Expand once so placeholder-like text in a title is kept literally. */
|
|
32
|
+
export function expandCommitMessageTemplate(template, variables) {
|
|
33
|
+
const errors = validateCommitMessageTemplate(template, "commit message template");
|
|
34
|
+
if (errors.length > 0)
|
|
35
|
+
throw new Error(errors.join("; "));
|
|
36
|
+
const effective = variables.scope ? template : template.replaceAll("({scope})", "");
|
|
37
|
+
return effective.replace(/\{([^{}]+)\}/g, (_placeholder, key) => variables[key]);
|
|
38
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Commit types supported by register items and their configured defaults. */
|
|
2
|
+
export const VALID_COMMIT_TYPES = [
|
|
3
|
+
"feat",
|
|
4
|
+
"fix",
|
|
5
|
+
"docs",
|
|
6
|
+
"refactor",
|
|
7
|
+
"test",
|
|
8
|
+
"chore",
|
|
9
|
+
"perf",
|
|
10
|
+
"build",
|
|
11
|
+
"ci",
|
|
12
|
+
"style",
|
|
13
|
+
"revert",
|
|
14
|
+
];
|
|
15
|
+
export const COMMIT_SCOPE_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, isAbsolute, join, posix, relative, resolve } from "node:path";
|
|
3
3
|
import dotenv from "dotenv";
|
|
4
|
+
import { validateBranchTemplate } from "./branch-template.js";
|
|
5
|
+
import { VALID_COMMIT_TYPES } from "./commit-types.js";
|
|
6
|
+
import { validateCommitMessageTemplate } from "./commit-message-template.js";
|
|
4
7
|
import { dump, load } from "./yaml.js";
|
|
5
8
|
import Ajv2020Module from "ajv/dist/2020.js";
|
|
6
9
|
import { runProviderScaffold, specdojoPackageRootDir } from "./provider-scaffold.js";
|
|
@@ -255,9 +258,28 @@ export function getProjectRepos(project) {
|
|
|
255
258
|
function isRecord(value) {
|
|
256
259
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
257
260
|
}
|
|
258
|
-
const REPO_KEYS = new Set([
|
|
261
|
+
const REPO_KEYS = new Set([
|
|
262
|
+
"name",
|
|
263
|
+
"path",
|
|
264
|
+
"integration_branch",
|
|
265
|
+
"integration_strategy",
|
|
266
|
+
"branch_template",
|
|
267
|
+
"setup",
|
|
268
|
+
"commit_types",
|
|
269
|
+
"commit_subject_template",
|
|
270
|
+
"merge_message_template",
|
|
271
|
+
]);
|
|
259
272
|
const REPO_SETUP_KEYS = new Set(["install", "build"]);
|
|
260
273
|
const EXTERNAL_PROJECT_KEYS = new Set(["path", "project_id"]);
|
|
274
|
+
function validateCommitTypes(value, at) {
|
|
275
|
+
if (value === undefined)
|
|
276
|
+
return [];
|
|
277
|
+
if (!isRecord(value))
|
|
278
|
+
return [`${at} must be an object mapping item types to commit types`];
|
|
279
|
+
return Object.entries(value).flatMap(([itemType, commitType]) => typeof commitType === "string" && VALID_COMMIT_TYPES.includes(commitType)
|
|
280
|
+
? []
|
|
281
|
+
: [`${at}.${itemType} must be one of: ${VALID_COMMIT_TYPES.join(", ")}`]);
|
|
282
|
+
}
|
|
261
283
|
/** Resolve a configured external-project repository from the SpecDojo root. */
|
|
262
284
|
export function resolveExternalProjectRoot(rootDir, project) {
|
|
263
285
|
return resolve(rootDir, project.path);
|
|
@@ -339,6 +361,11 @@ export function validateProjectRepos(projectId, project, projectIds, rootDir) {
|
|
|
339
361
|
if (!REPO_KEYS.has(key))
|
|
340
362
|
errors.push(`${at}: unknown key "${key}"`);
|
|
341
363
|
}
|
|
364
|
+
errors.push(...validateCommitTypes(repo.commit_types, `${at}.commit_types`));
|
|
365
|
+
for (const key of ["commit_subject_template", "merge_message_template"]) {
|
|
366
|
+
errors.push(...validateCommitMessageTemplate(repo[key], `${at}.${key}`));
|
|
367
|
+
}
|
|
368
|
+
errors.push(...validateBranchTemplate(repo.branch_template, `${at}.branch_template`, rootDir));
|
|
342
369
|
const name = repo.name;
|
|
343
370
|
if (typeof name !== "string" || !REPO_NAME_PATTERN.test(name)) {
|
|
344
371
|
errors.push(`${at}.name must match ${String(REPO_NAME_PATTERN)} (got ${JSON.stringify(name)})`);
|
|
@@ -384,8 +411,9 @@ export function validateProjectRepos(projectId, project, projectIds, rootDir) {
|
|
|
384
411
|
}
|
|
385
412
|
if (repo.integration_strategy !== undefined &&
|
|
386
413
|
repo.integration_strategy !== "merge" &&
|
|
387
|
-
repo.integration_strategy !== "branch-only"
|
|
388
|
-
|
|
414
|
+
repo.integration_strategy !== "branch-only" &&
|
|
415
|
+
repo.integration_strategy !== "ff") {
|
|
416
|
+
errors.push(`${at}.integration_strategy must be "merge", "branch-only" or "ff" when present`);
|
|
389
417
|
}
|
|
390
418
|
const setup = repo.setup;
|
|
391
419
|
if (setup !== undefined) {
|
|
@@ -685,7 +713,10 @@ export function loadConfig(configRootDir = specdojoRootDir()) {
|
|
|
685
713
|
const rootDir = dirname(dirname(configPath));
|
|
686
714
|
const repoErrors = projectIds
|
|
687
715
|
.sort()
|
|
688
|
-
.flatMap((projectId) =>
|
|
716
|
+
.flatMap((projectId) => [
|
|
717
|
+
...validateCommitTypes(parsed.projects[projectId].commit_types, `projects.${projectId}.commit_types`),
|
|
718
|
+
...validateProjectRepos(projectId, parsed.projects[projectId], projectIds, rootDir),
|
|
719
|
+
]);
|
|
689
720
|
const externalProjectErrors = validateExternalProjects(parsed.external_projects, projectIds, rootDir);
|
|
690
721
|
const configErrors = [...repoErrors, ...externalProjectErrors];
|
|
691
722
|
if (configErrors.length > 0) {
|