specdojo 0.7.0 → 0.8.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/.github/agents/specdojo-orchestrator.md +3 -2
- package/CHANGELOG.md +153 -0
- package/dist/catalog/build.js +24 -1
- package/dist/catalog/plan.js +1 -1
- package/dist/catalog/scaffold.js +4 -1
- package/dist/commands/init.js +5 -1
- package/dist/commands/night-orchestrator.js +6 -4
- package/dist/dashboard/dashboard-timeline.js +18 -16
- package/dist/dashboard/dashboard.js +612 -259
- package/dist/dashboard/epic-plan.js +81 -0
- package/dist/dashboard/exec-records.js +16 -20
- package/dist/dashboard/routines.js +8 -6
- package/dist/dashboard/timeline-build.js +5 -9
- package/dist/dashboard/timeline.js +9 -4
- package/dist/devcontainer/scaffold.js +18 -0
- package/dist/docs/frontmatter-namespace.js +1 -48
- package/dist/docs/yaml-pages.js +125 -3
- package/dist/exec/agent-config.js +22 -0
- package/dist/exec/agent-plan.js +3 -2
- package/dist/exec/commands.js +69 -21
- package/dist/exec/commit-hook-skips.js +78 -0
- package/dist/exec/core.js +19 -7
- package/dist/exec/events.js +159 -8
- package/dist/exec/evidence.js +64 -16
- package/dist/exec/handoff.js +9 -13
- package/dist/exec/limit.js +1 -1
- package/dist/exec/mechanical-result.js +45 -0
- package/dist/exec/migrate-records.js +249 -0
- package/dist/exec/parent-validation.js +153 -12
- package/dist/exec/pipeline-state.js +27 -5
- package/dist/exec/plans-condense-findings.js +89 -0
- package/dist/exec/plans-core.js +24 -17
- package/dist/exec/plans-generation.js +48 -25
- package/dist/exec/plans-grade-findings.js +8 -3
- package/dist/exec/plans-kata-findings.js +61 -0
- package/dist/exec/plans-planning.js +3 -3
- package/dist/exec/plans-storage.js +12 -24
- package/dist/exec/register-resume.js +55 -56
- package/dist/exec/register.js +26 -22
- package/dist/exec/repo-integration-sync.js +8 -4
- package/dist/exec/repo-integration.js +21 -1
- package/dist/exec/reporter.js +121 -23
- package/dist/exec/results.js +85 -24
- package/dist/exec/review-completion.js +47 -0
- package/dist/exec/review-kata.js +109 -0
- package/dist/exec/run/agent-pipeline.js +75 -6
- package/dist/exec/run/agent.js +20 -7
- package/dist/exec/run/in-place.js +69 -32
- package/dist/exec/run/job.js +81 -24
- package/dist/exec/run/lifecycle-commands.js +188 -36
- package/dist/exec/run/mode-shared.js +11 -3
- package/dist/exec/run/register-command.js +6 -10
- package/dist/exec/run/register-core.js +20 -13
- package/dist/exec/run/register-mode.js +12 -12
- package/dist/exec/run/register-post-review.js +21 -9
- package/dist/exec/run/register-resume.js +28 -18
- package/dist/exec/run/register-state.js +10 -7
- package/dist/exec/run/register-worktree.js +60 -30
- package/dist/exec/run/schedule-mode.js +4 -4
- package/dist/exec/run/schedule-prepare.js +201 -59
- package/dist/exec/run/schedule-task.js +129 -25
- package/dist/exec/run/shared.js +4 -3
- package/dist/exec/run/trailing-records.js +35 -0
- package/dist/exec/run-records.js +2 -0
- package/dist/exec/strategy.js +1 -0
- package/dist/exec/trailing-records.js +242 -0
- package/dist/exec/trial-commands.js +3 -2
- package/dist/exec/validate-records-commit.js +110 -0
- package/dist/exec/validate-records.js +148 -0
- package/dist/exec/worktree-command.js +29 -16
- package/dist/exec/worktree-ops-commit.js +119 -48
- package/dist/exec/worktree-ops-lifecycle.js +77 -48
- package/dist/exec/worktree-ops-merge.js +13 -2
- package/dist/exec/worktree-ops.js +2 -2
- package/dist/exec/worktree.js +19 -2
- package/dist/grade/apply.js +32 -6
- package/dist/grade/command-inspect.js +2 -2
- package/dist/grade/command-run.js +2 -0
- package/dist/grade/command-shared.js +1 -1
- package/dist/grade/core.js +18 -5
- package/dist/grade/markdown.js +3 -3
- package/dist/grade/pipeline-state.js +15 -11
- package/dist/grade/plan.js +37 -17
- package/dist/grade/result.js +3 -3
- package/dist/grade/run.js +23 -3
- package/dist/grade/target-discovery.js +17 -4
- package/dist/grade/targets.js +12 -11
- package/dist/job/job.js +31 -17
- package/dist/job/noop.js +104 -0
- package/dist/register/core.js +2 -0
- package/dist/register/create-commands.js +28 -3
- package/dist/register/deliverable-target.js +9 -1
- package/dist/register/epic.js +104 -26
- package/dist/register/event-merge.js +3 -0
- package/dist/register/events.js +4 -0
- package/dist/register/external-project.js +3 -0
- package/dist/register/item.js +6 -0
- package/dist/register/maintenance-commands.js +4 -1
- package/dist/register/planning.js +7 -14
- package/dist/register/register.js +43 -9
- package/dist/register/track-domains.js +34 -0
- package/dist/register/track-plan.js +78 -0
- package/dist/register/transition-commands.js +8 -0
- package/dist/register/work-table.js +64 -0
- package/dist/review/grade.js +35 -13
- package/dist/routine/definition.js +4 -3
- package/dist/routine/failure.js +30 -0
- package/dist/routine/routine.js +56 -32
- package/dist/routine/storage.js +33 -0
- package/dist/schedule/schedule.js +1 -0
- package/dist/schedule/strategy-generate-document.js +26 -14
- package/dist/schedule/strategy-generate-scope.js +17 -45
- package/dist/schedule/strategy-generate.js +33 -3
- package/dist/schedule/strategy-profiles.js +86 -12
- package/dist/shared/agent-types.js +2 -0
- package/dist/shared/condense-records.js +25 -0
- package/dist/shared/deprecation.js +8 -0
- package/dist/shared/document-metadata.js +20 -0
- package/dist/shared/finding-cause.js +20 -0
- package/dist/shared/frontmatter-namespace.js +48 -0
- package/dist/shared/git.js +142 -15
- package/dist/shared/grade-result.js +17 -1
- package/dist/shared/local-state.js +20 -0
- package/dist/shared/markdownlint-config.js +8 -3
- package/dist/shared/plan-conventions.js +129 -0
- package/dist/shared/plan-templates.js +57 -41
- package/dist/shared/run-records.js +224 -0
- package/dist/shared/specdojo-config.js +39 -21
- package/dist/shared/text.js +65 -5
- package/dist/shared/timeline-index.js +2 -0
- package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +9 -2
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +4 -74
- package/docs/ja/specdojo/exec-templates/xep-condense-template.md +50 -0
- package/docs/ja/specdojo/exec-templates/xep-draft-template.md +17 -5
- package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +16 -3
- package/docs/ja/specdojo/exec-templates/xep-recipe-guided-template.md +15 -5
- package/docs/ja/specdojo/exec-templates/xep-recipe-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -1
- package/docs/ja/specdojo/exec-templates/xep-rulebook-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xep-sample-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xep-template-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xer-condense-template.md +25 -0
- package/docs/ja/specdojo/exec-templates/xp-common-conventions-template.md +50 -0
- package/docs/ja/specdojo/exec-templates/xrp-common-conventions-template.md +30 -0
- package/docs/ja/specdojo/guides/branch-workflow-guide.md +1 -1
- package/docs/ja/specdojo/guides/docs-editing-guide.md +12 -0
- package/docs/ja/specdojo/guides/docs-structure-guide.md +48 -15
- package/docs/ja/specdojo/guides/exec-config-guide.md +47 -16
- package/docs/ja/specdojo/guides/exec-operation-guide.md +53 -17
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +20 -11
- package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +92 -55
- package/docs/ja/specdojo/guides/project-move-guide.md +381 -0
- package/docs/ja/specdojo/guides/quick-start-guide.md +70 -14
- package/docs/ja/specdojo/guides/register-operation-guide.md +25 -5
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +2 -0
- package/docs/ja/specdojo/guides/review-guide.md +22 -19
- package/docs/ja/specdojo/guides/routine-operation-guide.md +14 -8
- package/docs/ja/specdojo/guides/ryu-guide.md +23 -13
- package/docs/ja/specdojo/guides/schedule-design-guide.md +7 -4
- package/docs/ja/specdojo/guides/schedule-operation-guide.md +27 -3
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +5 -4
- package/docs/ja/specdojo/guides/timeline-design-guide.md +27 -144
- package/docs/ja/specdojo/guides/use-case-guide.md +92 -155
- package/docs/ja/specdojo/recipes/bac-recipe.md +94 -0
- package/docs/ja/specdojo/recipes/bes-recipe.md +105 -0
- package/docs/ja/specdojo/recipes/br-recipe.md +84 -0
- package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +36 -24
- package/docs/ja/specdojo/recipes/cnd-recipe.md +125 -0
- package/docs/ja/specdojo/recipes/cpd-recipe.md +126 -0
- package/docs/ja/specdojo/recipes/cxd-recipe.md +145 -0
- package/docs/ja/specdojo/recipes/ifd-recipe.md +134 -0
- package/docs/ja/specdojo/recipes/ifx-cmd-recipe.md +135 -86
- package/docs/ja/specdojo/recipes/ifx-index-recipe.md +130 -0
- package/docs/ja/specdojo/recipes/pm-organization-recipe.md +29 -26
- package/docs/ja/specdojo/recipes/pm-plan-recipe.md +35 -26
- package/docs/ja/specdojo/recipes/pm-quality-management-plan-recipe.md +38 -28
- package/docs/ja/specdojo/recipes/pm-raci-recipe.md +39 -31
- package/docs/ja/specdojo/recipes/pm-roles-recipe.md +26 -28
- package/docs/ja/specdojo/recipes/prj-assumptions-constraints-dependencies-recipe.md +10 -8
- package/docs/ja/specdojo/recipes/prj-comparison-of-alternatives-recipe.md +18 -17
- package/docs/ja/specdojo/recipes/stsd-recipe.md +100 -62
- package/docs/ja/specdojo/recipes/sysd-critical-flows-recipe.md +106 -0
- package/docs/ja/specdojo/recipes/sysd-cross-cutting-policy-recipe.md +137 -0
- package/docs/ja/specdojo/recipes/sysd-index-recipe.md +122 -0
- package/docs/ja/specdojo/references/command-reference.md +79 -64
- package/docs/ja/specdojo/references/deliverables-reference.md +9 -4
- package/docs/ja/specdojo/references/directory-layout-reference.md +3 -2
- package/docs/ja/specdojo/references/specdojo-config-reference.md +17 -16
- package/docs/ja/specdojo/rulebooks/bac-rulebook.md +72 -290
- package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +212 -79
- package/docs/ja/specdojo/rulebooks/bds-rulebook.md +138 -154
- package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +147 -59
- package/docs/ja/specdojo/rulebooks/bes-rulebook.md +100 -96
- package/docs/ja/specdojo/rulebooks/br-rulebook.md +88 -108
- package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +126 -211
- package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +56 -35
- package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +102 -68
- package/docs/ja/specdojo/rulebooks/cdt-rulebook.md +152 -0
- package/docs/ja/specdojo/rulebooks/cld-rulebook.md +9 -184
- package/docs/ja/specdojo/rulebooks/clis-rulebook.md +187 -0
- package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +93 -247
- package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +104 -241
- package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +124 -257
- package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +87 -98
- package/docs/ja/specdojo/rulebooks/dct-rulebook.md +9 -7
- package/docs/ja/specdojo/rulebooks/dec-rulebook.md +2 -1
- package/docs/ja/specdojo/rulebooks/dss-rulebook.md +193 -0
- package/docs/ja/specdojo/rulebooks/gl-rulebook.md +100 -54
- package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +69 -252
- package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +91 -76
- package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +252 -226
- package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +118 -40
- package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +11 -11
- package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +9 -9
- package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +4 -4
- package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +11 -11
- package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +11 -11
- package/docs/ja/specdojo/rulebooks/mm-rulebook.md +4 -3
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +34 -29
- package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +8 -8
- package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +2 -2
- package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +50 -56
- package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +46 -55
- package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +57 -54
- package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +50 -65
- package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +2 -2
- package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +70 -97
- package/docs/ja/specdojo/rulebooks/pr-rulebook.md +2 -1
- package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +47 -56
- package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +61 -135
- package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +116 -32
- package/docs/ja/specdojo/rulebooks/sf-rulebook.md +118 -61
- package/docs/ja/specdojo/rulebooks/sld-rulebook.md +152 -57
- package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +51 -39
- package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +101 -46
- package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +72 -329
- package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +74 -263
- package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +78 -195
- package/docs/ja/specdojo/rulebooks/tml-rulebook.md +4 -9
- package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +3 -4
- package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +3 -3
- package/docs/ja/specdojo/rulebooks/uis-rulebook.md +140 -143
- package/docs/ja/specdojo/samples/bac-sample.md +106 -21
- package/docs/ja/specdojo/samples/bdd-sample.yaml +143 -35
- package/docs/ja/specdojo/samples/bds-sample.md +100 -21
- package/docs/ja/specdojo/samples/bes-index-sample.md +59 -20
- package/docs/ja/specdojo/samples/bes-sample.md +80 -21
- package/docs/ja/specdojo/samples/br-sample.md +68 -14
- package/docs/ja/specdojo/samples/ccd-sample.md +81 -19
- package/docs/ja/specdojo/samples/cdfd-sample.md +172 -99
- package/docs/ja/specdojo/samples/cdfd-uc-sample.md +9 -7
- package/docs/ja/specdojo/samples/cdsd-sample.md +89 -20
- package/docs/ja/specdojo/samples/cdt-sample.md +116 -0
- package/docs/ja/specdojo/samples/cld-sample.md +3 -30
- package/docs/ja/specdojo/samples/clis-sample.md +132 -0
- package/docs/ja/specdojo/samples/cnd-sample.md +127 -21
- package/docs/ja/specdojo/samples/cpd-sample.md +136 -22
- package/docs/ja/specdojo/samples/cxd-sample.md +108 -22
- package/docs/ja/specdojo/samples/dct-index-sample.yaml +63 -17
- package/docs/ja/specdojo/samples/dss-sample.md +175 -0
- package/docs/ja/specdojo/samples/gl-sample.yaml +50 -14
- package/docs/ja/specdojo/samples/ifd-sample.md +105 -21
- package/docs/ja/specdojo/samples/ifx-cmd-sample.yaml +91 -60
- package/docs/ja/specdojo/samples/ifx-file-sample.md +462 -21
- package/docs/ja/specdojo/samples/ifx-index-sample.yaml +87 -19
- package/docs/ja/specdojo/samples/pm-members-sample.yaml +37 -13
- package/docs/ja/specdojo/samples/pm-organization-sample.md +52 -20
- package/docs/ja/specdojo/samples/pm-plan-sample.md +84 -26
- package/docs/ja/specdojo/samples/pm-quality-management-plan-sample.md +55 -22
- package/docs/ja/specdojo/samples/pm-raci-sample.md +69 -28
- package/docs/ja/specdojo/samples/pm-roles-sample.yaml +13 -12
- package/docs/ja/specdojo/samples/prj-assumptions-constraints-dependencies-sample.md +50 -26
- package/docs/ja/specdojo/samples/prj-comparison-of-alternatives-sample.md +89 -62
- package/docs/ja/specdojo/samples/sf-index-sample.md +89 -20
- package/docs/ja/specdojo/samples/sf-sample.md +121 -21
- package/docs/ja/specdojo/samples/sld-sample.md +107 -21
- package/docs/ja/specdojo/samples/stsd-sample.md +54 -26
- package/docs/ja/specdojo/samples/sysd-critical-flows-sample.md +166 -21
- package/docs/ja/specdojo/samples/sysd-cross-cutting-policy-sample.md +178 -21
- package/docs/ja/specdojo/samples/sysd-index-sample.md +82 -21
- package/docs/ja/specdojo/samples/tml-sample.yaml +4 -1
- package/docs/ja/specdojo/samples/uis-sample.md +164 -20
- package/docs/ja/specdojo/standards/document-metadata-standard.md +33 -4
- package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +3 -1
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +1 -0
- package/docs/ja/specdojo/templates/bac-template.md +76 -0
- package/docs/ja/specdojo/templates/bes-template.md +56 -0
- package/docs/ja/specdojo/templates/br-template.md +64 -0
- package/docs/ja/specdojo/templates/cdfd-template.md +81 -54
- package/docs/ja/specdojo/templates/cdfd-uc-template.md +9 -5
- package/docs/ja/specdojo/templates/cnd-template.md +137 -0
- package/docs/ja/specdojo/templates/cpd-template.md +129 -0
- package/docs/ja/specdojo/templates/cxd-template.md +105 -0
- package/docs/ja/specdojo/templates/dct-data-model-cdt-template.yaml +40 -0
- package/docs/ja/specdojo/templates/dct-data-model-cld-template.yaml +7 -14
- package/docs/ja/specdojo/templates/dct-index-template.md +9 -20
- package/docs/ja/specdojo/templates/dct-project-management-template.yaml +5 -1
- package/docs/ja/specdojo/templates/ifd-template.md +86 -0
- package/docs/ja/specdojo/templates/ifx-cmd-template.yaml +44 -28
- package/docs/ja/specdojo/templates/ifx-index-template.yaml +40 -0
- package/docs/ja/specdojo/templates/opr-template.md +2 -4
- package/docs/ja/specdojo/templates/pm-organization-template.md +9 -3
- package/docs/ja/specdojo/templates/pm-plan-template.md +4 -4
- package/docs/ja/specdojo/templates/pm-quality-management-plan-template.md +17 -9
- package/docs/ja/specdojo/templates/pm-raci-template.md +24 -13
- package/docs/ja/specdojo/templates/pm-roles-template.yaml +3 -2
- package/docs/ja/specdojo/templates/prj-assumptions-constraints-dependencies-template.md +6 -3
- package/docs/ja/specdojo/templates/prj-comparison-of-alternatives-template.md +22 -19
- package/docs/ja/specdojo/templates/stsd-template.md +46 -21
- package/docs/ja/specdojo/templates/sysd-critical-flows-template.md +94 -0
- package/docs/ja/specdojo/templates/sysd-cross-cutting-policy-template.md +122 -0
- package/docs/ja/specdojo/templates/sysd-index-template.md +89 -0
- package/docs/specdojo/lib/yaml-metadata.cjs +7 -0
- package/docs/specdojo/schemas/v1/bdd.schema.yaml +25 -57
- package/docs/specdojo/schemas/v1/condense-records.schema.yaml +26 -0
- package/docs/specdojo/schemas/v1/dct.schema.yaml +10 -0
- package/docs/specdojo/schemas/v1/deliverable-frontmatter.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/esil.schema.yaml +7 -141
- package/docs/specdojo/schemas/v1/exec-common.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +53 -3
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +14 -0
- package/docs/specdojo/schemas/v1/exec-result-frontmatter.schema.yaml +18 -0
- package/docs/specdojo/schemas/v1/finding-cause.schema.yaml +22 -0
- package/docs/specdojo/schemas/v1/grade-pipeline-state.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/grade-result.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/ifx-cmd.schema.yaml +65 -5
- package/docs/specdojo/schemas/v1/ifx-index.schema.yaml +142 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +17 -1
- package/package.json +2 -2
- package/templates/antigravity/orchestrator.md +3 -2
- package/templates/claude/agents/specdojo-orchestrator.md +3 -2
- package/templates/codex/agents/specdojo-orchestrator.toml +3 -2
- package/templates/codex/orchestrator.md +3 -2
- package/templates/devcontainer/tmux.conf +6 -0
- package/templates/opencode/agents/specdojo-orchestrator.md +3 -2
package/dist/register/epic.js
CHANGED
|
@@ -1,42 +1,120 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { getProjectRegisterPath, loadConfig, specdojoRootDir } from "../shared/specdojo-config.js";
|
|
4
|
+
import { loadRegisterItemDocs, readSpecdojoFields } from "./item.js";
|
|
5
|
+
export function validateRegisterStartOn(itemType, value, allowRemove = false) {
|
|
6
|
+
if (value === undefined)
|
|
7
|
+
return;
|
|
8
|
+
if (itemType !== "epic")
|
|
9
|
+
throw new Error("--start-on / start_on is only valid for epic items");
|
|
10
|
+
if (allowRemove && value === "-")
|
|
11
|
+
return;
|
|
12
|
+
const date = typeof value === "string" ? new Date(`${value}T00:00:00Z`) : undefined;
|
|
13
|
+
if (typeof value !== "string" ||
|
|
14
|
+
!/^\d{4}-\d{2}-\d{2}$/.test(value) ||
|
|
15
|
+
!date ||
|
|
16
|
+
Number.isNaN(date.getTime()) ||
|
|
17
|
+
date.toISOString().slice(0, 10) !== value) {
|
|
18
|
+
throw new Error(`Invalid start_on: "${String(value)}". Must be a valid calendar date (YYYY-MM-DD)`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function hasReversedEpicDates(item) {
|
|
22
|
+
return (item.startOn !== undefined && /^\d{4}-\d{2}-\d{2}$/.test(item.due) && item.startOn > item.due);
|
|
23
|
+
}
|
|
24
|
+
export function registerEpicDateWarnings(paths) {
|
|
25
|
+
return loadRegisterItemDocs(paths.projectRegisterPath)
|
|
26
|
+
.filter(({ item }) => item.type === "epic" && hasReversedEpicDates(item))
|
|
27
|
+
.map(({ item }) => `${item.id}: start_on (${item.startOn}) is after due_on (${item.due}); period is unknown`);
|
|
28
|
+
}
|
|
29
|
+
export function validateRegisterDomains(itemType, domains) {
|
|
30
|
+
if (domains === undefined)
|
|
31
|
+
return;
|
|
32
|
+
if (itemType !== "epic")
|
|
33
|
+
throw new Error("--domain / domains is only valid for epic items");
|
|
34
|
+
if (!Array.isArray(domains) ||
|
|
35
|
+
domains.some((v) => typeof v !== "string" || !v.trim() || v === "-")) {
|
|
36
|
+
throw new Error("domains must be an array of non-empty strings");
|
|
37
|
+
}
|
|
38
|
+
if (new Set(domains).size !== domains.length)
|
|
39
|
+
throw new Error("Duplicate epic domains");
|
|
40
|
+
}
|
|
41
|
+
function validateTrack(itemType, track) {
|
|
8
42
|
if (itemType !== "epic") {
|
|
9
43
|
if (track !== undefined)
|
|
10
44
|
throw new Error("--track is only valid for epic items");
|
|
11
|
-
return;
|
|
12
45
|
}
|
|
13
|
-
if (!track || !/^[a-z0-9][a-z0-9-]*$/.test(track)) {
|
|
46
|
+
else if (!track || !/^[a-z0-9][a-z0-9-]*$/.test(track)) {
|
|
14
47
|
throw new Error("An epic requires --track with a lowercase track identifier");
|
|
15
48
|
}
|
|
49
|
+
}
|
|
50
|
+
export function validateRegisterTrack(projectId, itemType, track, excludingId) {
|
|
51
|
+
validateTrack(itemType, track);
|
|
52
|
+
if (itemType !== "epic")
|
|
53
|
+
return;
|
|
16
54
|
const { config } = loadConfig();
|
|
17
55
|
const project = config?.projects[projectId];
|
|
18
56
|
if (!project)
|
|
19
57
|
throw new Error(`Cannot validate epic track: unknown project ${projectId}`);
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
58
|
+
const path = getProjectRegisterPath(project);
|
|
59
|
+
if (!path)
|
|
22
60
|
return;
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
throw new Error(
|
|
26
|
-
|
|
27
|
-
|
|
61
|
+
const duplicate = loadRegisterItemDocs(resolve(specdojoRootDir(), path)).find((doc) => doc.id !== excludingId && doc.item.type === "epic" && doc.item.track === track);
|
|
62
|
+
if (duplicate)
|
|
63
|
+
throw new Error(`Duplicate epic track "${track}": ${duplicate.id}`);
|
|
64
|
+
}
|
|
65
|
+
// Only local epic edges determine the overall plan. Qualified references to this project
|
|
66
|
+
// are equivalent to local IDs; dependencies on other items remain execution constraints.
|
|
67
|
+
export function epicPredecessors(item, projectId, epics) {
|
|
68
|
+
return (item.dependsOn ?? []).flatMap((ref) => {
|
|
69
|
+
const id = ref.startsWith(`${projectId}:`) ? ref.slice(projectId.length + 1) : ref;
|
|
70
|
+
const predecessor = epics.get(id);
|
|
71
|
+
return predecessor ? [predecessor] : [];
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function orderEpics(items, projectId) {
|
|
75
|
+
const epics = new Map(items.filter((item) => item.type === "epic").map((item) => [item.id, item]));
|
|
76
|
+
const ordered = [];
|
|
77
|
+
const visited = new Set();
|
|
78
|
+
const visiting = new Set();
|
|
79
|
+
const tracks = new Set();
|
|
80
|
+
for (const item of epics.values()) {
|
|
81
|
+
validateTrack(item.type, item.track);
|
|
82
|
+
validateRegisterDomains(item.type, item.domains);
|
|
83
|
+
if (tracks.has(item.track))
|
|
84
|
+
throw new Error(`Duplicate epic track "${item.track}"`);
|
|
85
|
+
tracks.add(item.track);
|
|
28
86
|
}
|
|
87
|
+
const visit = (item) => {
|
|
88
|
+
if (visiting.has(item.id))
|
|
89
|
+
throw new Error(`Epic depends_on cycle: ${[...visiting, item.id].join(" -> ")}`);
|
|
90
|
+
if (visited.has(item.id))
|
|
91
|
+
return;
|
|
92
|
+
visiting.add(item.id);
|
|
93
|
+
for (const predecessor of epicPredecessors(item, projectId, epics))
|
|
94
|
+
visit(predecessor);
|
|
95
|
+
visiting.delete(item.id);
|
|
96
|
+
visited.add(item.id);
|
|
97
|
+
ordered.push(item);
|
|
98
|
+
};
|
|
99
|
+
for (const item of [...epics.values()].sort((a, b) => a.id.localeCompare(b.id)))
|
|
100
|
+
visit(item);
|
|
101
|
+
return ordered;
|
|
29
102
|
}
|
|
30
103
|
export function validateRegisterEpicDocs(paths) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
104
|
+
const docs = loadRegisterItemDocs(paths.projectRegisterPath);
|
|
105
|
+
try {
|
|
106
|
+
for (const doc of docs) {
|
|
107
|
+
const fields = readSpecdojoFields(readFileSync(doc.path, "utf8"));
|
|
108
|
+
validateRegisterStartOn(doc.item.type, fields.start_on);
|
|
109
|
+
validateTrack(doc.item.type, doc.item.track);
|
|
110
|
+
validateRegisterDomains(doc.item.type, fields.domains);
|
|
35
111
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
112
|
+
orderEpics(docs.map((doc) => doc.item), paths.projectId);
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
return [
|
|
117
|
+
`${paths.projectRegisterPath}: ${error instanceof Error ? error.message : String(error)}`,
|
|
118
|
+
];
|
|
119
|
+
}
|
|
42
120
|
}
|
|
@@ -127,6 +127,8 @@ function fieldUpdateFromChange(change) {
|
|
|
127
127
|
return isUnset ? undefined : { item_type: value };
|
|
128
128
|
case "track":
|
|
129
129
|
return { track: isUnset ? REMOVE_REGISTER_ITEM_FIELD : value };
|
|
130
|
+
case "start_on":
|
|
131
|
+
return { start_on: isUnset ? REMOVE_REGISTER_ITEM_FIELD : value };
|
|
130
132
|
case "priority":
|
|
131
133
|
return isUnset ? undefined : { priority: value };
|
|
132
134
|
case "difficulty":
|
|
@@ -160,6 +162,7 @@ function fieldUpdateFromChange(change) {
|
|
|
160
162
|
return undefined;
|
|
161
163
|
}
|
|
162
164
|
}
|
|
165
|
+
case "domains":
|
|
163
166
|
case "depends_on":
|
|
164
167
|
case "derived_from": {
|
|
165
168
|
if (isUnset)
|
package/dist/register/events.js
CHANGED
|
@@ -15,10 +15,12 @@ export const REGISTER_EVENT_FIELDS = [
|
|
|
15
15
|
"input",
|
|
16
16
|
"type",
|
|
17
17
|
"track",
|
|
18
|
+
"domains",
|
|
18
19
|
"priority",
|
|
19
20
|
"difficulty",
|
|
20
21
|
"owner",
|
|
21
22
|
"registered",
|
|
23
|
+
"start_on",
|
|
22
24
|
"due",
|
|
23
25
|
"completed",
|
|
24
26
|
"conclusion",
|
|
@@ -76,10 +78,12 @@ export function registerEventFieldValues(content, filename, timeZone) {
|
|
|
76
78
|
input: item.inputs?.length ? JSON.stringify(item.inputs) : CELL_NONE,
|
|
77
79
|
type: item.type,
|
|
78
80
|
track: item.track ?? CELL_NONE,
|
|
81
|
+
domains: item.domains ? JSON.stringify(item.domains) : CELL_NONE,
|
|
79
82
|
priority: item.priority,
|
|
80
83
|
difficulty: item.difficulty ?? CELL_NONE,
|
|
81
84
|
owner: item.owner,
|
|
82
85
|
registered: item.registered,
|
|
86
|
+
start_on: item.startOn ?? CELL_NONE,
|
|
83
87
|
due: item.due,
|
|
84
88
|
completed: item.completed,
|
|
85
89
|
conclusion: item.conclusion,
|
|
@@ -41,8 +41,11 @@ export function buildExternalRegisterAddArgs(alias, externalProject, opts) {
|
|
|
41
41
|
opts.conclusion,
|
|
42
42
|
];
|
|
43
43
|
addValue(args, "--track", opts.track);
|
|
44
|
+
for (const domain of opts.domain ?? [])
|
|
45
|
+
addValue(args, "--domain", domain);
|
|
44
46
|
addValue(args, "--difficulty", opts.difficulty);
|
|
45
47
|
addValue(args, "--registered", opts.registered);
|
|
48
|
+
addValue(args, "--start-on", opts.startOn);
|
|
46
49
|
addValue(args, "--approach", opts.approach);
|
|
47
50
|
for (const input of opts.input ?? [])
|
|
48
51
|
addValue(args, "--input", input);
|
package/dist/register/item.js
CHANGED
|
@@ -71,11 +71,13 @@ const SPECDOJO_KEY_ORDER = [
|
|
|
71
71
|
"based_on",
|
|
72
72
|
"item_type",
|
|
73
73
|
"track",
|
|
74
|
+
"domains",
|
|
74
75
|
"item_status",
|
|
75
76
|
"priority",
|
|
76
77
|
"difficulty",
|
|
77
78
|
"owner",
|
|
78
79
|
"registered_at",
|
|
80
|
+
"start_on",
|
|
79
81
|
"due_on",
|
|
80
82
|
"completed_at",
|
|
81
83
|
"block_reason",
|
|
@@ -261,10 +263,12 @@ export function readRegisterItemContent(content, filename) {
|
|
|
261
263
|
...(inputs ? { inputs } : {}),
|
|
262
264
|
type: asString(fields.item_type) ?? CELL_TODO,
|
|
263
265
|
...(asString(fields.track) ? { track: asString(fields.track) } : {}),
|
|
266
|
+
...(Array.isArray(fields.domains) ? { domains: fields.domains } : {}),
|
|
264
267
|
priority: asString(fields.priority) ?? "medium",
|
|
265
268
|
...(difficulty ? { difficulty } : {}),
|
|
266
269
|
owner: asString(fields.owner) ?? CELL_TODO,
|
|
267
270
|
registeredAt: asString(fields.registered_at) ?? CELL_TODO,
|
|
271
|
+
...(asString(fields.start_on) ? { startOn: asString(fields.start_on) } : {}),
|
|
268
272
|
due: fields.due_on === null
|
|
269
273
|
? CELL_NONE
|
|
270
274
|
: (asString(fields.due_on) ??
|
|
@@ -405,6 +409,8 @@ export function registerItemFieldsFromItem(item) {
|
|
|
405
409
|
? null
|
|
406
410
|
: inlineCodeAnglePlaceholders(item.conclusion.trim()),
|
|
407
411
|
...(item.track ? { track: item.track } : {}),
|
|
412
|
+
...(item.startOn !== undefined ? { start_on: item.startOn } : {}),
|
|
413
|
+
...(item.domains !== undefined ? { domains: item.domains } : {}),
|
|
408
414
|
...(item.approach ? { approach: item.approach } : {}),
|
|
409
415
|
...(item.targetPath ? { target_path: item.targetPath } : {}),
|
|
410
416
|
...(item.targetRulebook ? { target_rulebook: item.targetRulebook } : {}),
|
|
@@ -5,7 +5,7 @@ import { registerEventFilePath, validateRegisterEventDocs } from "./events.js";
|
|
|
5
5
|
import { validateRegisterItemDocs } from "./item.js";
|
|
6
6
|
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
7
7
|
import { validateRegisterDependencyDocs } from "./dependency.js";
|
|
8
|
-
import { validateRegisterEpicDocs } from "./epic.js";
|
|
8
|
+
import { registerEpicDateWarnings, validateRegisterEpicDocs } from "./epic.js";
|
|
9
9
|
import { validateDerivedFromDocs } from "./derivation.js";
|
|
10
10
|
export function registerMaintenanceCommands(reg, dependencies) {
|
|
11
11
|
const { addProjectOption, addRegisterCommitOptions, applyRegisterMigrationPlan, generateDerivedViewFiles, loadItemForUpdate, migrateEmbeddedRegisterEvents, migrateRegisterEventsFromGit, parseHistoryIds, planRegisterMigration, planRenumber, printCommandError, registerEventActor, renumberPjrItem, repoRelativePathspec, resolveRegisterPaths, runRegisterMutation, validBuildScopes, writeDerivedViews, } = dependencies;
|
|
@@ -102,6 +102,9 @@ export function registerMaintenanceCommands(reg, dependencies) {
|
|
|
102
102
|
...eventErrors,
|
|
103
103
|
].join("\n")}`);
|
|
104
104
|
}
|
|
105
|
+
for (const warning of registerEpicDateWarnings(paths)) {
|
|
106
|
+
process.stderr.write(`Warning: ${warning}\n`);
|
|
107
|
+
}
|
|
105
108
|
const views = generateDerivedViewFiles(paths, scope);
|
|
106
109
|
if (opts.dryRun) {
|
|
107
110
|
for (const view of views) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getProjectCatalogPath,
|
|
4
|
-
import { loadTimelineIndex } from "../shared/timeline-index.js";
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { loadRegisterItemDocs } from "./item.js";
|
|
3
|
+
import { getProjectCatalogPath, getProjectRegisterPath, } from "../shared/specdojo-config.js";
|
|
5
4
|
export function isPlanningApproach(approach) {
|
|
6
5
|
return approach === "catalog-planning" || approach === "strategy-planning";
|
|
7
6
|
}
|
|
@@ -23,15 +22,9 @@ export function validatePlanningTarget(opts) {
|
|
|
23
22
|
if (!opts.project.schedule_path?.trim()) {
|
|
24
23
|
throw new Error('Approach "strategy-planning" requires schedule_path');
|
|
25
24
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
const { index, errors } = loadTimelineIndex(file);
|
|
32
|
-
if (errors.length > 0)
|
|
33
|
-
throw new Error(`${file}: ${errors.join("; ")}`);
|
|
34
|
-
if (!index.tracks.some((track) => track.track === unit)) {
|
|
35
|
-
throw new Error(`Undefined strategy track "${unit}" in ${join(getProjectTimelinePath(opts.project), "tml-index.yaml")}`);
|
|
25
|
+
const path = getProjectRegisterPath(opts.project);
|
|
26
|
+
const epics = path ? loadRegisterItemDocs(resolve(opts.repoRoot, path)) : [];
|
|
27
|
+
if (!epics.some((doc) => doc.item.type === "epic" && doc.item.track === unit)) {
|
|
28
|
+
throw new Error(`Undefined strategy track "${unit}": create an epic governing this track first`);
|
|
36
29
|
}
|
|
37
30
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { relative, sep } from "node:path";
|
|
3
|
+
import { setImmediate } from "node:timers/promises";
|
|
3
4
|
import { CrossProcessMutex } from "../shared/cross-process-lock.js";
|
|
4
5
|
import { gitOutput, gitResult, repoRelative, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "../shared/git.js";
|
|
5
6
|
import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
@@ -59,8 +60,10 @@ function addProjectOption(cmd) {
|
|
|
59
60
|
return cmd.option("--project <projectId>", "Project id in specdojo.config.json");
|
|
60
61
|
}
|
|
61
62
|
function assertRegisterItemCommitTargetsClean(context, view) {
|
|
62
|
-
if (!view.ticketPath)
|
|
63
|
+
if (!view.ticketPath) {
|
|
64
|
+
context.assertCommitTargetsClean([context.paths.pjrIndexPath]);
|
|
63
65
|
return;
|
|
66
|
+
}
|
|
64
67
|
context.assertCommitTargetsClean([
|
|
65
68
|
view.ticketPath,
|
|
66
69
|
registerEventFilePath(context.paths.projectRegisterPath, view.id),
|
|
@@ -103,14 +106,33 @@ function isGeneratedRegisterPath(repoRoot, paths, path) {
|
|
|
103
106
|
return (normalized === ".specdojo/doc-index.json" ||
|
|
104
107
|
generatedPrefixes.some((prefix) => normalized.startsWith(prefix)));
|
|
105
108
|
}
|
|
106
|
-
function commitRegisterMutation(repoRoot, paths, command, result, preexisting, message) {
|
|
107
|
-
const changed = worktreeStatusPaths(repoRoot).filter((path) =>
|
|
109
|
+
async function commitRegisterMutation(repoRoot, paths, command, result, preexisting, targets, message) {
|
|
110
|
+
const changed = worktreeStatusPaths(repoRoot).filter((path) => targets.has(path) &&
|
|
111
|
+
!preexisting.has(path) &&
|
|
112
|
+
!isGeneratedRegisterPath(repoRoot, paths, path));
|
|
108
113
|
if (changed.length === 0) {
|
|
109
114
|
process.stdout.write(`No register changes to commit for ${result.id}.\n`);
|
|
110
115
|
return;
|
|
111
116
|
}
|
|
117
|
+
// spawnSync delays JS signal callbacks until Git returns. Yield before committing and after
|
|
118
|
+
// each commit so a pending interruption uses the same targeted rollback as a hook failure.
|
|
119
|
+
let interrupted;
|
|
120
|
+
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
121
|
+
const handlers = signals.map((signal) => {
|
|
122
|
+
const handler = () => {
|
|
123
|
+
interrupted = signal;
|
|
124
|
+
};
|
|
125
|
+
process.on(signal, handler);
|
|
126
|
+
return handler;
|
|
127
|
+
});
|
|
128
|
+
const checkInterruption = async () => {
|
|
129
|
+
await setImmediate();
|
|
130
|
+
if (interrupted)
|
|
131
|
+
throw new Error(`Register commit interrupted by ${interrupted}; staged changes rolled back.`);
|
|
132
|
+
};
|
|
112
133
|
try {
|
|
113
134
|
stageCommitTargets(repoRoot, changed);
|
|
135
|
+
await checkInterruption();
|
|
114
136
|
const staged = gitResult(repoRoot, ["diff", "--cached", "--quiet", "--", ...changed]);
|
|
115
137
|
if (staged.status === 0) {
|
|
116
138
|
process.stdout.write(`No register changes to commit for ${result.id}.\n`);
|
|
@@ -123,6 +145,7 @@ function commitRegisterMutation(repoRoot, paths, command, result, preexisting, m
|
|
|
123
145
|
throw new Error("Register commit message must not be empty");
|
|
124
146
|
// --only は初回・amend とも指定し、開始前からある staged 変更を混ぜない。
|
|
125
147
|
gitOutput(repoRoot, ["commit", "--only", "-m", commitMessage, "--", ...changed]);
|
|
148
|
+
await checkInterruption();
|
|
126
149
|
for (let attempt = 0; attempt < REGISTER_COMMIT_STABILIZATION_ATTEMPTS; attempt++) {
|
|
127
150
|
const remaining = worktreeStatusPaths(repoRoot).filter((path) => changed.includes(path));
|
|
128
151
|
if (remaining.length === 0) {
|
|
@@ -131,7 +154,9 @@ function commitRegisterMutation(repoRoot, paths, command, result, preexisting, m
|
|
|
131
154
|
return;
|
|
132
155
|
}
|
|
133
156
|
stageCommitTargets(repoRoot, remaining);
|
|
157
|
+
await checkInterruption();
|
|
134
158
|
gitOutput(repoRoot, ["commit", "--only", "--amend", "--no-edit", "--", ...remaining]);
|
|
159
|
+
await checkInterruption();
|
|
135
160
|
}
|
|
136
161
|
const remaining = worktreeStatusPaths(repoRoot).filter((path) => changed.includes(path));
|
|
137
162
|
if (remaining.length === 0) {
|
|
@@ -145,8 +170,12 @@ function commitRegisterMutation(repoRoot, paths, command, result, preexisting, m
|
|
|
145
170
|
catch (error) {
|
|
146
171
|
// changed は開始前に clean だった対象だけ。本文を残して、自分の stage だけを戻す。
|
|
147
172
|
unstageCommitTargets(repoRoot, changed);
|
|
173
|
+
await setImmediate();
|
|
148
174
|
throw error;
|
|
149
175
|
}
|
|
176
|
+
finally {
|
|
177
|
+
signals.forEach((signal, index) => process.removeListener(signal, handlers[index]));
|
|
178
|
+
}
|
|
150
179
|
}
|
|
151
180
|
async function runRegisterMutationInCurrentWorktree(command, opts, mutate, requireCleanRegister) {
|
|
152
181
|
const paths = resolveRegisterPaths(opts);
|
|
@@ -164,8 +193,9 @@ async function runRegisterMutationInCurrentWorktree(command, opts, mutate, requi
|
|
|
164
193
|
}, {
|
|
165
194
|
onWait: () => process.stdout.write("Waiting for the register lifecycle lock held by another operation\n"),
|
|
166
195
|
});
|
|
167
|
-
await mutex.runExclusive(() => {
|
|
196
|
+
await mutex.runExclusive(async () => {
|
|
168
197
|
const preexisting = new Set(worktreeStatusPaths(repoRoot));
|
|
198
|
+
const commitTargets = new Set();
|
|
169
199
|
if (requireCleanRegister) {
|
|
170
200
|
const registerPrefix = `${repoRelative(repoRoot, paths.projectRegisterPath)}/`;
|
|
171
201
|
const dirtyRegisterPaths = [...preexisting].filter((path) => path === registerPrefix.slice(0, -1) || path.startsWith(registerPrefix));
|
|
@@ -174,18 +204,22 @@ async function runRegisterMutationInCurrentWorktree(command, opts, mutate, requi
|
|
|
174
204
|
dirtyRegisterPaths.map((path) => ` ${path}`).join("\n"));
|
|
175
205
|
}
|
|
176
206
|
}
|
|
207
|
+
// These paths are declared by add/update/transition/rename before they write. A repository
|
|
208
|
+
// status delta also contains files created by concurrent schedule processes, so it is not
|
|
209
|
+
// an ownership boundary for this commit.
|
|
177
210
|
const assertCommitTargetsClean = (targets) => {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
211
|
+
const relativeTargets = targets.map((target) => repoRelative(repoRoot, target));
|
|
212
|
+
const overlapping = relativeTargets.filter((target) => preexisting.has(target));
|
|
213
|
+
if (overlapping.length === 0) {
|
|
214
|
+
relativeTargets.forEach((target) => commitTargets.add(target));
|
|
182
215
|
return;
|
|
216
|
+
}
|
|
183
217
|
throw new Error(`Cannot use --commit because register targets already have uncommitted changes:\n` +
|
|
184
218
|
overlapping.map((path) => ` ${path}`).join("\n"));
|
|
185
219
|
};
|
|
186
220
|
const result = mutate({ paths, assertCommitTargetsClean });
|
|
187
221
|
rebuildRegisterViews(paths);
|
|
188
|
-
commitRegisterMutation(repoRoot, paths, command, result, preexisting, opts.message);
|
|
222
|
+
await commitRegisterMutation(repoRoot, paths, command, result, preexisting, commitTargets, opts.message);
|
|
189
223
|
});
|
|
190
224
|
}
|
|
191
225
|
async function runRegisterMutation(command, opts, mutate) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { loadRegisterItemDocs } from "./item.js";
|
|
4
|
+
import { readYaml } from "../shared/fs.js";
|
|
5
|
+
import { loadTimelineIndex } from "../shared/timeline-index.js";
|
|
6
|
+
export function resolveTrackDomains(opts) {
|
|
7
|
+
const legacyPath = join(opts.timelinePath, "tml-index.yaml");
|
|
8
|
+
const legacy = existsSync(legacyPath) ? loadTimelineIndex(legacyPath) : undefined;
|
|
9
|
+
const scope = opts.existingStrategy?.scope;
|
|
10
|
+
if (Array.isArray(scope?.catalogs)) {
|
|
11
|
+
const domains = scope.catalogs.flatMap((entry) => {
|
|
12
|
+
if (!entry || typeof entry !== "object" || typeof entry.path !== "string")
|
|
13
|
+
return [];
|
|
14
|
+
const path = resolve(opts.repoRoot ?? ".", entry.path.replace(/^\//, ""));
|
|
15
|
+
const doc = existsSync(path) ? readYaml(path) : null;
|
|
16
|
+
const domain = doc?.domain ?? entry.id?.split(":dct-")[1] ?? entry.path.match(/dct-(.+)\.ya?ml$/)?.[1];
|
|
17
|
+
return domain ? [domain] : [];
|
|
18
|
+
});
|
|
19
|
+
return { domains: [...new Set(domains)], source: "strategy", errors: [] };
|
|
20
|
+
}
|
|
21
|
+
const items = opts.registerItems ??
|
|
22
|
+
(opts.registerPath ? loadRegisterItemDocs(opts.registerPath).map((doc) => doc.item) : []);
|
|
23
|
+
const epics = items.filter((item) => item.type === "epic" && item.track === opts.track);
|
|
24
|
+
if (epics.length > 1)
|
|
25
|
+
return { domains: [], source: "epic", errors: [`Duplicate epic track "${opts.track}"`] };
|
|
26
|
+
if (epics[0]?.domains !== undefined) {
|
|
27
|
+
return { domains: epics[0].domains, source: "epic", errors: [] };
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
domains: legacy?.index.tracks.find((entry) => entry.track === opts.track)?.domains ?? [],
|
|
31
|
+
source: "timeline",
|
|
32
|
+
errors: legacy?.errors ?? [],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { epicPredecessors, orderEpics } from "./epic.js";
|
|
4
|
+
import { loadRegisterItemDocs } from "./item.js";
|
|
5
|
+
import { readYaml } from "../shared/fs.js";
|
|
6
|
+
import { loadTimelineIndex } from "../shared/timeline-index.js";
|
|
7
|
+
import { resolveTrackDomains } from "./track-domains.js";
|
|
8
|
+
/** Epic order and domains supersede legacy plans; legacy-only tracks remain readable. */
|
|
9
|
+
export function loadTrackPlan(opts) {
|
|
10
|
+
const file = join(opts.timelinePath, "tml-index.yaml");
|
|
11
|
+
const loaded = existsSync(file)
|
|
12
|
+
? loadTimelineIndex(file)
|
|
13
|
+
: {
|
|
14
|
+
index: {
|
|
15
|
+
id: "",
|
|
16
|
+
project_id: opts.projectId ?? "",
|
|
17
|
+
status: "draft",
|
|
18
|
+
tracks: [],
|
|
19
|
+
},
|
|
20
|
+
errors: [],
|
|
21
|
+
};
|
|
22
|
+
const items = opts.registerPath
|
|
23
|
+
? loadRegisterItemDocs(opts.registerPath).map((doc) => doc.item)
|
|
24
|
+
: [];
|
|
25
|
+
const epics = orderEpics(items, loaded.index.project_id);
|
|
26
|
+
if (epics.length === 0 && !existsSync(file) && !opts.registerPath && !opts.schedulePath) {
|
|
27
|
+
throw new Error(`Timeline index not found: ${file}`);
|
|
28
|
+
}
|
|
29
|
+
const byId = new Map(epics.map((item) => [item.id, item]));
|
|
30
|
+
const depth = new Map();
|
|
31
|
+
for (const item of epics) {
|
|
32
|
+
const predecessors = epicPredecessors(item, loaded.index.project_id, byId);
|
|
33
|
+
const order = 1 + Math.max(0, ...predecessors.map((p) => depth.get(p.id) ?? 0));
|
|
34
|
+
depth.set(item.id, order);
|
|
35
|
+
const previous = loaded.index.tracks.find((track) => track.track === item.track);
|
|
36
|
+
const plan = {
|
|
37
|
+
...previous,
|
|
38
|
+
track: item.track,
|
|
39
|
+
domains: item.domains ?? previous?.domains ?? [],
|
|
40
|
+
catalog_status: previous?.catalog_status ?? "not_started",
|
|
41
|
+
order,
|
|
42
|
+
depends_on: predecessors.map((p) => p.track),
|
|
43
|
+
};
|
|
44
|
+
loaded.index.tracks = loaded.index.tracks.filter((track) => track.track !== item.track);
|
|
45
|
+
loaded.index.tracks.push(plan);
|
|
46
|
+
}
|
|
47
|
+
if (opts.schedulePath && existsSync(opts.schedulePath)) {
|
|
48
|
+
for (const name of readdirSync(opts.schedulePath).filter((name) => /^sch-strategy-.+\.yaml$/.test(name))) {
|
|
49
|
+
const doc = readYaml(join(opts.schedulePath, name));
|
|
50
|
+
if (doc?.track && !loaded.index.tracks.some((entry) => entry.track === doc.track)) {
|
|
51
|
+
loaded.index.tracks.push({
|
|
52
|
+
track: doc.track,
|
|
53
|
+
domains: [],
|
|
54
|
+
catalog_status: "not_started",
|
|
55
|
+
order: 1,
|
|
56
|
+
depends_on: [],
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const track of loaded.index.tracks) {
|
|
62
|
+
const strategyPath = opts.schedulePath
|
|
63
|
+
? join(opts.schedulePath, `sch-strategy-${track.track}.yaml`)
|
|
64
|
+
: undefined;
|
|
65
|
+
const existingStrategy = strategyPath && existsSync(strategyPath)
|
|
66
|
+
? readYaml(strategyPath)
|
|
67
|
+
: undefined;
|
|
68
|
+
const resolved = resolveTrackDomains({
|
|
69
|
+
...opts,
|
|
70
|
+
registerItems: items,
|
|
71
|
+
track: track.track,
|
|
72
|
+
existingStrategy,
|
|
73
|
+
});
|
|
74
|
+
track.domains = resolved.domains;
|
|
75
|
+
loaded.errors.push(...resolved.errors);
|
|
76
|
+
}
|
|
77
|
+
return loaded;
|
|
78
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
1
2
|
import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
2
3
|
import { nowUtcTimestamp } from "./date.js";
|
|
3
4
|
import { CELL_NONE } from "./item.js";
|
|
5
|
+
import { registerWorkTableIssueMessage, registerWorkTableIssues } from "./work-table.js";
|
|
4
6
|
export function registerTransitionCommands(reg, dependencies) {
|
|
5
7
|
const { addProjectOption, addRegisterCommitOptions, applyItemUpdate, assertRegisterItemCommitTargetsClean, assertTerminalOperationAllowed, loadItemForUpdate, parseRegisterTimestampOption, registerEventActor, runRegisterMutation, updateTicketStatusForItem, } = dependencies;
|
|
6
8
|
// --- close ---
|
|
@@ -20,6 +22,12 @@ export function registerTransitionCommands(reg, dependencies) {
|
|
|
20
22
|
const view = loadItemForUpdate(paths, opts.id, "require-active");
|
|
21
23
|
const item = view.item;
|
|
22
24
|
assertTerminalOperationAllowed(item, "close");
|
|
25
|
+
if (view.ticketPath) {
|
|
26
|
+
const issues = registerWorkTableIssues(readFileSync(view.ticketPath, "utf8"));
|
|
27
|
+
if (issues.length > 0) {
|
|
28
|
+
throw new Error(`Cannot close ${item.id}: ${registerWorkTableIssueMessage(item.id, issues)}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
23
31
|
assertRegisterItemCommitTargetsClean(context, view);
|
|
24
32
|
const targetStatus = opts.status ?? (["decision", "question"].includes(item.type) ? "decided" : "done");
|
|
25
33
|
if (targetStatus !== "done" && targetStatus !== "decided") {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// 個票の「作業内容」の表が実績に合っているかを検査する。close の前に、未着手のまま
|
|
2
|
+
// 理由のない行や `_TODO_` の残った行を見つけ、完了を止める理由として返す。
|
|
3
|
+
const WORK_TABLE_HEADING_RE = /^##\s+(?:\d+\.\s*)?作業内容\s*$/;
|
|
4
|
+
const PLACEHOLDER_CELLS = new Set(["", "-", "_TODO_"]);
|
|
5
|
+
const DONE_STATE = "done";
|
|
6
|
+
function splitTableRow(line) {
|
|
7
|
+
const trimmed = line.trim().replace(/^\|/, "").replace(/\|$/, "");
|
|
8
|
+
// `\|` はセル内の文字であり、列の区切りではない。
|
|
9
|
+
return trimmed.split(/(?<!\\)\|/).map((cell) => cell.trim());
|
|
10
|
+
}
|
|
11
|
+
// インラインコードの `_TODO_` は記法の説明であり、未記入の目印ではない。
|
|
12
|
+
function hasTodoMarker(cell) {
|
|
13
|
+
return cell.replace(/`[^`]*`/g, "").includes("_TODO_");
|
|
14
|
+
}
|
|
15
|
+
function isSeparatorRow(cells) {
|
|
16
|
+
return cells.length > 0 && cells.every((cell) => /^:?-{3,}:?$/.test(cell));
|
|
17
|
+
}
|
|
18
|
+
function workTableLines(content) {
|
|
19
|
+
const body = content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "");
|
|
20
|
+
const lines = body.split(/\r?\n/);
|
|
21
|
+
const heading = lines.findIndex((line) => WORK_TABLE_HEADING_RE.test(line));
|
|
22
|
+
if (heading < 0)
|
|
23
|
+
return [];
|
|
24
|
+
const section = [];
|
|
25
|
+
for (const line of lines.slice(heading + 1)) {
|
|
26
|
+
if (/^##\s+/.test(line))
|
|
27
|
+
break;
|
|
28
|
+
section.push(line);
|
|
29
|
+
}
|
|
30
|
+
const start = section.findIndex((line) => line.trim().startsWith("|"));
|
|
31
|
+
if (start < 0)
|
|
32
|
+
return [];
|
|
33
|
+
const endOffset = section.slice(start).findIndex((line) => !line.trim().startsWith("|"));
|
|
34
|
+
return section.slice(start, endOffset < 0 ? undefined : start + endOffset);
|
|
35
|
+
}
|
|
36
|
+
// 状態が done でない行は、メモに残した理由があれば通す。理由のない行と、どの列であれ
|
|
37
|
+
// `_TODO_` の目印が残る行を問題として返す。表や状態の列がない個票は検査の対象外とする。
|
|
38
|
+
export function registerWorkTableIssues(content) {
|
|
39
|
+
const [header, separator, ...rows] = workTableLines(content).map(splitTableRow);
|
|
40
|
+
if (!header || !separator || !isSeparatorRow(separator))
|
|
41
|
+
return [];
|
|
42
|
+
const stateIndex = header.indexOf("状態");
|
|
43
|
+
if (stateIndex < 0)
|
|
44
|
+
return [];
|
|
45
|
+
const noteIndex = header.indexOf("メモ");
|
|
46
|
+
const numberIndex = header.indexOf("No");
|
|
47
|
+
return rows.flatMap((cells, index) => {
|
|
48
|
+
const label = `row ${numberIndex >= 0 && cells[numberIndex] ? cells[numberIndex] : index + 1}`;
|
|
49
|
+
if (cells.some(hasTodoMarker)) {
|
|
50
|
+
return [`${label} still contains _TODO_`];
|
|
51
|
+
}
|
|
52
|
+
const state = cells[stateIndex] ?? "";
|
|
53
|
+
if (state === DONE_STATE)
|
|
54
|
+
return [];
|
|
55
|
+
const note = noteIndex >= 0 ? (cells[noteIndex] ?? "") : "";
|
|
56
|
+
if (!PLACEHOLDER_CELLS.has(note))
|
|
57
|
+
return [];
|
|
58
|
+
return [`${label} is "${state || "-"}" without a reason in メモ`];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export function registerWorkTableIssueMessage(id, issues) {
|
|
62
|
+
return (`the 作業内容 table of ${id} does not match the work done: ${issues.join("; ")}. ` +
|
|
63
|
+
`Set each row to done, or write why it remains in メモ.`);
|
|
64
|
+
}
|