specdojo 0.4.0 → 0.4.1
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 +61 -2
- package/CHANGELOG.md +43 -0
- package/README.md +8 -7
- package/dist/commands/init.js +72 -15
- package/dist/commands/night-orchestrator.js +287 -0
- package/dist/commands/orchestrator.js +10 -3
- package/dist/devcontainer/command.js +3 -1
- package/dist/devcontainer/scaffold.js +166 -5
- package/dist/exec/agent-config.js +60 -2
- package/dist/exec/parent-validation.js +14 -0
- package/dist/exec/pipeline-state.js +13 -0
- package/dist/exec/register.js +23 -1
- package/dist/exec/repo-integration.js +1 -1
- package/dist/exec/reporter.js +113 -13
- package/dist/exec/results.js +36 -14
- package/dist/exec/run/agent-pipeline.js +3 -0
- package/dist/exec/run/agent.js +40 -5
- package/dist/exec/run/job.js +2 -2
- package/dist/exec/run/lifecycle-commands.js +2 -2
- package/dist/exec/run/register-command.js +23 -4
- package/dist/exec/run/register-core.js +17 -0
- package/dist/exec/run/register-mode.js +39 -16
- package/dist/exec/run/register-post-review.js +420 -0
- package/dist/exec/run/register-resume.js +27 -11
- package/dist/exec/run/register-worktree.js +66 -2
- package/dist/exec/run/run.js +1 -1
- package/dist/exec/run/shared.js +22 -24
- package/dist/exec/task-repos.js +102 -15
- package/dist/register/core.js +14 -2
- package/dist/register/create-commands.js +62 -6
- package/dist/register/event-merge.js +13 -1
- package/dist/register/events.js +4 -0
- package/dist/register/item.js +9 -0
- package/dist/register/migration.js +1 -0
- package/dist/register/register.js +2 -2
- package/dist/shared/git.js +45 -15
- package/dist/shared/provider-scaffold.js +3 -2
- package/dist/shared/specdojo-config.js +69 -16
- package/dist/shared/text.js +4 -1
- package/dist/shared/workspace-scaffold.js +69 -0
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +2 -1
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +2 -0
- package/docs/ja/specdojo/exec-templates/xrp-register-post-run-template.md +46 -0
- package/docs/ja/specdojo/guides/branch-workflow-guide.md +34 -1
- package/docs/ja/specdojo/guides/docs-structure-guide.md +2 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +79 -11
- package/docs/ja/specdojo/guides/exec-operation-guide.md +39 -1
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +9 -3
- package/docs/ja/specdojo/guides/quick-start-guide.md +9 -6
- package/docs/ja/specdojo/guides/register-operation-guide.md +42 -0
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +52 -6
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +1 -1
- package/docs/ja/specdojo/guides/waza-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +101 -56
- package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +5 -2
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +92 -18
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +6 -1
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +12 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +21 -0
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +35 -0
- package/package.json +17 -17
- package/templates/antigravity/README.md +1 -1
- package/templates/antigravity/orchestrator.md +61 -2
- package/templates/claude/agents/specdojo-orchestrator.md +61 -2
- package/templates/codex/README.md +17 -0
- package/templates/codex/agents/specdojo-orchestrator.toml +61 -2
- package/templates/codex/orchestrator.md +61 -2
- package/templates/devcontainer/devcontainer.json +3 -0
- package/templates/devcontainer/post-create.sh +15 -7
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +38 -5
- package/templates/devcontainer/remote-host/ssh-config.sample +3 -0
- package/templates/devcontainer/vim/vimrc +37 -0
- package/templates/init-agent-members.yaml +3 -3
- package/templates/init-exec-defaults.yaml +20 -1
- package/templates/opencode/agents/specdojo-orchestrator.md +61 -2
package/dist/exec/run/agent.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { basename, relative, resolve, sep } from "node:path";
|
|
4
|
-
import { resolveMemberCommand, resolveRateLimitDetection, resolveRateLimitPolicy, } from "../agent-config.js";
|
|
4
|
+
import { resolveConnectionErrorDetection, resolveMemberCommand, resolveRateLimitDetection, resolveRateLimitPolicy, } from "../agent-config.js";
|
|
5
5
|
import { decidePinnedWait, normalizeAgentLimit, } from "../limit.js";
|
|
6
6
|
import { replaceDocIndexRefs } from "../../docs/doc-index.js";
|
|
7
7
|
import { loadPlan, parsePlanTaskIdentity } from "../plans.js";
|
|
@@ -13,7 +13,7 @@ import { agentGitStateViolation, captureAgentGitStateAcrossRepos, changedAgentGi
|
|
|
13
13
|
import { recordGitStateBlockAcrossRepos, recordProtectedConfigBlockAcrossRepos, } from "../protection-handoff.js";
|
|
14
14
|
import { productRepoEnvironment, productRootsFromEnvironment, withAgentExtraRoots, withoutInheritedRepoEnvironment, } from "../task-repos.js";
|
|
15
15
|
import { gitEnvironment } from "../worktree.js";
|
|
16
|
-
import { isRateLimitError, resolveAgentOverride, selectCandidates, } from "./shared.js";
|
|
16
|
+
import { isConnectionError, isRateLimitError, resolveAgentOverride, selectCandidates, } from "./shared.js";
|
|
17
17
|
function delay(ms) {
|
|
18
18
|
return new Promise((resolveDelay) => setTimeout(resolveDelay, ms));
|
|
19
19
|
}
|
|
@@ -133,9 +133,14 @@ and does not block pipeline completion.
|
|
|
133
133
|
Use validation status \`not_applicable\` when the repository does not meet a check's applicability
|
|
134
134
|
conditions, and include a non-empty \`reason\`. The runner carries it into the result without
|
|
135
135
|
blocking completion, but rejects the claim when it can confirm the check applies:
|
|
136
|
-
- \`npm run <script>\` / \`npm test\`: the script exists in package.json
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
- \`npm run <script>\` / \`npm test\`: the script exists in package.json and any change-type
|
|
137
|
+
condition below is met. The placeholder \`test\` script that \`npm init\` writes
|
|
138
|
+
(\`echo "Error: no test specified" && exit 1\`) counts as absent.
|
|
139
|
+
- \`npx <package>\`: the package is in package.json dependencies or devDependencies and any
|
|
140
|
+
change-type condition below is met.
|
|
141
|
+
- \`npm run validate:schema:file\` requires a changed \`*.yaml\` or \`*.yml\` file; Prettier
|
|
142
|
+
requires a changed \`*.md\`, \`*.ts\`, \`*.js\`, \`*.json\`, \`*.yaml\`, or \`*.yml\` file;
|
|
143
|
+
markdownlint requires a changed \`*.md\` file.
|
|
139
144
|
- A command that targets a declared product repository (a \`<repo>:<path>\` argument or
|
|
140
145
|
\`--prefix <repo>\`) is judged by that repository's package.json, not the project repository's.
|
|
141
146
|
- \`specdojo catalog validate\`: the run's target project (or \`--project <id>\`) sets \`catalog_path\`
|
|
@@ -434,6 +439,18 @@ export async function runWithRetry(candidates, prompt, execDefaults, cwd, env, r
|
|
|
434
439
|
lastStdout = attempt.stdout;
|
|
435
440
|
lastExitCode = attempt.exitCode;
|
|
436
441
|
lastLimit = attempt.limit;
|
|
442
|
+
const connectionError = attempt.result === "failure" &&
|
|
443
|
+
isConnectionError(attempt.exitCode, `${attempt.stdout}\n${attempt.stderr}`, resolveConnectionErrorDetection(execDefaults, candidate.provider));
|
|
444
|
+
if (connectionError) {
|
|
445
|
+
return {
|
|
446
|
+
result: "failure",
|
|
447
|
+
exitCode: attempt.exitCode,
|
|
448
|
+
stdout: attempt.stdout,
|
|
449
|
+
stderr: attempt.stderr,
|
|
450
|
+
connectionError: true,
|
|
451
|
+
actor: candidate.actor,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
437
454
|
if (attempt.result !== "rate_limit")
|
|
438
455
|
return {
|
|
439
456
|
result: attempt.result,
|
|
@@ -454,6 +471,22 @@ export async function runWithRetry(candidates, prompt, execDefaults, cwd, env, r
|
|
|
454
471
|
};
|
|
455
472
|
const recoveryEvents = [];
|
|
456
473
|
const firstPass = await runPass(pinned ? candidates.slice(0, 1) : candidates);
|
|
474
|
+
if (firstPass.connectionError && pinned?.fallbackCandidate) {
|
|
475
|
+
const primary = candidates[0];
|
|
476
|
+
const fallback = pinned.fallbackCandidate;
|
|
477
|
+
const resumedAt = (pinned.now?.() ?? new Date()).toISOString();
|
|
478
|
+
process.stdout.write(`Connection error detected for pinned agent ${primary?.actor ?? "-"}. ` +
|
|
479
|
+
`Falling back to ${fallback.actor} at ${resumedAt}.\n`);
|
|
480
|
+
recoveryEvents.push({
|
|
481
|
+
action: "fallback",
|
|
482
|
+
trigger: "connection_error",
|
|
483
|
+
from_actor: primary?.actor ?? "unknown",
|
|
484
|
+
to_actor: fallback.actor,
|
|
485
|
+
resumed_at: resumedAt,
|
|
486
|
+
});
|
|
487
|
+
const fallbackResult = await runPass([fallback]);
|
|
488
|
+
return { ...fallbackResult, attempts, rateLimitEvents: recoveryEvents };
|
|
489
|
+
}
|
|
457
490
|
if (firstPass.result !== "rate_limit") {
|
|
458
491
|
return { ...firstPass, attempts, rateLimitEvents: recoveryEvents };
|
|
459
492
|
}
|
|
@@ -466,6 +499,7 @@ export async function runWithRetry(candidates, prompt, execDefaults, cwd, env, r
|
|
|
466
499
|
`Falling back to ${fallback.actor} at ${resumedAt}.\n`);
|
|
467
500
|
recoveryEvents.push({
|
|
468
501
|
action: "fallback",
|
|
502
|
+
trigger: "rate_limit",
|
|
469
503
|
from_actor: primary?.actor ?? "unknown",
|
|
470
504
|
to_actor: fallback.actor,
|
|
471
505
|
resumed_at: resumedAt,
|
|
@@ -483,6 +517,7 @@ export async function runWithRetry(candidates, prompt, execDefaults, cwd, env, r
|
|
|
483
517
|
const resumedAt = (pinned.now?.() ?? new Date()).toISOString();
|
|
484
518
|
recoveryEvents.push({
|
|
485
519
|
action: "wait",
|
|
520
|
+
trigger: "rate_limit",
|
|
486
521
|
from_actor: primary?.actor ?? "unknown",
|
|
487
522
|
to_actor: primary?.actor ?? "unknown",
|
|
488
523
|
resume_at: resumeAt.toISOString(),
|
package/dist/exec/run/job.js
CHANGED
|
@@ -6,7 +6,7 @@ import { loadExecDefaultsConfig, resolveMemberCommand, } from "../agent-config.j
|
|
|
6
6
|
import { activateResolvedProjectPaths, resolveProjectPaths } from "../project.js";
|
|
7
7
|
import { specdojoRootDir } from "../../shared/specdojo-config.js";
|
|
8
8
|
import { ROUTINE_BUSY_SKIP_EXIT_CODE, ROUTINE_EXEC_ENV } from "./lock.js";
|
|
9
|
-
import { isResultUnfilled, readResultFrontmatterSnapshot, renderReporterResult, scaffoldResult, updateResultStatus, } from "../results.js";
|
|
9
|
+
import { isResultUnfilled, readResultFrontmatterSnapshot, renderReporterResult, scaffoldResult, stripLeadingListMarker, updateResultStatus, } from "../results.js";
|
|
10
10
|
import { formatMarkdownFile } from "../format.js";
|
|
11
11
|
import { completeJobRun, executeJobCommand, generateJobReviewPlan, isJobCommandTask, jobRunUsesReviewedIntegration, loadJobDefinition, loadJobRunRecord, materializeJobRun, recordJobRunReview, resolveJobPaths, resolveJobReviewAgentNominations, } from "../../job/job.js";
|
|
12
12
|
import { ensureExecWorktree, formatGitResultFailure, gitOutput, gitResult, resolveWorktreeBase, summarizeGitHookFailure, } from "../worktree.js";
|
|
@@ -276,7 +276,7 @@ async function fillIncompleteJobReviewResult(resultPath, reason) {
|
|
|
276
276
|
content = content
|
|
277
277
|
.replace(/_TODO_: 評価結果サイドカー[^\n]*/, `Job Run の review を完了できなかった: ${safeReason}`)
|
|
278
278
|
.replace(/_TODO_: 変更内容[^\n]*/, `- runner が review を完了できなかったため統合不可と判断した。`)
|
|
279
|
-
.replace(/_TODO_: 未充足事項[^\n]*/, `- ${safeReason}`)
|
|
279
|
+
.replace(/_TODO_: 未充足事項[^\n]*/, `- ${stripLeadingListMarker(safeReason) || "理由なし"}`)
|
|
280
280
|
.replace(/_TODO_: `approach`[^\n]*/, "Job Run の出力は変更していない。")
|
|
281
281
|
.replace(/- verdict: _TODO_([^\n]*)/, "- verdict: incomplete");
|
|
282
282
|
writeFileSync(resultPath, content, "utf8");
|
|
@@ -500,8 +500,8 @@ export function registerResumeCommand(exec) {
|
|
|
500
500
|
cmd.option("--executor-by <nickname>", "agent-members.yaml executor nickname for pipeline tasks");
|
|
501
501
|
cmd.option("--reporter-by <nickname>", "agent-members.yaml reporter nickname for pipeline tasks");
|
|
502
502
|
cmd.option("--on-rate-limit <action>", "Pinned-agent rate-limit action: stop|wait|fallback (overrides rate_limit_policy.pinned)");
|
|
503
|
-
cmd.option("--fallback-executor-by <nickname>", "Fallback executor after a rate limit");
|
|
504
|
-
cmd.option("--fallback-reporter-by <nickname>", "Fallback reporter after a rate limit");
|
|
503
|
+
cmd.option("--fallback-executor-by <nickname>", "Fallback executor after a rate limit or configured connection error");
|
|
504
|
+
cmd.option("--fallback-reporter-by <nickname>", "Fallback reporter after a rate limit or configured connection error");
|
|
505
505
|
cmd.option("--parallel <n>", "Number of tasks to resume in parallel", "1");
|
|
506
506
|
cmd.option("--worktree-base <path>", "Override worktree base directory");
|
|
507
507
|
cmd.option("--exec-defaults <path>", "Path to exec-defaults.yaml global config (default: .specdojo/exec-defaults.yaml)");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { loadExecDefaultsConfig } from "../agent-config.js";
|
|
1
|
+
import { loadExecDefaultsConfig, resolveRegisterPostReview } from "../agent-config.js";
|
|
2
2
|
import { resolveProjectPaths } from "../project.js";
|
|
3
3
|
import { isRegisterFailureMode } from "../register.js";
|
|
4
|
+
import { configuredProductRepos } from "../task-repos.js";
|
|
4
5
|
import { EXCLUSIVE_EXEC_RUN, parseParallel, resolveExecDefaultsPath, resolveRegisterWorktree, withProjectExecRunLock, } from "./shared.js";
|
|
5
6
|
import { runBatchMode, runManualMode } from "./schedule-mode.js";
|
|
6
7
|
import { runInPlaceMode } from "./in-place.js";
|
|
@@ -29,6 +30,7 @@ export function registerRunCommand(exec) {
|
|
|
29
30
|
rcmd.option("--scheduled-at <dateTime>", "Scheduled occurrence time for a Job Run");
|
|
30
31
|
rcmd.option("--job-trigger <source>", "Job trigger source: manual|routine|ci", "manual");
|
|
31
32
|
rcmd.option("--register-commit", "With in-place --register: commit each successful item's changes as a separate commit (default: leave changes in the working tree). Ignored in worktree mode, which always commits", false);
|
|
33
|
+
rcmd.option("--post-review", "After integrating a register worktree, run a read-only completion review and automatically close eligible todo/issue items");
|
|
32
34
|
rcmd.option("--on-failure <mode>", "With --register: stop|continue remaining items after a failure (default: stop)");
|
|
33
35
|
rcmd.option("--resume", "With register worktree mode: resume the stage where a run stopped (executor, reporter, or integration), reusing the existing worktree and checkpoints", false);
|
|
34
36
|
rcmd.option("--resume-from <stage>", "With --resume: resume a reporter-stage run from executor instead (accepted value: executor)");
|
|
@@ -37,6 +39,7 @@ export function registerRunCommand(exec) {
|
|
|
37
39
|
rcmd.option("--in-place", "Run a register item in the current working tree (overrides run.register_execution; cannot be combined with --worktree)", false);
|
|
38
40
|
rcmd.option("--track-state", "Record claim/complete events (requires --task; --by optional, actor auto-derived from the resolved agent)", false);
|
|
39
41
|
rcmd.option("--archive-on-success", "Archive the generated plan to exec/plans/done/ after a successful in-place run", false);
|
|
42
|
+
rcmd.option("--integration-branch <repo=branch>", "With register worktree mode: integrate the declared product repository <repo> into the local branch <branch> for this run (repeatable; overrides repos[].integration_branch; resume reuses the value recorded at the start)", (value, previous = []) => [...previous, value]);
|
|
40
43
|
rcmd.option("--parallel <n>", "Number of worktree instances to run in parallel", "1");
|
|
41
44
|
rcmd.option("--worktree-base <path>", "Override worktree base directory");
|
|
42
45
|
rcmd.option("--strategy <s>", "Task selection strategy: critical-first|fifo (default: critical-first)");
|
|
@@ -47,12 +50,12 @@ export function registerRunCommand(exec) {
|
|
|
47
50
|
rcmd.option("--exec-defaults <path>", "Path to exec-defaults.yaml global config (default: .specdojo/exec-defaults.yaml)");
|
|
48
51
|
rcmd.option("--agent-config <path>", "Deprecated alias for --exec-defaults");
|
|
49
52
|
rcmd.option("--edit-by <nickname>", "agent-members.yaml nickname for edit-mode tasks in --auto batch runs");
|
|
50
|
-
rcmd.option("--review-by <nickname>", "agent-members.yaml nickname for review-mode tasks in --auto batch runs");
|
|
53
|
+
rcmd.option("--review-by <nickname>", "agent-members.yaml nickname for review-mode tasks in --auto batch runs or register post-review");
|
|
51
54
|
rcmd.option("--executor-by <nickname>", "Executor nickname; with --register, also accepts PJR-ID=nickname assignments separated by commas. With --plan / --deliverable, runs the executor/reporter pipeline");
|
|
52
55
|
rcmd.option("--reporter-by <nickname>", "agent-members.yaml reporter nickname for agent_pipeline tasks (with --plan / --deliverable, runs the executor/reporter pipeline)");
|
|
53
56
|
rcmd.option("--on-rate-limit <action>", "Pinned-agent rate-limit action: stop|wait|fallback (overrides rate_limit_policy.pinned)");
|
|
54
|
-
rcmd.option("--fallback-executor-by <nickname>", "Fallback executor
|
|
55
|
-
rcmd.option("--fallback-reporter-by <nickname>", "Fallback reporter
|
|
57
|
+
rcmd.option("--fallback-executor-by <nickname>", "Fallback executor for a selected rate-limit fallback or configured connection error");
|
|
58
|
+
rcmd.option("--fallback-reporter-by <nickname>", "Fallback reporter for a selected rate-limit fallback or configured connection error");
|
|
56
59
|
rcmd.option("--dry-run", "Print resolved command without executing", false);
|
|
57
60
|
rcmd.action(async (opts) => {
|
|
58
61
|
try {
|
|
@@ -109,12 +112,28 @@ export function registerRunCommand(exec) {
|
|
|
109
112
|
const { schedulePath, executionPath } = resolveProjectPaths({ project: opts.project });
|
|
110
113
|
const execDefaults = loadExecDefaultsConfig(resolveExecDefaultsPath(opts, schedulePath), executionPath);
|
|
111
114
|
opts.worktree = resolveRegisterWorktree(opts, execDefaults);
|
|
115
|
+
opts.postReview = opts.postReview || resolveRegisterPostReview(execDefaults);
|
|
116
|
+
}
|
|
117
|
+
if (opts.postReview && !(hasRegister && opts.worktree)) {
|
|
118
|
+
process.stdout.write("--post-review (or run.register_post_review) requires --register in worktree mode.\n");
|
|
119
|
+
process.exitCode = 1;
|
|
120
|
+
return;
|
|
112
121
|
}
|
|
113
122
|
if (hasRegister && !opts.worktree && parseParallel(opts.parallel) !== 1) {
|
|
114
123
|
process.stdout.write("--parallel with --register requires worktree mode; use --worktree or configure run.register_execution: worktree.\n");
|
|
115
124
|
process.exitCode = 1;
|
|
116
125
|
return;
|
|
117
126
|
}
|
|
127
|
+
const integrationBranches = opts.integrationBranch ?? [];
|
|
128
|
+
if (integrationBranches.length > 0) {
|
|
129
|
+
if (!(hasRegister && opts.worktree)) {
|
|
130
|
+
process.stdout.write("--integration-branch requires --register (or --register-filter) in worktree mode.\n");
|
|
131
|
+
process.exitCode = 1;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// 形式・宣言済みリポジトリ・ローカルブランチの存在を、register の状態を変える前に確かめる。
|
|
135
|
+
configuredProductRepos(resolveProjectPaths({ project: opts.project }).schedulePath, integrationBranches);
|
|
136
|
+
}
|
|
118
137
|
if (opts.join && !(hasRegister && opts.worktree)) {
|
|
119
138
|
process.stdout.write("--join requires --register (or --register-filter) in worktree mode.\n");
|
|
120
139
|
process.exitCode = 1;
|
|
@@ -14,6 +14,23 @@ import { expandPromptRefs } from "./agent.js";
|
|
|
14
14
|
import { runAgentPipeline } from "./agent-pipeline.js";
|
|
15
15
|
import { spawnAgentInPlace } from "./in-place.js";
|
|
16
16
|
import { commitSubject, repoRelativePath, spawnSelf } from "./mode-shared.js";
|
|
17
|
+
// CLI choices are the highest-priority layer. A difficulty route only supplies omitted stage and
|
|
18
|
+
// recovery options; without a matching route the historical priority-based selection is kept.
|
|
19
|
+
export function applyRegisterDifficultyRouting(item, opts, execDefaults) {
|
|
20
|
+
if (opts.by?.trim() || !item.difficulty)
|
|
21
|
+
return opts;
|
|
22
|
+
const route = execDefaults.routing?.[item.difficulty];
|
|
23
|
+
if (!route)
|
|
24
|
+
return opts;
|
|
25
|
+
return {
|
|
26
|
+
...opts,
|
|
27
|
+
executorBy: opts.executorBy ?? route.executor_by,
|
|
28
|
+
reporterBy: opts.reporterBy ?? route.reporter_by,
|
|
29
|
+
onRateLimit: opts.onRateLimit ?? route.on_rate_limit,
|
|
30
|
+
fallbackExecutorBy: opts.fallbackExecutorBy ?? route.fallback_executor_by,
|
|
31
|
+
fallbackReporterBy: opts.fallbackReporterBy ?? route.fallback_reporter_by,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
17
34
|
// --register の単一 agent 実行(--by 指定時)の agent を解決する。owner(Role code)や
|
|
18
35
|
// role からの自動選択は行わない(PJR-ADZ6)。agent は全員 stage_role を持つ pipeline
|
|
19
36
|
// メンバーであり、owner・role から選ぶと pipeline 用でない agent(翻訳専用など)や
|
|
@@ -12,9 +12,10 @@ import { findExecWorktree, resolveWorktreeBase } from "../worktree.js";
|
|
|
12
12
|
import { findResumableRegisterRun } from "../register-resume.js";
|
|
13
13
|
import { configuredWorktreeBase, parseParallel, resolveExecDefaultsPath, runCompletionDrivenWorkerPool, } from "./shared.js";
|
|
14
14
|
import { loadRosterForExecutionPath } from "./agent.js";
|
|
15
|
-
import { resolveRegisterCommand, isRegisterPipelineRequested, parseRegisterExecutorSelection, selectedRegisterExecutor, resolveRegisterPipelineCommand, runSingleRegisterItem, } from "./register-core.js";
|
|
15
|
+
import { applyRegisterDifficultyRouting, resolveRegisterCommand, isRegisterPipelineRequested, parseRegisterExecutorSelection, selectedRegisterExecutor, resolveRegisterPipelineCommand, runSingleRegisterItem, } from "./register-core.js";
|
|
16
16
|
import { runSingleRegisterItemWorktree } from "./register-worktree.js";
|
|
17
17
|
import { resumeSingleRegisterItemWorktree } from "./register-resume.js";
|
|
18
|
+
import { resolveRegisterPostReviewAgents } from "./register-post-review.js";
|
|
18
19
|
// register 項目の実行(複数ID)。in-place モードは指定順に1件ずつ直列実行し、各IDが plan/result
|
|
19
20
|
// 生成・start・agent実行・review/waiting 遷移まで完結してから次へ進む。worktree モードは成果物を
|
|
20
21
|
// worktree に隔離し、状態遷移を root で直列化する(--parallel で並列化可能)。失敗時は
|
|
@@ -48,29 +49,46 @@ export async function runRegisterMode(opts) {
|
|
|
48
49
|
process.stdout.write("No matching register items.\n");
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
|
-
const hasExecutorSelection = executorSelection.kind !== "none";
|
|
52
|
-
const optsForItem = (pjrId) => ({
|
|
53
|
-
...opts,
|
|
54
|
-
executorBy: selectedRegisterExecutor(executorSelection, pjrId),
|
|
55
|
-
});
|
|
56
52
|
for (const duplicate of duplicates) {
|
|
57
53
|
process.stdout.write(`Skipping duplicate register item id: ${duplicate}\n`);
|
|
58
54
|
}
|
|
59
55
|
const failureMode = opts.onFailure
|
|
60
56
|
? opts.onFailure
|
|
61
57
|
: "stop";
|
|
62
|
-
// --executor-by / --reporter-by は両方揃って初めて pipeline モードになる。片方だけの指定は
|
|
63
|
-
// 曖昧なため、実行前に明示的なエラーで止める(isRegisterPipelineRequested は片方でも true を
|
|
64
|
-
// 返すため、resolveRegisterPipelineCommand 側の対称チェックとは別に、ここで早期に検知する)。
|
|
65
|
-
// 再開は state が示す段だけを実行する。stale executor の再実行では各 agent の明示指定を
|
|
66
|
-
// 個別に許可し、省略時は state に記録された actor を使う。
|
|
67
|
-
if (!opts.resume &&
|
|
68
|
-
((hasExecutorSelection && !opts.reporterBy) || (!hasExecutorSelection && opts.reporterBy))) {
|
|
69
|
-
throw new Error("--register pipeline execution requires both --executor-by and --reporter-by.");
|
|
70
|
-
}
|
|
71
58
|
const roster = loadRosterForExecutionPath(executionPath);
|
|
72
59
|
const execDefaults = loadExecDefaultsConfig(resolveExecDefaultsPath(opts, schedulePath), executionPath);
|
|
60
|
+
const optsForItem = (pjrId) => {
|
|
61
|
+
const { item } = resolveRegisterRunTarget(projectId, pjrId);
|
|
62
|
+
const itemOptions = {
|
|
63
|
+
...opts,
|
|
64
|
+
executorBy: selectedRegisterExecutor(executorSelection, pjrId),
|
|
65
|
+
};
|
|
66
|
+
const routed = applyRegisterDifficultyRouting(item, itemOptions, execDefaults);
|
|
67
|
+
// A resume without explicit stage overrides must keep the actors recorded in pipeline state.
|
|
68
|
+
// The route still supplies recovery behavior and fallbacks for those pinned actors.
|
|
69
|
+
return opts.resume
|
|
70
|
+
? {
|
|
71
|
+
...routed,
|
|
72
|
+
executorBy: itemOptions.executorBy,
|
|
73
|
+
reporterBy: itemOptions.reporterBy,
|
|
74
|
+
}
|
|
75
|
+
: routed;
|
|
76
|
+
};
|
|
77
|
+
// Validate the effective per-item selection before creating worktrees or changing register
|
|
78
|
+
// state. A route may supply the counterpart of one explicitly overridden stage.
|
|
79
|
+
if (!opts.resume) {
|
|
80
|
+
for (const pjrId of ids) {
|
|
81
|
+
const itemOpts = optsForItem(pjrId);
|
|
82
|
+
if ((itemOpts.executorBy && !itemOpts.reporterBy) ||
|
|
83
|
+
(!itemOpts.executorBy && itemOpts.reporterBy)) {
|
|
84
|
+
throw new Error("--register pipeline execution requires both --executor-by and --reporter-by, either explicitly or from the item's difficulty route.");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
73
88
|
const useWorktree = !!opts.worktree;
|
|
89
|
+
const postReviewAgents = opts.postReview
|
|
90
|
+
? resolveRegisterPostReviewAgents(roster, opts, execDefaults)
|
|
91
|
+
: undefined;
|
|
74
92
|
const parallel = parseParallel(opts.parallel);
|
|
75
93
|
const worktreeBase = resolveWorktreeBase(repoRoot, opts.worktreeBase, configuredWorktreeBase(schedulePath));
|
|
76
94
|
if (opts.dryRun && opts.resume) {
|
|
@@ -121,9 +139,13 @@ export async function runRegisterMode(opts) {
|
|
|
121
139
|
process.stdout.write(`[dry-run] command: ${command}\n`);
|
|
122
140
|
}
|
|
123
141
|
process.stdout.write(`[dry-run] plan: ${join(executionPath, "exec", "plans", `${stem}-plan.md`)}\n`);
|
|
142
|
+
if (postReviewAgents) {
|
|
143
|
+
process.stdout.write(`[dry-run] post-review executor: ${postReviewAgents.executor.actor}\n`);
|
|
144
|
+
process.stdout.write(`[dry-run] post-review reporter: ${postReviewAgents.reporterCandidates[0]?.actor}\n`);
|
|
145
|
+
}
|
|
124
146
|
}
|
|
125
147
|
process.stdout.write(`[dry-run] cwd: ${useWorktree ? `${worktreeBase}/<worktree>` : repoRoot}\n`);
|
|
126
|
-
process.stdout.write(`[dry-run] transitions: start (in-progress) → review on success / waiting on failure\n`);
|
|
148
|
+
process.stdout.write(`[dry-run] transitions: start (in-progress) → review on success / waiting on failure${postReviewAgents ? "; after integration, post-review closes eligible todo/issue items or returns incomplete items to waiting" : ""}\n`);
|
|
127
149
|
return;
|
|
128
150
|
}
|
|
129
151
|
const context = {
|
|
@@ -141,6 +163,7 @@ export async function runRegisterMode(opts) {
|
|
|
141
163
|
// ロックディレクトリの枠で統制する。
|
|
142
164
|
providerConcurrencyGate: new ProviderConcurrencyGate(execDefaults, execLocksDir(executionPath)),
|
|
143
165
|
registerCommit: !!opts.registerCommit,
|
|
166
|
+
postReview: !!opts.postReview,
|
|
144
167
|
worktree: useWorktree,
|
|
145
168
|
worktreeBase,
|
|
146
169
|
};
|