specdojo 0.3.1 → 0.4.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/CHANGELOG.md +47 -0
- package/README.md +77 -18
- package/dist/{catalog-build-references.js → catalog/build-references.js} +4 -4
- package/dist/catalog/build-render.js +32 -0
- package/dist/{catalog-build.js → catalog/build.js} +9 -9
- package/dist/{catalog.js → catalog/catalog.js} +10 -10
- package/dist/{catalog-generate.js → catalog/generate.js} +8 -8
- package/dist/catalog/paths.js +1 -0
- package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +4 -4
- package/dist/{catalog-plan.js → catalog/plan.js} +4 -4
- package/dist/{catalog-scaffold.js → catalog/scaffold.js} +3 -3
- package/dist/{agent.js → commands/agent.js} +11 -11
- package/dist/{build-command.js → commands/build.js} +2 -2
- package/dist/{init-command.js → commands/init.js} +98 -32
- package/dist/{orchestrator.js → commands/orchestrator.js} +2 -2
- package/dist/{watch.js → commands/watch.js} +3 -3
- package/dist/{dashboard-timeline.js → dashboard/dashboard-timeline.js} +2 -2
- package/dist/{dashboard.js → dashboard/dashboard.js} +11 -10
- package/dist/{dashboard-exec-records.js → dashboard/exec-records.js} +2 -2
- package/dist/{dashboard-routines.js → dashboard/routines.js} +6 -5
- package/dist/{dashboard-shared.js → dashboard/shared.js} +1 -1
- package/dist/{timeline-build.js → dashboard/timeline-build.js} +2 -1
- package/dist/{timeline.js → dashboard/timeline.js} +1 -1
- package/dist/{deliverable.js → deliverable/deliverable.js} +5 -5
- package/dist/{deliverable-trash.js → deliverable/trash.js} +5 -5
- package/dist/{devcontainer-command.js → devcontainer/command.js} +5 -3
- package/dist/{devcontainer-scaffold.js → devcontainer/scaffold.js} +94 -2
- package/dist/{doc-index.js → docs/doc-index.js} +1 -1
- package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +1 -1
- package/dist/{index-command.js → docs/index-command.js} +1 -1
- package/dist/docs/template-resolution.js +1 -0
- package/dist/{viewpoint-document-kinds-check.js → docs/viewpoint-document-kinds-check.js} +1 -1
- package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
- package/dist/{yaml-pages.js → docs/yaml-pages.js} +2 -2
- package/dist/{exec-agent-config.js → exec/agent-config.js} +33 -4
- package/dist/{exec-agent-git-state.js → exec/agent-git-state.js} +1 -1
- package/dist/{exec-agent-protected-config.js → exec/agent-protected-config.js} +1 -1
- package/dist/{exec-commands.js → exec/commands.js} +22 -18
- package/dist/{exec-core.js → exec/core.js} +11 -11
- package/dist/{exec-events.js → exec/events.js} +2 -2
- package/dist/{exec-evidence.js → exec/evidence.js} +11 -6
- package/dist/exec/exec.js +2 -0
- package/dist/exec/format.js +1 -0
- package/dist/{exec-handoff.js → exec/handoff.js} +13 -12
- package/dist/{exec-limit.js → exec/limit.js} +93 -12
- package/dist/{exec-parent-validation.js → exec/parent-validation.js} +4 -4
- package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +16 -2
- package/dist/{exec-plans-core.js → exec/plans-core.js} +68 -114
- package/dist/{exec-plans-generation.js → exec/plans-generation.js} +53 -10
- package/dist/{exec-plans-storage.js → exec/plans-storage.js} +5 -5
- package/dist/{exec-plans.js → exec/plans.js} +3 -3
- package/dist/{exec-project.js → exec/project.js} +1 -1
- package/dist/{exec-protection-handoff.js → exec/protection-handoff.js} +3 -3
- package/dist/{exec-register-resume.js → exec/register-resume.js} +2 -2
- package/dist/{exec-register.js → exec/register.js} +92 -9
- package/dist/{exec-repo-integration-git.js → exec/repo-integration-git.js} +2 -2
- package/dist/{exec-repo-integration-sync.js → exec/repo-integration-sync.js} +4 -4
- package/dist/{exec-repo-integration.js → exec/repo-integration.js} +13 -10
- package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
- package/dist/{exec-reporter-output.js → exec/reporter-output.js} +2 -2
- package/dist/{exec-reporter.js → exec/reporter.js} +29 -12
- package/dist/{exec-results.js → exec/results.js} +256 -22
- package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +32 -12
- package/dist/{exec-run-agent.js → exec/run/agent.js} +79 -27
- package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
- package/dist/{exec-run-job.js → exec/run/job.js} +64 -35
- package/dist/{exec-run-lifecycle-commands.js → exec/run/lifecycle-commands.js} +30 -22
- package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
- package/dist/{exec-run-mode-shared.js → exec/run/mode-shared.js} +3 -3
- package/dist/{exec-run-register-command.js → exec/run/register-command.js} +18 -10
- package/dist/{exec-run-register-core.js → exec/run/register-core.js} +46 -21
- package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +20 -16
- package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +22 -17
- package/dist/{exec-run-register-state.js → exec/run/register-state.js} +13 -10
- package/dist/{exec-run-register-worktree.js → exec/run/register-worktree.js} +54 -23
- package/dist/{exec-run.js → exec/run/run.js} +11 -11
- package/dist/{exec-run-schedule-mode.js → exec/run/schedule-mode.js} +17 -17
- package/dist/{exec-run-schedule-prepare.js → exec/run/schedule-prepare.js} +31 -18
- package/dist/{exec-run-schedule-task.js → exec/run/schedule-task.js} +45 -18
- package/dist/{exec-run-shared.js → exec/run/shared.js} +61 -11
- package/dist/{exec-schedule-calendar.js → exec/schedule/calendar.js} +1 -1
- package/dist/{exec-schedule-cpm.js → exec/schedule/cpm.js} +2 -2
- package/dist/{exec-schedule-gantt-chart-render.js → exec/schedule/gantt-chart-render.js} +2 -2
- package/dist/exec/schedule/gantt-chart.js +2 -0
- package/dist/{exec-schedule-hash.js → exec/schedule/hash.js} +2 -2
- package/dist/exec/schedule/index.js +1 -0
- package/dist/{exec-schedule-initial.js → exec/schedule/initial.js} +2 -2
- package/dist/{exec-schedule-progress.js → exec/schedule/progress.js} +2 -2
- package/dist/{exec-schedule-ready.js → exec/schedule/ready.js} +2 -2
- package/dist/{exec-schedule.js → exec/schedule/schedule.js} +11 -11
- package/dist/exec/shared.js +63 -0
- package/dist/exec/slot-lock.js +1 -0
- package/dist/{exec-strategy.js → exec/strategy.js} +2 -2
- package/dist/{exec-task-repos.js → exec/task-repos.js} +2 -2
- package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
- package/dist/{exec-trial-commands.js → exec/trial-commands.js} +20 -22
- package/dist/{exec-trial-core.js → exec/trial-core.js} +6 -6
- package/dist/{exec-trial.js → exec/trial.js} +2 -2
- package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
- package/dist/{exec-worktree-ops-commit.js → exec/worktree-ops-commit.js} +25 -60
- package/dist/{exec-worktree-ops-lifecycle.js → exec/worktree-ops-lifecycle.js} +13 -8
- package/dist/{exec-worktree-ops-merge.js → exec/worktree-ops-merge.js} +48 -7
- package/dist/{exec-worktree-ops.js → exec/worktree-ops.js} +3 -3
- package/dist/exec/worktree.js +305 -0
- package/dist/{grade-apply.js → grade/apply.js} +9 -9
- package/dist/{grade-command-apply.js → grade/command-apply.js} +7 -7
- package/dist/{grade-command-inspect.js → grade/command-inspect.js} +6 -6
- package/dist/{grade-command-plan.js → grade/command-plan.js} +5 -5
- package/dist/{grade-core.js → grade/core.js} +3 -3
- package/dist/grade/grade.js +19 -0
- package/dist/{grade-markdown.js → grade/markdown.js} +6 -6
- package/dist/{grade-pipeline-state.js → grade/pipeline-state.js} +4 -4
- package/dist/{grade-plan.js → grade/plan.js} +5 -5
- package/dist/{grade-result.js → grade/result.js} +5 -94
- package/dist/{grade-target-discovery.js → grade/target-discovery.js} +7 -7
- package/dist/{grade-targets.js → grade/targets.js} +11 -8
- package/dist/{job-definition.js → job/definition.js} +25 -6
- package/dist/{job.js → job/job.js} +12 -11
- package/dist/{kata-command.js → kata/command.js} +3 -3
- package/dist/{kata.js → kata/kata.js} +5 -5
- package/dist/register/approach.js +134 -0
- package/dist/{register-core.js → register/core.js} +13 -7
- package/dist/{register-create-commands.js → register/create-commands.js} +115 -8
- package/dist/{register-date.js → register/date.js} +1 -1
- package/dist/register/derivation.js +163 -0
- package/dist/{register-event-merge.js → register/event-merge.js} +32 -3
- package/dist/{register-events.js → register/events.js} +9 -3
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +23 -5
- package/dist/register/lifecycle-lock.js +5 -0
- package/dist/{register-maintenance-commands.js → register/maintenance-commands.js} +13 -7
- package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
- package/dist/{register-migration.js → register/migration.js} +4 -4
- package/dist/{register.js → register/register.js} +32 -27
- package/dist/{register-renumber.js → register/renumber.js} +38 -11
- package/dist/{register-transition-commands.js → register/transition-commands.js} +3 -3
- package/dist/{register-update.js → register/update.js} +5 -5
- package/dist/{register-views.js → register/views.js} +47 -7
- package/dist/{review-grade.js → review/grade.js} +2 -2
- package/dist/{review-plan.js → review/plan.js} +3 -3
- package/dist/{routine-definition.js → routine/definition.js} +2 -2
- package/dist/{routine.js → routine/routine.js} +49 -22
- package/dist/{schedule-approach.js → schedule/approach.js} +8 -8
- package/dist/{schedule-build.js → schedule/build.js} +7 -4
- package/dist/{schedule.js → schedule/schedule.js} +6 -6
- package/dist/{schedule-strategy-generate-document.js → schedule/strategy-generate-document.js} +2 -2
- package/dist/{schedule-strategy-generate-scope.js → schedule/strategy-generate-scope.js} +4 -4
- package/dist/{schedule-strategy-generate.js → schedule/strategy-generate.js} +10 -10
- package/dist/shared/agent-types.js +23 -0
- package/dist/shared/artifact-path.js +9 -0
- package/dist/{build-if-stale.js → shared/build-if-stale.js} +1 -1
- package/dist/{catalog-build-render.js → shared/catalog-render.js} +3 -32
- package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
- package/dist/shared/fs.js +30 -0
- package/dist/{exec-worktree.js → shared/git.js} +83 -241
- package/dist/shared/grade-result.js +94 -0
- package/dist/{package-paths.js → shared/package-paths.js} +3 -3
- package/dist/shared/plan-templates.js +114 -0
- package/dist/{exec-provider-scaffold.js → shared/provider-scaffold.js} +3 -1
- package/dist/shared/random.js +4 -0
- package/dist/{exec-schedule-index.js → shared/schedule-index.js} +3 -1
- package/dist/shared/schedule-paths.js +9 -0
- package/dist/{specdojo-config.js → shared/specdojo-config.js} +93 -5
- package/dist/{exec-shared.js → shared/text.js} +0 -134
- package/dist/shared/time.js +28 -0
- package/dist/specdojo.js +22 -22
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +29 -17
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xer-template.md +1 -3
- package/docs/ja/specdojo/exec-templates/xrp-job-template.md +6 -4
- package/docs/ja/specdojo/guides/exec-config-guide.md +91 -16
- package/docs/ja/specdojo/guides/exec-operation-guide.md +145 -12
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +31 -0
- package/docs/ja/specdojo/guides/quick-start-guide.md +81 -16
- package/docs/ja/specdojo/guides/register-operation-guide.md +2 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +10 -1
- package/docs/ja/specdojo/guides/review-guide.md +1 -1
- package/docs/ja/specdojo/guides/routine-operation-guide.md +5 -5
- package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +52 -28
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +17 -11
- package/docs/ja/specdojo/standards/job-definition-standard.md +20 -18
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
- package/docs/ja/specdojo/templates/pjr-derived-items-template.md +22 -0
- package/docs/ja/specdojo/templates/pjr-index-template.md +1 -0
- package/docs/specdojo/schemas/v1/agent-members.schema.yaml +29 -2
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +20 -0
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +23 -0
- package/docs/specdojo/schemas/v1/job-run.schema.yaml +2 -2
- package/docs/specdojo/schemas/v1/job.schema.yaml +7 -0
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +26 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +70 -7
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +1 -1
- package/package.json +1 -1
- package/templates/antigravity/README.md +5 -1
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
- package/templates/claude/README.md +27 -3
- package/templates/claude/agents/claude-executor.md +0 -1
- package/templates/claude/agents/claude-reporter.md +2 -1
- package/templates/claude/agents/claude-review-executor.md +0 -1
- package/templates/codex/README.md +23 -4
- package/templates/devcontainer/devcontainer.json +2 -2
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +69 -0
- package/templates/devcontainer/remote-host/ssh-config.sample +16 -0
- package/templates/init-agent-members.yaml +75 -25
- package/templates/init-exec-defaults.yaml +24 -8
- package/templates/opencode/README.md +17 -3
- package/templates/opencode/agents/opencode-executor.md +0 -1
- package/templates/opencode/agents/opencode-reporter.md +2 -1
- package/templates/opencode/agents/opencode-review-executor.md +0 -1
- package/dist/exec-schedule-gantt-chart.js +0 -2
- package/dist/exec.js +0 -2
- package/dist/grade.js +0 -19
- package/templates/claude/agents/claude-expert-review-executor.md +0 -14
- /package/dist/{catalog-plan-prompt.js → catalog/plan-prompt.js} +0 -0
- /package/dist/{catalog-types.js → catalog/types.js} +0 -0
- /package/dist/{template-frontmatter.js → docs/template-frontmatter.js} +0 -0
- /package/dist/{role-types.js → exec/role-types.js} +0 -0
- /package/dist/{exec-schedule-gantt-chart-scope.js → exec/schedule/gantt-chart-scope.js} +0 -0
- /package/dist/{exec-types.js → exec/types.js} +0 -0
- /package/dist/{grade-command-shared.js → grade/command-shared.js} +0 -0
- /package/dist/{register-command-types.js → register/command-types.js} +0 -0
- /package/dist/{review-types.js → review/types.js} +0 -0
- /package/dist/{schedule-phase-sets.js → schedule/phase-sets.js} +0 -0
- /package/dist/{schedule-strategy-profiles.js → schedule/strategy-profiles.js} +0 -0
- /package/dist/{agent-response.js → shared/agent-response.js} +0 -0
- /package/dist/{catalog-paths.js → shared/catalog-paths.js} +0 -0
- /package/dist/{dist-freshness.js → shared/dist-freshness.js} +0 -0
- /package/dist/{git-environment.js → shared/git-environment.js} +0 -0
- /package/dist/{exec-format.js → shared/markdown-format.js} +0 -0
- /package/dist/{practice-id.js → shared/practice-id.js} +0 -0
- /package/dist/{spawn-self.js → shared/spawn-self.js} +0 -0
- /package/dist/{specdojo-gitignore.js → shared/specdojo-gitignore.js} +0 -0
- /package/dist/{template-resolution.js → shared/template-resolution.js} +0 -0
- /package/dist/{yaml-schema-modeline.js → shared/yaml-schema-modeline.js} +0 -0
- /package/dist/{yaml.js → shared/yaml.js} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { basename, join, relative, resolve } from "node:path";
|
|
3
|
-
import { load } from "
|
|
4
|
-
import { specdojoRootDir } from "
|
|
5
|
-
import { kataDirsForKinds, resolveIncludedRulebooks, resolveKataRefs } from "
|
|
6
|
-
import { resolveBasePath, resolveDeliverablePath } from "
|
|
7
|
-
import { isDctPlanFileName } from "
|
|
8
|
-
import { buildSpecdojoFrontmatter, readSpecdojoNamespace } from "
|
|
9
|
-
import { qualifyPracticeId, SPECDOJO_PRACTICE_AUTHORITY } from "
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
3
|
+
import { load } from "../shared/yaml.js";
|
|
4
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
5
|
+
import { kataDirsForKinds, resolveIncludedRulebooks, resolveKataRefs } from "../kata/kata.js";
|
|
6
|
+
import { resolveBasePath, resolveDeliverablePath } from "../catalog/paths.js";
|
|
7
|
+
import { isDctPlanFileName } from "../catalog/plan.js";
|
|
8
|
+
import { buildSpecdojoFrontmatter, readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
|
|
9
|
+
import { qualifyPracticeId, SPECDOJO_PRACTICE_AUTHORITY } from "../shared/practice-id.js";
|
|
10
|
+
import { MISSING } from "../shared/plan-templates.js";
|
|
11
|
+
export { MISSING, execTemplatePath, execTemplatesDir, injectCommonConventions, loadPlanTemplate, } from "../shared/plan-templates.js";
|
|
12
|
+
import { resolveViewpointsDoc, viewpointAppliesToDocument } from "../review/plan.js";
|
|
13
|
+
import { listFilesRecursive, nowUtcIsoSeconds, randomHex, tsForFilenameUtc } from "./shared.js";
|
|
14
|
+
import { gradeFindingDisplayMessage, gradeResultPathForDocument, readGradeResultForDocument, } from "../shared/grade-result.js";
|
|
15
|
+
import { renderReviewGradeSummary, reviewGradeFreshness } from "../review/grade.js";
|
|
16
16
|
export function execDocId(projectId, prefix, localBase) {
|
|
17
17
|
const localId = `${prefix}-${localBase.toLowerCase()}`;
|
|
18
18
|
return projectId ? `${projectId}:${localId}` : localId;
|
|
@@ -95,6 +95,60 @@ export function loadCatalogDocs(catalogPath) {
|
|
|
95
95
|
}
|
|
96
96
|
return docs;
|
|
97
97
|
}
|
|
98
|
+
function resolvedDeliverablesInCatalog(catalogPath) {
|
|
99
|
+
const deliverables = [];
|
|
100
|
+
const visit = (sections, parentBase, domain) => {
|
|
101
|
+
for (const section of sections) {
|
|
102
|
+
const sectionBase = resolveBasePath(parentBase, section.base_path);
|
|
103
|
+
for (const item of section.deliverables ?? []) {
|
|
104
|
+
deliverables.push({
|
|
105
|
+
domain,
|
|
106
|
+
localId: item.local_id,
|
|
107
|
+
slug: item.local_id,
|
|
108
|
+
info: {
|
|
109
|
+
deliverable: item,
|
|
110
|
+
resolvedPath: resolveDeliverablePath(sectionBase, item.path),
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
visit(section.groups ?? [], sectionBase, domain);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
for (const doc of loadCatalogDocs(catalogPath)) {
|
|
118
|
+
visit(doc.groups, resolveBasePath("", doc.base_path), doc.domain);
|
|
119
|
+
}
|
|
120
|
+
return deliverables;
|
|
121
|
+
}
|
|
122
|
+
// Register targets use document IDs rather than schedule local_ids. Resolve the document ID
|
|
123
|
+
// back to its catalog entry so register-originated approach plans can share schedule rendering.
|
|
124
|
+
export function resolveDeliverableByDocId(catalogPath, projectId, targetId) {
|
|
125
|
+
const matches = resolvedDeliverablesInCatalog(catalogPath).filter((target) => {
|
|
126
|
+
const docId = deliverableDocId(projectId, target.info.deliverable.local_id, target.info.resolvedPath);
|
|
127
|
+
return (targetId === docId ||
|
|
128
|
+
targetId === target.localId ||
|
|
129
|
+
targetId === qualifiedDocId(projectId, target.localId));
|
|
130
|
+
});
|
|
131
|
+
if (matches.length === 0) {
|
|
132
|
+
throw new Error(`catalog deliverable target not found for document id: ${targetId}`);
|
|
133
|
+
}
|
|
134
|
+
if (matches.length > 1) {
|
|
135
|
+
throw new Error(`ambiguous catalog deliverable target for document id ${targetId}: ${matches
|
|
136
|
+
.map((match) => match.localId)
|
|
137
|
+
.join(", ")}`);
|
|
138
|
+
}
|
|
139
|
+
return matches[0];
|
|
140
|
+
}
|
|
141
|
+
// A kata may be declared by zero, one, or several deliverables. Only a unique declaration is
|
|
142
|
+
// used as the maintenance plan's evidence context; otherwise the explicitly targeted kata remains
|
|
143
|
+
// executable without selecting an arbitrary deliverable.
|
|
144
|
+
export function findUniqueDeliverableForKataTarget(catalogPath, targetId, kind) {
|
|
145
|
+
const matches = resolvedDeliverablesInCatalog(catalogPath).filter((target) => {
|
|
146
|
+
const refs = resolveKataRefs(target.info.deliverable.rulebook, target.info.deliverable.kind);
|
|
147
|
+
const refPath = refs[kind];
|
|
148
|
+
return refPath !== MISSING && refDocIdFromPath(refPath) === targetId;
|
|
149
|
+
});
|
|
150
|
+
return matches.length === 1 ? matches[0].info : null;
|
|
151
|
+
}
|
|
98
152
|
// Resolve a `--deliverable` identifier (a bare `local_id`) to a catalog deliverable.
|
|
99
153
|
// `local_id` is unique project-wide (catalog validate warns otherwise); an ambiguous
|
|
100
154
|
// match is an error rather than a silent first match.
|
|
@@ -171,106 +225,6 @@ export function frontmatter(meta) {
|
|
|
171
225
|
return buildSpecdojoFrontmatter(inner);
|
|
172
226
|
}
|
|
173
227
|
// ---------------------------------------------------------------------------
|
|
174
|
-
// Template-based generation (edit-plan / review-plan テンプレートの展開)
|
|
175
|
-
// ---------------------------------------------------------------------------
|
|
176
|
-
// Shared conventions (link notation など) appended to every generated plan. The plan is the
|
|
177
|
-
// only context guaranteed to reach the executing agent regardless of tool (it is piped via
|
|
178
|
-
// stdin), so cross-tool rules must travel with the plan rather than tool-specific instruction
|
|
179
|
-
// files. Kept as a single fragment to avoid duplicating the rule across every plan template.
|
|
180
|
-
const COMMON_CONVENTIONS_TEMPLATE = "xep-common-conventions-template.md";
|
|
181
|
-
export function execTemplatesDir() {
|
|
182
|
-
return resolveSpecdojoPath("docs/ja/specdojo/exec-templates");
|
|
183
|
-
}
|
|
184
|
-
export function execTemplatePath(fileName) {
|
|
185
|
-
return resolveSpecdojoPath(`docs/ja/specdojo/exec-templates/${fileName}`);
|
|
186
|
-
}
|
|
187
|
-
function templatePrefix(mode) {
|
|
188
|
-
return mode === "review" ? "xrp" : "xep";
|
|
189
|
-
}
|
|
190
|
-
function standardTemplateFileName(mode) {
|
|
191
|
-
return `${templatePrefix(mode)}-template.md`;
|
|
192
|
-
}
|
|
193
|
-
function approachTemplateFileName(mode, approach) {
|
|
194
|
-
return `${templatePrefix(mode)}-${approach}-template.md`;
|
|
195
|
-
}
|
|
196
|
-
// Selects <prefix>-<approach>-template.md when it exists, falling back
|
|
197
|
-
// to the standard <prefix>-template.md. Any missing variant falls through to the
|
|
198
|
-
// next candidate so a plan is always produced.
|
|
199
|
-
function resolvePlanTemplatePath(mode, approach) {
|
|
200
|
-
if (approach) {
|
|
201
|
-
const candidatePath = resolveSpecdojoPathIfExists(`docs/ja/specdojo/exec-templates/${approachTemplateFileName(mode, approach)}`);
|
|
202
|
-
if (candidatePath)
|
|
203
|
-
return candidatePath;
|
|
204
|
-
}
|
|
205
|
-
return execTemplatePath(standardTemplateFileName(mode));
|
|
206
|
-
}
|
|
207
|
-
function readTemplate(templatePath, cache) {
|
|
208
|
-
const cached = cache.get(templatePath);
|
|
209
|
-
if (cached !== undefined)
|
|
210
|
-
return cached;
|
|
211
|
-
if (!existsSync(templatePath)) {
|
|
212
|
-
throw new Error(`Template not found: ${templatePath}`);
|
|
213
|
-
}
|
|
214
|
-
const content = readFileSync(templatePath, "utf8");
|
|
215
|
-
cache.set(templatePath, content);
|
|
216
|
-
return content;
|
|
217
|
-
}
|
|
218
|
-
export function loadPlanTemplate(mode, approach, cache) {
|
|
219
|
-
return readTemplate(resolvePlanTemplatePath(mode, approach), cache);
|
|
220
|
-
}
|
|
221
|
-
// Marker a plan template places to control where the shared conventions fragment lands.
|
|
222
|
-
const COMMON_CONVENTIONS_PLACEHOLDER = "_COMMON_CONVENTIONS_";
|
|
223
|
-
// Lines delimiting the review-only block of the conventions fragment (review の判断手順). The
|
|
224
|
-
// block is kept, without the marker lines, in review plans and dropped from every other plan.
|
|
225
|
-
const REVIEW_ONLY_START = "<!-- review-only:start -->";
|
|
226
|
-
const REVIEW_ONLY_END = "<!-- review-only:end -->";
|
|
227
|
-
function selectReviewOnlyBlock(conventions, isReview) {
|
|
228
|
-
const kept = [];
|
|
229
|
-
let inside = false;
|
|
230
|
-
for (const line of conventions.split("\n")) {
|
|
231
|
-
const marker = line.trim();
|
|
232
|
-
if (marker === REVIEW_ONLY_START) {
|
|
233
|
-
inside = true;
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
if (marker === REVIEW_ONLY_END) {
|
|
237
|
-
inside = false;
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
if (!inside || isReview)
|
|
241
|
-
kept.push(line);
|
|
242
|
-
}
|
|
243
|
-
return kept
|
|
244
|
-
.join("\n")
|
|
245
|
-
.replace(/\n{3,}/g, "\n\n")
|
|
246
|
-
.trimEnd();
|
|
247
|
-
}
|
|
248
|
-
// Placeholder in the conventions fragment for the resolved schema path. The agent cannot derive
|
|
249
|
-
// the schema path on its own (it would have to hunt for it and risks burning its turn before
|
|
250
|
-
// filling the result), so the generator resolves it deterministically and bakes it in here.
|
|
251
|
-
const SCHEMA_REF_PLACEHOLDER = "_SCHEMA_REF_";
|
|
252
|
-
// Injects the shared conventions fragment into a built plan body so every generated plan carries
|
|
253
|
-
// the same rules (e.g. link notation) in its own text, independent of the executing tool. A
|
|
254
|
-
// template controls placement via the COMMON_CONVENTIONS_PLACEHOLDER marker; templates without the
|
|
255
|
-
// marker get the block appended so the rules are never silently dropped.
|
|
256
|
-
// schemaRef is the resolved schema path: when MISSING (non-yaml deliverable or no schema), the
|
|
257
|
-
// schema-validation bullet is dropped so the plan never asks for a check it cannot specify.
|
|
258
|
-
// mode selects whether the review-only block (review の判断手順) is kept; it defaults to edit so
|
|
259
|
-
// register / job plans never carry review instructions.
|
|
260
|
-
export function injectCommonConventions(body, schemaRef, cache, mode = "edit") {
|
|
261
|
-
let conventions = selectReviewOnlyBlock(readTemplate(execTemplatePath(COMMON_CONVENTIONS_TEMPLATE), cache), mode === "review");
|
|
262
|
-
conventions =
|
|
263
|
-
schemaRef === MISSING
|
|
264
|
-
? conventions
|
|
265
|
-
.split("\n")
|
|
266
|
-
.filter((line) => !line.includes(SCHEMA_REF_PLACEHOLDER))
|
|
267
|
-
.join("\n")
|
|
268
|
-
: conventions.split(SCHEMA_REF_PLACEHOLDER).join(schemaRef);
|
|
269
|
-
if (body.includes(COMMON_CONVENTIONS_PLACEHOLDER)) {
|
|
270
|
-
return body.split(COMMON_CONVENTIONS_PLACEHOLDER).join(conventions);
|
|
271
|
-
}
|
|
272
|
-
return `${body.trimEnd()}\n\n${conventions}\n`;
|
|
273
|
-
}
|
|
274
228
|
export function phaseDescriptionText(task) {
|
|
275
229
|
if (task.description)
|
|
276
230
|
return task.description.trimEnd();
|
|
@@ -360,7 +314,7 @@ export function kataRefState(refPath) {
|
|
|
360
314
|
}
|
|
361
315
|
// 対象成果物の depends_on を、依存先 doc の [[id]] 参照の入れ子リストで提示する。
|
|
362
316
|
// id は依存先の frontmatter、未作成なら配置規約から解決する。agent へ plan を渡すときに
|
|
363
|
-
// expandPromptRefs(src/exec
|
|
317
|
+
// expandPromptRefs(src/exec/run/agent.ts, format:'path')が
|
|
364
318
|
// この [[id]] を doc-index 経由でリポジトリ相対パスへ展開し、agent が先行成果物を直接開ける。
|
|
365
319
|
// テンプレート側はラベル直後にこの値を差し込むため、件数 0・成果物未解決時は先頭スペース付きの
|
|
366
320
|
// インライン値、依存ありの場合は改行始まりの入れ子リストを返す。
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { DEFAULT_PROJECT_CONTEXT } from "
|
|
4
|
-
import { resolveDeliverableSchemaRef, resolveKataRefs } from "
|
|
5
|
-
import { formatMarkdownFile } from "./
|
|
6
|
-
import { expandTemplate } from "./
|
|
7
|
-
import { MISSING, applicableReviewCriteria, crossDeliverableTargetDetails, deliverableDependsOn, 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 "./
|
|
8
|
-
function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, projectId, catalogPath, projectContext, resultRef, stem, crossDeliverables = new Map()) {
|
|
3
|
+
import { DEFAULT_PROJECT_CONTEXT } from "../shared/specdojo-config.js";
|
|
4
|
+
import { resolveDeliverableSchemaRef, resolveKataRefs } from "../kata/kata.js";
|
|
5
|
+
import { formatMarkdownFile } from "./format.js";
|
|
6
|
+
import { expandTemplate } from "./shared.js";
|
|
7
|
+
import { MISSING, applicableReviewCriteria, crossDeliverableTargetDetails, deliverableDependsOn, 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";
|
|
8
|
+
function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, projectId, catalogPath, projectContext, resultRef, stem, crossDeliverables = new Map(), planOverrides) {
|
|
9
9
|
const cpm = task.cpm;
|
|
10
10
|
const onCriticalPath = cpm !== undefined && cpm.slack === 0;
|
|
11
|
-
const targets =
|
|
11
|
+
const targets = planOverrides?.targets
|
|
12
|
+
? [...planOverrides.targets]
|
|
13
|
+
: targetDocIdsForTask(projectId, task, deliverable, crossDeliverables);
|
|
12
14
|
const meta = {
|
|
13
15
|
id: execDocId(projectId, "xep", stem),
|
|
14
16
|
type: "exec-plan",
|
|
@@ -18,6 +20,7 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
18
20
|
mode: "edit",
|
|
19
21
|
status: "ready",
|
|
20
22
|
project_id: projectId,
|
|
23
|
+
...(planOverrides?.origin ? { origin: planOverrides.origin } : {}),
|
|
21
24
|
...(task.owner ? { owner: task.owner } : {}),
|
|
22
25
|
...(onCriticalPath ? { on_critical_path: true } : {}),
|
|
23
26
|
...(task.approach ? { approach: task.approach } : {}),
|
|
@@ -25,7 +28,8 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
25
28
|
};
|
|
26
29
|
const criteria = deliverable?.deliverable.done_criteria ?? [];
|
|
27
30
|
const ownerRole = ownerRoleFields(task.owner, roleMap, vpMap, deliverable?.deliverable.rulebook);
|
|
28
|
-
const refs =
|
|
31
|
+
const refs = planOverrides?.refs ??
|
|
32
|
+
resolveKataRefs(deliverable?.deliverable.rulebook, deliverable?.deliverable.kind);
|
|
29
33
|
const values = {
|
|
30
34
|
_FRONTMATTER_: frontmatter(meta),
|
|
31
35
|
_TASK_ID_: task.id,
|
|
@@ -55,7 +59,20 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
55
59
|
_GRADE_FINDINGS_: gradeFindingsText(projectId, gradeFindingTargetPath(task.approach, deliverable, refs)),
|
|
56
60
|
_TARGET_DELIVERABLES_: crossDeliverableTargetDetails(projectId, task.target_local_ids ?? [], crossDeliverables, catalogPath),
|
|
57
61
|
};
|
|
58
|
-
|
|
62
|
+
const body = expandTemplate(template, values);
|
|
63
|
+
if (!planOverrides?.additionalConditions)
|
|
64
|
+
return body;
|
|
65
|
+
const section = [
|
|
66
|
+
"## 個票の追加完了条件",
|
|
67
|
+
"",
|
|
68
|
+
"成果物カタログの `done_criteria` に加え、登録簿の個票が定める次の条件も満たす。",
|
|
69
|
+
"",
|
|
70
|
+
planOverrides.additionalConditions.trim(),
|
|
71
|
+
"",
|
|
72
|
+
].join("\n");
|
|
73
|
+
return body.includes("_COMMON_CONVENTIONS_")
|
|
74
|
+
? body.replace("_COMMON_CONVENTIONS_", `${section}\n_COMMON_CONVENTIONS_`)
|
|
75
|
+
: `${body.trimEnd()}\n\n${section}`;
|
|
59
76
|
}
|
|
60
77
|
// review plan は成果物を再評価しない。grade の評価結果(サイドカー)の位置と完了条件を示し、
|
|
61
78
|
// 評価結果を事実として受け取ってタスクの完了可否を判断させる(bps-task-completion)。
|
|
@@ -135,7 +152,7 @@ async function writeTaskPlan(ctx, task, override) {
|
|
|
135
152
|
const template = loadPlanTemplate(mode, task.approach, ctx.templateCache);
|
|
136
153
|
const body = mode === "review"
|
|
137
154
|
? buildReviewPlanMarkdown(template, planTask, deliverable, criteria, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, ctx.reviewGradeOutcome)
|
|
138
|
-
: buildEditPlanMarkdown(template, planTask, deliverable, ctx.roleMap, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, crossDeliverables);
|
|
155
|
+
: buildEditPlanMarkdown(template, planTask, deliverable, ctx.roleMap, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, crossDeliverables, override);
|
|
139
156
|
const schemaRef = resolveDeliverableSchemaRef(deliverable?.resolvedPath);
|
|
140
157
|
const content = injectCommonConventions(body, schemaRef, ctx.templateCache, mode);
|
|
141
158
|
writeFileSync(outPath, content, "utf8");
|
|
@@ -182,6 +199,32 @@ export async function generateDeliverablePlan(opts) {
|
|
|
182
199
|
...(opts.stem ? { stem: opts.stem } : {}),
|
|
183
200
|
});
|
|
184
201
|
}
|
|
202
|
+
// Register items with an approach use the same template and catalog/kata resolution as
|
|
203
|
+
// schedule tasks, while keeping register identity and target coverage in the plan metadata.
|
|
204
|
+
export async function generateRegisterApproachPlan(opts) {
|
|
205
|
+
const ctx = newPlanGenContext(opts);
|
|
206
|
+
const task = {
|
|
207
|
+
id: opts.taskId,
|
|
208
|
+
name: opts.title,
|
|
209
|
+
description: opts.description,
|
|
210
|
+
mode: "edit",
|
|
211
|
+
approach: opts.approach,
|
|
212
|
+
...(opts.deliverable ? { local_id: opts.deliverable.deliverable.local_id } : {}),
|
|
213
|
+
...(opts.owner ? { owner: opts.owner } : {}),
|
|
214
|
+
schedule_file: "",
|
|
215
|
+
fifo_rank: 0,
|
|
216
|
+
critical_first_rank: 0,
|
|
217
|
+
};
|
|
218
|
+
return await writeTaskPlan(ctx, task, {
|
|
219
|
+
deliverable: opts.deliverable ?? null,
|
|
220
|
+
origin: "register",
|
|
221
|
+
targets: opts.targets,
|
|
222
|
+
...(opts.refs ? { refs: opts.refs } : {}),
|
|
223
|
+
additionalConditions: opts.additionalConditions,
|
|
224
|
+
...(opts.outPath ? { outPath: opts.outPath } : {}),
|
|
225
|
+
stem: opts.stem,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
185
228
|
function newPlanGenContext(opts) {
|
|
186
229
|
const plansDir = join(opts.executionPath, "exec", "plans");
|
|
187
230
|
mkdirSync(plansDir, { recursive: true });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync } from "node:fs";
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
|
-
import { specdojoRootDir } from "
|
|
4
|
-
import { nowUtcIsoSeconds, randomHex, tsForFilenameUtc } from "./
|
|
5
|
-
import { readSpecdojoNamespace } from "
|
|
6
|
-
import { gradeFindingDisplayMessage, gradeResultPathForDocument, readGradeResultForDocument, } from "
|
|
7
|
-
import { lookupDocIndex } from "
|
|
3
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
4
|
+
import { nowUtcIsoSeconds, randomHex, tsForFilenameUtc } from "./shared.js";
|
|
5
|
+
import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
|
|
6
|
+
import { gradeFindingDisplayMessage, gradeResultPathForDocument, readGradeResultForDocument, } from "../shared/grade-result.js";
|
|
7
|
+
import { lookupDocIndex } from "../docs/doc-index.js";
|
|
8
8
|
export function archivePlan(opts) {
|
|
9
9
|
const plansDir = join(opts.executionPath, "exec", "plans");
|
|
10
10
|
const from = join(plansDir, `${opts.slug}-plan.md`);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { MISSING, applicableReviewCriteria, buildInPlaceStem, deliverableDocId, deliverableDocPath, execTemplatePath, execTemplatesDir, finalizeResultSectionsForDeliverable, injectCommonConventions, ownerRoleFields, resolveDeliverableTarget, reviewGradeSubject, stemFromPlanPath, targetDocIdsForDeliverable, targetDocIdsForScheduledTask, targetReferenceDirsForApproach, } from "./
|
|
2
|
-
export { generateDeliverablePlan, generateSinglePlan } from "./
|
|
3
|
-
export { archivePlan, loadPlan, parsePlanTaskIdentity, planPathForTask, registerGradeFindingsText, } from "./
|
|
1
|
+
export { MISSING, applicableReviewCriteria, buildInPlaceStem, deliverableDocId, deliverableDocPath, execTemplatePath, execTemplatesDir, finalizeResultSectionsForDeliverable, injectCommonConventions, ownerRoleFields, resolveDeliverableTarget, reviewGradeSubject, stemFromPlanPath, targetDocIdsForDeliverable, targetDocIdsForScheduledTask, targetReferenceDirsForApproach, } from "./plans-core.js";
|
|
2
|
+
export { generateDeliverablePlan, generateRegisterApproachPlan, generateSinglePlan, } from "./plans-generation.js";
|
|
3
|
+
export { archivePlan, loadPlan, parsePlanTaskIdentity, planPathForTask, registerGradeFindingsText, } from "./plans-storage.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join, resolve } from "node:path";
|
|
2
|
-
import { getProjectCatalogPath, getProjectContext, getProjectExecutionPath, getProjectRolesPath, getProjectSchedulePath, getProjectViewpointsPath, loadConfig, loadEnv, specdojoRootDir, } from "
|
|
2
|
+
import { getProjectCatalogPath, getProjectContext, getProjectExecutionPath, getProjectRolesPath, getProjectSchedulePath, getProjectViewpointsPath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
3
3
|
function projectBaseDir() {
|
|
4
4
|
return specdojoRootDir();
|
|
5
5
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { stripTerminalControlSequences } from "./
|
|
3
|
-
import { describeAgentProtectedConfigChanges, qualifiedRepoPaths, } from "./
|
|
4
|
-
import { describeAgentGitStateChanges, qualifiedGitStateFields, } from "./
|
|
2
|
+
import { stripTerminalControlSequences } from "./shared.js";
|
|
3
|
+
import { describeAgentProtectedConfigChanges, qualifiedRepoPaths, } from "./agent-protected-config.js";
|
|
4
|
+
import { describeAgentGitStateChanges, qualifiedGitStateFields, } from "./agent-git-state.js";
|
|
5
5
|
// PJR-VH6R: 保護機構が agent の変更を止めたとき、規約は「対象・変更理由・提案差分・
|
|
6
6
|
// 変更後に必要な検証」を result の申し送りへ書くことを求めている。しかし block は agent の
|
|
7
7
|
// 記入を待たずに成立するため、実際には _TODO_ のまま残り、orchestrator が worktree の
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readdirSync } from "node:fs";
|
|
2
2
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
-
import { loadPipelineResumeCheckpoint } from "./
|
|
4
|
-
import { safeSlug } from "./
|
|
3
|
+
import { loadPipelineResumeCheckpoint } from "./pipeline-state.js";
|
|
4
|
+
import { safeSlug } from "./shared.js";
|
|
5
5
|
function executorResumeHandoff(evidence) {
|
|
6
6
|
if (!evidence)
|
|
7
7
|
return [];
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join, relative } from "node:path";
|
|
3
|
-
import { findRegisterItem, loadRegisterItems, PJR_ID_RE, resolveRegisterPaths, TERMINAL_STATUSES_SET, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "
|
|
4
|
-
import { execTemplatePath, injectCommonConventions, MISSING, registerGradeFindingsText, } from "./
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { join, relative, resolve } from "node:path";
|
|
3
|
+
import { findRegisterItem, loadRegisterItems, PJR_ID_RE, resolveRegisterPaths, TERMINAL_STATUSES_SET, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "../register/register.js";
|
|
4
|
+
import { execTemplatePath, injectCommonConventions, MISSING, registerGradeFindingsText, } from "./plans.js";
|
|
5
|
+
import { generateRegisterApproachPlan } from "./plans-generation.js";
|
|
6
|
+
import { findUniqueDeliverableForKataTarget, resolveDeliverableByDocId, } from "./plans-core.js";
|
|
7
|
+
import { collectDocIndexEntries } from "../docs/doc-index.js";
|
|
8
|
+
import { resolveKataRefs } from "../kata/kata.js";
|
|
9
|
+
import { buildSpecdojoFrontmatter } from "../docs/frontmatter-namespace.js";
|
|
10
|
+
import { escapeMarkdownInline, expandTemplate, inlineCodeAnglePlaceholders, stripTerminalControlSequences, } from "./shared.js";
|
|
11
|
+
import { formatMarkdownFile } from "./format.js";
|
|
12
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
9
13
|
const EDIT_TYPES = new Set(["todo", "issue", "change-request"]);
|
|
10
14
|
const INVESTIGATE_TYPES = new Set(["question", "risk"]);
|
|
11
15
|
export function registerItemCategory(itemType) {
|
|
@@ -211,6 +215,12 @@ const REGISTER_PLAN_TEMPLATES = {
|
|
|
211
215
|
edit: "xep-register-template.md",
|
|
212
216
|
investigate: "xep-register-investigate-template.md",
|
|
213
217
|
};
|
|
218
|
+
const MAINTENANCE_TARGET_KIND = {
|
|
219
|
+
"rulebook-maintenance": "rulebook",
|
|
220
|
+
"recipe-maintenance": "recipe",
|
|
221
|
+
"sample-maintenance": "sample",
|
|
222
|
+
"template-maintenance": "template",
|
|
223
|
+
};
|
|
214
224
|
// Canonical repo-root-relative path (POSIX separators, no leading slash); mirrors the
|
|
215
225
|
// convention used by exec-plans for agent-consumed paths.
|
|
216
226
|
function repoRelativePath(absPath) {
|
|
@@ -246,9 +256,84 @@ function registerPlanFrontmatter(projectId, stem, item) {
|
|
|
246
256
|
}
|
|
247
257
|
return buildSpecdojoFrontmatter(inner);
|
|
248
258
|
}
|
|
259
|
+
function registerCompletionConditions(item, ticketPath) {
|
|
260
|
+
if (ticketPath && existsSync(ticketPath)) {
|
|
261
|
+
const content = readFileSync(ticketPath, "utf8");
|
|
262
|
+
const body = content.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "");
|
|
263
|
+
const lines = body.split(/\r?\n/);
|
|
264
|
+
const heading = lines.findIndex((line) => /^##\s+(?:\d+\.\s*)?完了条件\s*$/.test(line));
|
|
265
|
+
if (heading >= 0) {
|
|
266
|
+
const endOffset = lines.slice(heading + 1).findIndex((line) => /^##\s+/.test(line));
|
|
267
|
+
const end = endOffset >= 0 ? heading + 1 + endOffset : lines.length;
|
|
268
|
+
const conditions = lines
|
|
269
|
+
.slice(heading + 1, end)
|
|
270
|
+
.join("\n")
|
|
271
|
+
.trim();
|
|
272
|
+
if (conditions)
|
|
273
|
+
return conditions;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return item.description && item.description !== "_TODO_"
|
|
277
|
+
? escapeMarkdownInline(item.description)
|
|
278
|
+
: "- 個票に明示的な完了条件がないため、タイトルと概要を追加条件として扱う。";
|
|
279
|
+
}
|
|
280
|
+
function indexedDocumentPath(targetId) {
|
|
281
|
+
const repoRoot = specdojoRootDir();
|
|
282
|
+
const indexed = collectDocIndexEntries(join(repoRoot, "docs"), repoRoot)[targetId];
|
|
283
|
+
if (!indexed) {
|
|
284
|
+
throw new Error(`Target document id is not resolvable via the document index: ${targetId}`);
|
|
285
|
+
}
|
|
286
|
+
const withoutLine = indexed.replace(/:\d+$/, "");
|
|
287
|
+
return relative(repoRoot, resolve(repoRoot, withoutLine)).replace(/\\/g, "/");
|
|
288
|
+
}
|
|
249
289
|
export async function generateRegisterPlan(opts) {
|
|
250
290
|
const { item } = opts;
|
|
251
291
|
const category = requireRunnableRegisterItem(item);
|
|
292
|
+
const ticketPath = ticketPathFromItem(item, opts.registerPaths.projectRegisterPath);
|
|
293
|
+
if (item.approach) {
|
|
294
|
+
const [targetId] = item.targets ?? [];
|
|
295
|
+
if (!targetId || (item.targets?.length ?? 0) !== 1) {
|
|
296
|
+
throw new Error(`Register item ${item.id} approach requires exactly one target document id.`);
|
|
297
|
+
}
|
|
298
|
+
const maintenanceKind = MAINTENANCE_TARGET_KIND[item.approach];
|
|
299
|
+
let deliverable = null;
|
|
300
|
+
let refs;
|
|
301
|
+
if (maintenanceKind) {
|
|
302
|
+
deliverable = opts.catalogPath
|
|
303
|
+
? findUniqueDeliverableForKataTarget(opts.catalogPath, targetId, maintenanceKind)
|
|
304
|
+
: null;
|
|
305
|
+
refs = deliverable
|
|
306
|
+
? resolveKataRefs(deliverable.deliverable.rulebook, deliverable.deliverable.kind)
|
|
307
|
+
: { rulebook: MISSING, recipe: MISSING, sample: MISSING, template: MISSING };
|
|
308
|
+
refs = { ...refs, [maintenanceKind]: indexedDocumentPath(targetId) };
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
if (!opts.catalogPath) {
|
|
312
|
+
throw new Error(`Register item ${item.id} approach requires catalog_path to resolve ${targetId}.`);
|
|
313
|
+
}
|
|
314
|
+
deliverable = resolveDeliverableByDocId(opts.catalogPath, opts.projectId, targetId).info;
|
|
315
|
+
}
|
|
316
|
+
const planPath = await generateRegisterApproachPlan({
|
|
317
|
+
executionPath: opts.executionPath,
|
|
318
|
+
projectId: opts.projectId,
|
|
319
|
+
catalogPath: opts.catalogPath ?? "",
|
|
320
|
+
...(opts.rolesPath ? { rolesPath: opts.rolesPath } : {}),
|
|
321
|
+
...(opts.viewpointsPath ? { viewpointsPath: opts.viewpointsPath } : {}),
|
|
322
|
+
...(opts.projectContext ? { projectContext: opts.projectContext } : {}),
|
|
323
|
+
taskId: item.id,
|
|
324
|
+
title: item.title,
|
|
325
|
+
description: item.description,
|
|
326
|
+
...(item.owner && item.owner !== "-" && item.owner !== "_TODO_" ? { owner: item.owner } : {}),
|
|
327
|
+
approach: item.approach,
|
|
328
|
+
targets: item.targets ?? [],
|
|
329
|
+
deliverable,
|
|
330
|
+
...(refs ? { refs } : {}),
|
|
331
|
+
additionalConditions: registerCompletionConditions(item, ticketPath),
|
|
332
|
+
...(opts.outPath ? { outPath: opts.outPath } : {}),
|
|
333
|
+
stem: opts.stem,
|
|
334
|
+
});
|
|
335
|
+
return { planPath, category };
|
|
336
|
+
}
|
|
252
337
|
const templatePath = execTemplatePath(REGISTER_PLAN_TEMPLATES[category]);
|
|
253
338
|
if (!existsSync(templatePath)) {
|
|
254
339
|
throw new Error(`Template not found: ${templatePath}`);
|
|
@@ -258,7 +343,6 @@ export async function generateRegisterPlan(opts) {
|
|
|
258
343
|
mkdirSync(plansDir, { recursive: true });
|
|
259
344
|
const planPath = opts.outPath ?? join(plansDir, `${opts.stem}-plan.md`);
|
|
260
345
|
const resultRef = `${repoRelativePath(opts.executionPath)}/exec/results/${opts.stem}-result.md`;
|
|
261
|
-
const ticketPath = ticketPathFromItem(item, opts.registerPaths.projectRegisterPath);
|
|
262
346
|
const values = {
|
|
263
347
|
_FRONTMATTER_: registerPlanFrontmatter(opts.projectId, opts.stem, item),
|
|
264
348
|
_PJR_ID_: item.id,
|
|
@@ -273,7 +357,6 @@ export async function generateRegisterPlan(opts) {
|
|
|
273
357
|
_PJR_PRIORITY_: item.priority,
|
|
274
358
|
_PJR_OWNER_: item.owner,
|
|
275
359
|
_PJR_DUE_: item.due,
|
|
276
|
-
_PJR_INDEX_PATH_: repoRelativePath(opts.registerPaths.pjrIndexPath),
|
|
277
360
|
_PJR_TICKET_REF_: ticketPath ? `\`${repoRelativePath(ticketPath)}\`` : "-",
|
|
278
361
|
_RESULT_REF_: resultRef,
|
|
279
362
|
_GRADE_FINDINGS_: ticketPath ? registerGradeFindingsText(opts.projectId, ticketPath) : "- なし",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { gitOutput, gitResult } from "./
|
|
2
|
-
import { PROJECT_REPO_WORKTREE_DIRNAME } from "
|
|
1
|
+
import { gitOutput, gitResult } from "./worktree.js";
|
|
2
|
+
import { PROJECT_REPO_WORKTREE_DIRNAME } from "../shared/specdojo-config.js";
|
|
3
3
|
/** Name under which the project repository is recorded in `stages.integrate.repos`. */
|
|
4
4
|
export const PROJECT_REPO_NAME = PROJECT_REPO_WORKTREE_DIRNAME;
|
|
5
5
|
export function zeroSeparated(cwd, args) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import { productIntegrationTarget } from "./
|
|
3
|
-
import { abortMerge } from "./
|
|
4
|
-
import { gitOutput, gitResult } from "./
|
|
5
|
-
import { PROJECT_REPO_NAME, branchExists, dirtyPaths, gitText, mergeInProgress, zeroSeparated, } from "./
|
|
2
|
+
import { productIntegrationTarget } from "./task-repos.js";
|
|
3
|
+
import { abortMerge } from "./worktree-ops.js";
|
|
4
|
+
import { gitOutput, gitResult } from "./worktree.js";
|
|
5
|
+
import { PROJECT_REPO_NAME, branchExists, dirtyPaths, gitText, mergeInProgress, zeroSeparated, } from "./repo-integration-git.js";
|
|
6
6
|
function isAncestor(cwd, ancestor, descendant) {
|
|
7
7
|
return gitResult(cwd, ["merge-base", "--is-ancestor", ancestor, descendant]).status === 0;
|
|
8
8
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { appendFileSync, existsSync, mkdirSync } from "node:fs";
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
|
-
import { acquireSchedulerLock, releaseSchedulerLock } from "./
|
|
4
|
-
import { productIntegrationTarget } from "./
|
|
5
|
-
import { abortMerge, commitTargetPaths, isExecBranchMergedIntoCurrent, recordRootNewFilesHandoff, REGISTER_NEW_FILE_DIR_PREFIXES, repoRelative, stabilizeCommitTargets, stageCommitTargets, worktreeStatusPaths, } from "./
|
|
6
|
-
import { appendGitFailureLog, gitOutput, gitResult, listRegisteredWorktrees, summarizeGitHookFailure, } from "./
|
|
7
|
-
import { resolveRepoQualifiedRef } from "
|
|
8
|
-
import { PROJECT_REPO_NAME, branchExists, dirtyPaths, gitText, mergeInProgress, zeroSeparated, } from "./
|
|
9
|
-
export { PROJECT_REPO_NAME } from "./
|
|
3
|
+
import { acquireSchedulerLock, releaseSchedulerLock } from "./events.js";
|
|
4
|
+
import { productIntegrationTarget } from "./task-repos.js";
|
|
5
|
+
import { abortMerge, commitTargetPaths, isExecBranchMergedIntoCurrent, recordRootNewFilesHandoff, REGISTER_NEW_FILE_DIR_PREFIXES, repoRelative, stabilizeCommitTargets, stageCommitTargets, worktreeStatusPaths, } from "./worktree-ops.js";
|
|
6
|
+
import { appendGitFailureLog, appendGitResultFailureLog, formatGitResultFailure, gitOutput, gitResult, listRegisteredWorktrees, summarizeGitHookFailure, } from "./worktree.js";
|
|
7
|
+
import { resolveRepoQualifiedRef } from "../shared/specdojo-config.js";
|
|
8
|
+
import { PROJECT_REPO_NAME, branchExists, dirtyPaths, gitText, mergeInProgress, zeroSeparated, } from "./repo-integration-git.js";
|
|
9
|
+
export { PROJECT_REPO_NAME } from "./repo-integration-git.js";
|
|
10
10
|
// PJR-0WAA: 1 つのタスクがプロジェクトリポジトリと宣言済みのプロダクトリポジトリ(`repos`)を
|
|
11
11
|
// 変更する場合の統合段。commit 対象の算出と commit はリポジトリごとに行い、統合の前に全リポジトリ
|
|
12
12
|
// で merge 可否を確かめる。統合は宣言順にプロダクト、最後にプロジェクトの順で行い、リポジトリ別の
|
|
@@ -104,12 +104,15 @@ export function commitProductWorktree(product, params) {
|
|
|
104
104
|
return { repo: product.name, targets, outOfScope, committed: false, rootNewFiles: [] };
|
|
105
105
|
}
|
|
106
106
|
stageCommitTargets(product.path, targets);
|
|
107
|
-
const
|
|
107
|
+
const stagedArgs = ["diff", "--cached", "--quiet", "--", ...targets];
|
|
108
|
+
const staged = gitResult(product.path, stagedArgs);
|
|
108
109
|
if (staged.status === 0) {
|
|
109
110
|
return { repo: product.name, targets, outOfScope, committed: false, rootNewFiles: [] };
|
|
110
111
|
}
|
|
111
112
|
if (staged.status !== 1) {
|
|
112
|
-
|
|
113
|
+
appendGitResultFailureLog(params.failureLogPath, `${product.name}: git diff staged-change inspection`, staged);
|
|
114
|
+
throw new Error(`${product.name}: failed to inspect staged changes in ${product.path}: ` +
|
|
115
|
+
formatGitResultFailure(stagedArgs, staged));
|
|
113
116
|
}
|
|
114
117
|
const commit = gitResult(product.path, ["commit", "-m", params.message, "--", ...targets]);
|
|
115
118
|
if (commit.status !== 0) {
|
|
@@ -391,7 +394,7 @@ export function mergeProductIntoTarget(params) {
|
|
|
391
394
|
}
|
|
392
395
|
return commit;
|
|
393
396
|
}
|
|
394
|
-
export { syncTaskWorktreesWithIntegrationTargets, syncWorktreeWithIntegrationTarget, } from "./
|
|
397
|
+
export { syncTaskWorktreesWithIntegrationTargets, syncWorktreeWithIntegrationTarget, } from "./repo-integration-sync.js";
|
|
395
398
|
/** Integration failure that names the integrated and the remaining repositories. */
|
|
396
399
|
export class RepoIntegrationError extends Error {
|
|
397
400
|
repo;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { productMergeState } from "./
|
|
3
|
-
import { productIntegrationTarget } from "./
|
|
4
|
-
import { gitOutput, gitResult } from "./
|
|
2
|
+
import { productMergeState } from "./repo-integration.js";
|
|
3
|
+
import { productIntegrationTarget } from "./task-repos.js";
|
|
4
|
+
import { gitOutput, gitResult } from "./worktree.js";
|
|
5
5
|
// PJR-30SW: プロダクト側の commit と merge commit へ付ける `Refs:` trailer と、統合後に result へ
|
|
6
6
|
// 記録する trace 表。trace key は PJR-1SXK の決定どおり `<project-id>:<item-id>` とする。
|
|
7
7
|
/** Heading text of the trace section the runner appends to the result. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Ajv2020Module from "ajv/dist/2020.js";
|
|
2
|
-
import { extractJsonText } from "
|
|
3
|
-
import { REVIEW_VERDICTS, describeInvalidReviewVerdict, isReviewVerdict } from "
|
|
2
|
+
import { extractJsonText } from "../shared/agent-response.js";
|
|
3
|
+
import { REVIEW_VERDICTS, describeInvalidReviewVerdict, isReviewVerdict } from "../review/types.js";
|
|
4
4
|
export const MAX_TEXT_LENGTH = 4_000;
|
|
5
5
|
// review の verdict の正本は review-types.ts であり、verdict_definitions と同じ語彙を使う。
|
|
6
6
|
export { REVIEW_VERDICTS };
|