specdojo 0.2.1 → 0.3.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 +165 -0
- package/CHANGELOG.md +298 -0
- package/README.md +92 -42
- package/dist/agent-response.js +20 -0
- package/dist/agent.js +4 -4
- package/dist/build-command.js +28 -8
- package/dist/catalog-build-references.js +144 -0
- package/dist/catalog-build-render.js +144 -0
- package/dist/catalog-build.js +13 -290
- package/dist/catalog-generate.js +6 -9
- package/dist/catalog-plan-generate.js +2 -2
- package/dist/catalog-plan.js +6 -6
- package/dist/catalog-scaffold.js +4 -4
- package/dist/catalog.js +2 -2
- package/dist/dashboard-exec-records.js +105 -0
- package/dist/dashboard-routines.js +255 -0
- package/dist/dashboard-shared.js +14 -0
- package/dist/dashboard-timeline.js +175 -0
- package/dist/dashboard.js +31 -444
- package/dist/deliverable-trash.js +3 -3
- package/dist/devcontainer-command.js +43 -0
- package/dist/devcontainer-scaffold.js +165 -0
- package/dist/doc-index.js +3 -3
- package/dist/exec-agent-config.js +107 -9
- package/dist/exec-agent-git-state.js +18 -0
- package/dist/exec-agent-protected-config.js +46 -8
- package/dist/exec-commands.js +557 -0
- package/dist/exec-core.js +457 -0
- package/dist/exec-evidence.js +254 -11
- package/dist/exec-handoff.js +336 -0
- package/dist/exec-parent-validation.js +317 -43
- package/dist/exec-pipeline-state.js +74 -9
- package/dist/exec-plans-core.js +693 -0
- package/dist/exec-plans-generation.js +206 -0
- package/dist/exec-plans-storage.js +131 -0
- package/dist/exec-plans.js +3 -1016
- package/dist/exec-protection-handoff.js +43 -2
- package/dist/exec-provider-scaffold.js +247 -15
- package/dist/exec-register-resume.js +65 -19
- package/dist/exec-register.js +9 -3
- package/dist/exec-repo-integration-git.js +23 -0
- package/dist/exec-repo-integration-sync.js +264 -0
- package/dist/exec-repo-integration.js +534 -0
- package/dist/exec-repo-trace.js +182 -0
- package/dist/exec-reporter-output.js +206 -0
- package/dist/exec-reporter.js +525 -248
- package/dist/exec-results.js +103 -71
- package/dist/exec-run-agent-pipeline.js +256 -0
- package/dist/exec-run-agent.js +531 -0
- package/dist/exec-run-in-place.js +541 -0
- package/dist/exec-run-job.js +717 -0
- package/dist/exec-run-lifecycle-commands.js +522 -0
- package/dist/exec-run-lock.js +110 -107
- package/dist/exec-run-mode-shared.js +140 -0
- package/dist/exec-run-register-command.js +244 -0
- package/dist/exec-run-register-core.js +386 -0
- package/dist/exec-run-register-mode.js +206 -0
- package/dist/exec-run-register-resume.js +393 -0
- package/dist/exec-run-register-state.js +322 -0
- package/dist/exec-run-register-worktree.js +509 -0
- package/dist/exec-run-schedule-mode.js +294 -0
- package/dist/exec-run-schedule-prepare.js +353 -0
- package/dist/exec-run-schedule-task.js +572 -0
- package/dist/exec-run-shared.js +399 -0
- package/dist/exec-run.js +11 -4953
- package/dist/exec-shared.js +9 -2
- package/dist/exec-slot-lock.js +242 -0
- package/dist/exec-task-repos.js +415 -0
- package/dist/exec-trial-commands.js +558 -0
- package/dist/exec-trial-core.js +371 -0
- package/dist/exec-trial.js +2 -895
- package/dist/exec-worktree-command.js +87 -43
- package/dist/exec-worktree-ops-commit.js +707 -0
- package/dist/exec-worktree-ops-lifecycle.js +292 -0
- package/dist/exec-worktree-ops-merge.js +303 -0
- package/dist/exec-worktree-ops.js +3 -847
- package/dist/exec-worktree.js +146 -31
- package/dist/exec.js +2 -999
- package/dist/frontmatter-namespace.js +2 -2
- 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-markdown.js +274 -0
- package/dist/grade-pipeline-state.js +184 -0
- package/dist/grade-plan.js +507 -0
- package/dist/grade-result.js +133 -5
- package/dist/grade-target-discovery.js +265 -0
- package/dist/grade-targets.js +432 -0
- package/dist/grade.js +14 -2451
- package/dist/init-command.js +443 -0
- package/dist/job-definition.js +670 -0
- package/dist/job.js +64 -578
- package/dist/kata-command.js +2 -2
- package/dist/orchestrator.js +213 -0
- package/dist/register-command-types.js +1 -0
- package/dist/register-core.js +363 -0
- package/dist/register-create-commands.js +245 -0
- package/dist/register-event-merge.js +169 -0
- package/dist/register-events.js +4 -4
- package/dist/register-item.js +13 -7
- package/dist/register-maintenance-commands.js +187 -0
- package/dist/register-migration.js +268 -0
- package/dist/register-renumber.js +314 -0
- package/dist/register-transition-commands.js +248 -0
- package/dist/register-update.js +230 -0
- package/dist/register-views.js +256 -0
- package/dist/register.js +175 -1975
- package/dist/review-grade.js +252 -0
- package/dist/review-plan.js +114 -4
- package/dist/review-types.js +40 -1
- package/dist/routine-definition.js +401 -0
- package/dist/routine.js +73 -402
- package/dist/schedule-approach.js +2 -2
- package/dist/schedule-build.js +2 -2
- package/dist/schedule-strategy-generate-document.js +273 -0
- package/dist/schedule-strategy-generate-scope.js +199 -0
- package/dist/schedule-strategy-generate.js +9 -473
- package/dist/schedule.js +19 -6
- package/dist/specdojo-config.js +465 -20
- package/dist/specdojo-gitignore.js +135 -0
- package/dist/specdojo.js +6 -0
- package/dist/viewpoint-document-kinds-check.js +128 -0
- package/dist/yaml-pages.js +4 -4
- package/dist/yaml.js +28 -0
- package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +348 -90
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +51 -17
- package/docs/ja/specdojo/exec-templates/xep-fully-guided-template.md +7 -5
- package/docs/ja/specdojo/exec-templates/xrp-freeform-template.md +29 -31
- package/docs/ja/specdojo/exec-templates/xrp-fully-guided-template.md +34 -55
- package/docs/ja/specdojo/exec-templates/xrp-job-template.md +54 -0
- package/docs/ja/specdojo/exec-templates/xrp-recipe-guided-template.md +28 -37
- package/docs/ja/specdojo/exec-templates/xrp-recipe-maintenance-template.md +29 -34
- package/docs/ja/specdojo/exec-templates/xrp-retrofit-template.md +30 -30
- package/docs/ja/specdojo/exec-templates/xrp-rulebook-maintenance-template.md +29 -34
- package/docs/ja/specdojo/exec-templates/xrp-sample-maintenance-template.md +29 -34
- package/docs/ja/specdojo/exec-templates/xrp-template-maintenance-template.md +29 -34
- package/docs/ja/specdojo/exec-templates/xrp-template.md +29 -28
- package/docs/ja/specdojo/exec-templates/xrr-template.md +11 -9
- package/docs/ja/specdojo/guides/docs-editing-guide.md +20 -0
- package/docs/ja/specdojo/guides/docs-structure-guide.md +103 -70
- package/docs/ja/specdojo/guides/exec-config-guide.md +93 -49
- package/docs/ja/specdojo/guides/exec-operation-guide.md +124 -27
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +40 -11
- package/docs/ja/specdojo/guides/kata-guide.md +4 -4
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +45 -22
- package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +1 -1
- package/docs/ja/specdojo/guides/practice-system-composition-guide.md +13 -13
- package/docs/ja/specdojo/guides/quick-start-guide.md +260 -30
- package/docs/ja/specdojo/guides/register-operation-guide.md +31 -14
- package/docs/ja/specdojo/guides/release-v0-3-0-migration-guide.md +264 -0
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +22 -1
- package/docs/ja/specdojo/guides/review-guide.md +195 -158
- package/docs/ja/specdojo/guides/routine-operation-guide.md +75 -10
- package/docs/ja/specdojo/guides/ryu-guide.md +32 -30
- package/docs/ja/specdojo/guides/schedule-design-guide.md +10 -10
- package/docs/ja/specdojo/guides/schedule-operation-guide.md +1 -1
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +58 -33
- package/docs/ja/specdojo/guides/use-case-guide.md +3 -3
- package/docs/ja/specdojo/guides/waza-guide.md +15 -2
- package/docs/ja/specdojo/index.md +2 -2
- package/docs/ja/specdojo/philosophy/specdojo-philosophy.md +5 -5
- package/docs/ja/specdojo/recipes/bps-recipe.md +213 -0
- package/docs/ja/specdojo/recipes/pm-members-recipe.md +52 -117
- package/docs/ja/specdojo/references/command-reference.md +335 -92
- package/docs/ja/specdojo/references/deliverables-reference.md +1 -1
- package/docs/ja/specdojo/references/directory-layout-reference.md +13 -9
- package/docs/ja/specdojo/references/specdojo-config-reference.md +107 -24
- package/docs/ja/specdojo/rulebooks/bps-rulebook.md +132 -220
- package/docs/ja/specdojo/rulebooks/br-rulebook.md +6 -44
- package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +2 -0
- package/docs/ja/specdojo/rulebooks/dmd-rulebook.md +0 -87
- package/docs/ja/specdojo/rulebooks/gl-rulebook.md +61 -39
- package/docs/ja/specdojo/rulebooks/ifx-cmd-rulebook.md +0 -87
- package/docs/ja/specdojo/rulebooks/ifx-index-rulebook.md +1 -33
- package/docs/ja/specdojo/rulebooks/opd-rulebook.md +0 -137
- package/docs/ja/specdojo/rulebooks/opr-rulebook.md +0 -247
- package/docs/ja/specdojo/rulebooks/otp-rulebook.md +0 -83
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +4 -2
- package/docs/ja/specdojo/rulebooks/pm-members-rulebook.md +78 -150
- package/docs/ja/specdojo/rulebooks/pm-roles-rulebook.md +5 -4
- package/docs/ja/specdojo/rulebooks/sch-rulebook.md +1 -1
- package/docs/ja/specdojo/rulebooks/stsd-mermaid-rulebook.md +0 -11
- package/docs/ja/specdojo/rulebooks/stsd-rulebook.md +0 -61
- package/docs/ja/specdojo/rulebooks/tml-rulebook.md +2 -47
- package/docs/ja/specdojo/samples/bps-sample.md +74 -21
- package/docs/ja/specdojo/samples/gl-sample.yaml +17 -1
- package/docs/ja/specdojo/samples/ifx-index-sample.yaml +28 -0
- package/docs/ja/specdojo/samples/pm-members-sample.yaml +2 -67
- package/docs/ja/specdojo/samples/pm-organization-sample.md +8 -7
- package/docs/ja/specdojo/samples/pm-raci-sample.md +1 -1
- package/docs/ja/specdojo/samples/tml-sample.yaml +40 -0
- package/docs/ja/specdojo/standards/document-metadata-standard.md +21 -16
- package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +14 -14
- package/docs/ja/specdojo/standards/job-definition-standard.md +37 -17
- package/docs/ja/specdojo/standards/people-and-organization-definition-standard.md +37 -32
- package/docs/ja/specdojo/standards/philosophy-authoring-standard.md +1 -1
- package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +21 -11
- package/docs/ja/specdojo/templates/agent-members-template.yaml +25 -0
- package/docs/ja/specdojo/templates/bps-template.md +91 -0
- package/docs/ja/specdojo/templates/pm-members-template.yaml +2 -59
- package/docs/specdojo/schemas/v1/agent-members.schema.yaml +76 -0
- package/docs/specdojo/schemas/v1/exec-common.schema.yaml +4 -2
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +55 -2
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +93 -6
- package/docs/specdojo/schemas/v1/exec-reporter-output.schema.yaml +27 -78
- package/docs/specdojo/schemas/v1/gl.schema.yaml +87 -0
- package/docs/specdojo/schemas/v1/grade-result.schema.yaml +33 -0
- package/docs/specdojo/schemas/v1/job-run.schema.yaml +27 -0
- package/docs/specdojo/schemas/v1/job.schema.yaml +25 -0
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +49 -1
- package/docs/specdojo/schemas/v1/pm-members.schema.yaml +9 -169
- package/docs/specdojo/schemas/v1/pm-review-viewpoints.schema.yaml +100 -10
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +13 -0
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +3 -0
- package/docs/specdojo/schemas/v1/routine.schema.yaml +7 -0
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +110 -0
- package/package.json +17 -12
- package/templates/antigravity/README.md +29 -4
- package/templates/antigravity/{pm-members-snippet.yaml → agent-members-snippet.yaml} +8 -2
- package/templates/antigravity/exec-defaults-snippet.yaml +10 -7
- package/templates/antigravity/orchestrator.md +18 -7
- package/templates/antigravity/settings.global.json +55 -0
- package/templates/claude/agents/claude-executor.md +14 -0
- package/templates/claude/agents/claude-reporter.md +16 -0
- package/templates/claude/agents/specdojo-orchestrator.md +18 -7
- package/templates/claude/settings.edit.json +27 -1
- package/templates/codex/README.md +5 -4
- package/templates/codex/agents/specdojo-orchestrator.toml +18 -7
- package/templates/codex/orchestrator.md +18 -7
- package/templates/copilot/README.md +7 -5
- package/templates/copilot/{pm-members-snippet.yaml → agent-members-snippet.yaml} +4 -2
- package/templates/devcontainer/devcontainer.json +27 -0
- package/templates/devcontainer/emacs/init.el +88 -0
- package/templates/devcontainer/post-create.sh +62 -0
- package/templates/init-agent-members.yaml +200 -0
- package/templates/init-exec-defaults.yaml +74 -0
- package/templates/opencode/agents/specdojo-orchestrator.md +18 -7
- package/docs/ja/specdojo/exec-templates/xrp-viewpoint-detail-template.md +0 -7
- package/docs/ja/specdojo/exec-templates/xrr-viewpoint-detail-template.md +0 -7
package/dist/routine.js
CHANGED
|
@@ -1,407 +1,15 @@
|
|
|
1
1
|
import { spawnSync } from "node:child_process";
|
|
2
2
|
import { appendFileSync, existsSync, mkdirSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { ensureFreshDistBuildForEntry } from "./dist-freshness.js";
|
|
6
|
-
import { selfRunArgs } from "./spawn-self.js";
|
|
7
|
-
import { getProjectRoutinesPath, loadConfig, loadEnv, specdojoRootDir } from "./specdojo-config.js";
|
|
8
|
-
import { ensureDir, listFilesRecursive, nowUtcIsoSeconds, padEndDisplay, readJson, readYaml, writeJson, } from "./exec-shared.js";
|
|
9
6
|
import { ROUTINE_BUSY_SKIP_EXIT_CODE, ROUTINE_EXEC_ENV } from "./exec-run-lock.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Interval / due
|
|
17
|
-
// ================================
|
|
18
|
-
const INTERVAL_UNIT_MS = {
|
|
19
|
-
m: 60_000,
|
|
20
|
-
h: 3_600_000,
|
|
21
|
-
d: 86_400_000,
|
|
22
|
-
w: 604_800_000,
|
|
23
|
-
};
|
|
24
|
-
// interval は `<正の整数><単位>` 形式(m: 分, h: 時間, d: 日, w: 週)。
|
|
25
|
-
export function parseIntervalMs(text) {
|
|
26
|
-
const match = text.trim().match(/^([1-9]\d*)(m|h|d|w)$/);
|
|
27
|
-
if (!match) {
|
|
28
|
-
throw new Error(`Invalid interval: "${text}". Use <positive integer><unit> with unit m|h|d|w (e.g. 30m, 6h, 1d, 1w)`);
|
|
29
|
-
}
|
|
30
|
-
return Number.parseInt(match[1], 10) * INTERVAL_UNIT_MS[match[2]];
|
|
31
|
-
}
|
|
32
|
-
// last_run が無い(未実行)または不正な場合は due とみなす。
|
|
33
|
-
export function isRoutineDue(doc, lastRun, now) {
|
|
34
|
-
if (!doc.interval)
|
|
35
|
-
return cronOccurrences(doc, lastRun, now).length > 0;
|
|
36
|
-
if (!lastRun)
|
|
37
|
-
return true;
|
|
38
|
-
const last = new Date(lastRun);
|
|
39
|
-
if (Number.isNaN(last.getTime()))
|
|
40
|
-
return true;
|
|
41
|
-
return now.getTime() - last.getTime() >= parseIntervalMs(doc.interval);
|
|
42
|
-
}
|
|
43
|
-
function parseCronField(text, min, max, label) {
|
|
44
|
-
const result = new Set();
|
|
45
|
-
for (const token of text.split(",")) {
|
|
46
|
-
const [base, stepText] = token.split("/");
|
|
47
|
-
const step = stepText === undefined ? 1 : Number(stepText);
|
|
48
|
-
if (!Number.isSafeInteger(step) || step < 1)
|
|
49
|
-
throw new Error(`Invalid cron ${label}: ${text}`);
|
|
50
|
-
let start;
|
|
51
|
-
let end;
|
|
52
|
-
if (base === "*") {
|
|
53
|
-
start = min;
|
|
54
|
-
end = max;
|
|
55
|
-
}
|
|
56
|
-
else if (base.includes("-")) {
|
|
57
|
-
const parts = base.split("-").map(Number);
|
|
58
|
-
if (parts.length !== 2)
|
|
59
|
-
throw new Error(`Invalid cron ${label}: ${text}`);
|
|
60
|
-
[start, end] = parts;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
start = Number(base);
|
|
64
|
-
end = start;
|
|
65
|
-
}
|
|
66
|
-
if (!Number.isSafeInteger(start) ||
|
|
67
|
-
!Number.isSafeInteger(end) ||
|
|
68
|
-
start < min ||
|
|
69
|
-
end > max ||
|
|
70
|
-
start > end) {
|
|
71
|
-
throw new Error(`Invalid cron ${label}: ${text}`);
|
|
72
|
-
}
|
|
73
|
-
for (let value = start; value <= end; value += step)
|
|
74
|
-
result.add(value);
|
|
75
|
-
}
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
export function parseCronExpression(expression) {
|
|
79
|
-
const fields = expression.trim().split(/\s+/);
|
|
80
|
-
if (fields.length !== 5)
|
|
81
|
-
throw new Error(`Invalid cron expression: "${expression}" (expected 5 fields)`);
|
|
82
|
-
return [
|
|
83
|
-
parseCronField(fields[0], 0, 59, "minute"),
|
|
84
|
-
parseCronField(fields[1], 0, 23, "hour"),
|
|
85
|
-
parseCronField(fields[2], 1, 31, "day-of-month"),
|
|
86
|
-
parseCronField(fields[3], 1, 12, "month"),
|
|
87
|
-
parseCronField(fields[4], 0, 6, "day-of-week"),
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
function zonedParts(date, timezone) {
|
|
91
|
-
const parts = new Intl.DateTimeFormat("en-US", {
|
|
92
|
-
timeZone: timezone,
|
|
93
|
-
minute: "numeric",
|
|
94
|
-
hour: "numeric",
|
|
95
|
-
day: "numeric",
|
|
96
|
-
month: "numeric",
|
|
97
|
-
weekday: "short",
|
|
98
|
-
hourCycle: "h23",
|
|
99
|
-
}).formatToParts(date);
|
|
100
|
-
const value = (type) => parts.find((part) => part.type === type)?.value ?? "";
|
|
101
|
-
const weekday = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"].indexOf(value("weekday"));
|
|
102
|
-
return [
|
|
103
|
-
Number(value("minute")),
|
|
104
|
-
Number(value("hour")),
|
|
105
|
-
Number(value("day")),
|
|
106
|
-
Number(value("month")),
|
|
107
|
-
weekday,
|
|
108
|
-
];
|
|
109
|
-
}
|
|
110
|
-
export function cronMatches(expression, timezone, date) {
|
|
111
|
-
const fields = parseCronExpression(expression);
|
|
112
|
-
const parts = zonedParts(date, timezone);
|
|
113
|
-
return fields.every((field, index) => field.has(parts[index]));
|
|
114
|
-
}
|
|
115
|
-
const MAX_CRON_LOOKBACK_MINUTES = 366 * 24 * 60;
|
|
116
|
-
export function cronOccurrences(doc, lastScheduledFor, now) {
|
|
117
|
-
if (!doc.trigger)
|
|
118
|
-
return [];
|
|
119
|
-
const nowMinute = new Date(Math.floor(now.getTime() / 60_000) * 60_000);
|
|
120
|
-
const parsedLast = lastScheduledFor ? new Date(lastScheduledFor) : null;
|
|
121
|
-
if (parsedLast && Number.isNaN(parsedLast.getTime()))
|
|
122
|
-
return cronOccurrences(doc, undefined, now);
|
|
123
|
-
if (doc.policy?.missed_run === "skip") {
|
|
124
|
-
const lastMinute = parsedLast
|
|
125
|
-
? Math.floor(parsedLast.getTime() / 60_000) * 60_000
|
|
126
|
-
: Number.NEGATIVE_INFINITY;
|
|
127
|
-
return nowMinute.getTime() > lastMinute &&
|
|
128
|
-
cronMatches(doc.trigger.cron, doc.trigger.timezone, nowMinute)
|
|
129
|
-
? [nowMinute]
|
|
130
|
-
: [];
|
|
131
|
-
}
|
|
132
|
-
if (!parsedLast) {
|
|
133
|
-
for (let offset = 0; offset <= MAX_CRON_LOOKBACK_MINUTES; offset++) {
|
|
134
|
-
const candidate = new Date(nowMinute.getTime() - offset * 60_000);
|
|
135
|
-
if (cronMatches(doc.trigger.cron, doc.trigger.timezone, candidate))
|
|
136
|
-
return [candidate];
|
|
137
|
-
}
|
|
138
|
-
return [];
|
|
139
|
-
}
|
|
140
|
-
const occurrences = [];
|
|
141
|
-
let cursor = Math.floor(parsedLast.getTime() / 60_000) * 60_000 + 60_000;
|
|
142
|
-
const maxStart = nowMinute.getTime() - MAX_CRON_LOOKBACK_MINUTES * 60_000;
|
|
143
|
-
if (cursor < maxStart)
|
|
144
|
-
cursor = maxStart;
|
|
145
|
-
for (; cursor <= nowMinute.getTime(); cursor += 60_000) {
|
|
146
|
-
const candidate = new Date(cursor);
|
|
147
|
-
if (cronMatches(doc.trigger.cron, doc.trigger.timezone, candidate))
|
|
148
|
-
occurrences.push(candidate);
|
|
149
|
-
if (occurrences.length > 1000)
|
|
150
|
-
throw new Error(`Too many missed cron occurrences for ${doc.id}`);
|
|
151
|
-
}
|
|
152
|
-
return doc.policy?.missed_run === "all" ? occurrences : occurrences.slice(-1);
|
|
153
|
-
}
|
|
154
|
-
export function isoWeek(date, timezone) {
|
|
155
|
-
const local = new Intl.DateTimeFormat("en-CA", {
|
|
156
|
-
timeZone: timezone,
|
|
157
|
-
year: "numeric",
|
|
158
|
-
month: "2-digit",
|
|
159
|
-
day: "2-digit",
|
|
160
|
-
}).format(date);
|
|
161
|
-
const [year, month, day] = local.split("-").map(Number);
|
|
162
|
-
const value = new Date(Date.UTC(year, month - 1, day));
|
|
163
|
-
const weekday = value.getUTCDay() || 7;
|
|
164
|
-
value.setUTCDate(value.getUTCDate() + 4 - weekday);
|
|
165
|
-
const weekYear = value.getUTCFullYear();
|
|
166
|
-
const first = new Date(Date.UTC(weekYear, 0, 1));
|
|
167
|
-
const week = Math.ceil(((value.getTime() - first.getTime()) / 86_400_000 + 1) / 7);
|
|
168
|
-
return `${weekYear}-W${String(week).padStart(2, "0")}`;
|
|
169
|
-
}
|
|
170
|
-
// ================================
|
|
171
|
-
// Validation
|
|
172
|
-
// ================================
|
|
173
|
-
function isRecord(value) {
|
|
174
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
175
|
-
}
|
|
176
|
-
function parseRoutineAction(value, fieldName, errors) {
|
|
177
|
-
if (!isRecord(value)) {
|
|
178
|
-
errors.push(`${fieldName} must be a mapping with kind`);
|
|
179
|
-
return undefined;
|
|
180
|
-
}
|
|
181
|
-
const kind = typeof value.kind === "string" ? value.kind : "";
|
|
182
|
-
if (kind === "specdojo") {
|
|
183
|
-
const unknownKeys = Object.keys(value).filter((key) => key !== "kind" && key !== "args");
|
|
184
|
-
if (unknownKeys.length > 0) {
|
|
185
|
-
errors.push(`${fieldName} has unknown key(s): ${unknownKeys.sort().join(", ")}`);
|
|
186
|
-
}
|
|
187
|
-
const args = value.args;
|
|
188
|
-
if (!Array.isArray(args) ||
|
|
189
|
-
args.length === 0 ||
|
|
190
|
-
args.some((item) => typeof item !== "string" || item.length === 0)) {
|
|
191
|
-
errors.push(`${fieldName}.args must be a non-empty list of strings`);
|
|
192
|
-
return undefined;
|
|
193
|
-
}
|
|
194
|
-
if (args.includes("exec") || args.includes("--project")) {
|
|
195
|
-
errors.push(`${fieldName}.args must not include exec or --project (project is appended)`);
|
|
196
|
-
return undefined;
|
|
197
|
-
}
|
|
198
|
-
return { kind: "specdojo", args: args };
|
|
199
|
-
}
|
|
200
|
-
const unknownKeys = Object.keys(value).filter((key) => key !== "kind" && key !== "job" && key !== "inputs");
|
|
201
|
-
if (unknownKeys.length > 0) {
|
|
202
|
-
errors.push(`${fieldName} has unknown key(s): ${unknownKeys.sort().join(", ")}`);
|
|
203
|
-
}
|
|
204
|
-
if (kind !== "job") {
|
|
205
|
-
errors.push(`${fieldName}.kind must be job or specdojo (got "${kind}")`);
|
|
206
|
-
}
|
|
207
|
-
if (typeof value.job !== "string" || !/^job-[a-z0-9][a-z0-9-]*$/.test(value.job)) {
|
|
208
|
-
errors.push(`${fieldName}.job must match job-<slug>`);
|
|
209
|
-
}
|
|
210
|
-
if (value.inputs !== undefined &&
|
|
211
|
-
(!isRecord(value.inputs) ||
|
|
212
|
-
Object.values(value.inputs).some((item) => typeof item !== "string"))) {
|
|
213
|
-
errors.push(`${fieldName}.inputs must be a mapping of string values`);
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
kind: "job",
|
|
217
|
-
job: typeof value.job === "string" ? value.job : "",
|
|
218
|
-
...(isRecord(value.inputs) ? { inputs: value.inputs } : {}),
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
// rtn-*.yaml 1 ファイルぶんを検証し、妥当なら RoutineDoc として返す。
|
|
222
|
-
// id はファイル名(拡張子なし)と一致させ、doc-index と同じ「ファイル名 = id」規約に揃える。
|
|
223
|
-
export function parseRoutineDoc(value, fileName) {
|
|
224
|
-
const errors = [];
|
|
225
|
-
if (!isRecord(value)) {
|
|
226
|
-
return { errors: [`${fileName}: routine file must be a YAML mapping`] };
|
|
227
|
-
}
|
|
228
|
-
const expectedId = fileName.replace(/\.(yaml|yml)$/, "");
|
|
229
|
-
const id = typeof value.id === "string" ? value.id.trim() : "";
|
|
230
|
-
if (!id) {
|
|
231
|
-
errors.push("id is required");
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
if (!/^rtn-[a-z0-9][a-z0-9-]*$/.test(id)) {
|
|
235
|
-
errors.push(`id "${id}" must match rtn-<slug> (lowercase letters, digits, hyphens)`);
|
|
236
|
-
}
|
|
237
|
-
if (id !== expectedId) {
|
|
238
|
-
errors.push(`id "${id}" must match the file name base "${expectedId}"`);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (value.enabled !== undefined && typeof value.enabled !== "boolean") {
|
|
242
|
-
errors.push("enabled must be a boolean");
|
|
243
|
-
}
|
|
244
|
-
const interval = typeof value.interval === "string" ? value.interval.trim() : "";
|
|
245
|
-
const trigger = isRecord(value.trigger) ? value.trigger : undefined;
|
|
246
|
-
if (!interval && !trigger) {
|
|
247
|
-
errors.push("interval or trigger is required");
|
|
248
|
-
}
|
|
249
|
-
if (interval && trigger)
|
|
250
|
-
errors.push("specify either interval or trigger, not both");
|
|
251
|
-
if (interval) {
|
|
252
|
-
try {
|
|
253
|
-
parseIntervalMs(interval);
|
|
254
|
-
}
|
|
255
|
-
catch (error) {
|
|
256
|
-
errors.push(error instanceof Error ? error.message : String(error));
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
let parsedTrigger;
|
|
260
|
-
if (trigger) {
|
|
261
|
-
const cron = typeof trigger.cron === "string" ? trigger.cron.trim() : "";
|
|
262
|
-
const timezone = typeof trigger.timezone === "string" ? trigger.timezone.trim() : "";
|
|
263
|
-
if (!cron)
|
|
264
|
-
errors.push("trigger.cron is required");
|
|
265
|
-
else {
|
|
266
|
-
try {
|
|
267
|
-
parseCronExpression(cron);
|
|
268
|
-
}
|
|
269
|
-
catch (error) {
|
|
270
|
-
errors.push(error instanceof Error ? error.message : String(error));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (!timezone)
|
|
274
|
-
errors.push("trigger.timezone is required");
|
|
275
|
-
else {
|
|
276
|
-
try {
|
|
277
|
-
new Intl.DateTimeFormat("en-US", { timeZone: timezone }).format();
|
|
278
|
-
}
|
|
279
|
-
catch {
|
|
280
|
-
errors.push(`Invalid trigger.timezone: ${timezone}`);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
if (cron && timezone)
|
|
284
|
-
parsedTrigger = { cron, timezone };
|
|
285
|
-
}
|
|
286
|
-
let policy;
|
|
287
|
-
if (value.policy !== undefined) {
|
|
288
|
-
if (!isRecord(value.policy))
|
|
289
|
-
errors.push("policy must be a mapping");
|
|
290
|
-
else {
|
|
291
|
-
const missed = value.policy.missed_run;
|
|
292
|
-
const overlap = value.policy.overlap;
|
|
293
|
-
if (missed !== undefined && missed !== "skip" && missed !== "latest" && missed !== "all") {
|
|
294
|
-
errors.push("policy.missed_run must be skip, latest, or all");
|
|
295
|
-
}
|
|
296
|
-
if (overlap !== undefined && overlap !== "skip")
|
|
297
|
-
errors.push("policy.overlap must be skip");
|
|
298
|
-
policy = {
|
|
299
|
-
...(missed === "skip" || missed === "latest" || missed === "all"
|
|
300
|
-
? { missed_run: missed }
|
|
301
|
-
: {}),
|
|
302
|
-
...(overlap === "skip" ? { overlap } : {}),
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
let action;
|
|
307
|
-
if (Array.isArray(value.action)) {
|
|
308
|
-
if (value.action.length === 0)
|
|
309
|
-
errors.push("action must contain at least one action");
|
|
310
|
-
const parsed = value.action.map((item, index) => parseRoutineAction(item, `action[${index}]`, errors));
|
|
311
|
-
if (parsed.every((item) => item !== undefined))
|
|
312
|
-
action = parsed;
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
action = parseRoutineAction(value.action, "action", errors);
|
|
316
|
-
}
|
|
317
|
-
if (errors.length > 0 || action === undefined) {
|
|
318
|
-
return { errors: errors.map((message) => `${fileName}: ${message}`) };
|
|
319
|
-
}
|
|
320
|
-
const doc = {
|
|
321
|
-
id,
|
|
322
|
-
...(typeof value.name === "string" ? { name: value.name } : {}),
|
|
323
|
-
...(typeof value.description === "string" ? { description: value.description } : {}),
|
|
324
|
-
...(typeof value.enabled === "boolean" ? { enabled: value.enabled } : {}),
|
|
325
|
-
...(interval ? { interval } : {}),
|
|
326
|
-
...(parsedTrigger ? { trigger: parsedTrigger } : {}),
|
|
327
|
-
...(policy ? { policy } : {}),
|
|
328
|
-
action,
|
|
329
|
-
};
|
|
330
|
-
return { doc, errors: [] };
|
|
331
|
-
}
|
|
332
|
-
// ================================
|
|
333
|
-
// Path resolution / loading
|
|
334
|
-
// ================================
|
|
335
|
-
export function resolveRoutinePaths(opts) {
|
|
336
|
-
loadEnv();
|
|
337
|
-
const { config, configPath } = loadConfig();
|
|
338
|
-
const baseDir = specdojoRootDir();
|
|
339
|
-
if (!config) {
|
|
340
|
-
throw new Error(`routine commands require specdojo.config.json.\nRun: specdojo config init`);
|
|
341
|
-
}
|
|
342
|
-
const projectId = opts.project?.trim() ||
|
|
343
|
-
process.env.SPECDOJO_PROJECT?.trim() ||
|
|
344
|
-
config.current_project?.trim() ||
|
|
345
|
-
Object.keys(config.projects)[0] ||
|
|
346
|
-
"";
|
|
347
|
-
if (!projectId) {
|
|
348
|
-
throw new Error(`No project specified. Use --project <id> or SPECDOJO_PROJECT.`);
|
|
349
|
-
}
|
|
350
|
-
const project = config.projects[projectId];
|
|
351
|
-
if (!project) {
|
|
352
|
-
throw new Error(`Unknown project: ${projectId} (check ${configPath})`);
|
|
353
|
-
}
|
|
354
|
-
const routinesPath = getProjectRoutinesPath(project);
|
|
355
|
-
if (!routinesPath) {
|
|
356
|
-
throw new Error(`routines_path not set for project '${projectId}' in ${configPath}.\n` +
|
|
357
|
-
`Add "routines_path": "<path>" to the project config.`);
|
|
358
|
-
}
|
|
359
|
-
const absRoutinesPath = resolve(baseDir, routinesPath);
|
|
360
|
-
const generatedPath = join(absRoutinesPath, "generated");
|
|
361
|
-
return {
|
|
362
|
-
projectId,
|
|
363
|
-
routinesPath: absRoutinesPath,
|
|
364
|
-
generatedPath,
|
|
365
|
-
statePath: join(generatedPath, "routine-state.json"),
|
|
366
|
-
runsPath: join(generatedPath, "routine-runs.jsonl"),
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
function isRoutineYamlFile(filePath) {
|
|
370
|
-
return /^rtn-.+\.(yaml|yml)$/.test(basename(filePath));
|
|
371
|
-
}
|
|
372
|
-
// routines ディレクトリ配下の rtn-*.yaml を読み込む。ファイル列挙順に依存しないよう
|
|
373
|
-
// ソートし、パース失敗・検証エラー・id 重複はファイル名つきで集約して返す。
|
|
374
|
-
export function loadRoutines(routinesPath) {
|
|
375
|
-
const routines = [];
|
|
376
|
-
const errors = [];
|
|
377
|
-
const seenIds = new Map();
|
|
378
|
-
const files = listFilesRecursive(routinesPath).filter(isRoutineYamlFile).sort();
|
|
379
|
-
for (const filePath of files) {
|
|
380
|
-
const fileName = basename(filePath);
|
|
381
|
-
let raw;
|
|
382
|
-
try {
|
|
383
|
-
raw = readYaml(filePath);
|
|
384
|
-
}
|
|
385
|
-
catch (error) {
|
|
386
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
387
|
-
errors.push(`${fileName}: YAML parse error: ${message}`);
|
|
388
|
-
continue;
|
|
389
|
-
}
|
|
390
|
-
const parsed = parseRoutineDoc(raw, fileName);
|
|
391
|
-
if (!parsed.doc) {
|
|
392
|
-
errors.push(...parsed.errors);
|
|
393
|
-
continue;
|
|
394
|
-
}
|
|
395
|
-
const duplicatePath = seenIds.get(parsed.doc.id);
|
|
396
|
-
if (duplicatePath) {
|
|
397
|
-
errors.push(`${fileName}: duplicate routine id "${parsed.doc.id}" (also in ${duplicatePath})`);
|
|
398
|
-
continue;
|
|
399
|
-
}
|
|
400
|
-
seenIds.set(parsed.doc.id, fileName);
|
|
401
|
-
routines.push({ filePath, doc: parsed.doc });
|
|
402
|
-
}
|
|
403
|
-
return { routines, errors };
|
|
404
|
-
}
|
|
7
|
+
import { ensureDir, listFilesRecursive, nowUtcIsoSeconds, padEndDisplay, readJson, writeJson, } from "./exec-shared.js";
|
|
8
|
+
import { jobDeclaresReview, jobRunUsesReviewedIntegration, loadJobDefinition, resolveJobPaths, resolveJobReviewAgentNominations, } from "./job.js";
|
|
9
|
+
import { cronOccurrences, isRecord, isRoutineDue, isRoutineYamlFile, isoWeek, loadRoutines, resolveRoutinePaths, routineActionKindLabel, } from "./routine-definition.js";
|
|
10
|
+
import { selfRunArgs } from "./spawn-self.js";
|
|
11
|
+
import { specdojoRootDir } from "./specdojo-config.js";
|
|
12
|
+
export { cronMatches, cronOccurrences, isRoutineDue, isoWeek, loadRoutines, parseCronExpression, parseIntervalMs, parseRoutineDoc, resolveRoutinePaths, routineActionKindLabel, } from "./routine-definition.js";
|
|
405
13
|
// ================================
|
|
406
14
|
// State
|
|
407
15
|
// ================================
|
|
@@ -473,13 +81,36 @@ function ensureFreshDistForRoutineRun() {
|
|
|
473
81
|
}
|
|
474
82
|
return result.outcome !== "rebuild-failed";
|
|
475
83
|
}
|
|
84
|
+
let lastRoutineSpawnReason;
|
|
85
|
+
let lastRoutineSpawnRunId;
|
|
476
86
|
function spawnSelf(args) {
|
|
87
|
+
lastRoutineSpawnReason = undefined;
|
|
88
|
+
lastRoutineSpawnRunId = undefined;
|
|
477
89
|
const [exe, fullArgs] = selfRunArgs(args);
|
|
478
90
|
const result = spawnSync(exe, fullArgs, {
|
|
479
|
-
|
|
91
|
+
encoding: "utf8",
|
|
92
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
93
|
+
maxBuffer: 128 * 1024 * 1024,
|
|
480
94
|
cwd: specdojoRootDir(),
|
|
481
95
|
env: { ...process.env, [ROUTINE_EXEC_ENV]: "1" },
|
|
482
96
|
});
|
|
97
|
+
if (result.stdout)
|
|
98
|
+
process.stdout.write(result.stdout);
|
|
99
|
+
if (result.stderr)
|
|
100
|
+
process.stderr.write(result.stderr);
|
|
101
|
+
const output = `${result.stdout ?? ""}\n${result.stderr ?? ""}`;
|
|
102
|
+
const marker = [...output.matchAll(/^\[routine-job\]\s+([^\n]+)$/gm)].at(-1)?.[1];
|
|
103
|
+
if (marker) {
|
|
104
|
+
lastRoutineSpawnRunId = marker.match(/\brun_id=([^\s]+)/)?.[1];
|
|
105
|
+
lastRoutineSpawnReason = marker.match(/\breason=(.+)$/)?.[1]?.trim();
|
|
106
|
+
}
|
|
107
|
+
if (!lastRoutineSpawnReason && result.status !== 0) {
|
|
108
|
+
lastRoutineSpawnReason = String(result.stderr ?? "")
|
|
109
|
+
.split(/\r?\n/)
|
|
110
|
+
.map((line) => line.trim())
|
|
111
|
+
.filter(Boolean)
|
|
112
|
+
.at(-1);
|
|
113
|
+
}
|
|
483
114
|
if (result.status === ROUTINE_BUSY_SKIP_EXIT_CODE)
|
|
484
115
|
return "skipped";
|
|
485
116
|
return result.status === 0 ? "success" : "failure";
|
|
@@ -504,11 +135,30 @@ export function buildJobRunArgs(action, projectId, scheduledAt, timezone = "UTC"
|
|
|
504
135
|
"--if-busy",
|
|
505
136
|
"skip",
|
|
506
137
|
];
|
|
138
|
+
// action.commit is kept for compatibility. A Job that declares task.review is reviewed by
|
|
139
|
+
// exec run regardless of this flag, so the Job's declaration takes precedence.
|
|
140
|
+
if (action.commit)
|
|
141
|
+
args.push("--worktree");
|
|
507
142
|
for (const [key, value] of Object.entries(action.inputs ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
|
|
508
143
|
args.push("--input", `${key}=${renderRoutineInput(value, scheduledAt, timezone)}`);
|
|
509
144
|
}
|
|
510
145
|
return args;
|
|
511
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Describes how a job action's Run is integrated and which review agents the Job nominates.
|
|
149
|
+
* The Job's task.review declaration wins over the legacy routine `commit`; routine never
|
|
150
|
+
* passes --review-by / --reporter-by, so an agent without a Job nomination is auto selected.
|
|
151
|
+
*/
|
|
152
|
+
export function describeJobActionReview(action, definition) {
|
|
153
|
+
if (!jobRunUsesReviewedIntegration(definition, { worktree: action.commit === true })) {
|
|
154
|
+
return "review: none (in-place)";
|
|
155
|
+
}
|
|
156
|
+
const source = jobDeclaresReview(definition)
|
|
157
|
+
? "job task.review"
|
|
158
|
+
: "routine action.commit (compat)";
|
|
159
|
+
const nominations = resolveJobReviewAgentNominations({}, definition);
|
|
160
|
+
return `review: ${source} (executor=${nominations.executor?.nickname ?? "auto"}, reporter=${nominations.reporter?.nickname ?? "auto"})`;
|
|
161
|
+
}
|
|
512
162
|
export function aggregateRoutineActionResults(results) {
|
|
513
163
|
if (results.includes("failure"))
|
|
514
164
|
return "failure";
|
|
@@ -528,7 +178,18 @@ function executeRoutineAction(doc, action, projectId, dryRun, scheduledAt = new
|
|
|
528
178
|
? buildSpecdojoActionArgs(action, projectId)
|
|
529
179
|
: buildJobRunArgs(action, projectId, scheduledAt, doc.trigger?.timezone ?? "UTC");
|
|
530
180
|
if (dryRun) {
|
|
181
|
+
lastRoutineSpawnReason = undefined;
|
|
182
|
+
lastRoutineSpawnRunId = undefined;
|
|
531
183
|
process.stdout.write(` [dry-run] specdojo ${args.join(" ")}\n`);
|
|
184
|
+
if (action.kind === "job") {
|
|
185
|
+
try {
|
|
186
|
+
const definition = loadJobDefinition(resolveJobPaths(projectId), action.job);
|
|
187
|
+
process.stdout.write(` [dry-run] ${describeJobActionReview(action, definition)}\n`);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
process.stdout.write(` [dry-run] review: unknown (${error instanceof Error ? error.message : String(error)})\n`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
532
193
|
return "success";
|
|
533
194
|
}
|
|
534
195
|
return spawnSelf(args);
|
|
@@ -573,7 +234,8 @@ function executeRoutine(routine, projectId, dryRun, scheduledAt = new Date()) {
|
|
|
573
234
|
const jobRunId = dryRun ? undefined : findJobRunId(doc.action, projectId, scheduledAt);
|
|
574
235
|
return {
|
|
575
236
|
result,
|
|
576
|
-
jobRunIds: jobRunId ? [jobRunId] : [],
|
|
237
|
+
jobRunIds: lastRoutineSpawnRunId ? [lastRoutineSpawnRunId] : jobRunId ? [jobRunId] : [],
|
|
238
|
+
...(lastRoutineSpawnReason ? { reason: lastRoutineSpawnReason } : {}),
|
|
577
239
|
};
|
|
578
240
|
}
|
|
579
241
|
const actionResults = executeRoutineActions(actions, (action, index) => {
|
|
@@ -590,7 +252,14 @@ function executeRoutine(routine, projectId, dryRun, scheduledAt = new Date()) {
|
|
|
590
252
|
const runId = findJobRunId(action, projectId, scheduledAt);
|
|
591
253
|
return runId ? [runId] : [];
|
|
592
254
|
});
|
|
593
|
-
return {
|
|
255
|
+
return {
|
|
256
|
+
result,
|
|
257
|
+
actionResults,
|
|
258
|
+
jobRunIds: [
|
|
259
|
+
...new Set([...(lastRoutineSpawnRunId ? [lastRoutineSpawnRunId] : []), ...jobRunIds]),
|
|
260
|
+
],
|
|
261
|
+
...(lastRoutineSpawnReason ? { reason: lastRoutineSpawnReason } : {}),
|
|
262
|
+
};
|
|
594
263
|
}
|
|
595
264
|
// ================================
|
|
596
265
|
// Command registration
|
|
@@ -785,6 +454,7 @@ export function registerRoutineCommands(program) {
|
|
|
785
454
|
state.routines[entry.doc.id] = {
|
|
786
455
|
...state.routines[entry.doc.id],
|
|
787
456
|
last_result: result,
|
|
457
|
+
...(execution.reason ? { last_reason: execution.reason } : { last_reason: undefined }),
|
|
788
458
|
last_action_results: execution.actionResults,
|
|
789
459
|
};
|
|
790
460
|
writeRoutineState(paths, state);
|
|
@@ -796,6 +466,7 @@ export function registerRoutineCommands(program) {
|
|
|
796
466
|
completed_at: nowUtcIsoSeconds(),
|
|
797
467
|
result,
|
|
798
468
|
job_run_ids: execution.jobRunIds,
|
|
469
|
+
...(execution.reason ? { reason: execution.reason } : {}),
|
|
799
470
|
});
|
|
800
471
|
}
|
|
801
472
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// sch-strategy-<track>.yaml; deliverable/Kata facts and stored grades are read on every run.
|
|
3
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { join, resolve } from "node:path";
|
|
5
|
-
import
|
|
5
|
+
import { load } from "./yaml.js";
|
|
6
6
|
import { collectResolvedDeliverables } from "./catalog-build.js";
|
|
7
7
|
import { resolveBasePath } from "./catalog-paths.js";
|
|
8
8
|
import { readYaml } from "./exec-shared.js";
|
|
@@ -37,7 +37,7 @@ function readGrade(repoRoot, relPath, projectId) {
|
|
|
37
37
|
metadata = readSpecdojoNamespace(content);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
const parsed = relPath.endsWith(".json") ? JSON.parse(content) :
|
|
40
|
+
const parsed = relPath.endsWith(".json") ? JSON.parse(content) : load(content);
|
|
41
41
|
if (!isRecord(parsed))
|
|
42
42
|
return undefined;
|
|
43
43
|
metadata = isRecord(parsed.specdojo) ? parsed.specdojo : parsed;
|
package/dist/schedule-build.js
CHANGED
|
@@ -124,7 +124,7 @@ function topoSort(deliverables, crossDeps) {
|
|
|
124
124
|
// --- Main export ---
|
|
125
125
|
function validateAgentAssignment(label, assignment, roster, errors) {
|
|
126
126
|
if (!roster) {
|
|
127
|
-
errors.push(`${label}: agent assignment requires
|
|
127
|
+
errors.push(`${label}: agent assignment requires configured member registries`);
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
for (const [stageRole, nickname] of [
|
|
@@ -135,7 +135,7 @@ function validateAgentAssignment(label, assignment, roster, errors) {
|
|
|
135
135
|
continue;
|
|
136
136
|
const members = roster.members.filter((member) => member.type === "agent" && member.nickname === nickname);
|
|
137
137
|
if (members.length !== 1) {
|
|
138
|
-
errors.push(`${label}.agent.${stageRole}: nickname '${nickname}' was not found uniquely in
|
|
138
|
+
errors.push(`${label}.agent.${stageRole}: nickname '${nickname}' was not found uniquely in agent-members.yaml`);
|
|
139
139
|
continue;
|
|
140
140
|
}
|
|
141
141
|
if (members[0].stage_role !== stageRole) {
|