specdojo 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/agents/specdojo-orchestrator.md +2 -0
- package/CHANGELOG.md +100 -0
- package/README.md +2 -2
- package/dist/catalog/generate.js +144 -13
- package/dist/commands/agent.js +33 -0
- package/dist/commands/init.js +2 -0
- package/dist/commands/orchestrator.js +10 -1
- package/dist/deliverable/deliverable.js +77 -4
- package/dist/devcontainer/command.js +18 -0
- package/dist/devcontainer/host-script.js +21 -0
- package/dist/devcontainer/scaffold.js +4 -3
- package/dist/exec/antigravity-session.js +154 -0
- package/dist/exec/core.js +1 -0
- package/dist/exec/parent-validation.js +14 -0
- package/dist/exec/plan-markdownlint.js +89 -0
- package/dist/exec/plans-core.js +46 -1
- package/dist/exec/plans-generation.js +45 -5
- package/dist/exec/plans-planning.js +1 -1
- package/dist/exec/plans-storage.js +1 -0
- package/dist/exec/product-branch-records.js +105 -0
- package/dist/exec/product-branches.js +52 -0
- package/dist/exec/register-product-message.js +50 -0
- package/dist/exec/register-resume.js +28 -0
- package/dist/exec/register.js +6 -0
- package/dist/exec/repo-integration-sync.js +4 -2
- package/dist/exec/repo-integration.js +41 -4
- package/dist/exec/repo-trace.js +2 -0
- package/dist/exec/results.js +9 -5
- package/dist/exec/run/lifecycle-commands.js +85 -16
- package/dist/exec/run/register-command.js +22 -0
- package/dist/exec/run/register-resume.js +11 -1
- package/dist/exec/run/register-worktree.js +29 -8
- package/dist/exec/run/schedule-mode.js +22 -2
- package/dist/exec/run/schedule-prepare.js +49 -4
- package/dist/exec/run/schedule-task.js +3 -0
- package/dist/exec/strategy.js +2 -1
- package/dist/exec/task-repos.js +78 -16
- package/dist/exec/worktree-command.js +2 -2
- package/dist/exec/worktree-ops-commit.js +1 -13
- package/dist/exec/worktree-ops-lifecycle.js +40 -36
- package/dist/exec/worktree.js +3 -3
- package/dist/register/core.js +5 -0
- package/dist/register/create-commands.js +54 -2
- package/dist/register/deliverable-target.js +24 -17
- package/dist/register/event-merge.js +4 -0
- package/dist/register/events.js +6 -0
- package/dist/register/external-project.js +2 -0
- package/dist/register/input.js +168 -0
- package/dist/register/item.js +61 -0
- package/dist/register/register.js +33 -25
- package/dist/register/renumber.js +4 -0
- package/dist/register/update.js +6 -0
- package/dist/schedule/approach.js +9 -0
- package/dist/schedule/strategy-profiles.js +22 -2
- package/dist/shared/agent-types.js +4 -1
- package/dist/shared/branch-template.js +26 -0
- package/dist/shared/commit-message-template.js +38 -0
- package/dist/shared/commit-types.js +15 -0
- package/dist/shared/git.js +7 -0
- package/dist/shared/provider-scaffold.js +2 -0
- package/dist/shared/specdojo-config.js +35 -4
- package/dist/shared/specdojo-gitignore.js +1 -0
- package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +2 -0
- package/docs/ja/specdojo/exec-templates/xep-draft-template.md +93 -0
- package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +9 -2
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +2 -0
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +2 -0
- package/docs/ja/specdojo/exec-templates/xer-human-bootstrap-finalize-template.md +2 -0
- package/docs/ja/specdojo/exec-templates/xer-human-draft-template.md +23 -0
- package/docs/ja/specdojo/exec-templates/xer-human-finalize-template.md +2 -0
- package/docs/ja/specdojo/exec-templates/xrp-fully-guided-template.md +7 -4
- package/docs/ja/specdojo/guides/docs-editing-guide.md +36 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +16 -12
- package/docs/ja/specdojo/guides/exec-operation-guide.md +116 -10
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +4 -2
- package/docs/ja/specdojo/guides/quick-start-guide.md +597 -871
- package/docs/ja/specdojo/guides/register-operation-guide.md +16 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +31 -4
- package/docs/ja/specdojo/guides/ryu-guide.md +114 -23
- package/docs/ja/specdojo/guides/schedule-design-guide.md +31 -4
- package/docs/ja/specdojo/guides/schedule-operation-guide.md +14 -0
- package/docs/ja/specdojo/guides/use-case-guide.md +537 -77
- package/docs/ja/specdojo/recipes/cdfd-overview-recipe.md +88 -86
- package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +96 -122
- package/docs/ja/specdojo/recipes/exec-human-finalize-recipe.md +1 -0
- package/docs/ja/specdojo/recipes/tsd-recipe.md +20 -12
- package/docs/ja/specdojo/references/command-reference.md +111 -46
- package/docs/ja/specdojo/references/specdojo-config-reference.md +69 -8
- package/docs/ja/specdojo/rulebooks/cdfd-d2-rulebook.md +367 -0
- package/docs/ja/specdojo/rulebooks/cdfd-mermaid-rulebook.md +6 -5
- package/docs/ja/specdojo/rulebooks/cdfd-overview-rulebook.md +96 -100
- package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +38 -47
- package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +108 -103
- package/docs/ja/specdojo/rulebooks/dct-rulebook.md +8 -0
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +4 -0
- package/docs/ja/specdojo/rulebooks/sch-rulebook.md +3 -1
- package/docs/ja/specdojo/samples/cdfd-overview-sample.md +248 -140
- package/docs/ja/specdojo/samples/cdfd-uc-sample.md +128 -97
- package/docs/ja/specdojo/samples/dct-sample.yaml +5 -1
- package/docs/ja/specdojo/standards/document-metadata-standard.md +16 -0
- package/docs/ja/specdojo/standards/exec-human-finalize-standard.md +1 -0
- package/docs/ja/specdojo/standards/guide-authoring-standard.md +2 -1
- package/docs/ja/specdojo/standards/philosophy-authoring-standard.md +1 -0
- package/docs/ja/specdojo/standards/recipe-authoring-standard.md +2 -1
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -1
- package/docs/ja/specdojo/standards/standard-authoring-standard.md +2 -1
- package/docs/ja/specdojo/templates/cdfd-overview-template.md +161 -83
- package/docs/ja/specdojo/templates/cdfd-uc-template.md +127 -90
- package/docs/ja/specdojo/templates/pjr-change-request-template.md +10 -4
- package/docs/ja/specdojo/templates/pjr-issue-template.md +10 -4
- package/docs/ja/specdojo/templates/pjr-question-template.md +11 -5
- package/docs/ja/specdojo/templates/pjr-risk-template.md +10 -4
- package/docs/ja/specdojo/templates/pjr-todo-template.md +10 -4
- package/docs/specdojo/schemas/v1/dct.schema.yaml +9 -0
- package/docs/specdojo/schemas/v1/exec-common.schema.yaml +2 -1
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +35 -0
- package/docs/specdojo/schemas/v1/sch-strategy.schema.yaml +1 -0
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +41 -2
- package/package.json +6 -2
- package/templates/antigravity/README.md +19 -46
- package/templates/antigravity/exec-defaults-snippet.yaml +5 -6
- package/templates/antigravity/orchestrator.md +2 -0
- package/templates/antigravity/settings.edit.json +73 -0
- package/templates/antigravity/settings.orchestrator.json +15 -0
- package/templates/antigravity/settings.report.json +7 -0
- package/templates/antigravity/settings.review.json +7 -0
- package/templates/claude/agents/specdojo-orchestrator.md +2 -0
- package/templates/codex/agents/specdojo-orchestrator.toml +2 -0
- package/templates/codex/orchestrator.md +2 -0
- package/templates/devcontainer/remote-host/devcontainer-tmux.sh +217 -0
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +8 -90
- package/templates/devcontainer/remote-host/ssh-config.sample +3 -1
- package/templates/init-agent-members.yaml +1 -0
- package/templates/init-exec-defaults.yaml +1 -1
- package/templates/opencode/agents/specdojo-orchestrator.md +2 -0
|
@@ -3,15 +3,17 @@ import { gradeCheckpointPaths } from "../grade-checkpoint.js";
|
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { qualifyTaskId, randomHex } from "../shared.js";
|
|
6
|
-
import { resolveAgentMember } from "../../shared/specdojo-config.js";
|
|
6
|
+
import { loadConfig, resolveAgentMember, } from "../../shared/specdojo-config.js";
|
|
7
|
+
import { resolveProductBranches } from "../product-branches.js";
|
|
8
|
+
import { registerProductMessage } from "../register-product-message.js";
|
|
7
9
|
import { buildInPlaceStem } from "../plans.js";
|
|
8
10
|
import { generateRegisterPlan, requireRunnableRegisterItem, resolveRegisterRunTarget, sanitizeRegisterConclusion, ticketPathFromItem, } from "../register.js";
|
|
9
11
|
import { readResultFrontmatterSnapshot, scaffoldResult, updateResultStatus } from "../results.js";
|
|
10
|
-
import { findExecWorktree, gitOutput } from "../worktree.js";
|
|
11
|
-
import { configuredProductRepos, integrationBranchOverrideRecord, withProductRepoPrompt, } from "../task-repos.js";
|
|
12
|
+
import { findExecWorktree, gitOutput, } from "../worktree.js";
|
|
13
|
+
import { configuredProductRepos, integrationBranchOverrideRecord, reserveProductBranches, withProductRepoPrompt, } from "../task-repos.js";
|
|
12
14
|
import { checkpointAndEnsureWorktree, commitTargetPaths, commitWorktreeChanges, discardStaleExecWorktree, isExecBranchMergedIntoCurrent, mergeWorktreeIntoCurrent, removeWorktree, taskTargetsAtHead, WorktreeRemovedBranchDeletionError, worktreeStatusPaths, } from "../worktree-ops.js";
|
|
13
15
|
import { commitProductWorktrees, integrateTaskRepositories, projectMergeBlockers, PROJECT_REPO_NAME, RepoIntegrationError, } from "../repo-integration.js";
|
|
14
|
-
import { productIntegrationTrace, recordResultTrace,
|
|
16
|
+
import { productIntegrationTrace, recordResultTrace, registerProjectMergeMessage, traceKey, } from "../repo-trace.js";
|
|
15
17
|
import { pipelineStateLocation, readPipelineState } from "../pipeline-state.js";
|
|
16
18
|
import { findResumableRegisterRun } from "../register-resume.js";
|
|
17
19
|
import { isAuthoringApproach } from "../../kata/authoring.js";
|
|
@@ -199,7 +201,18 @@ export async function finalizeRegisterWorktreeRun(params) {
|
|
|
199
201
|
// PJR-30SW: プロダクト側の commit と merge commit、プロジェクト側の merge commit に
|
|
200
202
|
// `Refs: <project-id>:<item-id>` を付ける(PJR-1SXK)。
|
|
201
203
|
const itemTraceKey = traceKey(projectId, item.id);
|
|
202
|
-
const
|
|
204
|
+
const projectConfig = (worktree.repos?.length ?? 0) > 0
|
|
205
|
+
? loadConfig(repoRoot).config?.projects[projectId]
|
|
206
|
+
: undefined;
|
|
207
|
+
const productMessage = (product, kind) => registerProductMessage({
|
|
208
|
+
projectId,
|
|
209
|
+
item,
|
|
210
|
+
ticketPath,
|
|
211
|
+
projectConfig,
|
|
212
|
+
product,
|
|
213
|
+
kind,
|
|
214
|
+
repoConfig: projectConfig?.repos?.find((repo) => repo.name === product.name),
|
|
215
|
+
});
|
|
203
216
|
const integrateStartedAt = new Date().toISOString();
|
|
204
217
|
recordIntegrateStage(params.pipelineStatePath, integrateStartedAt, (current) => ({
|
|
205
218
|
status: "running",
|
|
@@ -213,7 +226,7 @@ export async function finalizeRegisterWorktreeRun(params) {
|
|
|
213
226
|
try {
|
|
214
227
|
const productOutcomes = commitProductWorktrees({
|
|
215
228
|
worktree,
|
|
216
|
-
message: productMessage,
|
|
229
|
+
message: (product) => productMessage(product, "commit"),
|
|
217
230
|
targets: taskTargetsAtHead(wtContext, worktree, stem),
|
|
218
231
|
scopeLogPath: integrateLogPath(params.pipelineStatePath),
|
|
219
232
|
failureLogPath: integrateLogPath(params.pipelineStatePath),
|
|
@@ -262,7 +275,7 @@ export async function finalizeRegisterWorktreeRun(params) {
|
|
|
262
275
|
integrateTaskRepositories({
|
|
263
276
|
worktree,
|
|
264
277
|
mergeMessage,
|
|
265
|
-
productMergeMessage: productMessage,
|
|
278
|
+
productMergeMessage: (product) => productMessage(product, "merge"),
|
|
266
279
|
checkProject: () => projectMergeBlockers({
|
|
267
280
|
context: wtContext,
|
|
268
281
|
worktree,
|
|
@@ -432,7 +445,14 @@ export async function runSingleRegisterItemWorktree(context, opts, pjrId, lifecy
|
|
|
432
445
|
: undefined;
|
|
433
446
|
// PJR-98G4: repos を宣言した project では、プロダクトの worktree も同じタスクの下に作る。
|
|
434
447
|
// PJR-XRAB: --integration-branch は設定の integration_branch より優先する。
|
|
435
|
-
const products = configuredProductRepos(schedulePath, opts.integrationBranch)
|
|
448
|
+
const products = resolveProductBranches(configuredProductRepos(schedulePath, opts.integrationBranch), {
|
|
449
|
+
projectId,
|
|
450
|
+
taskId: worktreeTaskId,
|
|
451
|
+
item,
|
|
452
|
+
ticketPath,
|
|
453
|
+
projectConfig: loadConfig().config?.projects[projectId],
|
|
454
|
+
overrides: opts.branch,
|
|
455
|
+
});
|
|
436
456
|
const integrationBranchOverrides = integrationBranchOverrideRecord(opts.integrationBranch);
|
|
437
457
|
// Phase 1: plan/result 生成 → register start → checkpoint → worktree 作成(root で直列化)。
|
|
438
458
|
const setup = async () => {
|
|
@@ -466,6 +486,7 @@ export async function runSingleRegisterItemWorktree(context, opts, pjrId, lifecy
|
|
|
466
486
|
const discarded = discardStaleExecWorktree({ context: wtContext, worktreeTaskId, products });
|
|
467
487
|
if (discarded)
|
|
468
488
|
process.stdout.write(` [run] discarded stale worktree/branch: ${discarded}\n`);
|
|
489
|
+
reserveProductBranches(products, worktreeTaskId);
|
|
469
490
|
const { planPath } = await generateRegisterPlan({
|
|
470
491
|
executionPath,
|
|
471
492
|
projectId,
|
|
@@ -5,6 +5,7 @@ import { activateResolvedProjectPaths, resolveProjectPaths } from "../project.js
|
|
|
5
5
|
import { readAllEventFiles, foldEventsToState } from "../events.js";
|
|
6
6
|
import { buildScheduleIndex, findStaleGeneratedTracks } from "../schedule/schedule.js";
|
|
7
7
|
import { buildInitialStateFromStrategy } from "../schedule/initial.js";
|
|
8
|
+
import { scheduleTrackNames } from "../schedule/gantt-chart-scope.js";
|
|
8
9
|
import { readReadySnapshot } from "../schedule/ready.js";
|
|
9
10
|
import { specdojoRootDir } from "../../shared/specdojo-config.js";
|
|
10
11
|
import { extractLocalId, extractPhaseSuffix } from "../../schedule/phase-sets.js";
|
|
@@ -52,6 +53,14 @@ export async function runBatchMode(opts) {
|
|
|
52
53
|
const repoRoot = specdojoRootDir();
|
|
53
54
|
const worktreeBase = resolveWorktreeBase(repoRoot, opts.worktreeBase, configuredWorktreeBase(schedulePath));
|
|
54
55
|
const parallel = parseParallel(opts.parallel);
|
|
56
|
+
// Validate against the schedule, including tracks with no Ready tasks, before any claim.
|
|
57
|
+
const track = opts.track;
|
|
58
|
+
if (track !== undefined) {
|
|
59
|
+
const tracks = scheduleTrackNames(buildScheduleIndex(schedulePath));
|
|
60
|
+
if (!tracks.includes(track)) {
|
|
61
|
+
throw new Error(`Unknown schedule track: ${track}. Available tracks: ${tracks.join(", ")}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
55
64
|
const execDefaults = loadExecDefaultsConfig(resolveExecDefaultsPath(opts, schedulePath), executionPath);
|
|
56
65
|
const roster = loadRosterForExecutionPath(executionPath);
|
|
57
66
|
const { localIdToPhaseSets, phaseSetSuffixToId } = buildTaskPhaseMap(schedulePath);
|
|
@@ -67,12 +76,23 @@ export async function runBatchMode(opts) {
|
|
|
67
76
|
return { preparedTasks: [], readyCount: 0 };
|
|
68
77
|
}
|
|
69
78
|
const readySnapshot = readReadySnapshot(readyJsonPath);
|
|
70
|
-
const
|
|
79
|
+
const strategyIds = strategy === "fifo"
|
|
71
80
|
? readySnapshot.strategies.fifo.ordered_task_ids
|
|
72
81
|
: readySnapshot.strategies["critical-first"].ordered_task_ids;
|
|
82
|
+
const taskMap = new Map(readySnapshot.tasks.map((t) => [t.id, t]));
|
|
83
|
+
// Filter every snapshot before preparation, so setup failures and loop refills cannot
|
|
84
|
+
// escape the requested track. Use schedule_file rather than parsing hyphenated task IDs.
|
|
85
|
+
const orderedIds = track === undefined
|
|
86
|
+
? strategyIds
|
|
87
|
+
: strategyIds.filter((id) => {
|
|
88
|
+
const task = taskMap.get(id);
|
|
89
|
+
if (!task)
|
|
90
|
+
return false;
|
|
91
|
+
const file = basename(task.schedule_file);
|
|
92
|
+
return file === `sch-track-${track}.yaml` || file === `sch-track-${track}.yml`;
|
|
93
|
+
});
|
|
73
94
|
if (orderedIds.length === 0)
|
|
74
95
|
return { preparedTasks: [], readyCount: 0 };
|
|
75
|
-
const taskMap = new Map(readySnapshot.tasks.map((t) => [t.id, t]));
|
|
76
96
|
const preparedTasks = [];
|
|
77
97
|
for (const taskId of orderedIds) {
|
|
78
98
|
if (preparedTasks.length >= limit)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import { join } from "node:path";
|
|
2
3
|
import { resolveMemberCommand } from "../agent-config.js";
|
|
3
4
|
import { canCompleteTask, readAllEventFiles, foldEventsToState } from "../events.js";
|
|
@@ -9,11 +10,11 @@ import { ensureReviewGrade } from "../../review/grade.js";
|
|
|
9
10
|
import { gradeCheckpointPaths } from "../grade-checkpoint.js";
|
|
10
11
|
import { isResultUnfilled, readResultFrontmatterSnapshot, scaffoldResult } from "../results.js";
|
|
11
12
|
import { worktreeNameFromTaskId } from "../worktree.js";
|
|
12
|
-
import { configuredProductRepos, plannedProjectWorktreePath } from "../task-repos.js";
|
|
13
|
+
import { configuredProductRepos, plannedProjectWorktreePath, preflightProductBranches, productBranchForTask, } from "../task-repos.js";
|
|
13
14
|
import { checkpointAndEnsureWorktree, discardStaleExecWorktree } from "../worktree-ops.js";
|
|
14
15
|
import { pipelineStateLocation } from "../pipeline-state.js";
|
|
15
16
|
import { collectBusyActors, pinnedExecutor, pinnedReporter, resolveAgentOverride, resolveExecDefaultsPath, resolvePinnedRateLimitRunOptions, resolveTaskPhaseContext, selectCandidates, } from "./shared.js";
|
|
16
|
-
import { buildExecutorPrompt, executorRequirements, loadPrompt, reportProductWorktrees, reporterRequirements, resolveReporterAgentCandidates, } from "./agent.js";
|
|
17
|
+
import { buildExecutorPrompt, executorRequirements, loadPrompt, pathInsideWorktree, reportProductWorktrees, reporterRequirements, resolveReporterAgentCandidates, } from "./agent.js";
|
|
17
18
|
import { integrateLogPath, spawnClaim, spawnRelease } from "./mode-shared.js";
|
|
18
19
|
export function findClaimEventPath(schedulePath, taskId) {
|
|
19
20
|
const claims = readAllEventFiles(schedulePath).filter((item) => item.event.task_id === taskId && item.event.type === "claim");
|
|
@@ -162,6 +163,46 @@ export async function prepareSingleTask(task, projectId, repoRoot, schedulePath,
|
|
|
162
163
|
const reporterRateLimitOptions = reporterPinned && reporterCandidates?.[0]
|
|
163
164
|
? resolvePinnedRateLimitRunOptions(rateLimitOverrides, execDefaults, roster, "reporter", reporterCandidates[0])
|
|
164
165
|
: undefined;
|
|
166
|
+
if (pipelineResume?.executorTarget) {
|
|
167
|
+
const { executorTarget, worktree } = pipelineResume;
|
|
168
|
+
if (!worktree)
|
|
169
|
+
throw new Error(`no exec worktree to resume executor for ${task.id}`);
|
|
170
|
+
const worktreeExecutionPath = pathInsideWorktree(repoRoot, worktree.path, executionPath);
|
|
171
|
+
const planPrompt = loadPrompt(worktreeExecutionPath, task.id);
|
|
172
|
+
const resultPath = join(executionPath, "exec", "results", `${task.id}-result.md`);
|
|
173
|
+
const worktreeResultPath = pathInsideWorktree(repoRoot, worktree.path, resultPath);
|
|
174
|
+
if (!planPrompt || !existsSync(resultPath) || !existsSync(worktreeResultPath)) {
|
|
175
|
+
throw new Error(`plan or result is missing for executor resume: ${task.id}`);
|
|
176
|
+
}
|
|
177
|
+
const claimEventPath = findClaimEventPath(schedulePath, task.id);
|
|
178
|
+
if (!claimEventPath)
|
|
179
|
+
throw new Error(`claim event is missing for executor resume: ${task.id}`);
|
|
180
|
+
reportProductWorktrees(worktree);
|
|
181
|
+
return {
|
|
182
|
+
task,
|
|
183
|
+
actor,
|
|
184
|
+
agentCandidates,
|
|
185
|
+
plan: planPrompt,
|
|
186
|
+
prompt: buildExecutorPrompt(planPrompt, execDefaults.pipeline?.parent_validations),
|
|
187
|
+
worktree,
|
|
188
|
+
resultPath,
|
|
189
|
+
resultScaffold: readResultFrontmatterSnapshot(resultPath),
|
|
190
|
+
checkpointPaths: [
|
|
191
|
+
join(executionPath, "exec", "plans", `${task.id}-plan.md`),
|
|
192
|
+
resultPath,
|
|
193
|
+
claimEventPath,
|
|
194
|
+
...gradeCheckpointPaths({ repoRoot, executionPath }),
|
|
195
|
+
],
|
|
196
|
+
pipelineRunId: executorTarget.runId,
|
|
197
|
+
pipelineResumeStage: "executor",
|
|
198
|
+
pipelineStateRef: executorTarget.stateRef,
|
|
199
|
+
initialChangeTargets: executorTarget.initialChanges,
|
|
200
|
+
resumeHandoff: executorTarget.handoff,
|
|
201
|
+
reporterCandidates,
|
|
202
|
+
executorRateLimitOptions,
|
|
203
|
+
reporterRateLimitOptions,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
165
206
|
const reviewGradeOutcome = await gradeBeforeReviewPlan({
|
|
166
207
|
task,
|
|
167
208
|
projectId,
|
|
@@ -196,7 +237,11 @@ export async function prepareSingleTask(task, projectId, repoRoot, schedulePath,
|
|
|
196
237
|
const worktreeTaskId = qualifyTaskId(projectId, task.id);
|
|
197
238
|
const worktreeName = worktreeNameFromTaskId(worktreeTaskId);
|
|
198
239
|
// PJR-98G4: repos を宣言した project では <base>/<task>/project/ と <base>/<task>/<repo>/ を作る。
|
|
199
|
-
const products = configuredProductRepos(schedulePath)
|
|
240
|
+
const products = configuredProductRepos(schedulePath).map((product) => ({
|
|
241
|
+
...product,
|
|
242
|
+
branch: productBranchForTask(product, worktreeTaskId, skipClaim),
|
|
243
|
+
}));
|
|
244
|
+
preflightProductBranches(products, worktreeTaskId);
|
|
200
245
|
if (dryRun) {
|
|
201
246
|
const worktree = {
|
|
202
247
|
path: plannedProjectWorktreePath(worktreeBase, worktreeTaskId, products),
|
|
@@ -207,7 +252,7 @@ export async function prepareSingleTask(task, projectId, repoRoot, schedulePath,
|
|
|
207
252
|
process.stdout.write(` [run] would setup: worktree ${worktree.path} (${worktree.branch})\n`);
|
|
208
253
|
for (const product of products) {
|
|
209
254
|
process.stdout.write(` [run] would setup: worktree ${join(worktreeBase, worktreeName, product.name)} ` +
|
|
210
|
-
`(${
|
|
255
|
+
`(${productBranchForTask(product, worktreeTaskId)} in ${product.repoRoot})\n`);
|
|
211
256
|
}
|
|
212
257
|
const claimMsg = skipClaim
|
|
213
258
|
? ` [dry-run] already claimed: ${task.id} as ${actor} (skip claim)`
|
|
@@ -140,6 +140,8 @@ export async function runPreparedTask(prepared, projectId, repoRoot, schedulePat
|
|
|
140
140
|
? buildExecutorPrompt(prepared.plan, execDefaults.pipeline?.parent_validations, {
|
|
141
141
|
resumed: true,
|
|
142
142
|
existingChanges: worktreeStatusPaths(prepared.worktree.path),
|
|
143
|
+
initialChangeTargets: prepared.initialChangeTargets,
|
|
144
|
+
resumeHandoff: prepared.resumeHandoff,
|
|
143
145
|
})
|
|
144
146
|
: prepared.prompt;
|
|
145
147
|
const executorOutcome = await runWithRetry(prepared.agentCandidates, withProductRepoPrompt(executorPrompt, prepared.worktree.repos), execDefaults, prepared.worktree.path, agentEnvironment(repoRoot, prepared.worktree.path, schedulePath, executionPath, prepared.worktree.repos), worktreeResultPath, prepared.executorRateLimitOptions);
|
|
@@ -178,6 +180,7 @@ export async function runPreparedTask(prepared, projectId, repoRoot, schedulePat
|
|
|
178
180
|
plan: prepared.plan,
|
|
179
181
|
evidence: executorEvidence,
|
|
180
182
|
evidencePath: executorEvidencePath,
|
|
183
|
+
initialChangeTargets: prepared.initialChangeTargets,
|
|
181
184
|
})
|
|
182
185
|
: undefined;
|
|
183
186
|
if (result === "success" && coverageFailure) {
|
package/dist/exec/strategy.js
CHANGED
|
@@ -4,7 +4,8 @@ function isTaskMode(value) {
|
|
|
4
4
|
return value === "edit" || value === "review";
|
|
5
5
|
}
|
|
6
6
|
function isApproach(value) {
|
|
7
|
-
return (value === "
|
|
7
|
+
return (value === "draft" ||
|
|
8
|
+
value === "fully-guided" ||
|
|
8
9
|
value === "recipe-guided" ||
|
|
9
10
|
value === "freeform" ||
|
|
10
11
|
value === "bootstrap" ||
|
package/dist/exec/task-repos.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { expandBranchTemplate } from "../shared/branch-template.js";
|
|
1
2
|
import { existsSync, readdirSync, rmdirSync } from "node:fs";
|
|
2
3
|
import { dirname, resolve } from "node:path";
|
|
3
4
|
import { getProjectRepos, getProjectSchedulePath, loadConfig, PROJECT_REPO_WORKTREE_DIRNAME, resolveRepoRoot, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
4
|
-
import { ensureExecWorktree,
|
|
5
|
+
import { ensureExecWorktree, execWorktreePath, findExecWorktree, generateWorktreeArtifacts, gitOutput, gitResult, installWorktreeDependencies, listRegisteredWorktrees, worktreeNameFromTaskId, } from "./worktree.js";
|
|
6
|
+
import { assertProductBranchAvailable, existingProductTaskBranch, forgetProductBranch, productBranchExists, productBranchRecords, recordedProductBranch, reserveProductBranch, } from "./product-branch-records.js";
|
|
5
7
|
// PJR-98G4: 1 つのタスクがプロジェクトリポジトリと宣言済みのプロダクトリポジトリ(`repos`)を
|
|
6
8
|
// 変更する場合の worktree を扱う。`repos` を持たない project では、ここの関数はどれも空の結果を
|
|
7
9
|
// 返し、既存の 1 リポジトリ・`<worktree_base>/<task-id>/` 直下の配置を変えない。
|
|
@@ -69,6 +71,7 @@ export function resolveProductRepos(rootDir, project, integrationBranches) {
|
|
|
69
71
|
name: repo.name,
|
|
70
72
|
repoRoot: resolveRepoRoot(rootDir, repo),
|
|
71
73
|
...(integrationBranch ? { integrationBranch } : {}),
|
|
74
|
+
...(repo.branch_template ? { branchTemplate: repo.branch_template } : {}),
|
|
72
75
|
...(repo.integration_strategy ? { integrationStrategy: repo.integration_strategy } : {}),
|
|
73
76
|
install: repo.setup?.install ?? true,
|
|
74
77
|
build: repo.setup?.build ?? true,
|
|
@@ -156,18 +159,35 @@ export function productIntegrationTarget(product) {
|
|
|
156
159
|
return product.integrationBranch ?? currentBranchOrNull(product.repoRoot) ?? "HEAD";
|
|
157
160
|
}
|
|
158
161
|
const skip = () => undefined;
|
|
162
|
+
export function preflightProductBranches(products, taskId) {
|
|
163
|
+
for (const product of products) {
|
|
164
|
+
if (!existsSync(product.repoRoot)) {
|
|
165
|
+
throw new Error(`Product repository "${product.name}" does not exist: ${product.repoRoot} (check repos[].path)`);
|
|
166
|
+
}
|
|
167
|
+
assertProductBranchAvailable(product.repoRoot, taskId, productBranchForTask(product, taskId));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** Reserve every name before recording register start or creating any product worktree. */
|
|
171
|
+
export function reserveProductBranches(products, taskId) {
|
|
172
|
+
preflightProductBranches(products, taskId);
|
|
173
|
+
for (const product of products) {
|
|
174
|
+
reserveProductBranch(product.repoRoot, taskId, productBranchForTask(product, taskId), productIntegrationTarget(product));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
159
177
|
/**
|
|
160
178
|
* Create (or reuse) `<worktree_base>/<task-name>/<repo>/` for every product repository. A new
|
|
161
179
|
* exec branch starts from the declared `integration_branch` (or the repository's current branch)
|
|
162
180
|
* because the checkpoint commit belongs to the project repository only.
|
|
163
181
|
*/
|
|
164
182
|
export function ensureProductWorktrees(opts) {
|
|
183
|
+
reserveProductBranches(opts.products, opts.taskId);
|
|
165
184
|
return opts.products.map((product) => {
|
|
166
185
|
if (!existsSync(product.repoRoot)) {
|
|
167
186
|
throw new Error(`Product repository "${product.name}" does not exist: ${product.repoRoot} (check repos[].path)`);
|
|
168
187
|
}
|
|
188
|
+
const branch = productBranchForTask(product, opts.taskId);
|
|
169
189
|
const generate = product.build ? (opts.generateArtifacts ?? generateWorktreeArtifacts) : skip;
|
|
170
|
-
const existing = findExecWorktree(product.repoRoot, opts.taskId);
|
|
190
|
+
const existing = findExecWorktree(product.repoRoot, opts.taskId, branch);
|
|
171
191
|
if (existing) {
|
|
172
192
|
// Same as the project worktree on reuse: dependencies stay, generated files are rebuilt.
|
|
173
193
|
generate(existing.path);
|
|
@@ -178,6 +198,7 @@ export function ensureProductWorktrees(opts) {
|
|
|
178
198
|
worktreeBase: opts.worktreeBase,
|
|
179
199
|
taskId: opts.taskId,
|
|
180
200
|
repoDirName: product.name,
|
|
201
|
+
branch,
|
|
181
202
|
startPoint: productIntegrationTarget(product),
|
|
182
203
|
installDependencies: product.install
|
|
183
204
|
? (opts.installDependencies ?? installWorktreeDependencies)
|
|
@@ -198,12 +219,33 @@ function toProductWorktree(product, worktree) {
|
|
|
198
219
|
...(product.integrationStrategy ? { integrationStrategy: product.integrationStrategy } : {}),
|
|
199
220
|
};
|
|
200
221
|
}
|
|
222
|
+
/** Recorded names survive template/topic changes and do not depend on a branch prefix. */
|
|
223
|
+
export function productBranchForTask(product, taskId, reuseRecorded = true) {
|
|
224
|
+
const separator = taskId.indexOf(":");
|
|
225
|
+
const project = separator >= 0 ? taskId.slice(0, separator) : "";
|
|
226
|
+
const id = separator >= 0 ? taskId.slice(separator + 1) : taskId;
|
|
227
|
+
return (product.branch ??
|
|
228
|
+
(reuseRecorded ? recordedProductBranch(product.repoRoot, taskId) : undefined) ??
|
|
229
|
+
(product.branchTemplate
|
|
230
|
+
? expandBranchTemplate(product.branchTemplate, {
|
|
231
|
+
project,
|
|
232
|
+
id,
|
|
233
|
+
topic: id.toLowerCase(),
|
|
234
|
+
type: "feat",
|
|
235
|
+
scope: "",
|
|
236
|
+
title: id,
|
|
237
|
+
})
|
|
238
|
+
: `exec/${worktreeNameFromTaskId(taskId)}`));
|
|
239
|
+
}
|
|
201
240
|
/** Registered product worktrees of a task (repositories without one are omitted). */
|
|
202
241
|
export function findProductWorktrees(products, taskId) {
|
|
203
242
|
return products.flatMap((product) => {
|
|
204
243
|
if (!existsSync(product.repoRoot))
|
|
205
244
|
return [];
|
|
206
|
-
const
|
|
245
|
+
const branch = existingProductTaskBranch(product.repoRoot, taskId);
|
|
246
|
+
if (!branch)
|
|
247
|
+
return [];
|
|
248
|
+
const found = findExecWorktree(product.repoRoot, taskId, branch);
|
|
207
249
|
return found ? [toProductWorktree(product, found)] : [];
|
|
208
250
|
});
|
|
209
251
|
}
|
|
@@ -315,6 +357,7 @@ export function removeProductWorktrees(params) {
|
|
|
315
357
|
// keep Git's safe `-d` so unintegrated product work is never deleted.
|
|
316
358
|
const flag = isMergedIntoTarget(product) ? "-D" : "-d";
|
|
317
359
|
gitOutput(product.repoRoot, ["branch", flag, product.branch]);
|
|
360
|
+
forgetProductBranch(product.repoRoot, product.branch);
|
|
318
361
|
}
|
|
319
362
|
}
|
|
320
363
|
}
|
|
@@ -339,12 +382,14 @@ export function removeEmptyTaskDirectory(worktree) {
|
|
|
339
382
|
*/
|
|
340
383
|
export function discardStaleProductWorktrees(products, taskId) {
|
|
341
384
|
// A retained branch is product-side review work, not abandoned scheduler residue.
|
|
342
|
-
// Check every product before removing anything, including a previous task's project worktree.
|
|
343
385
|
for (const product of products) {
|
|
386
|
+
if (!existsSync(product.repoRoot))
|
|
387
|
+
continue;
|
|
388
|
+
const branch = existingProductTaskBranch(product.repoRoot, taskId);
|
|
344
389
|
if (product.integrationStrategy === "branch-only" &&
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
throw new Error(`${product.name}: retained exec branch
|
|
390
|
+
branch &&
|
|
391
|
+
productBranchExists(product.repoRoot, branch)) {
|
|
392
|
+
throw new Error(`${product.name}: retained exec branch ${branch} already exists; ` +
|
|
348
393
|
`resume the existing run or finish product-side review and rename/remove the branch before a fresh run`);
|
|
349
394
|
}
|
|
350
395
|
}
|
|
@@ -352,19 +397,20 @@ export function discardStaleProductWorktrees(products, taskId) {
|
|
|
352
397
|
for (const product of products) {
|
|
353
398
|
if (!existsSync(product.repoRoot))
|
|
354
399
|
continue;
|
|
355
|
-
const
|
|
356
|
-
if (!
|
|
400
|
+
const branch = existingProductTaskBranch(product.repoRoot, taskId);
|
|
401
|
+
if (!branch)
|
|
357
402
|
continue;
|
|
403
|
+
const existing = findExecWorktree(product.repoRoot, taskId, branch);
|
|
358
404
|
if (existing) {
|
|
359
405
|
if (resolve(product.repoRoot) === resolve(existing.path)) {
|
|
360
|
-
throw new Error(`Refusing to discard the main checkout of ${product.name} as stale residue: ${
|
|
406
|
+
throw new Error(`Refusing to discard the main checkout of ${product.name} as stale residue: ${branch}`);
|
|
361
407
|
}
|
|
362
408
|
gitOutput(product.repoRoot, ["worktree", "remove", "--force", existing.path]);
|
|
363
409
|
}
|
|
364
|
-
|
|
365
|
-
if (execBranchExists(product.repoRoot, taskId)) {
|
|
410
|
+
if (productBranchExists(product.repoRoot, branch)) {
|
|
366
411
|
gitOutput(product.repoRoot, ["branch", "-D", branch]);
|
|
367
412
|
}
|
|
413
|
+
forgetProductBranch(product.repoRoot, branch);
|
|
368
414
|
discarded.push(`${product.name}:${branch}`);
|
|
369
415
|
}
|
|
370
416
|
return discarded;
|
|
@@ -379,14 +425,25 @@ export function listOrphanedProductExecBranches(products, projectId) {
|
|
|
379
425
|
.map((worktree) => worktree.branch)
|
|
380
426
|
.filter((branch) => !!branch));
|
|
381
427
|
const target = productIntegrationTarget(product);
|
|
382
|
-
|
|
428
|
+
const legacyBranches = gitOutput(product.repoRoot, [
|
|
383
429
|
"for-each-ref",
|
|
384
430
|
"--format=%(refname:short)",
|
|
385
431
|
"refs/heads/exec/",
|
|
386
432
|
])
|
|
387
433
|
.split(/\r?\n/)
|
|
388
434
|
.map((branch) => branch.trim())
|
|
389
|
-
.filter((branch) => branch.startsWith(prefix)
|
|
435
|
+
.filter((branch) => branch.startsWith(prefix));
|
|
436
|
+
const records = productBranchRecords(product.repoRoot);
|
|
437
|
+
const owned = records
|
|
438
|
+
.filter((record) => record.taskId.startsWith(`${projectId}:`))
|
|
439
|
+
.map((record) => record.branch);
|
|
440
|
+
return [
|
|
441
|
+
...new Set([
|
|
442
|
+
...owned,
|
|
443
|
+
...legacyBranches.filter((branch) => !records.some((record) => record.branch === branch)),
|
|
444
|
+
]),
|
|
445
|
+
]
|
|
446
|
+
.filter((branch) => !checkedOut.has(branch) && productBranchExists(product.repoRoot, branch))
|
|
390
447
|
.sort()
|
|
391
448
|
.map((branch) => ({
|
|
392
449
|
repo: product.name,
|
|
@@ -395,7 +452,7 @@ export function listOrphanedProductExecBranches(products, projectId) {
|
|
|
395
452
|
}));
|
|
396
453
|
});
|
|
397
454
|
}
|
|
398
|
-
/** Delete
|
|
455
|
+
/** Delete only orphan branches verified as merged into the product's integration target. */
|
|
399
456
|
export function pruneOrphanedProductExecBranches(params) {
|
|
400
457
|
const orphaned = listOrphanedProductExecBranches(params.products, params.projectId);
|
|
401
458
|
for (const item of orphaned) {
|
|
@@ -405,7 +462,12 @@ export function pruneOrphanedProductExecBranches(params) {
|
|
|
405
462
|
if (!product)
|
|
406
463
|
continue;
|
|
407
464
|
try {
|
|
408
|
-
|
|
465
|
+
// The main checkout's HEAD need not be the integration target. Recheck that target
|
|
466
|
+
// before using -D, just as removeProductWorktrees does for a non-orphan branch.
|
|
467
|
+
if (!isMergedIntoTarget({ ...product, branch: item.branch }))
|
|
468
|
+
continue;
|
|
469
|
+
gitOutput(product.repoRoot, ["branch", "-D", item.branch]);
|
|
470
|
+
forgetProductBranch(product.repoRoot, item.branch);
|
|
409
471
|
}
|
|
410
472
|
catch (error) {
|
|
411
473
|
throw new Error(`Failed to delete merged orphaned exec branch ${item.repo}:${item.branch}; ` +
|
|
@@ -8,7 +8,7 @@ import { activateResolvedProjectPaths, resolveProjectPaths } from "./project.js"
|
|
|
8
8
|
import { agentGitStateViolation, captureAgentGitStateAcrossRepos, changedAgentGitStateAcrossRepos, qualifiedGitStateFields, } from "./agent-git-state.js";
|
|
9
9
|
import { agentProtectedConfigViolation, captureAgentProtectedConfigAcrossRepos, changedAgentProtectedConfigAcrossRepos, qualifiedRepoPaths, } from "./agent-protected-config.js";
|
|
10
10
|
import { recordGitStateBlockAcrossRepos, recordProtectedConfigBlockAcrossRepos, } from "./protection-handoff.js";
|
|
11
|
-
import { configuredProductRepos, missingProductWorktrees, plannedProjectWorktreePath, pruneOrphanedProductExecBranches, productRepoEnvironment, withAgentExtraRoots, withoutInheritedRepoEnvironment, withProductRepoPrompt, withProductWorktrees, } from "./task-repos.js";
|
|
11
|
+
import { configuredProductRepos, missingProductWorktrees, plannedProjectWorktreePath, productBranchForTask, pruneOrphanedProductExecBranches, productRepoEnvironment, withAgentExtraRoots, withoutInheritedRepoEnvironment, withProductRepoPrompt, withProductWorktrees, } from "./task-repos.js";
|
|
12
12
|
import { resolveAgentMember } from "../shared/specdojo-config.js";
|
|
13
13
|
import { buildTaskPhaseMap, loadPrompt, loadRosterForExecutionPath, resolveTaskPhaseContext, selectCandidates, } from "./run/run.js";
|
|
14
14
|
import { buildScheduleIndex } from "./schedule/schedule.js";
|
|
@@ -147,7 +147,7 @@ async function prepare(opts) {
|
|
|
147
147
|
name: product.name,
|
|
148
148
|
repoRoot: product.repoRoot,
|
|
149
149
|
path: resolve(base, name, product.name),
|
|
150
|
-
branch,
|
|
150
|
+
branch: productBranchForTask(product, worktreeTaskId),
|
|
151
151
|
created: false,
|
|
152
152
|
})),
|
|
153
153
|
}
|
|
@@ -11,7 +11,7 @@ import { assertNoPendingProductChanges, productIntegrationTarget } from "./task-
|
|
|
11
11
|
import { specdojoPackageRootDir } from "../shared/package-paths.js";
|
|
12
12
|
import { DEFAULT_MARKDOWNLINT_CONFIG, hasMarkdownlintConfig, } from "../shared/markdownlint-config.js";
|
|
13
13
|
import { repoRelative, stageCommitTargets, worktreeStatusPaths as statusPaths, } from "../shared/git.js";
|
|
14
|
-
export { repoRelative, selectStageablePaths, stageCommitTargets, worktreeStatusPaths, } from "../shared/git.js";
|
|
14
|
+
export { repoRelative, selectStageablePaths, stageCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "../shared/git.js";
|
|
15
15
|
import { appendGitFailureLog, appendGitResultFailureLog, formatGitResultFailure, gitEnvironment, gitOutput, gitResult, summarizeGitHookFailure, worktreeNameFromTaskId, } from "./worktree.js";
|
|
16
16
|
const MAX_COMMIT_STABILIZATION_ATTEMPTS = 3;
|
|
17
17
|
export function currentBranch(repoRoot) {
|
|
@@ -392,18 +392,6 @@ export function partitionCommitTargets(context, worktree, taskId) {
|
|
|
392
392
|
export function commitTargetPaths(context, worktree, taskId) {
|
|
393
393
|
return partitionCommitTargets(context, worktree, taskId).targets;
|
|
394
394
|
}
|
|
395
|
-
// `git add` の pathspec は作業ツリーと index だけを照合する。削除が既に index へ入っている
|
|
396
|
-
// パスはそのどちらにも存在しないため、`-A` を付けても「pathspec did not match any files」で
|
|
397
|
-
// fatal になる。このようなパスは追加で stage する内容が無いので、add の対象から除外する。
|
|
398
|
-
// commit / commit --amend の pathspec は HEAD も照合するため、対象から外さずに削除を記録できる。
|
|
399
|
-
// runner が stage した対象だけを index から戻す。利用者や別処理が stage 済みの無関係な
|
|
400
|
-
// パスは保持し、commit / hook の失敗を後続の exec run へ持ち越さない。
|
|
401
|
-
export function unstageCommitTargets(repoRoot, paths) {
|
|
402
|
-
const unique = [...new Set(paths)];
|
|
403
|
-
if (unique.length === 0)
|
|
404
|
-
return;
|
|
405
|
-
gitOutput(repoRoot, ["reset", "--quiet", "--", ...unique]);
|
|
406
|
-
}
|
|
407
395
|
// markdownlint-cli の終了コード。1 だけが記法違反を表し、それ以外は実行環境の問題である。
|
|
408
396
|
const MARKDOWNLINT_EXIT_LINT_ERRORS = 1;
|
|
409
397
|
// worktree または SpecDojo package の node_modules から markdownlint-cli を探す。
|
|
@@ -254,45 +254,49 @@ function checkpointAndEnsureProjectWorktree(params, repoDirName, ensureSiblingWo
|
|
|
254
254
|
const worktree = ensureProjectWorktree();
|
|
255
255
|
for (const path of paths)
|
|
256
256
|
copyCheckpointPath(context.repoRoot, worktree.path, path);
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if (committed.status !== 0) {
|
|
270
|
-
// A failing git hook (pre-commit / commit-msg) aborts the commit but leaves the staged
|
|
271
|
-
// paths in the index. Unstage only this checkpoint so a hook or caller's unrelated staged
|
|
272
|
-
// paths remain intact.
|
|
273
|
-
unstageCommitTargets(worktree.path, paths);
|
|
274
|
-
// hook(lefthook 等)の生出力には ANSI エスケープや制御文字が含まれうる。この detail は
|
|
275
|
-
// register 経路で pjr-index の結論列・result の理由欄へ伝播するため、ここで除去して
|
|
276
|
-
// 表示崩れを防ぐ(register 側の sanitize と二重だが、非 register の呼び出し元も守る)。
|
|
277
|
-
const output = [committed.stdout, committed.stderr]
|
|
278
|
-
.map((part) => typeof part === "string" ? stripTerminalControlSequences(part).trim() : "")
|
|
279
|
-
.filter(Boolean)
|
|
280
|
-
.join("\n");
|
|
281
|
-
appendGitFailureLog(params.failureLogPath, [
|
|
282
|
-
`=== ${new Date().toISOString()} git commit checkpoint ===`,
|
|
283
|
-
`exit: ${committed.status ?? "unknown"}`,
|
|
284
|
-
"--- stdout ---",
|
|
285
|
-
typeof committed.stdout === "string" ? committed.stdout : "",
|
|
286
|
-
"--- stderr ---",
|
|
287
|
-
typeof committed.stderr === "string" ? committed.stderr : "",
|
|
288
|
-
"",
|
|
257
|
+
try {
|
|
258
|
+
stageCommitTargets(worktree.path, paths);
|
|
259
|
+
const checkpointArgs = ["diff", "--cached", "--quiet", "--", ...paths];
|
|
260
|
+
const checkpoint = gitResult(worktree.path, checkpointArgs);
|
|
261
|
+
assertCheckpointInspection(checkpointArgs, checkpoint, params.failureLogPath);
|
|
262
|
+
if (checkpoint.status === 1) {
|
|
263
|
+
const committed = gitResult(worktree.path, [
|
|
264
|
+
"commit",
|
|
265
|
+
"-m",
|
|
266
|
+
params.commitMessage,
|
|
267
|
+
"--",
|
|
268
|
+
...paths,
|
|
289
269
|
]);
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
270
|
+
if (committed.status !== 0) {
|
|
271
|
+
// hook(lefthook 等)の生出力には ANSI エスケープや制御文字が含まれうる。この detail は
|
|
272
|
+
// register 経路で pjr-index の結論列・result の理由欄へ伝播するため、ここで除去して
|
|
273
|
+
// 表示崩れを防ぐ(register 側の sanitize と二重だが、非 register の呼び出し元も守る)。
|
|
274
|
+
const output = [committed.stdout, committed.stderr]
|
|
275
|
+
.map((part) => typeof part === "string" ? stripTerminalControlSequences(part).trim() : "")
|
|
276
|
+
.filter(Boolean)
|
|
277
|
+
.join("\n");
|
|
278
|
+
appendGitFailureLog(params.failureLogPath, [
|
|
279
|
+
`=== ${new Date().toISOString()} git commit checkpoint ===`,
|
|
280
|
+
`exit: ${committed.status ?? "unknown"}`,
|
|
281
|
+
"--- stdout ---",
|
|
282
|
+
typeof committed.stdout === "string" ? committed.stdout : "",
|
|
283
|
+
"--- stderr ---",
|
|
284
|
+
typeof committed.stderr === "string" ? committed.stderr : "",
|
|
285
|
+
"",
|
|
286
|
+
]);
|
|
287
|
+
throw new Error(
|
|
288
|
+
// register の短い block_reason にも step とエラーが残るよう、補足より先に要約を置く。
|
|
289
|
+
`Checkpoint commit failed: ${summarizeGitHookFailure(output)} ` +
|
|
290
|
+
`(${params.commitMessage}; staged changes rolled back; likely a failing git hook)`);
|
|
291
|
+
}
|
|
294
292
|
}
|
|
295
293
|
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
// stage 後の検査や hook が失敗しても、この checkpoint の対象だけを戻す。
|
|
296
|
+
// root の index と、hook が別途 stage した無関係なパスには触れない。
|
|
297
|
+
unstageCommitTargets(worktree.path, paths);
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
296
300
|
return worktree;
|
|
297
301
|
}
|
|
298
302
|
return ensureProjectWorktree();
|
package/dist/exec/worktree.js
CHANGED
|
@@ -43,9 +43,9 @@ export function listRegisteredWorktrees(repoRoot) {
|
|
|
43
43
|
pushCurrent();
|
|
44
44
|
return result;
|
|
45
45
|
}
|
|
46
|
-
export function findExecWorktree(repoRoot, taskId) {
|
|
46
|
+
export function findExecWorktree(repoRoot, taskId, branchOverride) {
|
|
47
47
|
const name = worktreeNameFromTaskId(taskId);
|
|
48
|
-
const branch = `exec/${name}`;
|
|
48
|
+
const branch = branchOverride ?? `exec/${name}`;
|
|
49
49
|
const registered = listRegisteredWorktrees(repoRoot).find((item) => item.branch === branch);
|
|
50
50
|
if (!registered)
|
|
51
51
|
return null;
|
|
@@ -251,7 +251,7 @@ export function ensureExecWorktree(opts) {
|
|
|
251
251
|
throw new Error(`Worktree base must be outside the repository: ${opts.worktreeBase}`);
|
|
252
252
|
}
|
|
253
253
|
const name = worktreeNameFromTaskId(opts.taskId);
|
|
254
|
-
const branch = `exec/${name}`;
|
|
254
|
+
const branch = opts.branch ?? `exec/${name}`;
|
|
255
255
|
const worktreePath = execWorktreePath(opts.worktreeBase, opts.taskId, opts.repoDirName);
|
|
256
256
|
const registered = listRegisteredWorktrees(repoRoot);
|
|
257
257
|
const registeredAtPath = registered.find((item) => item.path === worktreePath);
|
package/dist/register/core.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setRegisterInput } from "./input.js";
|
|
1
2
|
import { randomInt, randomUUID } from "node:crypto";
|
|
2
3
|
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
3
4
|
import { basename, dirname, join, resolve } from "node:path";
|
|
@@ -362,6 +363,8 @@ export function buildRegisterItemContent(opts) {
|
|
|
362
363
|
if (!isPlaceholderCell(opts.fields.description)) {
|
|
363
364
|
content = setRegisterItemDescription(content, opts.fields.description);
|
|
364
365
|
}
|
|
366
|
+
if (opts.fields.inputs !== undefined)
|
|
367
|
+
content = setRegisterInput(content, opts.fields.inputs);
|
|
365
368
|
return applyRegisterItemFields(content, registerItemFieldsFromItem({
|
|
366
369
|
id: opts.displayId,
|
|
367
370
|
status: opts.fields.status,
|
|
@@ -384,5 +387,7 @@ export function buildRegisterItemContent(opts) {
|
|
|
384
387
|
...(opts.fields.sources ? { sources: opts.fields.sources } : {}),
|
|
385
388
|
...(opts.fields.derivedFrom ? { derivedFrom: opts.fields.derivedFrom } : {}),
|
|
386
389
|
...(opts.fields.dependsOn ? { dependsOn: opts.fields.dependsOn } : {}),
|
|
390
|
+
...(opts.fields.commitType ? { commitType: opts.fields.commitType } : {}),
|
|
391
|
+
...(opts.fields.commitScope ? { commitScope: opts.fields.commitScope } : {}),
|
|
387
392
|
}));
|
|
388
393
|
}
|