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
|
@@ -2,7 +2,7 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { gitEnvironment } from "./worktree.js";
|
|
4
4
|
import { acquirePoolSlot, getActiveExecLocksDir, releaseLock } from "./slot-lock.js";
|
|
5
|
-
import { redactSensitiveText } from "./evidence.js";
|
|
5
|
+
import { MAX_CHANGE_FILES, redactSensitiveText } from "./evidence.js";
|
|
6
6
|
import { PROJECT_REPO_WORKTREE_DIRNAME, REPO_NAME_PATTERN } from "../shared/specdojo-config.js";
|
|
7
7
|
export const MAX_PARENT_VALIDATION_STREAM_BYTES = 1024 * 1024;
|
|
8
8
|
const MAX_SUMMARY_LENGTH = 1_000;
|
|
@@ -164,15 +164,25 @@ function isRecord(value) {
|
|
|
164
164
|
function assignmentLabel(id, repo) {
|
|
165
165
|
return repo === PARENT_VALIDATION_PROJECT_REPO ? id : `${repo}:${id}`;
|
|
166
166
|
}
|
|
167
|
+
function parsePaths(value, where) {
|
|
168
|
+
if (value === undefined)
|
|
169
|
+
return undefined;
|
|
170
|
+
if (!Array.isArray(value) ||
|
|
171
|
+
value.length === 0 ||
|
|
172
|
+
!value.every((pattern) => typeof pattern === "string" && pattern.trim().length > 0)) {
|
|
173
|
+
throw new Error(`${where}.paths must be a non-empty array of non-empty glob strings`);
|
|
174
|
+
}
|
|
175
|
+
return value.map((pattern) => pattern.trim());
|
|
176
|
+
}
|
|
167
177
|
function parseEntry(entry, index) {
|
|
168
178
|
const where = `pipeline.parent_validations[${index}] in exec-defaults`;
|
|
169
179
|
if (typeof entry === "string")
|
|
170
180
|
return { id: entry, repo: PARENT_VALIDATION_PROJECT_REPO };
|
|
171
181
|
if (!isRecord(entry)) {
|
|
172
|
-
throw new Error(`${where} must be a validation id or { id, repo }: ${JSON.stringify(entry)}`);
|
|
182
|
+
throw new Error(`${where} must be a validation id or { id, repo?, paths? }: ${JSON.stringify(entry)}`);
|
|
173
183
|
}
|
|
174
184
|
const unknownKeys = Object.keys(entry)
|
|
175
|
-
.filter((key) => key !== "id" && key !== "repo")
|
|
185
|
+
.filter((key) => key !== "id" && key !== "repo" && key !== "paths")
|
|
176
186
|
.sort();
|
|
177
187
|
if (unknownKeys.length > 0) {
|
|
178
188
|
throw new Error(`${where}: unknown key(s) ${unknownKeys.map((key) => `"${key}"`).join(", ")}`);
|
|
@@ -180,17 +190,22 @@ function parseEntry(entry, index) {
|
|
|
180
190
|
if (typeof entry.id !== "string" || entry.id.length === 0) {
|
|
181
191
|
throw new Error(`${where}.id must be a non-empty string`);
|
|
182
192
|
}
|
|
183
|
-
|
|
193
|
+
const paths = parsePaths(entry.paths, where);
|
|
194
|
+
if (entry.repo === undefined && paths === undefined) {
|
|
195
|
+
throw new Error(`${where} must set repo or paths when written as an object`);
|
|
196
|
+
}
|
|
197
|
+
const repo = entry.repo ?? PARENT_VALIDATION_PROJECT_REPO;
|
|
198
|
+
if (typeof repo !== "string" || !REPO_NAME_PATTERN.test(repo)) {
|
|
184
199
|
throw new Error(`${where}.repo must match ${String(REPO_NAME_PATTERN)} (got ${JSON.stringify(entry.repo)})`);
|
|
185
200
|
}
|
|
186
|
-
return { id: entry.id, repo:
|
|
201
|
+
return { id: entry.id, repo, ...(paths ? { paths } : {}) };
|
|
187
202
|
}
|
|
188
203
|
export function resolveParentValidationAssignments(entries) {
|
|
189
204
|
if (!entries)
|
|
190
205
|
return [];
|
|
191
206
|
const seen = new Set();
|
|
192
207
|
return entries.map((entry, index) => {
|
|
193
|
-
const { id, repo } = parseEntry(entry, index);
|
|
208
|
+
const { id, repo, paths } = parseEntry(entry, index);
|
|
194
209
|
const label = assignmentLabel(id, repo);
|
|
195
210
|
if (seen.has(label)) {
|
|
196
211
|
throw new Error(`Duplicate parent validation id in exec-defaults: ${label}`);
|
|
@@ -202,9 +217,76 @@ export function resolveParentValidationAssignments(entries) {
|
|
|
202
217
|
if (!definition) {
|
|
203
218
|
throw new Error(`Unknown parent validation id in exec-defaults: ${id} (allowed: ${Object.keys(PARENT_VALIDATION_REGISTRY).join(", ")})`);
|
|
204
219
|
}
|
|
205
|
-
return { definition, repo, label };
|
|
220
|
+
return { definition, repo, label, ...(paths ? { paths } : {}) };
|
|
206
221
|
});
|
|
207
222
|
}
|
|
223
|
+
function escapeRegExp(value) {
|
|
224
|
+
return value.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
225
|
+
}
|
|
226
|
+
// lefthook の glob と同じ書き方のうち、`**`・`*`・`?`・入れ子のない `{a,b}` だけを扱う。
|
|
227
|
+
function globSource(pattern) {
|
|
228
|
+
let source = "";
|
|
229
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
230
|
+
const char = pattern[index];
|
|
231
|
+
if (char === "*" && pattern[index + 1] === "*") {
|
|
232
|
+
const followedBySlash = pattern[index + 2] === "/";
|
|
233
|
+
source += followedBySlash ? "(?:.*/)?" : ".*";
|
|
234
|
+
index += followedBySlash ? 2 : 1;
|
|
235
|
+
}
|
|
236
|
+
else if (char === "*") {
|
|
237
|
+
source += "[^/]*";
|
|
238
|
+
}
|
|
239
|
+
else if (char === "?") {
|
|
240
|
+
source += "[^/]";
|
|
241
|
+
}
|
|
242
|
+
else if (char === "{" && pattern.indexOf("}", index) > index) {
|
|
243
|
+
const end = pattern.indexOf("}", index);
|
|
244
|
+
const alternatives = pattern
|
|
245
|
+
.slice(index + 1, end)
|
|
246
|
+
.split(",")
|
|
247
|
+
.map(globSource);
|
|
248
|
+
source += `(?:${alternatives.join("|")})`;
|
|
249
|
+
index = end;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
source += escapeRegExp(char);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return source;
|
|
256
|
+
}
|
|
257
|
+
export function matchesParentValidationPaths(path, patterns) {
|
|
258
|
+
return patterns.some((pattern) => new RegExp(`^${globSource(pattern)}$`).test(path));
|
|
259
|
+
}
|
|
260
|
+
// evidence の変更一覧は、プロジェクトの変更を相対パス、プロダクトの変更を `<repo>:<path>`、
|
|
261
|
+
// 名前の変更を `old -> new` で記録する。割り当てたリポジトリの相対パスへ戻して照合する。
|
|
262
|
+
function changedPathsForRepo(changedPaths, repo, productRepos) {
|
|
263
|
+
const sides = changedPaths.flatMap((path) => path.split(" -> "));
|
|
264
|
+
if (repo !== PARENT_VALIDATION_PROJECT_REPO) {
|
|
265
|
+
const prefix = `${repo}:`;
|
|
266
|
+
return sides.filter((path) => path.startsWith(prefix)).map((path) => path.slice(prefix.length));
|
|
267
|
+
}
|
|
268
|
+
return sides.filter((path) => !productRepos.some((name) => path.startsWith(`${name}:`)));
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Selection from the executor's recorded changes. A truncated change list (the evidence keeps at
|
|
272
|
+
* most MAX_CHANGE_FILES entries) is treated as unknown so no validation is skipped.
|
|
273
|
+
*/
|
|
274
|
+
export function parentValidationSelectionForEvidence(evidence) {
|
|
275
|
+
if (evidence.changes.length >= MAX_CHANGE_FILES)
|
|
276
|
+
return {};
|
|
277
|
+
return { changedPaths: evidence.changes.map((change) => change.path) };
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Whether a validation declared with `paths` is skipped for the given change set. Validations
|
|
281
|
+
* without `paths` always run, and so does every validation when the change set is unknown.
|
|
282
|
+
*/
|
|
283
|
+
export function isParentValidationSkipped(assignment, selection, productRepos = []) {
|
|
284
|
+
const patterns = assignment.paths;
|
|
285
|
+
const changedPaths = selection?.changedPaths;
|
|
286
|
+
if (!patterns || changedPaths === undefined)
|
|
287
|
+
return false;
|
|
288
|
+
return !changedPathsForRepo(changedPaths, assignment.repo, productRepos).some((path) => matchesParentValidationPaths(path, patterns));
|
|
289
|
+
}
|
|
208
290
|
export function resolveParentValidationDefinitions(entries) {
|
|
209
291
|
return resolveParentValidationAssignments(entries).map((assignment) => assignment.definition);
|
|
210
292
|
}
|
|
@@ -291,15 +373,32 @@ function validationSummary(result) {
|
|
|
291
373
|
* without spawning anything. Results carry `repo` when the run spans product repositories or the
|
|
292
374
|
* assignment names one, so single-repository evidence keeps its previous shape.
|
|
293
375
|
*/
|
|
294
|
-
export async function runParentValidationBatch(entries, cwd, invoke = invokeParentValidation) {
|
|
376
|
+
export async function runParentValidationBatch(entries, cwd, invoke = invokeParentValidation, selection) {
|
|
295
377
|
const assignments = resolveParentValidationAssignments(entries);
|
|
296
378
|
const roots = typeof cwd === "string" ? { project: cwd } : cwd;
|
|
297
379
|
const recordsRepo = Object.keys(roots.repos ?? {}).length > 0 ||
|
|
298
380
|
assignments.some((assignment) => assignment.repo !== PARENT_VALIDATION_PROJECT_REPO);
|
|
299
381
|
const validations = [];
|
|
300
382
|
const failureOutputs = [];
|
|
301
|
-
|
|
383
|
+
const productRepos = Object.keys(roots.repos ?? {});
|
|
384
|
+
for (const assignment of assignments) {
|
|
385
|
+
const { definition, repo } = assignment;
|
|
302
386
|
const repoField = recordsRepo ? { repo } : {};
|
|
387
|
+
if (isParentValidationSkipped(assignment, selection, productRepos)) {
|
|
388
|
+
// 変更の種類に合わない検証は流さず、記録だけを残す(PJR-T01P)。ラベルの並びを保つため、
|
|
389
|
+
// 再開時の hasRecordedParentValidations は流し直しを要求しない。
|
|
390
|
+
const reason = truncateHead(`skipped by change type: no changed file matches paths (${(assignment.paths ?? []).join(", ")})`, MAX_SUMMARY_LENGTH);
|
|
391
|
+
validations.push({
|
|
392
|
+
id: definition.id,
|
|
393
|
+
source: "runner",
|
|
394
|
+
...repoField,
|
|
395
|
+
command: definition.displayCommand,
|
|
396
|
+
status: "not_applicable",
|
|
397
|
+
summary: reason,
|
|
398
|
+
reason,
|
|
399
|
+
});
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
303
402
|
const root = repo === PARENT_VALIDATION_PROJECT_REPO
|
|
304
403
|
? roots.project
|
|
305
404
|
: Object.hasOwn(roots.repos ?? {}, repo)
|
|
@@ -338,8 +437,8 @@ export async function runParentValidationBatch(entries, cwd, invoke = invokePare
|
|
|
338
437
|
}
|
|
339
438
|
return { validations, failureOutputs };
|
|
340
439
|
}
|
|
341
|
-
export async function runParentValidations(entries, cwd, invoke = invokeParentValidation) {
|
|
342
|
-
return (await runParentValidationBatch(entries, cwd, invoke)).validations;
|
|
440
|
+
export async function runParentValidations(entries, cwd, invoke = invokeParentValidation, selection) {
|
|
441
|
+
return (await runParentValidationBatch(entries, cwd, invoke, selection)).validations;
|
|
343
442
|
}
|
|
344
443
|
/** `<id>` or `<repo>:<id>` of a recorded runner validation (no `repo` means the project). */
|
|
345
444
|
export function recordedParentValidationLabel(validation) {
|
|
@@ -439,11 +538,53 @@ export function parentValidationGateFor(execDefaults, lockRoot = getActiveExecLo
|
|
|
439
538
|
return gate;
|
|
440
539
|
}
|
|
441
540
|
export function failedParentValidationReason(validations) {
|
|
442
|
-
|
|
541
|
+
// runner の `not_applicable` は、`paths` に合う変更が無く流さなかった検証である(PJR-T01P)。
|
|
542
|
+
const failed = validations.filter((validation) => validation.source === "runner" &&
|
|
543
|
+
validation.status !== "passed" &&
|
|
544
|
+
validation.status !== "not_applicable");
|
|
443
545
|
if (failed.length === 0)
|
|
444
546
|
return undefined;
|
|
445
547
|
return `parent validation failed: ${failed.map(recordedParentValidationLabel).join(", ")}`;
|
|
446
548
|
}
|
|
549
|
+
// PJR-Q2AT: executor が親検証をまとめて 1 行(例: `parent runner: lint-ts, lint-fm`、
|
|
550
|
+
// `親 runner 指定検査(lint-ts, lint-fm)`)に書いた場合に、末尾の区切り列を検証ラベルとして取り出す。
|
|
551
|
+
const AGGREGATE_LABEL_PATTERN = "(?:[A-Za-z0-9][A-Za-z0-9_-]*:)?[a-z][a-z0-9-]*";
|
|
552
|
+
const AGGREGATE_LINE_PATTERN = new RegExp(`^(\\S.*?)(?:[::((\\[]|\\s)\\s*(${AGGREGATE_LABEL_PATTERN}(?:\\s*[,、]\\s*${AGGREGATE_LABEL_PATTERN})*)\\s*[))\\]]?\\s*$`, "u");
|
|
553
|
+
// コマンドそのもの(`npm run lint:md` など)をまとめた行と取り違えない。
|
|
554
|
+
const COMMAND_PREFIX_PATTERN = /^(?:npm|npx|pnpm|yarn|node|tsx|specdojo)(?:\s|$)/u;
|
|
555
|
+
function aggregatedParentValidationLabels(command) {
|
|
556
|
+
const normalized = command.trim().replace(/\s+/gu, " ");
|
|
557
|
+
if (COMMAND_PREFIX_PATTERN.test(normalized))
|
|
558
|
+
return undefined;
|
|
559
|
+
const match = AGGREGATE_LINE_PATTERN.exec(normalized);
|
|
560
|
+
if (!match)
|
|
561
|
+
return undefined;
|
|
562
|
+
return match[2].split(/\s*[,、]\s*/u).filter((label) => label.length > 0);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Whether an executor validation line that lists parent validation labels together
|
|
566
|
+
* (e.g. `parent runner: lint-ts, lint-fm`) is covered by the runner's own results.
|
|
567
|
+
* Every listed label must have a runner record (so it is configured in
|
|
568
|
+
* `pipeline.parent_validations`) that passed or was skipped by change type.
|
|
569
|
+
*/
|
|
570
|
+
export function isAggregatedParentValidationSatisfied(command, validations) {
|
|
571
|
+
const labels = aggregatedParentValidationLabels(command);
|
|
572
|
+
if (!labels || labels.length === 0)
|
|
573
|
+
return false;
|
|
574
|
+
const runnerStatuses = new Map();
|
|
575
|
+
for (const validation of validations) {
|
|
576
|
+
if (validation.source !== "runner" || typeof validation.id !== "string")
|
|
577
|
+
continue;
|
|
578
|
+
const label = recordedParentValidationLabel(validation);
|
|
579
|
+
runnerStatuses.set(label, [...(runnerStatuses.get(label) ?? []), validation.status]);
|
|
580
|
+
}
|
|
581
|
+
return labels.every((label) => {
|
|
582
|
+
const statuses = runnerStatuses.get(label);
|
|
583
|
+
return (statuses !== undefined &&
|
|
584
|
+
statuses.length > 0 &&
|
|
585
|
+
statuses.every((status) => status === "passed" || status === "not_applicable"));
|
|
586
|
+
});
|
|
587
|
+
}
|
|
447
588
|
/**
|
|
448
589
|
* Replaces stale runner-owned validation results while preserving executor-owned evidence.
|
|
449
590
|
* The caller must supply results produced from the fixed parent-validation allowlist.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
3
|
-
import {
|
|
3
|
+
import { runEvidencePath, taskEvidencePaths } from "./run-records.js";
|
|
4
|
+
import { ensureDir } from "./shared.js";
|
|
4
5
|
function emptyStage(actor) {
|
|
5
6
|
return {
|
|
6
7
|
status: "pending",
|
|
@@ -33,7 +34,7 @@ function executionRelative(repoRoot, executionPath) {
|
|
|
33
34
|
return rel;
|
|
34
35
|
}
|
|
35
36
|
export function pipelineStateLocation(input) {
|
|
36
|
-
const path = join(input.worktreePath, executionRelative(input.repoRoot, input.executionPath),
|
|
37
|
+
const path = taskEvidencePaths(join(input.worktreePath, executionRelative(input.repoRoot, input.executionPath)), input.taskId, input.runId).state;
|
|
37
38
|
return { path, ref: relative(input.worktreePath, path).split(sep).join("/") };
|
|
38
39
|
}
|
|
39
40
|
function isStageState(value) {
|
|
@@ -196,6 +197,29 @@ function resolveArtifactRef(worktreePath, ref) {
|
|
|
196
197
|
return null;
|
|
197
198
|
return path;
|
|
198
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Validations recorded in the executor evidence of a run (PJR-T01P: the integration commit reads
|
|
202
|
+
* the parent-validation results). Returns an empty list when the state or evidence is unreadable.
|
|
203
|
+
*/
|
|
204
|
+
export function recordedRunValidations(worktreePath, statePath) {
|
|
205
|
+
if (!statePath || !existsSync(statePath))
|
|
206
|
+
return [];
|
|
207
|
+
try {
|
|
208
|
+
const state = readPipelineState(statePath);
|
|
209
|
+
const ref = state.stages.executor.artifact_ref;
|
|
210
|
+
const evidencePath = ref ? resolveArtifactRef(worktreePath, ref) : null;
|
|
211
|
+
if (!evidencePath || !existsSync(evidencePath))
|
|
212
|
+
return [];
|
|
213
|
+
const evidence = JSON.parse(readFileSync(evidencePath, "utf8"));
|
|
214
|
+
if (!isExecutorEvidence(evidence, state.task_id, state.run_id))
|
|
215
|
+
return [];
|
|
216
|
+
return Array.isArray(evidence.validations) ? evidence.validations : [];
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
// 読めない場合は hook を外さない(すべて流す)側へ倒す。
|
|
220
|
+
return [];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
199
223
|
function isExecutorEvidence(value, taskId, runId) {
|
|
200
224
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
201
225
|
return false;
|
|
@@ -226,9 +250,7 @@ export function loadPipelineResumeCheckpoint(input) {
|
|
|
226
250
|
const recordedEvidenceRef = state.stages.executor.artifact_ref;
|
|
227
251
|
const evidenceRef = recordedEvidenceRef ??
|
|
228
252
|
(state.stages.executor.status === "running"
|
|
229
|
-
? relative(input.worktreePath,
|
|
230
|
-
.split(sep)
|
|
231
|
-
.join("/")
|
|
253
|
+
? relative(input.worktreePath, runEvidencePath(statePath)).split(sep).join("/")
|
|
232
254
|
: null);
|
|
233
255
|
if (!evidenceRef)
|
|
234
256
|
return { state, statePath };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { collectDocIndexEntries } from "../docs/doc-index.js";
|
|
4
|
+
import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
|
|
5
|
+
import { isGeneratedGradeTarget, isTrashedGradeTarget, resolveSafeMarkdownPath, resolveSafeRepositoryPath, } from "../grade/targets.js";
|
|
6
|
+
import { resolveKataRefs } from "../kata/kata.js";
|
|
7
|
+
import { isCondenseRecords } from "../shared/condense-records.js";
|
|
8
|
+
import { getProjectExecutionPath, loadConfig, specdojoRootDir } from "../shared/specdojo-config.js";
|
|
9
|
+
import { load } from "../shared/yaml.js";
|
|
10
|
+
import { inlineCode } from "./plans-grade-findings.js";
|
|
11
|
+
import { listRunRecords } from "./run-records.js";
|
|
12
|
+
/** Latest completed condense result per deliverable, independent of grade freshness. */
|
|
13
|
+
export function condenseKataFindingsText(projectId, kind, kataPath) {
|
|
14
|
+
const root = specdojoRootDir();
|
|
15
|
+
const project = loadConfig(root).config?.projects[projectId];
|
|
16
|
+
if (!project)
|
|
17
|
+
return [];
|
|
18
|
+
const latest = new Map();
|
|
19
|
+
for (const path of listRunRecords(resolve(root, getProjectExecutionPath(project)), "result")) {
|
|
20
|
+
if (!path.endsWith(".md"))
|
|
21
|
+
continue;
|
|
22
|
+
try {
|
|
23
|
+
const meta = readSpecdojoNamespace(readFileSync(path, "utf8"));
|
|
24
|
+
if (meta.type !== "exec-result" ||
|
|
25
|
+
meta.project_id !== projectId ||
|
|
26
|
+
meta.approach !== "condense" ||
|
|
27
|
+
meta.mode !== "edit" ||
|
|
28
|
+
meta.status !== "complete")
|
|
29
|
+
continue;
|
|
30
|
+
if (!Array.isArray(meta.targets) ||
|
|
31
|
+
meta.targets.length !== 1 ||
|
|
32
|
+
typeof meta.targets[0] !== "string")
|
|
33
|
+
continue;
|
|
34
|
+
const timestamp = meta.completed_at ?? meta.started_at;
|
|
35
|
+
const time = typeof timestamp === "string" ? Date.parse(timestamp) : NaN;
|
|
36
|
+
if (!Number.isFinite(time))
|
|
37
|
+
continue;
|
|
38
|
+
const previous = latest.get(meta.targets[0]);
|
|
39
|
+
if (!previous || previous.time <= time)
|
|
40
|
+
latest.set(meta.targets[0], { meta, path, time });
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// An unreadable result is not evidence for editing a Kata.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (latest.size === 0)
|
|
47
|
+
return [];
|
|
48
|
+
const entries = collectDocIndexEntries(resolve(root, "docs"), root);
|
|
49
|
+
const lines = [];
|
|
50
|
+
for (const [document, { meta, path: resultPath }] of latest) {
|
|
51
|
+
try {
|
|
52
|
+
// Select the latest result before validating records: an empty or invalid latest result
|
|
53
|
+
// must never revive records from an older condense run.
|
|
54
|
+
if (!isCondenseRecords(meta.condense_records))
|
|
55
|
+
continue;
|
|
56
|
+
const indexed = entries[document];
|
|
57
|
+
if (!indexed)
|
|
58
|
+
continue;
|
|
59
|
+
const indexedPath = indexed.replace(/:\d+$/, "");
|
|
60
|
+
const path = indexedPath.endsWith(".md")
|
|
61
|
+
? resolveSafeMarkdownPath(indexedPath, root, projectId)
|
|
62
|
+
: resolveSafeRepositoryPath(indexedPath, "condense target");
|
|
63
|
+
if (isGeneratedGradeTarget(path, root) || isTrashedGradeTarget(path, root))
|
|
64
|
+
continue;
|
|
65
|
+
const content = readFileSync(path, "utf8");
|
|
66
|
+
const parsed = path.endsWith(".md") ? readSpecdojoNamespace(content) : load(content);
|
|
67
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
68
|
+
continue;
|
|
69
|
+
const metadata = parsed;
|
|
70
|
+
const documentMeta = metadata.specdojo && typeof metadata.specdojo === "object"
|
|
71
|
+
? metadata.specdojo
|
|
72
|
+
: metadata;
|
|
73
|
+
if (documentMeta.id !== document || typeof documentMeta.rulebook !== "string")
|
|
74
|
+
continue;
|
|
75
|
+
const refs = resolveKataRefs(documentMeta.rulebook);
|
|
76
|
+
if (resolve(root, refs[kind]) !== resolve(root, kataPath))
|
|
77
|
+
continue;
|
|
78
|
+
for (const record of meta.condense_records) {
|
|
79
|
+
if (record.cause.type !== "kata" || record.cause.kind !== kind)
|
|
80
|
+
continue;
|
|
81
|
+
lines.push(`- source=condense; result=${inlineCode(String(meta.id ?? resultPath))}; document=${inlineCode(document)}; location=${inlineCode(record.location)}; category=${inlineCode(record.category)}; action=${inlineCode(record.action)}; reason=${inlineCode(record.reason)}; cause=kata:${kind}; location=${inlineCode(record.cause.location)}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Missing documents or unresolved declarations cannot identify the target Kata.
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return lines;
|
|
89
|
+
}
|
package/dist/exec/plans-core.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { deliverableDocId, loadPlanCatalogDocs as loadCatalogDocs, } from "../catalog/document-target.js";
|
|
2
|
-
|
|
2
|
+
import { recordStem } from "./run-records.js";
|
|
3
|
+
export { deliverableDocId, loadPlanCatalogDocs as loadCatalogDocs, resolveDeliverableByDocId, } from "../catalog/document-target.js";
|
|
4
|
+
export { execTemplatePath, execTemplatesDir, injectCommonConventions, loadPlanTemplate, MISSING, } from "../shared/plan-templates.js";
|
|
3
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
6
|
import { basename, join, relative, resolve } from "node:path";
|
|
5
|
-
import { load } from "../shared/yaml.js";
|
|
6
|
-
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
7
|
-
import { kataDirsForKinds, resolveIncludedRulebooks, resolveKataRefs } from "../kata/kata.js";
|
|
8
7
|
import { resolveBasePath, resolveDeliverablePath } from "../catalog/paths.js";
|
|
9
8
|
import { isDctPlanFileName } from "../catalog/plan.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
export { MISSING, execTemplatePath, execTemplatesDir, injectCommonConventions, loadPlanTemplate, } from "../shared/plan-templates.js";
|
|
9
|
+
import { buildSpecdojoFrontmatter, readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
|
|
10
|
+
import { kataDirsForKinds, resolveIncludedRulebooks, resolveKataRefs } from "../kata/kata.js";
|
|
11
|
+
import { renderReviewGradeSummary, reviewGradeFreshness } from "../review/grade.js";
|
|
14
12
|
import { resolveViewpointsDoc, viewpointAppliesToDocument } from "../review/plan.js";
|
|
15
|
-
import { listFilesRecursive, nowUtcIsoSeconds, randomHex, tsForFilenameUtc } from "./shared.js";
|
|
16
13
|
import { gradeResultPathForDocument, readGradeResultForDocument } from "../shared/grade-result.js";
|
|
17
|
-
import {
|
|
14
|
+
import { MISSING } from "../shared/plan-templates.js";
|
|
15
|
+
import { qualifyPracticeId, SPECDOJO_PRACTICE_AUTHORITY } from "../shared/practice-id.js";
|
|
16
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
17
|
+
import { load } from "../shared/yaml.js";
|
|
18
18
|
import { planGradeFindingText } from "./plans-grade-findings.js";
|
|
19
|
+
import { listFilesRecursive, nowUtcIsoSeconds, randomHex, tsForFilenameUtc } from "./shared.js";
|
|
19
20
|
export function execDocId(projectId, prefix, localBase) {
|
|
20
21
|
const localId = `${prefix}-${localBase.toLowerCase()}`;
|
|
21
22
|
return projectId ? `${projectId}:${localId}` : localId;
|
|
@@ -37,10 +38,10 @@ export function buildInPlaceStem(slug, dependencies = {}) {
|
|
|
37
38
|
issuedInPlaceStems.add(stem);
|
|
38
39
|
return stem;
|
|
39
40
|
}
|
|
40
|
-
// Recover the shared stem from a plan path: `.../
|
|
41
|
+
// Recover the shared stem from a plan path: `.../runs/<origin>/<item>/<stem>/plan.md` → `<stem>`.
|
|
41
42
|
// Used when re-running `--plan <path>` so the tied result is overwritten in place.
|
|
42
43
|
export function stemFromPlanPath(planPath) {
|
|
43
|
-
return
|
|
44
|
+
return recordStem(planPath);
|
|
44
45
|
}
|
|
45
46
|
// ---------------------------------------------------------------------------
|
|
46
47
|
// Catalog helpers
|
|
@@ -220,7 +221,7 @@ export function deliverablePath(deliverable) {
|
|
|
220
221
|
export function deliverableName(deliverable) {
|
|
221
222
|
return deliverable?.deliverable.name ?? MISSING;
|
|
222
223
|
}
|
|
223
|
-
export function gradeFindingsText(projectId, targetPath) {
|
|
224
|
+
export function gradeFindingsText(projectId, targetPath, includeCause = false) {
|
|
224
225
|
if (!targetPath || targetPath === MISSING || !existsSync(join(specdojoRootDir(), targetPath))) {
|
|
225
226
|
return "- なし";
|
|
226
227
|
}
|
|
@@ -229,7 +230,7 @@ export function gradeFindingsText(projectId, targetPath) {
|
|
|
229
230
|
if (!result || result.findings.length === 0)
|
|
230
231
|
return "- なし";
|
|
231
232
|
return result.findings
|
|
232
|
-
.map((finding) => `- ${finding.id} ${planGradeFindingText(finding)}`)
|
|
233
|
+
.map((finding) => `- ${finding.id} ${planGradeFindingText(finding, includeCause)}`)
|
|
233
234
|
.join("\n");
|
|
234
235
|
}
|
|
235
236
|
catch {
|
|
@@ -298,12 +299,13 @@ export function kataRefState(refPath) {
|
|
|
298
299
|
return existsSync(resolve(specdojoRootDir(), refPath)) ? "existing" : "missing";
|
|
299
300
|
}
|
|
300
301
|
// 対象成果物の depends_on を、依存先 doc の [[id]] 参照の入れ子リストで提示する。
|
|
301
|
-
// id は依存先の frontmatter、未作成なら配置規約から解決する。
|
|
302
|
+
// id は依存先の frontmatter、未作成なら配置規約から解決する。markMissing の場合は
|
|
303
|
+
// 未作成の依存をインラインコードで示す。agent へ plan を渡すときに
|
|
302
304
|
// expandPromptRefs(src/exec/run/agent.ts, format:'path')が
|
|
303
305
|
// この [[id]] を doc-index 経由でリポジトリ相対パスへ展開し、agent が先行成果物を直接開ける。
|
|
304
306
|
// テンプレート側はラベル直後にこの値を差し込むため、件数 0・成果物未解決時は先頭スペース付きの
|
|
305
307
|
// インライン値、依存ありの場合は改行始まりの入れ子リストを返す。
|
|
306
|
-
export function deliverableDependsOn(deliverable, projectId, catalogPath) {
|
|
308
|
+
export function deliverableDependsOn(deliverable, projectId, catalogPath, markMissing = false) {
|
|
307
309
|
if (!deliverable)
|
|
308
310
|
return ` ${MISSING}`;
|
|
309
311
|
const deps = deliverable.deliverable.depends_on ?? [];
|
|
@@ -311,7 +313,11 @@ export function deliverableDependsOn(deliverable, projectId, catalogPath) {
|
|
|
311
313
|
return " -";
|
|
312
314
|
const lines = deps.map((dep) => {
|
|
313
315
|
const info = findDeliverableInfo(catalogPath, dep);
|
|
314
|
-
|
|
316
|
+
const id = deliverableDocId(projectId, dep, info?.resolvedPath);
|
|
317
|
+
if (markMissing && (!info || !existsSync(resolve(specdojoRootDir(), info.resolvedPath)))) {
|
|
318
|
+
return ` - \`${id}\`(未作成)`;
|
|
319
|
+
}
|
|
320
|
+
return ` - [[${id}]]`;
|
|
315
321
|
});
|
|
316
322
|
return `\n${lines.join("\n")}`;
|
|
317
323
|
}
|
|
@@ -343,6 +349,7 @@ export function deliverableBasedOn(deliverable) {
|
|
|
343
349
|
return ids.length ? ids.map((ref) => `[[${ref}]]`).join("、") : "なし";
|
|
344
350
|
}
|
|
345
351
|
const PROJECT_CONTEXT_EXCLUDED_APPROACHES = new Set([
|
|
352
|
+
"condense",
|
|
346
353
|
"cross-deliverable-dedup",
|
|
347
354
|
"rulebook-authoring",
|
|
348
355
|
"recipe-authoring",
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { expandPlanConventions } from "../shared/plan-conventions.js";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { isAuthoringApproach } from "../kata/authoring.js";
|
|
5
|
+
import { resolveDeliverableSchemaRef, resolveKataRefs } from "../kata/kata.js";
|
|
1
6
|
import { registerInputSection } from "../register/input.js";
|
|
2
|
-
import {
|
|
3
|
-
import { join } from "node:path";
|
|
7
|
+
import { isPlanningApproach } from "../register/planning.js";
|
|
4
8
|
import { DEFAULT_PROJECT_CONTEXT, specdojoRootDir } from "../shared/specdojo-config.js";
|
|
5
|
-
import { resolveDeliverableSchemaRef, resolveKataRefs } from "../kata/kata.js";
|
|
6
9
|
import { formatMarkdownFile } from "./format.js";
|
|
7
10
|
import { assertPlanMarkdownlint } from "./plan-markdownlint.js";
|
|
11
|
+
import { applicableReviewCriteria, buildInPlaceStem, crossDeliverableTargetDetails, deliverableBasedOn, deliverableBrief, deliverableDependsOn, deliverableName, deliverableOverview, deliverablePath, doneCriteriaChecklist, doneCriteriaGoals, doneCriteriaItems, execDocId, findDeliverableInfo, frontmatter, gradeFindingsText, gradeFindingTargetPath, gradeResultRef, gradeTargetKind, implementationEvidence, injectCommonConventions, kataRefState, loadPlanTemplate, loadRoles, loadViewpoints, MISSING, ownerRoleFields, phaseDescriptionText, projectContextSection, repoRelativePath, reviewDoneCriteriaRows, reviewGradeSummaryText, rulebookIncludesText, targetDocIds, targetDocIdsForTask, } from "./plans-core.js";
|
|
12
|
+
import { kataCauseFindingsText } from "./plans-kata-findings.js";
|
|
13
|
+
import { kataReviewSummary, scheduleKataReviewSubjects } from "./review-kata.js";
|
|
14
|
+
import { isRunRecordPath, resultForPlan, taskRecordPaths } from "./run-records.js";
|
|
8
15
|
import { expandTemplate } from "./shared.js";
|
|
9
|
-
import { isAuthoringApproach } from "../kata/authoring.js";
|
|
10
|
-
import { isPlanningApproach } from "../register/planning.js";
|
|
11
|
-
import { MISSING, applicableReviewCriteria, crossDeliverableTargetDetails, deliverableDependsOn, deliverableBasedOn, deliverableBrief, deliverableName, deliverableOverview, deliverablePath, doneCriteriaChecklist, doneCriteriaGoals, doneCriteriaItems, execDocId, findDeliverableInfo, frontmatter, gradeFindingsText, gradeFindingTargetPath, gradeResultRef, gradeTargetKind, implementationEvidence, injectCommonConventions, kataRefState, loadPlanTemplate, loadRoles, loadViewpoints, ownerRoleFields, phaseDescriptionText, projectContextSection, repoRelativePath, reviewDoneCriteriaRows, reviewGradeSummaryText, rulebookIncludesText, targetDocIds, targetDocIdsForTask, } from "./plans-core.js";
|
|
12
16
|
function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, projectId, catalogPath, projectContext, resultRef, stem, crossDeliverables = new Map(), planOverrides) {
|
|
13
17
|
const cpm = task.cpm;
|
|
14
18
|
const onCriticalPath = cpm !== undefined && cpm.slack === 0;
|
|
@@ -34,12 +38,16 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
34
38
|
const ownerRole = ownerRoleFields(task.owner, roleMap, vpMap, deliverable?.deliverable.rulebook);
|
|
35
39
|
const refs = planOverrides?.refs ??
|
|
36
40
|
resolveKataRefs(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind);
|
|
41
|
+
const usesOptionalImplementationEvidence = task.approach === "draft" ||
|
|
42
|
+
task.approach === "fully-guided" ||
|
|
43
|
+
task.approach === "recipe-guided";
|
|
44
|
+
const evidence = implementationEvidence(deliverable);
|
|
37
45
|
const values = {
|
|
38
46
|
_FRONTMATTER_: frontmatter(meta),
|
|
39
47
|
_TASK_ID_: task.id,
|
|
40
48
|
_PHASE_DESCRIPTION_: phaseDescriptionText(task),
|
|
41
49
|
_DELIVERABLE_NAME_: deliverableName(deliverable),
|
|
42
|
-
_DELIVERABLE_DEPENDS_ON_: deliverableDependsOn(deliverable, projectId, catalogPath),
|
|
50
|
+
_DELIVERABLE_DEPENDS_ON_: deliverableDependsOn(deliverable, projectId, catalogPath, usesOptionalImplementationEvidence),
|
|
43
51
|
_DELIVERABLE_BASED_ON_: deliverableBasedOn(deliverable),
|
|
44
52
|
_REGISTER_INPUT_: registerInputSection(planOverrides?.registerInput)
|
|
45
53
|
? "下記「個票の入力(前提)」を参照。"
|
|
@@ -47,9 +55,13 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
47
55
|
_DELIVERABLE_BRIEF_: deliverableBrief(deliverable),
|
|
48
56
|
_PROJECT_CONTEXT_: projectContextSection(projectContext, deliverable, task.approach, projectId),
|
|
49
57
|
_DELIVERABLE_OVERVIEW_: deliverableOverview(deliverable),
|
|
50
|
-
_IMPLEMENTATION_EVIDENCE_:
|
|
51
|
-
?
|
|
52
|
-
|
|
58
|
+
_IMPLEMENTATION_EVIDENCE_: usesOptionalImplementationEvidence
|
|
59
|
+
? evidence === MISSING
|
|
60
|
+
? "なし(`evidence_refs` 未指定またはカタログなし)。"
|
|
61
|
+
: evidence
|
|
62
|
+
: deliverable?.catalogless
|
|
63
|
+
? "個票に指定された実装のパスを読み取り専用の調査入力とする。パスが未指定なら実装反映の前に個票へ明記する。"
|
|
64
|
+
: evidence,
|
|
53
65
|
_DELIVERABLE_PATH_: deliverablePath(deliverable),
|
|
54
66
|
_RESULT_REF_: resultRef,
|
|
55
67
|
_RULEBOOK_REF_: refs.rulebook,
|
|
@@ -69,7 +81,10 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
69
81
|
: doneCriteriaGoals(criteria, task.owner),
|
|
70
82
|
_DONE_CRITERIA_CHECKLIST_: doneCriteriaChecklist(criteria),
|
|
71
83
|
_DONE_CRITERIA_ITEMS_: doneCriteriaItems(criteria),
|
|
72
|
-
_GRADE_FINDINGS_: gradeFindingsText(projectId, gradeFindingTargetPath(task.approach, deliverable, refs)),
|
|
84
|
+
_GRADE_FINDINGS_: gradeFindingsText(projectId, gradeFindingTargetPath(task.approach, deliverable, refs), task.approach === "fully-guided"),
|
|
85
|
+
_KATA_CAUSE_FINDINGS_: task.approach?.endsWith("-maintenance")
|
|
86
|
+
? kataCauseFindingsText(projectId, task.approach.replace(/-maintenance$/, ""), gradeFindingTargetPath(task.approach, deliverable, refs))
|
|
87
|
+
: "- なし",
|
|
73
88
|
_TARGET_DELIVERABLES_: crossDeliverableTargetDetails(projectId, task.target_local_ids ?? [], crossDeliverables, catalogPath),
|
|
74
89
|
_AUTHORING_KATA_ID_: planOverrides?.authoring?.id ?? MISSING,
|
|
75
90
|
_AUTHORING_KATA_KIND_: planOverrides?.authoring?.kind ?? MISSING,
|
|
@@ -172,7 +187,12 @@ function buildReviewPlanMarkdown(template, task, deliverable, criteria, vpMap, p
|
|
|
172
187
|
_GRADE_SUBJECT_PATH_: gradeSubjectPath,
|
|
173
188
|
_GRADE_TARGET_: gradeTargetKind(task.approach),
|
|
174
189
|
_GRADE_RESULT_PATH_: gradeResultRef(projectId, gradeSubjectPath),
|
|
175
|
-
_GRADE_SUMMARY_:
|
|
190
|
+
_GRADE_SUMMARY_: [
|
|
191
|
+
reviewGradeSummaryText(projectId, gradeSubjectPath, reviewGradeOutcome),
|
|
192
|
+
kataReviewSummary(scheduleKataReviewSubjects(task, deliverable, projectId), projectId),
|
|
193
|
+
]
|
|
194
|
+
.filter(Boolean)
|
|
195
|
+
.join("\n\n"),
|
|
176
196
|
_DONE_CRITERIA_ROWS_: reviewDoneCriteriaRows(applicableCriteria),
|
|
177
197
|
};
|
|
178
198
|
const hasBrief = Boolean(deliverable?.deliverable.brief?.trim());
|
|
@@ -203,11 +223,12 @@ async function writeTaskPlan(ctx, task, override) {
|
|
|
203
223
|
: localId && ctx.catalogPath
|
|
204
224
|
? findDeliverableInfo(ctx.catalogPath, localId)
|
|
205
225
|
: null;
|
|
206
|
-
//
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
|
|
226
|
+
// Keep the existing document-id convention, with a unique stem for each retained run.
|
|
227
|
+
const stem = override?.stem ?? buildInPlaceStem(task.id);
|
|
228
|
+
const records = taskRecordPaths(ctx.executionPath, task.id, stem, override?.origin ?? "schedule");
|
|
229
|
+
const outPath = override?.outPath ?? records.plan;
|
|
230
|
+
mkdirSync(dirname(outPath), { recursive: true });
|
|
231
|
+
const resultRef = repoRelativePath(isRunRecordPath(outPath) ? resultForPlan(outPath) : records.result);
|
|
211
232
|
const criteria = deliverable?.deliverable.done_criteria ?? [];
|
|
212
233
|
if ((task.execution ?? "agent") === "human") {
|
|
213
234
|
throw new Error(`Task ${task.id} has execution: human; claim it to create and use its result instead of a plan.`);
|
|
@@ -218,14 +239,22 @@ async function writeTaskPlan(ctx, task, override) {
|
|
|
218
239
|
implementationEvidence(deliverable) === MISSING) {
|
|
219
240
|
throw new Error(`Task ${task.id} uses approach: retrofit but the target deliverable has no evidence_refs.`);
|
|
220
241
|
}
|
|
242
|
+
if (task.approach === "condense" &&
|
|
243
|
+
(mode !== "edit" ||
|
|
244
|
+
!deliverable?.resolvedPath ||
|
|
245
|
+
!existsSync(resolve(specdojoRootDir(), deliverable.resolvedPath)) ||
|
|
246
|
+
(override?.targets ??
|
|
247
|
+
targetDocIdsForTask(ctx.projectId, task, deliverable, crossDeliverables)).length !== 1)) {
|
|
248
|
+
throw new Error(`Task ${task.id} uses condense; exactly one existing deliverable and edit mode are required`);
|
|
249
|
+
}
|
|
221
250
|
const template = loadPlanTemplate(mode, task.approach, ctx.templateCache);
|
|
222
251
|
const body = mode === "review"
|
|
223
252
|
? buildReviewPlanMarkdown(template, planTask, deliverable, criteria, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, ctx.reviewGradeOutcome)
|
|
224
253
|
: buildEditPlanMarkdown(template, planTask, deliverable, ctx.roleMap, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, crossDeliverables, override);
|
|
225
254
|
const schemaRef = resolveDeliverableSchemaRef(deliverable?.resolvedPath);
|
|
226
|
-
const content = `${injectCommonConventions(body, schemaRef, ctx.templateCache, mode).replace(/[\r\n]+$/u, "")}\n`;
|
|
255
|
+
const content = `${injectCommonConventions(body, schemaRef, ctx.templateCache, mode, { executionPath: ctx.executionPath, planPath: outPath }).replace(/[\r\n]+$/u, "")}\n`;
|
|
227
256
|
if (task.schedule_file && override?.origin !== "register") {
|
|
228
|
-
await assertPlanMarkdownlint(specdojoRootDir(), task.id, outPath, content);
|
|
257
|
+
await assertPlanMarkdownlint(specdojoRootDir(), task.id, outPath, expandPlanConventions(content, dirname(outPath)));
|
|
229
258
|
}
|
|
230
259
|
writeFileSync(outPath, content, "utf8");
|
|
231
260
|
await formatMarkdownFile(outPath);
|
|
@@ -300,10 +329,7 @@ export async function generateRegisterApproachPlan(opts) {
|
|
|
300
329
|
});
|
|
301
330
|
}
|
|
302
331
|
function newPlanGenContext(opts) {
|
|
303
|
-
const plansDir = join(opts.executionPath, "exec", "plans");
|
|
304
|
-
mkdirSync(plansDir, { recursive: true });
|
|
305
332
|
return {
|
|
306
|
-
plansDir,
|
|
307
333
|
executionPath: opts.executionPath,
|
|
308
334
|
projectId: opts.projectId,
|
|
309
335
|
catalogPath: opts.catalogPath,
|
|
@@ -318,6 +344,3 @@ function newPlanGenContext(opts) {
|
|
|
318
344
|
templateCache: new Map(),
|
|
319
345
|
};
|
|
320
346
|
}
|
|
321
|
-
// Move a completed plan to exec/plans/done/ with a unique UTC + random suffix
|
|
322
|
-
// (same convention as event filenames), or delete it. The plan is regenerable
|
|
323
|
-
// from the catalog, so deletion is safe; the result remains as the record.
|