specdojo 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/agents/specdojo-orchestrator.md +61 -2
- package/CHANGELOG.md +90 -0
- package/README.md +85 -25
- 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} +168 -45
- package/dist/commands/night-orchestrator.js +287 -0
- package/dist/{orchestrator.js → commands/orchestrator.js} +12 -5
- 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} +8 -4
- package/dist/devcontainer/scaffold.js +418 -0
- 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} +92 -5
- 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} +18 -4
- package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +29 -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} +114 -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} +14 -11
- 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} +142 -25
- package/dist/{exec-results.js → exec/results.js} +287 -31
- package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +35 -12
- package/dist/{exec-run-agent.js → exec/run/agent.js} +115 -28
- package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
- package/dist/{exec-run-job.js → exec/run/job.js} +65 -36
- 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} +38 -11
- package/dist/{exec-run-register-core.js → exec/run/register-core.js} +63 -21
- package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +58 -31
- package/dist/exec/run/register-post-review.js +420 -0
- package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +48 -27
- 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} +119 -24
- 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} +78 -30
- 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} +104 -17
- 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} +26 -8
- package/dist/{register-create-commands.js → register/create-commands.js} +171 -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} +44 -3
- package/dist/{register-events.js → register/events.js} +13 -3
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +32 -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} +5 -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/shared/git.js +346 -0
- 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} +6 -3
- 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} +162 -21
- package/dist/{exec-shared.js → shared/text.js} +4 -135
- package/dist/shared/time.js +28 -0
- package/dist/shared/workspace-scaffold.js +69 -0
- package/dist/specdojo.js +22 -22
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +31 -18
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +3 -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/exec-templates/xrp-register-post-run-template.md +46 -0
- package/docs/ja/specdojo/guides/branch-workflow-guide.md +34 -1
- package/docs/ja/specdojo/guides/docs-structure-guide.md +2 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +169 -26
- package/docs/ja/specdojo/guides/exec-operation-guide.md +184 -13
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +40 -3
- package/docs/ja/specdojo/guides/quick-start-guide.md +89 -21
- package/docs/ja/specdojo/guides/register-operation-guide.md +44 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +61 -6
- 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/specdojo-overview-guide.md +1 -1
- package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
- package/docs/ja/specdojo/guides/waza-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +124 -55
- package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +22 -13
- 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 +111 -17
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +28 -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 +38 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +5 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +91 -7
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +36 -1
- package/package.json +17 -17
- package/templates/antigravity/README.md +6 -2
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
- package/templates/antigravity/orchestrator.md +61 -2
- 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/claude/agents/specdojo-orchestrator.md +61 -2
- package/templates/codex/README.md +40 -4
- package/templates/codex/agents/specdojo-orchestrator.toml +61 -2
- package/templates/codex/orchestrator.md +61 -2
- package/templates/devcontainer/devcontainer.json +5 -2
- package/templates/devcontainer/post-create.sh +15 -7
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +102 -0
- package/templates/devcontainer/remote-host/ssh-config.sample +19 -0
- package/templates/devcontainer/vim/vimrc +37 -0
- package/templates/init-agent-members.yaml +75 -25
- package/templates/init-exec-defaults.yaml +44 -9
- 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/templates/opencode/agents/specdojo-orchestrator.md +61 -2
- package/dist/devcontainer-scaffold.js +0 -165
- package/dist/exec-schedule-gantt-chart.js +0 -2
- package/dist/exec-worktree.js +0 -474
- 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
|
@@ -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",
|
|
@@ -28,6 +28,7 @@ export const VALID_TYPES = [
|
|
|
28
28
|
"note",
|
|
29
29
|
];
|
|
30
30
|
export const VALID_PRIORITIES = ["high", "medium", "low"];
|
|
31
|
+
export const VALID_DIFFICULTIES = ["hard", "medium", "easy"];
|
|
31
32
|
export const TERMINAL_STATUSES_SET = new Set(["done", "decided", "rejected", "deferred"]);
|
|
32
33
|
// PJR-ID の乱数部分に使う 32 文字セット。曖昧文字(`I` / `L` / `O` / `U`)を除いた
|
|
33
34
|
// 英大文字(単一ケース)と数字で構成し、目視・手入力時の誤読を避ける。
|
|
@@ -58,12 +59,16 @@ const SPECDOJO_KEY_ORDER = [
|
|
|
58
59
|
"item_type",
|
|
59
60
|
"item_status",
|
|
60
61
|
"priority",
|
|
62
|
+
"difficulty",
|
|
61
63
|
"owner",
|
|
62
64
|
"registered_at",
|
|
63
65
|
"due_on",
|
|
64
66
|
"completed_at",
|
|
65
67
|
"block_reason",
|
|
66
68
|
"conclusion",
|
|
69
|
+
"derived_from",
|
|
70
|
+
"autopilot",
|
|
71
|
+
"approach",
|
|
67
72
|
"targets",
|
|
68
73
|
];
|
|
69
74
|
// ================================
|
|
@@ -92,8 +97,15 @@ export function ticketRefCell(filename) {
|
|
|
92
97
|
return `[${filename.replace(/\.md$/, "")}](./${filename})`;
|
|
93
98
|
}
|
|
94
99
|
// 表セルへ埋め込むために1行化し、列区切りの `|` をエスケープする。
|
|
95
|
-
|
|
96
|
-
|
|
100
|
+
// すでにエスケープ済みの `\|` は再エスケープせず、複数回の呼び出しに対して冪等にする。
|
|
101
|
+
export function toCell(text) {
|
|
102
|
+
if (typeof text !== "string")
|
|
103
|
+
return "";
|
|
104
|
+
return text
|
|
105
|
+
.replace(/\r?\n/g, " ")
|
|
106
|
+
.replace(/\s+/g, " ")
|
|
107
|
+
.replace(/(?<!\\)((\\\\)*)\|/g, "$1\\|")
|
|
108
|
+
.trim();
|
|
97
109
|
}
|
|
98
110
|
// H1(`# PJR-XXXX タイトル`)からタイトルを導出する。表示 ID の接頭辞は取り除く。
|
|
99
111
|
export function titleFromBody(body, id) {
|
|
@@ -159,6 +171,12 @@ export function readRegisterItemContent(content, filename) {
|
|
|
159
171
|
const targets = Array.isArray(fields.targets)
|
|
160
172
|
? fields.targets.filter((entry) => typeof entry === "string" && entry.trim() !== "")
|
|
161
173
|
: undefined;
|
|
174
|
+
const approach = asString(fields.approach);
|
|
175
|
+
const derivedFrom = Array.isArray(fields.derived_from)
|
|
176
|
+
? fields.derived_from.filter((entry) => typeof entry === "string" && entry.trim() !== "")
|
|
177
|
+
: undefined;
|
|
178
|
+
const autopilot = fields.autopilot === "approved" ? "approved" : undefined;
|
|
179
|
+
const difficulty = asString(fields.difficulty);
|
|
162
180
|
const item = {
|
|
163
181
|
id,
|
|
164
182
|
status: asString(fields.item_status) ?? "open",
|
|
@@ -166,6 +184,7 @@ export function readRegisterItemContent(content, filename) {
|
|
|
166
184
|
description: descriptionFromBody(body),
|
|
167
185
|
type: asString(fields.item_type) ?? CELL_TODO,
|
|
168
186
|
priority: asString(fields.priority) ?? "medium",
|
|
187
|
+
...(difficulty ? { difficulty } : {}),
|
|
169
188
|
owner: asString(fields.owner) ?? CELL_TODO,
|
|
170
189
|
registeredAt: asString(fields.registered_at) ?? CELL_TODO,
|
|
171
190
|
due: fields.due_on === null
|
|
@@ -175,7 +194,10 @@ export function readRegisterItemContent(content, filename) {
|
|
|
175
194
|
completedAt: asString(fields.completed_at) ?? CELL_NONE,
|
|
176
195
|
conclusion: asString(fields.conclusion) ?? CELL_NONE,
|
|
177
196
|
ticket: ticketRefCell(filename),
|
|
197
|
+
...(approach ? { approach } : {}),
|
|
178
198
|
...(targets && targets.length > 0 ? { targets } : {}),
|
|
199
|
+
...(derivedFrom && derivedFrom.length > 0 ? { derivedFrom } : {}),
|
|
200
|
+
...(autopilot ? { autopilot } : {}),
|
|
179
201
|
};
|
|
180
202
|
return {
|
|
181
203
|
id,
|
|
@@ -284,6 +306,7 @@ export function registerItemFieldsFromItem(item) {
|
|
|
284
306
|
item_type: item.type,
|
|
285
307
|
item_status: item.status,
|
|
286
308
|
priority: item.priority,
|
|
309
|
+
...(item.difficulty ? { difficulty: item.difficulty } : {}),
|
|
287
310
|
owner: isPlaceholderCell(item.owner) ? null : item.owner.trim(),
|
|
288
311
|
registered_at: isPlaceholderCell(item.registeredAt) ? null : item.registeredAt.trim(),
|
|
289
312
|
due_on: item.due.trim() === CELL_TODO
|
|
@@ -295,6 +318,10 @@ export function registerItemFieldsFromItem(item) {
|
|
|
295
318
|
conclusion: isPlaceholderCell(item.conclusion)
|
|
296
319
|
? null
|
|
297
320
|
: inlineCodeAnglePlaceholders(item.conclusion.trim()),
|
|
321
|
+
...(item.approach ? { approach: item.approach } : {}),
|
|
322
|
+
...(item.targets && item.targets.length > 0 ? { targets: item.targets } : {}),
|
|
323
|
+
...(item.derivedFrom && item.derivedFrom.length > 0 ? { derived_from: item.derivedFrom } : {}),
|
|
324
|
+
...(item.autopilot ? { autopilot: item.autopilot } : {}),
|
|
298
325
|
};
|
|
299
326
|
}
|
|
300
327
|
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",
|
|
@@ -144,6 +144,7 @@ export function planRegisterMigration(paths) {
|
|
|
144
144
|
title: tableCellToBody(source.item.title),
|
|
145
145
|
description: tableCellToBody(source.item.description),
|
|
146
146
|
priority: source.item.priority,
|
|
147
|
+
...(source.item.difficulty ? { difficulty: source.item.difficulty } : {}),
|
|
147
148
|
status: source.item.status,
|
|
148
149
|
owner: source.item.owner,
|
|
149
150
|
registeredAt: source.item.registeredAt,
|
|
@@ -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_DIFFICULTIES, 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_DIFFICULTIES, 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) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { basename, dirname, join } from "node:path";
|
|
3
|
-
import { extractTableHeading, formatTableRow, injectRegisterRows, parsePjrIndex, REGISTER_INDEX_TEMPLATE, } from "./
|
|
4
|
-
import { readRegisterEventsFromContent, registerEventFilePath } from "./
|
|
5
|
-
import { compareRegisterItemIds, loadRegisterItemDocs, ticketRefCell, toDisplayItem, VALID_PRIORITIES, VALID_STATUSES, } from "./
|
|
6
|
-
import { flattenTemplateFrontmatter } from "
|
|
7
|
-
import { resolveSpecdojoTemplatePath } from "
|
|
2
|
+
import { basename, dirname, join, relative, sep } from "node:path";
|
|
3
|
+
import { extractTableHeading, formatTableRow, injectRegisterRows, parsePjrIndex, REGISTER_INDEX_TEMPLATE, } from "./core.js";
|
|
4
|
+
import { readRegisterEventsFromContent, registerEventFilePath } from "./events.js";
|
|
5
|
+
import { compareRegisterItemIds, loadRegisterItemDocs, ticketRefCell, toCell, toDisplayItem, VALID_PRIORITIES, VALID_STATUSES, } from "./item.js";
|
|
6
|
+
import { flattenTemplateFrontmatter } from "../docs/template-frontmatter.js";
|
|
7
|
+
import { resolveSpecdojoTemplatePath } from "../docs/template-resolution.js";
|
|
8
|
+
import { collectDerivedRegisterRelations } from "./derivation.js";
|
|
8
9
|
// ================================
|
|
9
10
|
// Derived View Generation
|
|
10
11
|
// ================================
|
|
@@ -140,6 +141,41 @@ function generateViewsByOwnerFile(items, projectId, heading) {
|
|
|
140
141
|
"by-owner": renderGroupedTables(groupByOwner(items), 1, heading),
|
|
141
142
|
});
|
|
142
143
|
}
|
|
144
|
+
function markdownLink(label, fromDirectory, targetPath) {
|
|
145
|
+
const path = relative(fromDirectory, targetPath).split(sep).join("/");
|
|
146
|
+
const href = path.startsWith(".") ? path : `./${path}`;
|
|
147
|
+
return `[${toCell(label)}](${href})`;
|
|
148
|
+
}
|
|
149
|
+
function generateDerivedItemsFile(paths, items) {
|
|
150
|
+
const sourceDocs = new Map(items.flatMap((view) => (view.ticketPath ? [[view.id, view.ticketPath]] : [])));
|
|
151
|
+
const rows = collectDerivedRegisterRelations(paths, items).map((relation) => {
|
|
152
|
+
const sourcePath = sourceDocs.get(relation.sourceId);
|
|
153
|
+
const sourceCell = sourcePath
|
|
154
|
+
? markdownLink(relation.sourceId, paths.generatedPath, sourcePath)
|
|
155
|
+
: relation.sourceId;
|
|
156
|
+
const derivedLabel = relation.derivedProjectId === paths.projectId
|
|
157
|
+
? relation.derivedItem.id
|
|
158
|
+
: `${relation.derivedProjectId}:${relation.derivedItem.id}`;
|
|
159
|
+
const derivedCell = markdownLink(derivedLabel, paths.generatedPath, relation.derivedTicketPath);
|
|
160
|
+
return `| ${[
|
|
161
|
+
sourceCell,
|
|
162
|
+
derivedCell,
|
|
163
|
+
relation.derivedItem.type,
|
|
164
|
+
relation.derivedItem.status,
|
|
165
|
+
relation.derivedItem.title,
|
|
166
|
+
]
|
|
167
|
+
.map(toCell)
|
|
168
|
+
.join(" | ")} |`;
|
|
169
|
+
});
|
|
170
|
+
const table = [
|
|
171
|
+
"<!-- prettier-ignore -->",
|
|
172
|
+
"| 元の項目 | 派生先 | 分類 | ステータス | タイトル |",
|
|
173
|
+
"| --- | --- | --- | --- | --- |",
|
|
174
|
+
...rows,
|
|
175
|
+
].join("\n");
|
|
176
|
+
const template = loadViewTemplate("pjr-derived-items-template.md", paths.projectId);
|
|
177
|
+
return injectViewSlots(template, { "derived-items": table });
|
|
178
|
+
}
|
|
143
179
|
function generateTypeFilterView(items, type, templateFileName, projectId, heading) {
|
|
144
180
|
const filtered = items.filter((it) => it.type === type);
|
|
145
181
|
const template = loadViewTemplate(templateFileName, projectId);
|
|
@@ -152,7 +188,8 @@ export function generateDerivedViewFiles(paths, scope) {
|
|
|
152
188
|
// 項目の値は個票 frontmatter(正本)から集める。列見出しは template から採用するため、
|
|
153
189
|
// 生成処理は作業ツリーの pjr-index.md を入力にしない。
|
|
154
190
|
// 「登録日」「完了日」は保存された日時をプロジェクトの登録日タイムゾーンへ変換して導出する。
|
|
155
|
-
const
|
|
191
|
+
const itemViews = loadRegisterItems(paths);
|
|
192
|
+
const items = itemViews.map((view) => toDisplayItem(view.item, paths.registerDateTimeZone));
|
|
156
193
|
const heading = extractTableHeading(loadViewTemplate(REGISTER_INDEX_TEMPLATE, paths.projectId));
|
|
157
194
|
// 個票セルのリンクは project-register/ 起点の `./` 表記で作られる。
|
|
158
195
|
// 各 generated/ ディレクトリから辿れるよう相対パスを付け替える。
|
|
@@ -177,6 +214,9 @@ export function generateDerivedViewFiles(paths, scope) {
|
|
|
177
214
|
}, {
|
|
178
215
|
path: join(paths.generatedPath, "pjr-views-by-owner.md"),
|
|
179
216
|
content: generateViewsByOwnerFile(viewItems, paths.projectId, heading),
|
|
217
|
+
}, {
|
|
218
|
+
path: join(paths.generatedPath, "pjr-derived-items.md"),
|
|
219
|
+
content: generateDerivedItemsFile(paths, itemViews),
|
|
180
220
|
});
|
|
181
221
|
}
|
|
182
222
|
if (scope === "controls" || scope === "all") {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { gitEnvironment } from "
|
|
5
|
-
import { gradeContentHash, gradeFindingDisplayMessage, gradeResultPathForDocument, parseGradeResult, } from "
|
|
4
|
+
import { gitEnvironment } from "../shared/git-environment.js";
|
|
5
|
+
import { gradeContentHash, gradeFindingDisplayMessage, gradeResultPathForDocument, parseGradeResult, } from "../shared/grade-result.js";
|
|
6
6
|
export const REVIEW_GRADE_SCRIPT = join("tools", "grade", "run-per-document.sh");
|
|
7
7
|
function errorMessage(error) {
|
|
8
8
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { dump, load } from "
|
|
3
|
-
import { resolveSpecdojoPath } from "
|
|
4
|
-
import { GRADE_LEVEL_REVIEW_VERDICTS, REVIEW_VERDICTS, describeInvalidReviewVerdict, } from "./
|
|
2
|
+
import { dump, load } from "../shared/yaml.js";
|
|
3
|
+
import { resolveSpecdojoPath } from "../docs/template-resolution.js";
|
|
4
|
+
import { GRADE_LEVEL_REVIEW_VERDICTS, REVIEW_VERDICTS, describeInvalidReviewVerdict, } from "./types.js";
|
|
5
5
|
export const COMMON_VIEWPOINTS_ID = "specdojo:pm-review-viewpoints";
|
|
6
6
|
function nestedRecord(value) {
|
|
7
7
|
return isRecord(value) ? value : undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { basename, join, resolve } from "node:path";
|
|
2
|
-
import { getProjectRoutinesPath, loadConfig, loadEnv, specdojoRootDir } from "
|
|
3
|
-
import { listFilesRecursive, readYaml } from "
|
|
2
|
+
import { getProjectRoutinesPath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
3
|
+
import { listFilesRecursive, readYaml } from "../shared/fs.js";
|
|
4
4
|
export function routineActionKindLabel(action) {
|
|
5
5
|
const actions = Array.isArray(action) ? action : [action];
|
|
6
6
|
return actions.length > 0 ? actions.map((item) => item.kind).join(" -> ") : "-";
|