specdojo 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/README.md +77 -18
- package/dist/{catalog-build-references.js → catalog/build-references.js} +4 -4
- package/dist/catalog/build-render.js +32 -0
- package/dist/{catalog-build.js → catalog/build.js} +9 -9
- package/dist/{catalog.js → catalog/catalog.js} +10 -10
- package/dist/{catalog-generate.js → catalog/generate.js} +8 -8
- package/dist/catalog/paths.js +1 -0
- package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +4 -4
- package/dist/{catalog-plan.js → catalog/plan.js} +4 -4
- package/dist/{catalog-scaffold.js → catalog/scaffold.js} +3 -3
- package/dist/{agent.js → commands/agent.js} +11 -11
- package/dist/{build-command.js → commands/build.js} +2 -2
- package/dist/{init-command.js → commands/init.js} +98 -32
- package/dist/{orchestrator.js → commands/orchestrator.js} +2 -2
- package/dist/{watch.js → commands/watch.js} +3 -3
- package/dist/{dashboard-timeline.js → dashboard/dashboard-timeline.js} +2 -2
- package/dist/{dashboard.js → dashboard/dashboard.js} +11 -10
- package/dist/{dashboard-exec-records.js → dashboard/exec-records.js} +2 -2
- package/dist/{dashboard-routines.js → dashboard/routines.js} +6 -5
- package/dist/{dashboard-shared.js → dashboard/shared.js} +1 -1
- package/dist/{timeline-build.js → dashboard/timeline-build.js} +2 -1
- package/dist/{timeline.js → dashboard/timeline.js} +1 -1
- package/dist/{deliverable.js → deliverable/deliverable.js} +5 -5
- package/dist/{deliverable-trash.js → deliverable/trash.js} +5 -5
- package/dist/{devcontainer-command.js → devcontainer/command.js} +5 -3
- package/dist/{devcontainer-scaffold.js → devcontainer/scaffold.js} +94 -2
- package/dist/{doc-index.js → docs/doc-index.js} +1 -1
- package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +1 -1
- package/dist/{index-command.js → docs/index-command.js} +1 -1
- package/dist/docs/template-resolution.js +1 -0
- package/dist/{viewpoint-document-kinds-check.js → docs/viewpoint-document-kinds-check.js} +1 -1
- package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
- package/dist/{yaml-pages.js → docs/yaml-pages.js} +2 -2
- package/dist/{exec-agent-config.js → exec/agent-config.js} +33 -4
- package/dist/{exec-agent-git-state.js → exec/agent-git-state.js} +1 -1
- package/dist/{exec-agent-protected-config.js → exec/agent-protected-config.js} +1 -1
- package/dist/{exec-commands.js → exec/commands.js} +22 -18
- package/dist/{exec-core.js → exec/core.js} +11 -11
- package/dist/{exec-events.js → exec/events.js} +2 -2
- package/dist/{exec-evidence.js → exec/evidence.js} +11 -6
- package/dist/exec/exec.js +2 -0
- package/dist/exec/format.js +1 -0
- package/dist/{exec-handoff.js → exec/handoff.js} +13 -12
- package/dist/{exec-limit.js → exec/limit.js} +93 -12
- package/dist/{exec-parent-validation.js → exec/parent-validation.js} +4 -4
- package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +16 -2
- package/dist/{exec-plans-core.js → exec/plans-core.js} +68 -114
- package/dist/{exec-plans-generation.js → exec/plans-generation.js} +53 -10
- package/dist/{exec-plans-storage.js → exec/plans-storage.js} +5 -5
- package/dist/{exec-plans.js → exec/plans.js} +3 -3
- package/dist/{exec-project.js → exec/project.js} +1 -1
- package/dist/{exec-protection-handoff.js → exec/protection-handoff.js} +3 -3
- package/dist/{exec-register-resume.js → exec/register-resume.js} +2 -2
- package/dist/{exec-register.js → exec/register.js} +92 -9
- package/dist/{exec-repo-integration-git.js → exec/repo-integration-git.js} +2 -2
- package/dist/{exec-repo-integration-sync.js → exec/repo-integration-sync.js} +4 -4
- package/dist/{exec-repo-integration.js → exec/repo-integration.js} +13 -10
- package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
- package/dist/{exec-reporter-output.js → exec/reporter-output.js} +2 -2
- package/dist/{exec-reporter.js → exec/reporter.js} +29 -12
- package/dist/{exec-results.js → exec/results.js} +256 -22
- package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +32 -12
- package/dist/{exec-run-agent.js → exec/run/agent.js} +79 -27
- package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
- package/dist/{exec-run-job.js → exec/run/job.js} +64 -35
- package/dist/{exec-run-lifecycle-commands.js → exec/run/lifecycle-commands.js} +30 -22
- package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
- package/dist/{exec-run-mode-shared.js → exec/run/mode-shared.js} +3 -3
- package/dist/{exec-run-register-command.js → exec/run/register-command.js} +18 -10
- package/dist/{exec-run-register-core.js → exec/run/register-core.js} +46 -21
- package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +20 -16
- package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +22 -17
- package/dist/{exec-run-register-state.js → exec/run/register-state.js} +13 -10
- package/dist/{exec-run-register-worktree.js → exec/run/register-worktree.js} +54 -23
- package/dist/{exec-run.js → exec/run/run.js} +11 -11
- package/dist/{exec-run-schedule-mode.js → exec/run/schedule-mode.js} +17 -17
- package/dist/{exec-run-schedule-prepare.js → exec/run/schedule-prepare.js} +31 -18
- package/dist/{exec-run-schedule-task.js → exec/run/schedule-task.js} +45 -18
- package/dist/{exec-run-shared.js → exec/run/shared.js} +61 -11
- package/dist/{exec-schedule-calendar.js → exec/schedule/calendar.js} +1 -1
- package/dist/{exec-schedule-cpm.js → exec/schedule/cpm.js} +2 -2
- package/dist/{exec-schedule-gantt-chart-render.js → exec/schedule/gantt-chart-render.js} +2 -2
- package/dist/exec/schedule/gantt-chart.js +2 -0
- package/dist/{exec-schedule-hash.js → exec/schedule/hash.js} +2 -2
- package/dist/exec/schedule/index.js +1 -0
- package/dist/{exec-schedule-initial.js → exec/schedule/initial.js} +2 -2
- package/dist/{exec-schedule-progress.js → exec/schedule/progress.js} +2 -2
- package/dist/{exec-schedule-ready.js → exec/schedule/ready.js} +2 -2
- package/dist/{exec-schedule.js → exec/schedule/schedule.js} +11 -11
- package/dist/exec/shared.js +63 -0
- package/dist/exec/slot-lock.js +1 -0
- package/dist/{exec-strategy.js → exec/strategy.js} +2 -2
- package/dist/{exec-task-repos.js → exec/task-repos.js} +2 -2
- package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
- package/dist/{exec-trial-commands.js → exec/trial-commands.js} +20 -22
- package/dist/{exec-trial-core.js → exec/trial-core.js} +6 -6
- package/dist/{exec-trial.js → exec/trial.js} +2 -2
- package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
- package/dist/{exec-worktree-ops-commit.js → exec/worktree-ops-commit.js} +25 -60
- package/dist/{exec-worktree-ops-lifecycle.js → exec/worktree-ops-lifecycle.js} +13 -8
- package/dist/{exec-worktree-ops-merge.js → exec/worktree-ops-merge.js} +48 -7
- package/dist/{exec-worktree-ops.js → exec/worktree-ops.js} +3 -3
- package/dist/exec/worktree.js +305 -0
- package/dist/{grade-apply.js → grade/apply.js} +9 -9
- package/dist/{grade-command-apply.js → grade/command-apply.js} +7 -7
- package/dist/{grade-command-inspect.js → grade/command-inspect.js} +6 -6
- package/dist/{grade-command-plan.js → grade/command-plan.js} +5 -5
- package/dist/{grade-core.js → grade/core.js} +3 -3
- package/dist/grade/grade.js +19 -0
- package/dist/{grade-markdown.js → grade/markdown.js} +6 -6
- package/dist/{grade-pipeline-state.js → grade/pipeline-state.js} +4 -4
- package/dist/{grade-plan.js → grade/plan.js} +5 -5
- package/dist/{grade-result.js → grade/result.js} +5 -94
- package/dist/{grade-target-discovery.js → grade/target-discovery.js} +7 -7
- package/dist/{grade-targets.js → grade/targets.js} +11 -8
- package/dist/{job-definition.js → job/definition.js} +25 -6
- package/dist/{job.js → job/job.js} +12 -11
- package/dist/{kata-command.js → kata/command.js} +3 -3
- package/dist/{kata.js → kata/kata.js} +5 -5
- package/dist/register/approach.js +134 -0
- package/dist/{register-core.js → register/core.js} +13 -7
- package/dist/{register-create-commands.js → register/create-commands.js} +115 -8
- package/dist/{register-date.js → register/date.js} +1 -1
- package/dist/register/derivation.js +163 -0
- package/dist/{register-event-merge.js → register/event-merge.js} +32 -3
- package/dist/{register-events.js → register/events.js} +9 -3
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +23 -5
- package/dist/register/lifecycle-lock.js +5 -0
- package/dist/{register-maintenance-commands.js → register/maintenance-commands.js} +13 -7
- package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
- package/dist/{register-migration.js → register/migration.js} +4 -4
- package/dist/{register.js → register/register.js} +32 -27
- package/dist/{register-renumber.js → register/renumber.js} +38 -11
- package/dist/{register-transition-commands.js → register/transition-commands.js} +3 -3
- package/dist/{register-update.js → register/update.js} +5 -5
- package/dist/{register-views.js → register/views.js} +47 -7
- package/dist/{review-grade.js → review/grade.js} +2 -2
- package/dist/{review-plan.js → review/plan.js} +3 -3
- package/dist/{routine-definition.js → routine/definition.js} +2 -2
- package/dist/{routine.js → routine/routine.js} +49 -22
- package/dist/{schedule-approach.js → schedule/approach.js} +8 -8
- package/dist/{schedule-build.js → schedule/build.js} +7 -4
- package/dist/{schedule.js → schedule/schedule.js} +6 -6
- package/dist/{schedule-strategy-generate-document.js → schedule/strategy-generate-document.js} +2 -2
- package/dist/{schedule-strategy-generate-scope.js → schedule/strategy-generate-scope.js} +4 -4
- package/dist/{schedule-strategy-generate.js → schedule/strategy-generate.js} +10 -10
- package/dist/shared/agent-types.js +23 -0
- package/dist/shared/artifact-path.js +9 -0
- package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
- package/dist/{catalog-build-render.js → shared/catalog-render.js} +3 -32
- package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
- package/dist/shared/fs.js +30 -0
- package/dist/{exec-worktree.js → shared/git.js} +83 -241
- package/dist/shared/grade-result.js +94 -0
- package/dist/{package-paths.js → shared/package-paths.js} +3 -3
- package/dist/shared/plan-templates.js +114 -0
- package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +3 -1
- package/dist/shared/random.js +4 -0
- package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
- package/dist/shared/schedule-paths.js +9 -0
- package/dist/{specdojo-config.js → shared/specdojo-config.js} +93 -5
- package/dist/{exec-shared.js → shared/text.js} +0 -134
- package/dist/shared/time.js +28 -0
- package/dist/specdojo.js +22 -22
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +29 -17
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
- package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
- package/docs/ja/specdojo/guides/exec-config-guide.md +91 -16
- package/docs/ja/specdojo/guides/exec-operation-guide.md +145 -12
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +31 -0
- package/docs/ja/specdojo/guides/quick-start-guide.md +81 -16
- package/docs/ja/specdojo/guides/register-operation-guide.md +2 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +10 -1
- package/docs/ja/specdojo/guides/review-guide.md +1 -1
- package/docs/ja/specdojo/guides/routine-operation-guide.md +5 -5
- package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +52 -28
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +17 -11
- package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
- package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
- package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
- package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +20 -0
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +23 -0
- package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
- package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +26 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +70 -7
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +1 -1
- package/package.json +1 -1
- package/templates/antigravity/README.md +5 -1
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
- package/templates/claude/README.md +27 -3
- package/templates/claude/agents/claude-executor.md +0 -1
- package/templates/claude/agents/claude-reporter.md +2 -1
- package/templates/claude/agents/claude-review-executor.md +0 -1
- package/templates/codex/README.md +23 -4
- package/templates/devcontainer/devcontainer.json +2 -2
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +69 -0
- package/templates/devcontainer/remote-host/ssh-config.sample +16 -0
- package/templates/init-agent-members.yaml +75 -25
- package/templates/init-exec-defaults.yaml +24 -8
- package/templates/opencode/README.md +17 -3
- package/templates/opencode/agents/opencode-executor.md +0 -1
- package/templates/opencode/agents/opencode-reporter.md +2 -1
- package/templates/opencode/agents/opencode-review-executor.md +0 -1
- package/dist/exec-schedule-gantt-chart.js +0 -2
- package/dist/exec.js +0 -2
- package/dist/grade.js +0 -19
- package/templates/claude/agents/claude-expert-review-executor.md +0 -14
- /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
- /package/dist/{catalog-types.js → catalog/types.js} +0 -0
- /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
- /package/dist/{role-types.js → exec/role-types.js} +0 -0
- /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
- /package/dist/{exec-types.js → exec/types.js} +0 -0
- /package/dist/{grade-command-shared.js → grade/command-shared.js} +0 -0
- /package/dist/{register-command-types.js → register/command-types.js} +0 -0
- /package/dist/{review-types.js → review/types.js} +0 -0
- /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
- /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
- /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
- /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
- /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
- /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
- /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
- /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
- /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
- /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
- /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
- /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
- /package/dist/{yaml.js → shared/yaml.js} +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { getProjectRegisterPath, loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
4
|
+
import { loadRegisterItemDocs, PJR_ID_RE } from "./item.js";
|
|
5
|
+
const QUALIFIED_REGISTER_ITEM_REF_RE = /^([a-z][a-z0-9-]*):(PJR-[0-9ABCDEFGHJKMNPQRSTVWXYZ]{4})$/;
|
|
6
|
+
export function parseRegisterItemRef(value, currentProjectId) {
|
|
7
|
+
if (PJR_ID_RE.test(value))
|
|
8
|
+
return { projectId: currentProjectId, itemId: value };
|
|
9
|
+
const match = QUALIFIED_REGISTER_ITEM_REF_RE.exec(value);
|
|
10
|
+
return match ? { projectId: match[1], itemId: match[2] } : undefined;
|
|
11
|
+
}
|
|
12
|
+
export function normalizeDerivedFrom(values, options) {
|
|
13
|
+
if (values === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
const refs = [...new Set(values.map((value) => value.trim()).filter(Boolean))];
|
|
16
|
+
if (refs.includes("-")) {
|
|
17
|
+
if (!options.allowRemove)
|
|
18
|
+
throw new Error("--from - is only valid with register update");
|
|
19
|
+
if (refs.length !== 1)
|
|
20
|
+
throw new Error("--from - cannot be combined with other item IDs");
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
if (refs.length === 0)
|
|
24
|
+
throw new Error("--from must contain a register item ID");
|
|
25
|
+
return refs;
|
|
26
|
+
}
|
|
27
|
+
function configuredItemIds(config, projectId) {
|
|
28
|
+
const project = config.projects[projectId];
|
|
29
|
+
if (!project)
|
|
30
|
+
return undefined;
|
|
31
|
+
const registerPath = getProjectRegisterPath(project);
|
|
32
|
+
if (!registerPath) {
|
|
33
|
+
throw new Error(`Cannot verify derived_from item in configured project ${projectId}: project_register_path is not set`);
|
|
34
|
+
}
|
|
35
|
+
const absolutePath = resolve(specdojoRootDir(), registerPath);
|
|
36
|
+
return new Set(loadRegisterItemDocs(absolutePath).map((doc) => doc.id));
|
|
37
|
+
}
|
|
38
|
+
function validateDerivedFromWithConfig(opts, config, idsByProject) {
|
|
39
|
+
for (const ref of opts.derivedFrom) {
|
|
40
|
+
const parsed = parseRegisterItemRef(ref, opts.projectId);
|
|
41
|
+
if (!parsed) {
|
|
42
|
+
throw new Error(`Invalid --from item ID: "${ref}". Use PJR-XXXX or <project-id>:PJR-XXXX`);
|
|
43
|
+
}
|
|
44
|
+
if (parsed.projectId === opts.projectId && parsed.itemId === opts.itemId) {
|
|
45
|
+
throw new Error(`Item ${opts.itemId} cannot derive from itself`);
|
|
46
|
+
}
|
|
47
|
+
if (!config.projects[parsed.projectId])
|
|
48
|
+
continue;
|
|
49
|
+
let ids = idsByProject.get(parsed.projectId);
|
|
50
|
+
if (!idsByProject.has(parsed.projectId)) {
|
|
51
|
+
ids = configuredItemIds(config, parsed.projectId);
|
|
52
|
+
idsByProject.set(parsed.projectId, ids);
|
|
53
|
+
}
|
|
54
|
+
if (!ids?.has(parsed.itemId)) {
|
|
55
|
+
throw new Error(`Derived-from item not found: ${ref} (searched configured project ${parsed.projectId})`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function validateDerivedFrom(opts) {
|
|
60
|
+
if (!opts.derivedFrom)
|
|
61
|
+
return;
|
|
62
|
+
const { config } = loadConfig();
|
|
63
|
+
if (!config)
|
|
64
|
+
throw new Error("register commands require specdojo.config.json");
|
|
65
|
+
validateDerivedFromWithConfig({ ...opts, derivedFrom: opts.derivedFrom }, config, new Map());
|
|
66
|
+
}
|
|
67
|
+
export function validateDerivedFromDocs(paths) {
|
|
68
|
+
const docs = loadRegisterItemDocs(paths.projectRegisterPath);
|
|
69
|
+
const derivedDocs = docs.filter((doc) => doc.item.derivedFrom !== undefined);
|
|
70
|
+
if (derivedDocs.length === 0)
|
|
71
|
+
return [];
|
|
72
|
+
let config;
|
|
73
|
+
try {
|
|
74
|
+
({ config } = loadConfig());
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return [`derived_from: ${error instanceof Error ? error.message : String(error)}`];
|
|
78
|
+
}
|
|
79
|
+
if (!config)
|
|
80
|
+
return ["derived_from: register commands require specdojo.config.json"];
|
|
81
|
+
const errors = [];
|
|
82
|
+
const idsByProject = new Map([
|
|
83
|
+
[paths.projectId, new Set(docs.map((doc) => doc.id))],
|
|
84
|
+
]);
|
|
85
|
+
for (const doc of derivedDocs) {
|
|
86
|
+
try {
|
|
87
|
+
validateDerivedFromWithConfig({
|
|
88
|
+
projectId: paths.projectId,
|
|
89
|
+
itemId: doc.id,
|
|
90
|
+
derivedFrom: doc.item.derivedFrom,
|
|
91
|
+
}, config, idsByProject);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
errors.push(`${doc.filename}: ${error instanceof Error ? error.message : String(error)}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return errors;
|
|
98
|
+
}
|
|
99
|
+
function configuredExternalRegisterDirectories(paths) {
|
|
100
|
+
let config;
|
|
101
|
+
try {
|
|
102
|
+
({ config } = loadConfig());
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// `init --dry-run` may intentionally preserve an existing, non-SpecDojo config file.
|
|
106
|
+
// The current project can still produce an empty/local derivation view in that case.
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
if (!config)
|
|
110
|
+
return [];
|
|
111
|
+
const configuredCurrent = config.projects[paths.projectId];
|
|
112
|
+
const configuredCurrentPath = configuredCurrent
|
|
113
|
+
? getProjectRegisterPath(configuredCurrent)
|
|
114
|
+
: undefined;
|
|
115
|
+
if (!configuredCurrentPath ||
|
|
116
|
+
resolve(specdojoRootDir(), configuredCurrentPath) !== resolve(paths.projectRegisterPath)) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
return Object.entries(config.projects).flatMap(([projectId, project]) => {
|
|
120
|
+
if (projectId === paths.projectId)
|
|
121
|
+
return [];
|
|
122
|
+
const registerPath = getProjectRegisterPath(project);
|
|
123
|
+
if (!registerPath)
|
|
124
|
+
return [];
|
|
125
|
+
const absolutePath = resolve(specdojoRootDir(), registerPath);
|
|
126
|
+
return existsSync(absolutePath) ? [{ projectId, registerPath: absolutePath }] : [];
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
export function collectDerivedRegisterRelations(paths, currentItems) {
|
|
130
|
+
const relations = [];
|
|
131
|
+
const collect = (projectId, items) => {
|
|
132
|
+
for (const item of items) {
|
|
133
|
+
for (const ref of item.item.derivedFrom ?? []) {
|
|
134
|
+
const source = parseRegisterItemRef(ref, projectId);
|
|
135
|
+
if (!source || source.projectId !== paths.projectId)
|
|
136
|
+
continue;
|
|
137
|
+
relations.push({
|
|
138
|
+
sourceId: source.itemId,
|
|
139
|
+
derivedProjectId: projectId,
|
|
140
|
+
derivedItem: item.item,
|
|
141
|
+
derivedTicketPath: item.ticketPath,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
collect(paths.projectId, currentItems.flatMap((view) => view.ticketPath ? [{ item: view.item, ticketPath: view.ticketPath }] : []));
|
|
147
|
+
for (const project of configuredExternalRegisterDirectories(paths)) {
|
|
148
|
+
collect(project.projectId, loadRegisterItemDocs(project.registerPath).map((doc) => ({
|
|
149
|
+
item: doc.item,
|
|
150
|
+
ticketPath: doc.path,
|
|
151
|
+
})));
|
|
152
|
+
}
|
|
153
|
+
return relations.sort((left, right) => {
|
|
154
|
+
if (left.sourceId !== right.sourceId)
|
|
155
|
+
return left.sourceId < right.sourceId ? -1 : 1;
|
|
156
|
+
if (left.derivedProjectId !== right.derivedProjectId) {
|
|
157
|
+
return left.derivedProjectId < right.derivedProjectId ? -1 : 1;
|
|
158
|
+
}
|
|
159
|
+
if (left.derivedItem.id === right.derivedItem.id)
|
|
160
|
+
return 0;
|
|
161
|
+
return left.derivedItem.id < right.derivedItem.id ? -1 : 1;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// 統合 merge で登録簿の記帳ファイルが競合したときの解決処理。イベントファイルは追記型の記録なので、
|
|
2
2
|
// 両側のイベントの和集合(同一 id は 1 件)を時刻順に並べ、`previous_event_id` の連鎖を張り直す。
|
|
3
3
|
// 個票は exec branch 側を基準にし、統合先だけにあるイベントが変えたフィールドのうち、frontmatter の
|
|
4
|
-
// 単純な値へ写せるもの(type / priority / owner / due
|
|
5
|
-
|
|
6
|
-
import {
|
|
4
|
+
// 単純な値へ写せるもの(type / priority / owner / due / approach / targets /
|
|
5
|
+
// derived_from)だけを再構築する。
|
|
6
|
+
import { readRegisterEventsFromContent, serializeRegisterEvents, } from "./events.js";
|
|
7
|
+
import { applyRegisterItemFields, CELL_NONE, CELL_TODO, REMOVE_REGISTER_ITEM_FIELD, } from "./item.js";
|
|
7
8
|
function hasStatusChange(event) {
|
|
8
9
|
return event.changes.some((change) => change.field === "status");
|
|
9
10
|
}
|
|
@@ -136,6 +137,34 @@ function fieldUpdateFromChange(change) {
|
|
|
136
137
|
? null
|
|
137
138
|
: value,
|
|
138
139
|
};
|
|
140
|
+
case "approach":
|
|
141
|
+
return { approach: isUnset ? REMOVE_REGISTER_ITEM_FIELD : value };
|
|
142
|
+
case "targets": {
|
|
143
|
+
if (isUnset)
|
|
144
|
+
return { targets: REMOVE_REGISTER_ITEM_FIELD };
|
|
145
|
+
try {
|
|
146
|
+
const parsed = JSON.parse(value);
|
|
147
|
+
return Array.isArray(parsed) && parsed.every((target) => typeof target === "string")
|
|
148
|
+
? { targets: parsed }
|
|
149
|
+
: undefined;
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
case "derived_from": {
|
|
156
|
+
if (isUnset)
|
|
157
|
+
return { derived_from: REMOVE_REGISTER_ITEM_FIELD };
|
|
158
|
+
try {
|
|
159
|
+
const parsed = JSON.parse(value);
|
|
160
|
+
return Array.isArray(parsed) && parsed.every((ref) => typeof ref === "string")
|
|
161
|
+
? { derived_from: parsed }
|
|
162
|
+
: undefined;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
139
168
|
default:
|
|
140
169
|
return undefined;
|
|
141
170
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
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 { dump, load } from "
|
|
7
|
-
import { CELL_NONE, displayIdFromTicketFilename, readRegisterItemContent, readSpecdojoFields, toDisplayItem, updateSpecdojoFields, VALID_STATUSES, } from "./
|
|
8
|
-
import { isUtcIsoSeconds, nowUtcIsoSeconds } from "
|
|
6
|
+
import { dump, load } from "../shared/yaml.js";
|
|
7
|
+
import { CELL_NONE, displayIdFromTicketFilename, readRegisterItemContent, readSpecdojoFields, toDisplayItem, updateSpecdojoFields, VALID_STATUSES, } from "./item.js";
|
|
8
|
+
import { isUtcIsoSeconds, nowUtcIsoSeconds } from "../shared/time.js";
|
|
9
9
|
export const REGISTER_EVENTS_DIRNAME = "events";
|
|
10
10
|
export const REGISTER_EVENTS_SCHEMA_MODELINE = "# yaml-language-server: $schema=../../../../../../specdojo/schemas/v1/register-events.schema.yaml";
|
|
11
11
|
export const REGISTER_EVENT_FIELDS = [
|
|
@@ -20,6 +20,9 @@ export const REGISTER_EVENT_FIELDS = [
|
|
|
20
20
|
"completed",
|
|
21
21
|
"conclusion",
|
|
22
22
|
"block_reason",
|
|
23
|
+
"approach",
|
|
24
|
+
"targets",
|
|
25
|
+
"derived_from",
|
|
23
26
|
];
|
|
24
27
|
export const REGISTER_EVENT_ACTIONS = [
|
|
25
28
|
"add",
|
|
@@ -68,6 +71,9 @@ export function registerEventFieldValues(content, filename, timeZone) {
|
|
|
68
71
|
completed: item.completed,
|
|
69
72
|
conclusion: item.conclusion,
|
|
70
73
|
block_reason: parsed.blockReason,
|
|
74
|
+
approach: item.approach ?? CELL_NONE,
|
|
75
|
+
targets: item.targets ? JSON.stringify(item.targets) : CELL_NONE,
|
|
76
|
+
derived_from: item.derivedFrom ? JSON.stringify(item.derivedFrom) : CELL_NONE,
|
|
71
77
|
};
|
|
72
78
|
}
|
|
73
79
|
function isUnsetFieldValue(value) {
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// 未移行の期間だけ Git 差分を読み、event の開始時刻より前の legacy 履歴として統合する。
|
|
3
3
|
//
|
|
4
4
|
// 比較対象は生成される登録項目一覧の列(ステータス・タイトル・説明・分類・優先度・担当・
|
|
5
|
-
//
|
|
6
|
-
//
|
|
5
|
+
// 登録日・期限・完了日・結論)に、待機時のブロック理由と approach / targets /
|
|
6
|
+
// derived_from を加える。
|
|
7
|
+
// 一覧に表示しない構造化フィールドも、個票の更新履歴として監査できるよう比較対象にする。
|
|
7
8
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
8
9
|
import { basename, join } from "node:path";
|
|
9
|
-
import { displayIdFromTicketFilename, isPlaceholderCell } from "./
|
|
10
|
-
import { gitOutput, gitResult } from "
|
|
11
|
-
import { DEFAULT_REGISTER_DATE_TIMEZONE } from "
|
|
12
|
-
import { REGISTER_EVENT_FIELDS, REGISTER_EVENTS_DIRNAME, displayIdFromRegisterEventFilename, readRegisterEventsFromContent, registerEventFieldValues, } from "./
|
|
10
|
+
import { displayIdFromTicketFilename, isPlaceholderCell } from "./item.js";
|
|
11
|
+
import { gitOutput, gitResult } from "../shared/git.js";
|
|
12
|
+
import { DEFAULT_REGISTER_DATE_TIMEZONE } from "../shared/specdojo-config.js";
|
|
13
|
+
import { REGISTER_EVENT_FIELDS, REGISTER_EVENTS_DIRNAME, displayIdFromRegisterEventFilename, readRegisterEventsFromContent, registerEventFieldValues, } from "./events.js";
|
|
13
14
|
// 比較する項目と出力順。登録項目一覧の列順(ID と個票リンクを除く)に合わせる。
|
|
14
15
|
export const REGISTER_HISTORY_FIELDS = REGISTER_EVENT_FIELDS;
|
|
15
16
|
// git log の1コミット分の区切り(レコード分離子)とヘッダー項目の区切り(単位分離子)。
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
// 表示 ID・タイトル・説明は frontmatter に重複させず、`id` / H1 / 本文から導出する。
|
|
6
6
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
|
-
import { dump, load } from "
|
|
9
|
-
import { inlineCodeAnglePlaceholders } from "
|
|
10
|
-
import { registerDateFromTimestamp } from "./
|
|
8
|
+
import { dump, load } from "../shared/yaml.js";
|
|
9
|
+
import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
10
|
+
import { registerDateFromTimestamp } from "./date.js";
|
|
11
11
|
export const VALID_STATUSES = [
|
|
12
12
|
"open",
|
|
13
13
|
"in-progress",
|
|
@@ -64,6 +64,8 @@ const SPECDOJO_KEY_ORDER = [
|
|
|
64
64
|
"completed_at",
|
|
65
65
|
"block_reason",
|
|
66
66
|
"conclusion",
|
|
67
|
+
"derived_from",
|
|
68
|
+
"approach",
|
|
67
69
|
"targets",
|
|
68
70
|
];
|
|
69
71
|
// ================================
|
|
@@ -92,8 +94,15 @@ export function ticketRefCell(filename) {
|
|
|
92
94
|
return `[${filename.replace(/\.md$/, "")}](./${filename})`;
|
|
93
95
|
}
|
|
94
96
|
// 表セルへ埋め込むために1行化し、列区切りの `|` をエスケープする。
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
// すでにエスケープ済みの `\|` は再エスケープせず、複数回の呼び出しに対して冪等にする。
|
|
98
|
+
export function toCell(text) {
|
|
99
|
+
if (typeof text !== "string")
|
|
100
|
+
return "";
|
|
101
|
+
return text
|
|
102
|
+
.replace(/\r?\n/g, " ")
|
|
103
|
+
.replace(/\s+/g, " ")
|
|
104
|
+
.replace(/(?<!\\)((\\\\)*)\|/g, "$1\\|")
|
|
105
|
+
.trim();
|
|
97
106
|
}
|
|
98
107
|
// H1(`# PJR-XXXX タイトル`)からタイトルを導出する。表示 ID の接頭辞は取り除く。
|
|
99
108
|
export function titleFromBody(body, id) {
|
|
@@ -159,6 +168,10 @@ export function readRegisterItemContent(content, filename) {
|
|
|
159
168
|
const targets = Array.isArray(fields.targets)
|
|
160
169
|
? fields.targets.filter((entry) => typeof entry === "string" && entry.trim() !== "")
|
|
161
170
|
: undefined;
|
|
171
|
+
const approach = asString(fields.approach);
|
|
172
|
+
const derivedFrom = Array.isArray(fields.derived_from)
|
|
173
|
+
? fields.derived_from.filter((entry) => typeof entry === "string" && entry.trim() !== "")
|
|
174
|
+
: undefined;
|
|
162
175
|
const item = {
|
|
163
176
|
id,
|
|
164
177
|
status: asString(fields.item_status) ?? "open",
|
|
@@ -175,7 +188,9 @@ export function readRegisterItemContent(content, filename) {
|
|
|
175
188
|
completedAt: asString(fields.completed_at) ?? CELL_NONE,
|
|
176
189
|
conclusion: asString(fields.conclusion) ?? CELL_NONE,
|
|
177
190
|
ticket: ticketRefCell(filename),
|
|
191
|
+
...(approach ? { approach } : {}),
|
|
178
192
|
...(targets && targets.length > 0 ? { targets } : {}),
|
|
193
|
+
...(derivedFrom && derivedFrom.length > 0 ? { derivedFrom } : {}),
|
|
179
194
|
};
|
|
180
195
|
return {
|
|
181
196
|
id,
|
|
@@ -295,6 +310,9 @@ export function registerItemFieldsFromItem(item) {
|
|
|
295
310
|
conclusion: isPlaceholderCell(item.conclusion)
|
|
296
311
|
? null
|
|
297
312
|
: inlineCodeAnglePlaceholders(item.conclusion.trim()),
|
|
313
|
+
...(item.approach ? { approach: item.approach } : {}),
|
|
314
|
+
...(item.targets && item.targets.length > 0 ? { targets: item.targets } : {}),
|
|
315
|
+
...(item.derivedFrom && item.derivedFrom.length > 0 ? { derived_from: item.derivedFrom } : {}),
|
|
298
316
|
};
|
|
299
317
|
}
|
|
300
318
|
function orderSpecdojoKeys(fields) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { existsSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { collectRegisterHistoryEvents, formatRegisterHistoryEvents } from "./
|
|
3
|
-
import { createGitTimestampResolver, planRegisterTimestampMigration, summarizeTimestampMigration, } from "./
|
|
4
|
-
import { registerEventFilePath, validateRegisterEventDocs } from "./
|
|
5
|
-
import { validateRegisterItemDocs } from "./
|
|
6
|
-
import { specdojoRootDir } from "
|
|
2
|
+
import { collectRegisterHistoryEvents, formatRegisterHistoryEvents } from "./history.js";
|
|
3
|
+
import { createGitTimestampResolver, planRegisterTimestampMigration, summarizeTimestampMigration, } from "./migrate-timestamps.js";
|
|
4
|
+
import { registerEventFilePath, validateRegisterEventDocs } from "./events.js";
|
|
5
|
+
import { validateRegisterItemDocs } from "./item.js";
|
|
6
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
7
|
+
import { validateDerivedFromDocs } from "./derivation.js";
|
|
7
8
|
export function registerMaintenanceCommands(reg, dependencies) {
|
|
8
9
|
const { addProjectOption, addRegisterCommitOptions, applyRegisterMigrationPlan, generateDerivedViewFiles, loadItemForUpdate, migrateEmbeddedRegisterEvents, migrateRegisterEventsFromGit, parseHistoryIds, planRegisterMigration, planRenumber, printCommandError, registerEventActor, renumberPjrItem, repoRelativePathspec, resolveRegisterPaths, runRegisterMutation, validBuildScopes, writeDerivedViews, } = dependencies;
|
|
9
10
|
// --- migrate ---
|
|
@@ -86,9 +87,14 @@ export function registerMaintenanceCommands(reg, dependencies) {
|
|
|
86
87
|
throw new Error(`Invalid scope: "${opts.scope}". Must be one of: ${validBuildScopes.join(", ")}`);
|
|
87
88
|
}
|
|
88
89
|
const validation = validateRegisterItemDocs(paths.projectRegisterPath);
|
|
90
|
+
const derivationErrors = validateDerivedFromDocs(paths);
|
|
89
91
|
const eventErrors = validateRegisterEventDocs(paths.projectRegisterPath, paths.registerDateTimeZone);
|
|
90
|
-
if (validation.errors.length > 0 || eventErrors.length > 0) {
|
|
91
|
-
throw new Error(`Invalid register item files:\n${[
|
|
92
|
+
if (validation.errors.length > 0 || derivationErrors.length > 0 || eventErrors.length > 0) {
|
|
93
|
+
throw new Error(`Invalid register item files:\n${[
|
|
94
|
+
...validation.errors,
|
|
95
|
+
...derivationErrors,
|
|
96
|
+
...eventErrors,
|
|
97
|
+
].join("\n")}`);
|
|
92
98
|
}
|
|
93
99
|
const views = generateDerivedViewFiles(paths, scope);
|
|
94
100
|
if (opts.dryRun) {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
// 後になっている項目では、追加コミットの時刻は起票時刻ではない)。
|
|
13
13
|
import { readdirSync, readFileSync } from "node:fs";
|
|
14
14
|
import { join, relative, sep } from "node:path";
|
|
15
|
-
import { applyRegisterItemTimestamps, displayIdFromTicketFilename, readRegisterItemContent, readRegisterItemLegacyDates, } from "./
|
|
16
|
-
import { normalizeRegisterTimestamp, REGISTER_FALLBACK_TIME_OF_DAY, registerDateFromTimestamp, timestampFromDateInTimeZone, } from "./
|
|
17
|
-
import { gitResult } from "
|
|
15
|
+
import { applyRegisterItemTimestamps, displayIdFromTicketFilename, readRegisterItemContent, readRegisterItemLegacyDates, } from "./item.js";
|
|
16
|
+
import { normalizeRegisterTimestamp, REGISTER_FALLBACK_TIME_OF_DAY, registerDateFromTimestamp, timestampFromDateInTimeZone, } from "./date.js";
|
|
17
|
+
import { gitResult } from "../shared/git.js";
|
|
18
18
|
// git log の1行書式。コミットハッシュも ISO 日付も空白を含まないため、空白で分割できる。
|
|
19
19
|
const COMMIT_LOG_FORMAT = "--format=%H %aI";
|
|
20
20
|
// 完了日を記録する終端状態。deferred は終端だが完了日を持たないため含めない。
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { existsSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, join } from "node:path";
|
|
4
|
-
import { buildRegisterItemContent, locateRegisterTable, parsePjrIndex, slugify, validateFields, } from "./
|
|
5
|
-
import { applyRegisterItemFields, loadRegisterItemDocs, prependRegisterItemDescription, readRegisterItemContent, registerItemFieldsFromItem, setRegisterItemTitle, } from "./
|
|
6
|
-
import { resolveSpecdojoTemplatePath } from "
|
|
7
|
-
import { loadRegisterItems } from "./
|
|
4
|
+
import { buildRegisterItemContent, locateRegisterTable, parsePjrIndex, slugify, validateFields, } from "./core.js";
|
|
5
|
+
import { applyRegisterItemFields, loadRegisterItemDocs, prependRegisterItemDescription, readRegisterItemContent, registerItemFieldsFromItem, setRegisterItemTitle, } from "./item.js";
|
|
6
|
+
import { resolveSpecdojoTemplatePath } from "../docs/template-resolution.js";
|
|
7
|
+
import { loadRegisterItems } from "./views.js";
|
|
8
8
|
const REGISTER_ITEM_VALUE_KEYS = [
|
|
9
9
|
"id",
|
|
10
10
|
"status",
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { relative, sep } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { inlineCodeAnglePlaceholders } from "
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
export { PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, };
|
|
22
|
-
export { REGISTER_TOPIC_RE, VALID_TICKET_STATUSES, buildRegisterItemContent, extractTableHeading, findMarkdownReferenceFiles, generatePjrId, injectRegisterRows, parsePjrIndex, resolveRegisterPaths, } from "./
|
|
23
|
-
export { applyRegisterMigrationPlan, planRegisterMigration, } from "./
|
|
24
|
-
export { findItemById, findRegisterItem, generateDerivedViewFiles, injectViewSlots, loadRegisterItems, sortByRegisteredDesc, } from "./
|
|
25
|
-
export { parseTicketFilename, updateTicketFrontmatterStatus, updateTicketStatusForItem, } from "./
|
|
26
|
-
export { planRenumber, planRetopic, renumberPjrItem, renumberReferences, renumberTicketContent, retopicPjrItem, ticketTopicFromFilename, } from "./
|
|
3
|
+
import { CrossProcessMutex } from "../shared/cross-process-lock.js";
|
|
4
|
+
import { gitOutput, gitResult, repoRelative, stageCommitTargets, worktreeStatusPaths, } from "../shared/git.js";
|
|
5
|
+
import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
6
|
+
import { atomicWriteFile, buildRegisterItemContent, derivedTopicNeedsWarning, generatePjrId, printDerivedTopicWarning, registerEventActor, REGISTER_TOPIC_RE, resolveRegisterPaths, slugify, validateFields, } from "./core.js";
|
|
7
|
+
import { registerCreateCommands, registerUpdateCommand } from "./create-commands.js";
|
|
8
|
+
import { normalizeRegisterTimestamp } from "./date.js";
|
|
9
|
+
import { validateDerivedFromDocs } from "./derivation.js";
|
|
10
|
+
import { appendRegisterEvent, deterministicRegisterEventId, readEmbeddedRegisterEvents, readRegisterEventsFromContent, registerEventFilePath, removeEmbeddedRegisterEvents, serializeRegisterEvents, validateRegisterEventDocs, } from "./events.js";
|
|
11
|
+
import { collectRegisterHistoryEvents } from "./history.js";
|
|
12
|
+
import { loadRegisterItemDocs, PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, toCell, validateRegisterItemDocs, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "./item.js";
|
|
13
|
+
import { registerMaintenanceCommands } from "./maintenance-commands.js";
|
|
14
|
+
import { applyRegisterMigrationPlan, planRegisterMigration } from "./migration.js";
|
|
15
|
+
import { planRenumber, planRetopic, renumberPjrItem, retopicPjrItem, ticketTopicFromFilename, } from "./renumber.js";
|
|
16
|
+
import { registerTransitionCommands } from "./transition-commands.js";
|
|
17
|
+
import { applyItemUpdate, assertTerminalOperationAllowed, loadItemForUpdate, updateTicketStatusForItem, } from "./update.js";
|
|
18
|
+
import { generateDerivedViewFiles, loadRegisterItems, VALID_BUILD_SCOPES, writeDerivedViews, } from "./views.js";
|
|
19
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
20
|
+
import { registerLifecyclePoolPath } from "./lifecycle-lock.js";
|
|
21
|
+
export { PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, toCell, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, };
|
|
22
|
+
export { REGISTER_TOPIC_RE, VALID_TICKET_STATUSES, buildRegisterItemContent, extractTableHeading, findMarkdownReferenceFiles, generatePjrId, injectRegisterRows, parsePjrIndex, resolveRegisterPaths, } from "./core.js";
|
|
23
|
+
export { applyRegisterMigrationPlan, planRegisterMigration, } from "./migration.js";
|
|
24
|
+
export { findItemById, findRegisterItem, generateDerivedViewFiles, injectViewSlots, loadRegisterItems, sortByRegisteredDesc, } from "./views.js";
|
|
25
|
+
export { parseTicketFilename, updateTicketFrontmatterStatus, updateTicketStatusForItem, } from "./update.js";
|
|
26
|
+
export { planRenumber, planRetopic, renumberPjrItem, renumberReferences, renumberTicketContent, retopicPjrItem, ticketTopicFromFilename, } from "./renumber.js";
|
|
27
27
|
// 作成する個票ファイル名と割り当て ID を算出する純粋関数。I/O を持たず、
|
|
28
28
|
// フィールド検証と ID 衝突検知だけを行う。ID を省略するとランダムに採番する。
|
|
29
29
|
export function planRegisterItem(opts) {
|
|
@@ -81,9 +81,14 @@ function defaultRegisterCommitMessage(command, result) {
|
|
|
81
81
|
}
|
|
82
82
|
function rebuildRegisterViews(paths) {
|
|
83
83
|
const validation = validateRegisterItemDocs(paths.projectRegisterPath);
|
|
84
|
+
const derivationErrors = validateDerivedFromDocs(paths);
|
|
84
85
|
const eventErrors = validateRegisterEventDocs(paths.projectRegisterPath, paths.registerDateTimeZone);
|
|
85
|
-
if (validation.errors.length > 0 || eventErrors.length > 0) {
|
|
86
|
-
throw new Error(`Invalid register item files:\n${[
|
|
86
|
+
if (validation.errors.length > 0 || derivationErrors.length > 0 || eventErrors.length > 0) {
|
|
87
|
+
throw new Error(`Invalid register item files:\n${[
|
|
88
|
+
...validation.errors,
|
|
89
|
+
...derivationErrors,
|
|
90
|
+
...eventErrors,
|
|
91
|
+
].join("\n")}`);
|
|
87
92
|
}
|
|
88
93
|
writeDerivedViews(paths, "all");
|
|
89
94
|
}
|
|
@@ -141,7 +146,7 @@ async function runRegisterMutation(command, opts, mutate) {
|
|
|
141
146
|
if (!paths.executionPath) {
|
|
142
147
|
throw new Error(`Execution path is not configured for project ${paths.projectId}`);
|
|
143
148
|
}
|
|
144
|
-
const mutex = new CrossProcessMutex(
|
|
149
|
+
const mutex = new CrossProcessMutex(registerLifecyclePoolPath(paths.executionPath), {
|
|
145
150
|
actor: registerEventActor(opts),
|
|
146
151
|
label: `register ${command}`,
|
|
147
152
|
}, {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
2
2
|
import { basename, join } from "node:path";
|
|
3
|
-
import { atomicWriteFile, findMarkdownReferenceFiles, formatTableRow, isTableSeparator, parsePjrIndex, parseTableCells, prepareRegisterEventFile, REGISTER_SECTION_RE, REGISTER_TOPIC_RE, } from "./
|
|
4
|
-
import { appendRegisterEvent, buildRegisterEvent, registerEventFilePath
|
|
5
|
-
import { parseSpecdojoDocument } from "
|
|
6
|
-
import { applyRegisterItemFields, PJR_ID_RE, registerItemFieldsFromItem, REMOVE_REGISTER_ITEM_FIELD, setRegisterItemDescription, setRegisterItemTitle, ticketRefCell, toDisplayItem, } from "./
|
|
7
|
-
import { specdojoRootDir } from "
|
|
8
|
-
import { loadItemForUpdate } from "./
|
|
9
|
-
import { findRegisterItem, loadRegisterItems, writeDerivedViews } from "./
|
|
3
|
+
import { atomicWriteFile, findMarkdownReferenceFiles, formatTableRow, isTableSeparator, parsePjrIndex, parseTableCells, prepareRegisterEventFile, REGISTER_SECTION_RE, REGISTER_TOPIC_RE, } from "./core.js";
|
|
4
|
+
import { appendRegisterEvent, buildRegisterEvent, registerEventFilePath } from "./events.js";
|
|
5
|
+
import { parseSpecdojoDocument } from "../docs/frontmatter-namespace.js";
|
|
6
|
+
import { applyRegisterItemFields, PJR_ID_RE, readRegisterItemContent, readSpecdojoFields, registerItemFieldsFromItem, REMOVE_REGISTER_ITEM_FIELD, setRegisterItemDescription, setRegisterItemTitle, ticketRefCell, toDisplayItem, } from "./item.js";
|
|
7
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
8
|
+
import { loadItemForUpdate } from "./update.js";
|
|
9
|
+
import { findRegisterItem, loadRegisterItems, writeDerivedViews } from "./views.js";
|
|
10
10
|
// ================================
|
|
11
11
|
// Renumber (duplicate ID recovery)
|
|
12
12
|
// ================================
|
|
@@ -66,6 +66,31 @@ export function renumberReferences(content, fromDocId, toDocId) {
|
|
|
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 の
|
|
70
|
+
// 置換とは分けて frontmatter の配列だけを更新する。同一 project の短縮形と、別 project
|
|
71
|
+
// から参照する project 修飾形の両方を対象にする。
|
|
72
|
+
function renumberDerivedFromReferences(content, filename, sourceProjectId, fromId, toId) {
|
|
73
|
+
const parsed = readRegisterItemContent(content, filename);
|
|
74
|
+
if (!parsed?.item.derivedFrom)
|
|
75
|
+
return { content, changed: false };
|
|
76
|
+
const docId = readSpecdojoFields(content).id;
|
|
77
|
+
const referencingProjectId = typeof docId === "string" && docId.includes(":") ? docId.split(":", 1)[0] : undefined;
|
|
78
|
+
let changed = false;
|
|
79
|
+
const derivedFrom = parsed.item.derivedFrom.map((ref) => {
|
|
80
|
+
if (referencingProjectId === sourceProjectId && ref === fromId) {
|
|
81
|
+
changed = true;
|
|
82
|
+
return toId;
|
|
83
|
+
}
|
|
84
|
+
if (ref === `${sourceProjectId}:${fromId}`) {
|
|
85
|
+
changed = true;
|
|
86
|
+
return `${sourceProjectId}:${toId}`;
|
|
87
|
+
}
|
|
88
|
+
return ref;
|
|
89
|
+
});
|
|
90
|
+
return changed
|
|
91
|
+
? { content: applyRegisterItemFields(content, { derived_from: derivedFrom }), changed }
|
|
92
|
+
: { content, changed };
|
|
93
|
+
}
|
|
69
94
|
// topic 変更で書き換える全ファイルを事前に算出する。参照の更新範囲は renumber と
|
|
70
95
|
// 同じく docs/ja 配下(生成物を除く)とし、文書 ID を含む wikilink / targets を
|
|
71
96
|
// 付け替える。衝突や個票 ID の不整合は、書き込み前に検出する。
|
|
@@ -231,7 +256,7 @@ export function planRenumber(paths, fromId, toId) {
|
|
|
231
256
|
if (hasIndexRow) {
|
|
232
257
|
writes.push({ path: paths.pjrIndexPath, content: newIndexContent });
|
|
233
258
|
}
|
|
234
|
-
// 参照リンク・targets の付け替え(doc id を持つ個票がある場合のみ)。
|
|
259
|
+
// 参照リンク・targets・derived_from の付け替え(doc id を持つ個票がある場合のみ)。
|
|
235
260
|
if (fromDocId && toDocId) {
|
|
236
261
|
const root = specdojoRootDir();
|
|
237
262
|
const referenceFiles = findMarkdownReferenceFiles(root);
|
|
@@ -241,9 +266,11 @@ export function planRenumber(paths, fromId, toId) {
|
|
|
241
266
|
if (ticketRename && absPath === ticketRename.from)
|
|
242
267
|
continue;
|
|
243
268
|
const content = readFileSync(absPath, "utf8");
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
269
|
+
const docReferenceUpdate = renumberReferences(content, fromDocId, toDocId);
|
|
270
|
+
const derivedFromUpdate = renumberDerivedFromReferences(docReferenceUpdate.content, basename(absPath), paths.projectId, fromId, toId);
|
|
271
|
+
if (docReferenceUpdate.changed || derivedFromUpdate.changed) {
|
|
272
|
+
writes.push({ path: absPath, content: derivedFromUpdate.content });
|
|
273
|
+
}
|
|
247
274
|
}
|
|
248
275
|
}
|
|
249
276
|
return { writes, ticketRename };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { inlineCodeAnglePlaceholders } from "
|
|
2
|
-
import { nowUtcTimestamp } from "./
|
|
3
|
-
import { CELL_NONE } from "./
|
|
1
|
+
import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
2
|
+
import { nowUtcTimestamp } from "./date.js";
|
|
3
|
+
import { CELL_NONE } from "./item.js";
|
|
4
4
|
export function registerTransitionCommands(reg, dependencies) {
|
|
5
5
|
const { addProjectOption, addRegisterCommitOptions, applyItemUpdate, assertRegisterItemCommitTargetsClean, assertTerminalOperationAllowed, loadItemForUpdate, parseRegisterTimestampOption, registerEventActor, runRegisterMutation, updateTicketStatusForItem, } = dependencies;
|
|
6
6
|
// --- close ---
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { basename, join } from "node:path";
|
|
3
|
-
import { atomicWriteFile, prepareRegisterEventFile } from "./
|
|
4
|
-
import { buildRegisterEvent } from "./
|
|
5
|
-
import { parseSpecdojoDocument } from "
|
|
6
|
-
import { applyRegisterItemFields, formatRegisterItemFields, PJR_ID_RE, registerItemFieldsFromItem, REMOVE_REGISTER_ITEM_FIELD, setRegisterItemDescription, setRegisterItemTitle, TERMINAL_STATUSES_SET, } from "./
|
|
7
|
-
import { findRegisterItem, loadRegisterItems, writeDerivedViews } from "./
|
|
3
|
+
import { atomicWriteFile, prepareRegisterEventFile } from "./core.js";
|
|
4
|
+
import { buildRegisterEvent } from "./events.js";
|
|
5
|
+
import { parseSpecdojoDocument } from "../docs/frontmatter-namespace.js";
|
|
6
|
+
import { applyRegisterItemFields, formatRegisterItemFields, PJR_ID_RE, registerItemFieldsFromItem, REMOVE_REGISTER_ITEM_FIELD, setRegisterItemDescription, setRegisterItemTitle, TERMINAL_STATUSES_SET, } from "./item.js";
|
|
7
|
+
import { findRegisterItem, loadRegisterItems, writeDerivedViews } from "./views.js";
|
|
8
8
|
// 更新対象の登録項目を解決する。個票ファイルが無い項目は、書き込み先(正本)が無いため
|
|
9
9
|
// 更新できない。移行が済んでいない旧項目に当たった場合は、個票化を促して中断する。
|
|
10
10
|
export function loadItemForUpdate(paths, id, guard) {
|