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/review/grade.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
2
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
4
|
import { join } from "node:path";
|
|
4
5
|
import { gitEnvironment } from "../shared/git-environment.js";
|
|
@@ -84,6 +85,9 @@ export function reviewGradeArgs(opts) {
|
|
|
84
85
|
const args = [
|
|
85
86
|
"grade",
|
|
86
87
|
"run",
|
|
88
|
+
"--isolate-pipeline-state",
|
|
89
|
+
"--if-busy",
|
|
90
|
+
"wait",
|
|
87
91
|
"--run-id",
|
|
88
92
|
opts.runId,
|
|
89
93
|
"--project",
|
|
@@ -123,10 +127,16 @@ function lastLine(text) {
|
|
|
123
127
|
.filter(Boolean);
|
|
124
128
|
return lines.at(-1) ?? "";
|
|
125
129
|
}
|
|
130
|
+
// grade の出力の形式の誤りなど一過性の失敗に備え、review の前の grade は合計この回数まで試す
|
|
131
|
+
// (PJR-M18B)。各試行は別の run id を使い、失敗した試行の状態を引き継がない。
|
|
132
|
+
export const REVIEW_GRADE_MAX_ATTEMPTS = 3;
|
|
133
|
+
export function reviewGradeAttemptRunId(runId, attempt) {
|
|
134
|
+
return attempt <= 1 ? runId : `${runId}-a${attempt}`;
|
|
135
|
+
}
|
|
126
136
|
/**
|
|
127
137
|
* Runner-side grade before a review plan is generated. The executor never grades (PJR-2ZVS 3.6).
|
|
128
|
-
*
|
|
129
|
-
*
|
|
138
|
+
* A failed grade is retried up to maxAttempts times. Failures are reported in the outcome instead
|
|
139
|
+
* of thrown; the runner then blocks the review task instead of completing it (PJR-M18B).
|
|
130
140
|
*/
|
|
131
141
|
export async function ensureReviewGrade(opts) {
|
|
132
142
|
const freshness = reviewGradeFreshness({
|
|
@@ -135,12 +145,29 @@ export async function ensureReviewGrade(opts) {
|
|
|
135
145
|
rootDir: opts.repoRoot,
|
|
136
146
|
});
|
|
137
147
|
const decision = decideReviewGradeAction({
|
|
138
|
-
freshness
|
|
148
|
+
freshness: freshness.state === "fresh" && freshness.result.target !== opts.target
|
|
149
|
+
? { ...freshness, state: "stale" }
|
|
150
|
+
: freshness,
|
|
139
151
|
dryRun: opts.dryRun,
|
|
140
152
|
});
|
|
141
153
|
if (!decision.run)
|
|
142
154
|
return decision.outcome;
|
|
143
|
-
const
|
|
155
|
+
const subjectKey = createHash("sha256").update(opts.subjectPath).digest("hex").slice(0, 10);
|
|
156
|
+
const baseRunId = reviewGradeRunId(`${opts.taskId}-${subjectKey}`, opts.now ?? new Date());
|
|
157
|
+
const invoke = opts.invoke ?? defaultInvoke;
|
|
158
|
+
const maxAttempts = Math.max(1, Math.floor(opts.maxAttempts ?? REVIEW_GRADE_MAX_ATTEMPTS));
|
|
159
|
+
for (let attempt = 1;; attempt += 1) {
|
|
160
|
+
const runId = reviewGradeAttemptRunId(baseRunId, attempt);
|
|
161
|
+
const detail = await invokeReviewGrade(opts, runId, invoke);
|
|
162
|
+
if (detail === undefined)
|
|
163
|
+
return { action: "executed", runId };
|
|
164
|
+
if (attempt >= maxAttempts)
|
|
165
|
+
return { action: "failed", runId, detail, attempts: attempt };
|
|
166
|
+
process.stderr.write(`[grade] attempt ${attempt}/${maxAttempts} failed; retrying: ${detail}\n`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** Run one grade attempt. Returns undefined on success, or the failure detail. */
|
|
170
|
+
async function invokeReviewGrade(opts, runId, invoke) {
|
|
144
171
|
const args = reviewGradeArgs({
|
|
145
172
|
runId,
|
|
146
173
|
projectId: opts.projectId,
|
|
@@ -149,7 +176,6 @@ export async function ensureReviewGrade(opts) {
|
|
|
149
176
|
by: opts.by,
|
|
150
177
|
execDefaultsPath: opts.execDefaultsPath,
|
|
151
178
|
});
|
|
152
|
-
const invoke = opts.invoke ?? defaultInvoke;
|
|
153
179
|
try {
|
|
154
180
|
// Resolve the entrypoint from this package, never from the consumer repository.
|
|
155
181
|
const javascript = fileURLToPath(new URL("../specdojo.js", import.meta.url));
|
|
@@ -158,16 +184,12 @@ export async function ensureReviewGrade(opts) {
|
|
|
158
184
|
: ["--import", "tsx", fileURLToPath(new URL("../specdojo.ts", import.meta.url))];
|
|
159
185
|
const { exitCode, stderr } = await invoke(process.execPath, [...entryArgs, ...args], opts.repoRoot);
|
|
160
186
|
if (exitCode === 0)
|
|
161
|
-
return
|
|
187
|
+
return undefined;
|
|
162
188
|
const reason = lastLine(stderr);
|
|
163
|
-
return {
|
|
164
|
-
action: "failed",
|
|
165
|
-
runId,
|
|
166
|
-
detail: `${opts.subjectPath}: exit ${exitCode}${reason ? `: ${reason}` : ""}`,
|
|
167
|
-
};
|
|
189
|
+
return `${opts.subjectPath}: exit ${exitCode}${reason ? `: ${reason}` : ""}`;
|
|
168
190
|
}
|
|
169
191
|
catch (error) {
|
|
170
|
-
return
|
|
192
|
+
return `${opts.subjectPath}: ${errorMessage(error)}`;
|
|
171
193
|
}
|
|
172
194
|
}
|
|
173
195
|
function outcomeLine(outcome) {
|
|
@@ -179,7 +201,7 @@ function outcomeLine(outcome) {
|
|
|
179
201
|
case "executed":
|
|
180
202
|
return `- runner の grade 実行: 実行した(run id: \`${outcome.runId}\`)`;
|
|
181
203
|
case "failed":
|
|
182
|
-
return `- runner の grade 実行:
|
|
204
|
+
return `- runner の grade 実行: ${outcome.attempts} 回試して失敗した(最後の run id: \`${outcome.runId}\`; ${outcome.detail})。runner はこの review タスクを完了にせず blocked にする`;
|
|
183
205
|
case "not-run":
|
|
184
206
|
return `- runner の grade 実行: 実行していない(${outcome.detail})`;
|
|
185
207
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { basename, join, resolve } from "node:path";
|
|
2
|
-
import { getProjectRoutinesPath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
2
|
+
import { getProjectRoutinesPath, getProjectExecutionPath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
3
3
|
import { listFilesRecursive, readYaml } from "../shared/fs.js";
|
|
4
|
+
import { routineStoragePaths } from "./storage.js";
|
|
4
5
|
export function routineActionKindLabel(action) {
|
|
5
6
|
const actions = Array.isArray(action) ? action : [action];
|
|
6
7
|
return actions.length > 0 ? actions.map((item) => item.kind).join(" -> ") : "-";
|
|
@@ -359,8 +360,8 @@ export function resolveRoutinePaths(opts) {
|
|
|
359
360
|
projectId,
|
|
360
361
|
routinesPath: absRoutinesPath,
|
|
361
362
|
generatedPath,
|
|
362
|
-
|
|
363
|
-
|
|
363
|
+
...routineStoragePaths(absRoutinesPath, baseDir),
|
|
364
|
+
failuresPath: resolve(baseDir, getProjectExecutionPath(project), "routines", "failures"),
|
|
364
365
|
};
|
|
365
366
|
}
|
|
366
367
|
export function isRoutineYamlFile(filePath) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { join, relative } from "node:path";
|
|
3
|
+
import { ensureDir, writeJson } from "../shared/fs.js";
|
|
4
|
+
import { gitOutput } from "../shared/git.js";
|
|
5
|
+
import { redactSensitiveText } from "../shared/text.js";
|
|
6
|
+
/** Durable diagnostics only when no Job Run exists to explain a failed routine. */
|
|
7
|
+
export function recordRoutineFailure(repoRoot, failuresPath, entry) {
|
|
8
|
+
if (entry.result !== "failure" || entry.job_run_ids.length > 0)
|
|
9
|
+
return undefined;
|
|
10
|
+
const runId = randomUUID();
|
|
11
|
+
const directory = join(failuresPath, entry.routine_id);
|
|
12
|
+
ensureDir(directory);
|
|
13
|
+
const file = join(directory, `${runId}.json`);
|
|
14
|
+
writeJson(file, {
|
|
15
|
+
...entry,
|
|
16
|
+
run_id: runId,
|
|
17
|
+
...(entry.reason ? { reason: redactSensitiveText(entry.reason) } : {}),
|
|
18
|
+
});
|
|
19
|
+
const target = relative(repoRoot, file);
|
|
20
|
+
gitOutput(repoRoot, ["add", "--", target]);
|
|
21
|
+
gitOutput(repoRoot, [
|
|
22
|
+
"commit",
|
|
23
|
+
"--only",
|
|
24
|
+
"-m",
|
|
25
|
+
`chore(routine): record failure ${entry.routine_id}`,
|
|
26
|
+
"--",
|
|
27
|
+
target,
|
|
28
|
+
]);
|
|
29
|
+
return file;
|
|
30
|
+
}
|
package/dist/routine/routine.js
CHANGED
|
@@ -11,6 +11,8 @@ import { jobDeclaresReview, jobRunUsesReviewedIntegration, loadJobDefinition, re
|
|
|
11
11
|
import { cronOccurrences, isRecord, isRoutineDue, isRoutineYamlFile, isoWeek, loadRoutines, resolveRoutinePaths, routineActionKindLabel, } from "./definition.js";
|
|
12
12
|
import { selfRunArgs } from "../shared/spawn-self.js";
|
|
13
13
|
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
14
|
+
import { migrateRoutineStorage } from "./storage.js";
|
|
15
|
+
import { recordRoutineFailure } from "./failure.js";
|
|
14
16
|
export { cronMatches, cronOccurrences, isRoutineDue, isoWeek, loadRoutines, parseCronExpression, parseIntervalMs, parseRoutineDoc, resolveRoutinePaths, routineActionKindLabel, } from "./definition.js";
|
|
15
17
|
// ================================
|
|
16
18
|
// State
|
|
@@ -30,7 +32,7 @@ function readRoutineState(statePath) {
|
|
|
30
32
|
return { routines: {} };
|
|
31
33
|
}
|
|
32
34
|
function writeRoutineState(paths, state) {
|
|
33
|
-
ensureDir(paths.
|
|
35
|
+
ensureDir(paths.stateDirectory);
|
|
34
36
|
writeJson(paths.statePath, state);
|
|
35
37
|
}
|
|
36
38
|
export function recordRoutineStart(current, startedAt, scheduledAt) {
|
|
@@ -68,8 +70,7 @@ export function appendRoutineRunHistory(runsPath, entry) {
|
|
|
68
70
|
const ROUTINE_LOCK_STALE_MS = 60 * 60 * 1000;
|
|
69
71
|
// routine run の多重起動(外部スケジューラの重複発火)を防ぐ簡易 lock。
|
|
70
72
|
// 生存中の lock があれば即座に失敗し、stale(1 時間超)な lock は奪う。
|
|
71
|
-
function acquireRoutineLock(
|
|
72
|
-
const lockDir = join(routinesPath, ".locks", "routine-run.lock");
|
|
73
|
+
function acquireRoutineLock(lockDir) {
|
|
73
74
|
ensureDir(resolve(lockDir, ".."));
|
|
74
75
|
try {
|
|
75
76
|
mkdirSync(lockDir);
|
|
@@ -110,9 +111,11 @@ function ensureFreshDistForRoutineRun() {
|
|
|
110
111
|
}
|
|
111
112
|
let lastRoutineSpawnReason;
|
|
112
113
|
let lastRoutineSpawnRunId;
|
|
114
|
+
let lastRoutineSpawnNoop = false;
|
|
113
115
|
function spawnSelf(args) {
|
|
114
116
|
lastRoutineSpawnReason = undefined;
|
|
115
117
|
lastRoutineSpawnRunId = undefined;
|
|
118
|
+
lastRoutineSpawnNoop = false;
|
|
116
119
|
const [exe, fullArgs] = selfRunArgs(args);
|
|
117
120
|
const result = spawnSync(exe, fullArgs, {
|
|
118
121
|
encoding: "utf8",
|
|
@@ -128,6 +131,7 @@ function spawnSelf(args) {
|
|
|
128
131
|
const output = `${result.stdout ?? ""}\n${result.stderr ?? ""}`;
|
|
129
132
|
const marker = [...output.matchAll(/^\[routine-job\]\s+([^\n]+)$/gm)].at(-1)?.[1];
|
|
130
133
|
if (marker) {
|
|
134
|
+
lastRoutineSpawnNoop = /\bstate=noop\b/.test(marker);
|
|
131
135
|
lastRoutineSpawnRunId = marker.match(/\brun_id=([^\s]+)/)?.[1];
|
|
132
136
|
lastRoutineSpawnReason = marker.match(/\breason=(.+)$/)?.[1]?.trim();
|
|
133
137
|
}
|
|
@@ -212,6 +216,7 @@ function executeRoutineAction(doc, action, projectId, dryRun, scheduledAt = new
|
|
|
212
216
|
if (dryRun) {
|
|
213
217
|
lastRoutineSpawnReason = undefined;
|
|
214
218
|
lastRoutineSpawnRunId = undefined;
|
|
219
|
+
lastRoutineSpawnNoop = false;
|
|
215
220
|
process.stdout.write(` [dry-run] specdojo ${args.join(" ")}\n`);
|
|
216
221
|
if (action.kind === "job") {
|
|
217
222
|
try {
|
|
@@ -231,7 +236,7 @@ export function buildSpecdojoActionArgs(action, projectId) {
|
|
|
231
236
|
return [...action.args, "--project", projectId];
|
|
232
237
|
}
|
|
233
238
|
function findJobRunId(action, projectId, scheduledAt) {
|
|
234
|
-
if (action.kind !== "job")
|
|
239
|
+
if (action.kind !== "job" || lastRoutineSpawnNoop)
|
|
235
240
|
return undefined;
|
|
236
241
|
const runsPath = resolveJobPaths(projectId).runsPath;
|
|
237
242
|
if (!existsSync(runsPath))
|
|
@@ -261,36 +266,40 @@ function executeRoutine(routine, projectId, dryRun, scheduledAt = new Date()) {
|
|
|
261
266
|
const actions = Array.isArray(doc.action) ? doc.action : [doc.action];
|
|
262
267
|
const label = doc.name ?? (actions.length === 1 ? actions[0].kind : `${actions.length} actions`);
|
|
263
268
|
process.stdout.write(`[routine] ${doc.id}: ${label}\n`);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return {
|
|
268
|
-
result,
|
|
269
|
-
jobRunIds: lastRoutineSpawnRunId ? [lastRoutineSpawnRunId] : jobRunId ? [jobRunId] : [],
|
|
270
|
-
...(lastRoutineSpawnReason ? { reason: lastRoutineSpawnReason } : {}),
|
|
271
|
-
};
|
|
272
|
-
}
|
|
269
|
+
const multiple = Array.isArray(doc.action);
|
|
270
|
+
const jobRunIds = [];
|
|
271
|
+
const reasons = [];
|
|
273
272
|
const actionResults = executeRoutineActions(actions, (action, index) => {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
273
|
+
if (multiple)
|
|
274
|
+
process.stdout.write(` action ${index}/${actions.length}: ${action.kind}\n`);
|
|
275
|
+
lastRoutineSpawnReason = undefined;
|
|
276
|
+
lastRoutineSpawnRunId = undefined;
|
|
277
|
+
lastRoutineSpawnNoop = false;
|
|
278
|
+
let result;
|
|
279
|
+
try {
|
|
280
|
+
result = executeRoutineAction(doc, action, projectId, dryRun, scheduledAt);
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
result = "failure";
|
|
284
|
+
lastRoutineSpawnReason = error instanceof Error ? error.message : String(error);
|
|
285
|
+
}
|
|
286
|
+
const runId = lastRoutineSpawnRunId ?? (dryRun ? undefined : findJobRunId(action, projectId, scheduledAt));
|
|
287
|
+
if (runId)
|
|
288
|
+
jobRunIds.push(runId);
|
|
289
|
+
if (lastRoutineSpawnReason)
|
|
290
|
+
reasons.push(lastRoutineSpawnReason);
|
|
291
|
+
if (multiple)
|
|
292
|
+
process.stdout.write(` action ${index}/${actions.length}: ${result}\n`);
|
|
277
293
|
return result;
|
|
278
294
|
});
|
|
279
295
|
const result = aggregateRoutineActionResults(actionResults.map((item) => item.result));
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
? []
|
|
283
|
-
: doc.action.flatMap((action) => {
|
|
284
|
-
const runId = findJobRunId(action, projectId, scheduledAt);
|
|
285
|
-
return runId ? [runId] : [];
|
|
286
|
-
});
|
|
296
|
+
if (multiple)
|
|
297
|
+
process.stdout.write(` action summary: ${actionResults.map((item) => `${item.index}:${item.result}`).join(", ")} => ${result}\n`);
|
|
287
298
|
return {
|
|
288
299
|
result,
|
|
289
|
-
actionResults,
|
|
290
|
-
jobRunIds: [
|
|
291
|
-
|
|
292
|
-
],
|
|
293
|
-
...(lastRoutineSpawnReason ? { reason: lastRoutineSpawnReason } : {}),
|
|
300
|
+
...(multiple ? { actionResults } : {}),
|
|
301
|
+
jobRunIds: [...new Set(jobRunIds)],
|
|
302
|
+
...(reasons.length ? { reason: reasons.join("; ") } : {}),
|
|
294
303
|
};
|
|
295
304
|
}
|
|
296
305
|
// ================================
|
|
@@ -368,6 +377,7 @@ export function registerRoutineCommands(program) {
|
|
|
368
377
|
process.exitCode = 1;
|
|
369
378
|
return;
|
|
370
379
|
}
|
|
380
|
+
migrateRoutineStorage(paths.routinesPath);
|
|
371
381
|
const state = readRoutineState(paths.statePath);
|
|
372
382
|
const now = new Date();
|
|
373
383
|
const rows = routines.map(({ doc }) => ({
|
|
@@ -423,6 +433,8 @@ export function registerRoutineCommands(program) {
|
|
|
423
433
|
}
|
|
424
434
|
if (errors.length > 0)
|
|
425
435
|
process.exitCode = 1;
|
|
436
|
+
if (!opts.dryRun)
|
|
437
|
+
migrateRoutineStorage(paths.routinesPath);
|
|
426
438
|
const state = readRoutineState(paths.statePath);
|
|
427
439
|
const now = new Date();
|
|
428
440
|
let selected;
|
|
@@ -457,7 +469,7 @@ export function registerRoutineCommands(program) {
|
|
|
457
469
|
process.exitCode = 1;
|
|
458
470
|
return;
|
|
459
471
|
}
|
|
460
|
-
lockDir = acquireRoutineLock(paths.
|
|
472
|
+
lockDir = acquireRoutineLock(paths.lockPath);
|
|
461
473
|
}
|
|
462
474
|
let failed = 0;
|
|
463
475
|
let partial = 0;
|
|
@@ -472,7 +484,17 @@ export function registerRoutineCommands(program) {
|
|
|
472
484
|
state.routines[entry.doc.id] = recordRoutineStart(state.routines[entry.doc.id], startedAt, entry.doc.trigger ? scheduledAt.toISOString() : undefined);
|
|
473
485
|
writeRoutineState(paths, state);
|
|
474
486
|
}
|
|
475
|
-
|
|
487
|
+
let execution;
|
|
488
|
+
try {
|
|
489
|
+
execution = executeRoutine(entry, paths.projectId, dryRun, scheduledAt);
|
|
490
|
+
}
|
|
491
|
+
catch (error) {
|
|
492
|
+
execution = {
|
|
493
|
+
result: "failure",
|
|
494
|
+
jobRunIds: [],
|
|
495
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
496
|
+
};
|
|
497
|
+
}
|
|
476
498
|
const { result } = execution;
|
|
477
499
|
if (result === "failure")
|
|
478
500
|
failed++;
|
|
@@ -485,7 +507,7 @@ export function registerRoutineCommands(program) {
|
|
|
485
507
|
if (!dryRun) {
|
|
486
508
|
state.routines[entry.doc.id] = recordRoutineCompletion(state.routines[entry.doc.id], result, execution.reason, execution.actionResults);
|
|
487
509
|
writeRoutineState(paths, state);
|
|
488
|
-
|
|
510
|
+
const history = {
|
|
489
511
|
version: 1,
|
|
490
512
|
routine_id: entry.doc.id,
|
|
491
513
|
scheduled_for: scheduledAt.toISOString(),
|
|
@@ -494,7 +516,9 @@ export function registerRoutineCommands(program) {
|
|
|
494
516
|
result,
|
|
495
517
|
job_run_ids: execution.jobRunIds,
|
|
496
518
|
...(execution.reason ? { reason: execution.reason } : {}),
|
|
497
|
-
}
|
|
519
|
+
};
|
|
520
|
+
appendRoutineRunHistory(paths.runsPath, history);
|
|
521
|
+
recordRoutineFailure(specdojoRootDir(), paths.failuresPath, history);
|
|
498
522
|
}
|
|
499
523
|
}
|
|
500
524
|
process.stdout.write(`[routine] ${selected.length} routine(s) processed, ${partial} partial, ${skipped} skipped, ${failed} failed\n`);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { constants, copyFileSync, existsSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { join, relative, resolve } from "node:path";
|
|
4
|
+
import { localStateDirectory } from "../shared/local-state.js";
|
|
5
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
6
|
+
export function routineStoragePaths(routinesPath, repoRoot = specdojoRootDir()) {
|
|
7
|
+
const key = createHash("sha256").update(relative(repoRoot, routinesPath)).digest("hex");
|
|
8
|
+
const stateDirectory = join(localStateDirectory(repoRoot), "routines", key);
|
|
9
|
+
return {
|
|
10
|
+
stateDirectory,
|
|
11
|
+
statePath: join(stateDirectory, "routine-state.json"),
|
|
12
|
+
runsPath: join(stateDirectory, "routine-runs.jsonl"),
|
|
13
|
+
lockPath: join(stateDirectory, ".locks", "routine-run.lock"),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Copy once, preserving the old files for rollback and never overwriting newer state. */
|
|
17
|
+
export function migrateRoutineStorage(routinesPath, repoRoot = specdojoRootDir()) {
|
|
18
|
+
const paths = routineStoragePaths(routinesPath, repoRoot);
|
|
19
|
+
for (const destination of [paths.statePath, paths.runsPath]) {
|
|
20
|
+
const source = join(routinesPath, "generated", destination === paths.statePath ? "routine-state.json" : "routine-runs.jsonl");
|
|
21
|
+
if (!existsSync(source) || existsSync(destination))
|
|
22
|
+
continue;
|
|
23
|
+
mkdirSync(resolve(destination, ".."), { recursive: true });
|
|
24
|
+
try {
|
|
25
|
+
copyFileSync(source, destination, constants.COPYFILE_EXCL);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
if (error.code !== "EEXIST")
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return paths;
|
|
33
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AUTHOR_PHASE_SETS, PHASE_SET_ORDER, profileFor, renderPhase, STRATEGY_PHASE_SETS, } from "./strategy-profiles.js";
|
|
2
2
|
import { artifactNameFromCatalogTitle, } from "./strategy-generate-scope.js";
|
|
3
|
-
function phaseSetsOf(
|
|
4
|
-
return profileFor(approach).phase_sets;
|
|
3
|
+
function phaseSetsOf(deliverable) {
|
|
4
|
+
return profileFor(deliverable.approach).phase_sets.filter((name) => !deliverable.not_needed_kata?.some((kind) => name === `${kind}-maintenance-pass`));
|
|
5
5
|
}
|
|
6
6
|
function orderPhaseSets(names) {
|
|
7
7
|
const unique = [...new Set(names)];
|
|
@@ -38,7 +38,7 @@ export function buildStrategyDocument(input) {
|
|
|
38
38
|
return false;
|
|
39
39
|
});
|
|
40
40
|
const sorted = [...eligibleDeliverables].sort((left, right) => left.local_id.localeCompare(right.local_id));
|
|
41
|
-
//
|
|
41
|
+
// Group by the effective sequence too: the same approach can omit different not-needed Kata.
|
|
42
42
|
const groups = new Map();
|
|
43
43
|
for (const deliverable of sorted) {
|
|
44
44
|
const owner = input.owners.get(deliverable.local_id);
|
|
@@ -46,22 +46,34 @@ export function buildStrategyDocument(input) {
|
|
|
46
46
|
errors.push(`${deliverable.local_id}: owner が解決できていない。`);
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
const
|
|
49
|
+
const sequence = phaseSetsOf(deliverable);
|
|
50
|
+
const key = JSON.stringify([owner, deliverable.approach, sequence]);
|
|
51
|
+
const group = groups.get(key) ?? {
|
|
52
|
+
owner,
|
|
53
|
+
approach: deliverable.approach,
|
|
54
|
+
sequence,
|
|
55
|
+
localIds: [],
|
|
56
|
+
};
|
|
51
57
|
group.localIds.push(deliverable.local_id);
|
|
52
58
|
groups.set(key, group);
|
|
53
59
|
}
|
|
54
60
|
const orderedGroups = [...groups.values()].sort((left, right) => left.owner === right.owner
|
|
55
|
-
? left.approach.localeCompare(right.approach)
|
|
61
|
+
? left.approach.localeCompare(right.approach) ||
|
|
62
|
+
left.sequence.join(",").localeCompare(right.sequence.join(","))
|
|
56
63
|
: left.owner.localeCompare(right.owner));
|
|
57
64
|
// The most common profile becomes default_phase_sets so rules that follow it stay compact.
|
|
58
|
-
const
|
|
65
|
+
const bySequence = new Map();
|
|
59
66
|
for (const deliverable of sorted) {
|
|
60
|
-
|
|
67
|
+
const sequence = phaseSetsOf(deliverable);
|
|
68
|
+
const key = JSON.stringify(sequence);
|
|
69
|
+
const entry = bySequence.get(key) ?? { sequence, count: 0 };
|
|
70
|
+
entry.count++;
|
|
71
|
+
bySequence.set(key, entry);
|
|
61
72
|
}
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
const defaultSequence = [...bySequence.entries()].sort((left, right) => right[1].count === left[1].count
|
|
74
|
+
? left[0].localeCompare(right[0])
|
|
75
|
+
: right[1].count - left[1].count)[0]?.[1].sequence ?? [];
|
|
76
|
+
const usedPhaseSets = orderPhaseSets(sorted.flatMap(phaseSetsOf));
|
|
65
77
|
const phaseSets = {};
|
|
66
78
|
for (const name of usedPhaseSets) {
|
|
67
79
|
const definition = STRATEGY_PHASE_SETS[name];
|
|
@@ -72,7 +84,7 @@ export function buildStrategyDocument(input) {
|
|
|
72
84
|
phaseSets[name] = definition.map(renderPhase);
|
|
73
85
|
}
|
|
74
86
|
const ownerRules = orderedGroups.map((group) => {
|
|
75
|
-
const sequence =
|
|
87
|
+
const sequence = group.sequence;
|
|
76
88
|
const sameAsDefault = sequence.length === defaultSequence.length &&
|
|
77
89
|
sequence.every((name, index) => name === defaultSequence[index]);
|
|
78
90
|
const finalizeApproach = profileFor(group.approach).finalize_approach;
|
|
@@ -86,7 +98,7 @@ export function buildStrategyDocument(input) {
|
|
|
86
98
|
};
|
|
87
99
|
});
|
|
88
100
|
// --- phase gates -------------------------------------------------------------
|
|
89
|
-
const countUsing = (phaseSetName) => sorted.filter((d) => phaseSetsOf(d
|
|
101
|
+
const countUsing = (phaseSetName) => sorted.filter((d) => phaseSetsOf(d).includes(phaseSetName)).length;
|
|
90
102
|
const authorPhaseSets = orderPhaseSets(usedPhaseSets.filter((name) => AUTHOR_PHASE_SETS.includes(name)));
|
|
91
103
|
const catalogScope = { catalogs: input.catalogs.map((catalog) => catalog.id) };
|
|
92
104
|
const artifactName = input.catalogs.length === 1 ? artifactNameFromCatalogTitle(input.catalogs[0].title) : undefined;
|
|
@@ -94,7 +106,7 @@ export function buildStrategyDocument(input) {
|
|
|
94
106
|
const dedupLocalIds = sorted
|
|
95
107
|
.filter((d) => d.approach === "cross-deliverable-dedup")
|
|
96
108
|
.map((d) => d.local_id);
|
|
97
|
-
const authorPassDeliverables = sorted.filter((d) => phaseSetsOf(d
|
|
109
|
+
const authorPassDeliverables = sorted.filter((d) => phaseSetsOf(d).some((name) => AUTHOR_PHASE_SETS.includes(name))).length;
|
|
98
110
|
const firstPassGateId = `G-${trackUpper}-first-pass`;
|
|
99
111
|
const gates = [];
|
|
100
112
|
const needsFirstPassGate = authorPhaseSets.length > 0 && (authorPassDeliverables >= 2 || dedupLocalIds.length >= 2);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import { relative, resolve } from "node:path";
|
|
3
3
|
import { collectResolvedDeliverables } from "../catalog/build.js";
|
|
4
4
|
import { resolveBasePath } from "../catalog/paths.js";
|
|
5
5
|
import { collectCatalogFilesByDomain } from "../shared/catalog-files.js";
|
|
6
6
|
import { readYaml } from "../shared/fs.js";
|
|
7
|
-
import {
|
|
8
|
-
import { resolveTimelineCatalogStatus } from "../register/catalog-status.js";
|
|
7
|
+
import { resolveTrackDomains } from "../register/track-domains.js";
|
|
9
8
|
export function isRecord(value) {
|
|
10
9
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
10
|
}
|
|
@@ -20,10 +19,10 @@ export function artifactNameFromCatalogTitle(title) {
|
|
|
20
19
|
return match ? match[1] : undefined;
|
|
21
20
|
}
|
|
22
21
|
// Resolves the catalogs a track covers. An existing strategy is authoritative (a human may have
|
|
23
|
-
// narrowed the scope on purpose); otherwise the
|
|
22
|
+
// narrowed the scope on purpose); otherwise epic domains, then the legacy track plan decide what belongs
|
|
24
23
|
// to the track, and every catalog file of those domains (including physical splits) is included.
|
|
25
24
|
export function resolveTrackScopeCatalogs(opts) {
|
|
26
|
-
const { repoRoot, catalogPath,
|
|
25
|
+
const { repoRoot, catalogPath, track } = opts;
|
|
27
26
|
const warnings = [];
|
|
28
27
|
const errors = [];
|
|
29
28
|
const byDomain = collectCatalogFilesByDomain(catalogPath);
|
|
@@ -41,44 +40,24 @@ export function resolveTrackScopeCatalogs(opts) {
|
|
|
41
40
|
...(doc.title ? { title: doc.title } : {}),
|
|
42
41
|
};
|
|
43
42
|
};
|
|
43
|
+
const resolved = resolveTrackDomains(opts);
|
|
44
|
+
errors.push(...resolved.errors);
|
|
44
45
|
const timelineCatalogs = [];
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
const plan = index.tracks.find((entry) => entry.track === track);
|
|
55
|
-
if (plan) {
|
|
56
|
-
for (const domain of plan.domains) {
|
|
57
|
-
const files = byDomain.get(domain) ?? [];
|
|
58
|
-
if (files.length === 0) {
|
|
59
|
-
warnings.push(`timeline: track '${track}' の domain '${domain}' に対応する dct-*.yaml が無い(scope から除外)。`);
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
for (const filePath of files) {
|
|
63
|
-
const ref = refFor(filePath);
|
|
64
|
-
if (ref)
|
|
65
|
-
timelineCatalogs.push(ref);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (plan.catalog_status !== "primary") {
|
|
69
|
-
warnings.push(`timeline: track '${track}' の catalog_status は '${plan.catalog_status}'。` +
|
|
70
|
-
`カタログ作成 todo の完了を確認して timeline build を実行する。todo がない domain は手書きの計画値を使う。`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
warnings.push(`timeline: track '${track}' が tml-index.yaml に無い。`);
|
|
46
|
+
for (const domain of resolved.source === "strategy" ? [] : resolved.domains) {
|
|
47
|
+
const files = byDomain.get(domain) ?? [];
|
|
48
|
+
if (files.length === 0)
|
|
49
|
+
warnings.push(`${resolved.source}: track '${track}' の domain '${domain}' に対応する dct-*.yaml が無い(scope から除外)。`);
|
|
50
|
+
for (const filePath of files) {
|
|
51
|
+
const ref = refFor(filePath);
|
|
52
|
+
if (ref)
|
|
53
|
+
timelineCatalogs.push(ref);
|
|
75
54
|
}
|
|
76
55
|
}
|
|
77
56
|
const existingScope = isRecord(opts.existingStrategy?.scope)
|
|
78
57
|
? opts.existingStrategy.scope
|
|
79
58
|
: undefined;
|
|
80
59
|
const existingCatalogs = Array.isArray(existingScope?.catalogs) ? existingScope.catalogs : [];
|
|
81
|
-
if (
|
|
60
|
+
if (Array.isArray(existingScope?.catalogs)) {
|
|
82
61
|
const catalogs = [];
|
|
83
62
|
for (const entry of existingCatalogs) {
|
|
84
63
|
if (!isRecord(entry) || typeof entry.path !== "string")
|
|
@@ -103,20 +82,13 @@ export function resolveTrackScopeCatalogs(opts) {
|
|
|
103
82
|
if (ref)
|
|
104
83
|
catalogs.push(ref);
|
|
105
84
|
}
|
|
106
|
-
const known = new Set(catalogs.map((catalog) => catalog.id));
|
|
107
|
-
for (const catalog of timelineCatalogs) {
|
|
108
|
-
if (known.has(catalog.id))
|
|
109
|
-
continue;
|
|
110
|
-
warnings.push(`timeline の domain から解決した ${catalog.id} が既存 scope に無い。scope を広げる場合は ` +
|
|
111
|
-
`sch-strategy-${track}.yaml の scope.catalogs を先に更新する。`);
|
|
112
|
-
}
|
|
113
85
|
return { catalogs, source: "strategy", warnings, errors };
|
|
114
86
|
}
|
|
115
87
|
if (timelineCatalogs.length === 0) {
|
|
116
|
-
errors.push(`track '${track}' の scope を解決できない。
|
|
88
|
+
errors.push(`track '${track}' の scope を解決できない。epic の domains と ` +
|
|
117
89
|
`dct-<domain>.yaml を用意するか、既存 strategy の scope.catalogs を先に定義する。`);
|
|
118
90
|
}
|
|
119
|
-
return { catalogs: timelineCatalogs, source:
|
|
91
|
+
return { catalogs: timelineCatalogs, source: resolved.source, warnings, errors };
|
|
120
92
|
}
|
|
121
93
|
// Deliverables of the scoped catalogs, in catalog order. `include_kinds` mirrors the strategy
|
|
122
94
|
// scope (work by default).
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// by code so `schedule build` and `exec refresh` stay deterministic.
|
|
5
5
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync, } from "node:fs";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
|
-
import { basename, join, resolve } from "node:path";
|
|
7
|
+
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
8
8
|
import { dump, load as loadYaml } from "../shared/yaml.js";
|
|
9
9
|
import { resolveSpecdojoPath } from "../docs/template-resolution.js";
|
|
10
10
|
import Ajv2020Module from "ajv/dist/2020.js";
|
|
@@ -124,6 +124,30 @@ export function dryRunStrategy(opts) {
|
|
|
124
124
|
rmSync(candidateDir, { recursive: true, force: true });
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
+
const YAML_SCHEMA_MODELINE_RE = /^#\s*yaml-language-server:\s+\$schema=\S+\s*$/;
|
|
128
|
+
function findSchemaModeline(content) {
|
|
129
|
+
for (const line of content.split(/\r?\n/)) {
|
|
130
|
+
if (line.trim() === "")
|
|
131
|
+
continue;
|
|
132
|
+
if (!line.startsWith("#"))
|
|
133
|
+
return undefined;
|
|
134
|
+
if (YAML_SCHEMA_MODELINE_RE.test(line))
|
|
135
|
+
return line;
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
// validate:schema は modeline から schema を解決するため、modeline の無い strategy は検証で失敗する。
|
|
140
|
+
// 書き出す内容に modeline が無ければ、既存ファイルの modeline を保ち、無ければ schema への相対参照を作る。
|
|
141
|
+
export function withStrategySchemaModeline(opts) {
|
|
142
|
+
if (findSchemaModeline(opts.content))
|
|
143
|
+
return opts.content;
|
|
144
|
+
const existing = findSchemaModeline(opts.current);
|
|
145
|
+
if (existing)
|
|
146
|
+
return `${existing}\n${opts.content}`;
|
|
147
|
+
const schemaPath = resolveSpecdojoPath(SCH_STRATEGY_SCHEMA_PATH, opts.repoRoot ? { repositoryRoot: opts.repoRoot } : {});
|
|
148
|
+
const schemaRef = relative(dirname(opts.path), schemaPath).split(sep).join("/");
|
|
149
|
+
return `# yaml-language-server: $schema=${schemaRef}\n${opts.content}`;
|
|
150
|
+
}
|
|
127
151
|
export function strategyPathFor(schedulePath, track) {
|
|
128
152
|
return join(schedulePath, `sch-strategy-${track}.yaml`);
|
|
129
153
|
}
|
|
@@ -134,7 +158,13 @@ export function writeStrategyFile(opts) {
|
|
|
134
158
|
const path = strategyPathFor(opts.schedulePath, opts.track);
|
|
135
159
|
const exists = existsSync(path);
|
|
136
160
|
const current = exists ? readFileSync(path, "utf8") : "";
|
|
137
|
-
const
|
|
161
|
+
const content = withStrategySchemaModeline({
|
|
162
|
+
path,
|
|
163
|
+
content: opts.content,
|
|
164
|
+
current,
|
|
165
|
+
...(opts.repoRoot ? { repoRoot: opts.repoRoot } : {}),
|
|
166
|
+
});
|
|
167
|
+
const diff = diffPlanText(current, content);
|
|
138
168
|
if (exists && diff.length === 0) {
|
|
139
169
|
return { path, written: false, skippedReason: "unchanged", diff };
|
|
140
170
|
}
|
|
@@ -147,7 +177,7 @@ export function writeStrategyFile(opts) {
|
|
|
147
177
|
mkdirSync(opts.schedulePath, { recursive: true });
|
|
148
178
|
const temporaryPath = join(opts.schedulePath, `.sch-strategy-${opts.track}.${process.pid}.tmp`);
|
|
149
179
|
try {
|
|
150
|
-
writeFileSync(temporaryPath,
|
|
180
|
+
writeFileSync(temporaryPath, content, "utf8");
|
|
151
181
|
renameSync(temporaryPath, path);
|
|
152
182
|
}
|
|
153
183
|
finally {
|