specdojo 0.1.0 → 0.2.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/LICENSE +22 -0
- package/README.md +82 -38
- package/dist/agent-response.js +27 -0
- package/dist/agent.js +124 -0
- package/dist/build-command.js +149 -0
- package/dist/build-if-stale.js +35 -0
- package/dist/catalog-build.js +1079 -0
- package/dist/catalog-generate.js +226 -0
- package/dist/catalog-paths.js +31 -0
- package/dist/catalog-plan-generate.js +301 -0
- package/dist/catalog-plan-prompt.js +73 -0
- package/dist/catalog-plan.js +471 -0
- package/dist/catalog-scaffold.js +255 -0
- package/dist/catalog-types.js +4 -0
- package/dist/catalog.js +606 -0
- package/dist/dashboard.js +980 -0
- package/dist/deliverable-trash.js +148 -0
- package/dist/deliverable.js +97 -0
- package/dist/dist-freshness.js +150 -0
- package/dist/doc-index.js +424 -0
- package/dist/exec-agent-config.js +172 -0
- package/dist/exec-agent-git-state.js +136 -0
- package/dist/exec-agent-protected-config.js +276 -0
- package/dist/exec-events.js +250 -112
- package/dist/exec-evidence.js +317 -0
- package/dist/exec-format.js +45 -0
- package/dist/exec-limit.js +202 -0
- package/dist/exec-parent-validation.js +169 -0
- package/dist/exec-pipeline-state.js +160 -0
- package/dist/exec-plans.js +1016 -0
- package/dist/exec-project.js +25 -11
- package/dist/exec-protection-handoff.js +169 -0
- package/dist/exec-provider-scaffold.js +99 -0
- package/dist/exec-register-resume.js +196 -0
- package/dist/exec-register.js +281 -0
- package/dist/exec-reporter.js +329 -0
- package/dist/exec-results.js +510 -0
- package/dist/exec-run-lock.js +149 -0
- package/dist/exec-run.js +4953 -0
- package/dist/exec-schedule-calendar.js +86 -9
- package/dist/exec-schedule-cpm.js +30 -12
- package/dist/exec-schedule-gantt-chart-render.js +428 -0
- package/dist/exec-schedule-gantt-chart-scope.js +111 -0
- package/dist/exec-schedule-gantt-chart.js +2 -0
- package/dist/exec-schedule-hash.js +34 -25
- package/dist/exec-schedule-index.js +200 -67
- package/dist/exec-schedule-initial.js +100 -0
- package/dist/exec-schedule-progress.js +51 -26
- package/dist/exec-schedule-ready.js +71 -27
- package/dist/exec-schedule.js +171 -93
- package/dist/exec-shared.js +146 -25
- package/dist/exec-strategy.js +547 -0
- package/dist/exec-task-view.js +64 -0
- package/dist/exec-trial.js +895 -0
- package/dist/exec-worktree-command.js +426 -0
- package/dist/exec-worktree-ops.js +847 -0
- package/dist/exec-worktree.js +359 -0
- package/dist/exec.js +744 -192
- package/dist/frontmatter-namespace.js +48 -0
- package/dist/git-environment.js +23 -0
- package/dist/grade-result.js +137 -0
- package/dist/grade.js +2456 -0
- package/dist/index-command.js +103 -0
- package/dist/job.js +1081 -0
- package/dist/kata-command.js +303 -0
- package/dist/kata.js +187 -0
- package/dist/package-paths.js +15 -0
- package/dist/practice-id.js +24 -0
- package/dist/register-date.js +122 -0
- package/dist/register-events.js +363 -0
- package/dist/register-history.js +323 -0
- package/dist/register-item.js +455 -0
- package/dist/register-migrate-timestamps.js +176 -0
- package/dist/register.js +2199 -0
- package/dist/review-plan.js +199 -0
- package/dist/review-types.js +1 -0
- package/dist/role-types.js +1 -0
- package/dist/routine.js +814 -0
- package/dist/schedule-approach.js +252 -0
- package/dist/schedule-build.js +552 -0
- package/dist/schedule-phase-sets.js +73 -0
- package/dist/schedule-strategy-generate.js +812 -0
- package/dist/schedule-strategy-profiles.js +276 -0
- package/dist/schedule.js +420 -0
- package/dist/spawn-self.js +28 -0
- package/dist/specdojo-config.js +133 -39
- package/dist/specdojo.js +55 -7
- package/dist/template-frontmatter.js +89 -0
- package/dist/template-resolution.js +92 -0
- package/dist/timeline-build.js +334 -0
- package/dist/timeline.js +107 -0
- package/dist/watch.js +313 -0
- package/dist/yaml-pages-command.js +28 -0
- package/dist/yaml-pages.js +180 -0
- package/dist/yaml-schema-modeline.js +49 -0
- package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +600 -0
- package/docs/ja/specdojo/exec-templates/xep-bootstrap-template.md +120 -0
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +37 -0
- package/docs/ja/specdojo/exec-templates/xep-cross-deliverable-dedup-template.md +51 -0
- package/docs/ja/specdojo/exec-templates/xep-freeform-template.md +74 -0
- package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +109 -0
- package/docs/ja/specdojo/exec-templates/xep-job-template.md +43 -0
- package/docs/ja/specdojo/exec-templates/xep-recipe-guided-template.md +82 -0
- package/docs/ja/specdojo/exec-templates/xep-recipe-maintenance-template.md +86 -0
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +42 -0
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +49 -0
- package/docs/ja/specdojo/exec-templates/xep-retrofit-template.md +98 -0
- package/docs/ja/specdojo/exec-templates/xep-rulebook-maintenance-template.md +86 -0
- package/docs/ja/specdojo/exec-templates/xep-sample-maintenance-template.md +86 -0
- package/docs/ja/specdojo/exec-templates/xep-template-maintenance-template.md +86 -0
- package/docs/ja/specdojo/exec-templates/xep-template.md +66 -0
- package/docs/ja/specdojo/exec-templates/xer-cross-deliverable-dedup-template.md +31 -0
- package/docs/ja/specdojo/exec-templates/xer-human-bootstrap-finalize-template.md +40 -0
- package/docs/ja/specdojo/exec-templates/xer-human-finalize-template.md +30 -0
- package/docs/ja/specdojo/exec-templates/xer-template.md +19 -0
- package/docs/ja/specdojo/exec-templates/xrp-freeform-template.md +70 -0
- package/docs/ja/specdojo/exec-templates/xrp-fully-guided-template.md +97 -0
- package/docs/ja/specdojo/exec-templates/xrp-recipe-guided-template.md +76 -0
- package/docs/ja/specdojo/exec-templates/xrp-recipe-maintenance-template.md +73 -0
- package/docs/ja/specdojo/exec-templates/xrp-retrofit-template.md +74 -0
- package/docs/ja/specdojo/exec-templates/xrp-rulebook-maintenance-template.md +74 -0
- package/docs/ja/specdojo/exec-templates/xrp-sample-maintenance-template.md +73 -0
- package/docs/ja/specdojo/exec-templates/xrp-template-maintenance-template.md +73 -0
- package/docs/ja/specdojo/exec-templates/xrp-template.md +67 -0
- package/docs/ja/specdojo/exec-templates/xrp-viewpoint-detail-template.md +7 -0
- package/docs/ja/specdojo/exec-templates/xrr-template.md +21 -0
- package/docs/ja/specdojo/exec-templates/xrr-viewpoint-detail-template.md +7 -0
- package/docs/ja/specdojo/guides/branch-workflow-guide.md +354 -0
- package/docs/ja/specdojo/guides/docs-editing-guide.md +327 -0
- package/docs/ja/specdojo/guides/docs-structure-guide.md +519 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +589 -0
- package/docs/ja/specdojo/guides/exec-operation-guide.md +440 -0
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +318 -0
- package/docs/ja/specdojo/guides/kata-guide.md +89 -0
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +127 -0
- package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +228 -0
- package/docs/ja/specdojo/guides/practice-system-composition-guide.md +111 -0
- package/docs/ja/specdojo/guides/quick-start-guide.md +473 -0
- package/docs/ja/specdojo/guides/register-operation-guide.md +418 -0
- package/docs/ja/specdojo/guides/review-guide.md +428 -0
- package/docs/ja/specdojo/guides/routine-operation-guide.md +282 -0
- package/docs/ja/specdojo/guides/ryu-guide.md +230 -0
- package/docs/ja/specdojo/guides/schedule-design-guide.md +429 -0
- package/docs/ja/specdojo/guides/schedule-operation-guide.md +151 -0
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +257 -0
- package/docs/ja/specdojo/guides/timeline-design-guide.md +160 -0
- package/docs/ja/specdojo/guides/track-design-guide.md +215 -0
- package/docs/ja/specdojo/guides/use-case-guide.md +133 -0
- package/docs/ja/specdojo/guides/waza-guide.md +224 -0
- package/docs/ja/specdojo/index.md +33 -0
- package/docs/ja/specdojo/philosophy/needs-to-implementation-philosophy.md +212 -0
- package/docs/ja/specdojo/philosophy/specdojo-philosophy.md +242 -0
- package/docs/ja/specdojo/recipes/cdfd-overview-recipe.md +198 -0
- package/docs/ja/specdojo/recipes/cdfd-recipe.md +218 -0
- package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +198 -0
- package/docs/ja/specdojo/recipes/exec-human-finalize-recipe.md +100 -0
- package/docs/ja/specdojo/recipes/ifx-cmd-recipe.md +148 -0
- package/docs/ja/specdojo/recipes/pm-communication-plan-recipe.md +97 -0
- package/docs/ja/specdojo/recipes/pm-members-recipe.md +149 -0
- package/docs/ja/specdojo/recipes/pm-organization-recipe.md +96 -0
- package/docs/ja/specdojo/recipes/pm-plan-recipe.md +98 -0
- package/docs/ja/specdojo/recipes/pm-quality-management-plan-recipe.md +97 -0
- package/docs/ja/specdojo/recipes/pm-raci-recipe.md +96 -0
- package/docs/ja/specdojo/recipes/pm-roles-recipe.md +136 -0
- package/docs/ja/specdojo/recipes/prj-assumptions-constraints-dependencies-recipe.md +162 -0
- package/docs/ja/specdojo/recipes/prj-charter-recipe.md +187 -0
- package/docs/ja/specdojo/recipes/prj-comparison-of-alternatives-recipe.md +235 -0
- package/docs/ja/specdojo/recipes/prj-issues-and-approach-recipe.md +205 -0
- package/docs/ja/specdojo/recipes/prj-overview-recipe.md +289 -0
- package/docs/ja/specdojo/recipes/prj-scope-recipe.md +201 -0
- package/docs/ja/specdojo/recipes/prj-stakeholder-register-recipe.md +168 -0
- package/docs/ja/specdojo/recipes/prj-success-criteria-and-acceptance-criteria-recipe.md +179 -0
- package/docs/ja/specdojo/recipes/stsd-recipe.md +138 -0
- package/docs/ja/specdojo/references/command-reference.md +718 -0
- package/docs/ja/specdojo/references/deliverables-reference.md +407 -0
- package/docs/ja/specdojo/references/directory-layout-reference.md +280 -0
- package/docs/ja/specdojo/references/specdojo-config-reference.md +133 -0
- package/docs/ja/specdojo/rulebooks/atc-index-rulebook.md +372 -0
- package/docs/ja/specdojo/rulebooks/atc-rulebook.md +302 -0
- package/docs/ja/specdojo/rulebooks/bac-rulebook.md +331 -0
- package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +134 -0
- package/docs/ja/specdojo/rulebooks/bds-rulebook.md +207 -0
- package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +102 -0
- package/docs/ja/specdojo/rulebooks/bes-rulebook.md +131 -0
- package/docs/ja/specdojo/rulebooks/bps-rulebook.md +269 -0
- package/docs/ja/specdojo/rulebooks/br-rulebook.md +187 -0
- package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +279 -0
- package/docs/ja/specdojo/rulebooks/cdfd-mermaid-rulebook.md +219 -0
- package/docs/ja/specdojo/rulebooks/cdfd-overview-rulebook.md +233 -0
- package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +182 -0
- package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +171 -0
- package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +105 -0
- package/docs/ja/specdojo/rulebooks/cld-rulebook.md +195 -0
- package/docs/ja/specdojo/rulebooks/cnd-mermaid-rulebook.md +285 -0
- package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +292 -0
- package/docs/ja/specdojo/rulebooks/cop-index-rulebook.md +171 -0
- package/docs/ja/specdojo/rulebooks/cop-rulebook.md +325 -0
- package/docs/ja/specdojo/rulebooks/cpd-mermaid-rulebook.md +266 -0
- package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +294 -0
- package/docs/ja/specdojo/rulebooks/cstd-rulebook.md +21 -0
- package/docs/ja/specdojo/rulebooks/cxd-mermaid-rulebook.md +401 -0
- package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +311 -0
- package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +158 -0
- package/docs/ja/specdojo/rulebooks/dct-rulebook.md +287 -0
- package/docs/ja/specdojo/rulebooks/dec-rulebook.md +62 -0
- package/docs/ja/specdojo/rulebooks/dmd-index-rulebook.md +100 -0
- package/docs/ja/specdojo/rulebooks/dmd-rulebook.md +298 -0
- package/docs/ja/specdojo/rulebooks/etc-index-rulebook.md +379 -0
- package/docs/ja/specdojo/rulebooks/etc-rulebook.md +310 -0
- package/docs/ja/specdojo/rulebooks/gl-rulebook.md +86 -0
- package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +297 -0
- package/docs/ja/specdojo/rulebooks/ifx-api-rulebook.md +79 -0
- package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +213 -0
- package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +311 -0
- package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +94 -0
- package/docs/ja/specdojo/rulebooks/ifx-msg-rulebook.md +81 -0
- package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +117 -0
- package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +118 -0
- package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +116 -0
- package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +116 -0
- package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +116 -0
- package/docs/ja/specdojo/rulebooks/itc-index-rulebook.md +421 -0
- package/docs/ja/specdojo/rulebooks/itc-rulebook.md +307 -0
- package/docs/ja/specdojo/rulebooks/mip-index-rulebook.md +312 -0
- package/docs/ja/specdojo/rulebooks/mm-rulebook.md +63 -0
- package/docs/ja/specdojo/rulebooks/mtp-rulebook.md +353 -0
- package/docs/ja/specdojo/rulebooks/nfr-availability-rulebook.md +184 -0
- package/docs/ja/specdojo/rulebooks/nfr-index-rulebook.md +179 -0
- package/docs/ja/specdojo/rulebooks/nfr-integrity-rulebook.md +184 -0
- package/docs/ja/specdojo/rulebooks/nfr-maintainability-rulebook.md +183 -0
- package/docs/ja/specdojo/rulebooks/nfr-operations-rulebook.md +185 -0
- package/docs/ja/specdojo/rulebooks/nfr-performance-rulebook.md +185 -0
- package/docs/ja/specdojo/rulebooks/nfr-reliability-rulebook.md +186 -0
- package/docs/ja/specdojo/rulebooks/nfr-security-safety-rulebook.md +186 -0
- package/docs/ja/specdojo/rulebooks/nfr-usability-rulebook.md +184 -0
- package/docs/ja/specdojo/rulebooks/ntp-rulebook.md +61 -0
- package/docs/ja/specdojo/rulebooks/opd-index-rulebook.md +84 -0
- package/docs/ja/specdojo/rulebooks/opd-rulebook.md +357 -0
- package/docs/ja/specdojo/rulebooks/opr-index-rulebook.md +80 -0
- package/docs/ja/specdojo/rulebooks/opr-rulebook.md +484 -0
- package/docs/ja/specdojo/rulebooks/otp-index-rulebook.md +120 -0
- package/docs/ja/specdojo/rulebooks/otp-rulebook.md +293 -0
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +211 -0
- package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +94 -0
- package/docs/ja/specdojo/rulebooks/pm-communication-plan-rulebook.md +116 -0
- package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +93 -0
- package/docs/ja/specdojo/rulebooks/pm-members-rulebook.md +190 -0
- package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +108 -0
- package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +122 -0
- package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +117 -0
- package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +116 -0
- package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +93 -0
- package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +146 -0
- package/docs/ja/specdojo/rulebooks/pr-rulebook.md +65 -0
- package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +178 -0
- package/docs/ja/specdojo/rulebooks/prj-charter-rulebook.md +232 -0
- package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +235 -0
- package/docs/ja/specdojo/rulebooks/prj-issues-and-approach-rulebook.md +242 -0
- package/docs/ja/specdojo/rulebooks/prj-overview-rulebook.md +187 -0
- package/docs/ja/specdojo/rulebooks/prj-scope-rulebook.md +201 -0
- package/docs/ja/specdojo/rulebooks/prj-stakeholder-register-rulebook.md +165 -0
- package/docs/ja/specdojo/rulebooks/prj-success-criteria-and-acceptance-criteria-rulebook.md +165 -0
- package/docs/ja/specdojo/rulebooks/sac-rulebook.md +202 -0
- package/docs/ja/specdojo/rulebooks/sch-rulebook.md +139 -0
- package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +63 -0
- package/docs/ja/specdojo/rulebooks/sf-rulebook.md +93 -0
- package/docs/ja/specdojo/rulebooks/sld-rulebook.md +93 -0
- package/docs/ja/specdojo/rulebooks/stc-index-rulebook.md +329 -0
- package/docs/ja/specdojo/rulebooks/stc-rulebook.md +297 -0
- package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +132 -0
- package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +215 -0
- package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +376 -0
- package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +313 -0
- package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +246 -0
- package/docs/ja/specdojo/rulebooks/sysd-rulebook.md +119 -0
- package/docs/ja/specdojo/rulebooks/tml-rulebook.md +188 -0
- package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +114 -0
- package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +117 -0
- package/docs/ja/specdojo/rulebooks/tsd-index-rulebook.md +101 -0
- package/docs/ja/specdojo/rulebooks/tsd-rulebook.md +103 -0
- package/docs/ja/specdojo/rulebooks/tsp-index-rulebook.md +396 -0
- package/docs/ja/specdojo/rulebooks/uis-rulebook.md +207 -0
- package/docs/ja/specdojo/rulebooks/utc-index-rulebook.md +387 -0
- package/docs/ja/specdojo/rulebooks/utc-rulebook.md +303 -0
- package/docs/ja/specdojo/samples/atc-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/atc-sample.md +41 -0
- package/docs/ja/specdojo/samples/bac-sample.md +38 -0
- package/docs/ja/specdojo/samples/bdd-sample.yaml +71 -0
- package/docs/ja/specdojo/samples/bds-sample.md +38 -0
- package/docs/ja/specdojo/samples/bes-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/bes-sample.md +38 -0
- package/docs/ja/specdojo/samples/bps-sample.md +38 -0
- package/docs/ja/specdojo/samples/br-sample.md +40 -0
- package/docs/ja/specdojo/samples/ccd-sample.md +38 -0
- package/docs/ja/specdojo/samples/cdfd-overview-sample.md +284 -0
- package/docs/ja/specdojo/samples/cdfd-sample.md +229 -0
- package/docs/ja/specdojo/samples/cdfd-uc-sample.md +146 -0
- package/docs/ja/specdojo/samples/cdsd-sample.md +38 -0
- package/docs/ja/specdojo/samples/cld-sample.md +38 -0
- package/docs/ja/specdojo/samples/cnd-sample.md +38 -0
- package/docs/ja/specdojo/samples/cop-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/cop-sample.md +38 -0
- package/docs/ja/specdojo/samples/cpd-sample.md +38 -0
- package/docs/ja/specdojo/samples/cstd-sample.md +11 -0
- package/docs/ja/specdojo/samples/cxd-sample.md +38 -0
- package/docs/ja/specdojo/samples/dct-index-sample.yaml +39 -0
- package/docs/ja/specdojo/samples/dct-sample.yaml +91 -0
- package/docs/ja/specdojo/samples/dec-sample.md +39 -0
- package/docs/ja/specdojo/samples/dmd-index-sample.md +50 -0
- package/docs/ja/specdojo/samples/dmd-sample.md +74 -0
- package/docs/ja/specdojo/samples/etc-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/etc-sample.md +38 -0
- package/docs/ja/specdojo/samples/gl-sample.yaml +37 -0
- package/docs/ja/specdojo/samples/ifd-sample.md +38 -0
- package/docs/ja/specdojo/samples/ifx-api-sample.yaml +102 -0
- package/docs/ja/specdojo/samples/ifx-cmd-sample.yaml +107 -0
- package/docs/ja/specdojo/samples/ifx-file-sample.md +38 -0
- package/docs/ja/specdojo/samples/ifx-msg-sample.yaml +89 -0
- package/docs/ja/specdojo/samples/imp-business-sample.md +66 -0
- package/docs/ja/specdojo/samples/imp-data-sample.md +60 -0
- package/docs/ja/specdojo/samples/imp-interface-sample.md +60 -0
- package/docs/ja/specdojo/samples/imp-operations-sample.md +60 -0
- package/docs/ja/specdojo/samples/imp-test-sample.md +60 -0
- package/docs/ja/specdojo/samples/itc-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/itc-sample.md +38 -0
- package/docs/ja/specdojo/samples/mip-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/mm-sample.md +35 -0
- package/docs/ja/specdojo/samples/mtp-sample.md +38 -0
- package/docs/ja/specdojo/samples/nfr-availability-sample.md +38 -0
- package/docs/ja/specdojo/samples/nfr-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/nfr-integrity-sample.md +38 -0
- package/docs/ja/specdojo/samples/nfr-maintainability-sample.md +38 -0
- package/docs/ja/specdojo/samples/nfr-operations-sample.md +38 -0
- package/docs/ja/specdojo/samples/nfr-performance-sample.md +38 -0
- package/docs/ja/specdojo/samples/nfr-reliability-sample.md +38 -0
- package/docs/ja/specdojo/samples/nfr-security-safety-sample.md +38 -0
- package/docs/ja/specdojo/samples/nfr-usability-sample.md +38 -0
- package/docs/ja/specdojo/samples/ntp-sample.md +38 -0
- package/docs/ja/specdojo/samples/opd-access-control-sample.md +29 -0
- package/docs/ja/specdojo/samples/opd-incident-management-sample.md +31 -0
- package/docs/ja/specdojo/samples/opd-index-sample.md +41 -0
- package/docs/ja/specdojo/samples/opd-monitoring-sample.md +32 -0
- package/docs/ja/specdojo/samples/opd-sample.md +38 -0
- package/docs/ja/specdojo/samples/opr-access-control-sample.md +24 -0
- package/docs/ja/specdojo/samples/opr-backup-restore-sample.md +27 -0
- package/docs/ja/specdojo/samples/opr-batch-sample.md +23 -0
- package/docs/ja/specdojo/samples/opr-change-sample.md +24 -0
- package/docs/ja/specdojo/samples/opr-incident-sample.md +38 -0
- package/docs/ja/specdojo/samples/opr-index-sample.md +43 -0
- package/docs/ja/specdojo/samples/opr-monitoring-sample.md +27 -0
- package/docs/ja/specdojo/samples/opr-sample.md +38 -0
- package/docs/ja/specdojo/samples/opr-support-sample.md +23 -0
- package/docs/ja/specdojo/samples/otp-index-sample.md +66 -0
- package/docs/ja/specdojo/samples/otp-sample.md +68 -0
- package/docs/ja/specdojo/samples/pm-change-request-log-sample.md +47 -0
- package/docs/ja/specdojo/samples/pm-communication-plan-sample.md +46 -0
- package/docs/ja/specdojo/samples/pm-issue-log-sample.md +45 -0
- package/docs/ja/specdojo/samples/pm-members-sample.yaml +103 -0
- package/docs/ja/specdojo/samples/pm-organization-sample.md +46 -0
- package/docs/ja/specdojo/samples/pm-plan-sample.md +57 -0
- package/docs/ja/specdojo/samples/pm-quality-management-plan-sample.md +52 -0
- package/docs/ja/specdojo/samples/pm-raci-sample.md +57 -0
- package/docs/ja/specdojo/samples/pm-risk-register-sample.md +43 -0
- package/docs/ja/specdojo/samples/pm-roles-sample.yaml +41 -0
- package/docs/ja/specdojo/samples/pr-sample.md +39 -0
- package/docs/ja/specdojo/samples/prj-assumptions-constraints-dependencies-sample.md +57 -0
- package/docs/ja/specdojo/samples/prj-charter-sample.md +121 -0
- package/docs/ja/specdojo/samples/prj-comparison-of-alternatives-sample.md +105 -0
- package/docs/ja/specdojo/samples/prj-issues-and-approach-sample.md +78 -0
- package/docs/ja/specdojo/samples/prj-overview-sample.md +95 -0
- package/docs/ja/specdojo/samples/prj-scope-sample.md +71 -0
- package/docs/ja/specdojo/samples/prj-stakeholder-register-sample.md +60 -0
- package/docs/ja/specdojo/samples/prj-success-criteria-and-acceptance-criteria-sample.md +62 -0
- package/docs/ja/specdojo/samples/sac-sample.md +38 -0
- package/docs/ja/specdojo/samples/sf-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/sf-sample.md +38 -0
- package/docs/ja/specdojo/samples/sld-sample.md +38 -0
- package/docs/ja/specdojo/samples/stc-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/stc-sample.md +38 -0
- package/docs/ja/specdojo/samples/stsd-sample.md +58 -0
- package/docs/ja/specdojo/samples/sysd-critical-flows-sample.md +38 -0
- package/docs/ja/specdojo/samples/sysd-cross-cutting-policy-sample.md +38 -0
- package/docs/ja/specdojo/samples/sysd-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/trc-requirements-to-specs-sample.md +56 -0
- package/docs/ja/specdojo/samples/trc-requirements-to-tests-sample.md +56 -0
- package/docs/ja/specdojo/samples/tsd-index-sample.md +29 -0
- package/docs/ja/specdojo/samples/tsd-sample.md +38 -0
- package/docs/ja/specdojo/samples/tsp-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/uis-sample.md +38 -0
- package/docs/ja/specdojo/samples/utc-index-sample.md +38 -0
- package/docs/ja/specdojo/samples/utc-sample.md +38 -0
- package/docs/ja/specdojo/schemas/v1/guide-content.schema.yaml +20 -0
- package/docs/ja/specdojo/schemas/v1/philosophy-content.schema.yaml +21 -0
- package/docs/ja/specdojo/schemas/v1/reference-content.schema.yaml +21 -0
- package/docs/ja/specdojo/standards/document-metadata-standard.md +323 -0
- package/docs/ja/specdojo/standards/exec-human-finalize-standard.md +75 -0
- package/docs/ja/specdojo/standards/git-branching-standard.md +227 -0
- package/docs/ja/specdojo/standards/guide-authoring-standard.md +124 -0
- package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +929 -0
- package/docs/ja/specdojo/standards/job-definition-standard.md +148 -0
- package/docs/ja/specdojo/standards/people-and-organization-definition-standard.md +431 -0
- package/docs/ja/specdojo/standards/philosophy-authoring-standard.md +113 -0
- package/docs/ja/specdojo/standards/recipe-authoring-standard.md +143 -0
- package/docs/ja/specdojo/standards/reference-authoring-standard.md +99 -0
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +140 -0
- package/docs/ja/specdojo/standards/sample-authoring-standard.md +151 -0
- package/docs/ja/specdojo/standards/standard-authoring-standard.md +108 -0
- package/docs/ja/specdojo/standards/template-authoring-standard.md +101 -0
- package/docs/ja/specdojo/standards/test-document-scope-standard.md +176 -0
- package/docs/ja/specdojo/templates/cdfd-overview-template.md +199 -0
- package/docs/ja/specdojo/templates/cdfd-template.md +173 -0
- package/docs/ja/specdojo/templates/cdfd-uc-template.md +148 -0
- package/docs/ja/specdojo/templates/dct-architecture-template.yaml +136 -0
- package/docs/ja/specdojo/templates/dct-business-acceptance-criteria-template.yaml +34 -0
- package/docs/ja/specdojo/templates/dct-business-model-bes-template.yaml +75 -0
- package/docs/ja/specdojo/templates/dct-business-model-bps-template.yaml +49 -0
- package/docs/ja/specdojo/templates/dct-business-model-br-template.yaml +50 -0
- package/docs/ja/specdojo/templates/dct-data-flow-template.yaml +40 -0
- package/docs/ja/specdojo/templates/dct-data-model-bdd-template.yaml +46 -0
- package/docs/ja/specdojo/templates/dct-data-model-ccd-template.yaml +46 -0
- package/docs/ja/specdojo/templates/dct-data-model-cdsd-template.yaml +41 -0
- package/docs/ja/specdojo/templates/dct-data-model-cld-template.yaml +38 -0
- package/docs/ja/specdojo/templates/dct-data-model-sld-template.yaml +38 -0
- package/docs/ja/specdojo/templates/dct-data-model-stsd-template.yaml +46 -0
- package/docs/ja/specdojo/templates/dct-external-interface-specs-template.yaml +114 -0
- package/docs/ja/specdojo/templates/dct-glossary-template.yaml +35 -0
- package/docs/ja/specdojo/templates/dct-impact-analysis-template.yaml +138 -0
- package/docs/ja/specdojo/templates/dct-index-template.md +40 -0
- package/docs/ja/specdojo/templates/dct-migration-planning-template.yaml +148 -0
- package/docs/ja/specdojo/templates/dct-non-functional-requirements-template.yaml +222 -0
- package/docs/ja/specdojo/templates/dct-operations-template.yaml +108 -0
- package/docs/ja/specdojo/templates/dct-project-definition-template.yaml +210 -0
- package/docs/ja/specdojo/templates/dct-project-management-template.yaml +423 -0
- package/docs/ja/specdojo/templates/dct-system-acceptance-criteria-template.yaml +37 -0
- package/docs/ja/specdojo/templates/dct-system-design-template.yaml +82 -0
- package/docs/ja/specdojo/templates/dct-system-functions-template.yaml +58 -0
- package/docs/ja/specdojo/templates/dct-test-specs-template.yaml +261 -0
- package/docs/ja/specdojo/templates/dct-user-interface-model-template.yaml +60 -0
- package/docs/ja/specdojo/templates/ifx-cmd-template.yaml +88 -0
- package/docs/ja/specdojo/templates/opr-template.md +85 -0
- package/docs/ja/specdojo/templates/pjr-change-request-template.md +60 -0
- package/docs/ja/specdojo/templates/pjr-decision-template.md +61 -0
- package/docs/ja/specdojo/templates/pjr-index-template.md +49 -0
- package/docs/ja/specdojo/templates/pjr-issue-template.md +50 -0
- package/docs/ja/specdojo/templates/pjr-note-template.md +35 -0
- package/docs/ja/specdojo/templates/pjr-question-template.md +53 -0
- package/docs/ja/specdojo/templates/pjr-risk-template.md +49 -0
- package/docs/ja/specdojo/templates/pjr-todo-template.md +41 -0
- package/docs/ja/specdojo/templates/pjr-views-by-owner-template.md +22 -0
- package/docs/ja/specdojo/templates/pjr-views-by-priority-template.md +22 -0
- package/docs/ja/specdojo/templates/pjr-views-by-status-template.md +22 -0
- package/docs/ja/specdojo/templates/pm-change-request-log-template.md +20 -0
- package/docs/ja/specdojo/templates/pm-communication-plan-template.md +46 -0
- package/docs/ja/specdojo/templates/pm-decision-log-template.md +20 -0
- package/docs/ja/specdojo/templates/pm-issue-log-template.md +20 -0
- package/docs/ja/specdojo/templates/pm-members-template.yaml +105 -0
- package/docs/ja/specdojo/templates/pm-organization-template.md +44 -0
- package/docs/ja/specdojo/templates/pm-plan-template.md +52 -0
- package/docs/ja/specdojo/templates/pm-quality-management-plan-template.md +46 -0
- package/docs/ja/specdojo/templates/pm-raci-template.md +51 -0
- package/docs/ja/specdojo/templates/pm-risk-register-template.md +20 -0
- package/docs/ja/specdojo/templates/pm-roles-template.yaml +53 -0
- package/docs/ja/specdojo/templates/prj-assumptions-constraints-dependencies-template.md +59 -0
- package/docs/ja/specdojo/templates/prj-charter-template.md +116 -0
- package/docs/ja/specdojo/templates/prj-comparison-of-alternatives-template.md +116 -0
- package/docs/ja/specdojo/templates/prj-issues-and-approach-template.md +89 -0
- package/docs/ja/specdojo/templates/prj-overview-template.md +85 -0
- package/docs/ja/specdojo/templates/prj-scope-template.md +75 -0
- package/docs/ja/specdojo/templates/prj-stakeholder-register-template.md +64 -0
- package/docs/ja/specdojo/templates/prj-success-criteria-and-acceptance-criteria-template.md +60 -0
- package/docs/ja/specdojo/templates/stsd-template.md +57 -0
- package/docs/specdojo/schemas/v1/bdd.schema.yaml +230 -0
- package/docs/specdojo/schemas/v1/common-frontmatter.schema.yaml +77 -0
- package/docs/specdojo/schemas/v1/dct-index.schema.yaml +85 -0
- package/docs/specdojo/schemas/v1/dct-plan.schema.yaml +324 -0
- package/docs/specdojo/schemas/v1/dct.schema.yaml +368 -0
- package/docs/specdojo/schemas/v1/deliverable-frontmatter.schema.yaml +91 -0
- package/docs/specdojo/schemas/v1/esil.schema.yaml +142 -0
- package/docs/specdojo/schemas/v1/exec-common.schema.yaml +101 -0
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +272 -0
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +162 -0
- package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +126 -0
- package/docs/specdojo/schemas/v1/exec-reporter-output.schema.yaml +151 -0
- package/docs/specdojo/schemas/v1/exec-result-frontmatter.schema.yaml +144 -0
- package/docs/specdojo/schemas/v1/grade-done-criteria.schema.yaml +79 -0
- package/docs/specdojo/schemas/v1/grade-pipeline-state.schema.yaml +60 -0
- package/docs/specdojo/schemas/v1/grade-result.schema.yaml +118 -0
- package/docs/specdojo/schemas/v1/guide-frontmatter.schema.yaml +19 -0
- package/docs/specdojo/schemas/v1/ifx-cmd.schema.yaml +293 -0
- package/docs/specdojo/schemas/v1/job-run.schema.yaml +90 -0
- package/docs/specdojo/schemas/v1/job.schema.yaml +198 -0
- package/docs/specdojo/schemas/v1/philosophy-frontmatter.schema.yaml +19 -0
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +56 -0
- package/docs/specdojo/schemas/v1/pm-members.schema.yaml +252 -0
- package/docs/specdojo/schemas/v1/pm-review-viewpoints.schema.yaml +387 -0
- package/docs/specdojo/schemas/v1/pm-roles.schema.yaml +106 -0
- package/docs/specdojo/schemas/v1/recipe-frontmatter.schema.yaml +27 -0
- package/docs/specdojo/schemas/v1/reference-frontmatter.schema.yaml +18 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +106 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +204 -0
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +36 -0
- package/docs/specdojo/schemas/v1/routine.schema.yaml +87 -0
- package/docs/specdojo/schemas/v1/rulebook-frontmatter.schema.yaml +61 -0
- package/docs/specdojo/schemas/v1/sch-common.schema.yaml +258 -0
- package/docs/specdojo/schemas/v1/sch-defaults.schema.yaml +48 -0
- package/docs/specdojo/schemas/v1/sch-milestones.schema.yaml +64 -0
- package/docs/specdojo/schemas/v1/sch-strategy.schema.yaml +772 -0
- package/docs/specdojo/schemas/v1/sch-track.schema.yaml +66 -0
- package/docs/specdojo/schemas/v1/standard-frontmatter.schema.yaml +18 -0
- package/docs/specdojo/schemas/v1/tml-index.schema.yaml +103 -0
- package/package.json +120 -24
- package/templates/claude/README.md +46 -0
- package/templates/claude/agents/claude-expert-review-executor.md +14 -0
- package/templates/claude/agents/claude-review-executor.md +14 -0
- package/templates/claude/settings.edit.json +6 -0
- package/templates/claude/settings.report.json +6 -0
- package/templates/claude/settings.review.json +7 -0
- package/templates/codex/README.md +61 -0
- package/templates/codex/agents/codex-executor.toml +12 -0
- package/templates/codex/agents/codex-expert-executor.toml +12 -0
- package/templates/codex/agents/codex-expert-review-executor.toml +10 -0
- package/templates/codex/agents/codex-review-executor.toml +10 -0
- package/templates/copilot/README.md +41 -0
- package/templates/copilot/exec-defaults-snippet.yaml +28 -0
- package/templates/copilot/pm-members-snippet.yaml +44 -0
- package/templates/opencode/README.md +41 -0
- package/templates/opencode/agents/opencode-executor.md +59 -0
- package/templates/opencode/agents/opencode-reporter.md +26 -0
- package/templates/opencode/agents/opencode-review-executor.md +48 -0
- package/dist/exec-schedule-timeline-render.js +0 -201
- package/dist/exec-schedule-timeline.js +0 -2
|
@@ -0,0 +1,847 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { appendFileSync, copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
|
|
3
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { load } from "js-yaml";
|
|
5
|
+
import { acquireSchedulerLock, releaseSchedulerLock } from "./exec-events.js";
|
|
6
|
+
import { deliverableDocPath, parsePlanTaskIdentity, targetReferenceDirsForApproach, } from "./exec-plans.js";
|
|
7
|
+
import { parseResultTaskIdentity } from "./exec-results.js";
|
|
8
|
+
import { stripTerminalControlSequences } from "./exec-shared.js";
|
|
9
|
+
import { agentProtectedConfigPaths, agentProtectedConfigViolation, } from "./exec-agent-protected-config.js";
|
|
10
|
+
import { recordProtectedConfigBlock } from "./exec-protection-handoff.js";
|
|
11
|
+
import { specdojoPackageRootDir } from "./package-paths.js";
|
|
12
|
+
import { ensureExecWorktree, execBranchExists, findExecWorktree, generateWorktreeArtifacts, gitEnvironment, gitOutput, gitResult, listRegisteredWorktrees, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./exec-worktree.js";
|
|
13
|
+
const DEFAULT_LOCK_TIMEOUT_MS = 10_000;
|
|
14
|
+
const DEFAULT_LOCK_STALE_MS = 300_000;
|
|
15
|
+
const MAX_COMMIT_STABILIZATION_ATTEMPTS = 3;
|
|
16
|
+
export function repoRelative(repoRoot, path) {
|
|
17
|
+
const value = relative(repoRoot, path);
|
|
18
|
+
if (!value || value === ".." || value.startsWith(`..${sep}`)) {
|
|
19
|
+
throw new Error(`Path is outside repository root: ${path}`);
|
|
20
|
+
}
|
|
21
|
+
return value.split(sep).join("/");
|
|
22
|
+
}
|
|
23
|
+
export function currentBranch(repoRoot) {
|
|
24
|
+
const branch = gitOutput(repoRoot, ["branch", "--show-current"]).trim();
|
|
25
|
+
if (!branch)
|
|
26
|
+
throw new Error("Detached HEAD is not supported for exec worktree commands.");
|
|
27
|
+
return branch;
|
|
28
|
+
}
|
|
29
|
+
function statusPaths(repoRoot) {
|
|
30
|
+
const output = gitOutput(repoRoot, ["status", "--porcelain=v1", "-z", "--untracked-files=all"]);
|
|
31
|
+
const records = output.split("\0").filter(Boolean);
|
|
32
|
+
const paths = [];
|
|
33
|
+
for (let index = 0; index < records.length; index++) {
|
|
34
|
+
const record = records[index];
|
|
35
|
+
if (record.length < 4)
|
|
36
|
+
continue;
|
|
37
|
+
const status = record.slice(0, 2);
|
|
38
|
+
paths.push(record.slice(3));
|
|
39
|
+
if ((status.includes("R") || status.includes("C")) && records[index + 1]) {
|
|
40
|
+
paths.push(records[++index]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return paths;
|
|
44
|
+
}
|
|
45
|
+
export function worktreeStatusPaths(repoRoot) {
|
|
46
|
+
return statusPaths(repoRoot);
|
|
47
|
+
}
|
|
48
|
+
export function taskPaths(context, taskId) {
|
|
49
|
+
const executionRel = repoRelative(context.repoRoot, context.executionPath);
|
|
50
|
+
return {
|
|
51
|
+
executionRel,
|
|
52
|
+
planRel: `${executionRel}/exec/plans/${taskId}-plan.md`,
|
|
53
|
+
resultRel: `${executionRel}/exec/results/${taskId}-result.md`,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function isCommitTargetPath(path, executionRel, resultRel) {
|
|
57
|
+
const normalized = path.replaceAll("\\", "/");
|
|
58
|
+
if (normalized === resultRel)
|
|
59
|
+
return true;
|
|
60
|
+
// doc-index は root と worktree の双方で再生成される生成物。commit-target に含めると
|
|
61
|
+
// merge 時の overlap ガードで衝突するため除外する。
|
|
62
|
+
if (normalized === ".specdojo/doc-index.json")
|
|
63
|
+
return false;
|
|
64
|
+
if (normalized.startsWith(`${executionRel}/exec/plans/`))
|
|
65
|
+
return false;
|
|
66
|
+
if (normalized.startsWith(`${executionRel}/exec/results/`))
|
|
67
|
+
return false;
|
|
68
|
+
if (normalized.startsWith(`${executionRel}/exec/events/`))
|
|
69
|
+
return false;
|
|
70
|
+
if (normalized.startsWith(`${executionRel}/generated/`))
|
|
71
|
+
return false;
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
// Reads a deliverable's frontmatter `status`. Markdown deliverables carry it in the
|
|
75
|
+
// leading `---` frontmatter block; yaml/json deliverables carry it as a top-level field.
|
|
76
|
+
// Returns undefined when absent or unparsable (treated as "not ready").
|
|
77
|
+
export function deliverableStatus(content, relPath) {
|
|
78
|
+
const isMarkdown = /\.md$/i.test(relPath);
|
|
79
|
+
let source = content;
|
|
80
|
+
if (isMarkdown) {
|
|
81
|
+
const fm = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
82
|
+
if (!fm)
|
|
83
|
+
return undefined;
|
|
84
|
+
source = fm[1];
|
|
85
|
+
}
|
|
86
|
+
let parsed;
|
|
87
|
+
try {
|
|
88
|
+
parsed = load(source);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
94
|
+
return undefined;
|
|
95
|
+
// Markdown deliverables carry status in the `specdojo:` namespace; yaml/json data
|
|
96
|
+
// files carry it as a top-level field.
|
|
97
|
+
const container = isMarkdown
|
|
98
|
+
? parsed.specdojo
|
|
99
|
+
: parsed;
|
|
100
|
+
if (!container || typeof container !== "object" || Array.isArray(container))
|
|
101
|
+
return undefined;
|
|
102
|
+
const status = container.status;
|
|
103
|
+
return typeof status === "string" ? status : undefined;
|
|
104
|
+
}
|
|
105
|
+
// Promotion of a deliverable's frontmatter status to "ready" is a human-only gate.
|
|
106
|
+
// Agents commit their changes through commitWorktreeChanges, so reject (block) any run
|
|
107
|
+
// that transitions a deliverable to "ready" here; humans promote out-of-band via a direct
|
|
108
|
+
// edit and git commit, which never passes through this path.
|
|
109
|
+
function assertNoAgentReadyPromotion(context, worktree, taskId, paths) {
|
|
110
|
+
const { resultRel } = taskPaths(context, taskId);
|
|
111
|
+
const resultContent = readWorktreeHeadFile(worktree.path, resultRel);
|
|
112
|
+
if (resultContent && parseResultTaskIdentity(resultContent)?.execution === "human") {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const promoted = [];
|
|
116
|
+
for (const relPath of paths) {
|
|
117
|
+
if (relPath === resultRel)
|
|
118
|
+
continue;
|
|
119
|
+
const absPath = resolve(worktree.path, relPath);
|
|
120
|
+
if (!existsSync(absPath))
|
|
121
|
+
continue; // deletion is not a promotion
|
|
122
|
+
if (deliverableStatus(readFileSync(absPath, "utf8"), relPath) !== "ready")
|
|
123
|
+
continue;
|
|
124
|
+
const base = gitResult(worktree.path, ["show", `HEAD:${relPath}`]);
|
|
125
|
+
const baseStatus = base.status === 0 && typeof base.stdout === "string"
|
|
126
|
+
? deliverableStatus(base.stdout, relPath)
|
|
127
|
+
: undefined;
|
|
128
|
+
if (baseStatus !== "ready")
|
|
129
|
+
promoted.push(relPath);
|
|
130
|
+
}
|
|
131
|
+
if (promoted.length > 0) {
|
|
132
|
+
throw new Error(`Deliverable status promotion to "ready" is human-only and must not be done by an agent run: ${promoted.join(", ")}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function isHumanWorktreeExecution(context, worktree, taskId) {
|
|
136
|
+
const { resultRel } = taskPaths(context, taskId);
|
|
137
|
+
const resultContent = readWorktreeHeadFile(worktree.path, resultRel);
|
|
138
|
+
return !!resultContent && parseResultTaskIdentity(resultContent)?.execution === "human";
|
|
139
|
+
}
|
|
140
|
+
// worktree の未 commit 差分に加え、agent が provider 側の git 制約を回避して直接
|
|
141
|
+
// commit した差分も検査する。human execution と通常の人間 / orchestrator commit は
|
|
142
|
+
// agent 統合経路ではないため、このガードの対象外。
|
|
143
|
+
function assertNoAgentProtectedConfigChanges(context, worktree, taskId) {
|
|
144
|
+
if (isHumanWorktreeExecution(context, worktree, taskId))
|
|
145
|
+
return;
|
|
146
|
+
const { resultRel } = taskPaths(context, taskId);
|
|
147
|
+
const rootHead = gitOutput(context.repoRoot, ["rev-parse", "HEAD"]).trim();
|
|
148
|
+
const compareBase = gitOutput(worktree.path, ["merge-base", "HEAD", rootHead]).trim();
|
|
149
|
+
const committed = zeroSeparatedPaths(worktree.path, [
|
|
150
|
+
"diff",
|
|
151
|
+
"--no-renames",
|
|
152
|
+
"--name-only",
|
|
153
|
+
"-z",
|
|
154
|
+
`${compareBase}..HEAD`,
|
|
155
|
+
]);
|
|
156
|
+
const protectedPaths = agentProtectedConfigPaths(worktree.path, [
|
|
157
|
+
...statusPaths(worktree.path),
|
|
158
|
+
...committed,
|
|
159
|
+
]);
|
|
160
|
+
if (protectedPaths.length > 0) {
|
|
161
|
+
const reason = agentProtectedConfigViolation(protectedPaths);
|
|
162
|
+
// commit 前の再検査でも、対象と提案差分を result の申し送りへ残してから block する。
|
|
163
|
+
recordProtectedConfigBlock({
|
|
164
|
+
resultPath: resolve(worktree.path, resultRel),
|
|
165
|
+
repoRoot: worktree.path,
|
|
166
|
+
paths: protectedPaths,
|
|
167
|
+
reason,
|
|
168
|
+
});
|
|
169
|
+
throw new Error(reason);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const DOC_INDEX_REL = ".specdojo/doc-index.json";
|
|
173
|
+
// worktree の HEAD(CLI が checkpoint した版)からファイル内容を読む。
|
|
174
|
+
// agent は working tree を書き換えられるが HEAD は書き換えられないため、
|
|
175
|
+
// ここから読む情報はプロンプトインジェクションに対して改ざん耐性がある。
|
|
176
|
+
function readWorktreeHeadFile(worktreePath, relPath) {
|
|
177
|
+
const result = gitResult(worktreePath, ["show", `HEAD:${relPath}`]);
|
|
178
|
+
return result.status === 0 && typeof result.stdout === "string" ? result.stdout : undefined;
|
|
179
|
+
}
|
|
180
|
+
// HEAD の doc-index から doc id → repo 相対パスを引く。"path:line" 形式は path 部を使う。
|
|
181
|
+
function headDocIndexLookup(worktreePath) {
|
|
182
|
+
const content = readWorktreeHeadFile(worktreePath, DOC_INDEX_REL);
|
|
183
|
+
let entries = {};
|
|
184
|
+
if (content) {
|
|
185
|
+
try {
|
|
186
|
+
const parsed = JSON.parse(content);
|
|
187
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
188
|
+
const candidate = parsed.entries;
|
|
189
|
+
if (candidate && typeof candidate === "object" && !Array.isArray(candidate)) {
|
|
190
|
+
entries = candidate;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
// 壊れた index は「引けない」として扱い、catalog フォールバックに委ねる。
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return (id) => {
|
|
199
|
+
const value = entries[id];
|
|
200
|
+
if (typeof value !== "string")
|
|
201
|
+
return undefined;
|
|
202
|
+
const match = value.match(/^(.+):\d+$/);
|
|
203
|
+
return match ? match[1] : value;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
// agent は HEAD の plan、human は HEAD の result frontmatter から commit 許可リストを
|
|
207
|
+
// 導出する。いずれも task 識別を復元できない場合は null を返し、呼び出し側は従来の
|
|
208
|
+
// 除外リスト方式へフォールバックする。checkpoint 済みの HEAD を読むため、agent の
|
|
209
|
+
// working tree 改変からは影響を受けない。
|
|
210
|
+
export function resolveCommitScope(context, worktree, taskId) {
|
|
211
|
+
const { executionRel, planRel, resultRel } = taskPaths(context, taskId);
|
|
212
|
+
const resultContent = readWorktreeHeadFile(worktree.path, resultRel);
|
|
213
|
+
const resultIdentity = resultContent ? parseResultTaskIdentity(resultContent) : null;
|
|
214
|
+
const planContent = readWorktreeHeadFile(worktree.path, planRel);
|
|
215
|
+
const planIdentity = planContent ? parsePlanTaskIdentity(planContent) : null;
|
|
216
|
+
// 旧版で生成済みの human plan が残っていても、明示された execution を優先して
|
|
217
|
+
// result の targets を正本に切り替える。
|
|
218
|
+
const identity = resultIdentity?.execution === "human" ? resultIdentity : planIdentity;
|
|
219
|
+
if (!identity)
|
|
220
|
+
return { scope: null, unresolvedTargets: [] };
|
|
221
|
+
if (identity.mode === "review") {
|
|
222
|
+
return {
|
|
223
|
+
scope: { mode: "review", allowedFiles: [resultRel], allowedDirPrefixes: [] },
|
|
224
|
+
unresolvedTargets: [],
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
// register 由来のタスクは対象成果物を特定できず targets を持たない。許可リストを
|
|
228
|
+
// 導出する根拠が無いため、従来どおり除外リスト方式へフォールバックする(register の
|
|
229
|
+
// 通常経路である作業ツリー差分による commit と同じ範囲になる)。
|
|
230
|
+
if (identity.origin === "register")
|
|
231
|
+
return { scope: null, unresolvedTargets: [] };
|
|
232
|
+
// schedule 由来の edit タスクは targets から commit 許可リストを導出する。targets が
|
|
233
|
+
// 無いと許可リストが result 1 件へ縮退し、成果物の変更が commit されないまま worktree に
|
|
234
|
+
// 残る。静かに縮退させず、ここで失敗させる。
|
|
235
|
+
if ((identity.targets ?? []).length === 0) {
|
|
236
|
+
throw new Error(`commit-scope: no targets in plan/result frontmatter for edit task ${taskId}. ` +
|
|
237
|
+
`Schedule-originated edit tasks must declare targets; ` +
|
|
238
|
+
`register-originated tasks must declare "origin: register".`);
|
|
239
|
+
}
|
|
240
|
+
const allowedFiles = new Set([resultRel]);
|
|
241
|
+
const unresolvedTargets = [];
|
|
242
|
+
const lookup = headDocIndexLookup(worktree.path);
|
|
243
|
+
for (const target of identity.targets ?? []) {
|
|
244
|
+
const fromIndex = lookup(target);
|
|
245
|
+
if (fromIndex) {
|
|
246
|
+
allowedFiles.add(fromIndex);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
// doc-index 未登録(未作成の新規成果物など)は catalog が宣言するパスへ解決する。
|
|
250
|
+
const localId = identity.projectId && target.startsWith(`${identity.projectId}:`)
|
|
251
|
+
? target.slice(identity.projectId.length + 1)
|
|
252
|
+
: target;
|
|
253
|
+
const fromCatalog = context.catalogPath
|
|
254
|
+
? deliverableDocPath(context.catalogPath, localId)
|
|
255
|
+
: undefined;
|
|
256
|
+
if (fromCatalog) {
|
|
257
|
+
allowedFiles.add(fromCatalog);
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
unresolvedTargets.push(target);
|
|
261
|
+
}
|
|
262
|
+
const allowedDirPrefixes = targetReferenceDirsForApproach(identity.approach).map((dir) => `${dir}/`);
|
|
263
|
+
// Pipeline evidence is runner-owned and stored per task/run. It must be committed together with
|
|
264
|
+
// the eventual reporter-generated result so the structured executor record survives worktree
|
|
265
|
+
// removal. Legacy tasks create no files under this prefix, so their commit scope is unchanged.
|
|
266
|
+
allowedDirPrefixes.push(`${executionRel}/exec/evidence/${worktreeNameFromTaskId(taskId)}/`);
|
|
267
|
+
return {
|
|
268
|
+
scope: { mode: "edit", allowedFiles: [...allowedFiles], allowedDirPrefixes },
|
|
269
|
+
unresolvedTargets,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
// worktree の変更を「commit するパス」「許可リスト外のため commit しないパス」に分ける。
|
|
273
|
+
// 除外リスト(isCommitTargetPath)は許可リストの内側でも引き続き適用する。
|
|
274
|
+
export function partitionCommitTargets(context, worktree, taskId) {
|
|
275
|
+
const { executionRel, resultRel } = taskPaths(context, taskId);
|
|
276
|
+
const candidates = statusPaths(worktree.path).filter((path) => isCommitTargetPath(path, executionRel, resultRel));
|
|
277
|
+
const { scope, unresolvedTargets } = resolveCommitScope(context, worktree, taskId);
|
|
278
|
+
if (!scope)
|
|
279
|
+
return { targets: candidates, outOfScope: [], unresolvedTargets };
|
|
280
|
+
const targets = [];
|
|
281
|
+
const outOfScope = [];
|
|
282
|
+
for (const path of candidates) {
|
|
283
|
+
const allowed = scope.allowedFiles.includes(path) ||
|
|
284
|
+
scope.allowedDirPrefixes.some((prefix) => path.startsWith(prefix));
|
|
285
|
+
(allowed ? targets : outOfScope).push(path);
|
|
286
|
+
}
|
|
287
|
+
return { targets, outOfScope, unresolvedTargets };
|
|
288
|
+
}
|
|
289
|
+
export function commitTargetPaths(context, worktree, taskId) {
|
|
290
|
+
return partitionCommitTargets(context, worktree, taskId).targets;
|
|
291
|
+
}
|
|
292
|
+
// `git add` の pathspec は作業ツリーと index だけを照合する。削除が既に index へ入っている
|
|
293
|
+
// パスはそのどちらにも存在しないため、`-A` を付けても「pathspec did not match any files」で
|
|
294
|
+
// fatal になる。このようなパスは追加で stage する内容が無いので、add の対象から除外する。
|
|
295
|
+
// commit / commit --amend の pathspec は HEAD も照合するため、対象から外さずに削除を記録できる。
|
|
296
|
+
export function selectStageablePaths(repoRoot, paths) {
|
|
297
|
+
if (paths.length === 0)
|
|
298
|
+
return [];
|
|
299
|
+
const indexed = new Set(zeroSeparatedPaths(repoRoot, ["ls-files", "--full-name", "-z", "--", ...paths]));
|
|
300
|
+
// 作業ツリー側の存在確認は lstat で行う。git は symlink 自体を追跡するため、リンク先が
|
|
301
|
+
// 無い symlink も add の対象になる(existsSync はリンク先を辿るため false になる)。
|
|
302
|
+
const existsInWorktree = (path) => lstatSync(resolve(repoRoot, path), { throwIfNoEntry: false }) !== undefined;
|
|
303
|
+
return paths.filter((path) => indexed.has(path) || existsInWorktree(path));
|
|
304
|
+
}
|
|
305
|
+
// commit 対象を stage する。stage できる対象が無い場合(staged 済みの削除だけが残る場合)は
|
|
306
|
+
// git add を実行しない。commit 対象の限定は呼び出し側の paths が担うため、範囲は変わらない。
|
|
307
|
+
export function stageCommitTargets(repoRoot, paths) {
|
|
308
|
+
const stageable = selectStageablePaths(repoRoot, paths);
|
|
309
|
+
if (stageable.length === 0)
|
|
310
|
+
return;
|
|
311
|
+
gitOutput(repoRoot, ["add", "-A", "--", ...stageable]);
|
|
312
|
+
}
|
|
313
|
+
// markdownlint-cli の終了コード。1 だけが記法違反を表し、それ以外は実行環境の問題である。
|
|
314
|
+
const MARKDOWNLINT_EXIT_LINT_ERRORS = 1;
|
|
315
|
+
// worktree または SpecDojo package の node_modules から markdownlint-cli を探す。
|
|
316
|
+
// markdownlint-cli は devDependency のため、配布先の利用プロジェクトでは存在しないことがある。
|
|
317
|
+
function findMarkdownlintExecutable(worktreePath) {
|
|
318
|
+
const executableName = process.platform === "win32" ? "markdownlint.cmd" : "markdownlint";
|
|
319
|
+
const candidates = [
|
|
320
|
+
join(worktreePath, "node_modules", ".bin", executableName),
|
|
321
|
+
join(specdojoPackageRootDir(), "node_modules", ".bin", executableName),
|
|
322
|
+
];
|
|
323
|
+
return candidates.find(existsSync);
|
|
324
|
+
}
|
|
325
|
+
// result は commit hook の Prettier 実行対象から除外するため(.prettierignore)、runner が
|
|
326
|
+
// commit 前に markdownlint を直接実行する。hook 由来の汎用的な git commit 失敗ではなく、
|
|
327
|
+
// result の記法違反として block 理由を残せるようにする。
|
|
328
|
+
// markdownlint-cli が見つからない環境では検査を省略し、hook 側の検査に委ねる。
|
|
329
|
+
// 行末の空白を除き、ファイル末尾を改行 1 つに揃える。強調記法など内容に関わる置換は行わない。
|
|
330
|
+
export function normalizeResultWhitespace(resultPath) {
|
|
331
|
+
const content = readFileSync(resultPath, "utf8");
|
|
332
|
+
const normalized = content.replace(/[ \t]+$/gm, "").replace(/\n*$/, "\n");
|
|
333
|
+
if (normalized !== content)
|
|
334
|
+
writeFileSync(resultPath, normalized, "utf8");
|
|
335
|
+
}
|
|
336
|
+
export function assertResultMarkdownlint(context, worktree, taskId) {
|
|
337
|
+
const { resultRel } = taskPaths(context, taskId);
|
|
338
|
+
const resultPath = resolve(worktree.path, resultRel);
|
|
339
|
+
if (!existsSync(resultPath)) {
|
|
340
|
+
process.stdout.write(`result-markdownlint: result ${resultRel} not found; skipped pre-commit lint\n`);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
// reporter の出力に由来する行末の空白と末尾改行の不足は、内容に影響しない空白だけの違反
|
|
344
|
+
// (MD009 / MD047)であり、以前は commit hook の Prettier が黙って整えていた。Prettier の
|
|
345
|
+
// 対象外にした分をここで補い、記法違反として block するのは内容に関わる違反に限る。
|
|
346
|
+
normalizeResultWhitespace(resultPath);
|
|
347
|
+
const executable = findMarkdownlintExecutable(worktree.path);
|
|
348
|
+
if (!executable) {
|
|
349
|
+
process.stdout.write(`result-markdownlint: markdownlint-cli not found; skipped pre-commit lint of ${resultRel}\n`);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const result = spawnSync(executable, [resultRel], {
|
|
353
|
+
cwd: worktree.path,
|
|
354
|
+
encoding: "utf8",
|
|
355
|
+
env: gitEnvironment(),
|
|
356
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
357
|
+
});
|
|
358
|
+
if (!result.error && result.status === 0)
|
|
359
|
+
return;
|
|
360
|
+
const output = stripTerminalControlSequences([result.stdout, result.stderr, result.error?.message].filter(Boolean).join("\n"))
|
|
361
|
+
.trim()
|
|
362
|
+
.replace(/\s+/g, " ");
|
|
363
|
+
const detail = output ? output.slice(0, 1_000) : `exit ${result.status ?? "unknown"}`;
|
|
364
|
+
if (!result.error && result.status === MARKDOWNLINT_EXIT_LINT_ERRORS) {
|
|
365
|
+
throw new Error(`Result Markdown notation violation before commit: ${detail}`);
|
|
366
|
+
}
|
|
367
|
+
throw new Error(`Failed to run markdownlint on ${resultRel} before commit: ${detail}`);
|
|
368
|
+
}
|
|
369
|
+
export function stabilizeCommitTargets(repoRoot, listRemainingPaths, maxAttempts = MAX_COMMIT_STABILIZATION_ATTEMPTS) {
|
|
370
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
371
|
+
const paths = listRemainingPaths();
|
|
372
|
+
if (paths.length === 0)
|
|
373
|
+
return;
|
|
374
|
+
stageCommitTargets(repoRoot, paths);
|
|
375
|
+
const staged = gitResult(repoRoot, ["diff", "--cached", "--quiet", "--", ...paths]);
|
|
376
|
+
if (staged.status === 0) {
|
|
377
|
+
// pathspec commit は hook が再stageした内容を commit した後、元の index を復元して
|
|
378
|
+
// HEAD と逆向きの差分を残す場合がある。この場合は add が index を HEAD へ揃えて
|
|
379
|
+
// 差分を解消するため、再取得して消えていれば正常な収束として扱う。
|
|
380
|
+
const remaining = listRemainingPaths();
|
|
381
|
+
if (remaining.length === 0)
|
|
382
|
+
return;
|
|
383
|
+
throw new Error(`Failed to stage post-hook commit-target changes: ${remaining.join(", ")}`);
|
|
384
|
+
}
|
|
385
|
+
if (staged.status !== 1)
|
|
386
|
+
throw new Error("Failed to inspect post-hook worktree changes.");
|
|
387
|
+
gitOutput(repoRoot, ["commit", "--amend", "--no-edit", "--", ...paths]);
|
|
388
|
+
}
|
|
389
|
+
const dirty = listRemainingPaths();
|
|
390
|
+
if (dirty.length > 0) {
|
|
391
|
+
throw new Error(`Pre-commit hooks kept changing commit-target files: ${dirty.join(", ")}`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function zeroSeparatedPaths(repoRoot, args) {
|
|
395
|
+
return gitOutput(repoRoot, args).split("\0").filter(Boolean);
|
|
396
|
+
}
|
|
397
|
+
function rootDirtyPaths(repoRoot) {
|
|
398
|
+
return new Set([
|
|
399
|
+
...zeroSeparatedPaths(repoRoot, ["diff", "--no-renames", "--name-only", "-z"]),
|
|
400
|
+
...zeroSeparatedPaths(repoRoot, ["diff", "--cached", "--no-renames", "--name-only", "-z"]),
|
|
401
|
+
...zeroSeparatedPaths(repoRoot, ["ls-files", "--others", "--exclude-standard", "-z"]),
|
|
402
|
+
]);
|
|
403
|
+
}
|
|
404
|
+
// Commit the task result and deliverable changes inside the worktree onto its exec branch.
|
|
405
|
+
// The commit is limited to the mode-based allowlist (resolveCommitScope); out-of-scope
|
|
406
|
+
// changes stay uncommitted in the worktree and are reported. Excludes plans, events,
|
|
407
|
+
// generated files, and other tasks' results (see isCommitTargetPath).
|
|
408
|
+
export function commitWorktreeChanges(params) {
|
|
409
|
+
const { context, worktree, taskId } = params;
|
|
410
|
+
assertNoAgentProtectedConfigChanges(context, worktree, taskId);
|
|
411
|
+
const { targets: paths, outOfScope, unresolvedTargets, } = partitionCommitTargets(context, worktree, taskId);
|
|
412
|
+
for (const target of unresolvedTargets) {
|
|
413
|
+
process.stdout.write(`commit-scope: unresolved target doc id (not committable): ${target}\n`);
|
|
414
|
+
}
|
|
415
|
+
if (outOfScope.length > 0) {
|
|
416
|
+
process.stdout.write(`commit-scope: skipped non-target changes (left in worktree):\n${outOfScope
|
|
417
|
+
.map((path) => ` ${path}`)
|
|
418
|
+
.join("\n")}\n`);
|
|
419
|
+
}
|
|
420
|
+
if (paths.length === 0) {
|
|
421
|
+
process.stdout.write("No commit-target changes.\n");
|
|
422
|
+
return { targets: [], committed: false };
|
|
423
|
+
}
|
|
424
|
+
assertNoAgentReadyPromotion(context, worktree, taskId, paths);
|
|
425
|
+
process.stdout.write(`commit-targets:\n${paths.map((path) => ` ${path}`).join("\n")}\n`);
|
|
426
|
+
if (params.dryRun)
|
|
427
|
+
return { targets: paths, committed: false };
|
|
428
|
+
assertResultMarkdownlint(context, worktree, taskId);
|
|
429
|
+
stageCommitTargets(worktree.path, paths);
|
|
430
|
+
const staged = gitResult(worktree.path, ["diff", "--cached", "--quiet", "--", ...paths]);
|
|
431
|
+
if (staged.status === 0) {
|
|
432
|
+
process.stdout.write("No staged commit-target changes.\n");
|
|
433
|
+
return { targets: paths, committed: false };
|
|
434
|
+
}
|
|
435
|
+
if (staged.status !== 1)
|
|
436
|
+
throw new Error("Failed to inspect staged worktree changes.");
|
|
437
|
+
gitOutput(worktree.path, [
|
|
438
|
+
"commit",
|
|
439
|
+
"-m",
|
|
440
|
+
params.message?.trim() || `exec(${taskId}): apply task changes`,
|
|
441
|
+
"--",
|
|
442
|
+
...paths,
|
|
443
|
+
]);
|
|
444
|
+
stabilizeCommitTargets(worktree.path, () => commitTargetPaths(context, worktree, taskId));
|
|
445
|
+
return { targets: paths, committed: true };
|
|
446
|
+
}
|
|
447
|
+
// The checkpoint commit lives on the exec branch only, so the root keeps its own uncommitted copy
|
|
448
|
+
// of the bookkeeping files while the task runs (the schedule/register state must stay visible at
|
|
449
|
+
// root). Before the exec branch is merged those copies must yield to the committed versions,
|
|
450
|
+
// otherwise the overlap guard below rejects the merge. Capture them so a failed merge can put the
|
|
451
|
+
// root back exactly as it was.
|
|
452
|
+
export function releaseRootWorkingCopies(repoRoot, relPaths) {
|
|
453
|
+
const snapshot = [];
|
|
454
|
+
try {
|
|
455
|
+
for (const rel of new Set(relPaths)) {
|
|
456
|
+
const absolute = resolve(repoRoot, rel);
|
|
457
|
+
const exists = lstatSync(absolute, { throwIfNoEntry: false }) !== undefined;
|
|
458
|
+
snapshot.push({ rel, content: exists ? readFileSync(absolute) : null });
|
|
459
|
+
restoreToHead(repoRoot, rel);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
catch (error) {
|
|
463
|
+
// Releasing is itself allowed to fail (for example because a path unexpectedly became a
|
|
464
|
+
// directory). Put back every copy already touched before propagating the failure; otherwise a
|
|
465
|
+
// merge that never started could still discard root-side execution state.
|
|
466
|
+
restoreRootWorkingCopies(repoRoot, snapshot);
|
|
467
|
+
throw error;
|
|
468
|
+
}
|
|
469
|
+
return snapshot;
|
|
470
|
+
}
|
|
471
|
+
export function restoreRootWorkingCopies(repoRoot, snapshot) {
|
|
472
|
+
for (const { rel, content } of snapshot) {
|
|
473
|
+
const absolute = resolve(repoRoot, rel);
|
|
474
|
+
if (content === null) {
|
|
475
|
+
rmSync(absolute, { recursive: true, force: true });
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
mkdirSync(resolve(absolute, ".."), { recursive: true });
|
|
479
|
+
writeFileSync(absolute, content);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
// Merge the task exec branch into the branch currently checked out at repoRoot.
|
|
483
|
+
// Serializes with the scheduler lock so parallel merges do not race on root HEAD.
|
|
484
|
+
// `releaseRootPaths` are root-side working copies of bookkeeping files that the exec branch also
|
|
485
|
+
// carries (see releaseRootWorkingCopies); they are restored when the merge does not complete.
|
|
486
|
+
export function mergeWorktreeIntoCurrent(params) {
|
|
487
|
+
const { context, worktree, taskId } = params;
|
|
488
|
+
const targetBranch = currentBranch(context.repoRoot);
|
|
489
|
+
if (targetBranch === worktree.branch) {
|
|
490
|
+
throw new Error(`Merge must run from a branch other than ${worktree.branch}.`);
|
|
491
|
+
}
|
|
492
|
+
let lockDir = "";
|
|
493
|
+
let released = [];
|
|
494
|
+
let merged = false;
|
|
495
|
+
const releasePaths = (params.releaseRootPaths ?? []).map((path) => repoRelative(context.repoRoot, path));
|
|
496
|
+
const releasePathSet = new Set(releasePaths);
|
|
497
|
+
try {
|
|
498
|
+
if (!params.dryRun) {
|
|
499
|
+
lockDir = acquireSchedulerLock(context.schedulePath, {
|
|
500
|
+
actor: `worktree-merge:${targetBranch}`,
|
|
501
|
+
lockTimeoutMs: DEFAULT_LOCK_TIMEOUT_MS,
|
|
502
|
+
lockStaleMs: DEFAULT_LOCK_STALE_MS,
|
|
503
|
+
});
|
|
504
|
+
released = releaseRootWorkingCopies(context.repoRoot, releasePaths);
|
|
505
|
+
}
|
|
506
|
+
const dirty = commitTargetPaths(context, worktree, taskId);
|
|
507
|
+
if (dirty.length > 0) {
|
|
508
|
+
throw new Error(`Worktree has uncommitted commit-target changes: ${dirty.join(", ")}`);
|
|
509
|
+
}
|
|
510
|
+
const compareBase = gitOutput(context.repoRoot, ["merge-base", "HEAD", worktree.branch]).trim();
|
|
511
|
+
const count = Number.parseInt(gitOutput(context.repoRoot, [
|
|
512
|
+
"rev-list",
|
|
513
|
+
"--count",
|
|
514
|
+
`${compareBase}..${worktree.branch}`,
|
|
515
|
+
]).trim(), 10);
|
|
516
|
+
if (!Number.isFinite(count) || count < 1) {
|
|
517
|
+
throw new Error(`No commits to merge from ${worktree.branch}.`);
|
|
518
|
+
}
|
|
519
|
+
const mergePaths = new Set(zeroSeparatedPaths(context.repoRoot, [
|
|
520
|
+
"diff",
|
|
521
|
+
"--no-renames",
|
|
522
|
+
"--name-only",
|
|
523
|
+
"-z",
|
|
524
|
+
`${compareBase}..${worktree.branch}`,
|
|
525
|
+
]));
|
|
526
|
+
const overlap = [...rootDirtyPaths(context.repoRoot)].filter((path) => mergePaths.has(path) && !(params.dryRun && releasePathSet.has(path)));
|
|
527
|
+
if (overlap.length > 0) {
|
|
528
|
+
throw new Error(`Current worktree changes overlap merge paths: ${overlap.join(", ")}`);
|
|
529
|
+
}
|
|
530
|
+
if (params.dryRun) {
|
|
531
|
+
process.stdout.write(`[dry-run] git merge ${params.ffOnly ? "--ff-only" : params.message ? `--no-ff -m ${JSON.stringify(params.message)}` : "--no-ff --no-edit"} ${worktree.branch}\n`);
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
const mergeArgs = params.ffOnly
|
|
535
|
+
? ["merge", "--ff-only", worktree.branch]
|
|
536
|
+
: params.message
|
|
537
|
+
? ["merge", "--no-ff", "-m", params.message, worktree.branch]
|
|
538
|
+
: ["merge", "--no-ff", "--no-edit", worktree.branch];
|
|
539
|
+
const mergeResult = gitResult(context.repoRoot, mergeArgs);
|
|
540
|
+
if (mergeResult.status === 0) {
|
|
541
|
+
merged = true;
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
const mergeOutput = [mergeResult.stdout, mergeResult.stderr]
|
|
545
|
+
.filter((part) => typeof part === "string" && part.length > 0)
|
|
546
|
+
.join(mergeResult.stdout && mergeResult.stderr ? "\n" : "");
|
|
547
|
+
const mergeInProgress = gitResult(context.repoRoot, ["rev-parse", "--verify", "--quiet", "MERGE_HEAD"]).status ===
|
|
548
|
+
0;
|
|
549
|
+
const abortResult = mergeInProgress
|
|
550
|
+
? gitResult(context.repoRoot, ["merge", "--abort"])
|
|
551
|
+
: undefined;
|
|
552
|
+
if (params.failureLogPath) {
|
|
553
|
+
mkdirSync(resolve(params.failureLogPath, ".."), { recursive: true });
|
|
554
|
+
const abortOutput = abortResult
|
|
555
|
+
? [abortResult.stdout, abortResult.stderr]
|
|
556
|
+
.filter((part) => typeof part === "string" && part.length > 0)
|
|
557
|
+
.join(abortResult.stdout && abortResult.stderr ? "\n" : "")
|
|
558
|
+
: "";
|
|
559
|
+
appendFileSync(params.failureLogPath, [
|
|
560
|
+
`=== ${new Date().toISOString()} git ${mergeArgs.join(" ")} ===`,
|
|
561
|
+
`exit: ${mergeResult.status ?? "unknown"}`,
|
|
562
|
+
"--- stdout ---",
|
|
563
|
+
typeof mergeResult.stdout === "string" ? mergeResult.stdout : "",
|
|
564
|
+
"--- stderr ---",
|
|
565
|
+
typeof mergeResult.stderr === "string" ? mergeResult.stderr : "",
|
|
566
|
+
"--- merge --abort ---",
|
|
567
|
+
abortResult ? `exit: ${abortResult.status ?? "unknown"}` : "not required",
|
|
568
|
+
abortOutput,
|
|
569
|
+
"",
|
|
570
|
+
].join("\n"), "utf8");
|
|
571
|
+
}
|
|
572
|
+
const summary = summarizeGitHookFailure(mergeOutput);
|
|
573
|
+
if (abortResult && abortResult.status !== 0) {
|
|
574
|
+
const abortOutput = [abortResult.stdout, abortResult.stderr]
|
|
575
|
+
.filter((part) => typeof part === "string" && part.length > 0)
|
|
576
|
+
.join("\n");
|
|
577
|
+
const abortSummary = summarizeGitHookFailure(abortOutput);
|
|
578
|
+
const instruction = `automatic git merge --abort failed; run git merge --abort manually in ` +
|
|
579
|
+
`${context.repoRoot} before continuing`;
|
|
580
|
+
process.stderr.write(`error: ${instruction}; ${abortSummary}\n`);
|
|
581
|
+
throw new Error(`git merge failed: ${summary}; ${instruction}; ${abortSummary}`);
|
|
582
|
+
}
|
|
583
|
+
throw new Error(`git merge failed: ${summary}`);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
finally {
|
|
587
|
+
if (!merged && released.length > 0)
|
|
588
|
+
restoreRootWorkingCopies(context.repoRoot, released);
|
|
589
|
+
if (lockDir)
|
|
590
|
+
releaseSchedulerLock(lockDir);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
// Whether the task exec branch is already contained in the merge-target HEAD. The integrate
|
|
594
|
+
// stage retry uses this to stay idempotent: when a previous attempt merged but failed afterwards
|
|
595
|
+
// (for example while removing the worktree), re-running the merge would fail with "No commits to
|
|
596
|
+
// merge", so the retry skips the merge and continues with the remaining integration steps.
|
|
597
|
+
// exec ブランチが統合ブランチへ merge 済みかを判定する。ancestor 判定だけでは、exec ブランチが
|
|
598
|
+
// 作成直後(先端が統合ブランチ上の commit のまま)の場合も true になる。runner の統合は
|
|
599
|
+
// --no-ff で merge するため、merge 済みなら先端は HEAD の first-parent 連鎖には含まれない。
|
|
600
|
+
// 先端が first-parent 連鎖上にあるなら、task の commit がまだ無い状態とみなす。
|
|
601
|
+
export function isExecBranchMergedIntoCurrent(params) {
|
|
602
|
+
const repoRoot = params.context.repoRoot;
|
|
603
|
+
const isAncestor = gitResult(repoRoot, ["merge-base", "--is-ancestor", params.worktree.branch, "HEAD"]).status ===
|
|
604
|
+
0;
|
|
605
|
+
if (!isAncestor)
|
|
606
|
+
return false;
|
|
607
|
+
const tip = gitResult(repoRoot, ["rev-parse", "--verify", `${params.worktree.branch}^{commit}`]);
|
|
608
|
+
if (tip.status !== 0 || typeof tip.stdout !== "string")
|
|
609
|
+
return false;
|
|
610
|
+
const firstParentChain = gitOutput(repoRoot, ["rev-list", "--first-parent", "HEAD"])
|
|
611
|
+
.split("\n")
|
|
612
|
+
.map((line) => line.trim());
|
|
613
|
+
return !firstParentChain.includes(tip.stdout.trim());
|
|
614
|
+
}
|
|
615
|
+
// Remove a task worktree once its commit-target changes are committed and merged.
|
|
616
|
+
export function removeWorktree(params) {
|
|
617
|
+
const { context, worktree, taskId } = params;
|
|
618
|
+
if (resolve(context.repoRoot) === resolve(worktree.path)) {
|
|
619
|
+
throw new Error("Run remove from the merge-target worktree, not the task worktree.");
|
|
620
|
+
}
|
|
621
|
+
const dirty = commitTargetPaths(context, worktree, taskId);
|
|
622
|
+
const merged = gitResult(context.repoRoot, ["merge-base", "--is-ancestor", worktree.branch, "HEAD"]).status ===
|
|
623
|
+
0;
|
|
624
|
+
if (!params.force && dirty.length > 0) {
|
|
625
|
+
throw new Error(`Worktree has uncommitted commit-target changes: ${dirty.join(", ")}`);
|
|
626
|
+
}
|
|
627
|
+
if (!params.force && !merged) {
|
|
628
|
+
throw new Error(`Exec branch is not merged into current HEAD: ${worktree.branch}`);
|
|
629
|
+
}
|
|
630
|
+
// Past the guards, any remaining uncommitted files are non-commit-target bookkeeping
|
|
631
|
+
// (doc-index, generated/, events) that were intentionally excluded from the task commit.
|
|
632
|
+
// git refuses to remove a worktree while those are dirty, so force past them: they are
|
|
633
|
+
// regenerable, and the tool already judged the worktree removable.
|
|
634
|
+
const leftover = worktreeStatusPaths(worktree.path);
|
|
635
|
+
const forceGit = params.force || leftover.length > 0;
|
|
636
|
+
if (params.force) {
|
|
637
|
+
process.stderr.write("Warning: forcing worktree removal; uncommitted changes may be lost.\n");
|
|
638
|
+
}
|
|
639
|
+
else if (leftover.length > 0) {
|
|
640
|
+
process.stderr.write(`Discarding regenerated files in worktree: ${leftover.join(", ")}\n`);
|
|
641
|
+
}
|
|
642
|
+
if (params.dryRun) {
|
|
643
|
+
process.stdout.write(`[dry-run] git worktree remove${forceGit ? " --force" : ""} ${worktree.path}\n`);
|
|
644
|
+
if (params.deleteBranch)
|
|
645
|
+
process.stdout.write(`[dry-run] git branch -d ${worktree.branch}\n`);
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
gitOutput(context.repoRoot, [
|
|
649
|
+
"worktree",
|
|
650
|
+
"remove",
|
|
651
|
+
...(forceGit ? ["--force"] : []),
|
|
652
|
+
worktree.path,
|
|
653
|
+
]);
|
|
654
|
+
if (params.deleteBranch) {
|
|
655
|
+
try {
|
|
656
|
+
gitOutput(context.repoRoot, ["branch", "-d", worktree.branch]);
|
|
657
|
+
}
|
|
658
|
+
catch (error) {
|
|
659
|
+
// worktree removal and branch deletion cannot be atomic: Git refuses to delete a branch
|
|
660
|
+
// while it is checked out. Make the resulting state explicit so the caller does not report
|
|
661
|
+
// that the worktree was preserved and operators can recover it with `worktree prune`.
|
|
662
|
+
throw new WorktreeRemovedBranchDeletionError(worktree.branch, error);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
export class WorktreeRemovedBranchDeletionError extends Error {
|
|
667
|
+
branch;
|
|
668
|
+
constructor(branch, cause) {
|
|
669
|
+
super(`Worktree was removed, but exec branch deletion failed and the branch remains: ` +
|
|
670
|
+
`${branch}; cause=${cause instanceof Error ? cause.message : String(cause)}`);
|
|
671
|
+
this.name = "WorktreeRemovedBranchDeletionError";
|
|
672
|
+
this.branch = branch;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
// List project-scoped exec branches that are no longer checked out by any registered worktree.
|
|
676
|
+
// A failed/interrupted run intentionally keeps both its worktree and branch, so it is not an
|
|
677
|
+
// orphan. The merged flag lets callers distinguish safely removable residue from unintegrated
|
|
678
|
+
// work that must be preserved.
|
|
679
|
+
export function listOrphanedExecBranches(params) {
|
|
680
|
+
const { repoRoot, projectId } = params;
|
|
681
|
+
const projectPrefix = `exec/${worktreeNameFromTaskId(projectId)}-`;
|
|
682
|
+
const registeredBranches = new Set(listRegisteredWorktrees(repoRoot)
|
|
683
|
+
.map((worktree) => worktree.branch)
|
|
684
|
+
.filter((branch) => !!branch));
|
|
685
|
+
const branches = gitOutput(repoRoot, [
|
|
686
|
+
"for-each-ref",
|
|
687
|
+
"--format=%(refname:short)",
|
|
688
|
+
"refs/heads/exec/",
|
|
689
|
+
])
|
|
690
|
+
.split(/\r?\n/)
|
|
691
|
+
.map((branch) => branch.trim())
|
|
692
|
+
.filter((branch) => branch.startsWith(projectPrefix) && !registeredBranches.has(branch))
|
|
693
|
+
.sort();
|
|
694
|
+
return branches.map((branch) => ({
|
|
695
|
+
branch,
|
|
696
|
+
mergedIntoCurrent: gitResult(repoRoot, ["merge-base", "--is-ancestor", branch, "HEAD"]).status === 0,
|
|
697
|
+
}));
|
|
698
|
+
}
|
|
699
|
+
// Delete only merged orphan branches with Git's safe `-d`. Unmerged branches are always retained,
|
|
700
|
+
// even if the caller asks for a real prune. A deletion failure is not swallowed: gitOutput's
|
|
701
|
+
// stderr-backed reason is propagated so the execution log records why residue remains.
|
|
702
|
+
export function pruneOrphanedExecBranches(params) {
|
|
703
|
+
const current = currentBranch(params.repoRoot);
|
|
704
|
+
if (current.startsWith("exec/")) {
|
|
705
|
+
throw new Error("Run worktree prune from the merge-target worktree, not an exec branch.");
|
|
706
|
+
}
|
|
707
|
+
const orphaned = listOrphanedExecBranches(params);
|
|
708
|
+
for (const item of orphaned) {
|
|
709
|
+
if (!item.mergedIntoCurrent)
|
|
710
|
+
continue;
|
|
711
|
+
if (!params.dryRun) {
|
|
712
|
+
try {
|
|
713
|
+
gitOutput(params.repoRoot, ["branch", "-d", item.branch]);
|
|
714
|
+
}
|
|
715
|
+
catch (error) {
|
|
716
|
+
throw new Error(`Failed to delete merged orphaned exec branch ${item.branch}; ` +
|
|
717
|
+
`cause=${error instanceof Error ? error.message : String(error)}`);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return orphaned;
|
|
722
|
+
}
|
|
723
|
+
// A fresh claim of a task that still owns an exec worktree/branch means a prior lifecycle
|
|
724
|
+
// (e.g. blocked or cancelled, then reset to todo) left residue behind. The scheduler has abandoned
|
|
725
|
+
// that branch, so discard it before re-preparing: otherwise checkpointAndEnsureWorktree reuses the
|
|
726
|
+
// stale worktree, skips the checkpoint commit, and the freshly-scaffolded root plan/result/claim
|
|
727
|
+
// files never reach the exec branch (the merge would land the stale branch's versions instead).
|
|
728
|
+
// Returns the discarded branch name for logging, or null when no residue existed.
|
|
729
|
+
export function discardStaleExecWorktree(params) {
|
|
730
|
+
const { context, worktreeTaskId } = params;
|
|
731
|
+
const branch = `exec/${worktreeNameFromTaskId(worktreeTaskId)}`;
|
|
732
|
+
const existing = findExecWorktree(context.repoRoot, worktreeTaskId);
|
|
733
|
+
if (!existing && !execBranchExists(context.repoRoot, worktreeTaskId))
|
|
734
|
+
return null;
|
|
735
|
+
if (existing) {
|
|
736
|
+
if (resolve(context.repoRoot) === resolve(existing.path)) {
|
|
737
|
+
throw new Error(`Refusing to discard the merge-target worktree as stale residue: ${branch}`);
|
|
738
|
+
}
|
|
739
|
+
// Force past any uncommitted/blocked state in the abandoned worktree; its branch is discarded
|
|
740
|
+
// next, so nothing here is worth preserving.
|
|
741
|
+
gitOutput(context.repoRoot, ["worktree", "remove", "--force", existing.path]);
|
|
742
|
+
}
|
|
743
|
+
// The branch is unmerged (the scheduler reset the task to todo), so a safe `-d` would fail; use
|
|
744
|
+
// `-D` to drop it deliberately.
|
|
745
|
+
if (execBranchExists(context.repoRoot, worktreeTaskId)) {
|
|
746
|
+
gitOutput(context.repoRoot, ["branch", "-D", branch]);
|
|
747
|
+
}
|
|
748
|
+
return branch;
|
|
749
|
+
}
|
|
750
|
+
function copyCheckpointPath(sourceRoot, targetRoot, relPath) {
|
|
751
|
+
const source = resolve(sourceRoot, relPath);
|
|
752
|
+
const target = resolve(targetRoot, relPath);
|
|
753
|
+
if (!existsSync(source)) {
|
|
754
|
+
rmSync(target, { recursive: true, force: true });
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
const stat = lstatSync(source);
|
|
758
|
+
if (!stat.isFile()) {
|
|
759
|
+
throw new Error(`Execution checkpoint path must be a file: ${relPath}`);
|
|
760
|
+
}
|
|
761
|
+
mkdirSync(resolve(target, ".."), { recursive: true });
|
|
762
|
+
copyFileSync(source, target);
|
|
763
|
+
}
|
|
764
|
+
// Put a root path back to its HEAD state: tracked files are restored, paths absent from HEAD are
|
|
765
|
+
// removed (and unstaged if a hook or caller had staged them).
|
|
766
|
+
function restoreToHead(repoRoot, relPath) {
|
|
767
|
+
const tracked = gitResult(repoRoot, ["ls-files", "--error-unmatch", "--", relPath]).status === 0;
|
|
768
|
+
if (tracked) {
|
|
769
|
+
gitOutput(repoRoot, ["restore", "--source=HEAD", "--staged", "--worktree", "--", relPath]);
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
gitResult(repoRoot, ["reset", "--quiet", "--", relPath]);
|
|
773
|
+
rmSync(resolve(repoRoot, relPath), { recursive: true, force: true });
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
// Create the task worktree from the current integration HEAD, then commit the execution
|
|
777
|
+
// checkpoint (plan / result / claim or register-start bookkeeping) on the exec branch only. The
|
|
778
|
+
// root keeps its uncommitted copies so the task state stays visible there while the agent runs;
|
|
779
|
+
// the merge releases them (releaseRootWorkingCopies) right before the exec branch lands.
|
|
780
|
+
// Consequently the prepare/start bookkeeping is reachable through the merge DAG without adding a
|
|
781
|
+
// first-parent commit to the integration branch.
|
|
782
|
+
export function checkpointAndEnsureWorktree(params) {
|
|
783
|
+
const { context, worktreeTaskId, base } = params;
|
|
784
|
+
const branch = `exec/${worktreeNameFromTaskId(worktreeTaskId)}`;
|
|
785
|
+
const existing = findExecWorktree(context.repoRoot, worktreeTaskId);
|
|
786
|
+
if (existing) {
|
|
787
|
+
// 依存と違い、生成物は前回実行時のまま古くなる。生成段階を持たない版が作成した
|
|
788
|
+
// worktree では存在すらしない。再利用時も作り直し、生成物起因の検証失敗を避ける。
|
|
789
|
+
generateWorktreeArtifacts(existing.path);
|
|
790
|
+
return existing;
|
|
791
|
+
}
|
|
792
|
+
if (!execBranchExists(context.repoRoot, worktreeTaskId)) {
|
|
793
|
+
if (currentBranch(context.repoRoot) === branch) {
|
|
794
|
+
throw new Error(`Prepare must run from a branch other than ${branch}.`);
|
|
795
|
+
}
|
|
796
|
+
const staged = gitResult(context.repoRoot, ["diff", "--cached", "--quiet"]);
|
|
797
|
+
if (staged.status === 1) {
|
|
798
|
+
const stagedFiles = gitOutput(context.repoRoot, ["diff", "--cached", "--name-only"]).trim();
|
|
799
|
+
throw new Error(`Root index has staged changes; commit or unstage them first:\n${stagedFiles}`);
|
|
800
|
+
}
|
|
801
|
+
if (staged.status !== 0)
|
|
802
|
+
throw new Error("Failed to inspect staged changes in root worktree.");
|
|
803
|
+
const paths = params.checkpointPaths.map((path) => repoRelative(context.repoRoot, path));
|
|
804
|
+
const worktree = ensureExecWorktree({
|
|
805
|
+
repoRoot: context.repoRoot,
|
|
806
|
+
worktreeBase: base,
|
|
807
|
+
taskId: worktreeTaskId,
|
|
808
|
+
});
|
|
809
|
+
for (const path of paths)
|
|
810
|
+
copyCheckpointPath(context.repoRoot, worktree.path, path);
|
|
811
|
+
stageCommitTargets(worktree.path, paths);
|
|
812
|
+
const checkpoint = gitResult(worktree.path, ["diff", "--cached", "--quiet", "--", ...paths]);
|
|
813
|
+
if (checkpoint.status === 1) {
|
|
814
|
+
const committed = gitResult(worktree.path, [
|
|
815
|
+
"commit",
|
|
816
|
+
"-m",
|
|
817
|
+
params.commitMessage,
|
|
818
|
+
"--",
|
|
819
|
+
...paths,
|
|
820
|
+
]);
|
|
821
|
+
if (committed.status !== 0) {
|
|
822
|
+
// A failing git hook (pre-commit / commit-msg) aborts the commit but leaves the staged
|
|
823
|
+
// paths in the index. Unstage everything so the residue does not trip the staged-changes
|
|
824
|
+
// guard for every subsequent task and abort the whole loop. The index was verified clean
|
|
825
|
+
// above, so a full reset only drops what this checkpoint (and its hooks) staged.
|
|
826
|
+
gitResult(worktree.path, ["reset", "--quiet"]);
|
|
827
|
+
// hook(lefthook 等)の生出力には ANSI エスケープや制御文字が含まれうる。この detail は
|
|
828
|
+
// register 経路で pjr-index の結論列・result の理由欄へ伝播するため、ここで除去して
|
|
829
|
+
// 表示崩れを防ぐ(register 側の sanitize と二重だが、非 register の呼び出し元も守る)。
|
|
830
|
+
const detail = [committed.stdout, committed.stderr]
|
|
831
|
+
.map((part) => typeof part === "string" ? stripTerminalControlSequences(part).trim() : "")
|
|
832
|
+
.filter(Boolean)
|
|
833
|
+
.join("\n");
|
|
834
|
+
throw new Error(`Checkpoint commit failed (${params.commitMessage}); staged changes rolled back (likely a failing git hook):\n${detail}`);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
else if (checkpoint.status !== 0) {
|
|
838
|
+
throw new Error("Failed to inspect execution checkpoint changes.");
|
|
839
|
+
}
|
|
840
|
+
return worktree;
|
|
841
|
+
}
|
|
842
|
+
return ensureExecWorktree({
|
|
843
|
+
repoRoot: context.repoRoot,
|
|
844
|
+
worktreeBase: base,
|
|
845
|
+
taskId: worktreeTaskId,
|
|
846
|
+
});
|
|
847
|
+
}
|