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,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readdirSync, rmdirSync } from "node:fs";
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
|
-
import { getProjectRepos, getProjectSchedulePath, loadConfig, PROJECT_REPO_WORKTREE_DIRNAME, resolveRepoRoot, specdojoRootDir, } from "
|
|
4
|
-
import { ensureExecWorktree, execBranchExists, execWorktreePath, findExecWorktree, generateWorktreeArtifacts, gitOutput, gitResult, installWorktreeDependencies, listRegisteredWorktrees, worktreeNameFromTaskId, } from "./
|
|
3
|
+
import { getProjectRepos, getProjectSchedulePath, loadConfig, PROJECT_REPO_WORKTREE_DIRNAME, resolveRepoRoot, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
4
|
+
import { ensureExecWorktree, execBranchExists, execWorktreePath, findExecWorktree, generateWorktreeArtifacts, gitOutput, gitResult, installWorktreeDependencies, listRegisteredWorktrees, worktreeNameFromTaskId, } from "./worktree.js";
|
|
5
5
|
// PJR-98G4: 1 つのタスクがプロジェクトリポジトリと宣言済みのプロダクトリポジトリ(`repos`)を
|
|
6
6
|
// 変更する場合の worktree を扱う。`repos` を持たない project では、ここの関数はどれも空の結果を
|
|
7
7
|
// 返し、既存の 1 リポジトリ・`<worktree_base>/<task-id>/` 直下の配置を変えない。
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { buildScheduleIndex } from "./
|
|
4
|
-
import { readReadySnapshot } from "./
|
|
5
|
-
import { buildPhaseModeIndex, resolveAgentAssignment, resolveAgentPipeline, resolveApproach, resolveTaskCapabilities, resolveTaskExecution, resolveTaskMode, resolveTaskProficiency, } from "./
|
|
6
|
-
import { extractLocalId, extractPhaseSuffix } from "
|
|
3
|
+
import { buildScheduleIndex } from "./schedule/schedule.js";
|
|
4
|
+
import { readReadySnapshot } from "./schedule/ready.js";
|
|
5
|
+
import { buildPhaseModeIndex, resolveAgentAssignment, resolveAgentPipeline, resolveApproach, resolveTaskCapabilities, resolveTaskExecution, resolveTaskMode, resolveTaskProficiency, } from "./strategy.js";
|
|
6
|
+
import { extractLocalId, extractPhaseSuffix } from "../schedule/phase-sets.js";
|
|
7
7
|
// Reconstruct a full ReadyTaskView for a task from the schedule (+ ready.json when
|
|
8
8
|
// present), filling mode/execution/approach/capabilities/proficiency/pipeline from strategy
|
|
9
9
|
// metadata. Works for any scheduled task regardless of its current state.
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { copyFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
-
import { defaultExecDefaultsPath, loadExecDefaultsConfig, resolveMemberCommand, resolveRateLimitDetection, } from "./
|
|
5
|
-
import { agentProtectedConfigViolation, isAgentProtectedConfigPath, } from "./
|
|
6
|
-
import { recordExecutorEvidence, recordParentValidationFailureOutput, } from "./
|
|
7
|
-
import { parentValidationLabels
|
|
8
|
-
import { activateResolvedProjectPaths, resolveProjectPaths } from "./
|
|
9
|
-
import { buildExecutorPrompt, isRateLimitError, loadRosterForExecutionPath, runConfiguredParentValidationBatch, } from "./
|
|
10
|
-
import { parsePlanTaskIdentity } from "./
|
|
11
|
-
import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "./
|
|
12
|
-
import { ensureDir, safeSlug } from "./
|
|
13
|
-
import { ensureExecWorktree, execBranchExists, findExecWorktree, gitOutput, gitResult, resolveWorktreeBase, } from "./
|
|
14
|
-
import { specdojoRootDir } from "
|
|
15
|
-
import { TRIAL_PROMPT_SUFFIX, buildComparisonRecord, buildTrialBaseValidation, classifyReporterFailure, comparisonDir, comparisonPath, configuredWorktreeBase, hasValidExecutorEnvelope, parsePositiveInteger, parseRating, readComparison, repoRelative, resolveMember, spawnAgent, updateObjectiveMetrics, worktreeEnvironment, writeComparison, } from "./
|
|
4
|
+
import { defaultExecDefaultsPath, loadExecDefaultsConfig, resolveMemberCommand, resolveRateLimitDetection, } from "./agent-config.js";
|
|
5
|
+
import { agentProtectedConfigViolation, isAgentProtectedConfigPath, } from "./agent-protected-config.js";
|
|
6
|
+
import { recordExecutorEvidence, recordParentValidationFailureOutput, } from "./evidence.js";
|
|
7
|
+
import { parentValidationLabels } from "./parent-validation.js";
|
|
8
|
+
import { activateResolvedProjectPaths, resolveProjectPaths } from "./project.js";
|
|
9
|
+
import { buildExecutorPrompt, isRateLimitError, loadRosterForExecutionPath, runConfiguredParentValidationBatch, } from "./run/run.js";
|
|
10
|
+
import { parsePlanTaskIdentity } from "./plans.js";
|
|
11
|
+
import { deriveReporterFacts, evidenceForReporter, runReporterWithFormatRetry, } from "./reporter.js";
|
|
12
|
+
import { ensureDir, safeSlug } from "./shared.js";
|
|
13
|
+
import { ensureExecWorktree, execBranchExists, findExecWorktree, formatGitResultFailure, gitOutput, gitResult, resolveWorktreeBase, } from "./worktree.js";
|
|
14
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
15
|
+
import { TRIAL_PROMPT_SUFFIX, buildComparisonRecord, buildTrialBaseValidation, classifyReporterFailure, comparisonDir, comparisonPath, configuredWorktreeBase, hasValidExecutorEnvelope, parsePositiveInteger, parseRating, readComparison, repoRelative, resolveMember, spawnAgent, updateObjectiveMetrics, worktreeEnvironment, writeComparison, } from "./trial-core.js";
|
|
16
16
|
async function runOneTrial(params) {
|
|
17
17
|
const { trial, worktree } = params;
|
|
18
18
|
const startedAt = new Date();
|
|
@@ -186,14 +186,11 @@ function resolveTrialDefinitions(opts) {
|
|
|
186
186
|
return { agents };
|
|
187
187
|
}
|
|
188
188
|
function resolveBaseCommit(repoRoot, revision) {
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
]);
|
|
195
|
-
if (result.status !== 0)
|
|
196
|
-
throw new Error(`Trial base is not a commit: ${revision}`);
|
|
189
|
+
const args = ["rev-parse", "--verify", "--end-of-options", `${revision}^{commit}`];
|
|
190
|
+
const result = gitResult(repoRoot, args);
|
|
191
|
+
if (result.status !== 0) {
|
|
192
|
+
throw new Error(`Trial base is not a commit: ${revision}; ${formatGitResultFailure(args, result)}`);
|
|
193
|
+
}
|
|
197
194
|
return String(result.stdout).trim();
|
|
198
195
|
}
|
|
199
196
|
async function runTrials(opts) {
|
|
@@ -408,7 +405,8 @@ function commitSelectedTrial(repoRoot, record, trial) {
|
|
|
408
405
|
if (protectedPaths.length > 0)
|
|
409
406
|
throw new Error(agentProtectedConfigViolation(protectedPaths));
|
|
410
407
|
gitOutput(trial.worktree, ["add", "-A"]);
|
|
411
|
-
const
|
|
408
|
+
const stagedArgs = ["diff", "--cached", "--quiet"];
|
|
409
|
+
const staged = gitResult(trial.worktree, stagedArgs);
|
|
412
410
|
if (staged.status === 1) {
|
|
413
411
|
const commit = gitResult(trial.worktree, [
|
|
414
412
|
"commit",
|
|
@@ -421,7 +419,7 @@ function commitSelectedTrial(repoRoot, record, trial) {
|
|
|
421
419
|
}
|
|
422
420
|
}
|
|
423
421
|
else if (staged.status !== 0) {
|
|
424
|
-
throw new Error(
|
|
422
|
+
throw new Error(`Failed to inspect selected trial changes: ${formatGitResultFailure(stagedArgs, staged)}`);
|
|
425
423
|
}
|
|
426
424
|
const ahead = Number(gitOutput(trial.worktree, ["rev-list", "--count", `${record.base_commit}..HEAD`]).trim());
|
|
427
425
|
if (!Number.isFinite(ahead) || ahead < 1)
|
|
@@ -2,11 +2,11 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import { existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
5
|
-
import { agentProtectedConfigViolation, captureAgentProtectedConfigSnapshot, changedAgentProtectedConfigPaths, } from "./
|
|
6
|
-
import { agentGitStateViolation, captureAgentGitStateSnapshot, changedAgentGitStateFields, } from "./
|
|
7
|
-
import { ensureDir, safeSlug } from "./
|
|
8
|
-
import { gitEnvironment, gitResult, worktreeNameFromTaskId } from "./
|
|
9
|
-
import { getProjectSchedulePath, loadConfig, specdojoRootDir, } from "
|
|
5
|
+
import { agentProtectedConfigViolation, captureAgentProtectedConfigSnapshot, changedAgentProtectedConfigPaths, } from "./agent-protected-config.js";
|
|
6
|
+
import { agentGitStateViolation, captureAgentGitStateSnapshot, changedAgentGitStateFields, } from "./agent-git-state.js";
|
|
7
|
+
import { ensureDir, safeSlug } from "./shared.js";
|
|
8
|
+
import { gitEnvironment, gitResult, worktreeNameFromTaskId } from "./worktree.js";
|
|
9
|
+
import { getProjectSchedulePath, loadConfig, resolveAgentMember, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
10
10
|
export const TRIAL_PROMPT_SUFFIX = `
|
|
11
11
|
|
|
12
12
|
---
|
|
@@ -168,7 +168,7 @@ export function parseRating(value, flag) {
|
|
|
168
168
|
return Number(value);
|
|
169
169
|
}
|
|
170
170
|
export function resolveMember(roster, nickname, stageRole) {
|
|
171
|
-
const member = roster
|
|
171
|
+
const member = resolveAgentMember(roster, nickname);
|
|
172
172
|
if (!member)
|
|
173
173
|
throw new Error(`Agent nickname not found in agent-members.yaml: ${nickname}`);
|
|
174
174
|
if (member.disabled)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { buildComparisonRecord, buildTrialBaseValidation, classifyReporterFailure, extractPlanRepoPaths, updateObjectiveMetrics, } from "./
|
|
2
|
-
export { registerExecTrialCommands } from "./
|
|
1
|
+
export { buildComparisonRecord, buildTrialBaseValidation, classifyReporterFailure, extractPlanRepoPaths, updateObjectiveMetrics, } from "./trial-core.js";
|
|
2
|
+
export { registerExecTrialCommands } from "./trial-commands.js";
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
|
-
import { acquireSchedulerLock, foldEventsToState, readAllEventFiles, releaseSchedulerLock, } from "./
|
|
5
|
-
import { hasMemberCommandSource, loadExecDefaultsConfig, resolveMemberCommand, } from "./
|
|
6
|
-
import { activateResolvedProjectPaths, resolveProjectPaths } from "./
|
|
7
|
-
import { agentGitStateViolation, captureAgentGitStateAcrossRepos, changedAgentGitStateAcrossRepos, qualifiedGitStateFields, } from "./
|
|
8
|
-
import { agentProtectedConfigViolation, captureAgentProtectedConfigAcrossRepos, changedAgentProtectedConfigAcrossRepos, qualifiedRepoPaths, } from "./
|
|
9
|
-
import { recordGitStateBlockAcrossRepos, recordProtectedConfigBlockAcrossRepos, } from "./
|
|
10
|
-
import { configuredProductRepos, missingProductWorktrees, plannedProjectWorktreePath, pruneOrphanedProductExecBranches, productRepoEnvironment, withAgentExtraRoots, withoutInheritedRepoEnvironment, withProductRepoPrompt, withProductWorktrees, } from "./
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
4
|
+
import { acquireSchedulerLock, foldEventsToState, readAllEventFiles, releaseSchedulerLock, } from "./events.js";
|
|
5
|
+
import { hasMemberCommandSource, loadExecDefaultsConfig, resolveMemberCommand, } from "./agent-config.js";
|
|
6
|
+
import { activateResolvedProjectPaths, resolveProjectPaths } from "./project.js";
|
|
7
|
+
import { agentGitStateViolation, captureAgentGitStateAcrossRepos, changedAgentGitStateAcrossRepos, qualifiedGitStateFields, } from "./agent-git-state.js";
|
|
8
|
+
import { agentProtectedConfigViolation, captureAgentProtectedConfigAcrossRepos, changedAgentProtectedConfigAcrossRepos, qualifiedRepoPaths, } from "./agent-protected-config.js";
|
|
9
|
+
import { recordGitStateBlockAcrossRepos, recordProtectedConfigBlockAcrossRepos, } from "./protection-handoff.js";
|
|
10
|
+
import { configuredProductRepos, missingProductWorktrees, plannedProjectWorktreePath, pruneOrphanedProductExecBranches, productRepoEnvironment, withAgentExtraRoots, withoutInheritedRepoEnvironment, withProductRepoPrompt, withProductWorktrees, } from "./task-repos.js";
|
|
11
|
+
import { resolveAgentMember } from "../shared/specdojo-config.js";
|
|
12
|
+
import { buildTaskPhaseMap, loadPrompt, loadRosterForExecutionPath, resolveTaskPhaseContext, selectCandidates, } from "./run/run.js";
|
|
13
|
+
import { buildScheduleIndex } from "./schedule/schedule.js";
|
|
14
|
+
import { buildInitialStateFromStrategy } from "./schedule/initial.js";
|
|
15
|
+
import { generateSinglePlan } from "./plans.js";
|
|
16
|
+
import { qualifyTaskId } from "./shared.js";
|
|
17
|
+
import { buildTaskView } from "./task-view.js";
|
|
18
|
+
import { findExecWorktree, gitEnvironment, gitOutput, gitResult, resolveWorktreeBase, worktreeNameFromTaskId, } from "./worktree.js";
|
|
19
|
+
import { checkpointAndEnsureWorktree, commitWorktreeChanges, mergeWorktreeIntoCurrent, pruneOrphanedExecBranches, removeWorktree, taskPaths, worktreeStatusPaths, } from "./worktree-ops.js";
|
|
20
|
+
import { getProjectSchedulePath, loadConfig, specdojoRootDir } from "../shared/specdojo-config.js";
|
|
21
|
+
export { isCommitTargetPath, stabilizeCommitTargets } from "./worktree-ops.js";
|
|
21
22
|
const DEFAULT_LOCK_TIMEOUT_MS = 10_000;
|
|
22
23
|
const DEFAULT_LOCK_STALE_MS = 300_000;
|
|
23
24
|
function commandError(error) {
|
|
@@ -97,11 +98,12 @@ function resolveAgent(context, taskId, opts) {
|
|
|
97
98
|
if ((task.execution ?? "agent") === "human" && !opts.by) {
|
|
98
99
|
throw new Error(`Task requires human execution. Use --by <nickname> to override: ${taskId}`);
|
|
99
100
|
}
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const resolvedMember = resolveAgentMember(roster, nickname);
|
|
102
|
+
const member = resolvedMember && hasMemberCommandSource(execDefaults, resolvedMember)
|
|
103
|
+
? resolvedMember
|
|
104
|
+
: undefined;
|
|
103
105
|
const command = member ? resolveMemberCommand(execDefaults, member) : undefined;
|
|
104
|
-
if (!command) {
|
|
106
|
+
if (!member || !command) {
|
|
105
107
|
throw new Error(`Agent command not found for actor: ${nickname}`);
|
|
106
108
|
}
|
|
107
109
|
if (!opts.by) {
|
|
@@ -110,14 +112,14 @@ function resolveAgent(context, taskId, opts) {
|
|
|
110
112
|
throw new Error(`Cannot resolve phase context for task: ${taskId}`);
|
|
111
113
|
}
|
|
112
114
|
const candidates = selectCandidates({ capabilities: task.capabilities ?? [], proficiency: task.proficiency }, roster, task.mode ?? "edit", undefined, execDefaults);
|
|
113
|
-
if (!candidates.some((candidate) => candidate.nickname === nickname)) {
|
|
115
|
+
if (!candidates.some((candidate) => candidate.nickname === member.nickname)) {
|
|
114
116
|
throw new Error(`Claim actor does not satisfy task agent requirements: ${nickname}`);
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
const prompt = loadPrompt(context.executionPath, taskId);
|
|
118
120
|
if (!prompt)
|
|
119
121
|
throw new Error(`Plan not found for task: ${taskId}`);
|
|
120
|
-
return { actor: nickname, command, provider: member
|
|
122
|
+
return { actor: member.nickname, command, provider: member.provider, prompt };
|
|
121
123
|
}
|
|
122
124
|
function printWorktree(worktree) {
|
|
123
125
|
process.stdout.write(`worktree: ${worktree.path}\nbranch: ${worktree.branch}\n`);
|
|
@@ -1,48 +1,24 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
|
-
import { appendFileSync, existsSync,
|
|
3
|
-
import { join,
|
|
4
|
-
import { load } from "
|
|
5
|
-
import { deliverableDocPath, parsePlanTaskIdentity, targetReferenceDirsForApproach, } from "./
|
|
6
|
-
import { parseResultTaskIdentity } from "./
|
|
7
|
-
import { stripTerminalControlSequences } from "./
|
|
8
|
-
import { agentProtectedConfigPaths, agentProtectedConfigViolation, qualifiedRepoPaths, } from "./
|
|
9
|
-
import { recordProtectedConfigBlockAcrossRepos } from "./
|
|
10
|
-
import { assertNoPendingProductChanges, productIntegrationTarget } from "./
|
|
11
|
-
import { specdojoPackageRootDir } from "
|
|
12
|
-
import {
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { load } from "../shared/yaml.js";
|
|
5
|
+
import { deliverableDocPath, parsePlanTaskIdentity, targetReferenceDirsForApproach, } from "./plans.js";
|
|
6
|
+
import { parseResultTaskIdentity } from "./results.js";
|
|
7
|
+
import { stripTerminalControlSequences } from "./shared.js";
|
|
8
|
+
import { agentProtectedConfigPaths, agentProtectedConfigViolation, qualifiedRepoPaths, } from "./agent-protected-config.js";
|
|
9
|
+
import { recordProtectedConfigBlockAcrossRepos } from "./protection-handoff.js";
|
|
10
|
+
import { assertNoPendingProductChanges, productIntegrationTarget } from "./task-repos.js";
|
|
11
|
+
import { specdojoPackageRootDir } from "../shared/package-paths.js";
|
|
12
|
+
import { repoRelative, stageCommitTargets, worktreeStatusPaths as statusPaths, } from "../shared/git.js";
|
|
13
|
+
export { repoRelative, selectStageablePaths, stageCommitTargets, worktreeStatusPaths, } from "../shared/git.js";
|
|
14
|
+
import { appendGitFailureLog, appendGitResultFailureLog, formatGitResultFailure, gitEnvironment, gitOutput, gitResult, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./worktree.js";
|
|
13
15
|
const MAX_COMMIT_STABILIZATION_ATTEMPTS = 3;
|
|
14
|
-
export function repoRelative(repoRoot, path) {
|
|
15
|
-
const value = relative(repoRoot, path);
|
|
16
|
-
if (!value || value === ".." || value.startsWith(`..${sep}`)) {
|
|
17
|
-
throw new Error(`Path is outside repository root: ${path}`);
|
|
18
|
-
}
|
|
19
|
-
return value.split(sep).join("/");
|
|
20
|
-
}
|
|
21
16
|
export function currentBranch(repoRoot) {
|
|
22
17
|
const branch = gitOutput(repoRoot, ["branch", "--show-current"]).trim();
|
|
23
18
|
if (!branch)
|
|
24
19
|
throw new Error("Detached HEAD is not supported for exec worktree commands.");
|
|
25
20
|
return branch;
|
|
26
21
|
}
|
|
27
|
-
function statusPaths(repoRoot) {
|
|
28
|
-
const output = gitOutput(repoRoot, ["status", "--porcelain=v1", "-z", "--untracked-files=all"]);
|
|
29
|
-
const records = output.split("\0").filter(Boolean);
|
|
30
|
-
const paths = [];
|
|
31
|
-
for (let index = 0; index < records.length; index++) {
|
|
32
|
-
const record = records[index];
|
|
33
|
-
if (record.length < 4)
|
|
34
|
-
continue;
|
|
35
|
-
const status = record.slice(0, 2);
|
|
36
|
-
paths.push(record.slice(3));
|
|
37
|
-
if ((status.includes("R") || status.includes("C")) && records[index + 1]) {
|
|
38
|
-
paths.push(records[++index]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return paths;
|
|
42
|
-
}
|
|
43
|
-
export function worktreeStatusPaths(repoRoot) {
|
|
44
|
-
return statusPaths(repoRoot);
|
|
45
|
-
}
|
|
46
22
|
export function taskPaths(context, taskId) {
|
|
47
23
|
const executionRel = repoRelative(context.repoRoot, context.executionPath);
|
|
48
24
|
return {
|
|
@@ -419,23 +395,6 @@ export function commitTargetPaths(context, worktree, taskId) {
|
|
|
419
395
|
// パスはそのどちらにも存在しないため、`-A` を付けても「pathspec did not match any files」で
|
|
420
396
|
// fatal になる。このようなパスは追加で stage する内容が無いので、add の対象から除外する。
|
|
421
397
|
// commit / commit --amend の pathspec は HEAD も照合するため、対象から外さずに削除を記録できる。
|
|
422
|
-
export function selectStageablePaths(repoRoot, paths) {
|
|
423
|
-
if (paths.length === 0)
|
|
424
|
-
return [];
|
|
425
|
-
const indexed = new Set(zeroSeparatedPaths(repoRoot, ["ls-files", "--full-name", "-z", "--", ...paths]));
|
|
426
|
-
// 作業ツリー側の存在確認は lstat で行う。git は symlink 自体を追跡するため、リンク先が
|
|
427
|
-
// 無い symlink も add の対象になる(existsSync はリンク先を辿るため false になる)。
|
|
428
|
-
const existsInWorktree = (path) => lstatSync(resolve(repoRoot, path), { throwIfNoEntry: false }) !== undefined;
|
|
429
|
-
return paths.filter((path) => indexed.has(path) || existsInWorktree(path));
|
|
430
|
-
}
|
|
431
|
-
// commit 対象を stage する。stage できる対象が無い場合(staged 済みの削除だけが残る場合)は
|
|
432
|
-
// git add を実行しない。commit 対象の限定は呼び出し側の paths が担うため、範囲は変わらない。
|
|
433
|
-
export function stageCommitTargets(repoRoot, paths) {
|
|
434
|
-
const stageable = selectStageablePaths(repoRoot, paths);
|
|
435
|
-
if (stageable.length === 0)
|
|
436
|
-
return;
|
|
437
|
-
gitOutput(repoRoot, ["add", "-A", "--", ...stageable]);
|
|
438
|
-
}
|
|
439
398
|
// runner が stage した対象だけを index から戻す。利用者や別処理が stage 済みの無関係な
|
|
440
399
|
// パスは保持し、commit / hook の失敗を後続の exec run へ持ち越さない。
|
|
441
400
|
export function unstageCommitTargets(repoRoot, paths) {
|
|
@@ -506,7 +465,8 @@ export function stabilizeCommitTargets(repoRoot, listRemainingPaths, maxAttempts
|
|
|
506
465
|
if (paths.length === 0)
|
|
507
466
|
return;
|
|
508
467
|
stageCommitTargets(repoRoot, paths);
|
|
509
|
-
const
|
|
468
|
+
const stagedArgs = ["diff", "--cached", "--quiet", "--", ...paths];
|
|
469
|
+
const staged = gitResult(repoRoot, stagedArgs);
|
|
510
470
|
if (staged.status === 0) {
|
|
511
471
|
// pathspec commit は hook が再stageした内容を commit した後、元の index を復元して
|
|
512
472
|
// HEAD と逆向きの差分を残す場合がある。この場合は add が index を HEAD へ揃えて
|
|
@@ -516,8 +476,10 @@ export function stabilizeCommitTargets(repoRoot, listRemainingPaths, maxAttempts
|
|
|
516
476
|
return;
|
|
517
477
|
throw new Error(`Failed to stage post-hook commit-target changes: ${remaining.join(", ")}`);
|
|
518
478
|
}
|
|
519
|
-
if (staged.status !== 1)
|
|
520
|
-
|
|
479
|
+
if (staged.status !== 1) {
|
|
480
|
+
appendGitResultFailureLog(failureLogPath, "git diff post-hook worktree inspection", staged);
|
|
481
|
+
throw new Error(`Failed to inspect post-hook worktree changes: ${formatGitResultFailure(stagedArgs, staged)}`);
|
|
482
|
+
}
|
|
521
483
|
const commitArgs = ["commit", "--amend", "--no-edit", "--", ...paths];
|
|
522
484
|
const commit = gitResult(repoRoot, commitArgs);
|
|
523
485
|
if (commit.status !== 0) {
|
|
@@ -672,13 +634,16 @@ export function commitWorktreeChanges(params) {
|
|
|
672
634
|
return { targets: paths, committed: false };
|
|
673
635
|
assertResultMarkdownlint(context, worktree, taskId);
|
|
674
636
|
stageCommitTargets(worktree.path, paths);
|
|
675
|
-
const
|
|
637
|
+
const stagedArgs = ["diff", "--cached", "--quiet", "--", ...paths];
|
|
638
|
+
const staged = gitResult(worktree.path, stagedArgs);
|
|
676
639
|
if (staged.status === 0) {
|
|
677
640
|
process.stdout.write("No staged commit-target changes.\n");
|
|
678
641
|
return { targets: paths, committed: false };
|
|
679
642
|
}
|
|
680
|
-
if (staged.status !== 1)
|
|
681
|
-
|
|
643
|
+
if (staged.status !== 1) {
|
|
644
|
+
appendGitResultFailureLog(params.failureLogPath, "git diff staged worktree inspection", staged);
|
|
645
|
+
throw new Error(`Failed to inspect staged worktree changes: ${formatGitResultFailure(stagedArgs, staged)}`);
|
|
646
|
+
}
|
|
682
647
|
const commitArgs = [
|
|
683
648
|
"commit",
|
|
684
649
|
"-m",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { copyFileSync, existsSync, lstatSync, mkdirSync, rmSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
-
import { stripTerminalControlSequences } from "./
|
|
4
|
-
import { discardStaleProductWorktrees, ensureProductWorktrees, projectRepoDirName, productWorktreeRemovalBlockers, removeEmptyTaskDirectory, removeProductWorktrees, } from "./
|
|
5
|
-
import { appendGitFailureLog, ensureExecWorktree, execBranchExists, findExecWorktree, generateWorktreeArtifacts, gitOutput, gitResult, listRegisteredWorktrees, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./
|
|
6
|
-
import { commitTargetPaths, currentBranch, repoRelative, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, zeroSeparatedPaths, } from "./
|
|
3
|
+
import { stripTerminalControlSequences } from "./shared.js";
|
|
4
|
+
import { discardStaleProductWorktrees, ensureProductWorktrees, projectRepoDirName, productWorktreeRemovalBlockers, removeEmptyTaskDirectory, removeProductWorktrees, } from "./task-repos.js";
|
|
5
|
+
import { appendGitFailureLog, appendGitResultFailureLog, ensureExecWorktree, execBranchExists, findExecWorktree, formatGitResultFailure, generateWorktreeArtifacts, gitOutput, gitResult, listRegisteredWorktrees, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./worktree.js";
|
|
6
|
+
import { commitTargetPaths, currentBranch, repoRelative, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, zeroSeparatedPaths, } from "./worktree-ops-commit.js";
|
|
7
7
|
// Remove a task worktree once its commit-target changes are committed and merged.
|
|
8
8
|
export function removeWorktree(params) {
|
|
9
9
|
const { context, worktree, taskId } = params;
|
|
@@ -167,6 +167,12 @@ function copyCheckpointPath(sourceRoot, targetRoot, relPath) {
|
|
|
167
167
|
mkdirSync(resolve(target, ".."), { recursive: true });
|
|
168
168
|
copyFileSync(source, target);
|
|
169
169
|
}
|
|
170
|
+
export function assertCheckpointInspection(args, result, failureLogPath) {
|
|
171
|
+
if (result.status === 0 || result.status === 1)
|
|
172
|
+
return;
|
|
173
|
+
appendGitResultFailureLog(failureLogPath, "git diff checkpoint inspection", result);
|
|
174
|
+
throw new Error(`Failed to inspect execution checkpoint changes: ${formatGitResultFailure(args, result)}`);
|
|
175
|
+
}
|
|
170
176
|
// Create the task worktree from the current integration HEAD, then commit the execution
|
|
171
177
|
// checkpoint (plan / result / claim or register-start bookkeeping) on the exec branch only. The
|
|
172
178
|
// root keeps its uncommitted copies so the task state stays visible there while the agent runs;
|
|
@@ -249,7 +255,9 @@ function checkpointAndEnsureProjectWorktree(params, repoDirName, ensureSiblingWo
|
|
|
249
255
|
for (const path of paths)
|
|
250
256
|
copyCheckpointPath(context.repoRoot, worktree.path, path);
|
|
251
257
|
stageCommitTargets(worktree.path, paths);
|
|
252
|
-
const
|
|
258
|
+
const checkpointArgs = ["diff", "--cached", "--quiet", "--", ...paths];
|
|
259
|
+
const checkpoint = gitResult(worktree.path, checkpointArgs);
|
|
260
|
+
assertCheckpointInspection(checkpointArgs, checkpoint, params.failureLogPath);
|
|
253
261
|
if (checkpoint.status === 1) {
|
|
254
262
|
const committed = gitResult(worktree.path, [
|
|
255
263
|
"commit",
|
|
@@ -283,9 +291,6 @@ function checkpointAndEnsureProjectWorktree(params, repoDirName, ensureSiblingWo
|
|
|
283
291
|
`(likely a failing git hook): ${summarizeGitHookFailure(output)}`);
|
|
284
292
|
}
|
|
285
293
|
}
|
|
286
|
-
else if (checkpoint.status !== 0) {
|
|
287
|
-
throw new Error("Failed to inspect execution checkpoint changes.");
|
|
288
|
-
}
|
|
289
294
|
return worktree;
|
|
290
295
|
}
|
|
291
296
|
return ensureProjectWorktree();
|
|
@@ -1,13 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { basename, dirname, resolve } from "node:path";
|
|
3
|
-
import { acquireSchedulerLock, releaseSchedulerLock } from "./
|
|
4
|
-
import { rebuildRegisterTicketFromEvents, unionRegisterEventLogs } from "
|
|
5
|
-
import { displayIdFromRegisterEventFilename, REGISTER_EVENTS_DIRNAME } from "
|
|
6
|
-
import { displayIdFromTicketFilename } from "
|
|
7
|
-
import { appendGitFailureLog, gitOutput, gitResult, summarizeGitHookFailure, } from "./
|
|
8
|
-
import { commitTargetPaths, currentBranch, repoRelative, rootDirtyPaths, zeroSeparatedPaths, } from "./
|
|
4
|
+
import { acquireSchedulerLock, releaseSchedulerLock } from "./events.js";
|
|
5
|
+
import { rebuildRegisterTicketFromEvents, unionRegisterEventLogs, } from "../register/event-merge.js";
|
|
6
|
+
import { displayIdFromRegisterEventFilename, REGISTER_EVENTS_DIRNAME } from "../register/events.js";
|
|
7
|
+
import { displayIdFromTicketFilename } from "../register/item.js";
|
|
8
|
+
import { appendGitFailureLog, gitOutput, gitResult, summarizeGitHookFailure, } from "./worktree.js";
|
|
9
|
+
import { commitTargetPaths, currentBranch, repoRelative, rootDirtyPaths, zeroSeparatedPaths, } from "./worktree-ops-commit.js";
|
|
9
10
|
const DEFAULT_LOCK_TIMEOUT_MS = 10_000;
|
|
10
11
|
const DEFAULT_LOCK_STALE_MS = 300_000;
|
|
12
|
+
// A successful `git merge` runs post-merge, but a merge completed by the bookkeeping-conflict
|
|
13
|
+
// resolver below uses `git commit --no-verify` and therefore skips that hook. Invoke the same
|
|
14
|
+
// repository-local entry point explicitly after either path. Only a SpecDojo development checkout
|
|
15
|
+
// whose local bin points at dist is eligible; repositories consuming SpecDojo from node_modules
|
|
16
|
+
// remain unaffected. The script and this launcher are both best-effort so a dist rebuild failure
|
|
17
|
+
// never turns a completed merge into an integration failure.
|
|
18
|
+
function usesLocalSpecdojoDistBin(repoRoot) {
|
|
19
|
+
try {
|
|
20
|
+
const packageJson = JSON.parse(readFileSync(resolve(repoRoot, "package.json"), "utf8"));
|
|
21
|
+
if (packageJson.name !== "specdojo" || typeof packageJson.bin !== "object")
|
|
22
|
+
return false;
|
|
23
|
+
return packageJson.bin?.specdojo === "dist/specdojo.js";
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function runBuildIfStaleAfterMerge(repoRoot) {
|
|
30
|
+
try {
|
|
31
|
+
const scriptPath = resolve(repoRoot, "tools", "build-if-stale.mjs");
|
|
32
|
+
if (!existsSync(scriptPath) || !usesLocalSpecdojoDistBin(repoRoot))
|
|
33
|
+
return;
|
|
34
|
+
const result = spawnSync(process.execPath, [scriptPath], {
|
|
35
|
+
cwd: repoRoot,
|
|
36
|
+
stdio: "inherit",
|
|
37
|
+
shell: false,
|
|
38
|
+
});
|
|
39
|
+
if (result.error) {
|
|
40
|
+
process.stderr.write(` [integrate] warning: build-if-stale could not start: ${result.error.message}\n`);
|
|
41
|
+
}
|
|
42
|
+
else if (result.status !== 0) {
|
|
43
|
+
process.stderr.write(` [integrate] warning: build-if-stale failed with exit code ${result.status ?? "unknown"}\n`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
process.stderr.write(` [integrate] warning: build-if-stale failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
11
50
|
// The checkpoint commit lives on the exec branch only, so the root keeps its own uncommitted copy
|
|
12
51
|
// of the bookkeeping files while the task runs (the schedule/register state must stay visible at
|
|
13
52
|
// root). Before the exec branch is merged those copies must yield to the committed versions,
|
|
@@ -261,6 +300,8 @@ export function mergeWorktreeIntoCurrent(params) {
|
|
|
261
300
|
}
|
|
262
301
|
}
|
|
263
302
|
finally {
|
|
303
|
+
if (merged)
|
|
304
|
+
runBuildIfStaleAfterMerge(context.repoRoot);
|
|
264
305
|
if (!merged && released.length > 0)
|
|
265
306
|
restoreRootWorkingCopies(context.repoRoot, released);
|
|
266
307
|
if (lockDir)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { REGISTER_NEW_FILE_DIR_PREFIXES, ROOT_NEW_FILES_HANDOFF_LABEL, applyRootNewFilesHandoff, assertResultMarkdownlint, commitTargetPaths, commitWorktreeChanges, currentBranch, deliverableStatus, isCommitTargetPath, normalizeResultWhitespace, partitionCommitTargets, recordRootNewFilesHandoff, repoRelative, resolveCommitScope, selectStageablePaths, stabilizeCommitTargets, stageCommitTargets, taskPaths, taskTargetsAtHead, unstageCommitTargets, worktreeStatusPaths, } from "./
|
|
2
|
-
export { abortMerge, isExecBranchMergedIntoCurrent, mergeWorktreeIntoCurrent, releaseRootWorkingCopies, restoreRootWorkingCopies, } from "./
|
|
3
|
-
export { WorktreeRemovedBranchDeletionError, checkpointAndEnsureWorktree, discardStaleExecWorktree, listOrphanedExecBranches, pruneOrphanedExecBranches, removeWorktree, } from "./
|
|
1
|
+
export { REGISTER_NEW_FILE_DIR_PREFIXES, ROOT_NEW_FILES_HANDOFF_LABEL, applyRootNewFilesHandoff, assertResultMarkdownlint, commitTargetPaths, commitWorktreeChanges, currentBranch, deliverableStatus, isCommitTargetPath, normalizeResultWhitespace, partitionCommitTargets, recordRootNewFilesHandoff, repoRelative, resolveCommitScope, selectStageablePaths, stabilizeCommitTargets, stageCommitTargets, taskPaths, taskTargetsAtHead, unstageCommitTargets, worktreeStatusPaths, } from "./worktree-ops-commit.js";
|
|
2
|
+
export { abortMerge, isExecBranchMergedIntoCurrent, mergeWorktreeIntoCurrent, releaseRootWorkingCopies, restoreRootWorkingCopies, } from "./worktree-ops-merge.js";
|
|
3
|
+
export { WorktreeRemovedBranchDeletionError, checkpointAndEnsureWorktree, discardStaleExecWorktree, listOrphanedExecBranches, pruneOrphanedExecBranches, removeWorktree, } from "./worktree-ops-lifecycle.js";
|