specdojo 0.5.0 → 0.7.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 +100 -0
- package/README.md +2 -2
- package/dist/catalog/generate.js +144 -13
- package/dist/commands/agent.js +33 -0
- package/dist/commands/init.js +2 -0
- package/dist/commands/orchestrator.js +10 -1
- package/dist/deliverable/deliverable.js +77 -4
- package/dist/devcontainer/command.js +18 -0
- package/dist/devcontainer/host-script.js +21 -0
- package/dist/devcontainer/scaffold.js +4 -3
- package/dist/exec/antigravity-session.js +154 -0
- package/dist/exec/core.js +1 -0
- package/dist/exec/parent-validation.js +14 -0
- package/dist/exec/plan-markdownlint.js +89 -0
- package/dist/exec/plans-core.js +46 -1
- package/dist/exec/plans-generation.js +45 -5
- 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-resume.js +28 -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/lifecycle-commands.js +85 -16
- package/dist/exec/run/register-command.js +22 -0
- package/dist/exec/run/register-resume.js +11 -1
- package/dist/exec/run/register-worktree.js +29 -8
- package/dist/exec/run/schedule-mode.js +22 -2
- package/dist/exec/run/schedule-prepare.js +49 -4
- package/dist/exec/run/schedule-task.js +3 -0
- 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-ops-commit.js +1 -13
- package/dist/exec/worktree-ops-lifecycle.js +40 -36
- 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 +33 -25
- 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/git.js +7 -0
- package/dist/shared/provider-scaffold.js +2 -0
- package/dist/shared/specdojo-config.js +35 -4
- package/dist/shared/specdojo-gitignore.js +1 -0
- package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +2 -0
- 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/docs-editing-guide.md +36 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +16 -12
- package/docs/ja/specdojo/guides/exec-operation-guide.md +116 -10
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +4 -2
- package/docs/ja/specdojo/guides/quick-start-guide.md +597 -871
- package/docs/ja/specdojo/guides/register-operation-guide.md +16 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +31 -4
- 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/guides/schedule-operation-guide.md +14 -0
- package/docs/ja/specdojo/guides/use-case-guide.md +537 -77
- package/docs/ja/specdojo/recipes/cdfd-overview-recipe.md +88 -86
- package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +96 -122
- 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 +111 -46
- package/docs/ja/specdojo/references/specdojo-config-reference.md +69 -8
- package/docs/ja/specdojo/rulebooks/cdfd-d2-rulebook.md +367 -0
- package/docs/ja/specdojo/rulebooks/cdfd-mermaid-rulebook.md +6 -5
- package/docs/ja/specdojo/rulebooks/cdfd-overview-rulebook.md +96 -100
- package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +38 -47
- package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +108 -103
- 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/cdfd-overview-sample.md +248 -140
- package/docs/ja/specdojo/samples/cdfd-uc-sample.md +128 -97
- 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/cdfd-overview-template.md +161 -83
- package/docs/ja/specdojo/templates/cdfd-uc-template.md +127 -90
- 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 +2 -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 +41 -2
- package/package.json +6 -2
- package/templates/antigravity/README.md +19 -46
- package/templates/antigravity/exec-defaults-snippet.yaml +5 -6
- package/templates/antigravity/orchestrator.md +2 -0
- package/templates/antigravity/settings.edit.json +73 -0
- package/templates/antigravity/settings.orchestrator.json +15 -0
- package/templates/antigravity/settings.report.json +7 -0
- package/templates/antigravity/settings.review.json +7 -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/devcontainer-tmux.sh +217 -0
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +8 -90
- package/templates/devcontainer/remote-host/ssh-config.sample +3 -1
- package/templates/init-agent-members.yaml +1 -0
- package/templates/init-exec-defaults.yaml +1 -1
- package/templates/opencode/agents/specdojo-orchestrator.md +2 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { normalizeRegisterInput } from "./input.js";
|
|
1
2
|
import { existsSync, mkdirSync } from "node:fs";
|
|
2
3
|
import { join } from "node:path";
|
|
3
4
|
import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
4
5
|
import { APPROACHES } from "../shared/agent-types.js";
|
|
5
6
|
import { appendRegisterEvent, buildRegisterEvent, registerEventFilePath } from "./events.js";
|
|
6
7
|
import { nowUtcTimestamp } from "./date.js";
|
|
7
|
-
import { readRegisterItemContent, CELL_NONE, CELL_TODO, REMOVE_REGISTER_ITEM_FIELD, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, } from "./item.js";
|
|
8
|
+
import { readRegisterItemContent, CELL_NONE, CELL_TODO, REMOVE_REGISTER_ITEM_FIELD, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, VALID_COMMIT_TYPES, COMMIT_SCOPE_RE, } from "./item.js";
|
|
8
9
|
import { resolveSpecdojoTemplatePath } from "../docs/template-resolution.js";
|
|
9
10
|
import { validateRegisterApproachTargetsForProject } from "./approach.js";
|
|
10
11
|
import { normalizeDependsOn, validateRegisterDependencies } from "./dependency.js";
|
|
@@ -76,6 +77,7 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
76
77
|
addCmd.requiredOption("--type <type>", `Item type: ${VALID_TYPES.join(" | ")}`);
|
|
77
78
|
addCmd.option("--track <track>", "Track governed by an epic (required for epic)");
|
|
78
79
|
addCmd.requiredOption("--title <title>", "Short title for the item");
|
|
80
|
+
addCmd.option("--input <text>", "Premise recorded in the ticket (repeatable)", collectTarget);
|
|
79
81
|
addCmd.option("--description <text>", "Description shown in the list", "_TODO_");
|
|
80
82
|
addCmd.option("--priority <priority>", `Priority: ${VALID_PRIORITIES.join(" | ")}`, "medium");
|
|
81
83
|
addCmd.option("--difficulty <difficulty>", `Difficulty: ${VALID_DIFFICULTIES.join(" | ")}`);
|
|
@@ -92,6 +94,8 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
92
94
|
addCmd.option("--source <ref>", "Read-only exemplar for *-authoring (repeatable: doc id, path, or <repo>:<path>)", collectTarget);
|
|
93
95
|
addCmd.option("--from <item-id>", "Register item this item derives from (repeatable)", collectTarget);
|
|
94
96
|
addCmd.option("--depends-on <item-id>", "Predecessor item ID (repeatable; use - to remove)", collectTarget);
|
|
97
|
+
addCmd.option("--commit-type <type>", `Conventional Commits type: ${VALID_COMMIT_TYPES.join(" | ")}`);
|
|
98
|
+
addCmd.option("--commit-scope <scope>", "Conventional Commits scope");
|
|
95
99
|
addCmd.option("--id <id>", "Display ID (e.g., PJR-0061); auto-incremented if omitted");
|
|
96
100
|
addCmd.option("--topic <topic>", "Topic slug for ticket filename; derived from --title if omitted");
|
|
97
101
|
addCmd.option("--by <actor>", "Actor recorded in the append-only register event");
|
|
@@ -121,6 +125,14 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
121
125
|
!VALID_DIFFICULTIES.includes(opts.difficulty)) {
|
|
122
126
|
throw new Error(`Invalid difficulty: "${opts.difficulty}". Must be one of: ${VALID_DIFFICULTIES.join(", ")}`);
|
|
123
127
|
}
|
|
128
|
+
if (opts.commitType !== undefined &&
|
|
129
|
+
!VALID_COMMIT_TYPES.includes(opts.commitType)) {
|
|
130
|
+
throw new Error(`Invalid commit type: "${opts.commitType}". Must be one of: ${VALID_COMMIT_TYPES.join(", ")}`);
|
|
131
|
+
}
|
|
132
|
+
const commitScope = opts.commitScope?.trim();
|
|
133
|
+
if (commitScope !== undefined && !COMMIT_SCOPE_RE.test(commitScope)) {
|
|
134
|
+
throw new Error(`Invalid commit scope: "${commitScope}". Must match ${COMMIT_SCOPE_RE}`);
|
|
135
|
+
}
|
|
124
136
|
if (opts.target?.some((target) => target.trim() === "-")) {
|
|
125
137
|
throw new Error("--target - is only valid with register update");
|
|
126
138
|
}
|
|
@@ -150,6 +162,7 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
150
162
|
type: opts.type,
|
|
151
163
|
title: opts.title,
|
|
152
164
|
description: opts.description,
|
|
165
|
+
inputs: normalizeRegisterInput(opts.input),
|
|
153
166
|
priority: opts.priority,
|
|
154
167
|
...(opts.difficulty !== undefined ? { difficulty: opts.difficulty } : {}),
|
|
155
168
|
status: opts.status,
|
|
@@ -165,6 +178,8 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
165
178
|
? { targetRulebook: opts.targetRulebook.trim() }
|
|
166
179
|
: {}),
|
|
167
180
|
...(sources !== undefined ? { sources } : {}),
|
|
181
|
+
...(opts.commitType !== undefined ? { commitType: opts.commitType } : {}),
|
|
182
|
+
...(commitScope !== undefined ? { commitScope } : {}),
|
|
168
183
|
};
|
|
169
184
|
const templatePath = resolveSpecdojoTemplatePath(`pjr-${opts.type}-template.md`);
|
|
170
185
|
const { assignedId: displayId, ticketFilename } = planRegisterItem({
|
|
@@ -256,9 +271,12 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
256
271
|
updateCmd.option("--target-rulebook <doc-id>", "Replace deliverable rulebook id; use - to remove");
|
|
257
272
|
updateCmd.option("--approach <approach>", `Update execution approach (${APPROACHES.join(" | ")}; use - to remove)`);
|
|
258
273
|
updateCmd.option("--target <target>", "Replace target document ids (repeatable; legacy authoring exemplars may follow; use - to remove)", collectTarget);
|
|
274
|
+
updateCmd.option("--input <text>", "Replace ticket premises (repeatable; use - to remove)", collectTarget);
|
|
259
275
|
updateCmd.option("--source <ref>", "Replace read-only *-authoring exemplars (repeatable; use - to remove)", collectTarget);
|
|
260
276
|
updateCmd.option("--from <item-id>", "Replace source register item IDs (repeatable; use - to remove)", collectTarget);
|
|
261
277
|
updateCmd.option("--depends-on <item-id>", "Replace predecessor IDs (repeatable; use - to remove)", collectTarget);
|
|
278
|
+
updateCmd.option("--commit-type <type>", `Update Conventional Commits type (${VALID_COMMIT_TYPES.join(" | ")}; use - to remove)`);
|
|
279
|
+
updateCmd.option("--commit-scope <scope>", "Update Conventional Commits scope; use - to remove");
|
|
262
280
|
updateCmd.option("--topic <topic>", "Update the topic slug in the ticket filename and document ID");
|
|
263
281
|
updateCmd.option("--by <actor>", "Actor recorded in the append-only register event");
|
|
264
282
|
updateCmd.option("--reason <text>", "Reason recorded in the append-only register event");
|
|
@@ -283,14 +301,17 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
283
301
|
"approach",
|
|
284
302
|
"target",
|
|
285
303
|
"source",
|
|
304
|
+
"input",
|
|
286
305
|
"targetPath",
|
|
287
306
|
"targetRulebook",
|
|
288
307
|
"from",
|
|
289
308
|
"dependsOn",
|
|
309
|
+
"commitType",
|
|
310
|
+
"commitScope",
|
|
290
311
|
"topic",
|
|
291
312
|
].some((key) => opts[key] !== undefined);
|
|
292
313
|
if (!hasUpdates) {
|
|
293
|
-
throw new Error("At least one field option must be specified (--track, --title, --description, --priority, --difficulty, --owner, --due, --conclusion, --block-reason, --autopilot, --approach, --target, --source, --from, --depends-on, --topic)");
|
|
314
|
+
throw new Error("At least one field option must be specified (--track, --title, --description, --priority, --difficulty, --owner, --due, --conclusion, --block-reason, --autopilot, --approach, --target, --source, --input, --from, --depends-on, --commit-type, --commit-scope, --topic)");
|
|
294
315
|
}
|
|
295
316
|
if (opts.priority !== undefined &&
|
|
296
317
|
!VALID_PRIORITIES.includes(opts.priority)) {
|
|
@@ -304,6 +325,15 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
304
325
|
if (opts.due !== undefined && !/^(\d{4}-\d{2}-\d{2}|-|_TODO_)$/.test(opts.due)) {
|
|
305
326
|
throw new Error(`Invalid due: "${opts.due}". Must be YYYY-MM-DD, -, or _TODO_`);
|
|
306
327
|
}
|
|
328
|
+
if (opts.commitType !== undefined &&
|
|
329
|
+
opts.commitType !== "-" &&
|
|
330
|
+
!VALID_COMMIT_TYPES.includes(opts.commitType)) {
|
|
331
|
+
throw new Error(`Invalid commit type: "${opts.commitType}". Must be one of: ${VALID_COMMIT_TYPES.join(", ")}, -`);
|
|
332
|
+
}
|
|
333
|
+
const commitScope = opts.commitScope?.trim();
|
|
334
|
+
if (commitScope !== undefined && commitScope !== "-" && !COMMIT_SCOPE_RE.test(commitScope)) {
|
|
335
|
+
throw new Error(`Invalid commit scope: "${commitScope}". Must match ${COMMIT_SCOPE_RE}, or -`);
|
|
336
|
+
}
|
|
307
337
|
const topic = opts.topic?.trim();
|
|
308
338
|
if (topic !== undefined && !registerTopicPattern.test(topic)) {
|
|
309
339
|
throw new Error(`Invalid topic: "${topic}". Must use lowercase letters, numbers, and single hyphens`);
|
|
@@ -436,11 +466,23 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
436
466
|
derived_from: nextDerivedFrom ?? REMOVE_REGISTER_ITEM_FIELD,
|
|
437
467
|
}
|
|
438
468
|
: {}),
|
|
469
|
+
...(opts.commitType !== undefined
|
|
470
|
+
? {
|
|
471
|
+
commit_type: opts.commitType === "-" ? REMOVE_REGISTER_ITEM_FIELD : opts.commitType,
|
|
472
|
+
}
|
|
473
|
+
: {}),
|
|
474
|
+
...(commitScope !== undefined
|
|
475
|
+
? {
|
|
476
|
+
commit_scope: commitScope === "-" ? REMOVE_REGISTER_ITEM_FIELD : commitScope,
|
|
477
|
+
}
|
|
478
|
+
: {}),
|
|
439
479
|
};
|
|
440
480
|
const track = opts.track === undefined ? item.track : opts.track.trim();
|
|
441
481
|
validateRegisterTrack(paths.projectId, item.type, track);
|
|
482
|
+
const inputs = normalizeRegisterInput(opts.input, true);
|
|
442
483
|
const updated = {
|
|
443
484
|
...item,
|
|
485
|
+
...(inputs !== undefined ? { inputs } : {}),
|
|
444
486
|
...(track !== undefined ? { track } : {}),
|
|
445
487
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
446
488
|
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
@@ -451,9 +493,17 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
451
493
|
...(opts.owner !== undefined ? { owner: opts.owner } : {}),
|
|
452
494
|
...(opts.due !== undefined ? { due: opts.due } : {}),
|
|
453
495
|
...(opts.conclusion !== undefined ? { conclusion: opts.conclusion } : {}),
|
|
496
|
+
...(opts.commitType !== undefined && opts.commitType !== "-"
|
|
497
|
+
? { commitType: opts.commitType }
|
|
498
|
+
: {}),
|
|
499
|
+
...(commitScope !== undefined && commitScope !== "-" ? { commitScope } : {}),
|
|
454
500
|
};
|
|
455
501
|
if (opts.difficulty === "-")
|
|
456
502
|
delete updated.difficulty;
|
|
503
|
+
if (opts.commitType === "-")
|
|
504
|
+
delete updated.commitType;
|
|
505
|
+
if (commitScope === "-")
|
|
506
|
+
delete updated.commitScope;
|
|
457
507
|
if (opts.autopilot !== undefined) {
|
|
458
508
|
if (opts.autopilot === "-")
|
|
459
509
|
delete updated.autopilot;
|
|
@@ -517,6 +567,7 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
517
567
|
id: opts.id,
|
|
518
568
|
topic,
|
|
519
569
|
updated,
|
|
570
|
+
...(inputs !== undefined ? { inputs } : {}),
|
|
520
571
|
dryRun: opts.dryRun,
|
|
521
572
|
...(blockReasonUpdates ||
|
|
522
573
|
autopilotUpdates ||
|
|
@@ -541,6 +592,7 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
541
592
|
paths,
|
|
542
593
|
view,
|
|
543
594
|
updated,
|
|
595
|
+
...(inputs !== undefined ? { inputs } : {}),
|
|
544
596
|
dryRun: opts.dryRun,
|
|
545
597
|
action: "fields updated",
|
|
546
598
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
@@ -10,6 +10,7 @@ import { loadConfig } from "../shared/specdojo-config.js";
|
|
|
10
10
|
import { parsePracticeId } from "../shared/practice-id.js";
|
|
11
11
|
import { load } from "../shared/yaml.js";
|
|
12
12
|
export const CATALOG_LESS_APPROACHES = [
|
|
13
|
+
"draft",
|
|
13
14
|
"fully-guided",
|
|
14
15
|
"recipe-guided",
|
|
15
16
|
"freeform",
|
|
@@ -47,6 +48,28 @@ export function validateDeliverablePath(root, value) {
|
|
|
47
48
|
}
|
|
48
49
|
return path;
|
|
49
50
|
}
|
|
51
|
+
export function validateDeliverableTargetPath(repoRoot, targetId, targetPath, docIndexEntries) {
|
|
52
|
+
const entries = docIndexEntries ?? collectDocIndexEntries(resolve(repoRoot, "docs"), repoRoot);
|
|
53
|
+
const indexed = entries[targetId]?.replace(/:\d+$/, "");
|
|
54
|
+
const indexedPath = indexed ? relative(repoRoot, resolve(repoRoot, indexed)) : undefined;
|
|
55
|
+
if (!targetPath && !indexedPath) {
|
|
56
|
+
throw new Error(`Target ${targetId} is not indexed; specify --target-path and --target-rulebook (catalog_path is not configured)`);
|
|
57
|
+
}
|
|
58
|
+
const path = validateDeliverablePath(repoRoot, targetPath ?? indexedPath ?? "");
|
|
59
|
+
if (indexedPath && path !== validateDeliverablePath(repoRoot, indexedPath)) {
|
|
60
|
+
throw new Error(`--target-path conflicts with the indexed document ${targetId}: ${indexedPath}`);
|
|
61
|
+
}
|
|
62
|
+
const absolute = resolve(repoRoot, path);
|
|
63
|
+
const existing = existsSync(absolute);
|
|
64
|
+
const fm = existing ? metadata(absolute) : {};
|
|
65
|
+
if (existing && fm.id !== targetId) {
|
|
66
|
+
throw new Error(`--target-path is occupied by another document: ${path} (expected ${targetId})`);
|
|
67
|
+
}
|
|
68
|
+
if (AUTHORING_KINDS.includes(fm.type)) {
|
|
69
|
+
throw new Error(`Target ${targetId} is a kata, not a deliverable`);
|
|
70
|
+
}
|
|
71
|
+
return path;
|
|
72
|
+
}
|
|
50
73
|
export function resolveRegisterDeliverableTarget(opts) {
|
|
51
74
|
if (opts.catalogPath) {
|
|
52
75
|
try {
|
|
@@ -65,26 +88,10 @@ export function resolveRegisterDeliverableTarget(opts) {
|
|
|
65
88
|
throw new Error(`Approach "${opts.approach}" requires a deliverable target from the project catalog (catalog_path)`);
|
|
66
89
|
}
|
|
67
90
|
const entries = collectDocIndexEntries(resolve(opts.repoRoot, "docs"), opts.repoRoot);
|
|
68
|
-
const
|
|
69
|
-
const indexedPath = indexed
|
|
70
|
-
? relative(opts.repoRoot, resolve(opts.repoRoot, indexed))
|
|
71
|
-
: undefined;
|
|
72
|
-
if (!opts.targetPath && !indexedPath) {
|
|
73
|
-
throw new Error(`Target ${opts.targetId} is not indexed; specify --target-path and --target-rulebook (catalog_path is not configured)`);
|
|
74
|
-
}
|
|
75
|
-
const path = validateDeliverablePath(opts.repoRoot, opts.targetPath ?? indexedPath ?? "");
|
|
76
|
-
if (indexedPath && path !== validateDeliverablePath(opts.repoRoot, indexedPath)) {
|
|
77
|
-
throw new Error(`--target-path conflicts with the indexed document ${opts.targetId}: ${indexedPath}`);
|
|
78
|
-
}
|
|
91
|
+
const path = validateDeliverableTargetPath(opts.repoRoot, opts.targetId, opts.targetPath, entries);
|
|
79
92
|
const absolute = resolve(opts.repoRoot, path);
|
|
80
93
|
const existing = existsSync(absolute);
|
|
81
94
|
const fm = existing ? metadata(absolute) : {};
|
|
82
|
-
if (existing && fm.id !== opts.targetId) {
|
|
83
|
-
throw new Error(`--target-path is occupied by another document: ${path} (expected ${opts.targetId})`);
|
|
84
|
-
}
|
|
85
|
-
if (AUTHORING_KINDS.includes(fm.type)) {
|
|
86
|
-
throw new Error(`Target ${opts.targetId} is a kata, not a deliverable`);
|
|
87
|
-
}
|
|
88
95
|
const declaredRulebook = typeof fm.rulebook === "string" ? fm.rulebook : undefined;
|
|
89
96
|
if (opts.targetRulebook && declaredRulebook && opts.targetRulebook !== declaredRulebook) {
|
|
90
97
|
throw new Error(`--target-rulebook conflicts with specdojo.rulebook of ${opts.targetId}: ${declaredRulebook}`);
|
|
@@ -180,6 +180,10 @@ function fieldUpdateFromChange(change) {
|
|
|
180
180
|
: value === "approved"
|
|
181
181
|
? { autopilot: "approved" }
|
|
182
182
|
: undefined;
|
|
183
|
+
case "commit_type":
|
|
184
|
+
return isUnset ? { commit_type: REMOVE_REGISTER_ITEM_FIELD } : { commit_type: value };
|
|
185
|
+
case "commit_scope":
|
|
186
|
+
return isUnset ? { commit_scope: REMOVE_REGISTER_ITEM_FIELD } : { commit_scope: value };
|
|
183
187
|
default:
|
|
184
188
|
return undefined;
|
|
185
189
|
}
|
package/dist/register/events.js
CHANGED
|
@@ -12,6 +12,7 @@ export const REGISTER_EVENT_FIELDS = [
|
|
|
12
12
|
"status",
|
|
13
13
|
"title",
|
|
14
14
|
"description",
|
|
15
|
+
"input",
|
|
15
16
|
"type",
|
|
16
17
|
"track",
|
|
17
18
|
"priority",
|
|
@@ -30,6 +31,8 @@ export const REGISTER_EVENT_FIELDS = [
|
|
|
30
31
|
"derived_from",
|
|
31
32
|
"depends_on",
|
|
32
33
|
"autopilot",
|
|
34
|
+
"commit_type",
|
|
35
|
+
"commit_scope",
|
|
33
36
|
];
|
|
34
37
|
export const REGISTER_EVENT_ACTIONS = [
|
|
35
38
|
"add",
|
|
@@ -70,6 +73,7 @@ export function registerEventFieldValues(content, filename, timeZone) {
|
|
|
70
73
|
status: item.status,
|
|
71
74
|
title: item.title,
|
|
72
75
|
description: item.description,
|
|
76
|
+
input: item.inputs?.length ? JSON.stringify(item.inputs) : CELL_NONE,
|
|
73
77
|
type: item.type,
|
|
74
78
|
track: item.track ?? CELL_NONE,
|
|
75
79
|
priority: item.priority,
|
|
@@ -88,6 +92,8 @@ export function registerEventFieldValues(content, filename, timeZone) {
|
|
|
88
92
|
derived_from: item.derivedFrom ? JSON.stringify(item.derivedFrom) : CELL_NONE,
|
|
89
93
|
depends_on: item.dependsOn ? JSON.stringify(item.dependsOn) : CELL_NONE,
|
|
90
94
|
autopilot: item.autopilot ?? CELL_NONE,
|
|
95
|
+
commit_type: item.commitType ?? CELL_NONE,
|
|
96
|
+
commit_scope: item.commitScope ?? CELL_NONE,
|
|
91
97
|
};
|
|
92
98
|
}
|
|
93
99
|
function isUnsetFieldValue(value) {
|
|
@@ -44,6 +44,8 @@ export function buildExternalRegisterAddArgs(alias, externalProject, opts) {
|
|
|
44
44
|
addValue(args, "--difficulty", opts.difficulty);
|
|
45
45
|
addValue(args, "--registered", opts.registered);
|
|
46
46
|
addValue(args, "--approach", opts.approach);
|
|
47
|
+
for (const input of opts.input ?? [])
|
|
48
|
+
addValue(args, "--input", input);
|
|
47
49
|
for (const target of opts.target ?? [])
|
|
48
50
|
addValue(args, "--target", target);
|
|
49
51
|
for (const source of opts.source ?? [])
|
|
@@ -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
|
+
}
|