specdojo 0.4.4 → 0.4.6
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 +4 -4
- package/CHANGELOG.md +31 -0
- package/dist/commands/init.js +33 -7
- package/dist/devcontainer/scaffold.js +5 -1
- package/dist/exec/evidence.js +35 -3
- package/dist/exec/pipeline-state.js +1 -0
- package/dist/exec/plans-core.js +18 -2
- package/dist/exec/plans-generation.js +1 -1
- package/dist/exec/register-resume.js +8 -4
- package/dist/exec/register.js +47 -14
- package/dist/exec/reporter.js +8 -1
- package/dist/exec/results.js +1 -1
- package/dist/exec/run/agent-pipeline.js +7 -5
- package/dist/exec/run/agent.js +14 -1
- package/dist/exec/run/in-place.js +7 -4
- package/dist/exec/run/register-core.js +10 -2
- package/dist/exec/run/register-resume.js +1 -0
- package/dist/exec/run/register-worktree.js +7 -1
- package/dist/exec/task-repos.js +11 -0
- package/dist/exec/worktree-ops-lifecycle.js +4 -2
- package/dist/kata/command.js +54 -9
- package/dist/register/approach.js +13 -12
- package/dist/register/authoring-sources.js +132 -0
- package/dist/register/core.js +1 -0
- package/dist/register/create-commands.js +84 -15
- package/dist/register/events.js +2 -0
- package/dist/register/external-project.js +29 -8
- package/dist/register/item.js +6 -0
- package/dist/register/renumber.js +3 -3
- package/dist/register/views.js +3 -0
- package/dist/shared/git.js +3 -2
- package/dist/shared/lefthook-scaffold.js +5 -22
- package/dist/shared/markdownlint-scaffold.js +67 -0
- package/dist/shared/provider-scaffold.js +2 -2
- package/dist/shared/slidev-scaffold.js +102 -0
- package/dist/shared/specdojo-config.js +9 -3
- package/docs/ja/specdojo/exec-templates/xep-recipe-authoring-template.md +7 -7
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +5 -4
- package/docs/ja/specdojo/exec-templates/xep-rulebook-authoring-template.md +7 -7
- package/docs/ja/specdojo/exec-templates/xep-sample-authoring-template.md +7 -7
- package/docs/ja/specdojo/exec-templates/xep-template-authoring-template.md +7 -7
- package/docs/ja/specdojo/guides/exec-config-guide.md +46 -16
- package/docs/ja/specdojo/guides/kata-guide.md +111 -2
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +6 -6
- package/docs/ja/specdojo/guides/quick-start-guide.md +4 -2
- package/docs/ja/specdojo/guides/register-operation-guide.md +2 -0
- package/docs/ja/specdojo/references/command-reference.md +155 -59
- package/docs/ja/specdojo/references/specdojo-config-reference.md +2 -0
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +17 -1
- package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +4 -3
- package/docs/specdojo/schemas/v1/exec-result-frontmatter.schema.yaml +3 -3
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +1 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +31 -3
- package/package.json +8 -7
- package/templates/antigravity/orchestrator.md +4 -4
- package/templates/claude/README.md +2 -0
- package/templates/claude/agents/specdojo-orchestrator.md +4 -4
- package/templates/codex/README.md +38 -9
- package/templates/codex/agents/codex-executor.toml +1 -1
- package/templates/codex/agents/codex-expert-executor.toml +1 -1
- package/templates/codex/agents/codex-expert-review-executor.toml +1 -1
- package/templates/codex/agents/codex-review-executor.toml +1 -1
- package/templates/codex/agents/specdojo-orchestrator.toml +5 -5
- package/templates/codex/orchestrator.md +4 -4
- package/templates/init-agent-members.yaml +85 -13
- package/templates/opencode/agents/specdojo-orchestrator.md +4 -4
|
@@ -9,6 +9,7 @@ import { resolveSpecdojoTemplatePath } from "../docs/template-resolution.js";
|
|
|
9
9
|
import { validateRegisterApproachTargetsForProject } from "./approach.js";
|
|
10
10
|
import { normalizeDerivedFrom, validateDerivedFrom } from "./derivation.js";
|
|
11
11
|
import { delegateExternalRegisterAdd } from "./external-project.js";
|
|
12
|
+
import { isAuthoringApproach } from "../kata/authoring.js";
|
|
12
13
|
function collectTarget(value, previous = []) {
|
|
13
14
|
return [...previous, value];
|
|
14
15
|
}
|
|
@@ -25,6 +26,21 @@ function normalizedTargets(values) {
|
|
|
25
26
|
throw new Error("--target must contain a document id");
|
|
26
27
|
return targets;
|
|
27
28
|
}
|
|
29
|
+
function normalizedSources(values, allowRemove = false) {
|
|
30
|
+
if (values === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
const sources = [...new Set(values.map((value) => value.trim()).filter(Boolean))];
|
|
33
|
+
if (sources.includes("-")) {
|
|
34
|
+
if (!allowRemove)
|
|
35
|
+
throw new Error("--source - is only valid with register update");
|
|
36
|
+
if (sources.length !== 1)
|
|
37
|
+
throw new Error("--source - cannot be combined with other sources");
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
if (sources.length === 0)
|
|
41
|
+
throw new Error("--source must contain a reference");
|
|
42
|
+
return sources;
|
|
43
|
+
}
|
|
28
44
|
export function registerCreateCommands(reg, dependencies) {
|
|
29
45
|
const { addProjectOption, addRegisterCommitOptions, atomicWriteFile, buildRegisterItemContent, derivedTopicNeedsWarning, generateDerivedViewFiles, loadRegisterItems, parseRegisterTimestampOption, planRegisterItem, printCommandError, printDerivedTopicWarning, registerEventActor, registerTopicPattern, resolveRegisterPaths, runRegisterMutation, slugify, writeDerivedViews, } = dependencies;
|
|
30
46
|
// --- scaffold ---
|
|
@@ -67,7 +83,8 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
67
83
|
addCmd.option("--completed <datetime>", "Completion date-time (RFC 3339 with time zone, or -)", "-");
|
|
68
84
|
addCmd.option("--conclusion <text>", "Conclusion or resolution summary", "-");
|
|
69
85
|
addCmd.option("--approach <approach>", `Execution approach: ${APPROACHES.join(" | ")}`);
|
|
70
|
-
addCmd.option("--target <doc-id>", "Target document id (repeatable;
|
|
86
|
+
addCmd.option("--target <doc-id>", "Target document id (repeatable; authoring accepts legacy exemplar targets after the first)", collectTarget);
|
|
87
|
+
addCmd.option("--source <ref>", "Read-only exemplar for *-authoring (repeatable: doc id, path, or <repo>:<path>)", collectTarget);
|
|
71
88
|
addCmd.option("--from <item-id>", "Register item this item derives from (repeatable)", collectTarget);
|
|
72
89
|
addCmd.option("--id <id>", "Display ID (e.g., PJR-0061); auto-incremented if omitted");
|
|
73
90
|
addCmd.option("--topic <topic>", "Topic slug for ticket filename; derived from --title if omitted");
|
|
@@ -101,12 +118,20 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
101
118
|
if (opts.target?.some((target) => target.trim() === "-")) {
|
|
102
119
|
throw new Error("--target - is only valid with register update");
|
|
103
120
|
}
|
|
104
|
-
const
|
|
121
|
+
const rawTargets = normalizedTargets(opts.target);
|
|
122
|
+
const authoring = isAuthoringApproach(opts.approach);
|
|
123
|
+
const legacySources = authoring ? (rawTargets ?? []).slice(1) : [];
|
|
124
|
+
const targets = authoring ? rawTargets?.slice(0, 1) : rawTargets;
|
|
125
|
+
const explicitSources = normalizedSources(opts.source);
|
|
126
|
+
const sources = legacySources.length > 0 || explicitSources
|
|
127
|
+
? [...new Set([...legacySources, ...(explicitSources ?? [])])]
|
|
128
|
+
: undefined;
|
|
105
129
|
validateRegisterApproachTargetsForProject({
|
|
106
130
|
projectId: paths.projectId,
|
|
107
131
|
...(opts.approach !== undefined ? { approach: opts.approach } : {}),
|
|
108
|
-
...(
|
|
109
|
-
|
|
132
|
+
...(rawTargets !== undefined ? { targets: rawTargets } : {}),
|
|
133
|
+
...(explicitSources !== undefined ? { sources: explicitSources } : {}),
|
|
134
|
+
validateTargetsWithoutApproach: opts.target !== undefined || opts.source !== undefined,
|
|
110
135
|
});
|
|
111
136
|
const fields = {
|
|
112
137
|
type: opts.type,
|
|
@@ -122,6 +147,7 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
122
147
|
conclusion: opts.conclusion,
|
|
123
148
|
...(opts.approach !== undefined ? { approach: opts.approach } : {}),
|
|
124
149
|
...(targets !== undefined ? { targets } : {}),
|
|
150
|
+
...(sources !== undefined ? { sources } : {}),
|
|
125
151
|
};
|
|
126
152
|
const templatePath = resolveSpecdojoTemplatePath(`pjr-${opts.type}-template.md`);
|
|
127
153
|
const { assignedId: displayId, ticketFilename } = planRegisterItem({
|
|
@@ -204,7 +230,8 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
204
230
|
updateCmd.option("--block-reason <text>", "Update the waiting reason or use - to remove it");
|
|
205
231
|
updateCmd.option("--autopilot <approval>", "Night orchestrator approval: approved, or - to revoke");
|
|
206
232
|
updateCmd.option("--approach <approach>", `Update execution approach (${APPROACHES.join(" | ")}; use - to remove)`);
|
|
207
|
-
updateCmd.option("--target <doc-id>", "Replace target document ids (repeatable; use - to remove)", collectTarget);
|
|
233
|
+
updateCmd.option("--target <doc-id>", "Replace target document ids (repeatable; legacy authoring exemplars may follow; use - to remove)", collectTarget);
|
|
234
|
+
updateCmd.option("--source <ref>", "Replace read-only *-authoring exemplars (repeatable; use - to remove)", collectTarget);
|
|
208
235
|
updateCmd.option("--from <item-id>", "Replace source register item IDs (repeatable; use - to remove)", collectTarget);
|
|
209
236
|
updateCmd.option("--topic <topic>", "Update the topic slug in the ticket filename and document ID");
|
|
210
237
|
updateCmd.option("--by <actor>", "Actor recorded in the append-only register event");
|
|
@@ -228,11 +255,12 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
228
255
|
"autopilot",
|
|
229
256
|
"approach",
|
|
230
257
|
"target",
|
|
258
|
+
"source",
|
|
231
259
|
"from",
|
|
232
260
|
"topic",
|
|
233
261
|
].some((key) => opts[key] !== undefined);
|
|
234
262
|
if (!hasUpdates) {
|
|
235
|
-
throw new Error("At least one field option must be specified (--title, --description, --priority, --difficulty, --owner, --due, --conclusion, --block-reason, --autopilot, --approach, --target, --from, --topic)");
|
|
263
|
+
throw new Error("At least one field option must be specified (--title, --description, --priority, --difficulty, --owner, --due, --conclusion, --block-reason, --autopilot, --approach, --target, --source, --from, --topic)");
|
|
236
264
|
}
|
|
237
265
|
if (opts.priority !== undefined &&
|
|
238
266
|
!VALID_PRIORITIES.includes(opts.priority)) {
|
|
@@ -280,7 +308,31 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
280
308
|
: opts.approach.trim() === "-"
|
|
281
309
|
? undefined
|
|
282
310
|
: opts.approach.trim();
|
|
283
|
-
const
|
|
311
|
+
const authoring = isAuthoringApproach(nextApproach);
|
|
312
|
+
const providedTargets = opts.target === undefined ? undefined : normalizedTargets(opts.target);
|
|
313
|
+
const providedLegacySources = authoring ? (providedTargets ?? []).slice(1) : [];
|
|
314
|
+
const nextTargets = opts.target === undefined
|
|
315
|
+
? authoring
|
|
316
|
+
? item.targets?.slice(0, 1)
|
|
317
|
+
: item.targets
|
|
318
|
+
: authoring
|
|
319
|
+
? providedTargets?.slice(0, 1)
|
|
320
|
+
: providedTargets;
|
|
321
|
+
const existingSources = [
|
|
322
|
+
...(isAuthoringApproach(item.approach) ? (item.targets ?? []).slice(1) : []),
|
|
323
|
+
...(item.sources ?? []),
|
|
324
|
+
];
|
|
325
|
+
const explicitSources = opts.source === undefined ? undefined : normalizedSources(opts.source, true);
|
|
326
|
+
const nextSources = authoring
|
|
327
|
+
? opts.source !== undefined
|
|
328
|
+
? [...new Set([...providedLegacySources, ...(explicitSources ?? [])])]
|
|
329
|
+
: providedLegacySources.length > 0
|
|
330
|
+
? [...new Set(providedLegacySources)]
|
|
331
|
+
: [...new Set(existingSources)]
|
|
332
|
+
: opts.source !== undefined
|
|
333
|
+
? explicitSources
|
|
334
|
+
: item.sources;
|
|
335
|
+
const normalizedNextSources = nextSources && nextSources.length > 0 ? nextSources : undefined;
|
|
284
336
|
const nextDerivedFrom = opts.from === undefined
|
|
285
337
|
? item.derivedFrom
|
|
286
338
|
: normalizeDerivedFrom(opts.from, { allowRemove: true });
|
|
@@ -289,12 +341,18 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
289
341
|
itemId: item.id,
|
|
290
342
|
derivedFrom: nextDerivedFrom,
|
|
291
343
|
});
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
344
|
+
if (opts.approach !== undefined || opts.target !== undefined || opts.source !== undefined) {
|
|
345
|
+
validateRegisterApproachTargetsForProject({
|
|
346
|
+
projectId: paths.projectId,
|
|
347
|
+
...(nextApproach !== undefined ? { approach: nextApproach } : {}),
|
|
348
|
+
...(nextTargets !== undefined ? { targets: nextTargets } : {}),
|
|
349
|
+
...(normalizedNextSources !== undefined ? { sources: normalizedNextSources } : {}),
|
|
350
|
+
validateTargetsWithoutApproach: opts.target !== undefined || opts.source !== undefined,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
const shouldUpdateTargets = opts.target !== undefined ||
|
|
354
|
+
(authoring && opts.source !== undefined && (item.targets?.length ?? 0) > 1);
|
|
355
|
+
const shouldUpdateSources = opts.source !== undefined || (authoring && providedLegacySources.length > 0);
|
|
298
356
|
const approachTargetUpdates = {
|
|
299
357
|
...(opts.difficulty !== undefined
|
|
300
358
|
? {
|
|
@@ -306,11 +364,16 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
306
364
|
approach: nextApproach === undefined ? REMOVE_REGISTER_ITEM_FIELD : nextApproach,
|
|
307
365
|
}
|
|
308
366
|
: {}),
|
|
309
|
-
...(
|
|
367
|
+
...(shouldUpdateTargets
|
|
310
368
|
? {
|
|
311
369
|
targets: nextTargets ?? REMOVE_REGISTER_ITEM_FIELD,
|
|
312
370
|
}
|
|
313
371
|
: {}),
|
|
372
|
+
...(shouldUpdateSources
|
|
373
|
+
? {
|
|
374
|
+
sources: normalizedNextSources ?? REMOVE_REGISTER_ITEM_FIELD,
|
|
375
|
+
}
|
|
376
|
+
: {}),
|
|
314
377
|
...(opts.from !== undefined
|
|
315
378
|
? {
|
|
316
379
|
derived_from: nextDerivedFrom ?? REMOVE_REGISTER_ITEM_FIELD,
|
|
@@ -343,12 +406,18 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
343
406
|
else
|
|
344
407
|
updated.approach = nextApproach;
|
|
345
408
|
}
|
|
346
|
-
if (
|
|
409
|
+
if (shouldUpdateTargets) {
|
|
347
410
|
if (nextTargets === undefined)
|
|
348
411
|
delete updated.targets;
|
|
349
412
|
else
|
|
350
413
|
updated.targets = nextTargets;
|
|
351
414
|
}
|
|
415
|
+
if (shouldUpdateSources) {
|
|
416
|
+
if (normalizedNextSources === undefined)
|
|
417
|
+
delete updated.sources;
|
|
418
|
+
else
|
|
419
|
+
updated.sources = normalizedNextSources;
|
|
420
|
+
}
|
|
352
421
|
if (opts.from !== undefined) {
|
|
353
422
|
if (nextDerivedFrom === undefined)
|
|
354
423
|
delete updated.derivedFrom;
|
package/dist/register/events.js
CHANGED
|
@@ -23,6 +23,7 @@ export const REGISTER_EVENT_FIELDS = [
|
|
|
23
23
|
"block_reason",
|
|
24
24
|
"approach",
|
|
25
25
|
"targets",
|
|
26
|
+
"sources",
|
|
26
27
|
"derived_from",
|
|
27
28
|
"autopilot",
|
|
28
29
|
];
|
|
@@ -76,6 +77,7 @@ export function registerEventFieldValues(content, filename, timeZone) {
|
|
|
76
77
|
block_reason: parsed.blockReason,
|
|
77
78
|
approach: item.approach ?? CELL_NONE,
|
|
78
79
|
targets: item.targets ? JSON.stringify(item.targets) : CELL_NONE,
|
|
80
|
+
sources: item.sources ? JSON.stringify(item.sources) : CELL_NONE,
|
|
79
81
|
derived_from: item.derivedFrom ? JSON.stringify(item.derivedFrom) : CELL_NONE,
|
|
80
82
|
autopilot: item.autopilot ?? CELL_NONE,
|
|
81
83
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { loadConfig, resolveExternalProjectRoot, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
5
5
|
export const MINIMUM_EXTERNAL_REGISTER_VERSION = "0.4.2";
|
|
6
|
+
export const MINIMUM_EXTERNAL_SOURCE_VERSION = "0.4.5";
|
|
6
7
|
function addValue(args, flag, value) {
|
|
7
8
|
if (value !== undefined)
|
|
8
9
|
args.push(flag, value);
|
|
@@ -44,6 +45,8 @@ export function buildExternalRegisterAddArgs(alias, externalProject, opts) {
|
|
|
44
45
|
addValue(args, "--approach", opts.approach);
|
|
45
46
|
for (const target of opts.target ?? [])
|
|
46
47
|
addValue(args, "--target", target);
|
|
48
|
+
for (const source of opts.source ?? [])
|
|
49
|
+
addValue(args, "--source", source);
|
|
47
50
|
for (const source of opts.from ?? []) {
|
|
48
51
|
addValue(args, "--from", rewriteExternalDerivedFrom(source, alias, externalProject.project_id));
|
|
49
52
|
}
|
|
@@ -66,8 +69,11 @@ function versionParts(version) {
|
|
|
66
69
|
return [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
67
70
|
}
|
|
68
71
|
export function supportsExternalRegister(version) {
|
|
72
|
+
return versionAtLeast(version, MINIMUM_EXTERNAL_REGISTER_VERSION);
|
|
73
|
+
}
|
|
74
|
+
function versionAtLeast(version, required) {
|
|
69
75
|
const actual = versionParts(version);
|
|
70
|
-
const minimum = versionParts(
|
|
76
|
+
const minimum = versionParts(required);
|
|
71
77
|
if (!actual || !minimum)
|
|
72
78
|
return false;
|
|
73
79
|
for (let index = 0; index < actual.length; index += 1) {
|
|
@@ -78,11 +84,22 @@ export function supportsExternalRegister(version) {
|
|
|
78
84
|
}
|
|
79
85
|
function targetSpecdojoExecutable(repoRoot) {
|
|
80
86
|
const executable = join(repoRoot, "node_modules", ".bin", process.platform === "win32" ? "specdojo.cmd" : "specdojo");
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
if (existsSync(executable))
|
|
88
|
+
return { command: executable, args: [] };
|
|
89
|
+
const packagePath = join(repoRoot, "package.json");
|
|
90
|
+
if (existsSync(packagePath)) {
|
|
91
|
+
const pkg = JSON.parse(readFileSync(packagePath, "utf8"));
|
|
92
|
+
if (pkg && typeof pkg === "object" && "name" in pkg && pkg.name === "specdojo") {
|
|
93
|
+
const entrypoint = join(repoRoot, "dist", "specdojo.js");
|
|
94
|
+
if (!existsSync(entrypoint)) {
|
|
95
|
+
throw new Error(`External SpecDojo repository has not been built: ${entrypoint}. ` +
|
|
96
|
+
"Run npm run build in that repository.");
|
|
97
|
+
}
|
|
98
|
+
return { command: process.execPath, args: [entrypoint] };
|
|
99
|
+
}
|
|
84
100
|
}
|
|
85
|
-
|
|
101
|
+
throw new Error(`External project repository does not have SpecDojo installed: ${executable}. ` +
|
|
102
|
+
`Install specdojo ${MINIMUM_EXTERNAL_REGISTER_VERSION} or newer in that repository.`);
|
|
86
103
|
}
|
|
87
104
|
/**
|
|
88
105
|
* Delegate `register add` when `--project` names an external-project alias.
|
|
@@ -104,7 +121,7 @@ export function delegateExternalRegisterAdd(opts, run = spawnSync) {
|
|
|
104
121
|
}
|
|
105
122
|
const repoRoot = resolveExternalProjectRoot(rootDir, externalProject);
|
|
106
123
|
const executable = targetSpecdojoExecutable(repoRoot);
|
|
107
|
-
const versionResult = run(executable, ["--version"], {
|
|
124
|
+
const versionResult = run(executable.command, [...executable.args, "--version"], {
|
|
108
125
|
cwd: repoRoot,
|
|
109
126
|
encoding: "utf8",
|
|
110
127
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -122,7 +139,11 @@ export function delegateExternalRegisterAdd(opts, run = spawnSync) {
|
|
|
122
139
|
throw new Error(`External project ${alias} uses SpecDojo ${version || "with an unknown version"}; ` +
|
|
123
140
|
`${MINIMUM_EXTERNAL_REGISTER_VERSION} or newer is required for cross-project register add.`);
|
|
124
141
|
}
|
|
125
|
-
|
|
142
|
+
if ((opts.source?.length ?? 0) > 0 && !versionAtLeast(version, MINIMUM_EXTERNAL_SOURCE_VERSION)) {
|
|
143
|
+
throw new Error(`External project ${alias} uses SpecDojo ${version}; ` +
|
|
144
|
+
`${MINIMUM_EXTERNAL_SOURCE_VERSION} or newer is required for --source.`);
|
|
145
|
+
}
|
|
146
|
+
const result = run(executable.command, [...executable.args, ...buildExternalRegisterAddArgs(alias, externalProject, opts)], {
|
|
126
147
|
cwd: repoRoot,
|
|
127
148
|
encoding: "utf8",
|
|
128
149
|
stdio: "inherit",
|
package/dist/register/item.js
CHANGED
|
@@ -70,6 +70,7 @@ const SPECDOJO_KEY_ORDER = [
|
|
|
70
70
|
"autopilot",
|
|
71
71
|
"approach",
|
|
72
72
|
"targets",
|
|
73
|
+
"sources",
|
|
73
74
|
];
|
|
74
75
|
// ================================
|
|
75
76
|
// Derivation helpers
|
|
@@ -218,6 +219,9 @@ export function readRegisterItemContent(content, filename) {
|
|
|
218
219
|
const targets = Array.isArray(fields.targets)
|
|
219
220
|
? fields.targets.filter((entry) => typeof entry === "string" && entry.trim() !== "")
|
|
220
221
|
: undefined;
|
|
222
|
+
const sources = Array.isArray(fields.sources)
|
|
223
|
+
? fields.sources.filter((entry) => typeof entry === "string" && entry.trim() !== "")
|
|
224
|
+
: undefined;
|
|
221
225
|
const approach = asString(fields.approach);
|
|
222
226
|
const derivedFrom = Array.isArray(fields.derived_from)
|
|
223
227
|
? fields.derived_from.filter((entry) => typeof entry === "string" && entry.trim() !== "")
|
|
@@ -243,6 +247,7 @@ export function readRegisterItemContent(content, filename) {
|
|
|
243
247
|
ticket: ticketRefCell(filename),
|
|
244
248
|
...(approach ? { approach } : {}),
|
|
245
249
|
...(targets && targets.length > 0 ? { targets } : {}),
|
|
250
|
+
...(sources && sources.length > 0 ? { sources } : {}),
|
|
246
251
|
...(derivedFrom && derivedFrom.length > 0 ? { derivedFrom } : {}),
|
|
247
252
|
...(autopilot ? { autopilot } : {}),
|
|
248
253
|
};
|
|
@@ -367,6 +372,7 @@ export function registerItemFieldsFromItem(item) {
|
|
|
367
372
|
: inlineCodeAnglePlaceholders(item.conclusion.trim()),
|
|
368
373
|
...(item.approach ? { approach: item.approach } : {}),
|
|
369
374
|
...(item.targets && item.targets.length > 0 ? { targets: item.targets } : {}),
|
|
375
|
+
...(item.sources && item.sources.length > 0 ? { sources: item.sources } : {}),
|
|
370
376
|
...(item.derivedFrom && item.derivedFrom.length > 0 ? { derived_from: item.derivedFrom } : {}),
|
|
371
377
|
...(item.autopilot ? { autopilot: item.autopilot } : {}),
|
|
372
378
|
};
|
|
@@ -60,13 +60,13 @@ export function renumberTicketContent(content, fromId, toId, topic) {
|
|
|
60
60
|
return updated;
|
|
61
61
|
}
|
|
62
62
|
// 他文書からの参照リンク(wikilink `[[<docId>|...]]`)と
|
|
63
|
-
// exec plan / result の `targets` に含まれる doc id を新しい doc id へ置き換える。
|
|
63
|
+
// exec plan / result の `targets` と個票の `sources` に含まれる doc id を新しい doc id へ置き換える。
|
|
64
64
|
export function renumberReferences(content, fromDocId, toDocId) {
|
|
65
65
|
if (!content.includes(fromDocId))
|
|
66
66
|
return { content, changed: false };
|
|
67
67
|
return { content: content.split(fromDocId).join(toDocId), changed: true };
|
|
68
68
|
}
|
|
69
|
-
// `derived_from` は文書 ID ではなく表示 ID を保持するため、通常の wikilink / targets の
|
|
69
|
+
// `derived_from` は文書 ID ではなく表示 ID を保持するため、通常の wikilink / targets / sources の
|
|
70
70
|
// 置換とは分けて frontmatter の配列だけを更新する。同一 project の短縮形と、別 project
|
|
71
71
|
// から参照する project 修飾形の両方を対象にする。
|
|
72
72
|
function renumberDerivedFromReferences(content, filename, sourceProjectId, fromId, toId) {
|
|
@@ -256,7 +256,7 @@ export function planRenumber(paths, fromId, toId) {
|
|
|
256
256
|
if (hasIndexRow) {
|
|
257
257
|
writes.push({ path: paths.pjrIndexPath, content: newIndexContent });
|
|
258
258
|
}
|
|
259
|
-
// 参照リンク・targets・derived_from の付け替え(doc id を持つ個票がある場合のみ)。
|
|
259
|
+
// 参照リンク・targets・sources・derived_from の付け替え(doc id を持つ個票がある場合のみ)。
|
|
260
260
|
if (fromDocId && toDocId) {
|
|
261
261
|
const root = specdojoRootDir();
|
|
262
262
|
const referenceFiles = findMarkdownReferenceFiles(root);
|
package/dist/register/views.js
CHANGED
|
@@ -47,7 +47,10 @@ export function injectViewSlots(content, slots) {
|
|
|
47
47
|
}
|
|
48
48
|
// グループ(状態別・優先度別・担当者別など)を `### <chapter>.<n>. <label>` 見出し付きの
|
|
49
49
|
// テーブル群へ整形する。章見出しラベルは template 側が持つため、ここでは番号と値のみ扱う。
|
|
50
|
+
// 項目がない場合は空文字列を差し込むと前後の空行が重なり MD012 に当たるため、「該当なし」を書く。
|
|
50
51
|
function renderGroupedTables(groups, chapter, heading) {
|
|
52
|
+
if (groups.length === 0)
|
|
53
|
+
return "該当なし";
|
|
51
54
|
return groups
|
|
52
55
|
.map((group, index) => [
|
|
53
56
|
`### ${chapter}.${index + 1}. ${group.label}`,
|
package/dist/shared/git.js
CHANGED
|
@@ -232,8 +232,9 @@ export function summarizeGitHookFailure(output) {
|
|
|
232
232
|
// parallel: true の lefthook は成功した step の出力も並べるため、最初の step 見出しが
|
|
233
233
|
// 失敗した step とは限らない。末尾の summary で失敗印(🥊 など)が付いた step を優先する。
|
|
234
234
|
const failedSteps = lines
|
|
235
|
-
|
|
236
|
-
.
|
|
235
|
+
// step 名には空白や括弧を含む description も使われる。末尾の所要時間だけを除く。
|
|
236
|
+
.map((line) => line.match(/^(?:🥊|✗|✘|✕|❌)️?\s*(.+?)(?:\s+\([\d.]+\s+seconds?\))?$/u)?.[1])
|
|
237
|
+
.filter((name) => name !== undefined && !/^lefthook(?:\s|$)/u.test(name));
|
|
237
238
|
const selected = stepHeaders.find((header) => failedSteps.includes(header.step)) ?? stepHeaders[0];
|
|
238
239
|
const step = selected?.step ?? failedSteps[0] ?? "";
|
|
239
240
|
const stepIndex = selected?.index ?? -1;
|
|
@@ -1,26 +1,12 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { writeMarkdownlintConfigs } from "./markdownlint-scaffold.js";
|
|
4
5
|
const REQUIRED_DEV_DEPENDENCIES = ["lefthook", "prettier", "markdownlint-cli"];
|
|
5
6
|
const REQUIRED_SCRIPTS = {
|
|
6
7
|
prepare: "node tools/install-lefthook.mjs",
|
|
7
8
|
"pre-commit": "lefthook run pre-commit",
|
|
8
9
|
};
|
|
9
|
-
const MARKDOWNLINT_CONFIG_FILES = [
|
|
10
|
-
".markdownlint.jsonc",
|
|
11
|
-
".markdownlint.json",
|
|
12
|
-
".markdownlint.yaml",
|
|
13
|
-
".markdownlint.yml",
|
|
14
|
-
".markdownlintrc",
|
|
15
|
-
];
|
|
16
|
-
const MARKDOWNLINT_CONFIG = `${JSON.stringify({
|
|
17
|
-
MD013: false,
|
|
18
|
-
MD024: false,
|
|
19
|
-
MD033: false,
|
|
20
|
-
MD036: false,
|
|
21
|
-
MD041: false,
|
|
22
|
-
MD060: false,
|
|
23
|
-
}, null, 2)}\n`;
|
|
24
10
|
const MARKDOWNLINT_IGNORE = [".claude/agents/", ".github/agents/", ".opencode/agents/", ""].join("\n");
|
|
25
11
|
function isRecord(value) {
|
|
26
12
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -151,14 +137,11 @@ async function writeScaffoldFile(sourcePath, destinationPath, destinationLabel,
|
|
|
151
137
|
process.stdout.write(`Written: ${destinationLabel}\n`);
|
|
152
138
|
}
|
|
153
139
|
async function writeMarkdownlintScaffold(opts) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
process.stdout.write(`Skipped (markdownlint config already exists): ${existingConfig}\n`);
|
|
140
|
+
if (opts.slidevKataPatterns?.length) {
|
|
141
|
+
process.stdout.write(`Planned Slidev .markdownlintignore entries:\n${opts.slidevKataPatterns.join("\n")}\n`);
|
|
157
142
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
await writeScaffoldFile(undefined, path.join(opts.repoRoot, ".markdownlintignore"), ".markdownlintignore", MARKDOWNLINT_IGNORE, { force: false, dryRun: opts.dryRun });
|
|
143
|
+
await writeMarkdownlintConfigs(opts);
|
|
144
|
+
await writeScaffoldFile(undefined, path.join(opts.repoRoot, ".markdownlintignore"), ".markdownlintignore", MARKDOWNLINT_IGNORE + (opts.slidevKataPatterns ?? []).map((pattern) => `${pattern}\n`).join(""), { force: false, dryRun: opts.dryRun });
|
|
162
145
|
}
|
|
163
146
|
export async function runLefthookScaffold(opts) {
|
|
164
147
|
const templateTools = path.join(opts.packageRoot, "templates", "lefthook", "tools");
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { dump } from "js-yaml";
|
|
5
|
+
const BASE_CONFIG = {
|
|
6
|
+
MD013: false,
|
|
7
|
+
MD024: false,
|
|
8
|
+
MD033: false,
|
|
9
|
+
MD036: false,
|
|
10
|
+
MD041: false,
|
|
11
|
+
MD060: false,
|
|
12
|
+
};
|
|
13
|
+
// Slide boundaries and per-slide frontmatter interrupt normal Markdown blocks.
|
|
14
|
+
// Each slide may start with its own H1 or use a heading level chosen for its layout.
|
|
15
|
+
const SLIDEV_CONFIG = {
|
|
16
|
+
MD001: false,
|
|
17
|
+
MD022: false,
|
|
18
|
+
MD025: false,
|
|
19
|
+
MD031: false,
|
|
20
|
+
MD032: false,
|
|
21
|
+
};
|
|
22
|
+
export async function writeMarkdownlintConfigs(opts) {
|
|
23
|
+
const files = await readdir(opts.repoRoot);
|
|
24
|
+
const legacyConfigs = files.filter((file) => file.startsWith(".markdownlint."));
|
|
25
|
+
const cli2Configs = files.filter((file) => file.startsWith(".markdownlint-cli2."));
|
|
26
|
+
const hasRc = existsSync(path.join(opts.repoRoot, ".markdownlintrc"));
|
|
27
|
+
const rcContent = `${JSON.stringify(BASE_CONFIG, null, 2)}\n`;
|
|
28
|
+
const cli2Content = dump({
|
|
29
|
+
config: { extends: ".markdownlintrc" },
|
|
30
|
+
...(opts.slidevKataPatterns?.length
|
|
31
|
+
? {
|
|
32
|
+
overrides: [{ filter: opts.slidevKataPatterns, combine: "merge", config: SLIDEV_CONFIG }],
|
|
33
|
+
}
|
|
34
|
+
: {}),
|
|
35
|
+
});
|
|
36
|
+
process.stdout.write(`Planned markdownlint base (.markdownlintrc):\n${rcContent}` +
|
|
37
|
+
`Planned markdownlint-cli2 configuration (.markdownlint-cli2.yaml):\n${cli2Content}`);
|
|
38
|
+
if (opts.slidevKataPatterns?.length) {
|
|
39
|
+
process.stdout.write("Place the Slidev override FIRST in markdownlint-cli2 overrides (first match wins).\n");
|
|
40
|
+
}
|
|
41
|
+
if (legacyConfigs.length > 0) {
|
|
42
|
+
process.stdout.write(`Kept existing markdownlint config: ${legacyConfigs.join(", ")}.\n` +
|
|
43
|
+
"Migrate its rules to .markdownlintrc (JSON starting with {, without a leading comment), " +
|
|
44
|
+
"then remove the old .markdownlint.* config, including any in parent directories. " +
|
|
45
|
+
"Merge the CLI2 configuration above manually; see docs/ja/specdojo/references/command-reference.md.\n");
|
|
46
|
+
}
|
|
47
|
+
// Do not introduce competing settings or an extends pointing to a missing rc.
|
|
48
|
+
// Existing CLI2 configurations may have their own base; show additions for manual review.
|
|
49
|
+
const canCreateRc = legacyConfigs.length === 0 && cli2Configs.length === 0;
|
|
50
|
+
const canCreateCli2 = legacyConfigs.length === 0 && (hasRc || canCreateRc);
|
|
51
|
+
for (const [filename, content, canCreate] of [
|
|
52
|
+
[".markdownlintrc", rcContent, canCreateRc],
|
|
53
|
+
[".markdownlint-cli2.yaml", cli2Content, canCreateCli2],
|
|
54
|
+
]) {
|
|
55
|
+
const existing = filename === ".markdownlintrc" ? hasRc : cli2Configs.length > 0;
|
|
56
|
+
if (existing || !canCreate) {
|
|
57
|
+
process.stdout.write(`Kept existing markdownlint settings. Merge any missing ${filename} entries above manually.\n`);
|
|
58
|
+
}
|
|
59
|
+
else if (opts.dryRun) {
|
|
60
|
+
process.stdout.write(`[dry-run] would write: ${filename}\n`);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
await writeFile(path.join(opts.repoRoot, filename), content, "utf8");
|
|
64
|
+
process.stdout.write(`Written: ${filename}\n`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -12,8 +12,8 @@ export const ORCHESTRATOR_NPM_SCRIPTS = {
|
|
|
12
12
|
"orch:sonnet": "specdojo orchestrator launch --provider claude -- --agent specdojo-orchestrator --model sonnet --settings .specdojo/claude/settings.orchestrator.json",
|
|
13
13
|
},
|
|
14
14
|
codex: {
|
|
15
|
-
"orch:sol": 'specdojo orchestrator launch --provider codex -- -m gpt-
|
|
16
|
-
"orch:
|
|
15
|
+
"orch:sol": 'specdojo orchestrator launch --provider codex -- -m gpt-6.1-sol "$(cat .specdojo/codex/orchestrator.md)"',
|
|
16
|
+
"orch:luna": 'specdojo orchestrator launch --provider codex -- -m gpt-6-luna "$(cat .specdojo/codex/orchestrator.md)"',
|
|
17
17
|
},
|
|
18
18
|
antigravity: {
|
|
19
19
|
"orch:flash": 'specdojo orchestrator launch --provider antigravity -- --add-dir "$(pwd)" --model gemini-3.8-flash-high -i "$(cat .specdojo/antigravity/orchestrator.md)"',
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { writeMarkdownlintConfigs } from "./markdownlint-scaffold.js";
|
|
5
|
+
// Keep ordinary kata Markdown on the standard parser. Existing decks with other
|
|
6
|
+
// names can be added to the displayed overrides and ignore patterns by the user.
|
|
7
|
+
export const SLIDEV_KATA_PATTERNS = [
|
|
8
|
+
"docs/ja/specdojo/samples/**/*-slidev-sample.md",
|
|
9
|
+
"docs/ja/specdojo/templates/**/*-slidev-template.md",
|
|
10
|
+
];
|
|
11
|
+
const DEV_DEPENDENCIES = {
|
|
12
|
+
"@slidev/cli": "^53.0.0",
|
|
13
|
+
"prettier-plugin-slidev": "^1.0.5",
|
|
14
|
+
prettier: "^3.8.4",
|
|
15
|
+
};
|
|
16
|
+
const PRETTIER_CONFIG = {
|
|
17
|
+
overrides: [
|
|
18
|
+
{
|
|
19
|
+
files: SLIDEV_KATA_PATTERNS,
|
|
20
|
+
options: { parser: "slidev", plugins: ["prettier-plugin-slidev"] },
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
const PRETTIER_CONFIG_FILES = [
|
|
25
|
+
".prettierrc",
|
|
26
|
+
...["json", "json5", "yml", "yaml", "js", "ts", "mjs", "mts", "cjs", "cts", "toml"].map((extension) => `.prettierrc.${extension}`),
|
|
27
|
+
...["js", "ts", "mjs", "mts", "cjs", "cts"].map((extension) => `prettier.config.${extension}`),
|
|
28
|
+
];
|
|
29
|
+
function isRecord(value) {
|
|
30
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31
|
+
}
|
|
32
|
+
export async function runSlidevScaffold(opts) {
|
|
33
|
+
const packagePath = path.join(opts.repoRoot, "package.json");
|
|
34
|
+
const packageContent = existsSync(packagePath) ? await readFile(packagePath, "utf8") : undefined;
|
|
35
|
+
const parsed = packageContent === undefined ? {} : JSON.parse(packageContent);
|
|
36
|
+
if (!isRecord(parsed))
|
|
37
|
+
throw new Error(`Invalid ${packagePath}: expected an object`);
|
|
38
|
+
for (const field of ["dependencies", "devDependencies"]) {
|
|
39
|
+
if (parsed[field] !== undefined && !isRecord(parsed[field])) {
|
|
40
|
+
throw new Error(`Invalid ${packagePath}: ${field} must be an object`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const dependencies = isRecord(parsed.dependencies) ? parsed.dependencies : {};
|
|
44
|
+
const devDependencies = isRecord(parsed.devDependencies) ? parsed.devDependencies : {};
|
|
45
|
+
const additions = Object.fromEntries(Object.entries(DEV_DEPENDENCIES).filter(([name]) => !Object.hasOwn(dependencies, name) && !Object.hasOwn(devDependencies, name)));
|
|
46
|
+
process.stdout.write(`Planned package.json additions (Slidev):\n${JSON.stringify({ devDependencies: additions }, null, 2)}\n`);
|
|
47
|
+
for (const name of Object.keys(DEV_DEPENDENCIES)) {
|
|
48
|
+
if (Object.hasOwn(dependencies, name) || Object.hasOwn(devDependencies, name)) {
|
|
49
|
+
process.stdout.write(`Skipped (dependency already exists): ${name} in package.json\n`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (packageContent === undefined) {
|
|
53
|
+
process.stdout.write("Skipped package.json update (not found). Create it and add the entries above.\n");
|
|
54
|
+
}
|
|
55
|
+
const prettierConfig = Object.hasOwn(parsed, "prettier")
|
|
56
|
+
? "package.json#prettier"
|
|
57
|
+
: PRETTIER_CONFIG_FILES.find((file) => existsSync(path.join(opts.repoRoot, file)));
|
|
58
|
+
const prettierContent = `${JSON.stringify(PRETTIER_CONFIG, null, 2)}\n`;
|
|
59
|
+
process.stdout.write(`Planned Slidev Prettier overrides:\n${prettierContent}`);
|
|
60
|
+
if (prettierConfig) {
|
|
61
|
+
process.stdout.write(`Kept existing ${prettierConfig}. Merge the overrides above manually for your Slidev kata paths.\n`);
|
|
62
|
+
}
|
|
63
|
+
const ignorePath = path.join(opts.repoRoot, ".markdownlintignore");
|
|
64
|
+
const ignoreExists = existsSync(ignorePath);
|
|
65
|
+
const ignoreContent = `${SLIDEV_KATA_PATTERNS.join("\n")}\n`;
|
|
66
|
+
process.stdout.write(`Planned Slidev .markdownlintignore entries:\n${ignoreContent}`);
|
|
67
|
+
if (ignoreExists) {
|
|
68
|
+
process.stdout.write("Kept existing .markdownlintignore. Add any missing patterns above manually.\n");
|
|
69
|
+
}
|
|
70
|
+
process.stdout.write("Place the Slidev override LAST in Prettier overrides (last match wins).\n");
|
|
71
|
+
await writeMarkdownlintConfigs({ ...opts, slidevKataPatterns: SLIDEV_KATA_PATTERNS });
|
|
72
|
+
// Preview all additions before the first write, including on a normal run.
|
|
73
|
+
if (opts.dryRun) {
|
|
74
|
+
if (packageContent !== undefined && Object.keys(additions).length > 0) {
|
|
75
|
+
process.stdout.write("[dry-run] would update: package.json\n");
|
|
76
|
+
}
|
|
77
|
+
if (!prettierConfig)
|
|
78
|
+
process.stdout.write("[dry-run] would write: .prettierrc\n");
|
|
79
|
+
if (!ignoreExists)
|
|
80
|
+
process.stdout.write("[dry-run] would write: .markdownlintignore\n");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (packageContent !== undefined && Object.keys(additions).length > 0) {
|
|
84
|
+
parsed.devDependencies = { ...devDependencies, ...additions };
|
|
85
|
+
const indent = packageContent.match(/^([\t ]+)\S/m)?.[1] ?? " ";
|
|
86
|
+
await writeFile(packagePath, `${JSON.stringify(parsed, null, indent)}\n`, "utf8");
|
|
87
|
+
process.stdout.write("Updated: package.json\n");
|
|
88
|
+
}
|
|
89
|
+
if (!prettierConfig) {
|
|
90
|
+
await writeFile(path.join(opts.repoRoot, ".prettierrc"), prettierContent, "utf8");
|
|
91
|
+
process.stdout.write("Written: .prettierrc\n");
|
|
92
|
+
}
|
|
93
|
+
if (!ignoreExists) {
|
|
94
|
+
await writeFile(ignorePath, ignoreContent, "utf8");
|
|
95
|
+
process.stdout.write("Written: .markdownlintignore\n");
|
|
96
|
+
}
|
|
97
|
+
process.stdout.write("Next steps (Slidev):\n" +
|
|
98
|
+
" 1. Review the additions and any manual merges above, then run npm install.\n" +
|
|
99
|
+
" 2. Install the theme used by the kata and supply its project-specific components/assets.\n" +
|
|
100
|
+
' 3. Run ./node_modules/.bin/slidev build <kata-sample.md> --out "$PWD/tmp/slidev-dist".\n' +
|
|
101
|
+
" See docs/ja/specdojo/guides/kata-guide.md for the verification workflow.\n");
|
|
102
|
+
}
|