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
|
@@ -4,18 +4,34 @@
|
|
|
4
4
|
// the same phase ids, task suffixes, durations, modes and execution kinds.
|
|
5
5
|
const EXPERT_PIPELINE = { executor: "expert", reporter: "normal" };
|
|
6
6
|
const NORMAL_PIPELINE = { executor: "normal", reporter: "normal" };
|
|
7
|
+
// Shared authoring policy from the hand-maintained Kata strategies (T88P / kata-wave-1).
|
|
8
|
+
const KATA_AUTHORING_POLICY = "[[specdojo:rulebook-authoring-standard|Rulebook 記述標準]]の章立てに合わせ、" +
|
|
9
|
+
"rulebook に完成例の章を置かず sample へ外出しする。Markdown の第2〜第4階層の見出しに階層ごとの連番を付け、" +
|
|
10
|
+
"記述ガイドには章ごとの判断基準と良い例・悪い例を書く。sample は " +
|
|
11
|
+
"[[specdojo:clis-sample|CLI仕様の完成例]]程度の厚さとし、YAML は対象形式に合わせて内容を充実させる。" +
|
|
12
|
+
"recipe と template の要否を判断し、rulebook frontmatter に対応する ID または not-needed を宣言して理由を result に残す。" +
|
|
13
|
+
"実装・schema・リファレンスの値・構文・構造の詳細を再掲せず、正本を参照する。";
|
|
14
|
+
const MAINTENANCE_DETAILS = {
|
|
15
|
+
rulebook: "代表成果物の実績から rulebook の規則・判断基準を見直す。後続の段で recipe・sample・template を同期する。",
|
|
16
|
+
recipe: "改訂した rulebook に沿って recipe を同期する。問いと作成手順に責務を絞り、rulebook の規則を再定義しない。",
|
|
17
|
+
sample: "改訂した rulebook に沿って sample を完成例として手入れする。共通サンプル文脈を用い、" +
|
|
18
|
+
"代表成果物を単純に複写せず、判断に要る場面・例外を拾う。",
|
|
19
|
+
template: "改訂した rulebook に沿って template を同期する。骨組みに責務を絞り、" +
|
|
20
|
+
"必須の章・項目・表の列名を整合させ、説明や完成例を転載しない。",
|
|
21
|
+
};
|
|
7
22
|
function maintenancePhase(kind) {
|
|
8
23
|
return {
|
|
9
24
|
id: `${kind}-maintenance`,
|
|
10
25
|
name: `${kind} の見直し`,
|
|
11
|
-
task_suffix: "040",
|
|
26
|
+
task_suffix: { rulebook: "040", recipe: "045", sample: "050", template: "060" }[kind],
|
|
12
27
|
duration_days: 0.5,
|
|
13
28
|
execution: "agent",
|
|
14
29
|
mode: "edit",
|
|
15
30
|
approach: `${kind}-maintenance`,
|
|
16
31
|
pipeline: EXPERT_PIPELINE,
|
|
17
|
-
description:
|
|
18
|
-
|
|
32
|
+
description: MAINTENANCE_DETAILS[kind] +
|
|
33
|
+
"成果物本体はこの段で変更しない。実行時に対象が not-needed なら変更せず、その旨を result に記録して完了する。\n\n" +
|
|
34
|
+
KATA_AUTHORING_POLICY,
|
|
19
35
|
};
|
|
20
36
|
}
|
|
21
37
|
// Named phase sets. Keys are the phase_set names written into the generated strategy.
|
|
@@ -32,7 +48,9 @@ export const STRATEGY_PHASE_SETS = {
|
|
|
32
48
|
pipeline: EXPERT_PIPELINE,
|
|
33
49
|
description: "実践の型の作成条件から要否を判断し、代表成果物と必要な rulebook / recipe / sample / template を" +
|
|
34
50
|
"同じタスクで初期整備する。不要な3種は rulebook frontmatter へ not-needed と宣言し、必要な一式の構造・" +
|
|
35
|
-
"
|
|
51
|
+
"用語・粒度を整合させる。代表が既存なら型との整合に必要な範囲だけ直し、業務判断は確定しない。" +
|
|
52
|
+
"判断できない前提は推測せず result に残す。\n\n" +
|
|
53
|
+
KATA_AUTHORING_POLICY,
|
|
36
54
|
},
|
|
37
55
|
],
|
|
38
56
|
"retrofit-pass": [
|
|
@@ -124,6 +142,20 @@ export const STRATEGY_PHASE_SETS = {
|
|
|
124
142
|
"沿った情報の受け渡しを確認し、不足や不整合だけを最小限修正して done_criteria を満たす状態へ整える。",
|
|
125
143
|
},
|
|
126
144
|
],
|
|
145
|
+
"condense-pass": [
|
|
146
|
+
{
|
|
147
|
+
id: "condense",
|
|
148
|
+
name: "冗長さの整理",
|
|
149
|
+
task_suffix: "080",
|
|
150
|
+
duration_days: 0.25,
|
|
151
|
+
execution: "agent",
|
|
152
|
+
mode: "edit",
|
|
153
|
+
approach: "condense",
|
|
154
|
+
pipeline: NORMAL_PIPELINE,
|
|
155
|
+
description: "1 文書の冗長さを削る・まとめる・参照に置き換える。判断に要る背景・制約・例外・完了条件と意味を保ち、" +
|
|
156
|
+
"新しい内容を足さず、修正・保持した箇所と原因を result に記録する。",
|
|
157
|
+
},
|
|
158
|
+
],
|
|
127
159
|
"review-pass": [
|
|
128
160
|
{
|
|
129
161
|
id: "review",
|
|
@@ -180,6 +212,7 @@ export const PHASE_SET_ORDER = [
|
|
|
180
212
|
"sample-maintenance-pass",
|
|
181
213
|
"template-maintenance-pass",
|
|
182
214
|
"refine-pass",
|
|
215
|
+
"condense-pass",
|
|
183
216
|
"review-pass",
|
|
184
217
|
"retrofit-review-pass",
|
|
185
218
|
"finalize-pass",
|
|
@@ -202,37 +235,73 @@ export const AUTHOR_PHASE_SETS = [
|
|
|
202
235
|
export const STRATEGY_PROFILES = {
|
|
203
236
|
bootstrap: {
|
|
204
237
|
approach: "bootstrap",
|
|
205
|
-
phase_sets: [
|
|
238
|
+
phase_sets: [
|
|
239
|
+
"bootstrap-pass",
|
|
240
|
+
"rulebook-maintenance-pass",
|
|
241
|
+
"recipe-maintenance-pass",
|
|
242
|
+
"sample-maintenance-pass",
|
|
243
|
+
"template-maintenance-pass",
|
|
244
|
+
"refine-pass",
|
|
245
|
+
"condense-pass",
|
|
246
|
+
"retrofit-review-pass",
|
|
247
|
+
"finalize-pass",
|
|
248
|
+
],
|
|
206
249
|
finalize_approach: "bootstrap-finalize",
|
|
207
250
|
},
|
|
208
251
|
retrofit: {
|
|
209
252
|
approach: "retrofit",
|
|
210
|
-
phase_sets: [
|
|
253
|
+
phase_sets: [
|
|
254
|
+
"retrofit-pass",
|
|
255
|
+
"refine-pass",
|
|
256
|
+
"condense-pass",
|
|
257
|
+
"retrofit-review-pass",
|
|
258
|
+
"finalize-pass",
|
|
259
|
+
],
|
|
211
260
|
finalize_approach: "finalize",
|
|
212
261
|
},
|
|
213
262
|
"fully-guided": {
|
|
214
263
|
approach: "fully-guided",
|
|
215
|
-
phase_sets: ["guided-pass", "refine-pass", "review-pass", "finalize-pass"],
|
|
264
|
+
phase_sets: ["guided-pass", "refine-pass", "condense-pass", "review-pass", "finalize-pass"],
|
|
216
265
|
finalize_approach: "finalize",
|
|
217
266
|
},
|
|
218
267
|
draft: {
|
|
219
268
|
approach: "draft",
|
|
220
|
-
phase_sets: [
|
|
269
|
+
phase_sets: [
|
|
270
|
+
"context-pass",
|
|
271
|
+
"guided-pass",
|
|
272
|
+
"refine-pass",
|
|
273
|
+
"condense-pass",
|
|
274
|
+
"review-pass",
|
|
275
|
+
"finalize-pass",
|
|
276
|
+
],
|
|
221
277
|
finalize_approach: "finalize",
|
|
222
278
|
},
|
|
223
279
|
"recipe-guided": {
|
|
224
280
|
approach: "recipe-guided",
|
|
225
|
-
phase_sets: [
|
|
281
|
+
phase_sets: [
|
|
282
|
+
"recipe-guided-pass",
|
|
283
|
+
"refine-pass",
|
|
284
|
+
"condense-pass",
|
|
285
|
+
"review-pass",
|
|
286
|
+
"finalize-pass",
|
|
287
|
+
],
|
|
226
288
|
finalize_approach: "finalize",
|
|
227
289
|
},
|
|
228
290
|
freeform: {
|
|
229
291
|
approach: "freeform",
|
|
230
|
-
phase_sets: ["freeform-pass", "refine-pass", "review-pass", "finalize-pass"],
|
|
292
|
+
phase_sets: ["freeform-pass", "refine-pass", "condense-pass", "review-pass", "finalize-pass"],
|
|
231
293
|
finalize_approach: "finalize",
|
|
232
294
|
},
|
|
233
295
|
"rulebook-maintenance": {
|
|
234
296
|
approach: "rulebook-maintenance",
|
|
235
|
-
phase_sets: [
|
|
297
|
+
phase_sets: [
|
|
298
|
+
"rulebook-maintenance-pass",
|
|
299
|
+
"recipe-maintenance-pass",
|
|
300
|
+
"sample-maintenance-pass",
|
|
301
|
+
"template-maintenance-pass",
|
|
302
|
+
"review-pass",
|
|
303
|
+
"finalize-pass",
|
|
304
|
+
],
|
|
236
305
|
finalize_approach: "finalize",
|
|
237
306
|
},
|
|
238
307
|
"recipe-maintenance": {
|
|
@@ -254,7 +323,12 @@ export const STRATEGY_PROFILES = {
|
|
|
254
323
|
// starts at refine-pass; the pass is generated separately and blocks that first task.
|
|
255
324
|
"cross-deliverable-dedup": {
|
|
256
325
|
approach: "cross-deliverable-dedup",
|
|
257
|
-
phase_sets: ["refine-pass", "review-pass", "finalize-pass"],
|
|
326
|
+
phase_sets: ["refine-pass", "condense-pass", "review-pass", "finalize-pass"],
|
|
327
|
+
finalize_approach: "finalize",
|
|
328
|
+
},
|
|
329
|
+
condense: {
|
|
330
|
+
approach: "condense",
|
|
331
|
+
phase_sets: ["condense-pass", "review-pass", "finalize-pass"],
|
|
258
332
|
finalize_approach: "finalize",
|
|
259
333
|
},
|
|
260
334
|
finalize: {
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// bootstrap は成果物とその参考資料一式(rulebook/recipe/sample/template)を一貫した一組として
|
|
7
7
|
// 同一タスクで作成・整備する進め方(初期立ち上げ専用)。
|
|
8
8
|
// retrofit は宣言済みの実装エビデンスを現在動作の根拠として読み、成果物へ反映・新設する。
|
|
9
|
+
// condense は 1 文書の冗長さを直し、修正・保持の記録と原因を result に残す。
|
|
9
10
|
// cross-deliverable-dedup は明示した成果物群を横断して正本を選び、重複を要約と参照へ置換する。
|
|
10
11
|
// finalize は human が成果物のみを最終確認して status を ready へ確定する進め方、
|
|
11
12
|
// bootstrap-finalize は bootstrap と対になり、成果物と参考資料一式をまとめて確定する進め方。
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
export const APPROACHES = [
|
|
14
15
|
"draft",
|
|
15
16
|
"fully-guided",
|
|
17
|
+
"condense",
|
|
16
18
|
"recipe-guided",
|
|
17
19
|
"freeform",
|
|
18
20
|
"bootstrap",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isFindingCause } from "./finding-cause.js";
|
|
2
|
+
export const CONDENSE_CATEGORIES = [
|
|
3
|
+
"repetition",
|
|
4
|
+
"table-prose",
|
|
5
|
+
"figure-prose",
|
|
6
|
+
"unneeded-background",
|
|
7
|
+
"canonical-restatement",
|
|
8
|
+
];
|
|
9
|
+
export const CONDENSE_ACTIONS = ["delete", "merge", "reference", "retain"];
|
|
10
|
+
export function isCondenseRecords(value) {
|
|
11
|
+
return (Array.isArray(value) &&
|
|
12
|
+
value.length <= 100 &&
|
|
13
|
+
value.every((entry) => {
|
|
14
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
15
|
+
return false;
|
|
16
|
+
const record = entry;
|
|
17
|
+
const text = (value) => typeof value === "string" && value.trim().length > 0 && value.length <= 4000;
|
|
18
|
+
return (Object.keys(record).length === 5 &&
|
|
19
|
+
text(record.location) &&
|
|
20
|
+
text(record.reason) &&
|
|
21
|
+
CONDENSE_CATEGORIES.includes(record.category) &&
|
|
22
|
+
CONDENSE_ACTIONS.includes(record.action) &&
|
|
23
|
+
isFindingCause(record.cause));
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const warned = new Set();
|
|
2
|
+
/** Emit each compatibility warning once per CLI process, even across repeated loads. */
|
|
3
|
+
export function warnDeprecated(feature, migration) {
|
|
4
|
+
if (warned.has(feature))
|
|
5
|
+
return;
|
|
6
|
+
warned.add(feature);
|
|
7
|
+
process.stderr.write(`WARN: ${feature} is deprecated. ${migration}\n`);
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { extname } from "node:path";
|
|
3
|
+
import { load } from "./yaml.js";
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const yamlMetadata = require("../../docs/specdojo/lib/yaml-metadata.cjs");
|
|
6
|
+
export function isYamlDocument(path) {
|
|
7
|
+
return [".yaml", ".yml"].includes(extname(path).toLowerCase());
|
|
8
|
+
}
|
|
9
|
+
export function isGradeDocument(path) {
|
|
10
|
+
return extname(path).toLowerCase() === ".md" || isYamlDocument(path);
|
|
11
|
+
}
|
|
12
|
+
export function readYamlMetadata(content, path) {
|
|
13
|
+
const metadata = yamlMetadata(load(content));
|
|
14
|
+
for (const key of ["id", "type", "status", "rulebook"]) {
|
|
15
|
+
if (typeof metadata?.[key] !== "string" || !metadata[key].trim()) {
|
|
16
|
+
throw new Error(`${path}: YAML grade target requires metadata ${key} at the root or x-spec-meta`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return metadata;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function isFindingCause(value) {
|
|
2
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
3
|
+
return false;
|
|
4
|
+
const cause = value;
|
|
5
|
+
if (cause.type === "document")
|
|
6
|
+
return Object.keys(cause).length === 1;
|
|
7
|
+
return (cause.type === "kata" &&
|
|
8
|
+
typeof cause.kind === "string" &&
|
|
9
|
+
["rulebook", "recipe", "sample", "template"].includes(cause.kind) &&
|
|
10
|
+
typeof cause.location === "string" &&
|
|
11
|
+
cause.location.trim().length > 0 &&
|
|
12
|
+
Object.keys(cause).every((key) => ["type", "kind", "location"].includes(key)));
|
|
13
|
+
}
|
|
14
|
+
/** Legacy findings without a cause belong to the document. */
|
|
15
|
+
export function findingCause(finding) {
|
|
16
|
+
const cause = finding.cause;
|
|
17
|
+
return cause?.type === "kata"
|
|
18
|
+
? { type: "kata", kind: cause.kind, location: cause.location }
|
|
19
|
+
: { type: "document" };
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// SpecDojo が所有する Markdown frontmatter は `specdojo:` 名前空間配下に置く
|
|
2
|
+
// (document-metadata-standard.md)。他フレームワークの frontmatter キーとの衝突を避け、
|
|
3
|
+
// トップレベルを第三者ツールへ明け渡すための共通ユーティリティ。
|
|
4
|
+
//
|
|
5
|
+
// 対象は Markdown frontmatter のみ。独立 YAML データファイル(dct-*.yaml / pm-*.yaml /
|
|
6
|
+
// sch-*.yaml など)は名前空間化しないため、本モジュールは使わない。
|
|
7
|
+
import { load } from "./yaml.js";
|
|
8
|
+
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
9
|
+
function specdojoFromBlock(block) {
|
|
10
|
+
let parsed;
|
|
11
|
+
try {
|
|
12
|
+
parsed = load(block);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
18
|
+
return {};
|
|
19
|
+
const namespace = parsed.specdojo;
|
|
20
|
+
if (!namespace || typeof namespace !== "object" || Array.isArray(namespace))
|
|
21
|
+
return {};
|
|
22
|
+
return namespace;
|
|
23
|
+
}
|
|
24
|
+
// Markdown 文書先頭の frontmatter から `specdojo:` 名前空間オブジェクトを取り出す。
|
|
25
|
+
// frontmatter が無い / 解析不能 / `specdojo:` を欠く場合は空オブジェクトを返す。
|
|
26
|
+
export function readSpecdojoNamespace(content) {
|
|
27
|
+
const match = content.match(FRONTMATTER_RE);
|
|
28
|
+
if (!match)
|
|
29
|
+
return {};
|
|
30
|
+
return specdojoFromBlock(match[1]);
|
|
31
|
+
}
|
|
32
|
+
// readSpecdojoNamespace と同じだが、frontmatter に続く本文も返す(read-modify-write 用)。
|
|
33
|
+
export function parseSpecdojoDocument(content) {
|
|
34
|
+
const match = content.match(FRONTMATTER_RE);
|
|
35
|
+
if (!match)
|
|
36
|
+
return { data: {}, body: content };
|
|
37
|
+
return { data: specdojoFromBlock(match[1]), body: match[2] ?? "" };
|
|
38
|
+
}
|
|
39
|
+
// トップレベルの `key: value` 行群を `specdojo:` 配下へ字下げし、`---` で囲んだ
|
|
40
|
+
// frontmatter ブロック文字列にして返す。frontmatter を生成する各所で使う。
|
|
41
|
+
export function buildSpecdojoFrontmatter(innerLines) {
|
|
42
|
+
return [
|
|
43
|
+
"---",
|
|
44
|
+
"specdojo:",
|
|
45
|
+
...innerLines.map((line) => (line.length === 0 ? "" : ` ${line}`)),
|
|
46
|
+
"---",
|
|
47
|
+
].join("\n");
|
|
48
|
+
}
|
package/dist/shared/git.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { appendFileSync, lstatSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { appendFileSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, } from "node:fs";
|
|
3
3
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
4
4
|
import { gitEnvironment } from "./git-environment.js";
|
|
5
5
|
import { redactSensitiveText, stripTerminalControlSequences } from "./text.js";
|
|
@@ -10,9 +10,27 @@ export { GIT_LOCAL_ENV_VARS, gitEnvironment } from "./git-environment.js";
|
|
|
10
10
|
// for that lock, surfacing as "Unable to create '.../index.lock'". A failed lock acquisition
|
|
11
11
|
// happens before git mutates anything, so retrying the same command is safe and idempotent.
|
|
12
12
|
// 並行の run の統合や記帳と重なると、ロックは数百ミリ秒より長く保持される(PJR-G90K)。
|
|
13
|
-
//
|
|
13
|
+
// 手の commit の pre-commit hook が負荷の下で十数分ロックを握ることもあるため(PJR-964D)、
|
|
14
|
+
// 最初の 10 回は 1.5 秒間隔、その後は 5 秒間隔で、既定 20 分まで解放を待つ。
|
|
15
|
+
// ロックのファイルは消さない(実際に動いている git がありうる)。
|
|
14
16
|
export const INDEX_LOCK_RETRY_ATTEMPTS = 10;
|
|
15
17
|
export const INDEX_LOCK_RETRY_WAIT_MS = 1500;
|
|
18
|
+
export const INDEX_LOCK_LONG_RETRY_WAIT_MS = 5000;
|
|
19
|
+
export const DEFAULT_INDEX_LOCK_WAIT_MS = 20 * 60 * 1000;
|
|
20
|
+
// 待っている間の告知の間隔。最初の取り合いで 1 回告げ、その後はこの間隔で経過を出す。
|
|
21
|
+
export const INDEX_LOCK_PROGRESS_INTERVAL_MS = 30 * 1000;
|
|
22
|
+
let configuredIndexLockWaitMilliseconds = DEFAULT_INDEX_LOCK_WAIT_MS;
|
|
23
|
+
// exec-defaults の `run.git_index_lock_wait_seconds` を、この process の git 操作へ反映する。
|
|
24
|
+
// src/shared は exec を import できないため、exec 側の設定の読み込みから値を渡す。
|
|
25
|
+
export function configureIndexLockWait(milliseconds = DEFAULT_INDEX_LOCK_WAIT_MS) {
|
|
26
|
+
if (!Number.isFinite(milliseconds) || milliseconds < 0) {
|
|
27
|
+
throw new Error(`index.lock wait must be a non-negative number of milliseconds: ${milliseconds}`);
|
|
28
|
+
}
|
|
29
|
+
configuredIndexLockWaitMilliseconds = milliseconds;
|
|
30
|
+
}
|
|
31
|
+
export function indexLockWaitMilliseconds() {
|
|
32
|
+
return configuredIndexLockWaitMilliseconds;
|
|
33
|
+
}
|
|
16
34
|
// dubious ownership と、`.git` がある cwd での not-a-repository は一時的に起き、すぐの
|
|
17
35
|
// 再試行では収まらないことがある(並行実行中の統合段で確認した)。両方で上限を共有する。
|
|
18
36
|
const TRANSIENT_GIT_RETRY_DELAYS_MS = [2000, 5000, 10000];
|
|
@@ -47,6 +65,60 @@ export function isGitNotRepositoryWithGitMetadata(stderr, repoRoot) {
|
|
|
47
65
|
function sleepSync(milliseconds) {
|
|
48
66
|
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, milliseconds);
|
|
49
67
|
}
|
|
68
|
+
// 待つのをやめた理由を stderr の末尾へ足す。formatGitCommandFailure の要約は error 行を拾う。
|
|
69
|
+
function appendStderr(result, line) {
|
|
70
|
+
const stderr = typeof result.stderr === "string" ? result.stderr : "";
|
|
71
|
+
const separator = stderr === "" || stderr.endsWith("\n") ? "" : "\n";
|
|
72
|
+
return { ...result, stderr: `${stderr}${separator}${line}\n` };
|
|
73
|
+
}
|
|
74
|
+
export function formatWaitDuration(milliseconds) {
|
|
75
|
+
const totalSeconds = Math.round(milliseconds / 1000);
|
|
76
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
77
|
+
const seconds = totalSeconds % 60;
|
|
78
|
+
if (minutes === 0)
|
|
79
|
+
return `${seconds}s`;
|
|
80
|
+
return seconds === 0 ? `${minutes}m` : `${minutes}m${seconds}s`;
|
|
81
|
+
}
|
|
82
|
+
// 告知の分母。短い間隔の回数に、残りの時間を長い間隔で割った回数を足す。
|
|
83
|
+
function indexLockMaxAttempts(limitMilliseconds) {
|
|
84
|
+
const shortPhase = INDEX_LOCK_RETRY_ATTEMPTS * INDEX_LOCK_RETRY_WAIT_MS;
|
|
85
|
+
if (limitMilliseconds <= shortPhase) {
|
|
86
|
+
return Math.max(1, Math.ceil(limitMilliseconds / INDEX_LOCK_RETRY_WAIT_MS));
|
|
87
|
+
}
|
|
88
|
+
return (INDEX_LOCK_RETRY_ATTEMPTS +
|
|
89
|
+
Math.ceil((limitMilliseconds - shortPhase) / INDEX_LOCK_LONG_RETRY_WAIT_MS));
|
|
90
|
+
}
|
|
91
|
+
// Linux の /proc から、名前が git のプロセスが 1 つでも動いているかを調べる。どのプロセスが
|
|
92
|
+
// ロックを握るかを git は記録しないため、git が 1 つも動いていないときだけ「握り手がいない」と
|
|
93
|
+
// みなす(hook を実行中の git commit も git として残る)。/proc を読めない環境では undefined。
|
|
94
|
+
export function hasRunningGitProcess(procRoot = "/proc") {
|
|
95
|
+
let entries;
|
|
96
|
+
try {
|
|
97
|
+
entries = readdirSync(procRoot);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
if (!/^\d+$/.test(entry))
|
|
104
|
+
continue;
|
|
105
|
+
let name;
|
|
106
|
+
try {
|
|
107
|
+
name = readFileSync(join(procRoot, entry, "comm"), "utf8").trim();
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// 調べている間に終了したプロセスは数えない。
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (name === "git" || name.startsWith("git-"))
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
// ロックのファイルが残っていて、git のプロセスが 1 つも動いていなければ古いロックとみなす。
|
|
119
|
+
export function isIndexLockOrphaned(lockPath, procRoot = "/proc") {
|
|
120
|
+
return existsSync(lockPath) && hasRunningGitProcess(procRoot) === false;
|
|
121
|
+
}
|
|
50
122
|
export function transientGitFailureReason(stderr, repoRoot) {
|
|
51
123
|
if (isGitDubiousOwnership(stderr))
|
|
52
124
|
return "dubious ownership";
|
|
@@ -55,8 +127,13 @@ export function transientGitFailureReason(stderr, repoRoot) {
|
|
|
55
127
|
}
|
|
56
128
|
return undefined;
|
|
57
129
|
}
|
|
58
|
-
export function runGitWithTransientRetry(run, onTransientFailureRetry = () => undefined, sleep = sleepSync, repoRoot, recoverFromTransientFailure) {
|
|
130
|
+
export function runGitWithTransientRetry(run, onTransientFailureRetry = () => undefined, sleep = sleepSync, repoRoot, recoverFromTransientFailure, indexLockWait = {}) {
|
|
131
|
+
const limitMilliseconds = indexLockWait.limitMilliseconds ?? indexLockWaitMilliseconds();
|
|
132
|
+
const now = indexLockWait.now ?? Date.now;
|
|
133
|
+
const isLockOrphaned = indexLockWait.isLockOrphaned ?? isIndexLockOrphaned;
|
|
59
134
|
let indexLockRetries = 0;
|
|
135
|
+
let indexLockStartedAt;
|
|
136
|
+
let nextProgressAt = 0;
|
|
60
137
|
let transientFailureRetries = 0;
|
|
61
138
|
let result = run();
|
|
62
139
|
while (result.status !== 0) {
|
|
@@ -83,38 +160,72 @@ export function runGitWithTransientRetry(run, onTransientFailureRetry = () => un
|
|
|
83
160
|
continue;
|
|
84
161
|
}
|
|
85
162
|
}
|
|
86
|
-
if (
|
|
87
|
-
|
|
163
|
+
if (!isGitIndexLockContention(stderr))
|
|
164
|
+
break;
|
|
165
|
+
const lockPath = gitIndexLockPath(stderr);
|
|
166
|
+
indexLockStartedAt ??= now();
|
|
167
|
+
const elapsedMilliseconds = now() - indexLockStartedAt;
|
|
168
|
+
if (elapsedMilliseconds >= limitMilliseconds) {
|
|
169
|
+
return appendStderr(result, `error: index.lock was not released within ${formatWaitDuration(limitMilliseconds)}` +
|
|
170
|
+
" (run.git_index_lock_wait_seconds in exec-defaults)");
|
|
171
|
+
}
|
|
172
|
+
// 短い取り合いの間は古いロックか判断しない(git の起動と終了の合間に見えうる)。
|
|
173
|
+
if (indexLockRetries >= INDEX_LOCK_RETRY_ATTEMPTS && lockPath && isLockOrphaned(lockPath)) {
|
|
174
|
+
return appendStderr(result, `error: index.lock looks stale: no running git process holds ${lockPath}` +
|
|
175
|
+
` after ${formatWaitDuration(elapsedMilliseconds)};` +
|
|
176
|
+
" remove it after confirming no git uses the repository");
|
|
177
|
+
}
|
|
178
|
+
const interval = indexLockRetries < INDEX_LOCK_RETRY_ATTEMPTS
|
|
179
|
+
? INDEX_LOCK_RETRY_WAIT_MS
|
|
180
|
+
: INDEX_LOCK_LONG_RETRY_WAIT_MS;
|
|
181
|
+
const waitMilliseconds = Math.min(interval, limitMilliseconds - elapsedMilliseconds);
|
|
182
|
+
indexLockRetries += 1;
|
|
183
|
+
if (indexLockRetries === 1 || elapsedMilliseconds >= nextProgressAt) {
|
|
184
|
+
nextProgressAt =
|
|
185
|
+
(Math.floor(elapsedMilliseconds / INDEX_LOCK_PROGRESS_INTERVAL_MS) + 1) *
|
|
186
|
+
INDEX_LOCK_PROGRESS_INTERVAL_MS;
|
|
88
187
|
onTransientFailureRetry({
|
|
89
188
|
attempt: indexLockRetries,
|
|
90
|
-
maxAttempts:
|
|
91
|
-
waitMilliseconds
|
|
189
|
+
maxAttempts: indexLockMaxAttempts(limitMilliseconds),
|
|
190
|
+
waitMilliseconds,
|
|
92
191
|
reason: "index.lock contention",
|
|
192
|
+
elapsedMilliseconds,
|
|
193
|
+
limitMilliseconds,
|
|
194
|
+
...(lockPath ? { lockPath } : {}),
|
|
93
195
|
});
|
|
94
|
-
sleep(INDEX_LOCK_RETRY_WAIT_MS);
|
|
95
|
-
result = run();
|
|
96
|
-
continue;
|
|
97
196
|
}
|
|
98
|
-
|
|
197
|
+
sleep(waitMilliseconds);
|
|
198
|
+
result = run();
|
|
99
199
|
}
|
|
100
200
|
return result;
|
|
101
201
|
}
|
|
102
202
|
// spawnSync の既定の maxBuffer(1 MiB)では、未追跡のファイルが多い作業場所の
|
|
103
203
|
// `git status --porcelain` などが打ち切られ、子プロセスが SIGTERM で止められる。
|
|
104
204
|
export const GIT_OUTPUT_MAX_BUFFER = 256 * 1024 * 1024;
|
|
105
|
-
export function gitResult(repoRoot, args, recoverFromTransientFailure
|
|
205
|
+
export function gitResult(repoRoot, args, recoverFromTransientFailure,
|
|
206
|
+
// 隔離済みの Git 環境へ足す変数(統合の commit の LEFTHOOK_EXCLUDE など)。
|
|
207
|
+
extraEnv) {
|
|
106
208
|
const cwd = resolve(repoRoot);
|
|
107
209
|
const run = () => spawnSync("git", ["-C", cwd, ...args], {
|
|
108
210
|
// `-C` だけに依存せず、子プロセス自体も対象 repository から起動する。linked worktree の
|
|
109
211
|
// `.git` が相対 gitdir の場合も、resume 中の diff を runner の cwd から切り離す。
|
|
110
212
|
cwd,
|
|
111
213
|
encoding: "utf8",
|
|
112
|
-
env: gitEnvironment(),
|
|
214
|
+
env: { ...gitEnvironment(), ...extraEnv },
|
|
113
215
|
maxBuffer: GIT_OUTPUT_MAX_BUFFER,
|
|
114
216
|
stdio: ["ignore", "pipe", "pipe"],
|
|
115
217
|
});
|
|
116
|
-
return runGitWithTransientRetry(run, (
|
|
218
|
+
return runGitWithTransientRetry(run, (notice) => {
|
|
219
|
+
const { attempt, maxAttempts, waitMilliseconds, reason } = notice;
|
|
117
220
|
const summary = summarizeGitArguments(args);
|
|
221
|
+
if (notice.elapsedMilliseconds !== undefined && notice.limitMilliseconds !== undefined) {
|
|
222
|
+
const lock = notice.lockPath ? `, lock: ${notice.lockPath}` : "";
|
|
223
|
+
process.stderr.write("warning: waiting for index.lock to be released" +
|
|
224
|
+
` (elapsed ${formatWaitDuration(notice.elapsedMilliseconds)}` +
|
|
225
|
+
` / limit ${formatWaitDuration(notice.limitMilliseconds)}${lock}` +
|
|
226
|
+
`, cwd: ${repoRoot}${summary ? `, args: ${summary}` : ""})\n`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
118
229
|
process.stderr.write(`warning: git command failed with ${reason}; retrying in ${waitMilliseconds / 1000}s` +
|
|
119
230
|
` (attempt ${attempt}/${maxAttempts}, cwd: ${repoRoot}${summary ? `, args: ${summary}` : ""})\n`);
|
|
120
231
|
}, sleepSync, cwd, recoverFromTransientFailure);
|
|
@@ -194,7 +305,11 @@ export function formatGitCommandFailure(args, stderr, processFailure = "") {
|
|
|
194
305
|
// gitResult は index.lock の取り合いをやり直したうえで失敗を返す。どのロックが残っていたかを
|
|
195
306
|
// 要約の切り詰めに左右されず先頭に残す(ロックは runner が消さないため、人が確かめる手掛かり)。
|
|
196
307
|
const lockPath = isGitIndexLockContention(stderr) ? gitIndexLockPath(stderr) : undefined;
|
|
197
|
-
|
|
308
|
+
// 原因の候補: 手の commit などの hook がまだ動いている、または異常終了した git の古いロック。
|
|
309
|
+
const lockNotice = lockPath
|
|
310
|
+
? `index.lock is still held (lock: ${lockPath};` +
|
|
311
|
+
" a git hook such as pre-commit may still be running, or a crashed git left a stale lock)"
|
|
312
|
+
: "";
|
|
198
313
|
const cause = [processFailure.trim(), lockNotice, summarizeGitStderr(stderr)]
|
|
199
314
|
.filter((part) => part !== "")
|
|
200
315
|
.join(" / ");
|
|
@@ -352,3 +467,15 @@ export function unstageCommitTargets(repoRoot, paths) {
|
|
|
352
467
|
return;
|
|
353
468
|
gitOutput(repoRoot, ["reset", "--quiet", "--", ...unique]);
|
|
354
469
|
}
|
|
470
|
+
// A non-fast-forward merge requires a clean index even when staged paths do not overlap the
|
|
471
|
+
// incoming diff. Never reset or commit another operation's staged work on its behalf.
|
|
472
|
+
export function stagedMergeBlocker(repoRoot) {
|
|
473
|
+
const paths = gitOutput(repoRoot, ["diff", "--cached", "--no-renames", "--name-only", "-z"])
|
|
474
|
+
.split("\0")
|
|
475
|
+
.filter(Boolean);
|
|
476
|
+
if (paths.length === 0)
|
|
477
|
+
return undefined;
|
|
478
|
+
return (`Staged changes in integration target ${repoRoot}: ${paths.join(", ")}. ` +
|
|
479
|
+
`Commit them, or run git restore --staged -- <path> for each listed path in that worktree ` +
|
|
480
|
+
`(file contents are preserved), then retry integration.`);
|
|
481
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { isYamlDocument, readYamlMetadata } from "./document-metadata.js";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
3
|
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
3
4
|
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
5
|
import { load } from "./yaml.js";
|
|
6
|
+
import { isFindingCause } from "./finding-cause.js";
|
|
5
7
|
import { getProjectExecutionPath, loadConfig, resolveRepoRoot, specdojoRootDir, } from "./specdojo-config.js";
|
|
6
8
|
const DOCUMENT_ID_RE = /^[a-z0-9][a-z0-9-:]*$/;
|
|
7
9
|
export const SEVERITIES = ["blocker", "major", "minor", "note"];
|
|
@@ -23,6 +25,15 @@ export function markdownDocumentId(content, path) {
|
|
|
23
25
|
}
|
|
24
26
|
return id;
|
|
25
27
|
}
|
|
28
|
+
export function gradeDocumentId(content, path) {
|
|
29
|
+
if (!isYamlDocument(path))
|
|
30
|
+
return markdownDocumentId(content, path);
|
|
31
|
+
const id = readYamlMetadata(content, path).id;
|
|
32
|
+
if (typeof id !== "string" || !DOCUMENT_ID_RE.test(id)) {
|
|
33
|
+
throw new Error(`${path}: YAML metadata id is required to store a grade result`);
|
|
34
|
+
}
|
|
35
|
+
return id;
|
|
36
|
+
}
|
|
26
37
|
export function resolveGradeResultsDirectory(projectOption, rootDir = specdojoRootDir()) {
|
|
27
38
|
const { config } = loadConfig(rootDir);
|
|
28
39
|
if (!config)
|
|
@@ -66,7 +77,7 @@ export function gradeResultPathForDocument(opts) {
|
|
|
66
77
|
const resultsDirectory = opts.resultsDirectory
|
|
67
78
|
? resolve(rootDir, opts.resultsDirectory)
|
|
68
79
|
: resolveGradeResultsDirectory(opts.project, rootDir);
|
|
69
|
-
return gradeResultPath(repo ? join(resultsDirectory, repo.name) : resultsDirectory,
|
|
80
|
+
return gradeResultPath(repo ? join(resultsDirectory, repo.name) : resultsDirectory, gradeDocumentId(content, opts.documentPath));
|
|
70
81
|
}
|
|
71
82
|
export function parseGradeResult(content, path) {
|
|
72
83
|
const parsed = load(content);
|
|
@@ -94,6 +105,11 @@ export function parseGradeResult(content, path) {
|
|
|
94
105
|
Object.values(result.source_hashes).some((hash) => typeof hash !== "string" || !/^[a-f0-9]{64}$/.test(hash)))) {
|
|
95
106
|
throw new Error(`${path}: source_hashes must map sources to SHA-256 hex digests`);
|
|
96
107
|
}
|
|
108
|
+
for (const finding of result.findings) {
|
|
109
|
+
if (finding.cause !== undefined && !isFindingCause(finding.cause)) {
|
|
110
|
+
throw new Error(`${path}: invalid finding cause`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
97
113
|
return result;
|
|
98
114
|
}
|
|
99
115
|
export function gradeFindingDisplayMessage(finding) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { realpathSync } from "node:fs";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
6
|
+
import { gitEnvironment } from "./git-environment.js";
|
|
7
|
+
/** Machine-local state, shared by linked worktrees, never part of the repository tree. */
|
|
8
|
+
export function localStateDirectory(repoRoot) {
|
|
9
|
+
const common = spawnSync("git", ["rev-parse", "--git-common-dir"], {
|
|
10
|
+
cwd: repoRoot,
|
|
11
|
+
encoding: "utf8",
|
|
12
|
+
env: gitEnvironment(),
|
|
13
|
+
});
|
|
14
|
+
const identity = common.status === 0 ? resolve(repoRoot, common.stdout.trim()) : resolve(repoRoot);
|
|
15
|
+
const canonical = realpathSync(identity);
|
|
16
|
+
const key = createHash("sha256").update(canonical).digest("hex");
|
|
17
|
+
const configured = process.env.XDG_STATE_HOME;
|
|
18
|
+
const base = configured && isAbsolute(configured) ? configured : join(homedir(), ".local", "state");
|
|
19
|
+
return join(base, "specdojo", key);
|
|
20
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
4
|
import { dump } from "js-yaml";
|
|
4
5
|
// Keep the fallback result check and every scaffold on the same document rules.
|
|
5
6
|
export const DEFAULT_MARKDOWNLINT_CONFIG = {
|
|
@@ -15,10 +16,14 @@ export function hasMarkdownlintConfig(repoRoot) {
|
|
|
15
16
|
if (["jsonc", "json", "yaml", "yml"].some((ext) => existsSync(join(repoRoot, `.markdownlint.${ext}`))))
|
|
16
17
|
return true;
|
|
17
18
|
// markdownlint-cli also discovers .markdownlintrc in parent directories.
|
|
18
|
-
|
|
19
|
+
// ただし一時ディレクトリのルート(/tmp など)や Git リポジトリ境界を越えて親を辿らない。
|
|
20
|
+
const systemTmp = resolve(tmpdir());
|
|
21
|
+
for (let dir = resolve(repoRoot);; dir = dirname(dir)) {
|
|
19
22
|
if (existsSync(join(dir, ".markdownlintrc")))
|
|
20
23
|
return true;
|
|
21
|
-
if (dirname(dir) === dir)
|
|
24
|
+
if (dirname(dir) === dir || dir === systemTmp)
|
|
25
|
+
return false;
|
|
26
|
+
if (existsSync(join(dir, ".git")))
|
|
22
27
|
return false;
|
|
23
28
|
}
|
|
24
29
|
}
|