specdojo 0.3.0 → 0.3.1
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/CHANGELOG.md +18 -0
- package/dist/catalog-build-references.js +144 -0
- package/dist/catalog-build-render.js +144 -0
- package/dist/catalog-build.js +13 -290
- package/dist/catalog-generate.js +6 -9
- package/dist/catalog-plan-generate.js +2 -2
- package/dist/catalog-plan.js +6 -6
- package/dist/catalog-scaffold.js +4 -4
- package/dist/catalog.js +2 -2
- package/dist/dashboard-exec-records.js +105 -0
- package/dist/dashboard-routines.js +255 -0
- package/dist/dashboard-shared.js +14 -0
- package/dist/dashboard-timeline.js +175 -0
- package/dist/dashboard.js +10 -544
- package/dist/deliverable-trash.js +3 -3
- package/dist/doc-index.js +3 -3
- package/dist/exec-commands.js +557 -0
- package/dist/exec-core.js +457 -0
- package/dist/exec-plans-core.js +693 -0
- package/dist/exec-plans-generation.js +206 -0
- package/dist/exec-plans-storage.js +131 -0
- package/dist/exec-plans.js +3 -1018
- package/dist/exec-repo-integration-git.js +23 -0
- package/dist/exec-repo-integration-sync.js +264 -0
- package/dist/exec-repo-integration.js +4 -281
- package/dist/exec-reporter-output.js +206 -0
- package/dist/exec-reporter.js +2 -206
- package/dist/exec-results.js +22 -15
- package/dist/exec-run-agent-pipeline.js +256 -0
- package/dist/exec-run-agent.js +531 -0
- package/dist/exec-run-in-place.js +541 -0
- package/dist/exec-run-job.js +717 -0
- package/dist/exec-run-lifecycle-commands.js +522 -0
- package/dist/exec-run-mode-shared.js +140 -0
- package/dist/exec-run-register-command.js +244 -0
- package/dist/exec-run-register-core.js +386 -0
- package/dist/exec-run-register-mode.js +206 -0
- package/dist/exec-run-register-resume.js +393 -0
- package/dist/exec-run-register-state.js +322 -0
- package/dist/exec-run-register-worktree.js +509 -0
- package/dist/exec-run-schedule-mode.js +294 -0
- package/dist/exec-run-schedule-prepare.js +353 -0
- package/dist/exec-run-schedule-task.js +572 -0
- package/dist/exec-run-shared.js +399 -0
- package/dist/exec-run.js +11 -6182
- package/dist/exec-shared.js +2 -2
- package/dist/exec-trial-commands.js +558 -0
- package/dist/exec-trial-core.js +371 -0
- package/dist/exec-trial.js +2 -921
- package/dist/exec-worktree-ops-commit.js +707 -0
- package/dist/exec-worktree-ops-lifecycle.js +292 -0
- package/dist/exec-worktree-ops-merge.js +303 -0
- package/dist/exec-worktree-ops.js +3 -1292
- package/dist/exec-worktree.js +32 -4
- package/dist/exec.js +2 -1006
- package/dist/frontmatter-namespace.js +2 -2
- package/dist/grade-apply.js +734 -0
- package/dist/grade-command-apply.js +250 -0
- package/dist/grade-command-inspect.js +138 -0
- package/dist/grade-command-plan.js +101 -0
- package/dist/grade-command-shared.js +68 -0
- package/dist/grade-core.js +307 -0
- package/dist/grade-markdown.js +274 -0
- package/dist/grade-pipeline-state.js +184 -0
- package/dist/grade-plan.js +507 -0
- package/dist/grade-result.js +5 -5
- package/dist/grade-target-discovery.js +265 -0
- package/dist/grade-targets.js +432 -0
- package/dist/grade.js +14 -3188
- package/dist/init-command.js +7 -7
- package/dist/job-definition.js +670 -0
- package/dist/job.js +9 -673
- package/dist/kata-command.js +2 -2
- package/dist/register-command-types.js +1 -0
- package/dist/register-core.js +363 -0
- package/dist/register-create-commands.js +245 -0
- package/dist/register-events.js +4 -4
- package/dist/register-item.js +6 -6
- package/dist/register-maintenance-commands.js +187 -0
- package/dist/register-migration.js +268 -0
- package/dist/register-renumber.js +314 -0
- package/dist/register-transition-commands.js +248 -0
- package/dist/register-update.js +230 -0
- package/dist/register-views.js +256 -0
- package/dist/register.js +61 -2069
- package/dist/review-plan.js +3 -3
- package/dist/routine-definition.js +401 -0
- package/dist/routine.js +6 -402
- package/dist/schedule-approach.js +2 -2
- package/dist/schedule-strategy-generate-document.js +273 -0
- package/dist/schedule-strategy-generate-scope.js +199 -0
- package/dist/schedule-strategy-generate.js +9 -473
- package/dist/schedule.js +4 -4
- package/dist/specdojo-config.js +3 -4
- package/dist/viewpoint-document-kinds-check.js +3 -3
- package/dist/yaml-pages.js +4 -4
- package/dist/yaml.js +28 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +6 -6
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +20 -18
- package/docs/ja/specdojo/guides/routine-operation-guide.md +1 -1
- package/package.json +4 -5
- package/templates/antigravity/README.md +3 -3
- package/templates/antigravity/exec-defaults-snippet.yaml +6 -4
- package/templates/init-exec-defaults.yaml +3 -1
package/dist/kata-command.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, extname, join, relative, resolve } from "node:path";
|
|
3
|
-
import
|
|
3
|
+
import { load } from "./yaml.js";
|
|
4
4
|
import { readSpecdojoNamespace } from "./frontmatter-namespace.js";
|
|
5
5
|
import { specdojoResourceCandidates } from "./template-resolution.js";
|
|
6
6
|
export const KATA_RESOURCE_KINDS = [
|
|
@@ -54,7 +54,7 @@ function filesBelow(root) {
|
|
|
54
54
|
function parseDataFileId(content, extension) {
|
|
55
55
|
let parsed;
|
|
56
56
|
try {
|
|
57
|
-
parsed = extension === ".json" ? JSON.parse(content) :
|
|
57
|
+
parsed = extension === ".json" ? JSON.parse(content) : load(content);
|
|
58
58
|
}
|
|
59
59
|
catch {
|
|
60
60
|
return undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { randomInt, randomUUID } from "node:crypto";
|
|
2
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
3
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
+
import { inlineCodeAnglePlaceholders } from "./exec-shared.js";
|
|
5
|
+
import { appendRegisterEvent, registerEventFilePath, } from "./register-events.js";
|
|
6
|
+
import { REGISTER_TIMESTAMP_RE, resolveRegisterDateTimeZone, timestampFromDateInTimeZone, } from "./register-date.js";
|
|
7
|
+
import { applyRegisterItemFields, CELL_NONE, CELL_TODO, isPlaceholderCell, PJR_ID_ALPHABET, PJR_ID_RE, registerItemFieldsFromItem, setRegisterItemDescription, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "./register-item.js";
|
|
8
|
+
import { getProjectExecutionPath, getProjectRegisterPath, loadConfig, loadEnv, specdojoRootDir, } from "./specdojo-config.js";
|
|
9
|
+
import { flattenTemplateFrontmatter } from "./template-frontmatter.js";
|
|
10
|
+
export function registerEventActor(opts) {
|
|
11
|
+
return opts.by?.trim() || process.env.SPECDOJO_ACTOR?.trim() || "manual";
|
|
12
|
+
}
|
|
13
|
+
export function atomicWriteFile(path, content) {
|
|
14
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
15
|
+
const temporary = join(dirname(path), `.${basename(path)}.${randomUUID()}.tmp`);
|
|
16
|
+
try {
|
|
17
|
+
writeFileSync(temporary, content, { encoding: "utf8", flag: "wx" });
|
|
18
|
+
renameSync(temporary, path);
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
if (existsSync(temporary))
|
|
22
|
+
unlinkSync(temporary);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function findMarkdownReferenceFiles(root) {
|
|
26
|
+
const markdownFiles = [];
|
|
27
|
+
const docsJaPath = join(resolve(root), "docs", "ja");
|
|
28
|
+
function walk(directory) {
|
|
29
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
30
|
+
if (entry.name.startsWith("."))
|
|
31
|
+
continue;
|
|
32
|
+
const entryPath = join(directory, entry.name);
|
|
33
|
+
if (entry.isDirectory()) {
|
|
34
|
+
if (entry.name !== "generated")
|
|
35
|
+
walk(entryPath);
|
|
36
|
+
}
|
|
37
|
+
else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
38
|
+
markdownFiles.push(entryPath);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (existsSync(docsJaPath))
|
|
43
|
+
walk(docsJaPath);
|
|
44
|
+
return markdownFiles.sort((left, right) => left.localeCompare(right));
|
|
45
|
+
}
|
|
46
|
+
export function prepareRegisterEventFile(projectRegisterPath, displayId, event) {
|
|
47
|
+
const eventPath = registerEventFilePath(projectRegisterPath, displayId);
|
|
48
|
+
const content = existsSync(eventPath) ? readFileSync(eventPath, "utf8") : undefined;
|
|
49
|
+
return { path: eventPath, content: appendRegisterEvent(content, event) };
|
|
50
|
+
}
|
|
51
|
+
// ================================
|
|
52
|
+
// Constants
|
|
53
|
+
// ================================
|
|
54
|
+
// PJR-ID の乱数部分の桁数。
|
|
55
|
+
const PJR_ID_LENGTH = 4;
|
|
56
|
+
// 個票ファイル名・文書 ID の論点部分。先頭・末尾や連続ハイフンを許さない。
|
|
57
|
+
export const REGISTER_TOPIC_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
58
|
+
// 生成した ID が偶然含みうる不適切語の簡易ブロックリスト(4 文字, 大文字, 曖昧文字除外後)。
|
|
59
|
+
// 一致した候補は採用せず再抽選する。曖昧文字(I/L/O/U)を含む語は生成されえないため載せない。
|
|
60
|
+
const PJR_ID_BLOCKLIST = new Set(["CRAP", "DAMN", "TWAT", "WANK", "SHAG", "FART"]);
|
|
61
|
+
// 個票 Frontmatter の文書成熟度(specdojo:pjr-rulebook「個票 status の遷移基準」)。
|
|
62
|
+
// pjr-index の処理状態(VALID_STATUSES)とは別の状態軸として扱う。
|
|
63
|
+
export const VALID_TICKET_STATUSES = ["draft", "ready", "deprecated"];
|
|
64
|
+
// 登録項目一覧テーブルは specdojo:pjr-rulebook「本文構成」で章 1 に固定される。
|
|
65
|
+
// 見出し文言(言語依存)ではなく章番号でセクションを特定し、i18n 非依存にする。
|
|
66
|
+
export const REGISTER_SECTION_RE = /^## 1\.\s/;
|
|
67
|
+
// 登録項目一覧(pjr-index)の生成 template。外枠(H1・注記・章見出し)と章 1 の
|
|
68
|
+
// 列見出しを所有し、生成処理は行だけを差し込む。列名を定数として持たないことで、
|
|
69
|
+
// 一覧の言語は template 側の差し替えだけで切り替えられる。
|
|
70
|
+
export const REGISTER_INDEX_TEMPLATE = "pjr-index-template.md";
|
|
71
|
+
// ================================
|
|
72
|
+
// Path Resolution
|
|
73
|
+
// ================================
|
|
74
|
+
export function resolveRegisterPaths(opts) {
|
|
75
|
+
loadEnv();
|
|
76
|
+
const { config, configPath } = loadConfig();
|
|
77
|
+
const baseDir = specdojoRootDir();
|
|
78
|
+
const projectId = opts.project?.trim() ||
|
|
79
|
+
process.env.SPECDOJO_PROJECT?.trim() ||
|
|
80
|
+
(config ? Object.keys(config.projects)[0] : "");
|
|
81
|
+
if (!config) {
|
|
82
|
+
throw new Error(`register commands require specdojo.config.json.\nRun: specdojo config init`);
|
|
83
|
+
}
|
|
84
|
+
if (!projectId) {
|
|
85
|
+
throw new Error(`No project specified. Use --project <id> or SPECDOJO_PROJECT.`);
|
|
86
|
+
}
|
|
87
|
+
const project = config.projects[projectId];
|
|
88
|
+
if (!project) {
|
|
89
|
+
throw new Error(`Unknown project: ${projectId} (check ${configPath})`);
|
|
90
|
+
}
|
|
91
|
+
const registerPath = getProjectRegisterPath(project);
|
|
92
|
+
if (!registerPath) {
|
|
93
|
+
throw new Error(`project_register_path not set for project '${projectId}' in ${configPath}.\n` +
|
|
94
|
+
`Add "project_register_path": "<path>" to the project config.`);
|
|
95
|
+
}
|
|
96
|
+
const absRegisterPath = resolve(baseDir, registerPath);
|
|
97
|
+
return {
|
|
98
|
+
projectId,
|
|
99
|
+
projectRegisterPath: absRegisterPath,
|
|
100
|
+
executionPath: resolve(baseDir, getProjectExecutionPath(project)),
|
|
101
|
+
pjrIndexPath: join(absRegisterPath, "pjr-index.md"),
|
|
102
|
+
generatedPath: join(absRegisterPath, "generated"),
|
|
103
|
+
controlsGeneratedPath: join(dirname(absRegisterPath), "generated"),
|
|
104
|
+
registerDateTimeZone: resolveRegisterDateTimeZone(config, projectId),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// ================================
|
|
108
|
+
// Markdown Table Parsing
|
|
109
|
+
// ================================
|
|
110
|
+
export function parseTableCells(line) {
|
|
111
|
+
// Replace escaped pipes with placeholder before splitting
|
|
112
|
+
const PIPE = "\x01";
|
|
113
|
+
const normalized = line.replace(/\\\|/g, PIPE);
|
|
114
|
+
const cells = normalized.split("|").map((c) => c.replace(new RegExp(PIPE, "g"), "\\|").trim());
|
|
115
|
+
// Remove first and last empty elements (line starts and ends with |)
|
|
116
|
+
return cells.slice(1, cells.length - 1);
|
|
117
|
+
}
|
|
118
|
+
export function isTableSeparator(line) {
|
|
119
|
+
return line.startsWith("|") && /\|\s*---+\s*\|/.test(line);
|
|
120
|
+
}
|
|
121
|
+
export function locateRegisterTable(lines) {
|
|
122
|
+
let inSection = false;
|
|
123
|
+
let header;
|
|
124
|
+
for (let index = 0; index < lines.length; index++) {
|
|
125
|
+
const line = lines[index];
|
|
126
|
+
if (REGISTER_SECTION_RE.test(line)) {
|
|
127
|
+
inSection = true;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (inSection && /^## /.test(line))
|
|
131
|
+
break;
|
|
132
|
+
if (!inSection || !line.startsWith("|"))
|
|
133
|
+
continue;
|
|
134
|
+
if (isTableSeparator(line)) {
|
|
135
|
+
if (header === undefined) {
|
|
136
|
+
throw new Error("Register table header row not found before the separator in the register list source");
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
heading: { header: header.trim(), separator: line.trim() },
|
|
140
|
+
separatorIndex: index,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (header === undefined)
|
|
144
|
+
header = line;
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
export function extractTableHeading(content) {
|
|
149
|
+
const located = locateRegisterTable(content.split("\n"));
|
|
150
|
+
if (!located) {
|
|
151
|
+
throw new Error("Register table header row not found in the register list source");
|
|
152
|
+
}
|
|
153
|
+
return located.heading;
|
|
154
|
+
}
|
|
155
|
+
// 章 1 の登録項目一覧テーブルの区切り行直後へ、生成した行を差し込む。
|
|
156
|
+
// テーブルの列見出しは template が所有するため、生成処理は行だけを注入する。
|
|
157
|
+
export function injectRegisterRows(content, rows) {
|
|
158
|
+
const lines = content.split("\n");
|
|
159
|
+
const located = locateRegisterTable(lines);
|
|
160
|
+
if (!located) {
|
|
161
|
+
throw new Error(`Register table not found in template: ${REGISTER_INDEX_TEMPLATE}`);
|
|
162
|
+
}
|
|
163
|
+
lines.splice(located.separatorIndex + 1, 0, ...rows);
|
|
164
|
+
return lines.join("\n");
|
|
165
|
+
}
|
|
166
|
+
// 旧一覧(追跡対象だった頃の pjr-index.md)の表を読む互換経路。日付セルは暦日しか持たない
|
|
167
|
+
// ため、移行と同じ規則でプロジェクトタイムゾーンの 21:00 を補って日時へ変換する。
|
|
168
|
+
export function parsePjrIndex(content, timeZone) {
|
|
169
|
+
const lines = content.split("\n");
|
|
170
|
+
const items = [];
|
|
171
|
+
let inSection = false;
|
|
172
|
+
const toTimestamp = (cell) => isPlaceholderCell(cell) ? cell.trim() : timestampFromDateInTimeZone(cell.trim(), timeZone);
|
|
173
|
+
for (const line of lines) {
|
|
174
|
+
if (REGISTER_SECTION_RE.test(line)) {
|
|
175
|
+
inSection = true;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (inSection && /^## /.test(line))
|
|
179
|
+
break;
|
|
180
|
+
if (!inSection)
|
|
181
|
+
continue;
|
|
182
|
+
if (!line.startsWith("|") || isTableSeparator(line))
|
|
183
|
+
continue;
|
|
184
|
+
const cells = parseTableCells(line);
|
|
185
|
+
if (cells.length < 12)
|
|
186
|
+
continue;
|
|
187
|
+
if (!PJR_ID_RE.test(cells[0]))
|
|
188
|
+
continue;
|
|
189
|
+
items.push({
|
|
190
|
+
id: cells[0],
|
|
191
|
+
status: cells[1],
|
|
192
|
+
title: cells[2],
|
|
193
|
+
description: cells[3],
|
|
194
|
+
type: cells[4],
|
|
195
|
+
priority: cells[5],
|
|
196
|
+
owner: cells[6],
|
|
197
|
+
registeredAt: toTimestamp(cells[7]),
|
|
198
|
+
due: cells[8],
|
|
199
|
+
completedAt: toTimestamp(cells[9]),
|
|
200
|
+
conclusion: cells[10],
|
|
201
|
+
ticket: cells[11],
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return items;
|
|
205
|
+
}
|
|
206
|
+
// 32 文字セットから一様乱択した 4 文字を持つ PJR-ID 候補を 1 件生成する。
|
|
207
|
+
function defaultPjrCandidate() {
|
|
208
|
+
let suffix = "";
|
|
209
|
+
for (let i = 0; i < PJR_ID_LENGTH; i++) {
|
|
210
|
+
suffix += PJR_ID_ALPHABET[randomInt(0, PJR_ID_ALPHABET.length)];
|
|
211
|
+
}
|
|
212
|
+
return `PJR-${suffix}`;
|
|
213
|
+
}
|
|
214
|
+
// 既存 ID・不適切語ブロックリストと衝突しない PJR-ID をランダムに採番する。
|
|
215
|
+
// 生成候補が既存 ID かブロックリストに一致した場合は再抽選する。nextCandidate は
|
|
216
|
+
// テストで抽選列を差し込むための注入点で、既定は 32 文字セットからの一様乱択。
|
|
217
|
+
export function generatePjrId(existingIds, nextCandidate = defaultPjrCandidate, maxAttempts = 256) {
|
|
218
|
+
const existing = new Set(existingIds);
|
|
219
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
220
|
+
const id = nextCandidate();
|
|
221
|
+
if (!PJR_ID_RE.test(id))
|
|
222
|
+
continue;
|
|
223
|
+
if (existing.has(id))
|
|
224
|
+
continue;
|
|
225
|
+
if (PJR_ID_BLOCKLIST.has(id.slice("PJR-".length)))
|
|
226
|
+
continue;
|
|
227
|
+
return id;
|
|
228
|
+
}
|
|
229
|
+
throw new Error(`Failed to generate an unused PJR-ID after ${maxAttempts} attempts`);
|
|
230
|
+
}
|
|
231
|
+
export function formatTableRow(item) {
|
|
232
|
+
// frontmatter・本文由来を問わず、表へ展開する全セルを同じ規則で無害化する。
|
|
233
|
+
// 既存コードスパンは変換処理が保持するため、再生成しても二重に囲まれない。
|
|
234
|
+
const cells = [
|
|
235
|
+
item.id,
|
|
236
|
+
item.status,
|
|
237
|
+
item.title,
|
|
238
|
+
item.description,
|
|
239
|
+
item.type,
|
|
240
|
+
item.priority,
|
|
241
|
+
item.owner,
|
|
242
|
+
item.registered,
|
|
243
|
+
item.due,
|
|
244
|
+
item.completed,
|
|
245
|
+
item.conclusion,
|
|
246
|
+
item.ticket,
|
|
247
|
+
].map(inlineCodeAnglePlaceholders);
|
|
248
|
+
return `| ${cells.join(" | ")} |`;
|
|
249
|
+
}
|
|
250
|
+
// ================================
|
|
251
|
+
// Validation
|
|
252
|
+
// ================================
|
|
253
|
+
export function validateFields(opts) {
|
|
254
|
+
const errors = [];
|
|
255
|
+
if (!VALID_STATUSES.includes(opts.status)) {
|
|
256
|
+
errors.push(`Invalid status: "${opts.status}". Must be one of: ${VALID_STATUSES.join(", ")}`);
|
|
257
|
+
}
|
|
258
|
+
if (!VALID_TYPES.includes(opts.type)) {
|
|
259
|
+
errors.push(`Invalid type: "${opts.type}". Must be one of: ${VALID_TYPES.join(", ")}`);
|
|
260
|
+
}
|
|
261
|
+
if (!VALID_PRIORITIES.includes(opts.priority)) {
|
|
262
|
+
errors.push(`Invalid priority: "${opts.priority}". Must be one of: ${VALID_PRIORITIES.join(", ")}`);
|
|
263
|
+
}
|
|
264
|
+
if (opts.id && !PJR_ID_RE.test(opts.id)) {
|
|
265
|
+
errors.push(`Invalid ID: "${opts.id}". Must match PJR-XXXX (e.g., PJR-0001)`);
|
|
266
|
+
}
|
|
267
|
+
if (opts.registeredAt !== CELL_TODO && !REGISTER_TIMESTAMP_RE.test(opts.registeredAt)) {
|
|
268
|
+
errors.push(`Invalid registered: "${opts.registeredAt}". Must be an RFC 3339 UTC date-time (YYYY-MM-DDTHH:MM:SSZ) or _TODO_`);
|
|
269
|
+
}
|
|
270
|
+
if (!/^(\d{4}-\d{2}-\d{2}|-|_TODO_)$/.test(opts.due)) {
|
|
271
|
+
errors.push(`Invalid due: "${opts.due}". Must be YYYY-MM-DD, -, or _TODO_`);
|
|
272
|
+
}
|
|
273
|
+
if (opts.completedAt !== CELL_NONE && !REGISTER_TIMESTAMP_RE.test(opts.completedAt)) {
|
|
274
|
+
errors.push(`Invalid completed: "${opts.completedAt}". Must be an RFC 3339 UTC date-time (YYYY-MM-DDTHH:MM:SSZ) or -`);
|
|
275
|
+
}
|
|
276
|
+
if (errors.length > 0) {
|
|
277
|
+
throw new Error(errors.join("\n"));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// ================================
|
|
281
|
+
// Slug
|
|
282
|
+
// ================================
|
|
283
|
+
export function slugify(text) {
|
|
284
|
+
return (text
|
|
285
|
+
.toLowerCase()
|
|
286
|
+
.replace(/[^a-z0-9\s-]/g, " ")
|
|
287
|
+
.trim()
|
|
288
|
+
.replace(/[\s_]+/g, "-")
|
|
289
|
+
.replace(/-+/g, "-")
|
|
290
|
+
.replace(/^-|-$/g, "") || "item");
|
|
291
|
+
}
|
|
292
|
+
// 日本語主体のタイトルから ASCII の断片だけを topic にすると、個票名から内容を
|
|
293
|
+
// 推測できなくなる。区切り記号は数えず、文字・数字の過半が非 ASCII で、抽出できた
|
|
294
|
+
// ASCII 語が 1 語だけの場合を「意味を失う可能性がある既定 topic」とみなす。
|
|
295
|
+
export function derivedTopicNeedsWarning(title, topic) {
|
|
296
|
+
const asciiWords = title.match(/[a-z0-9]+/giu) ?? [];
|
|
297
|
+
if (topic === "item" && asciiWords.length === 0)
|
|
298
|
+
return true;
|
|
299
|
+
if (asciiWords.length !== 1)
|
|
300
|
+
return false;
|
|
301
|
+
const lettersAndNumbers = [...title].filter((char) => /[\p{L}\p{N}]/u.test(char));
|
|
302
|
+
const asciiCount = lettersAndNumbers.filter((char) => /[a-z0-9]/iu.test(char)).length;
|
|
303
|
+
return lettersAndNumbers.length - asciiCount > asciiCount;
|
|
304
|
+
}
|
|
305
|
+
export function printDerivedTopicWarning(topic) {
|
|
306
|
+
process.stdout.write(`Warning: derived topic "${topic}" may not describe the title. ` +
|
|
307
|
+
"Specify --topic with a lowercase, hyphen-separated English slug, or change it later " +
|
|
308
|
+
"with register update --topic.\n");
|
|
309
|
+
}
|
|
310
|
+
// ================================
|
|
311
|
+
// Ticket Generation
|
|
312
|
+
// ================================
|
|
313
|
+
function getTitlePlaceholder(type) {
|
|
314
|
+
return `_${type.toUpperCase().replace(/-/g, "_")}_TITLE_`;
|
|
315
|
+
}
|
|
316
|
+
function generateTicket(opts) {
|
|
317
|
+
if (!existsSync(opts.templatePath)) {
|
|
318
|
+
throw new Error(`Template not found: ${opts.templatePath}`);
|
|
319
|
+
}
|
|
320
|
+
let content = readFileSync(opts.templatePath, "utf8");
|
|
321
|
+
content = flattenTemplateFrontmatter(content);
|
|
322
|
+
const pjrLower = opts.displayId.toLowerCase();
|
|
323
|
+
// Keep the canonical document ID aligned with the ticket filename.
|
|
324
|
+
content = content.replace(/_PJR_DOCUMENT_ID_/g, `${opts.projectId}:${pjrLower}-${opts.topic}`);
|
|
325
|
+
// Replace remaining project id placeholder
|
|
326
|
+
content = content.replace(/_PROJECT_ID_/g, opts.projectId);
|
|
327
|
+
// Replace display id placeholder with uppercase
|
|
328
|
+
content = content.replace(/_PJR-XXXX_/g, opts.displayId);
|
|
329
|
+
// Replace type-specific title placeholder
|
|
330
|
+
const titlePh = getTitlePlaceholder(opts.type);
|
|
331
|
+
const safeTitle = inlineCodeAnglePlaceholders(opts.title);
|
|
332
|
+
content = content.replace(new RegExp(titlePh.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), safeTitle);
|
|
333
|
+
return content;
|
|
334
|
+
}
|
|
335
|
+
// 個票の完成形(テンプレート展開 + 説明の反映 + 登録項目 frontmatter)を組み立てる。
|
|
336
|
+
// 登録項目の構造化フィールドは frontmatter、タイトルは H1、説明は概要段落が正本になる。
|
|
337
|
+
export function buildRegisterItemContent(opts) {
|
|
338
|
+
let content = generateTicket({
|
|
339
|
+
projectId: opts.projectId,
|
|
340
|
+
displayId: opts.displayId,
|
|
341
|
+
topic: opts.topic,
|
|
342
|
+
type: opts.fields.type,
|
|
343
|
+
title: opts.fields.title,
|
|
344
|
+
templatePath: opts.templatePath,
|
|
345
|
+
});
|
|
346
|
+
if (!isPlaceholderCell(opts.fields.description)) {
|
|
347
|
+
content = setRegisterItemDescription(content, opts.fields.description);
|
|
348
|
+
}
|
|
349
|
+
return applyRegisterItemFields(content, registerItemFieldsFromItem({
|
|
350
|
+
id: opts.displayId,
|
|
351
|
+
status: opts.fields.status,
|
|
352
|
+
title: opts.fields.title,
|
|
353
|
+
description: opts.fields.description,
|
|
354
|
+
type: opts.fields.type,
|
|
355
|
+
priority: opts.fields.priority,
|
|
356
|
+
owner: opts.fields.owner,
|
|
357
|
+
registeredAt: opts.fields.registeredAt,
|
|
358
|
+
due: opts.fields.due,
|
|
359
|
+
completedAt: opts.fields.completedAt,
|
|
360
|
+
conclusion: opts.fields.conclusion,
|
|
361
|
+
ticket: "-",
|
|
362
|
+
}));
|
|
363
|
+
}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { inlineCodeAnglePlaceholders } from "./exec-shared.js";
|
|
4
|
+
import { appendRegisterEvent, buildRegisterEvent, registerEventFilePath, } from "./register-events.js";
|
|
5
|
+
import { nowUtcTimestamp } from "./register-date.js";
|
|
6
|
+
import { CELL_NONE, CELL_TODO, REMOVE_REGISTER_ITEM_FIELD, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "./register-item.js";
|
|
7
|
+
import { resolveSpecdojoTemplatePath } from "./template-resolution.js";
|
|
8
|
+
export function registerCreateCommands(reg, dependencies) {
|
|
9
|
+
const { addProjectOption, addRegisterCommitOptions, atomicWriteFile, buildRegisterItemContent, derivedTopicNeedsWarning, generateDerivedViewFiles, loadRegisterItems, parseRegisterTimestampOption, planRegisterItem, printCommandError, printDerivedTopicWarning, registerEventActor, registerTopicPattern, resolveRegisterPaths, runRegisterMutation, slugify, writeDerivedViews, } = dependencies;
|
|
10
|
+
// --- scaffold ---
|
|
11
|
+
const scaffoldCmd = reg
|
|
12
|
+
.command("scaffold")
|
|
13
|
+
.description("Initialize the register directory and generate its views");
|
|
14
|
+
addProjectOption(scaffoldCmd);
|
|
15
|
+
scaffoldCmd.option("--dry-run", "Print generated content to stdout without writing", false);
|
|
16
|
+
scaffoldCmd.action((opts) => {
|
|
17
|
+
try {
|
|
18
|
+
const paths = resolveRegisterPaths(opts);
|
|
19
|
+
if (opts.dryRun) {
|
|
20
|
+
for (const view of generateDerivedViewFiles(paths, "all")) {
|
|
21
|
+
process.stdout.write(`=== ${view.path} ===\n${view.content}\n\n`);
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
mkdirSync(paths.projectRegisterPath, { recursive: true });
|
|
26
|
+
process.stdout.write(`Created: ${paths.projectRegisterPath}/\n`);
|
|
27
|
+
for (const view of writeDerivedViews(paths, "all")) {
|
|
28
|
+
process.stdout.write(`Generated: ${view.path}\n`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
printCommandError(error);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
// --- add ---
|
|
36
|
+
const addCmd = reg.command("add").description("Add a new item to pjr-index.md");
|
|
37
|
+
addProjectOption(addCmd);
|
|
38
|
+
addCmd.requiredOption("--type <type>", `Item type: ${VALID_TYPES.join(" | ")}`);
|
|
39
|
+
addCmd.requiredOption("--title <title>", "Short title for the item");
|
|
40
|
+
addCmd.option("--description <text>", "Description shown in the list", "_TODO_");
|
|
41
|
+
addCmd.option("--priority <priority>", `Priority: ${VALID_PRIORITIES.join(" | ")}`, "medium");
|
|
42
|
+
addCmd.option("--status <status>", `Status: ${VALID_STATUSES.join(" | ")}`, "open");
|
|
43
|
+
addCmd.option("--owner <owner>", "Owner or role", "_TODO_");
|
|
44
|
+
addCmd.option("--registered <datetime>", "Registration date-time (RFC 3339 with time zone, or _TODO_; defaults to now in UTC)");
|
|
45
|
+
addCmd.option("--due <date>", "Due date (YYYY-MM-DD, -, or _TODO_)", "_TODO_");
|
|
46
|
+
addCmd.option("--completed <datetime>", "Completion date-time (RFC 3339 with time zone, or -)", "-");
|
|
47
|
+
addCmd.option("--conclusion <text>", "Conclusion or resolution summary", "-");
|
|
48
|
+
addCmd.option("--id <id>", "Display ID (e.g., PJR-0061); auto-incremented if omitted");
|
|
49
|
+
addCmd.option("--topic <topic>", "Topic slug for ticket filename; derived from --title if omitted");
|
|
50
|
+
addCmd.option("--by <actor>", "Actor recorded in the append-only register event");
|
|
51
|
+
addCmd.option("--reason <text>", "Reason recorded in the append-only register event");
|
|
52
|
+
addCmd.option("--force", "Overwrite existing ticket file", false);
|
|
53
|
+
addCmd.option("--dry-run", "Print the generated item file without writing", false);
|
|
54
|
+
addRegisterCommitOptions(addCmd);
|
|
55
|
+
addCmd.action(async (opts) => {
|
|
56
|
+
await runRegisterMutation("add", opts, ({ paths, assertCommitTargetsClean }) => {
|
|
57
|
+
const explicitTopic = opts.topic?.trim();
|
|
58
|
+
const topic = explicitTopic || slugify(opts.title);
|
|
59
|
+
const warnAboutDerivedTopic = explicitTopic === undefined && derivedTopicNeedsWarning(opts.title, topic);
|
|
60
|
+
if (!registerTopicPattern.test(topic)) {
|
|
61
|
+
throw new Error(`Invalid topic: "${topic}". Must use lowercase letters, numbers, and single hyphens`);
|
|
62
|
+
}
|
|
63
|
+
const registeredAt = parseRegisterTimestampOption(opts.registered, "registered", CELL_TODO);
|
|
64
|
+
const completedAt = parseRegisterTimestampOption(opts.completed, "completed", CELL_NONE);
|
|
65
|
+
const fields = {
|
|
66
|
+
type: opts.type,
|
|
67
|
+
title: opts.title,
|
|
68
|
+
description: opts.description,
|
|
69
|
+
priority: opts.priority,
|
|
70
|
+
status: opts.status,
|
|
71
|
+
owner: opts.owner,
|
|
72
|
+
registeredAt: registeredAt ?? nowUtcTimestamp(),
|
|
73
|
+
due: opts.due,
|
|
74
|
+
completedAt: completedAt ?? CELL_NONE,
|
|
75
|
+
conclusion: opts.conclusion,
|
|
76
|
+
};
|
|
77
|
+
const templatePath = resolveSpecdojoTemplatePath(`pjr-${opts.type}-template.md`);
|
|
78
|
+
const { assignedId: displayId, ticketFilename } = planRegisterItem({
|
|
79
|
+
existingIds: loadRegisterItems(paths).map((view) => view.id),
|
|
80
|
+
explicitId: opts.id?.trim() || undefined,
|
|
81
|
+
fields,
|
|
82
|
+
topic,
|
|
83
|
+
});
|
|
84
|
+
const ticketPath = join(paths.projectRegisterPath, ticketFilename);
|
|
85
|
+
const content = buildRegisterItemContent({
|
|
86
|
+
projectId: paths.projectId,
|
|
87
|
+
displayId,
|
|
88
|
+
topic,
|
|
89
|
+
fields,
|
|
90
|
+
templatePath,
|
|
91
|
+
});
|
|
92
|
+
const addEvent = buildRegisterEvent({
|
|
93
|
+
afterContent: content,
|
|
94
|
+
filename: ticketFilename,
|
|
95
|
+
timeZone: paths.registerDateTimeZone,
|
|
96
|
+
action: "add",
|
|
97
|
+
actor: registerEventActor(opts),
|
|
98
|
+
reason: opts.reason?.trim() || "item added",
|
|
99
|
+
});
|
|
100
|
+
if (!addEvent)
|
|
101
|
+
throw new Error(`Failed to build add event for ${displayId}`);
|
|
102
|
+
if (opts.dryRun) {
|
|
103
|
+
process.stdout.write(`Would create ${ticketPath}:\n${content}\n`);
|
|
104
|
+
process.stdout.write(`Would create ${registerEventFilePath(paths.projectRegisterPath, displayId)}:\n` +
|
|
105
|
+
`${appendRegisterEvent(undefined, addEvent)}\n`);
|
|
106
|
+
if (warnAboutDerivedTopic)
|
|
107
|
+
printDerivedTopicWarning(topic);
|
|
108
|
+
return { id: displayId, title: opts.title };
|
|
109
|
+
}
|
|
110
|
+
if (!opts.force && existsSync(ticketPath)) {
|
|
111
|
+
throw new Error(`Item file already exists (use --force to overwrite): ${ticketPath}`);
|
|
112
|
+
}
|
|
113
|
+
const eventPath = registerEventFilePath(paths.projectRegisterPath, displayId);
|
|
114
|
+
assertCommitTargetsClean([ticketPath, eventPath]);
|
|
115
|
+
if (!opts.force && existsSync(eventPath)) {
|
|
116
|
+
throw new Error(`Register event file already exists (use --force to overwrite): ${eventPath}`);
|
|
117
|
+
}
|
|
118
|
+
mkdirSync(paths.projectRegisterPath, { recursive: true });
|
|
119
|
+
atomicWriteFile(ticketPath, content);
|
|
120
|
+
atomicWriteFile(eventPath, appendRegisterEvent(undefined, addEvent));
|
|
121
|
+
process.stdout.write(`Created: ${ticketPath} (added ${displayId})\n`);
|
|
122
|
+
process.stdout.write(`Created: ${eventPath}\n`);
|
|
123
|
+
if (existsSync(paths.pjrIndexPath)) {
|
|
124
|
+
for (const view of writeDerivedViews(paths, "all")) {
|
|
125
|
+
process.stdout.write(`Generated: ${view.path}\n`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (warnAboutDerivedTopic)
|
|
129
|
+
printDerivedTopicWarning(topic);
|
|
130
|
+
return { id: displayId, title: opts.title };
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
export function registerUpdateCommand(reg, dependencies) {
|
|
135
|
+
const { addProjectOption, addRegisterCommitOptions, applyItemUpdate, assertRegisterItemCommitTargetsClean, loadItemForUpdate, planRetopic, registerEventActor, registerTopicPattern, retopicPjrItem, runRegisterMutation, ticketTopicFromFilename, } = dependencies;
|
|
136
|
+
// --- update ---
|
|
137
|
+
const updateCmd = reg.command("update").description("Update fields of a register item");
|
|
138
|
+
addProjectOption(updateCmd);
|
|
139
|
+
updateCmd.requiredOption("--id <id>", "Item ID (PJR-XXXX)");
|
|
140
|
+
updateCmd.option("--title <title>", "Update title");
|
|
141
|
+
updateCmd.option("--description <text>", "Update description");
|
|
142
|
+
updateCmd.option("--priority <priority>", `Update priority: ${VALID_PRIORITIES.join(" | ")}`);
|
|
143
|
+
updateCmd.option("--owner <owner>", "Update owner or role");
|
|
144
|
+
updateCmd.option("--due <date>", "Update due date (YYYY-MM-DD, -, or _TODO_)");
|
|
145
|
+
updateCmd.option("--conclusion <text>", "Update conclusion or use - to remove it");
|
|
146
|
+
updateCmd.option("--block-reason <text>", "Update the waiting reason or use - to remove it");
|
|
147
|
+
updateCmd.option("--topic <topic>", "Update the topic slug in the ticket filename and document ID");
|
|
148
|
+
updateCmd.option("--by <actor>", "Actor recorded in the append-only register event");
|
|
149
|
+
updateCmd.option("--reason <text>", "Reason recorded in the append-only register event");
|
|
150
|
+
updateCmd.option("--dry-run", "Print change without writing", false);
|
|
151
|
+
addRegisterCommitOptions(updateCmd);
|
|
152
|
+
updateCmd.action(async (opts) => {
|
|
153
|
+
await runRegisterMutation("update", opts, (context) => {
|
|
154
|
+
const { paths } = context;
|
|
155
|
+
const view = loadItemForUpdate(paths, opts.id);
|
|
156
|
+
const item = view.item;
|
|
157
|
+
const hasUpdates = [
|
|
158
|
+
"title",
|
|
159
|
+
"description",
|
|
160
|
+
"priority",
|
|
161
|
+
"owner",
|
|
162
|
+
"due",
|
|
163
|
+
"conclusion",
|
|
164
|
+
"blockReason",
|
|
165
|
+
"topic",
|
|
166
|
+
].some((key) => opts[key] !== undefined);
|
|
167
|
+
if (!hasUpdates) {
|
|
168
|
+
throw new Error("At least one field option must be specified (--title, --description, --priority, --owner, --due, --conclusion, --block-reason, --topic)");
|
|
169
|
+
}
|
|
170
|
+
if (opts.priority !== undefined &&
|
|
171
|
+
!VALID_PRIORITIES.includes(opts.priority)) {
|
|
172
|
+
throw new Error(`Invalid priority: "${opts.priority}". Must be one of: ${VALID_PRIORITIES.join(", ")}`);
|
|
173
|
+
}
|
|
174
|
+
if (opts.due !== undefined && !/^(\d{4}-\d{2}-\d{2}|-|_TODO_)$/.test(opts.due)) {
|
|
175
|
+
throw new Error(`Invalid due: "${opts.due}". Must be YYYY-MM-DD, -, or _TODO_`);
|
|
176
|
+
}
|
|
177
|
+
const topic = opts.topic?.trim();
|
|
178
|
+
if (topic !== undefined && !registerTopicPattern.test(topic)) {
|
|
179
|
+
throw new Error(`Invalid topic: "${topic}". Must use lowercase letters, numbers, and single hyphens`);
|
|
180
|
+
}
|
|
181
|
+
const blockReason = opts.blockReason?.trim();
|
|
182
|
+
if (blockReason !== undefined && blockReason === "") {
|
|
183
|
+
throw new Error("Block reason must not be empty; use - to remove it");
|
|
184
|
+
}
|
|
185
|
+
if (blockReason !== undefined && blockReason !== "-" && item.status !== "waiting") {
|
|
186
|
+
throw new Error(`Cannot set block reason for ${item.id}: status is "${item.status}" (expected "waiting"). Use - to remove it.`);
|
|
187
|
+
}
|
|
188
|
+
const blockReasonUpdates = blockReason === undefined
|
|
189
|
+
? undefined
|
|
190
|
+
: {
|
|
191
|
+
block_reason: blockReason === "-"
|
|
192
|
+
? REMOVE_REGISTER_ITEM_FIELD
|
|
193
|
+
: inlineCodeAnglePlaceholders(blockReason),
|
|
194
|
+
};
|
|
195
|
+
const updated = {
|
|
196
|
+
...item,
|
|
197
|
+
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
198
|
+
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
199
|
+
...(opts.priority !== undefined ? { priority: opts.priority } : {}),
|
|
200
|
+
...(opts.owner !== undefined ? { owner: opts.owner } : {}),
|
|
201
|
+
...(opts.due !== undefined ? { due: opts.due } : {}),
|
|
202
|
+
...(opts.conclusion !== undefined ? { conclusion: opts.conclusion } : {}),
|
|
203
|
+
};
|
|
204
|
+
const currentTopic = view.ticketFilename
|
|
205
|
+
? ticketTopicFromFilename(opts.id, view.ticketFilename)
|
|
206
|
+
: undefined;
|
|
207
|
+
if (topic !== undefined && topic !== currentTopic) {
|
|
208
|
+
const retopicPlan = planRetopic(paths, opts.id, topic);
|
|
209
|
+
context.assertCommitTargetsClean([
|
|
210
|
+
retopicPlan.ticketRename.from,
|
|
211
|
+
...retopicPlan.writes.map((write) => write.path),
|
|
212
|
+
registerEventFilePath(paths.projectRegisterPath, item.id),
|
|
213
|
+
]);
|
|
214
|
+
retopicPjrItem({
|
|
215
|
+
paths,
|
|
216
|
+
id: opts.id,
|
|
217
|
+
topic,
|
|
218
|
+
updated,
|
|
219
|
+
dryRun: opts.dryRun,
|
|
220
|
+
...(blockReasonUpdates ? { fieldUpdates: blockReasonUpdates } : {}),
|
|
221
|
+
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
222
|
+
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
223
|
+
actor: registerEventActor(opts),
|
|
224
|
+
reason: opts.reason?.trim() || "",
|
|
225
|
+
});
|
|
226
|
+
return { id: item.id, title: updated.title };
|
|
227
|
+
}
|
|
228
|
+
assertRegisterItemCommitTargetsClean(context, view);
|
|
229
|
+
applyItemUpdate({
|
|
230
|
+
paths,
|
|
231
|
+
view,
|
|
232
|
+
updated,
|
|
233
|
+
dryRun: opts.dryRun,
|
|
234
|
+
action: "fields updated",
|
|
235
|
+
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
236
|
+
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
237
|
+
...(blockReasonUpdates ? { fieldUpdates: blockReasonUpdates } : {}),
|
|
238
|
+
eventAction: "update",
|
|
239
|
+
eventActor: registerEventActor(opts),
|
|
240
|
+
eventReason: opts.reason?.trim() || "fields updated",
|
|
241
|
+
});
|
|
242
|
+
return { id: item.id, title: updated.title };
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}
|
package/dist/register-events.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
-
import
|
|
6
|
+
import { dump, load } from "./yaml.js";
|
|
7
7
|
import { CELL_NONE, displayIdFromTicketFilename, readRegisterItemContent, readSpecdojoFields, toDisplayItem, updateSpecdojoFields, VALID_STATUSES, } from "./register-item.js";
|
|
8
8
|
import { isUtcIsoSeconds, nowUtcIsoSeconds } from "./exec-shared.js";
|
|
9
9
|
export const REGISTER_EVENTS_DIRNAME = "events";
|
|
@@ -188,7 +188,7 @@ export function validateRegisterEventShape(value, source) {
|
|
|
188
188
|
export function readRegisterEventsFromContent(content, source) {
|
|
189
189
|
let parsed;
|
|
190
190
|
try {
|
|
191
|
-
parsed =
|
|
191
|
+
parsed = load(content);
|
|
192
192
|
}
|
|
193
193
|
catch (error) {
|
|
194
194
|
const detail = error instanceof Error ? error.message : String(error);
|
|
@@ -206,10 +206,10 @@ export function readRegisterEventsFromContent(content, source) {
|
|
|
206
206
|
return events;
|
|
207
207
|
}
|
|
208
208
|
export function serializeRegisterEvents(events) {
|
|
209
|
-
return `${REGISTER_EVENTS_SCHEMA_MODELINE}\n${
|
|
209
|
+
return `${REGISTER_EVENTS_SCHEMA_MODELINE}\n${dump([...events], {
|
|
210
210
|
lineWidth: -1,
|
|
211
211
|
noRefs: true,
|
|
212
|
-
|
|
212
|
+
quoteStyle: "double",
|
|
213
213
|
})}`;
|
|
214
214
|
}
|
|
215
215
|
export function appendRegisterEvent(content, event) {
|