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.
Files changed (104) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/catalog-build-references.js +144 -0
  3. package/dist/catalog-build-render.js +144 -0
  4. package/dist/catalog-build.js +13 -290
  5. package/dist/catalog-generate.js +6 -9
  6. package/dist/catalog-plan-generate.js +2 -2
  7. package/dist/catalog-plan.js +6 -6
  8. package/dist/catalog-scaffold.js +4 -4
  9. package/dist/catalog.js +2 -2
  10. package/dist/dashboard-exec-records.js +105 -0
  11. package/dist/dashboard-routines.js +255 -0
  12. package/dist/dashboard-shared.js +14 -0
  13. package/dist/dashboard-timeline.js +175 -0
  14. package/dist/dashboard.js +10 -544
  15. package/dist/deliverable-trash.js +3 -3
  16. package/dist/doc-index.js +3 -3
  17. package/dist/exec-commands.js +557 -0
  18. package/dist/exec-core.js +457 -0
  19. package/dist/exec-plans-core.js +693 -0
  20. package/dist/exec-plans-generation.js +206 -0
  21. package/dist/exec-plans-storage.js +131 -0
  22. package/dist/exec-plans.js +3 -1018
  23. package/dist/exec-repo-integration-git.js +23 -0
  24. package/dist/exec-repo-integration-sync.js +264 -0
  25. package/dist/exec-repo-integration.js +4 -281
  26. package/dist/exec-reporter-output.js +206 -0
  27. package/dist/exec-reporter.js +2 -206
  28. package/dist/exec-results.js +22 -15
  29. package/dist/exec-run-agent-pipeline.js +256 -0
  30. package/dist/exec-run-agent.js +531 -0
  31. package/dist/exec-run-in-place.js +541 -0
  32. package/dist/exec-run-job.js +717 -0
  33. package/dist/exec-run-lifecycle-commands.js +522 -0
  34. package/dist/exec-run-mode-shared.js +140 -0
  35. package/dist/exec-run-register-command.js +244 -0
  36. package/dist/exec-run-register-core.js +386 -0
  37. package/dist/exec-run-register-mode.js +206 -0
  38. package/dist/exec-run-register-resume.js +393 -0
  39. package/dist/exec-run-register-state.js +322 -0
  40. package/dist/exec-run-register-worktree.js +509 -0
  41. package/dist/exec-run-schedule-mode.js +294 -0
  42. package/dist/exec-run-schedule-prepare.js +353 -0
  43. package/dist/exec-run-schedule-task.js +572 -0
  44. package/dist/exec-run-shared.js +399 -0
  45. package/dist/exec-run.js +11 -6182
  46. package/dist/exec-shared.js +2 -2
  47. package/dist/exec-trial-commands.js +558 -0
  48. package/dist/exec-trial-core.js +371 -0
  49. package/dist/exec-trial.js +2 -921
  50. package/dist/exec-worktree-ops-commit.js +707 -0
  51. package/dist/exec-worktree-ops-lifecycle.js +292 -0
  52. package/dist/exec-worktree-ops-merge.js +303 -0
  53. package/dist/exec-worktree-ops.js +3 -1292
  54. package/dist/exec-worktree.js +32 -4
  55. package/dist/exec.js +2 -1006
  56. package/dist/frontmatter-namespace.js +2 -2
  57. package/dist/grade-apply.js +734 -0
  58. package/dist/grade-command-apply.js +250 -0
  59. package/dist/grade-command-inspect.js +138 -0
  60. package/dist/grade-command-plan.js +101 -0
  61. package/dist/grade-command-shared.js +68 -0
  62. package/dist/grade-core.js +307 -0
  63. package/dist/grade-markdown.js +274 -0
  64. package/dist/grade-pipeline-state.js +184 -0
  65. package/dist/grade-plan.js +507 -0
  66. package/dist/grade-result.js +5 -5
  67. package/dist/grade-target-discovery.js +265 -0
  68. package/dist/grade-targets.js +432 -0
  69. package/dist/grade.js +14 -3188
  70. package/dist/init-command.js +7 -7
  71. package/dist/job-definition.js +670 -0
  72. package/dist/job.js +9 -673
  73. package/dist/kata-command.js +2 -2
  74. package/dist/register-command-types.js +1 -0
  75. package/dist/register-core.js +363 -0
  76. package/dist/register-create-commands.js +245 -0
  77. package/dist/register-events.js +4 -4
  78. package/dist/register-item.js +6 -6
  79. package/dist/register-maintenance-commands.js +187 -0
  80. package/dist/register-migration.js +268 -0
  81. package/dist/register-renumber.js +314 -0
  82. package/dist/register-transition-commands.js +248 -0
  83. package/dist/register-update.js +230 -0
  84. package/dist/register-views.js +256 -0
  85. package/dist/register.js +61 -2069
  86. package/dist/review-plan.js +3 -3
  87. package/dist/routine-definition.js +401 -0
  88. package/dist/routine.js +6 -402
  89. package/dist/schedule-approach.js +2 -2
  90. package/dist/schedule-strategy-generate-document.js +273 -0
  91. package/dist/schedule-strategy-generate-scope.js +199 -0
  92. package/dist/schedule-strategy-generate.js +9 -473
  93. package/dist/schedule.js +4 -4
  94. package/dist/specdojo-config.js +3 -4
  95. package/dist/viewpoint-document-kinds-check.js +3 -3
  96. package/dist/yaml-pages.js +4 -4
  97. package/dist/yaml.js +28 -0
  98. package/docs/ja/specdojo/guides/exec-config-guide.md +6 -6
  99. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +20 -18
  100. package/docs/ja/specdojo/guides/routine-operation-guide.md +1 -1
  101. package/package.json +4 -5
  102. package/templates/antigravity/README.md +3 -3
  103. package/templates/antigravity/exec-defaults-snippet.yaml +6 -4
  104. package/templates/init-exec-defaults.yaml +3 -1
@@ -4,489 +4,25 @@
4
4
  // by code so `schedule build` and `exec refresh` stay deterministic.
5
5
  import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync, } from "node:fs";
6
6
  import { tmpdir } from "node:os";
7
- import { basename, join, relative, resolve } from "node:path";
8
- import yaml from "js-yaml";
7
+ import { basename, join, resolve } from "node:path";
8
+ import { dump, load as loadYaml } from "./yaml.js";
9
9
  import { resolveSpecdojoPath } from "./template-resolution.js";
10
10
  import Ajv2020Module from "ajv/dist/2020.js";
11
- import { collectResolvedDeliverables } from "./catalog-build.js";
12
- import { resolveBasePath } from "./catalog-paths.js";
13
11
  import { diffPlanText } from "./catalog-plan.js";
14
12
  import { readYaml } from "./exec-shared.js";
15
13
  import { buildScheduleTrack } from "./schedule-build.js";
16
- import { collectCatalogFilesByDomain, loadTimelineIndex } from "./timeline-build.js";
17
14
  import { collectApproachFacts, deriveApproaches, } from "./schedule-approach.js";
18
- import { AUTHOR_PHASE_SETS, PHASE_SET_ORDER, profileFor, renderPhase, STRATEGY_PHASE_SETS, } from "./schedule-strategy-profiles.js";
15
+ import { buildStrategyDocument, } from "./schedule-strategy-generate-document.js";
16
+ import { collectScopeDeliverables, isRecord, loadKnownRoles, resolveDeliverableOwners, resolveTrackScopeCatalogs, } from "./schedule-strategy-generate-scope.js";
19
17
  export const SCH_STRATEGY_SCHEMA_PATH = "docs/specdojo/schemas/v1/sch-strategy.schema.yaml";
20
- function isRecord(value) {
21
- return typeof value === "object" && value !== null && !Array.isArray(value);
22
- }
23
- function toRepoAbsolute(absolutePath, repoRoot) {
24
- return `/${relative(repoRoot, absolutePath).replace(/\\/g, "/")}`;
25
- }
26
- // ---- scope resolution ---------------------------------------------------------
27
- // Artifact label shown in the timeline for gates and milestones. Catalog titles follow
28
- // `成果物カタログ(<name>)`; anything else is left unset rather than guessed.
29
- export function artifactNameFromCatalogTitle(title) {
30
- const match = title?.match(/^成果物カタログ((.+))$/);
31
- return match ? match[1] : undefined;
32
- }
33
- // Resolves the catalogs a track covers. An existing strategy is authoritative (a human may have
34
- // narrowed the scope on purpose); otherwise the Timeline track plan decides which domains belong
35
- // to the track, and every catalog file of those domains (including physical splits) is included.
36
- export function resolveTrackScopeCatalogs(opts) {
37
- const { repoRoot, catalogPath, timelinePath, track } = opts;
38
- const warnings = [];
39
- const errors = [];
40
- const byDomain = collectCatalogFilesByDomain(catalogPath);
41
- const refFor = (filePath, localIds) => {
42
- const doc = readYaml(filePath);
43
- if (!doc?.id || !doc.domain) {
44
- errors.push(`${filePath}: id / domain が読み取れないため scope に含められない。`);
45
- return null;
46
- }
47
- return {
48
- id: doc.id,
49
- path: toRepoAbsolute(filePath, repoRoot),
50
- ...(localIds ? { local_ids: localIds } : {}),
51
- domain: doc.domain,
52
- ...(doc.title ? { title: doc.title } : {}),
53
- };
54
- };
55
- const timelineCatalogs = [];
56
- const indexFile = join(timelinePath, "tml-index.yaml");
57
- if (existsSync(indexFile)) {
58
- const { index, errors: loadErrors } = loadTimelineIndex(indexFile);
59
- if (loadErrors.length > 0) {
60
- warnings.push(`${basename(indexFile)}: ${loadErrors.join(" / ")}`);
61
- }
62
- const plan = index.tracks.find((entry) => entry.track === track);
63
- if (plan) {
64
- for (const domain of plan.domains) {
65
- const files = byDomain.get(domain) ?? [];
66
- if (files.length === 0) {
67
- warnings.push(`timeline: track '${track}' の domain '${domain}' に対応する dct-*.yaml が無い(scope から除外)。`);
68
- continue;
69
- }
70
- for (const filePath of files) {
71
- const ref = refFor(filePath);
72
- if (ref)
73
- timelineCatalogs.push(ref);
74
- }
75
- }
76
- if (plan.catalog_status !== "primary") {
77
- warnings.push(`timeline: track '${track}' の catalog_status は '${plan.catalog_status}'。` +
78
- `strategy 生成では昇格させないため、確認後に人間が primary へ更新する。`);
79
- }
80
- }
81
- else {
82
- warnings.push(`timeline: track '${track}' が tml-index.yaml に無い。`);
83
- }
84
- }
85
- const existingScope = isRecord(opts.existingStrategy?.scope)
86
- ? opts.existingStrategy.scope
87
- : undefined;
88
- const existingCatalogs = Array.isArray(existingScope?.catalogs) ? existingScope.catalogs : [];
89
- if (existingCatalogs.length > 0) {
90
- const catalogs = [];
91
- for (const entry of existingCatalogs) {
92
- if (!isRecord(entry) || typeof entry.path !== "string")
93
- continue;
94
- let localIds;
95
- if (entry.local_ids !== undefined) {
96
- if (!Array.isArray(entry.local_ids) ||
97
- entry.local_ids.length === 0 ||
98
- entry.local_ids.some((localId) => typeof localId !== "string" || localId.length === 0)) {
99
- errors.push(`scope.catalogs: ${entry.path} の local_ids は空でない文字列配列にする。`);
100
- }
101
- else {
102
- localIds = entry.local_ids;
103
- }
104
- }
105
- const filePath = resolve(repoRoot, entry.path.replace(/^\//, ""));
106
- if (!existsSync(filePath)) {
107
- errors.push(`scope.catalogs: カタログが見つからない: ${entry.path}`);
108
- continue;
109
- }
110
- const ref = refFor(filePath, localIds);
111
- if (ref)
112
- catalogs.push(ref);
113
- }
114
- const known = new Set(catalogs.map((catalog) => catalog.id));
115
- for (const catalog of timelineCatalogs) {
116
- if (known.has(catalog.id))
117
- continue;
118
- warnings.push(`timeline の domain から解決した ${catalog.id} が既存 scope に無い。scope を広げる場合は ` +
119
- `sch-strategy-${track}.yaml の scope.catalogs を先に更新する。`);
120
- }
121
- return { catalogs, source: "strategy", warnings, errors };
122
- }
123
- if (timelineCatalogs.length === 0) {
124
- errors.push(`track '${track}' の scope を解決できない。tml-index.yaml の domains と ` +
125
- `dct-<domain>.yaml を用意するか、既存 strategy の scope.catalogs を先に定義する。`);
126
- }
127
- return { catalogs: timelineCatalogs, source: "timeline", warnings, errors };
128
- }
129
- // Deliverables of the scoped catalogs, in catalog order. `include_kinds` mirrors the strategy
130
- // scope (work by default).
131
- export function collectScopeDeliverables(opts) {
132
- const errors = [];
133
- const deliverables = [];
134
- for (const catalog of opts.catalogs) {
135
- const filePath = resolve(opts.repoRoot, catalog.path.replace(/^\//, ""));
136
- const doc = readYaml(filePath);
137
- if (!doc?.groups) {
138
- errors.push(`${catalog.path}: groups が無い。`);
139
- continue;
140
- }
141
- const collected = [];
142
- collectResolvedDeliverables(doc.groups, resolveBasePath("", doc.base_path), collected);
143
- const catalogLocalIds = new Set(collected.map(({ item }) => item.local_id));
144
- for (const localId of catalog.local_ids ?? []) {
145
- if (!catalogLocalIds.has(localId)) {
146
- errors.push(`${catalog.id}: scope.local_ids の '${localId}' がカタログに存在しない。`);
147
- }
148
- }
149
- const selectedLocalIds = catalog.local_ids ? new Set(catalog.local_ids) : null;
150
- for (const { item } of collected) {
151
- if (!opts.includeKinds.includes(item.kind))
152
- continue;
153
- if (selectedLocalIds && !selectedLocalIds.has(item.local_id))
154
- continue;
155
- deliverables.push({
156
- local_id: item.local_id,
157
- catalog_id: catalog.id,
158
- depends_on: item.depends_on ?? [],
159
- });
160
- }
161
- }
162
- return { deliverables, errors };
163
- }
164
- // Owner derivation rule, in priority order:
165
- // 1. explicit --owner <local_id>=<ROLE>
166
- // 2. the owner already recorded in the existing strategy's owner_rules
167
- // 3. --default-owner <ROLE>
168
- // `done_criteria.roles` is deliberately not consulted: those are review viewpoints, not the
169
- // role that performs the work. When no rule applies, generation stops instead of guessing.
170
- export function resolveDeliverableOwners(opts) {
171
- const owners = new Map();
172
- const errors = [];
173
- const warnings = [];
174
- const unresolved = [];
175
- for (const localId of opts.localIds) {
176
- const owner = opts.overrides.get(localId) ?? opts.previous.get(localId) ?? opts.defaultOwner;
177
- if (!owner) {
178
- unresolved.push(localId);
179
- continue;
180
- }
181
- if (opts.knownRoles && opts.knownRoles.size > 0 && !opts.knownRoles.has(owner)) {
182
- errors.push(`owner '${owner}' は pm-roles.yaml に存在しない (${localId})。`);
183
- continue;
184
- }
185
- owners.set(localId, owner);
186
- }
187
- for (const localId of opts.overrides.keys()) {
188
- if (opts.localIds.includes(localId))
189
- continue;
190
- warnings.push(`--owner ${localId} は scope に含まれない成果物を指している(無視する)。`);
191
- }
192
- if (unresolved.length > 0) {
193
- errors.push(`主担当ロールを決定できない成果物がある: ${unresolved.join(", ")}。` +
194
- `--owner <local_id>=<ROLE> または --default-owner <ROLE> で明示する` +
195
- `(done_criteria.roles はレビュー観点であり主担当ではない)。`);
196
- }
197
- return { owners, errors, warnings };
198
- }
199
- export function loadKnownRoles(repoRoot, rolesPath) {
200
- if (!rolesPath)
201
- return new Set();
202
- const filePath = resolve(repoRoot, rolesPath);
203
- if (!existsSync(filePath))
204
- return new Set();
205
- const doc = readYaml(filePath);
206
- if (!isRecord(doc) || !Array.isArray(doc.roles))
207
- return new Set();
208
- const codes = doc.roles
209
- .map((role) => (isRecord(role) && typeof role.code === "string" ? role.code : ""))
210
- .filter(Boolean);
211
- return new Set(codes);
212
- }
213
- function phaseSetsOf(approach) {
214
- return profileFor(approach).phase_sets;
215
- }
216
- function orderPhaseSets(names) {
217
- const unique = [...new Set(names)];
218
- return unique.sort((left, right) => PHASE_SET_ORDER.indexOf(left) - PHASE_SET_ORDER.indexOf(right));
219
- }
220
- // Transitive catalog dependency check used to keep generated bootstrap ordering acyclic.
221
- function dependsTransitively(from, target, dependsOn) {
222
- const seen = new Set();
223
- const stack = [...(dependsOn.get(from) ?? [])];
224
- while (stack.length > 0) {
225
- const current = stack.pop();
226
- if (current === target)
227
- return true;
228
- if (seen.has(current))
229
- continue;
230
- seen.add(current);
231
- stack.push(...(dependsOn.get(current) ?? []));
232
- }
233
- return false;
234
- }
235
- export function buildStrategyDocument(input) {
236
- const warnings = [];
237
- const errors = [];
238
- const trackUpper = input.track.toUpperCase();
239
- const maintenanceKind = (approach) => {
240
- const match = approach.match(/^(rulebook|recipe|sample|template)-maintenance$/);
241
- return match?.[1];
242
- };
243
- const eligibleDeliverables = input.deliverables.filter((deliverable) => {
244
- const kind = maintenanceKind(deliverable.approach);
245
- if (!kind || !deliverable.not_needed_kata?.includes(kind))
246
- return true;
247
- errors.push(`${deliverable.local_id}: ${kind} は not-needed と宣言されているため ${kind}-maintenance を生成しない。`);
248
- return false;
249
- });
250
- const sorted = [...eligibleDeliverables].sort((left, right) => left.local_id.localeCompare(right.local_id));
251
- // --- owner_rules: one rule per (owner, approach) pair -------------------------
252
- const groups = new Map();
253
- for (const deliverable of sorted) {
254
- const owner = input.owners.get(deliverable.local_id);
255
- if (!owner) {
256
- errors.push(`${deliverable.local_id}: owner が解決できていない。`);
257
- continue;
258
- }
259
- const key = JSON.stringify([owner, deliverable.approach]);
260
- const group = groups.get(key) ?? { owner, approach: deliverable.approach, localIds: [] };
261
- group.localIds.push(deliverable.local_id);
262
- groups.set(key, group);
263
- }
264
- const orderedGroups = [...groups.values()].sort((left, right) => left.owner === right.owner
265
- ? left.approach.localeCompare(right.approach)
266
- : left.owner.localeCompare(right.owner));
267
- // The most common profile becomes default_phase_sets so rules that follow it stay compact.
268
- const byApproach = new Map();
269
- for (const deliverable of sorted) {
270
- byApproach.set(deliverable.approach, (byApproach.get(deliverable.approach) ?? 0) + 1);
271
- }
272
- const defaultApproach = [...byApproach.entries()].sort((left, right) => right[1] === left[1] ? left[0].localeCompare(right[0]) : right[1] - left[1])[0]?.[0];
273
- const defaultSequence = defaultApproach ? phaseSetsOf(defaultApproach) : [];
274
- const usedPhaseSets = orderPhaseSets(sorted.flatMap((d) => phaseSetsOf(d.approach)));
275
- const phaseSets = {};
276
- for (const name of usedPhaseSets) {
277
- const definition = STRATEGY_PHASE_SETS[name];
278
- if (!definition) {
279
- errors.push(`未定義の phase_set '${name}' が profile から参照された。`);
280
- continue;
281
- }
282
- phaseSets[name] = definition.map(renderPhase);
283
- }
284
- const ownerRules = orderedGroups.map((group) => {
285
- const sequence = phaseSetsOf(group.approach);
286
- const sameAsDefault = sequence.length === defaultSequence.length &&
287
- sequence.every((name, index) => name === defaultSequence[index]);
288
- const finalizeApproach = profileFor(group.approach).finalize_approach;
289
- return {
290
- local_ids: [...group.localIds].sort(),
291
- owner: group.owner,
292
- ...(sameAsDefault ? {} : { phase_sets: sequence.map((name) => ({ phase_set: name })) }),
293
- ...(finalizeApproach === "bootstrap-finalize"
294
- ? { phase_overrides: [{ phase: "finalize", approach: "bootstrap-finalize" }] }
295
- : {}),
296
- };
297
- });
298
- // --- phase gates -------------------------------------------------------------
299
- const countUsing = (phaseSetName) => sorted.filter((d) => phaseSetsOf(d.approach).includes(phaseSetName)).length;
300
- const authorPhaseSets = orderPhaseSets(usedPhaseSets.filter((name) => AUTHOR_PHASE_SETS.includes(name)));
301
- const catalogScope = { catalogs: input.catalogs.map((catalog) => catalog.id) };
302
- const artifactName = input.catalogs.length === 1 ? artifactNameFromCatalogTitle(input.catalogs[0].title) : undefined;
303
- const withArtifact = artifactName ? { artifact_name: artifactName } : {};
304
- const dedupLocalIds = sorted
305
- .filter((d) => d.approach === "cross-deliverable-dedup")
306
- .map((d) => d.local_id);
307
- const authorPassDeliverables = sorted.filter((d) => phaseSetsOf(d.approach).some((name) => AUTHOR_PHASE_SETS.includes(name))).length;
308
- const firstPassGateId = `G-${trackUpper}-first-pass`;
309
- const gates = [];
310
- const needsFirstPassGate = authorPhaseSets.length > 0 && (authorPassDeliverables >= 2 || dedupLocalIds.length >= 2);
311
- if (needsFirstPassGate) {
312
- gates.push({
313
- id: firstPassGateId,
314
- name: "初回パス完了",
315
- ...withArtifact,
316
- after_phase_sets: authorPhaseSets,
317
- owner: input.gateOwner,
318
- scope: catalogScope,
319
- });
320
- }
321
- if (countUsing("refine-pass") >= 2) {
322
- gates.push({
323
- id: `G-${trackUpper}-refine-pass`,
324
- name: "磨き込み完了",
325
- ...withArtifact,
326
- after_phase_sets: ["refine-pass"],
327
- owner: input.gateOwner,
328
- scope: catalogScope,
329
- });
330
- }
331
- const reviewPhaseSets = orderPhaseSets(usedPhaseSets.filter((name) => name === "review-pass" || name === "retrofit-review-pass"));
332
- if (reviewPhaseSets.length > 0 && sorted.length >= 2) {
333
- gates.push({
334
- id: `G-${trackUpper}-review-pass`,
335
- name: "レビュー完了",
336
- ...withArtifact,
337
- after_phase_sets: reviewPhaseSets,
338
- owner: input.gateOwner,
339
- scope: catalogScope,
340
- });
341
- }
342
- if (gates.length > 0 && !input.gateOwner) {
343
- errors.push("phase gate の owner を決定できない。--gate-owner <ROLE> または --default-owner <ROLE> で明示する。");
344
- }
345
- // --- cross-deliverable pass --------------------------------------------------
346
- const crossPasses = [];
347
- if (dedupLocalIds.length === 1) {
348
- errors.push(`cross-deliverable-dedup と判定された成果物が 1 件しかない (${dedupLocalIds[0]})。` +
349
- `横断タスクは 2 件以上の成果物を対象にする。判定を見直す。`);
350
- }
351
- else if (dedupLocalIds.length >= 2) {
352
- if (!needsFirstPassGate) {
353
- errors.push(`cross-deliverable-dedup を配置する前段フェーズが無い。` +
354
- `対象 track に author フェーズ(bootstrap / retrofit / draft)を持つ成果物が必要。`);
355
- }
356
- const passOwners = new Set(dedupLocalIds.map((localId) => input.owners.get(localId) ?? "").filter(Boolean));
357
- const passOwner = input.passOwnerOverride ?? (passOwners.size === 1 ? [...passOwners][0] : undefined);
358
- if (!passOwner) {
359
- errors.push(`横断タスクの主担当を決定できない(対象成果物の owner が ${[...passOwners].join(", ")})。` +
360
- `--owner ${input.track}-dedup=<ROLE> で明示する。`);
361
- }
362
- else {
363
- crossPasses.push({
364
- id: `${input.track}-dedup`,
365
- name: "成果物間の正本選択・重複整理",
366
- ...withArtifact,
367
- task_suffix: "060",
368
- duration_days: 0.5,
369
- owner: passOwner,
370
- after_gate: firstPassGateId,
371
- before_phase_set: "refine-pass",
372
- execution: "agent",
373
- mode: "edit",
374
- approach: "cross-deliverable-dedup",
375
- agent_pipeline: {
376
- stages: [
377
- { stage_role: "executor", proficiency: "expert" },
378
- { stage_role: "reporter", proficiency: "normal" },
379
- ],
380
- },
381
- description: "対象成果物を横断し、同じ事実・手順・定義が複数文書へ重複していないか確認する。" +
382
- "各情報の正本を選び、他の文書は必要な要約と参照へ整理する。各成果物の固有責務と " +
383
- "done_criteria は維持し、用語と受け渡しを統一する。\n",
384
- scope: { local_ids: [...dedupLocalIds].sort() },
385
- });
386
- }
387
- }
388
- // --- cross domain dependencies ----------------------------------------------
389
- const crossDeps = [
390
- ...(input.preserved.cross_domain_dependencies ?? []),
391
- ];
392
- const declared = new Set(crossDeps.map((dep) => JSON.stringify([dep.dependent, dep.requires])));
393
- if (input.bootstrapOrdering) {
394
- const bootstrapIds = sorted
395
- .filter((d) => d.approach === "bootstrap")
396
- .map((d) => d.local_id)
397
- .sort();
398
- for (const deliverable of sorted) {
399
- if (deliverable.approach === "bootstrap")
400
- continue;
401
- if (deliverable.approach === "finalize" || deliverable.approach === "bootstrap-finalize") {
402
- continue;
403
- }
404
- for (const bootstrapId of bootstrapIds) {
405
- const catalogOf = sorted.find((d) => d.local_id === bootstrapId)?.catalog_id;
406
- if (catalogOf !== deliverable.catalog_id)
407
- continue;
408
- if ((input.dependsOn.get(deliverable.local_id) ?? []).includes(bootstrapId))
409
- continue;
410
- if (dependsTransitively(bootstrapId, deliverable.local_id, input.dependsOn)) {
411
- warnings.push(`bootstrap 順序: ${bootstrapId} が ${deliverable.local_id} に依存しているため、` +
412
- `逆向きの待ち合わせは生成しない。`);
413
- continue;
414
- }
415
- const key = JSON.stringify([deliverable.local_id, bootstrapId]);
416
- if (declared.has(key))
417
- continue;
418
- declared.add(key);
419
- crossDeps.push({
420
- dependent: deliverable.local_id,
421
- requires: bootstrapId,
422
- note: "代表成果物の初期整備(bootstrap)で整った実践の型を前提にする",
423
- });
424
- }
425
- }
426
- }
427
- // --- group milestones --------------------------------------------------------
428
- const groupMilestones = input.catalogs.map((catalog) => {
429
- const label = artifactNameFromCatalogTitle(catalog.title);
430
- const sameDomainCount = input.catalogs.filter((item) => item.domain === catalog.domain).length;
431
- const catalogLocalId = catalog.id.includes(":")
432
- ? catalog.id.split(":").slice(1).join(":")
433
- : catalog.id;
434
- const milestoneSuffix = sameDomainCount > 1 ? catalogLocalId.replace(/^dct-/, "") : catalog.domain;
435
- return {
436
- catalog_id: catalog.id,
437
- milestone: {
438
- id: `M-${trackUpper}-${milestoneSuffix}`,
439
- name: "ドメイン完了",
440
- ...(label ? { artifact_name: label } : {}),
441
- owner: input.milestoneOwner,
442
- },
443
- };
444
- });
445
- if (groupMilestones.length > 0 && !input.milestoneOwner) {
446
- errors.push("group milestone の owner を決定できない。--milestone-owner <ROLE> または --default-owner <ROLE> で明示する。");
447
- }
448
- const doc = {
449
- kind: "strategy",
450
- id: `${input.projectId}:sch-strategy-${input.track}`,
451
- type: "project",
452
- status: input.preserved.status ?? "draft",
453
- title: input.preserved.title ?? `スケジュール戦略(${input.track})`,
454
- rulebook: "specdojo:sch-rulebook",
455
- track: input.track,
456
- ...(input.preserved.settings && Object.keys(input.preserved.settings).length > 0
457
- ? { settings: input.preserved.settings }
458
- : {}),
459
- scope: {
460
- catalogs: input.catalogs.map((catalog) => ({
461
- id: catalog.id,
462
- path: catalog.path,
463
- ...(catalog.local_ids ? { local_ids: catalog.local_ids } : {}),
464
- })),
465
- include_kinds: input.includeKinds,
466
- },
467
- approach_rules: input.preserved.approachRules,
468
- phase_sets: phaseSets,
469
- ...(defaultSequence.length > 0
470
- ? { default_phase_sets: defaultSequence.map((name) => ({ phase_set: name })) }
471
- : {}),
472
- owner_rules: ownerRules,
473
- ...(crossPasses.length > 0 ? { cross_deliverable_passes: crossPasses } : {}),
474
- ...(gates.length > 0 ? { phase_gates: gates } : {}),
475
- ...(crossDeps.length > 0 ? { cross_domain_dependencies: crossDeps } : {}),
476
- ...(groupMilestones.length > 0 ? { group_milestones: groupMilestones } : {}),
477
- ...(input.preserved.initial_state ? { initial_state: input.preserved.initial_state } : {}),
478
- };
479
- if (ownerRules.length === 0) {
480
- errors.push("owner_rules が空になる。判定済みの成果物が 1 件も無い。");
481
- }
482
- return { doc, warnings, errors };
483
- }
18
+ export { artifactNameFromCatalogTitle, collectScopeDeliverables, loadKnownRoles, resolveDeliverableOwners, resolveTrackScopeCatalogs, } from "./schedule-strategy-generate-scope.js";
19
+ export { buildStrategyDocument } from "./schedule-strategy-generate-document.js";
484
20
  // ---- serialization & validation ------------------------------------------------
485
21
  export function dumpStrategy(doc) {
486
- return yaml.dump(doc, {
22
+ return dump(doc, {
487
23
  lineWidth: 120,
488
24
  noRefs: true,
489
- quotingType: '"',
25
+ quoteStyle: "double",
490
26
  forceQuotes: false,
491
27
  });
492
28
  }
@@ -505,7 +41,7 @@ function compileStrategySchema(repoRoot) {
505
41
  repositoryRoot: repoRoot,
506
42
  });
507
43
  try {
508
- return yaml.load(readFileSync(filePath, "utf8"));
44
+ return loadYaml(readFileSync(filePath, "utf8"));
509
45
  }
510
46
  catch (error) {
511
47
  throw new Error(`Failed to read strategy schema: ${filePath} (${error instanceof Error ? error.message : String(error)})`);
package/dist/schedule.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { dirname, join, relative, resolve, sep } from "node:path";
2
2
  import { existsSync, readdirSync, writeFileSync } from "node:fs";
3
- import yaml from "js-yaml";
3
+ import { dump } from "./yaml.js";
4
4
  import { getProjectCatalogPath, getProjectRolesPath, getProjectSchedulePath, getProjectTimelinePath, loadConfig, loadEnv, loadMemberRoster, specdojoRootDir, } from "./specdojo-config.js";
5
5
  import { buildScheduleTrack, } from "./schedule-build.js";
6
6
  import { readYaml } from "./exec-shared.js";
@@ -158,7 +158,7 @@ export function updateMilestonesFile(schedulePath, projectId, newMilestones, dry
158
158
  generatedById.delete(milestone.id);
159
159
  }
160
160
  doc.milestones = orderedMilestones.map((milestone) => ({ ...milestone }));
161
- const outYaml = withSchemaModeline(filePath, MILESTONES_SCHEMA, yaml.dump(doc, { lineWidth: 120, noRefs: true }));
161
+ const outYaml = withSchemaModeline(filePath, MILESTONES_SCHEMA, dump(doc, { lineWidth: 120, noRefs: true }));
162
162
  if (dryRun) {
163
163
  const label = fileCreated ? "created" : "updated";
164
164
  process.stdout.write(`\n# --- (dry-run) sch-milestones.yaml (${label}) ---\n`);
@@ -399,9 +399,9 @@ export function registerScheduleCommands(program) {
399
399
  startDate,
400
400
  tasks,
401
401
  });
402
- const outYaml = withSchemaModeline(outFile, TRACK_SCHEMA, yaml.dump(outDoc, {
402
+ const outYaml = withSchemaModeline(outFile, TRACK_SCHEMA, dump(outDoc, {
403
403
  lineWidth: 120,
404
- quotingType: '"',
404
+ quoteStyle: "double",
405
405
  forceQuotes: false,
406
406
  noRefs: true,
407
407
  }));
@@ -1,7 +1,7 @@
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 yaml from "js-yaml";
4
+ import { dump, load } from "./yaml.js";
5
5
  import Ajv2020Module from "ajv/dist/2020.js";
6
6
  import { runProviderScaffold, specdojoPackageRootDir } from "./exec-provider-scaffold.js";
7
7
  import { ensureGitignore, formatGitignoreReport, gitignorePatternsForLayouts, } from "./specdojo-gitignore.js";
@@ -337,7 +337,7 @@ const Ajv2020 = Ajv2020Module.default;
337
337
  const memberSchemaValidators = new Map();
338
338
  function readYamlFile(path) {
339
339
  try {
340
- return yaml.load(readFileSync(path, "utf8"));
340
+ return load(readFileSync(path, "utf8"));
341
341
  }
342
342
  catch (error) {
343
343
  throw new Error(`Invalid YAML: ${path}: ${error instanceof Error ? error.message : String(error)}`);
@@ -374,8 +374,7 @@ function validateMemberFile(schemaName, path, value) {
374
374
  function dumpMemberFile(path, schemaName, value) {
375
375
  const schemaPath = join(specdojoPackageRootDir(), "docs", "specdojo", "schemas", "v1", schemaName);
376
376
  const schemaRef = relative(dirname(path), schemaPath).replaceAll("\\", "/");
377
- return (`# yaml-language-server: $schema=${schemaRef}\n` +
378
- yaml.dump(value, { lineWidth: 100, noRefs: true }));
377
+ return (`# yaml-language-server: $schema=${schemaRef}\n` + dump(value, { lineWidth: 100, noRefs: true }));
379
378
  }
380
379
  function configuredAgentMembersPath(baseDir) {
381
380
  const configPath = resolve(baseDir, ".specdojo", "specdojo.config.json");
@@ -1,7 +1,7 @@
1
1
  import { readdirSync, readFileSync } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
- import yaml from "js-yaml";
4
+ import { load } from "./yaml.js";
5
5
  // PJR-H220 / PJR-VJP8: 観点の document_kinds は rulebook ID の列挙で宣言する。rulebook を
6
6
  // 追加したときに観点ごとの扱いの判断が漏れないよう、include / exclude / confirmed_default の
7
7
  // どれにも載っていない rulebook を一覧にする。confirmed_default は判断の記録であり、適用判定
@@ -23,7 +23,7 @@ function rulebookIdFromMarkdown(markdown, filePath) {
23
23
  return undefined;
24
24
  let parsed;
25
25
  try {
26
- parsed = yaml.load(match[1]);
26
+ parsed = load(match[1]);
27
27
  }
28
28
  catch (error) {
29
29
  throw new Error(`Invalid rulebook frontmatter: ${filePath}`, { cause: error });
@@ -101,7 +101,7 @@ export function checkViewpointDocumentKinds(viewpointsPath = DEFAULT_VIEWPOINTS_
101
101
  if (rulebookIds.length === 0) {
102
102
  return { rulebookCount: 0, errors: [`No rulebooks found: ${rulebookDir}`] };
103
103
  }
104
- const doc = yaml.load(readFileSync(viewpointsPath, "utf8"));
104
+ const doc = load(readFileSync(viewpointsPath, "utf8"));
105
105
  const errors = lintViewpointDocumentKinds(doc, rulebookIds).map(formatViewpointDocumentKindsFinding);
106
106
  return { rulebookCount: rulebookIds.length, errors };
107
107
  }
@@ -1,6 +1,6 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join, posix } from "node:path";
3
- import yaml from "js-yaml";
3
+ import { dump, load } from "./yaml.js";
4
4
  import { collectDocIndexEntries } from "./doc-index.js";
5
5
  import { isDctTemplateCatalog, renderCatalogTemplateBody } from "./catalog-build.js";
6
6
  // YAML は VitePress のページにならないため、doc-index に載っている YAML ごとに
@@ -50,7 +50,7 @@ export function yamlPageRelPath(yamlRelPath) {
50
50
  function deriveMeta(yamlRelPath, content) {
51
51
  let parsed;
52
52
  try {
53
- parsed = yaml.load(content);
53
+ parsed = load(content);
54
54
  }
55
55
  catch {
56
56
  parsed = undefined;
@@ -89,7 +89,7 @@ function deriveMeta(yamlRelPath, content) {
89
89
  // 本文中のバッククォート連続より長いフェンスを使って壊れないようにする。
90
90
  export function renderYamlPage(yamlRelPath, content) {
91
91
  const { title, ...meta } = deriveMeta(yamlRelPath, content);
92
- const frontmatter = yaml.dump({ specdojo: meta }, { lineWidth: -1 }).trimEnd();
92
+ const frontmatter = dump({ specdojo: meta }, { lineWidth: -1 }).trimEnd();
93
93
  const fileName = posix.basename(yamlRelPath);
94
94
  const heading = title ?? fileName;
95
95
  const note = `> このページは \`${yamlRelPath}\` から生成された表示用ページです。正本は YAML ファイルであり、このページは再生成できます。`;
@@ -97,7 +97,7 @@ export function renderYamlPage(yamlRelPath, content) {
97
97
  // インスタンス(catalog build)と同じ表形式で本文を描画する。
98
98
  let parsed;
99
99
  try {
100
- parsed = yaml.load(content);
100
+ parsed = load(content);
101
101
  }
102
102
  catch {
103
103
  parsed = undefined;
package/dist/yaml.js ADDED
@@ -0,0 +1,28 @@
1
+ import { createRequire } from "node:module";
2
+ import { dump as dumpWithJsYaml, load as loadWithJsYaml, } from "js-yaml";
3
+ const require = createRequire(import.meta.url);
4
+ const jsYamlSchemas = require("js-yaml");
5
+ const legacyLoadSchema = (jsYamlSchemas.YAML11_SCHEMA ??
6
+ jsYamlSchemas.DEFAULT_SCHEMA);
7
+ const usesV5Api = jsYamlSchemas.YAML11_SCHEMA !== undefined;
8
+ if (legacyLoadSchema === undefined) {
9
+ throw new Error("js-yaml does not expose a YAML 1.1-compatible schema");
10
+ }
11
+ /** Load YAML with the scalar and merge-key behavior used by js-yaml 4. */
12
+ export function load(source, options = {}) {
13
+ return loadWithJsYaml(source, { ...options, schema: options.schema ?? legacyLoadSchema });
14
+ }
15
+ /** Dump YAML using the v5 option name while remaining runnable before the dependency handoff. */
16
+ export function dump(input, options = {}) {
17
+ const normalized = { ...options };
18
+ const quoteStyle = normalized.quoteStyle;
19
+ delete normalized.quoteStyle;
20
+ if (quoteStyle !== undefined) {
21
+ normalized[usesV5Api ? "quoteStyle" : "quotingType"] = usesV5Api
22
+ ? quoteStyle
23
+ : quoteStyle === "single"
24
+ ? "'"
25
+ : '"';
26
+ }
27
+ return dumpWithJsYaml(input, normalized);
28
+ }