specdojo 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/agents/specdojo-orchestrator.md +3 -2
- package/CHANGELOG.md +153 -0
- package/dist/catalog/build.js +24 -1
- package/dist/catalog/plan.js +1 -1
- package/dist/catalog/scaffold.js +4 -1
- package/dist/commands/init.js +5 -1
- package/dist/commands/night-orchestrator.js +6 -4
- package/dist/dashboard/dashboard-timeline.js +18 -16
- package/dist/dashboard/dashboard.js +612 -259
- package/dist/dashboard/epic-plan.js +81 -0
- package/dist/dashboard/exec-records.js +16 -20
- package/dist/dashboard/routines.js +8 -6
- package/dist/dashboard/timeline-build.js +5 -9
- package/dist/dashboard/timeline.js +9 -4
- package/dist/devcontainer/scaffold.js +18 -0
- package/dist/docs/frontmatter-namespace.js +1 -48
- package/dist/docs/yaml-pages.js +125 -3
- package/dist/exec/agent-config.js +22 -0
- package/dist/exec/agent-plan.js +3 -2
- package/dist/exec/commands.js +69 -21
- package/dist/exec/commit-hook-skips.js +78 -0
- package/dist/exec/core.js +19 -7
- package/dist/exec/events.js +159 -8
- package/dist/exec/evidence.js +64 -16
- package/dist/exec/handoff.js +9 -13
- package/dist/exec/limit.js +1 -1
- package/dist/exec/mechanical-result.js +45 -0
- package/dist/exec/migrate-records.js +249 -0
- package/dist/exec/parent-validation.js +153 -12
- package/dist/exec/pipeline-state.js +27 -5
- package/dist/exec/plans-condense-findings.js +89 -0
- package/dist/exec/plans-core.js +24 -17
- package/dist/exec/plans-generation.js +48 -25
- package/dist/exec/plans-grade-findings.js +8 -3
- package/dist/exec/plans-kata-findings.js +61 -0
- package/dist/exec/plans-planning.js +3 -3
- package/dist/exec/plans-storage.js +12 -24
- package/dist/exec/register-resume.js +55 -56
- package/dist/exec/register.js +26 -22
- package/dist/exec/repo-integration-sync.js +8 -4
- package/dist/exec/repo-integration.js +21 -1
- package/dist/exec/reporter.js +121 -23
- package/dist/exec/results.js +85 -24
- package/dist/exec/review-completion.js +47 -0
- package/dist/exec/review-kata.js +109 -0
- package/dist/exec/run/agent-pipeline.js +75 -6
- package/dist/exec/run/agent.js +20 -7
- package/dist/exec/run/in-place.js +69 -32
- package/dist/exec/run/job.js +81 -24
- package/dist/exec/run/lifecycle-commands.js +188 -36
- package/dist/exec/run/mode-shared.js +11 -3
- package/dist/exec/run/register-command.js +6 -10
- package/dist/exec/run/register-core.js +20 -13
- package/dist/exec/run/register-mode.js +12 -12
- package/dist/exec/run/register-post-review.js +21 -9
- package/dist/exec/run/register-resume.js +28 -18
- package/dist/exec/run/register-state.js +10 -7
- package/dist/exec/run/register-worktree.js +60 -30
- package/dist/exec/run/schedule-mode.js +4 -4
- package/dist/exec/run/schedule-prepare.js +201 -59
- package/dist/exec/run/schedule-task.js +129 -25
- package/dist/exec/run/shared.js +4 -3
- package/dist/exec/run/trailing-records.js +35 -0
- package/dist/exec/run-records.js +2 -0
- package/dist/exec/strategy.js +1 -0
- package/dist/exec/trailing-records.js +242 -0
- package/dist/exec/trial-commands.js +3 -2
- package/dist/exec/validate-records-commit.js +110 -0
- package/dist/exec/validate-records.js +148 -0
- package/dist/exec/worktree-command.js +29 -16
- package/dist/exec/worktree-ops-commit.js +119 -48
- package/dist/exec/worktree-ops-lifecycle.js +77 -48
- package/dist/exec/worktree-ops-merge.js +13 -2
- package/dist/exec/worktree-ops.js +2 -2
- package/dist/exec/worktree.js +19 -2
- package/dist/grade/apply.js +32 -6
- package/dist/grade/command-inspect.js +2 -2
- package/dist/grade/command-run.js +2 -0
- package/dist/grade/command-shared.js +1 -1
- package/dist/grade/core.js +18 -5
- package/dist/grade/markdown.js +3 -3
- package/dist/grade/pipeline-state.js +15 -11
- package/dist/grade/plan.js +37 -17
- package/dist/grade/result.js +3 -3
- package/dist/grade/run.js +23 -3
- package/dist/grade/target-discovery.js +17 -4
- package/dist/grade/targets.js +12 -11
- package/dist/job/job.js +31 -17
- package/dist/job/noop.js +104 -0
- package/dist/register/core.js +2 -0
- package/dist/register/create-commands.js +28 -3
- package/dist/register/deliverable-target.js +9 -1
- package/dist/register/epic.js +104 -26
- package/dist/register/event-merge.js +3 -0
- package/dist/register/events.js +4 -0
- package/dist/register/external-project.js +3 -0
- package/dist/register/item.js +6 -0
- package/dist/register/maintenance-commands.js +4 -1
- package/dist/register/planning.js +7 -14
- package/dist/register/register.js +43 -9
- package/dist/register/track-domains.js +34 -0
- package/dist/register/track-plan.js +78 -0
- package/dist/register/transition-commands.js +8 -0
- package/dist/register/work-table.js +64 -0
- package/dist/review/grade.js +35 -13
- package/dist/routine/definition.js +4 -3
- package/dist/routine/failure.js +30 -0
- package/dist/routine/routine.js +56 -32
- package/dist/routine/storage.js +33 -0
- package/dist/schedule/schedule.js +1 -0
- package/dist/schedule/strategy-generate-document.js +26 -14
- package/dist/schedule/strategy-generate-scope.js +17 -45
- package/dist/schedule/strategy-generate.js +33 -3
- package/dist/schedule/strategy-profiles.js +86 -12
- package/dist/shared/agent-types.js +2 -0
- package/dist/shared/condense-records.js +25 -0
- package/dist/shared/deprecation.js +8 -0
- package/dist/shared/document-metadata.js +20 -0
- package/dist/shared/finding-cause.js +20 -0
- package/dist/shared/frontmatter-namespace.js +48 -0
- package/dist/shared/git.js +142 -15
- package/dist/shared/grade-result.js +17 -1
- package/dist/shared/local-state.js +20 -0
- package/dist/shared/markdownlint-config.js +8 -3
- package/dist/shared/plan-conventions.js +129 -0
- package/dist/shared/plan-templates.js +57 -41
- package/dist/shared/run-records.js +224 -0
- package/dist/shared/specdojo-config.js +39 -21
- package/dist/shared/text.js +65 -5
- package/dist/shared/timeline-index.js +2 -0
- package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +9 -2
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +4 -74
- package/docs/ja/specdojo/exec-templates/xep-condense-template.md +50 -0
- package/docs/ja/specdojo/exec-templates/xep-draft-template.md +17 -5
- package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +16 -3
- package/docs/ja/specdojo/exec-templates/xep-recipe-guided-template.md +15 -5
- package/docs/ja/specdojo/exec-templates/xep-recipe-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -1
- package/docs/ja/specdojo/exec-templates/xep-rulebook-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xep-sample-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xep-template-maintenance-template.md +6 -0
- package/docs/ja/specdojo/exec-templates/xer-condense-template.md +25 -0
- package/docs/ja/specdojo/exec-templates/xp-common-conventions-template.md +50 -0
- package/docs/ja/specdojo/exec-templates/xrp-common-conventions-template.md +30 -0
- package/docs/ja/specdojo/guides/branch-workflow-guide.md +1 -1
- package/docs/ja/specdojo/guides/docs-editing-guide.md +12 -0
- package/docs/ja/specdojo/guides/docs-structure-guide.md +48 -15
- package/docs/ja/specdojo/guides/exec-config-guide.md +47 -16
- package/docs/ja/specdojo/guides/exec-operation-guide.md +53 -17
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +20 -11
- package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +92 -55
- package/docs/ja/specdojo/guides/project-move-guide.md +381 -0
- package/docs/ja/specdojo/guides/quick-start-guide.md +70 -14
- package/docs/ja/specdojo/guides/register-operation-guide.md +25 -5
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +2 -0
- package/docs/ja/specdojo/guides/review-guide.md +22 -19
- package/docs/ja/specdojo/guides/routine-operation-guide.md +14 -8
- package/docs/ja/specdojo/guides/ryu-guide.md +23 -13
- package/docs/ja/specdojo/guides/schedule-design-guide.md +7 -4
- package/docs/ja/specdojo/guides/schedule-operation-guide.md +27 -3
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +5 -4
- package/docs/ja/specdojo/guides/timeline-design-guide.md +27 -144
- package/docs/ja/specdojo/guides/use-case-guide.md +92 -155
- package/docs/ja/specdojo/recipes/bac-recipe.md +94 -0
- package/docs/ja/specdojo/recipes/bes-recipe.md +105 -0
- package/docs/ja/specdojo/recipes/br-recipe.md +84 -0
- package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +36 -24
- package/docs/ja/specdojo/recipes/cnd-recipe.md +125 -0
- package/docs/ja/specdojo/recipes/cpd-recipe.md +126 -0
- package/docs/ja/specdojo/recipes/cxd-recipe.md +145 -0
- package/docs/ja/specdojo/recipes/ifd-recipe.md +134 -0
- package/docs/ja/specdojo/recipes/ifx-cmd-recipe.md +135 -86
- package/docs/ja/specdojo/recipes/ifx-index-recipe.md +130 -0
- package/docs/ja/specdojo/recipes/pm-organization-recipe.md +29 -26
- package/docs/ja/specdojo/recipes/pm-plan-recipe.md +35 -26
- package/docs/ja/specdojo/recipes/pm-quality-management-plan-recipe.md +38 -28
- package/docs/ja/specdojo/recipes/pm-raci-recipe.md +39 -31
- package/docs/ja/specdojo/recipes/pm-roles-recipe.md +26 -28
- package/docs/ja/specdojo/recipes/prj-assumptions-constraints-dependencies-recipe.md +10 -8
- package/docs/ja/specdojo/recipes/prj-comparison-of-alternatives-recipe.md +18 -17
- package/docs/ja/specdojo/recipes/stsd-recipe.md +100 -62
- package/docs/ja/specdojo/recipes/sysd-critical-flows-recipe.md +106 -0
- package/docs/ja/specdojo/recipes/sysd-cross-cutting-policy-recipe.md +137 -0
- package/docs/ja/specdojo/recipes/sysd-index-recipe.md +122 -0
- package/docs/ja/specdojo/references/command-reference.md +79 -64
- package/docs/ja/specdojo/references/deliverables-reference.md +9 -4
- package/docs/ja/specdojo/references/directory-layout-reference.md +3 -2
- package/docs/ja/specdojo/references/specdojo-config-reference.md +17 -16
- package/docs/ja/specdojo/rulebooks/bac-rulebook.md +72 -290
- package/docs/ja/specdojo/rulebooks/bdd-rulebook.md +212 -79
- package/docs/ja/specdojo/rulebooks/bds-rulebook.md +138 -154
- package/docs/ja/specdojo/rulebooks/bes-index-rulebook.md +147 -59
- package/docs/ja/specdojo/rulebooks/bes-rulebook.md +100 -96
- package/docs/ja/specdojo/rulebooks/br-rulebook.md +88 -108
- package/docs/ja/specdojo/rulebooks/ccd-mermaid-rulebook.md +126 -211
- package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +56 -35
- package/docs/ja/specdojo/rulebooks/cdsd-rulebook.md +102 -68
- package/docs/ja/specdojo/rulebooks/cdt-rulebook.md +152 -0
- package/docs/ja/specdojo/rulebooks/cld-rulebook.md +9 -184
- package/docs/ja/specdojo/rulebooks/clis-rulebook.md +187 -0
- package/docs/ja/specdojo/rulebooks/cnd-rulebook.md +93 -247
- package/docs/ja/specdojo/rulebooks/cpd-rulebook.md +104 -241
- package/docs/ja/specdojo/rulebooks/cxd-rulebook.md +124 -257
- package/docs/ja/specdojo/rulebooks/dct-index-rulebook.md +87 -98
- package/docs/ja/specdojo/rulebooks/dct-rulebook.md +9 -7
- package/docs/ja/specdojo/rulebooks/dec-rulebook.md +2 -1
- package/docs/ja/specdojo/rulebooks/dss-rulebook.md +193 -0
- package/docs/ja/specdojo/rulebooks/gl-rulebook.md +100 -54
- package/docs/ja/specdojo/rulebooks/ifd-mermaid-rulebook.md +69 -252
- package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +91 -76
- package/docs/ja/specdojo/rulebooks/ifx-file-rulebook.md +252 -226
- package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +118 -40
- package/docs/ja/specdojo/rulebooks/imp-business-rulebook.md +11 -11
- package/docs/ja/specdojo/rulebooks/imp-data-rulebook.md +9 -9
- package/docs/ja/specdojo/rulebooks/imp-interface-rulebook.md +4 -4
- package/docs/ja/specdojo/rulebooks/imp-operations-rulebook.md +11 -11
- package/docs/ja/specdojo/rulebooks/imp-test-rulebook.md +11 -11
- package/docs/ja/specdojo/rulebooks/mm-rulebook.md +4 -3
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +34 -29
- package/docs/ja/specdojo/rulebooks/pm-change-request-log-rulebook.md +8 -8
- package/docs/ja/specdojo/rulebooks/pm-issue-log-rulebook.md +2 -2
- package/docs/ja/specdojo/rulebooks/pm-organization-rulebook.md +50 -56
- package/docs/ja/specdojo/rulebooks/pm-plan-rulebook.md +46 -55
- package/docs/ja/specdojo/rulebooks/pm-quality-management-plan-rulebook.md +57 -54
- package/docs/ja/specdojo/rulebooks/pm-raci-rulebook.md +50 -65
- package/docs/ja/specdojo/rulebooks/pm-risk-register-rulebook.md +2 -2
- package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +70 -97
- package/docs/ja/specdojo/rulebooks/pr-rulebook.md +2 -1
- package/docs/ja/specdojo/rulebooks/prj-assumptions-constraints-dependencies-rulebook.md +47 -56
- package/docs/ja/specdojo/rulebooks/prj-comparison-of-alternatives-rulebook.md +61 -135
- package/docs/ja/specdojo/rulebooks/sf-index-rulebook.md +116 -32
- package/docs/ja/specdojo/rulebooks/sf-rulebook.md +118 -61
- package/docs/ja/specdojo/rulebooks/sld-rulebook.md +152 -57
- package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +51 -39
- package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +101 -46
- package/docs/ja/specdojo/rulebooks/sysd-critical-flows-rulebook.md +72 -329
- package/docs/ja/specdojo/rulebooks/sysd-cross-cutting-policy-rulebook.md +74 -263
- package/docs/ja/specdojo/rulebooks/sysd-index-rulebook.md +78 -195
- package/docs/ja/specdojo/rulebooks/tml-rulebook.md +4 -9
- package/docs/ja/specdojo/rulebooks/trc-requirements-to-specs-rulebook.md +3 -4
- package/docs/ja/specdojo/rulebooks/trc-requirements-to-tests-rulebook.md +3 -3
- package/docs/ja/specdojo/rulebooks/uis-rulebook.md +140 -143
- package/docs/ja/specdojo/samples/bac-sample.md +106 -21
- package/docs/ja/specdojo/samples/bdd-sample.yaml +143 -35
- package/docs/ja/specdojo/samples/bds-sample.md +100 -21
- package/docs/ja/specdojo/samples/bes-index-sample.md +59 -20
- package/docs/ja/specdojo/samples/bes-sample.md +80 -21
- package/docs/ja/specdojo/samples/br-sample.md +68 -14
- package/docs/ja/specdojo/samples/ccd-sample.md +81 -19
- package/docs/ja/specdojo/samples/cdfd-sample.md +172 -99
- package/docs/ja/specdojo/samples/cdfd-uc-sample.md +9 -7
- package/docs/ja/specdojo/samples/cdsd-sample.md +89 -20
- package/docs/ja/specdojo/samples/cdt-sample.md +116 -0
- package/docs/ja/specdojo/samples/cld-sample.md +3 -30
- package/docs/ja/specdojo/samples/clis-sample.md +132 -0
- package/docs/ja/specdojo/samples/cnd-sample.md +127 -21
- package/docs/ja/specdojo/samples/cpd-sample.md +136 -22
- package/docs/ja/specdojo/samples/cxd-sample.md +108 -22
- package/docs/ja/specdojo/samples/dct-index-sample.yaml +63 -17
- package/docs/ja/specdojo/samples/dss-sample.md +175 -0
- package/docs/ja/specdojo/samples/gl-sample.yaml +50 -14
- package/docs/ja/specdojo/samples/ifd-sample.md +105 -21
- package/docs/ja/specdojo/samples/ifx-cmd-sample.yaml +91 -60
- package/docs/ja/specdojo/samples/ifx-file-sample.md +462 -21
- package/docs/ja/specdojo/samples/ifx-index-sample.yaml +87 -19
- package/docs/ja/specdojo/samples/pm-members-sample.yaml +37 -13
- package/docs/ja/specdojo/samples/pm-organization-sample.md +52 -20
- package/docs/ja/specdojo/samples/pm-plan-sample.md +84 -26
- package/docs/ja/specdojo/samples/pm-quality-management-plan-sample.md +55 -22
- package/docs/ja/specdojo/samples/pm-raci-sample.md +69 -28
- package/docs/ja/specdojo/samples/pm-roles-sample.yaml +13 -12
- package/docs/ja/specdojo/samples/prj-assumptions-constraints-dependencies-sample.md +50 -26
- package/docs/ja/specdojo/samples/prj-comparison-of-alternatives-sample.md +89 -62
- package/docs/ja/specdojo/samples/sf-index-sample.md +89 -20
- package/docs/ja/specdojo/samples/sf-sample.md +121 -21
- package/docs/ja/specdojo/samples/sld-sample.md +107 -21
- package/docs/ja/specdojo/samples/stsd-sample.md +54 -26
- package/docs/ja/specdojo/samples/sysd-critical-flows-sample.md +166 -21
- package/docs/ja/specdojo/samples/sysd-cross-cutting-policy-sample.md +178 -21
- package/docs/ja/specdojo/samples/sysd-index-sample.md +82 -21
- package/docs/ja/specdojo/samples/tml-sample.yaml +4 -1
- package/docs/ja/specdojo/samples/uis-sample.md +164 -20
- package/docs/ja/specdojo/standards/document-metadata-standard.md +33 -4
- package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +3 -1
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +1 -0
- package/docs/ja/specdojo/templates/bac-template.md +76 -0
- package/docs/ja/specdojo/templates/bes-template.md +56 -0
- package/docs/ja/specdojo/templates/br-template.md +64 -0
- package/docs/ja/specdojo/templates/cdfd-template.md +81 -54
- package/docs/ja/specdojo/templates/cdfd-uc-template.md +9 -5
- package/docs/ja/specdojo/templates/cnd-template.md +137 -0
- package/docs/ja/specdojo/templates/cpd-template.md +129 -0
- package/docs/ja/specdojo/templates/cxd-template.md +105 -0
- package/docs/ja/specdojo/templates/dct-data-model-cdt-template.yaml +40 -0
- package/docs/ja/specdojo/templates/dct-data-model-cld-template.yaml +7 -14
- package/docs/ja/specdojo/templates/dct-index-template.md +9 -20
- package/docs/ja/specdojo/templates/dct-project-management-template.yaml +5 -1
- package/docs/ja/specdojo/templates/ifd-template.md +86 -0
- package/docs/ja/specdojo/templates/ifx-cmd-template.yaml +44 -28
- package/docs/ja/specdojo/templates/ifx-index-template.yaml +40 -0
- package/docs/ja/specdojo/templates/opr-template.md +2 -4
- package/docs/ja/specdojo/templates/pm-organization-template.md +9 -3
- package/docs/ja/specdojo/templates/pm-plan-template.md +4 -4
- package/docs/ja/specdojo/templates/pm-quality-management-plan-template.md +17 -9
- package/docs/ja/specdojo/templates/pm-raci-template.md +24 -13
- package/docs/ja/specdojo/templates/pm-roles-template.yaml +3 -2
- package/docs/ja/specdojo/templates/prj-assumptions-constraints-dependencies-template.md +6 -3
- package/docs/ja/specdojo/templates/prj-comparison-of-alternatives-template.md +22 -19
- package/docs/ja/specdojo/templates/stsd-template.md +46 -21
- package/docs/ja/specdojo/templates/sysd-critical-flows-template.md +94 -0
- package/docs/ja/specdojo/templates/sysd-cross-cutting-policy-template.md +122 -0
- package/docs/ja/specdojo/templates/sysd-index-template.md +89 -0
- package/docs/specdojo/lib/yaml-metadata.cjs +7 -0
- package/docs/specdojo/schemas/v1/bdd.schema.yaml +25 -57
- package/docs/specdojo/schemas/v1/condense-records.schema.yaml +26 -0
- package/docs/specdojo/schemas/v1/dct.schema.yaml +10 -0
- package/docs/specdojo/schemas/v1/deliverable-frontmatter.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/esil.schema.yaml +7 -141
- package/docs/specdojo/schemas/v1/exec-common.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +53 -3
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +14 -0
- package/docs/specdojo/schemas/v1/exec-result-frontmatter.schema.yaml +18 -0
- package/docs/specdojo/schemas/v1/finding-cause.schema.yaml +22 -0
- package/docs/specdojo/schemas/v1/grade-pipeline-state.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/grade-result.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/ifx-cmd.schema.yaml +65 -5
- package/docs/specdojo/schemas/v1/ifx-index.schema.yaml +142 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +17 -1
- package/package.json +2 -2
- package/templates/antigravity/orchestrator.md +3 -2
- package/templates/claude/agents/specdojo-orchestrator.md +3 -2
- package/templates/codex/agents/specdojo-orchestrator.toml +3 -2
- package/templates/codex/orchestrator.md +3 -2
- package/templates/devcontainer/tmux.conf +6 -0
- package/templates/opencode/agents/specdojo-orchestrator.md +3 -2
package/dist/exec/commands.js
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
|
+
import { Option } from "commander";
|
|
1
2
|
import { existsSync } from "node:fs";
|
|
2
3
|
import { join, resolve as pathResolve } from "node:path";
|
|
3
4
|
import { validateCatalogLocalIds, validateRulebookKata } from "../catalog/build.js";
|
|
4
|
-
import {
|
|
5
|
-
import { eventsDirForProject, generatedDirForProject } from "./project.js";
|
|
6
|
-
import { assertValidActor, getProjectViewpointsPath, loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
7
|
-
import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, selectNextTask, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./schedule/schedule.js";
|
|
8
|
-
import { readReadySnapshot } from "./schedule/ready.js";
|
|
9
|
-
import { displayWidth, nowUtcIsoSeconds, padEndDisplay, requireNonEmpty } from "./shared.js";
|
|
10
|
-
import { archivePlan, buildInPlaceStem, generateDeliverablePlan, generateSinglePlan, resolveDeliverableTarget, stemFromPlanPath, } from "./plans.js";
|
|
5
|
+
import { commonViewpointsPath, scaffoldViewpoints } from "../review/plan.js";
|
|
11
6
|
import { runProviderScaffold, specdojoPackageRootDir } from "../shared/provider-scaffold.js";
|
|
7
|
+
import { assertValidActor, getProjectViewpointsPath, getProjectRoutinesPath, loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
8
|
+
import { DEFAULT_EVENT_MESSAGES, KNOWN_OWNER_LABELS, KNOWN_OWNER_LABELS_TEXT, addCommonAddOptions, addForceOption, addLockOptions, addOwnerOptions, addProjectOptions, addTakeOverOption, ensureActorCanClaimNext, findRosterMember, loadRosterForOpts, loadValidatedExecState, parseApproach, parseTaskMode, printCommandError, resolveClaimOwner, resolveForceOverride, resolveProjectContext, resolveProjectId, resolveSchedulerStrategy, runLockedEventCommand, runReleaseAllBlocked, runSimpleEventCommand, scaffoldClaimResult, } from "./core.js";
|
|
9
|
+
import { acquireSchedulerLock, canBlockTask, canCancelTask, canClaimTask, canCompleteTask, canReleaseTask, canReopenTask, canUnblockTask, claimOwnerOf, computeReadyIds, readAllEventFiles, releaseSchedulerLock, schedulerLockPath, writeEventFile, } from "./events.js";
|
|
10
|
+
import { registerExecHandoffCommands } from "./handoff.js";
|
|
11
|
+
import { registerRecordMigrationCommand } from "./migrate-records.js";
|
|
12
|
+
import { archivePlan, buildInPlaceStem, generateDeliverablePlan, generateSinglePlan, resolveDeliverableTarget, stemFromPlanPath, } from "./plans.js";
|
|
13
|
+
import { eventsDirForProject, generatedDirForProject } from "./project.js";
|
|
12
14
|
import { generateRegisterPlan, normalizePjrId, resolveRegisterRunTarget } from "./register.js";
|
|
13
|
-
import { commonViewpointsPath, scaffoldViewpoints } from "../review/plan.js";
|
|
14
15
|
import { registerCycleCommand, registerResumeCommand, registerRunCommand, registerSlotsCommand, } from "./run/run.js";
|
|
16
|
+
import { readReadySnapshot } from "./schedule/ready.js";
|
|
17
|
+
import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, selectNextTask, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./schedule/schedule.js";
|
|
18
|
+
import { displayWidth, nowUtcIsoSeconds, padEndDisplay, requireNonEmpty } from "./shared.js";
|
|
19
|
+
import { resolveOwnerForLocalId } from "./strategy.js";
|
|
15
20
|
import { buildTaskView } from "./task-view.js";
|
|
16
|
-
import { registerExecWorktreeCommands } from "./worktree-command.js";
|
|
17
21
|
import { registerExecTrialCommands } from "./trial.js";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
22
|
+
import { registerExecWorktreeCommands } from "./worktree-command.js";
|
|
23
|
+
import { validateRunRecordLayout } from "./validate-records.js";
|
|
24
|
+
import { validateRunRecordLayoutAtCommit } from "./validate-records-commit.js";
|
|
21
25
|
export function registerExecCommands(program) {
|
|
22
26
|
const exec = program.command("exec").description("Execution helpers");
|
|
23
27
|
registerExecHandoffCommands(exec);
|
|
28
|
+
registerRecordMigrationCommand(exec);
|
|
24
29
|
const lockedActions = {
|
|
25
30
|
claim: {
|
|
26
31
|
type: "claim",
|
|
@@ -44,7 +49,10 @@ export function registerExecCommands(program) {
|
|
|
44
49
|
},
|
|
45
50
|
unblock: {
|
|
46
51
|
type: "unblock",
|
|
47
|
-
check: ({ schedule, snapshot }, taskId) => canUnblockTask(schedule, snapshot, taskId
|
|
52
|
+
check: ({ schedule, snapshot }, taskId, actor, opts) => canUnblockTask(schedule, snapshot, taskId, {
|
|
53
|
+
requested: !!opts.takeOver,
|
|
54
|
+
isHuman: findRosterMember(loadRosterForOpts(opts), actor)?.type === "human",
|
|
55
|
+
}),
|
|
48
56
|
},
|
|
49
57
|
release: {
|
|
50
58
|
type: "release",
|
|
@@ -79,6 +87,8 @@ export function registerExecCommands(program) {
|
|
|
79
87
|
addOwnerOptions(cmd);
|
|
80
88
|
if (t === "complete" || t === "block" || t === "release")
|
|
81
89
|
addForceOption(cmd);
|
|
90
|
+
if (t === "unblock")
|
|
91
|
+
addTakeOverOption(cmd);
|
|
82
92
|
if (t === "release") {
|
|
83
93
|
cmd.option("--reset-worktree", "Discard the task's exec worktree and branch after releasing (force removal)", false);
|
|
84
94
|
cmd.option("--all-blocked", "Release every blocked task in the project back to todo (ignores --task)", false);
|
|
@@ -97,13 +107,53 @@ export function registerExecCommands(program) {
|
|
|
97
107
|
cmd.action((opts) => runSimpleEventCommand(opts, t));
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
|
-
const vcmd = exec
|
|
110
|
+
const vcmd = exec
|
|
111
|
+
.command("validate")
|
|
112
|
+
.description("Validate schedule, events and run record layout");
|
|
101
113
|
addProjectOptions(vcmd);
|
|
114
|
+
vcmd.option("--records-only", "Check only run record layout and runtime lock exclusion", false);
|
|
115
|
+
vcmd.addOption(new Option("--schedule-only", "Check only schedule and events (used before running tasks)")
|
|
116
|
+
.default(false)
|
|
117
|
+
.conflicts("recordsOnly"));
|
|
118
|
+
vcmd.option("--commit <rev>", "With --records-only, check the run records in the tree of <rev> instead of the working tree");
|
|
102
119
|
vcmd.action((opts) => {
|
|
103
120
|
try {
|
|
104
|
-
const { schedulePath, catalogPath } = resolveProjectContext(opts);
|
|
121
|
+
const { schedulePath, catalogPath, executionPath } = resolveProjectContext(opts);
|
|
122
|
+
const { config } = loadConfig();
|
|
123
|
+
const project = config?.projects[resolveProjectId(opts)];
|
|
124
|
+
const routinesPath = project && getProjectRoutinesPath(project);
|
|
125
|
+
if (opts.commit !== undefined && !opts.recordsOnly)
|
|
126
|
+
throw new Error("--commit requires --records-only");
|
|
127
|
+
const layoutOptions = {
|
|
128
|
+
executionPath,
|
|
129
|
+
repoRoot: specdojoRootDir(),
|
|
130
|
+
...(routinesPath ? { routinesPath: pathResolve(specdojoRootDir(), routinesPath) } : {}),
|
|
131
|
+
};
|
|
132
|
+
const layoutIssues = opts.scheduleOnly
|
|
133
|
+
? []
|
|
134
|
+
: typeof opts.commit === "string"
|
|
135
|
+
? validateRunRecordLayoutAtCommit({ ...layoutOptions, commit: opts.commit })
|
|
136
|
+
: validateRunRecordLayout(layoutOptions);
|
|
137
|
+
if (opts.recordsOnly) {
|
|
138
|
+
for (const issue of layoutIssues)
|
|
139
|
+
process.stdout.write(`ERROR: ${issue.path}: [${issue.reason}] ${issue.message}\n`);
|
|
140
|
+
if (!layoutIssues.length)
|
|
141
|
+
process.stdout.write(`OK: run record layout validation passed${typeof opts.commit === "string" ? ` (${opts.commit})` : ""}\n`);
|
|
142
|
+
exitWithCode(layoutIssues.length === 0);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
105
145
|
const res = validateAll(schedulePath);
|
|
146
|
+
for (const issue of layoutIssues) {
|
|
147
|
+
const message = `${issue.path}: [${issue.reason}] ${issue.message}`;
|
|
148
|
+
if (issue.reason !== "missing")
|
|
149
|
+
res.errors.push(message);
|
|
150
|
+
}
|
|
151
|
+
res.ok = res.errors.length === 0;
|
|
106
152
|
printValidateResult(res);
|
|
153
|
+
for (const issue of layoutIssues) {
|
|
154
|
+
if (issue.reason === "missing")
|
|
155
|
+
process.stdout.write(`WARN: ${issue.path}: [${issue.reason}] ${issue.message}\n`);
|
|
156
|
+
}
|
|
107
157
|
// Scheduled tasks resolve their deliverable by bare local_id, so warn when a
|
|
108
158
|
// local_id is not unique project-wide across the catalogs.
|
|
109
159
|
if (catalogPath && existsSync(catalogPath)) {
|
|
@@ -239,12 +289,12 @@ export function registerExecCommands(program) {
|
|
|
239
289
|
});
|
|
240
290
|
const archiveCmd = exec
|
|
241
291
|
.command("archive")
|
|
242
|
-
.description("
|
|
292
|
+
.description("Keep a completed run plan in its run directory, or delete it");
|
|
243
293
|
addProjectOptions(archiveCmd);
|
|
244
294
|
archiveCmd.option("--task <taskId>", "Scheduled task ID whose plan to archive");
|
|
245
295
|
archiveCmd.option("--deliverable <localId>", "Catalog deliverable local_id (unique project-wide)");
|
|
246
296
|
archiveCmd.option("--plan <path>", "Plan file to archive (for unique-named in-place plans)");
|
|
247
|
-
archiveCmd.option("--delete", "Delete the plan instead of
|
|
297
|
+
archiveCmd.option("--delete", "Delete the plan instead of retaining it", false);
|
|
248
298
|
archiveCmd.action((opts) => {
|
|
249
299
|
try {
|
|
250
300
|
const { executionPath, catalogPath } = resolveProjectContext(opts);
|
|
@@ -254,8 +304,6 @@ export function registerExecCommands(program) {
|
|
|
254
304
|
if ([hasTask, hasDeliverable, hasPlan].filter(Boolean).length !== 1) {
|
|
255
305
|
throw new Error("Specify exactly one of --task, --deliverable, or --plan.");
|
|
256
306
|
}
|
|
257
|
-
// `archivePlan` rebuilds `<slug>-plan.md`; for --plan the stem recovered from the filename
|
|
258
|
-
// is that slug, so a unique-named in-place plan archives to done/ like a fixed-name one.
|
|
259
307
|
const slug = hasPlan
|
|
260
308
|
? stemFromPlanPath(opts.plan.trim())
|
|
261
309
|
: hasTask
|
|
@@ -508,7 +556,7 @@ export function registerExecCommands(program) {
|
|
|
508
556
|
const filterBy = typeof opts.by === "string" ? opts.by.trim() : undefined;
|
|
509
557
|
const entries = Object.entries(snapshot.tasks)
|
|
510
558
|
.filter(([, cs]) => cs.state === filterState)
|
|
511
|
-
.filter(([, cs]) => !filterBy || cs
|
|
559
|
+
.filter(([, cs]) => !filterBy || claimOwnerOf(cs) === filterBy)
|
|
512
560
|
.sort(([a], [b]) => a.localeCompare(b));
|
|
513
561
|
if (entries.length === 0) {
|
|
514
562
|
const byMsg = filterBy ? ` for ${filterBy}` : "";
|
|
@@ -521,7 +569,7 @@ export function registerExecCommands(program) {
|
|
|
521
569
|
const rows = entries.map(([taskId, cs]) => ({
|
|
522
570
|
taskId,
|
|
523
571
|
name: schedule.nodes.get(taskId)?.name ?? "-",
|
|
524
|
-
by: cs
|
|
572
|
+
by: claimOwnerOf(cs) ?? "-",
|
|
525
573
|
ts: cs.last_ts ?? "-",
|
|
526
574
|
}));
|
|
527
575
|
// Size every column to its longest value (including the header) so nothing is truncated.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { parentValidationLabels, recordedParentValidationLabel } from "./parent-validation.js";
|
|
2
|
+
import { recordedRunValidations } from "./pipeline-state.js";
|
|
3
|
+
// LEFTHOOK_EXCLUDE はコンマ区切りのため、hook のコマンド名にコンマや空白を許さない。
|
|
4
|
+
const HOOK_NAME_PATTERN = /^[A-Za-z0-9_.-]+$/;
|
|
5
|
+
function isRecord(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
/** Validates `pipeline.commit_hook_skips` against the configured parent validations. */
|
|
9
|
+
export function resolveCommitHookSkips(value, parentValidationEntries) {
|
|
10
|
+
if (value === undefined)
|
|
11
|
+
return [];
|
|
12
|
+
if (!Array.isArray(value)) {
|
|
13
|
+
throw new Error("pipeline.commit_hook_skips in exec-defaults must be an array");
|
|
14
|
+
}
|
|
15
|
+
const labels = new Set(parentValidationLabels(parentValidationEntries));
|
|
16
|
+
const seen = new Set();
|
|
17
|
+
return value.map((entry, index) => {
|
|
18
|
+
const where = `pipeline.commit_hook_skips[${index}] in exec-defaults`;
|
|
19
|
+
if (!isRecord(entry))
|
|
20
|
+
throw new Error(`${where} must be { hook, covered_by }`);
|
|
21
|
+
const unknownKeys = Object.keys(entry).filter((key) => key !== "hook" && key !== "covered_by");
|
|
22
|
+
if (unknownKeys.length > 0) {
|
|
23
|
+
throw new Error(`${where}: unknown key(s) ${unknownKeys.sort().join(", ")}`);
|
|
24
|
+
}
|
|
25
|
+
if (typeof entry.hook !== "string" || !HOOK_NAME_PATTERN.test(entry.hook)) {
|
|
26
|
+
throw new Error(`${where}.hook must match ${String(HOOK_NAME_PATTERN)}`);
|
|
27
|
+
}
|
|
28
|
+
if (seen.has(entry.hook))
|
|
29
|
+
throw new Error(`${where}: duplicate hook ${entry.hook}`);
|
|
30
|
+
seen.add(entry.hook);
|
|
31
|
+
const coveredBy = entry.covered_by;
|
|
32
|
+
if (!Array.isArray(coveredBy) ||
|
|
33
|
+
coveredBy.length === 0 ||
|
|
34
|
+
!coveredBy.every((label) => typeof label === "string")) {
|
|
35
|
+
throw new Error(`${where}.covered_by must be a non-empty array of parent validation ids`);
|
|
36
|
+
}
|
|
37
|
+
const unknownLabels = coveredBy.filter((label) => !labels.has(label));
|
|
38
|
+
if (unknownLabels.length > 0) {
|
|
39
|
+
throw new Error(`${where}.covered_by is not in pipeline.parent_validations: ${unknownLabels.join(", ")}`);
|
|
40
|
+
}
|
|
41
|
+
return { hook: entry.hook, covered_by: [...coveredBy] };
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Hook commands the integration commit may skip: those whose every covering parent validation
|
|
46
|
+
* is recorded by the runner as `passed`. A validation skipped by change type (`not_applicable`)
|
|
47
|
+
* does not cover the hook, so the hook still runs when its own glob matches.
|
|
48
|
+
*/
|
|
49
|
+
export function integrationCommitHookExclusions(skips, validations) {
|
|
50
|
+
const passed = new Set(validations
|
|
51
|
+
.filter((validation) => validation.source === "runner" && validation.status === "passed")
|
|
52
|
+
.map(recordedParentValidationLabel));
|
|
53
|
+
return skips
|
|
54
|
+
.filter((skip) => skip.covered_by.every((label) => passed.has(label)))
|
|
55
|
+
.map((skip) => skip.hook);
|
|
56
|
+
}
|
|
57
|
+
/** Environment for the integration commit; merges with an inherited LEFTHOOK_EXCLUDE. */
|
|
58
|
+
export function lefthookExcludeEnvironment(hooks, inherited = process.env.LEFTHOOK_EXCLUDE) {
|
|
59
|
+
if (hooks.length === 0)
|
|
60
|
+
return undefined;
|
|
61
|
+
const names = [
|
|
62
|
+
...new Set([
|
|
63
|
+
...(inherited ?? "")
|
|
64
|
+
.split(",")
|
|
65
|
+
.map((name) => name.trim())
|
|
66
|
+
.filter(Boolean),
|
|
67
|
+
...hooks,
|
|
68
|
+
]),
|
|
69
|
+
];
|
|
70
|
+
return { LEFTHOOK_EXCLUDE: names.join(",") };
|
|
71
|
+
}
|
|
72
|
+
/** Hook commands to skip in a run's integration commit, from its recorded parent validations. */
|
|
73
|
+
export function integrationCommitSkipHooks(params) {
|
|
74
|
+
const skips = resolveCommitHookSkips(params.pipeline?.commit_hook_skips, params.pipeline?.parent_validations);
|
|
75
|
+
if (skips.length === 0)
|
|
76
|
+
return [];
|
|
77
|
+
return integrationCommitHookExclusions(skips, recordedRunValidations(params.worktreePath, params.pipelineStatePath));
|
|
78
|
+
}
|
package/dist/exec/core.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { acquireSchedulerLock, buildEvent, canReleaseTask, collectRepeatable, findDoingTasksForActor, foldEventsToState, readAllEventFiles, releaseSchedulerLock, writeEventFile, } from "./events.js";
|
|
2
|
-
import { activateResolvedProjectPaths, resolveProjectPaths } from "./project.js";
|
|
3
1
|
import { assertValidActor, loadConfig, loadMemberRoster, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
4
|
-
import {
|
|
5
|
-
import { qualifyTaskId, requireNonEmpty } from "./shared.js";
|
|
2
|
+
import { acquireSchedulerLock, buildEvent, canReleaseTask, collectRepeatable, findDoingTasksForActor, foldEventsToState, readAllEventFiles, releaseSchedulerLock, writeEventFile, } from "./events.js";
|
|
6
3
|
import { finalizeResultSectionsForDeliverable, targetDocIdsForScheduledTask } from "./plans.js";
|
|
4
|
+
import { activateResolvedProjectPaths, resolveProjectPaths } from "./project.js";
|
|
7
5
|
import { resetResultForClaim, scaffoldResult } from "./results.js";
|
|
8
|
-
import {
|
|
9
|
-
import { configuredProductRepos } from "./task-repos.js";
|
|
6
|
+
import { recordPathForRead, recordRef } from "./run-records.js";
|
|
10
7
|
import { buildInitialStateFromStrategy } from "./schedule/initial.js";
|
|
8
|
+
import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./schedule/schedule.js";
|
|
9
|
+
import { qualifyTaskId, requireNonEmpty } from "./shared.js";
|
|
11
10
|
import { buildPhaseModeIndex, resolveApproach, resolveTaskExecution, resolveTaskMode, } from "./strategy.js";
|
|
11
|
+
import { configuredProductRepos } from "./task-repos.js";
|
|
12
|
+
import { discardStaleExecWorktree } from "./worktree-ops.js";
|
|
12
13
|
export const KNOWN_OWNER_LABELS = ["PO", "PM", "BA", "ARC", "DEV", "QE", "UX", "OPS"];
|
|
13
14
|
export const KNOWN_OWNER_LABELS_TEXT = KNOWN_OWNER_LABELS.join("|");
|
|
14
15
|
const KNOWN_APPROACHES = [
|
|
15
16
|
"draft",
|
|
16
17
|
"fully-guided",
|
|
18
|
+
"condense",
|
|
17
19
|
"recipe-guided",
|
|
18
20
|
"freeform",
|
|
19
21
|
"bootstrap",
|
|
@@ -58,6 +60,9 @@ export function addLockOptions(cmd) {
|
|
|
58
60
|
export function addForceOption(cmd) {
|
|
59
61
|
return cmd.option("--force", "Human actor only: override the guard on a task held by another actor", false);
|
|
60
62
|
}
|
|
63
|
+
export function addTakeOverOption(cmd) {
|
|
64
|
+
return cmd.option("--take-over", "Human actor only: become the claim owner instead of keeping the current owner (e.g. an agent run)", false);
|
|
65
|
+
}
|
|
61
66
|
export function addOwnerOptions(cmd) {
|
|
62
67
|
return cmd
|
|
63
68
|
.option("--owner <owner>", `Planned owner label for assignment checks (${KNOWN_OWNER_LABELS_TEXT}; defaults to SPECDOJO_OWNER, roster owner, or actor)`)
|
|
@@ -216,7 +221,11 @@ export async function scaffoldClaimResult(opts) {
|
|
|
216
221
|
taskId: opts.taskId,
|
|
217
222
|
mode,
|
|
218
223
|
projectId: opts.projectId,
|
|
219
|
-
...(execution === "agent"
|
|
224
|
+
...(execution === "agent"
|
|
225
|
+
? {
|
|
226
|
+
planRef: recordRef(opts.executionPath, recordPathForRead(opts.executionPath, "plan", opts.taskId)),
|
|
227
|
+
}
|
|
228
|
+
: {}),
|
|
220
229
|
agent: opts.actor,
|
|
221
230
|
startedAt: opts.startedAt,
|
|
222
231
|
execution,
|
|
@@ -304,6 +313,9 @@ export async function runLockedEventCommand(opts, action) {
|
|
|
304
313
|
event.meta.owner_override = true;
|
|
305
314
|
}
|
|
306
315
|
}
|
|
316
|
+
if (action.type === "unblock" && resolvedOpts.takeOver) {
|
|
317
|
+
event.meta = { ...(event.meta ?? {}), take_over: true };
|
|
318
|
+
}
|
|
307
319
|
if (opts.dryRun) {
|
|
308
320
|
process.stdout.write(`[dry-run] ${JSON.stringify(event, null, 2)}\n`);
|
|
309
321
|
if (action.type === "release" && opts.resetWorktree) {
|
package/dist/exec/events.js
CHANGED
|
@@ -53,6 +53,133 @@ export function validateEventShape(obj, source) {
|
|
|
53
53
|
export function isExecEventV1(value, source) {
|
|
54
54
|
return validateEventShape(value, source).length === 0;
|
|
55
55
|
}
|
|
56
|
+
function advanceTaskState(state, event) {
|
|
57
|
+
if (event.type === "claim")
|
|
58
|
+
return "doing";
|
|
59
|
+
if (event.type === "block")
|
|
60
|
+
return "blocked";
|
|
61
|
+
if (event.type === "unblock")
|
|
62
|
+
return "doing";
|
|
63
|
+
if (event.type === "complete")
|
|
64
|
+
return "done";
|
|
65
|
+
if (event.type === "reopen")
|
|
66
|
+
return state === "done" ? "todo" : state;
|
|
67
|
+
if (event.type === "release") {
|
|
68
|
+
return state === "doing" || state === "blocked" ? "todo" : state;
|
|
69
|
+
}
|
|
70
|
+
if (event.type === "cancel") {
|
|
71
|
+
if (state === "todo")
|
|
72
|
+
return "cancelled";
|
|
73
|
+
if (state === "doing" || state === "blocked")
|
|
74
|
+
return "todo";
|
|
75
|
+
return "cancelled";
|
|
76
|
+
}
|
|
77
|
+
return state;
|
|
78
|
+
}
|
|
79
|
+
function isTransitionValidForState(state, lastBy, candidate, remaining) {
|
|
80
|
+
const { type } = candidate;
|
|
81
|
+
if (type === "note" || type === "estimate" || type === "link")
|
|
82
|
+
return true;
|
|
83
|
+
if (state === "todo") {
|
|
84
|
+
if (type === "cancel")
|
|
85
|
+
return true;
|
|
86
|
+
if (type !== "claim")
|
|
87
|
+
return false;
|
|
88
|
+
const otherClaims = remaining.filter((item) => item.event !== candidate && item.event.type === "claim");
|
|
89
|
+
if (otherClaims.length === 0)
|
|
90
|
+
return true;
|
|
91
|
+
const isResumeClaim = candidate.meta?.pipeline_resume_claimed === "true";
|
|
92
|
+
if (isResumeClaim &&
|
|
93
|
+
otherClaims.some((item) => item.event.meta?.pipeline_resume_claimed !== "true")) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const actorReleasedOrBlocked = (actor) => remaining.some((item) => (item.event.type === "release" || item.event.type === "block") && item.event.by === actor);
|
|
97
|
+
if (!actorReleasedOrBlocked(candidate.by) &&
|
|
98
|
+
otherClaims.some((item) => actorReleasedOrBlocked(item.event.by))) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
if (state === "doing") {
|
|
104
|
+
if (type !== "block" && type !== "complete" && type !== "release" && type !== "cancel") {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (lastBy &&
|
|
108
|
+
candidate.by !== lastBy &&
|
|
109
|
+
remaining.some((item) => (item.event.type === "block" ||
|
|
110
|
+
item.event.type === "complete" ||
|
|
111
|
+
item.event.type === "release" ||
|
|
112
|
+
item.event.type === "cancel") &&
|
|
113
|
+
item.event.by === lastBy)) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (type === "complete" &&
|
|
117
|
+
remaining.some((item) => item.event.type === "unblock") &&
|
|
118
|
+
!remaining.some((item) => item.event.type === "reopen") &&
|
|
119
|
+
remaining.some((item) => item.event.type === "block" && (!lastBy || item.event.by === lastBy))) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
if (state === "blocked") {
|
|
125
|
+
return type === "unblock" || type === "release" || type === "cancel";
|
|
126
|
+
}
|
|
127
|
+
if (state === "done") {
|
|
128
|
+
return type === "reopen";
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
function orderSameTimestampEventsByState(items) {
|
|
133
|
+
const taskStates = new Map();
|
|
134
|
+
for (let start = 0; start < items.length;) {
|
|
135
|
+
const ts = items[start].event.ts;
|
|
136
|
+
let end = start + 1;
|
|
137
|
+
while (end < items.length && items[end].event.ts === ts)
|
|
138
|
+
end += 1;
|
|
139
|
+
if (end - start === 1) {
|
|
140
|
+
const { event } = items[start];
|
|
141
|
+
const cur = taskStates.get(event.task_id) ?? { state: "todo" };
|
|
142
|
+
taskStates.set(event.task_id, {
|
|
143
|
+
state: advanceTaskState(cur.state, event),
|
|
144
|
+
lastBy: event.by,
|
|
145
|
+
});
|
|
146
|
+
start = end;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const byTask = new Map();
|
|
150
|
+
for (let i = start; i < end; i += 1) {
|
|
151
|
+
const taskId = items[i].event.task_id;
|
|
152
|
+
const indices = byTask.get(taskId);
|
|
153
|
+
if (indices)
|
|
154
|
+
indices.push(i);
|
|
155
|
+
else
|
|
156
|
+
byTask.set(taskId, [i]);
|
|
157
|
+
}
|
|
158
|
+
for (const [taskId, indices] of byTask.entries()) {
|
|
159
|
+
let cur = taskStates.get(taskId) ?? { state: "todo" };
|
|
160
|
+
if (indices.length === 1) {
|
|
161
|
+
const { event } = items[indices[0]];
|
|
162
|
+
taskStates.set(taskId, {
|
|
163
|
+
state: advanceTaskState(cur.state, event),
|
|
164
|
+
lastBy: event.by,
|
|
165
|
+
});
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const remaining = indices.map((idx) => items[idx]);
|
|
169
|
+
for (const targetIdx of indices) {
|
|
170
|
+
const validIdx = remaining.findIndex((candidate) => isTransitionValidForState(cur.state, cur.lastBy, candidate.event, remaining));
|
|
171
|
+
const [chosen] = remaining.splice(validIdx >= 0 ? validIdx : 0, 1);
|
|
172
|
+
items[targetIdx] = chosen;
|
|
173
|
+
cur = {
|
|
174
|
+
state: advanceTaskState(cur.state, chosen.event),
|
|
175
|
+
lastBy: chosen.event.by,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
taskStates.set(taskId, cur);
|
|
179
|
+
}
|
|
180
|
+
start = end;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
56
183
|
export function readAllEventFiles(projectPath) {
|
|
57
184
|
const dir = eventsDirForProject(projectPath);
|
|
58
185
|
const files = listFilesRecursive(dir).filter((p) => extname(p).toLowerCase() === ".json");
|
|
@@ -92,6 +219,7 @@ export function readAllEventFiles(projectPath) {
|
|
|
92
219
|
return orderA - orderB;
|
|
93
220
|
return a.path.localeCompare(b.path);
|
|
94
221
|
});
|
|
222
|
+
orderSameTimestampEventsByState(items);
|
|
95
223
|
return items;
|
|
96
224
|
}
|
|
97
225
|
export function buildEvent(type, o) {
|
|
@@ -135,6 +263,17 @@ export function writeEventFile(projectPath, event, dependencies = {}) {
|
|
|
135
263
|
}
|
|
136
264
|
}
|
|
137
265
|
}
|
|
266
|
+
// The actor that owns the claim of a doing/blocked task. Snapshots built before claimed_by existed
|
|
267
|
+
// (or hand-built ones) fall back to last_by.
|
|
268
|
+
export function claimOwnerOf(state) {
|
|
269
|
+
return state?.claimed_by ?? state?.last_by;
|
|
270
|
+
}
|
|
271
|
+
// `exec unblock --take-over` records take_over=true so the unblocking (human) actor becomes the claim
|
|
272
|
+
// owner. A plain unblock keeps the existing owner so the agent run can resume and complete.
|
|
273
|
+
export function isTakeOverEvent(event) {
|
|
274
|
+
const value = event.meta?.take_over;
|
|
275
|
+
return value === true || value === "true";
|
|
276
|
+
}
|
|
138
277
|
export function foldEventsToState(events, schedule, projectPath, initialTasks) {
|
|
139
278
|
const tasks = initialTasks ? { ...initialTasks } : {};
|
|
140
279
|
function ensure(id) {
|
|
@@ -146,6 +285,7 @@ export function foldEventsToState(events, schedule, projectPath, initialTasks) {
|
|
|
146
285
|
if (!schedule.nodes.has(event.task_id))
|
|
147
286
|
continue;
|
|
148
287
|
const cur = ensure(event.task_id);
|
|
288
|
+
const previousOwner = claimOwnerOf(cur);
|
|
149
289
|
cur.last_ts = event.ts;
|
|
150
290
|
cur.last_by = event.by;
|
|
151
291
|
cur.last_type = event.type;
|
|
@@ -190,6 +330,13 @@ export function foldEventsToState(events, schedule, projectPath, initialTasks) {
|
|
|
190
330
|
else
|
|
191
331
|
cur.state = "cancelled";
|
|
192
332
|
}
|
|
333
|
+
if (cur.state === "doing" || cur.state === "blocked") {
|
|
334
|
+
const movesClaim = event.type === "claim" || (event.type === "unblock" && isTakeOverEvent(event));
|
|
335
|
+
cur.claimed_by = movesClaim ? event.by : (previousOwner ?? event.by);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
delete cur.claimed_by;
|
|
339
|
+
}
|
|
193
340
|
}
|
|
194
341
|
for (const id of schedule.nodes.keys())
|
|
195
342
|
ensure(id);
|
|
@@ -231,7 +378,7 @@ export function computeReadyIds(schedule, snapshot) {
|
|
|
231
378
|
}
|
|
232
379
|
export function findDoingTasksForActor(snapshot, actor) {
|
|
233
380
|
return Object.entries(snapshot.tasks)
|
|
234
|
-
.filter(([, st]) => st.state === "doing" && st
|
|
381
|
+
.filter(([, st]) => st.state === "doing" && claimOwnerOf(st) === actor)
|
|
235
382
|
.map(([taskId]) => taskId)
|
|
236
383
|
.sort();
|
|
237
384
|
}
|
|
@@ -290,8 +437,8 @@ export function canCompleteTask(schedule, snapshot, taskId, actor, override) {
|
|
|
290
437
|
return { ok: false, reason: `task cancelled: ${taskId}` };
|
|
291
438
|
if (state !== "doing")
|
|
292
439
|
return { ok: false, reason: `task is not doing: ${taskId}` };
|
|
293
|
-
if (cur
|
|
294
|
-
return { ok: false, reason: crossActorReason(cur
|
|
440
|
+
if (claimOwnerOf(cur) !== actor && !canOverrideCrossActor(override)) {
|
|
441
|
+
return { ok: false, reason: crossActorReason(claimOwnerOf(cur)) };
|
|
295
442
|
}
|
|
296
443
|
return { ok: true };
|
|
297
444
|
}
|
|
@@ -363,12 +510,12 @@ export function canBlockTask(schedule, snapshot, taskId, actor, override) {
|
|
|
363
510
|
return { ok: false, reason: `task cancelled: ${taskId}` };
|
|
364
511
|
if (state !== "doing")
|
|
365
512
|
return { ok: false, reason: `task is not doing: ${taskId}` };
|
|
366
|
-
if (cur
|
|
367
|
-
return { ok: false, reason: crossActorReason(cur
|
|
513
|
+
if (claimOwnerOf(cur) !== actor && !canOverrideCrossActor(override)) {
|
|
514
|
+
return { ok: false, reason: crossActorReason(claimOwnerOf(cur)) };
|
|
368
515
|
}
|
|
369
516
|
return { ok: true };
|
|
370
517
|
}
|
|
371
|
-
export function canUnblockTask(schedule, snapshot, taskId) {
|
|
518
|
+
export function canUnblockTask(schedule, snapshot, taskId, takeOver) {
|
|
372
519
|
const node = schedule.nodes.get(taskId);
|
|
373
520
|
if (!node)
|
|
374
521
|
return { ok: false, reason: `task not found in schedule: ${taskId}` };
|
|
@@ -386,6 +533,10 @@ export function canUnblockTask(schedule, snapshot, taskId) {
|
|
|
386
533
|
return { ok: false, reason: `task cancelled: ${taskId}` };
|
|
387
534
|
if (state !== "blocked")
|
|
388
535
|
return { ok: false, reason: `task is not blocked: ${taskId}` };
|
|
536
|
+
// Taking over moves the claim away from its owner, so it is limited to humans like --force.
|
|
537
|
+
if (takeOver?.requested && !takeOver.isHuman) {
|
|
538
|
+
return { ok: false, reason: `--take-over requires a human actor: ${taskId}` };
|
|
539
|
+
}
|
|
389
540
|
return { ok: true };
|
|
390
541
|
}
|
|
391
542
|
// release returns a doing/blocked task to todo for re-execution. Only the claiming actor may
|
|
@@ -408,8 +559,8 @@ export function canReleaseTask(schedule, snapshot, taskId, actor, override) {
|
|
|
408
559
|
if (state !== "doing" && state !== "blocked") {
|
|
409
560
|
return { ok: false, reason: `task is not doing or blocked: ${taskId}` };
|
|
410
561
|
}
|
|
411
|
-
if (cur
|
|
412
|
-
return { ok: false, reason: crossActorReason(cur
|
|
562
|
+
if (claimOwnerOf(cur) !== actor && !canOverrideCrossActor(override)) {
|
|
563
|
+
return { ok: false, reason: crossActorReason(claimOwnerOf(cur)) };
|
|
413
564
|
}
|
|
414
565
|
return { ok: true };
|
|
415
566
|
}
|