specdojo 0.3.0 → 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 +65 -0
- package/README.md +77 -18
- package/dist/catalog/build-references.js +144 -0
- package/dist/catalog/build-render.js +32 -0
- package/dist/{catalog-build.js → catalog/build.js} +18 -295
- package/dist/{catalog.js → catalog/catalog.js} +11 -11
- package/dist/{catalog-generate.js → catalog/generate.js} +13 -16
- package/dist/catalog/paths.js +1 -0
- package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +5 -5
- package/dist/{catalog-plan.js → catalog/plan.js} +9 -9
- package/dist/{catalog-scaffold.js → catalog/scaffold.js} +6 -6
- 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} +103 -37
- package/dist/{orchestrator.js → commands/orchestrator.js} +2 -2
- package/dist/{watch.js → commands/watch.js} +3 -3
- package/dist/dashboard/dashboard-timeline.js +175 -0
- package/dist/{dashboard.js → dashboard/dashboard.js} +16 -549
- package/dist/dashboard/exec-records.js +105 -0
- package/dist/dashboard/routines.js +256 -0
- package/dist/dashboard/shared.js +14 -0
- 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} +7 -7
- 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} +3 -3
- package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +2 -2
- 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} +3 -3
- package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
- package/dist/{yaml-pages.js → docs/yaml-pages.js} +5 -5
- 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.js → exec/commands.js} +22 -467
- package/dist/exec/core.js +457 -0
- 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.js → exec/plans-core.js} +97 -468
- package/dist/exec/plans-generation.js +249 -0
- package/dist/exec/plans-storage.js +131 -0
- package/dist/exec/plans.js +3 -0
- 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 +23 -0
- package/dist/exec/repo-integration-sync.js +264 -0
- package/dist/{exec-repo-integration.js → exec/repo-integration.js} +13 -287
- package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
- package/dist/exec/reporter-output.js +206 -0
- package/dist/{exec-reporter.js → exec/reporter.js} +29 -216
- package/dist/{exec-results.js → exec/results.js} +277 -36
- package/dist/exec/run/agent-pipeline.js +276 -0
- package/dist/exec/run/agent.js +583 -0
- package/dist/exec/run/in-place.js +570 -0
- package/dist/exec/run/job.js +746 -0
- package/dist/exec/run/lifecycle-commands.js +530 -0
- package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
- package/dist/exec/run/mode-shared.js +140 -0
- package/dist/exec/run/register-command.js +252 -0
- package/dist/exec/run/register-core.js +411 -0
- package/dist/exec/run/register-mode.js +210 -0
- package/dist/exec/run/register-resume.js +398 -0
- package/dist/exec/run/register-state.js +325 -0
- package/dist/exec/run/register-worktree.js +540 -0
- package/dist/exec/run/run.js +11 -0
- package/dist/exec/run/schedule-mode.js +294 -0
- package/dist/exec/run/schedule-prepare.js +366 -0
- package/dist/exec/run/schedule-task.js +599 -0
- package/dist/exec/run/shared.js +449 -0
- 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.js → exec/trial-commands.js} +23 -388
- package/dist/exec/trial-core.js +371 -0
- package/dist/exec/trial.js +2 -0
- package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
- package/dist/exec/worktree-ops-commit.js +672 -0
- package/dist/exec/worktree-ops-lifecycle.js +297 -0
- package/dist/exec/worktree-ops-merge.js +344 -0
- package/dist/exec/worktree-ops.js +3 -0
- package/dist/exec/worktree.js +305 -0
- package/dist/grade/apply.js +734 -0
- package/dist/grade/command-apply.js +250 -0
- package/dist/grade/command-inspect.js +138 -0
- package/dist/grade/command-plan.js +101 -0
- package/dist/grade/command-shared.js +68 -0
- package/dist/grade/core.js +307 -0
- package/dist/grade/grade.js +19 -0
- package/dist/grade/markdown.js +274 -0
- package/dist/grade/pipeline-state.js +184 -0
- package/dist/grade/plan.js +507 -0
- package/dist/{grade-result.js → grade/result.js} +7 -96
- package/dist/grade/target-discovery.js +265 -0
- package/dist/grade/targets.js +435 -0
- package/dist/{job.js → job/definition.js} +32 -574
- package/dist/job/job.js +568 -0
- package/dist/{kata-command.js → kata/command.js} +4 -4
- package/dist/{kata.js → kata/kata.js} +5 -5
- package/dist/register/approach.js +134 -0
- package/dist/register/command-types.js +1 -0
- package/dist/register/core.js +369 -0
- package/dist/register/create-commands.js +352 -0
- 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} +12 -6
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +28 -10
- package/dist/register/lifecycle-lock.js +5 -0
- package/dist/register/maintenance-commands.js +193 -0
- package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
- package/dist/register/migration.js +268 -0
- package/dist/register/register.js +404 -0
- package/dist/register/renumber.js +341 -0
- package/dist/register/transition-commands.js +248 -0
- package/dist/register/update.js +230 -0
- package/dist/register/views.js +296 -0
- package/dist/{review-grade.js → review/grade.js} +2 -2
- package/dist/{review-plan.js → review/plan.js} +5 -5
- package/dist/routine/definition.js +401 -0
- package/dist/{routine.js → routine/routine.js} +50 -419
- package/dist/{schedule-approach.js → schedule/approach.js} +9 -9
- package/dist/{schedule-build.js → schedule/build.js} +7 -4
- package/dist/{schedule.js → schedule/schedule.js} +9 -9
- package/dist/schedule/strategy-generate-document.js +273 -0
- package/dist/schedule/strategy-generate-scope.js +199 -0
- package/dist/schedule/strategy-generate.js +348 -0
- 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/shared/catalog-render.js +115 -0
- package/dist/{exec-slot-lock.js → shared/cross-process-lock.js} +3 -1
- package/dist/shared/fs.js +30 -0
- package/dist/shared/git.js +316 -0
- 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} +96 -9
- package/dist/{exec-shared.js → shared/text.js} +0 -134
- package/dist/shared/time.js +28 -0
- package/dist/shared/yaml.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 +97 -22
- 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 +51 -18
- 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 +6 -6
- 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 +4 -5
- package/templates/antigravity/README.md +7 -3
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +10 -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 +26 -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-run.js +0 -6182
- package/dist/exec-schedule-gantt-chart.js +0 -2
- package/dist/exec-worktree-ops.js +0 -1292
- package/dist/exec-worktree.js +0 -446
- package/dist/grade.js +0 -3193
- package/dist/register.js +0 -2407
- package/dist/schedule-strategy-generate.js +0 -812
- 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/{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
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { acquireSchedulerLock, buildEvent, canReleaseTask, collectRepeatable, findDoingTasksForActor, foldEventsToState, readAllEventFiles, releaseSchedulerLock, writeEventFile, } from "./events.js";
|
|
2
|
+
import { activateResolvedProjectPaths, resolveProjectPaths } from "./project.js";
|
|
3
|
+
import { assertValidActor, loadConfig, loadMemberRoster, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
4
|
+
import { buildScheduleIndex, computeCpm, exitWithCode, printValidateResult, validateAll, writeCpmFiles, writeGeneratedCore, writeScheduleHashAndDiff, } from "./schedule/schedule.js";
|
|
5
|
+
import { qualifyTaskId, requireNonEmpty } from "./shared.js";
|
|
6
|
+
import { finalizeResultSectionsForDeliverable, targetDocIdsForScheduledTask } from "./plans.js";
|
|
7
|
+
import { resetResultForClaim, scaffoldResult } from "./results.js";
|
|
8
|
+
import { discardStaleExecWorktree } from "./worktree-ops.js";
|
|
9
|
+
import { configuredProductRepos } from "./task-repos.js";
|
|
10
|
+
import { buildInitialStateFromStrategy } from "./schedule/initial.js";
|
|
11
|
+
import { buildPhaseModeIndex, resolveApproach, resolveTaskExecution, resolveTaskMode, } from "./strategy.js";
|
|
12
|
+
export const KNOWN_OWNER_LABELS = ["PO", "PM", "BA", "ARC", "DEV", "QE", "UX", "OPS"];
|
|
13
|
+
export const KNOWN_OWNER_LABELS_TEXT = KNOWN_OWNER_LABELS.join("|");
|
|
14
|
+
const KNOWN_APPROACHES = [
|
|
15
|
+
"fully-guided",
|
|
16
|
+
"recipe-guided",
|
|
17
|
+
"freeform",
|
|
18
|
+
"bootstrap",
|
|
19
|
+
"retrofit",
|
|
20
|
+
"cross-deliverable-dedup",
|
|
21
|
+
"rulebook-maintenance",
|
|
22
|
+
"recipe-maintenance",
|
|
23
|
+
"sample-maintenance",
|
|
24
|
+
"template-maintenance",
|
|
25
|
+
"finalize",
|
|
26
|
+
"bootstrap-finalize",
|
|
27
|
+
];
|
|
28
|
+
export function parseTaskMode(value) {
|
|
29
|
+
const mode = typeof value === "string" ? value.trim().toLowerCase() : "edit";
|
|
30
|
+
if (mode !== "edit" && mode !== "review") {
|
|
31
|
+
throw new Error(`Invalid --mode value: ${mode}. Use one of: edit|review.`);
|
|
32
|
+
}
|
|
33
|
+
return mode;
|
|
34
|
+
}
|
|
35
|
+
export function parseApproach(value) {
|
|
36
|
+
const approach = typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
37
|
+
if (!KNOWN_APPROACHES.includes(approach)) {
|
|
38
|
+
throw new Error(`Invalid --approach value: ${approach}. Use one of: ${KNOWN_APPROACHES.join("|")}.`);
|
|
39
|
+
}
|
|
40
|
+
return approach;
|
|
41
|
+
}
|
|
42
|
+
export function addProjectOptions(cmd) {
|
|
43
|
+
return cmd.option("--project <projectId>", "Project id in specdojo.config.json (e.g. shj-0001)");
|
|
44
|
+
}
|
|
45
|
+
export function addLockOptions(cmd) {
|
|
46
|
+
return cmd
|
|
47
|
+
.option("--allow-multiple-doing", "Allow this actor to hold multiple doing tasks", false)
|
|
48
|
+
.option("--lock-timeout-ms <ms>", "Lock acquisition timeout in ms", "10000")
|
|
49
|
+
.option("--lock-stale-ms <ms>", "Lock stale threshold in ms", "300000");
|
|
50
|
+
}
|
|
51
|
+
export function addForceOption(cmd) {
|
|
52
|
+
return cmd.option("--force", "Human actor only: override the guard on a task held by another actor", false);
|
|
53
|
+
}
|
|
54
|
+
export function addOwnerOptions(cmd) {
|
|
55
|
+
return cmd
|
|
56
|
+
.option("--owner <owner>", `Planned owner label for assignment checks (${KNOWN_OWNER_LABELS_TEXT}; defaults to SPECDOJO_OWNER, roster owner, or actor)`)
|
|
57
|
+
.option("--allow-owner-mismatch", "Allow claiming a task assigned to a different owner", false);
|
|
58
|
+
}
|
|
59
|
+
// Fixed default messages for routine state transitions. Events whose message carries the
|
|
60
|
+
// reason itself (note / block / unblock / reopen / cancel) have no default and keep --msg required.
|
|
61
|
+
export const DEFAULT_EVENT_MESSAGES = {
|
|
62
|
+
claim: "claim task",
|
|
63
|
+
complete: "complete task",
|
|
64
|
+
release: "release task",
|
|
65
|
+
link: "link refs",
|
|
66
|
+
estimate: "update estimate",
|
|
67
|
+
};
|
|
68
|
+
export function addCommonAddOptions(cmd, options) {
|
|
69
|
+
addProjectOptions(cmd);
|
|
70
|
+
// `release --all-blocked` operates on every blocked task instead of a single --task, so the task
|
|
71
|
+
// option must be optional for that command. The single-task path still validates it via
|
|
72
|
+
// requireNonEmpty before building the event.
|
|
73
|
+
if (options?.requireTask === false) {
|
|
74
|
+
cmd.option("--task <taskId>", "Task/Milestone ID");
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
cmd.requiredOption("--task <taskId>", "Task/Milestone ID");
|
|
78
|
+
}
|
|
79
|
+
cmd.requiredOption("--by <actor>", "Actor (human/agent)");
|
|
80
|
+
if (options?.msgDefault !== undefined) {
|
|
81
|
+
cmd.option("--msg <message>", "Short message", options.msgDefault);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
cmd.requiredOption("--msg <message>", "Short message");
|
|
85
|
+
}
|
|
86
|
+
return cmd
|
|
87
|
+
.option("--run-id <id>", "Correlation id")
|
|
88
|
+
.option("--ref <k=v...>", "refs key=value (repeatable)", collectRepeatable, [])
|
|
89
|
+
.option("--meta <k=v...>", "meta key=value (repeatable)", collectRepeatable, [])
|
|
90
|
+
.option("--dry-run", "Print event JSON without writing to disk", false);
|
|
91
|
+
}
|
|
92
|
+
export function resolveProjectContext(opts) {
|
|
93
|
+
const resolvedPaths = resolveProjectPaths({ project: opts.project });
|
|
94
|
+
activateResolvedProjectPaths(resolvedPaths);
|
|
95
|
+
return resolvedPaths;
|
|
96
|
+
}
|
|
97
|
+
export function loadRosterForOpts(opts) {
|
|
98
|
+
const { config } = loadConfig();
|
|
99
|
+
if (!config)
|
|
100
|
+
return null;
|
|
101
|
+
const projectId = resolveProjectId(opts);
|
|
102
|
+
const project = config.projects[projectId];
|
|
103
|
+
if (!project)
|
|
104
|
+
return null;
|
|
105
|
+
return loadMemberRoster(specdojoRootDir(), project);
|
|
106
|
+
}
|
|
107
|
+
export function resolveProjectId(opts) {
|
|
108
|
+
const { config } = loadConfig();
|
|
109
|
+
return (opts.project?.trim() ||
|
|
110
|
+
process.env.SPECDOJO_PROJECT?.trim() ||
|
|
111
|
+
config?.current_project?.trim() ||
|
|
112
|
+
Object.keys(config?.projects ?? {})[0] ||
|
|
113
|
+
"");
|
|
114
|
+
}
|
|
115
|
+
export function findRosterMember(roster, actor) {
|
|
116
|
+
return roster?.members.find((member) => member.nickname === actor) ?? null;
|
|
117
|
+
}
|
|
118
|
+
// The --force override is honored only for actors registered as humans in the
|
|
119
|
+
// roster, so agents cannot steal a task another actor is working on.
|
|
120
|
+
export function resolveForceOverride(opts, actor) {
|
|
121
|
+
const isHuman = findRosterMember(loadRosterForOpts(opts), actor)?.type === "human";
|
|
122
|
+
return { isHuman, force: !!opts.force };
|
|
123
|
+
}
|
|
124
|
+
export function resolveClaimOwner(opts, actor, roster = null, taskOwner) {
|
|
125
|
+
const cliOwner = typeof opts.owner === "string" ? opts.owner.trim().toUpperCase() : "";
|
|
126
|
+
const envOwner = typeof process.env.SPECDOJO_OWNER === "string"
|
|
127
|
+
? process.env.SPECDOJO_OWNER.trim().toUpperCase()
|
|
128
|
+
: "";
|
|
129
|
+
const rosterMemberRoles = findRosterMember(roster, actor)?.roles ?? [];
|
|
130
|
+
// For multi-role actors, prefer the role matching the task's planned owner.
|
|
131
|
+
const matchedRole = taskOwner && rosterMemberRoles.length > 1
|
|
132
|
+
? (rosterMemberRoles
|
|
133
|
+
.find((r) => r.trim().toUpperCase() === taskOwner.toUpperCase() &&
|
|
134
|
+
KNOWN_OWNER_LABELS.includes(r.trim().toUpperCase()))
|
|
135
|
+
?.trim()
|
|
136
|
+
.toUpperCase() ?? "")
|
|
137
|
+
: "";
|
|
138
|
+
const rosterOwner = Array.isArray(rosterMemberRoles) && rosterMemberRoles.length > 0
|
|
139
|
+
? rosterMemberRoles[0].trim().toUpperCase()
|
|
140
|
+
: "";
|
|
141
|
+
if (cliOwner && !KNOWN_OWNER_LABELS.includes(cliOwner)) {
|
|
142
|
+
throw new Error(`Invalid --owner value: ${cliOwner}. Use one of: ${KNOWN_OWNER_LABELS_TEXT}.`);
|
|
143
|
+
}
|
|
144
|
+
if (envOwner && !KNOWN_OWNER_LABELS.includes(envOwner)) {
|
|
145
|
+
throw new Error(`Invalid SPECDOJO_OWNER value: ${envOwner}. Use one of: ${KNOWN_OWNER_LABELS_TEXT}.`);
|
|
146
|
+
}
|
|
147
|
+
if (rosterOwner &&
|
|
148
|
+
!KNOWN_OWNER_LABELS.includes(rosterOwner)) {
|
|
149
|
+
throw new Error(`Invalid roster owner for actor ${actor}: ${rosterOwner}. Use one of: ${KNOWN_OWNER_LABELS_TEXT}.`);
|
|
150
|
+
}
|
|
151
|
+
return cliOwner || envOwner || matchedRole || rosterOwner || "";
|
|
152
|
+
}
|
|
153
|
+
export function resolveSchedulerStrategy(opts, actor, roster = null) {
|
|
154
|
+
const cliStrategy = typeof opts.strategy === "string" ? opts.strategy.trim().toLowerCase() : "";
|
|
155
|
+
const rosterStrategy = findRosterMember(roster, actor)?.scheduler_strategy ?? "";
|
|
156
|
+
const strategy = (cliStrategy || rosterStrategy || "critical-first");
|
|
157
|
+
if (strategy !== "critical-first" && strategy !== "fifo") {
|
|
158
|
+
throw new Error(`Invalid --strategy value: ${strategy}. Use one of: critical-first|fifo.`);
|
|
159
|
+
}
|
|
160
|
+
return strategy;
|
|
161
|
+
}
|
|
162
|
+
export function printCommandError(error, fail = true) {
|
|
163
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
164
|
+
process.stdout.write(message + "\n");
|
|
165
|
+
if (fail)
|
|
166
|
+
exitWithCode(false);
|
|
167
|
+
else
|
|
168
|
+
process.exitCode = 1;
|
|
169
|
+
}
|
|
170
|
+
export function loadValidatedExecState(projectPath) {
|
|
171
|
+
const res = validateAll(projectPath);
|
|
172
|
+
if (!res.ok) {
|
|
173
|
+
printValidateResult(res);
|
|
174
|
+
exitWithCode(false);
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const schedule = buildScheduleIndex(projectPath);
|
|
178
|
+
const events = readAllEventFiles(projectPath);
|
|
179
|
+
const initialTasks = buildInitialStateFromStrategy(projectPath, schedule);
|
|
180
|
+
const snapshot = foldEventsToState(events, schedule, projectPath, initialTasks);
|
|
181
|
+
return { schedule, events, snapshot };
|
|
182
|
+
}
|
|
183
|
+
export function ensureActorCanClaimNext(snapshot, actor, allowMultipleDoing) {
|
|
184
|
+
const doingTasks = findDoingTasksForActor(snapshot, actor);
|
|
185
|
+
if (allowMultipleDoing || doingTasks.length === 0)
|
|
186
|
+
return true;
|
|
187
|
+
process.stdout.write(`Actor ${actor} already has doing task(s): ${doingTasks.join(", ")}\n` +
|
|
188
|
+
`Use --allow-multiple-doing to override.\n`);
|
|
189
|
+
exitWithCode(false);
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
export async function scaffoldClaimResult(opts) {
|
|
193
|
+
const scheduleNode = opts.state.schedule.nodes.get(opts.taskId);
|
|
194
|
+
const localId = scheduleNode?.local_id;
|
|
195
|
+
const phaseModeIndex = buildPhaseModeIndex(opts.schedulePath);
|
|
196
|
+
const mode = resolveTaskMode(localId, opts.taskId, phaseModeIndex, scheduleNode?.phase_suffix, scheduleNode?.phase_set);
|
|
197
|
+
const approach = resolveApproach(localId, opts.taskId, phaseModeIndex, scheduleNode?.phase_suffix, scheduleNode?.phase_set);
|
|
198
|
+
const execution = resolveTaskExecution(localId, opts.taskId, phaseModeIndex, scheduleNode?.phase_suffix, scheduleNode?.phase_set);
|
|
199
|
+
const finalizeSections = approach === "finalize" || approach === "bootstrap-finalize"
|
|
200
|
+
? finalizeResultSectionsForDeliverable(opts.catalogPath ?? "", localId, approach)
|
|
201
|
+
: undefined;
|
|
202
|
+
const targets = targetDocIdsForScheduledTask(opts.catalogPath ?? "", {
|
|
203
|
+
local_id: localId,
|
|
204
|
+
target_local_ids: scheduleNode?.target_local_ids,
|
|
205
|
+
approach,
|
|
206
|
+
}, opts.projectId);
|
|
207
|
+
const result = await scaffoldResult({
|
|
208
|
+
executionPath: opts.executionPath,
|
|
209
|
+
taskId: opts.taskId,
|
|
210
|
+
mode,
|
|
211
|
+
projectId: opts.projectId,
|
|
212
|
+
...(execution === "agent" ? { planRef: `exec/plans/${opts.taskId}-plan.md` } : {}),
|
|
213
|
+
agent: opts.actor,
|
|
214
|
+
startedAt: opts.startedAt,
|
|
215
|
+
execution,
|
|
216
|
+
...(approach ? { approach } : {}),
|
|
217
|
+
...(targets ? { targets } : {}),
|
|
218
|
+
...(finalizeSections ? { finalizeSections } : {}),
|
|
219
|
+
});
|
|
220
|
+
if (!result.created) {
|
|
221
|
+
await resetResultForClaim(result.resultPath, opts.actor, opts.startedAt, execution);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
export function runSimpleEventCommand(opts, type) {
|
|
225
|
+
try {
|
|
226
|
+
const { schedulePath } = resolveProjectContext(opts);
|
|
227
|
+
const actor = requireNonEmpty("by", opts.by);
|
|
228
|
+
const roster = loadRosterForOpts(opts);
|
|
229
|
+
assertValidActor(actor, roster);
|
|
230
|
+
const event = buildEvent(type, opts);
|
|
231
|
+
if (opts.dryRun) {
|
|
232
|
+
process.stdout.write(`[dry-run] ${JSON.stringify(event, null, 2)}\n`);
|
|
233
|
+
exitWithCode(true);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const out = writeEventFile(schedulePath, event);
|
|
237
|
+
process.stdout.write(out + "\n");
|
|
238
|
+
exitWithCode(true);
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
printCommandError(error, false);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
export async function runLockedEventCommand(opts, action) {
|
|
245
|
+
let lockDir = "";
|
|
246
|
+
try {
|
|
247
|
+
const { schedulePath, executionPath, catalogPath } = resolveProjectContext(opts);
|
|
248
|
+
const actor = requireNonEmpty("by", opts.by);
|
|
249
|
+
const roster = loadRosterForOpts(opts);
|
|
250
|
+
assertValidActor(actor, roster);
|
|
251
|
+
let taskId = typeof opts.task === "string" ? opts.task.trim() : "";
|
|
252
|
+
const allowMultipleDoing = !!opts.allowMultipleDoing;
|
|
253
|
+
const lockTimeoutMs = Number(opts.lockTimeoutMs);
|
|
254
|
+
const lockStaleMs = Number(opts.lockStaleMs);
|
|
255
|
+
lockDir = acquireSchedulerLock(schedulePath, { actor, lockTimeoutMs, lockStaleMs });
|
|
256
|
+
const state = loadValidatedExecState(schedulePath);
|
|
257
|
+
if (!state)
|
|
258
|
+
return;
|
|
259
|
+
if (!taskId && action.type === "complete") {
|
|
260
|
+
const doingTasks = findDoingTasksForActor(state.snapshot, actor);
|
|
261
|
+
if (doingTasks.length === 0) {
|
|
262
|
+
throw new Error(`Actor ${actor} has no doing task to complete.`);
|
|
263
|
+
}
|
|
264
|
+
if (doingTasks.length > 1) {
|
|
265
|
+
throw new Error(`Actor ${actor} has multiple doing tasks: ${doingTasks.join(", ")}. Specify --task.`);
|
|
266
|
+
}
|
|
267
|
+
taskId = doingTasks[0];
|
|
268
|
+
}
|
|
269
|
+
if (!taskId)
|
|
270
|
+
taskId = requireNonEmpty("task", opts.task);
|
|
271
|
+
const resolvedOpts = { ...opts, task: taskId };
|
|
272
|
+
if (action.requireSingleDoing &&
|
|
273
|
+
!ensureActorCanClaimNext(state.snapshot, actor, allowMultipleDoing)) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const check = action.check(state, taskId, actor, resolvedOpts);
|
|
277
|
+
if (!check.ok) {
|
|
278
|
+
process.stdout.write(`Cannot ${action.type} ${taskId}: ${check.reason}\n`);
|
|
279
|
+
exitWithCode(false);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const event = buildEvent(action.type, resolvedOpts);
|
|
283
|
+
if (action.type === "claim") {
|
|
284
|
+
const plannedOwner = state.schedule.nodes.get(taskId)?.owner;
|
|
285
|
+
const claimOwner = resolveClaimOwner(resolvedOpts, actor, roster, plannedOwner);
|
|
286
|
+
const cpm = computeCpm(state.schedule, schedulePath);
|
|
287
|
+
writeGeneratedCore(schedulePath, state.events, state.schedule, cpm);
|
|
288
|
+
writeScheduleHashAndDiff(schedulePath, state.schedule);
|
|
289
|
+
writeCpmFiles(schedulePath, cpm, state.snapshot);
|
|
290
|
+
event.meta = {
|
|
291
|
+
...(event.meta ?? {}),
|
|
292
|
+
claim_owner: claimOwner,
|
|
293
|
+
};
|
|
294
|
+
if (plannedOwner)
|
|
295
|
+
event.meta.planned_owner = plannedOwner;
|
|
296
|
+
if (plannedOwner && claimOwner !== plannedOwner && resolvedOpts.allowOwnerMismatch) {
|
|
297
|
+
event.meta.owner_override = true;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (opts.dryRun) {
|
|
301
|
+
process.stdout.write(`[dry-run] ${JSON.stringify(event, null, 2)}\n`);
|
|
302
|
+
if (action.type === "release" && opts.resetWorktree) {
|
|
303
|
+
resetExecWorktreeForTask({
|
|
304
|
+
projectId: resolveProjectId(opts),
|
|
305
|
+
taskId,
|
|
306
|
+
schedulePath,
|
|
307
|
+
executionPath,
|
|
308
|
+
dryRun: true,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
exitWithCode(true);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const out = writeEventFile(schedulePath, event);
|
|
315
|
+
if (action.type === "claim") {
|
|
316
|
+
await scaffoldClaimResult({
|
|
317
|
+
schedulePath,
|
|
318
|
+
executionPath,
|
|
319
|
+
catalogPath,
|
|
320
|
+
taskId,
|
|
321
|
+
state,
|
|
322
|
+
projectId: resolveProjectId(opts),
|
|
323
|
+
actor,
|
|
324
|
+
startedAt: new Date().toISOString(),
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
// The release event has been persisted (the task is now todo), so a retained exec worktree is
|
|
328
|
+
// stale residue. --reset-worktree discards it eagerly instead of waiting for the next claim to
|
|
329
|
+
// clean it up via discardStaleExecWorktree.
|
|
330
|
+
if (action.type === "release" && opts.resetWorktree) {
|
|
331
|
+
resetExecWorktreeForTask({
|
|
332
|
+
projectId: resolveProjectId(opts),
|
|
333
|
+
taskId,
|
|
334
|
+
schedulePath,
|
|
335
|
+
executionPath,
|
|
336
|
+
dryRun: false,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
process.stdout.write(out + "\n");
|
|
340
|
+
exitWithCode(true);
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
printCommandError(error);
|
|
344
|
+
}
|
|
345
|
+
finally {
|
|
346
|
+
if (lockDir) {
|
|
347
|
+
try {
|
|
348
|
+
releaseSchedulerLock(lockDir);
|
|
349
|
+
}
|
|
350
|
+
catch { }
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// Discards the exec worktree and branch left behind by a now-released task. A released task is back
|
|
355
|
+
// in todo, so any retained worktree is stale residue. `dryRun` only prints what would be discarded.
|
|
356
|
+
export function resetExecWorktreeForTask(args) {
|
|
357
|
+
const worktreeTaskId = qualifyTaskId(args.projectId, args.taskId);
|
|
358
|
+
if (args.dryRun) {
|
|
359
|
+
process.stdout.write(`[dry-run] reset worktree: discard exec/${worktreeTaskId}\n`);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const discarded = discardStaleExecWorktree({
|
|
363
|
+
context: {
|
|
364
|
+
repoRoot: specdojoRootDir(),
|
|
365
|
+
schedulePath: args.schedulePath,
|
|
366
|
+
executionPath: args.executionPath,
|
|
367
|
+
},
|
|
368
|
+
worktreeTaskId,
|
|
369
|
+
// PJR-98G4: repos を宣言した project では、プロダクト側の worktree と exec branch も破棄する。
|
|
370
|
+
products: configuredProductRepos(args.schedulePath),
|
|
371
|
+
});
|
|
372
|
+
process.stdout.write(discarded
|
|
373
|
+
? `reset worktree: discarded ${discarded}\n`
|
|
374
|
+
: `reset worktree: no worktree or branch for ${worktreeTaskId}\n`);
|
|
375
|
+
}
|
|
376
|
+
// `release --all-blocked`: return every blocked task in the project to todo under a single scheduler
|
|
377
|
+
// lock. Tasks blocked by a different actor are skipped unless --force is given (humans only); each
|
|
378
|
+
// skip is reported with its reason. --reset-worktree discards each released task's stale worktree.
|
|
379
|
+
export async function runReleaseAllBlocked(opts) {
|
|
380
|
+
let lockDir = "";
|
|
381
|
+
try {
|
|
382
|
+
const { schedulePath, executionPath } = resolveProjectContext(opts);
|
|
383
|
+
const actor = requireNonEmpty("by", opts.by);
|
|
384
|
+
const roster = loadRosterForOpts(opts);
|
|
385
|
+
assertValidActor(actor, roster);
|
|
386
|
+
requireNonEmpty("msg", opts.msg);
|
|
387
|
+
if (opts.task) {
|
|
388
|
+
process.stdout.write("Note: --all-blocked ignores --task.\n");
|
|
389
|
+
}
|
|
390
|
+
const lockTimeoutMs = Number(opts.lockTimeoutMs);
|
|
391
|
+
const lockStaleMs = Number(opts.lockStaleMs);
|
|
392
|
+
lockDir = acquireSchedulerLock(schedulePath, { actor, lockTimeoutMs, lockStaleMs });
|
|
393
|
+
const state = loadValidatedExecState(schedulePath);
|
|
394
|
+
if (!state)
|
|
395
|
+
return;
|
|
396
|
+
const projectId = resolveProjectId(opts);
|
|
397
|
+
const blockedTaskIds = Object.entries(state.snapshot.tasks)
|
|
398
|
+
.filter(([, cs]) => cs.state === "blocked")
|
|
399
|
+
.map(([taskId]) => taskId)
|
|
400
|
+
.sort((a, b) => a.localeCompare(b));
|
|
401
|
+
if (blockedTaskIds.length === 0) {
|
|
402
|
+
process.stdout.write("No blocked tasks to release.\n");
|
|
403
|
+
exitWithCode(true);
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const released = [];
|
|
407
|
+
const skipped = [];
|
|
408
|
+
const override = resolveForceOverride(opts, actor);
|
|
409
|
+
// Releasing one task does not change another task's releasability, so a single snapshot read is
|
|
410
|
+
// sufficient even though the in-memory snapshot is not re-folded after each write.
|
|
411
|
+
for (const taskId of blockedTaskIds) {
|
|
412
|
+
const check = canReleaseTask(state.schedule, state.snapshot, taskId, actor, override);
|
|
413
|
+
if (!check.ok) {
|
|
414
|
+
skipped.push({ taskId, reason: check.reason ?? "not releasable" });
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
const event = buildEvent("release", { ...opts, task: taskId });
|
|
418
|
+
if (opts.dryRun) {
|
|
419
|
+
process.stdout.write(`[dry-run] ${JSON.stringify(event, null, 2)}\n`);
|
|
420
|
+
if (opts.resetWorktree) {
|
|
421
|
+
resetExecWorktreeForTask({
|
|
422
|
+
projectId,
|
|
423
|
+
taskId,
|
|
424
|
+
schedulePath,
|
|
425
|
+
executionPath,
|
|
426
|
+
dryRun: true,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
released.push(taskId);
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
const out = writeEventFile(schedulePath, event);
|
|
433
|
+
if (opts.resetWorktree) {
|
|
434
|
+
resetExecWorktreeForTask({ projectId, taskId, schedulePath, executionPath, dryRun: false });
|
|
435
|
+
}
|
|
436
|
+
process.stdout.write(out + "\n");
|
|
437
|
+
released.push(taskId);
|
|
438
|
+
}
|
|
439
|
+
const dryRunSuffix = opts.dryRun ? " (dry-run)" : "";
|
|
440
|
+
process.stdout.write(`\nReleased ${released.length} blocked task(s)${dryRunSuffix}; skipped ${skipped.length}.\n`);
|
|
441
|
+
for (const s of skipped) {
|
|
442
|
+
process.stdout.write(` skip ${s.taskId}: ${s.reason}\n`);
|
|
443
|
+
}
|
|
444
|
+
exitWithCode(true);
|
|
445
|
+
}
|
|
446
|
+
catch (error) {
|
|
447
|
+
printCommandError(error);
|
|
448
|
+
}
|
|
449
|
+
finally {
|
|
450
|
+
if (lockDir) {
|
|
451
|
+
try {
|
|
452
|
+
releaseSchedulerLock(lockDir);
|
|
453
|
+
}
|
|
454
|
+
catch { }
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extname, join, resolve } from "node:path";
|
|
2
2
|
import { mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { collectRepeatable, ensureDir, isUtcIsoSeconds, listFilesRecursive, nowUtcIsoSeconds, parseKeyValuePairs, randomHex, readJson, requireNonEmpty, safeSlug, sleepMs, toArtifactPath, tsForFilenameUtc, writeJson, } from "./
|
|
4
|
-
import { eventsDirForProject, executionRootForProject } from "./
|
|
3
|
+
import { collectRepeatable, ensureDir, isUtcIsoSeconds, listFilesRecursive, nowUtcIsoSeconds, parseKeyValuePairs, randomHex, readJson, requireNonEmpty, safeSlug, sleepMs, toArtifactPath, tsForFilenameUtc, writeJson, } from "./shared.js";
|
|
4
|
+
import { eventsDirForProject, executionRootForProject } from "./project.js";
|
|
5
5
|
export { collectRepeatable };
|
|
6
6
|
export function validateEventShape(obj, source) {
|
|
7
7
|
const errs = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join, relative, sep } from "node:path";
|
|
3
|
-
import { ensureDir, redactSensitiveText, safeSlug } from "./
|
|
4
|
-
import { gitOutput } from "./
|
|
3
|
+
import { ensureDir, redactSensitiveText, safeSlug } from "./shared.js";
|
|
4
|
+
import { gitOutput } from "./worktree.js";
|
|
5
5
|
const MAX_LOG_BYTES = 64 * 1024;
|
|
6
6
|
const MAX_CHANGE_FILES = 1_000;
|
|
7
7
|
const MAX_FINAL_MESSAGE_LENGTH = 4_000;
|
|
@@ -29,7 +29,7 @@ function boundedLog(value) {
|
|
|
29
29
|
truncated: true,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export { redactSensitiveText } from "./
|
|
32
|
+
export { redactSensitiveText } from "./shared.js";
|
|
33
33
|
function boundedText(value, limit) {
|
|
34
34
|
return truncate(redactSensitiveText(typeof value === "string" ? value.trim() : ""), limit);
|
|
35
35
|
}
|
|
@@ -311,6 +311,7 @@ export function buildExecutorEvidence(input) {
|
|
|
311
311
|
},
|
|
312
312
|
validations,
|
|
313
313
|
...(report.targetCoverage.length > 0 ? { target_coverage: report.targetCoverage } : {}),
|
|
314
|
+
...(input.rateLimitEvents?.length ? { rate_limit_events: input.rateLimitEvents } : {}),
|
|
314
315
|
final_message: report.finalMessage,
|
|
315
316
|
...(input.status === "succeeded"
|
|
316
317
|
? {}
|
|
@@ -374,6 +375,7 @@ export function recordExecutorEvidence(input) {
|
|
|
374
375
|
diffStat,
|
|
375
376
|
logRefPath: repoRelative(input.worktreePath, logPath),
|
|
376
377
|
parentValidations: input.parentValidations,
|
|
378
|
+
rateLimitEvents: input.rateLimitEvents,
|
|
377
379
|
});
|
|
378
380
|
writeFileSync(logPath, logExcerpt, "utf8");
|
|
379
381
|
writeFileSync(evidencePath, `${JSON.stringify(evidence, null, 2)}\n`, "utf8");
|
|
@@ -408,11 +410,12 @@ export function recordCommandEvidence(input) {
|
|
|
408
410
|
writeFileSync(stderrPath, boundedStderr.content, "utf8");
|
|
409
411
|
const stdoutRef = repoRelative(input.worktreePath, stdoutPath);
|
|
410
412
|
const stderrRef = repoRelative(input.worktreePath, stderrPath);
|
|
411
|
-
const succeeded = input.exitCode === 0
|
|
413
|
+
const succeeded = !input.error && (input.exitCode === 0 || input.accepted === true);
|
|
414
|
+
const acceptedNonzero = succeeded && input.exitCode !== 0;
|
|
412
415
|
const safeCommand = boundedText(input.command, 16_000);
|
|
413
416
|
const summary = input.error
|
|
414
417
|
? `spawn failed: ${boundedText(input.error, MAX_VALIDATION_SUMMARY_LENGTH)}`
|
|
415
|
-
: `exit ${input.exitCode ?? "unknown"}`;
|
|
418
|
+
: `exit ${input.exitCode ?? "unknown"}${acceptedNonzero ? " (accepted)" : ""}`;
|
|
416
419
|
const evidence = {
|
|
417
420
|
schema_version: 1,
|
|
418
421
|
task_id: input.taskId,
|
|
@@ -423,7 +426,9 @@ export function recordCommandEvidence(input) {
|
|
|
423
426
|
status: succeeded ? "succeeded" : "failed",
|
|
424
427
|
started_at: input.startedAt,
|
|
425
428
|
completed_at: input.completedAt,
|
|
426
|
-
|
|
429
|
+
// The stage exit code represents whether the executor pipeline may continue. The actual
|
|
430
|
+
// command exit code remains authoritative in command.exit_code below.
|
|
431
|
+
exit_code: succeeded ? 0 : input.exitCode,
|
|
427
432
|
attempts: 1,
|
|
428
433
|
},
|
|
429
434
|
changes,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../shared/markdown-format.js";
|
|
@@ -3,16 +3,16 @@ import { existsSync, lstatSync, mkdtempSync, readFileSync, readdirSync, rmSync,
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { createInterface } from "node:readline/promises";
|
|
5
5
|
import { join, posix, resolve } from "node:path";
|
|
6
|
-
import { isAgentProtectedConfigPath } from "./
|
|
7
|
-
import { PROTECTION_HANDOFF_MARKER } from "./
|
|
8
|
-
import { normalizePjrId, resolveRegisterRunTarget } from "./
|
|
9
|
-
import { refsTrailer, withCommitTrailers } from "./
|
|
10
|
-
import { configuredProductReposForProject } from "./
|
|
11
|
-
import { parseSpecdojoDocument } from "
|
|
12
|
-
import { qualifyTaskId } from "./
|
|
13
|
-
import { specdojoRootDir } from "
|
|
14
|
-
import { findExecWorktree, gitEnvironment, gitOutput, gitResult } from "./
|
|
15
|
-
import { stageCommitTargets, stabilizeCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "./
|
|
6
|
+
import { isAgentProtectedConfigPath } from "./agent-protected-config.js";
|
|
7
|
+
import { PROTECTION_HANDOFF_MARKER } from "./protection-handoff.js";
|
|
8
|
+
import { normalizePjrId, resolveRegisterRunTarget } from "./register.js";
|
|
9
|
+
import { refsTrailer, withCommitTrailers } from "./repo-trace.js";
|
|
10
|
+
import { configuredProductReposForProject } from "./task-repos.js";
|
|
11
|
+
import { parseSpecdojoDocument } from "../docs/frontmatter-namespace.js";
|
|
12
|
+
import { qualifyTaskId } from "./shared.js";
|
|
13
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
14
|
+
import { findExecWorktree, formatGitResultFailure, gitEnvironment, gitOutput, gitResult, } from "./worktree.js";
|
|
15
|
+
import { stageCommitTargets, stabilizeCommitTargets, unstageCommitTargets, worktreeStatusPaths, } from "./worktree-ops.js";
|
|
16
16
|
const HANDOFF_MECHANISM = "agent-config-write";
|
|
17
17
|
const TRUNCATED_EVIDENCE_RE = /^\.\.\. \((?:\d+ 行を省略|文字数上限で切り詰め)\)$/m;
|
|
18
18
|
function sectionAfterMarker(content) {
|
|
@@ -182,11 +182,12 @@ function applyAndCommit(repo, message) {
|
|
|
182
182
|
throw new Error(gitApplyError(applied));
|
|
183
183
|
try {
|
|
184
184
|
stageCommitTargets(repo.root, repo.paths);
|
|
185
|
-
const
|
|
185
|
+
const stagedArgs = ["diff", "--cached", "--quiet", "--", ...repo.paths];
|
|
186
|
+
const staged = gitResult(repo.root, stagedArgs);
|
|
186
187
|
if (staged.status !== 1) {
|
|
187
188
|
if (staged.status === 0)
|
|
188
189
|
throw new Error("The proposed patch produced no staged change.");
|
|
189
|
-
throw new Error(
|
|
190
|
+
throw new Error(`Could not inspect the staged handoff change: ${formatGitResultFailure(stagedArgs, staged)}`);
|
|
190
191
|
}
|
|
191
192
|
const commit = gitResult(repo.root, ["commit", "-m", message, "--", ...repo.paths]);
|
|
192
193
|
if (commit.status !== 0) {
|