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
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { mkdirSync, existsSync, readFileSync, writeFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import { gradeFindingCount, parseGradeResult } from "./grade-result.js";
|
|
3
|
+
import { toArtifactPath } from "../shared/artifact-path.js";
|
|
4
|
+
import { readJson } from "../shared/fs.js";
|
|
5
|
+
import { readAllEventFiles } from "../exec/events.js";
|
|
6
|
+
import { getProjectExecutionPath, getProjectRoutinesPath, getProjectSchedulePath, getProjectTimelinePath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
7
|
+
import { resolveRegisterPaths, loadRegisterItems, } from "../register/register.js";
|
|
8
|
+
import { readRegisterEventsFromContent, registerEventFilePath, } from "../register/events.js";
|
|
9
|
+
import { buildTimelineWaves, loadTimelineIndex } from "./timeline-build.js";
|
|
10
|
+
import { buildTimelineGanttSvg, computeTimelineTrackSchedules, resolveDashboardCalendar, } from "./dashboard-timeline.js";
|
|
11
|
+
import { aggregateRoutines, buildDailyRoutineRows, formatZonedDateTime, ROUTINE_ROW_COLLAPSE_THRESHOLD, zonedDateKey, } from "./routines.js";
|
|
12
|
+
import { buildExecRecordsMarkdown, collectExecRecords, EXEC_RECORDS_FILE } from "./exec-records.js";
|
|
13
|
+
import { sanitizeDashboardCell } from "./shared.js";
|
|
14
|
+
import { gradeFindingCount, parseGradeResult } from "../grade/result.js";
|
|
16
15
|
// ================================
|
|
17
16
|
// Types
|
|
18
17
|
// ================================
|
|
@@ -56,178 +55,7 @@ export function resolveDashboardPaths(opts) {
|
|
|
56
55
|
gradeResultsPath: join(baseDir, getProjectExecutionPath(project), "grade", "results"),
|
|
57
56
|
};
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
// 予定開始日・終了日を算出する。横軸は日付であり、wave 番号ではない。
|
|
61
|
-
export function computeTimelineTrackSchedules(index, calendar) {
|
|
62
|
-
const waves = buildTimelineWaves(index.tracks);
|
|
63
|
-
const waveNumberByOrder = new Map();
|
|
64
|
-
for (const wave of waves) {
|
|
65
|
-
for (const tk of wave.tracks)
|
|
66
|
-
waveNumberByOrder.set(tk.order, wave.wave);
|
|
67
|
-
}
|
|
68
|
-
const startByTrack = new Map();
|
|
69
|
-
const endByTrack = new Map();
|
|
70
|
-
let cursor = index.planned_start_date;
|
|
71
|
-
for (const wave of waves) {
|
|
72
|
-
const waveStart = cursor;
|
|
73
|
-
let waveEnd;
|
|
74
|
-
for (const tk of wave.tracks) {
|
|
75
|
-
startByTrack.set(tk.track, waveStart);
|
|
76
|
-
if (tk.catalog_duration_estimate_days && waveStart) {
|
|
77
|
-
const end = addWorkingDaysToDate(waveStart, tk.catalog_duration_estimate_days, calendar);
|
|
78
|
-
endByTrack.set(tk.track, end);
|
|
79
|
-
if (!waveEnd || end > waveEnd)
|
|
80
|
-
waveEnd = end;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
endByTrack.set(tk.track, undefined);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// 次 wave の手始め。本 wave に推定日数のあるトラックがあれば最遅完了日の翌稼働日で、
|
|
87
|
-
// 未定のトラックだけなら直前の手始め日をそのまま受け継ぐ(後続波まで日付が伝播する)。
|
|
88
|
-
cursor = waveEnd ? addWorkingDaysToDate(waveEnd, 1, calendar) : cursor;
|
|
89
|
-
}
|
|
90
|
-
const schedule = index.tracks.map((tk) => ({
|
|
91
|
-
track: tk.track,
|
|
92
|
-
order: tk.order,
|
|
93
|
-
domains: tk.domains,
|
|
94
|
-
status: tk.catalog_status,
|
|
95
|
-
estimateDays: tk.catalog_duration_estimate_days,
|
|
96
|
-
parallel_group: tk.parallel_group,
|
|
97
|
-
depends_on: tk.depends_on,
|
|
98
|
-
startDate: startByTrack.get(tk.track),
|
|
99
|
-
endDate: endByTrack.get(tk.track),
|
|
100
|
-
wave: waveNumberByOrder.get(tk.order) ?? 0,
|
|
101
|
-
}));
|
|
102
|
-
return { schedule, plannedStartDate: index.planned_start_date };
|
|
103
|
-
}
|
|
104
|
-
// 稼働日カレンダーの機械可読正本:tml-index.planned_start_date を起点にし、Schedule 側
|
|
105
|
-
// (sch-defaults.yaml と各 sch-*.yaml)の calendar を buildScheduleIndex から復用する。
|
|
106
|
-
// 両方とも YAML 正本から機械的に読み取り、表示文言の解析に依存しない。
|
|
107
|
-
export function resolveDashboardCalendar(schedulePath) {
|
|
108
|
-
try {
|
|
109
|
-
return buildScheduleIndex(schedulePath).calendar;
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
return defaultScheduleCalendar();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
// ================================
|
|
116
|
-
// Timeline Gantt SVG (x-axis = date)
|
|
117
|
-
// ================================
|
|
118
|
-
function xmlEscape(text) {
|
|
119
|
-
return text
|
|
120
|
-
.replace(/&/g, "&")
|
|
121
|
-
.replace(/</g, "<")
|
|
122
|
-
.replace(/>/g, ">")
|
|
123
|
-
.replace(/"/g, """);
|
|
124
|
-
}
|
|
125
|
-
function statusColor(status) {
|
|
126
|
-
if (status === "primary")
|
|
127
|
-
return "#16a34a";
|
|
128
|
-
if (status === "draft")
|
|
129
|
-
return "#2563eb";
|
|
130
|
-
return "#d1d5db";
|
|
131
|
-
}
|
|
132
|
-
// 予定日付の無いトラックはバーを持たずラベルのみ表示する(手始め日 or 推定稼働日が未設定)。
|
|
133
|
-
export function buildTimelineGanttSvg(schedule, plannedStartDate, title = "トラック計画ガントチャート") {
|
|
134
|
-
const dayWidth = 30;
|
|
135
|
-
const rowHeight = 26;
|
|
136
|
-
const leftPad = 240;
|
|
137
|
-
const topPad = 56;
|
|
138
|
-
const bottomPad = 20;
|
|
139
|
-
// バーは startDate かつ endDate 両方を持つトラックへ。開始日のみのトラックは着手順の着手点として
|
|
140
|
-
// 四角(diamond)で表示する。軸の範囲は endDate が無いトラックも startDate を含めて算出する。
|
|
141
|
-
const fullRows = schedule.filter((row) => row.startDate);
|
|
142
|
-
if (fullRows.length === 0 || !plannedStartDate) {
|
|
143
|
-
return noDataTimelineSvg(title, plannedStartDate
|
|
144
|
-
? "トラックの予定開始日・終了日を算出できませんでした。"
|
|
145
|
-
: "計画開始日(tml-index.yaml の planned_start_date)が未設定です。");
|
|
146
|
-
}
|
|
147
|
-
const parseMs = (dateOnly) => {
|
|
148
|
-
const [year, month, day] = dateOnly.split("-").map(Number);
|
|
149
|
-
return Date.UTC(year, month - 1, day, 0, 0, 0, 0);
|
|
150
|
-
};
|
|
151
|
-
const startMs = parseMs(plannedStartDate);
|
|
152
|
-
let endMs = startMs;
|
|
153
|
-
for (const row of fullRows) {
|
|
154
|
-
const last = row.endDate ?? row.startDate;
|
|
155
|
-
if (parseMs(last) > endMs)
|
|
156
|
-
endMs = parseMs(last);
|
|
157
|
-
}
|
|
158
|
-
const totalDays = Math.max(1, Math.ceil((endMs - startMs) / 86_400_000) + 1);
|
|
159
|
-
const width = leftPad + totalDays * dayWidth + 24;
|
|
160
|
-
const height = topPad + schedule.length * rowHeight + bottomPad;
|
|
161
|
-
const xForDate = (dateOnly) => {
|
|
162
|
-
const daysDiff = Math.floor((parseMs(dateOnly) - startMs) / 86_400_000);
|
|
163
|
-
return leftPad + daysDiff * dayWidth;
|
|
164
|
-
};
|
|
165
|
-
const parts = [];
|
|
166
|
-
parts.push(`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" role="img" aria-label="${xmlEscape(title)}">`);
|
|
167
|
-
parts.push(`<style>
|
|
168
|
-
text { font-family: ui-sans-serif, system-ui, -apple-system, sans-serif; fill: #1f2937; }
|
|
169
|
-
.tl-title { font-size: 16px; font-weight: 700; fill: #0f172a; }
|
|
170
|
-
.tl-caption { font-size: 11px; fill: #64748b; }
|
|
171
|
-
.tl-label { font-size: 11px; font-weight: 600; fill: #1f2937; }
|
|
172
|
-
.tl-axis { font-size: 10px; fill: #475569; }
|
|
173
|
-
.tl-grid { stroke: #e2e8f0; stroke-width: 1; }
|
|
174
|
-
.tl-month-grid { stroke: #94a3b8; stroke-width: 1.5; }
|
|
175
|
-
.tl-note { font-size: 10px; fill: #9ca3af; }
|
|
176
|
-
</style>`);
|
|
177
|
-
parts.push(`<rect x="0" y="0" width="${width}" height="${height}" fill="#fffdf8" />`);
|
|
178
|
-
parts.push(`<text class="tl-title" x="16" y="24">${xmlEscape(title)}</text>`);
|
|
179
|
-
parts.push(`<text class="tl-caption" x="16" y="42">横軸は日付。予定開始日・予定終了日は tml-index.yaml の planned_start_date と catalog_duration_estimate_days(推定稼働日数)から算出。</text>`);
|
|
180
|
-
for (let offset = 0; offset < totalDays; offset++) {
|
|
181
|
-
const dayMs = startMs + offset * 86_400_000;
|
|
182
|
-
if (new Date(dayMs).getUTCDate() !== 1)
|
|
183
|
-
continue;
|
|
184
|
-
const x = leftPad + offset * dayWidth;
|
|
185
|
-
parts.push(`<line class="tl-month-grid" x1="${x}" y1="${topPad - 22}" x2="${x}" y2="${height - bottomPad}" />`);
|
|
186
|
-
parts.push(`<text class="tl-axis" x="${x + 4}" y="${topPad - 8}">${xmlEscape(new Date(dayMs).toISOString().slice(0, 7))}</text>`);
|
|
187
|
-
}
|
|
188
|
-
parts.push(`<line class="tl-grid" x1="${leftPad}" y1="${topPad - 22}" x2="${leftPad}" y2="${height - bottomPad}" />`);
|
|
189
|
-
let currentY = topPad;
|
|
190
|
-
for (const row of schedule) {
|
|
191
|
-
parts.push(`<text class="tl-label" x="8" y="${currentY + 14}">${xmlEscape(row.track)}</text>`);
|
|
192
|
-
if (row.startDate && row.endDate) {
|
|
193
|
-
const x1 = xForDate(row.startDate);
|
|
194
|
-
const x2 = xForDate(row.endDate);
|
|
195
|
-
const barWidth = Math.max(4, x2 - x1);
|
|
196
|
-
parts.push(`<rect x="${x1}" y="${currentY + 6}" width="${barWidth}" height="12" rx="3" fill="${statusColor(row.status)}" opacity="0.9" />`);
|
|
197
|
-
}
|
|
198
|
-
else if (row.startDate) {
|
|
199
|
-
// 開始日のみ(推定稼働日数未定): 着手点の diamond マーカーで表示。
|
|
200
|
-
const cx = xForDate(row.startDate);
|
|
201
|
-
parts.push(`<polygon points="${cx},${currentY + 2} ${cx + 6},${currentY + 8} ${cx},${currentY + 14} ${cx - 6},${currentY + 8}" fill="${statusColor(row.status)}" opacity="0.85" />`);
|
|
202
|
-
parts.push(`<text class="tl-note" x="${xForDate(row.startDate) + 8}" y="${currentY + 14}">${xmlEscape(datePlanNote(row))}</text>`);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
parts.push(`<text class="tl-note" x="${leftPad + 4}" y="${currentY + 14}">${xmlEscape(datePlanNote(row))}</text>`);
|
|
206
|
-
}
|
|
207
|
-
parts.push(`<line class="tl-grid" x1="0" y1="${currentY + rowHeight}" x2="${width}" y2="${currentY + rowHeight}" />`);
|
|
208
|
-
currentY += rowHeight;
|
|
209
|
-
}
|
|
210
|
-
parts.push(`</svg>`);
|
|
211
|
-
return parts.join("\n");
|
|
212
|
-
}
|
|
213
|
-
function datePlanNote(row) {
|
|
214
|
-
if (!row.startDate)
|
|
215
|
-
return "手始め日未定";
|
|
216
|
-
if (row.endDate === undefined || !row.estimateDays)
|
|
217
|
-
return `着手順 ${row.order}(推定稼働日数未定)`;
|
|
218
|
-
return `${row.startDate} ~ ${row.endDate}`;
|
|
219
|
-
}
|
|
220
|
-
function noDataTimelineSvg(title, message) {
|
|
221
|
-
const width = 560;
|
|
222
|
-
const height = 120;
|
|
223
|
-
return [
|
|
224
|
-
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" role="img" aria-label="${xmlEscape(title)}">`,
|
|
225
|
-
`<rect x="0" y="0" width="${width}" height="${height}" fill="#fffdf8" />`,
|
|
226
|
-
`<text class="tl-title" x="16" y="24">${xmlEscape(title)}</text>`,
|
|
227
|
-
`<text x="16" y="72" font-size="13" fill="#64748b">${xmlEscape(message)}</text>`,
|
|
228
|
-
`</svg>`,
|
|
229
|
-
].join("\n");
|
|
230
|
-
}
|
|
58
|
+
export { buildTimelineGanttSvg, computeTimelineTrackSchedules, resolveDashboardCalendar };
|
|
231
59
|
function aggregateRegister(projectId) {
|
|
232
60
|
const result = {
|
|
233
61
|
statusCounts: {},
|
|
@@ -350,272 +178,11 @@ function aggregateAttention(paths) {
|
|
|
350
178
|
}
|
|
351
179
|
return rows;
|
|
352
180
|
}
|
|
353
|
-
|
|
354
|
-
// 最終実行・実行結果・due 状況を得る。CLI 出力(routine list)の転記に依存しない。
|
|
355
|
-
function aggregateRoutines(routinesPath) {
|
|
356
|
-
if (!routinesPath || !existsSync(routinesPath))
|
|
357
|
-
return { rows: [], docs: [], history: [] };
|
|
358
|
-
const result = {
|
|
359
|
-
rows: [],
|
|
360
|
-
docs: [],
|
|
361
|
-
history: readRoutineRunHistory(join(routinesPath, "generated", "routine-runs.jsonl")),
|
|
362
|
-
error: undefined,
|
|
363
|
-
};
|
|
364
|
-
const stateEntries = readRoutineStateEntries(join(routinesPath, "generated", "routine-state.json"));
|
|
365
|
-
const now = new Date();
|
|
366
|
-
const files = readdirSync(routinesPath)
|
|
367
|
-
.filter((name) => /^rtn-.*\.(ya?ml)$/.test(name))
|
|
368
|
-
.sort();
|
|
369
|
-
for (const file of files) {
|
|
370
|
-
try {
|
|
371
|
-
const doc = parseRoutineFileSafe(join(routinesPath, file));
|
|
372
|
-
if (!doc?.id || typeof doc.id !== "string")
|
|
373
|
-
continue;
|
|
374
|
-
result.docs.push(doc);
|
|
375
|
-
buildRoutineRow(result, doc, stateEntries, now);
|
|
376
|
-
}
|
|
377
|
-
catch {
|
|
378
|
-
result.error = `routine file parse failed: ${file}`;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
result.rows.sort((a, b) => a.id.localeCompare(b.id));
|
|
382
|
-
return result;
|
|
383
|
-
}
|
|
384
|
-
export function readRoutineRunHistory(historyPath) {
|
|
385
|
-
if (!existsSync(historyPath))
|
|
386
|
-
return [];
|
|
387
|
-
const entries = [];
|
|
388
|
-
for (const [index, line] of readFileSync(historyPath, "utf8").split(/\r?\n/).entries()) {
|
|
389
|
-
if (!line.trim())
|
|
390
|
-
continue;
|
|
391
|
-
try {
|
|
392
|
-
const value = JSON.parse(line);
|
|
393
|
-
if (value.version === 1 &&
|
|
394
|
-
typeof value.routine_id === "string" &&
|
|
395
|
-
typeof value.scheduled_for === "string" &&
|
|
396
|
-
typeof value.started_at === "string" &&
|
|
397
|
-
typeof value.completed_at === "string" &&
|
|
398
|
-
["success", "failure", "skipped"].includes(value.result) &&
|
|
399
|
-
Array.isArray(value.job_run_ids)) {
|
|
400
|
-
entries.push(value);
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
throw new Error("invalid routine history entry");
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
catch {
|
|
407
|
-
throw new Error(`routine history parse failed at line ${index + 1}`);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return entries;
|
|
411
|
-
}
|
|
412
|
-
// 毎時の dashboard 更新のように 1 日に何度も動く routine は、日ごとに 1 行へまとめる。
|
|
413
|
-
const ROUTINE_ROW_COLLAPSE_THRESHOLD = 3;
|
|
414
|
-
export function formatZonedDateTime(iso, timeZone) {
|
|
415
|
-
const date = new Date(iso);
|
|
416
|
-
if (Number.isNaN(date.getTime()))
|
|
417
|
-
return iso;
|
|
418
|
-
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
419
|
-
timeZone,
|
|
420
|
-
month: "2-digit",
|
|
421
|
-
day: "2-digit",
|
|
422
|
-
hour: "2-digit",
|
|
423
|
-
minute: "2-digit",
|
|
424
|
-
hour12: false,
|
|
425
|
-
}).formatToParts(date);
|
|
426
|
-
const get = (type) => parts.find((part) => part.type === type)?.value ?? "";
|
|
427
|
-
return `${get("month")}-${get("day")} ${get("hour")}:${get("minute")}`;
|
|
428
|
-
}
|
|
429
|
-
function zonedDateKey(date, timeZone) {
|
|
430
|
-
return new Intl.DateTimeFormat("en-CA", {
|
|
431
|
-
timeZone,
|
|
432
|
-
year: "numeric",
|
|
433
|
-
month: "2-digit",
|
|
434
|
-
day: "2-digit",
|
|
435
|
-
}).format(date);
|
|
436
|
-
}
|
|
437
|
-
function previousDateKey(dateKey) {
|
|
438
|
-
const [year, month, day] = dateKey.split("-").map(Number);
|
|
439
|
-
const previous = new Date(Date.UTC(year, month - 1, day - 1));
|
|
440
|
-
return previous.toISOString().slice(0, 10);
|
|
441
|
-
}
|
|
442
|
-
function scheduledToday(doc, today, now, timeZone) {
|
|
443
|
-
if (!doc.trigger || doc.enabled === false)
|
|
444
|
-
return [];
|
|
445
|
-
const start = Math.floor((now.getTime() - 36 * 60 * 60 * 1000) / 60_000) * 60_000;
|
|
446
|
-
const end = Math.floor((now.getTime() + 36 * 60 * 60 * 1000) / 60_000) * 60_000;
|
|
447
|
-
const matches = [];
|
|
448
|
-
for (let cursor = start; cursor <= end; cursor += 60_000) {
|
|
449
|
-
const candidate = new Date(cursor);
|
|
450
|
-
if (zonedDateKey(candidate, timeZone) === today &&
|
|
451
|
-
cronMatches(doc.trigger.cron, doc.trigger.timezone, candidate)) {
|
|
452
|
-
matches.push(candidate);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
return matches;
|
|
456
|
-
}
|
|
457
|
-
export function buildDailyRoutineRows(docs, history, now, timeZone = "Asia/Tokyo") {
|
|
458
|
-
const today = zonedDateKey(now, timeZone);
|
|
459
|
-
const yesterday = previousDateKey(today);
|
|
460
|
-
const rows = history
|
|
461
|
-
.filter((entry) => {
|
|
462
|
-
const key = zonedDateKey(new Date(entry.scheduled_for), timeZone);
|
|
463
|
-
return key === yesterday || key === today;
|
|
464
|
-
})
|
|
465
|
-
.map((entry) => ({
|
|
466
|
-
day: zonedDateKey(new Date(entry.scheduled_for), timeZone) === yesterday ? "昨日" : "本日",
|
|
467
|
-
routineId: entry.routine_id,
|
|
468
|
-
scheduledFor: entry.scheduled_for,
|
|
469
|
-
startedAt: entry.started_at,
|
|
470
|
-
completedAt: entry.completed_at,
|
|
471
|
-
result: entry.result,
|
|
472
|
-
jobRunIds: entry.job_run_ids,
|
|
473
|
-
runCount: 1,
|
|
474
|
-
}));
|
|
475
|
-
const completedKeys = new Set(history.map((entry) => `${entry.routine_id}:${new Date(entry.scheduled_for).toISOString().slice(0, 16)}`));
|
|
476
|
-
for (const doc of docs) {
|
|
477
|
-
for (const scheduledFor of scheduledToday(doc, today, now, timeZone)) {
|
|
478
|
-
const key = `${doc.id}:${scheduledFor.toISOString().slice(0, 16)}`;
|
|
479
|
-
if (completedKeys.has(key))
|
|
480
|
-
continue;
|
|
481
|
-
rows.push({
|
|
482
|
-
day: "本日",
|
|
483
|
-
routineId: doc.id,
|
|
484
|
-
scheduledFor: scheduledFor.toISOString(),
|
|
485
|
-
startedAt: "-",
|
|
486
|
-
completedAt: "-",
|
|
487
|
-
// 予定時刻を過ぎても履歴がなければ、skip や cron 停止で動かなかったことを示す。
|
|
488
|
-
result: scheduledFor.getTime() <= now.getTime() ? "未実行" : "予定",
|
|
489
|
-
jobRunIds: [],
|
|
490
|
-
runCount: 1,
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
return collapseFrequentRoutineRows(rows).sort((a, b) => a.scheduledFor.localeCompare(b.scheduledFor) || a.routineId.localeCompare(b.routineId));
|
|
495
|
-
}
|
|
496
|
-
// 同じ routine・同じ日の行が閾値以上あれば、最新の実行 1 行に件数をまとめる。
|
|
497
|
-
export function collapseFrequentRoutineRows(rows) {
|
|
498
|
-
const groups = new Map();
|
|
499
|
-
for (const row of rows) {
|
|
500
|
-
const key = `${row.day}:${row.routineId}`;
|
|
501
|
-
groups.set(key, [...(groups.get(key) ?? []), row]);
|
|
502
|
-
}
|
|
503
|
-
const collapsed = [];
|
|
504
|
-
for (const group of groups.values()) {
|
|
505
|
-
if (group.length < ROUTINE_ROW_COLLAPSE_THRESHOLD) {
|
|
506
|
-
collapsed.push(...group);
|
|
507
|
-
continue;
|
|
508
|
-
}
|
|
509
|
-
const executed = group.filter((row) => row.result !== "予定" && row.result !== "未実行");
|
|
510
|
-
const latest = [...(executed.length > 0 ? executed : group)].sort((a, b) => b.scheduledFor.localeCompare(a.scheduledFor))[0];
|
|
511
|
-
const failures = executed.filter((row) => row.result === "failure").length;
|
|
512
|
-
collapsed.push({
|
|
513
|
-
...latest,
|
|
514
|
-
runCount: executed.length > 0 ? executed.length : group.length,
|
|
515
|
-
jobRunIds: [],
|
|
516
|
-
result: failures > 0 ? "failure" : latest.result,
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
return collapsed;
|
|
520
|
-
}
|
|
521
|
-
// generated/routine-state.json の routines.<id> が状態の正本。破損時は空。
|
|
522
|
-
function readRoutineStateEntries(statePath) {
|
|
523
|
-
const entries = {};
|
|
524
|
-
if (!existsSync(statePath))
|
|
525
|
-
return entries;
|
|
526
|
-
try {
|
|
527
|
-
const parsed = readJson(statePath);
|
|
528
|
-
const routines = parsed?.routines;
|
|
529
|
-
if (routines && typeof routines === "object") {
|
|
530
|
-
for (const [id, value] of Object.entries(routines)) {
|
|
531
|
-
if (value && typeof value === "object") {
|
|
532
|
-
const entry = value;
|
|
533
|
-
entries[id] = {
|
|
534
|
-
last_run: typeof entry.last_run === "string" ? entry.last_run : undefined,
|
|
535
|
-
last_result: typeof entry.last_result === "string" ? entry.last_result : undefined,
|
|
536
|
-
last_scheduled_for: typeof entry.last_scheduled_for === "string" ? entry.last_scheduled_for : undefined,
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
catch {
|
|
543
|
-
return {};
|
|
544
|
-
}
|
|
545
|
-
return entries;
|
|
546
|
-
}
|
|
547
|
-
function parseRoutineFileSafe(filePath) {
|
|
548
|
-
let parsed;
|
|
549
|
-
try {
|
|
550
|
-
parsed = yaml.load(readFileSync(filePath, "utf8"));
|
|
551
|
-
}
|
|
552
|
-
catch {
|
|
553
|
-
return undefined;
|
|
554
|
-
}
|
|
555
|
-
if (!parsed || typeof parsed !== "object")
|
|
556
|
-
return undefined;
|
|
557
|
-
return parsed;
|
|
558
|
-
}
|
|
559
|
-
// routine 1 行を機械可読な正本から集計し、due は now と状態から判定する。
|
|
560
|
-
function buildRoutineRow(result, doc, stateEntries, now) {
|
|
561
|
-
const id = String(doc.id);
|
|
562
|
-
const enabled = doc.enabled === undefined ? true : doc.enabled;
|
|
563
|
-
const kind = doc.action ? routineActionKindLabel(doc.action) : "-";
|
|
564
|
-
const stateEntry = stateEntries[id];
|
|
565
|
-
let lastRun = "-";
|
|
566
|
-
if (stateEntry?.last_run) {
|
|
567
|
-
lastRun = stateEntry.last_result
|
|
568
|
-
? `${stateEntry.last_run} (${stateEntry.last_result})`
|
|
569
|
-
: stateEntry.last_run;
|
|
570
|
-
}
|
|
571
|
-
result.rows.push({
|
|
572
|
-
id,
|
|
573
|
-
name: typeof doc.name === "string" ? doc.name : undefined,
|
|
574
|
-
enabled,
|
|
575
|
-
schedule: routineScheduleLabel(doc),
|
|
576
|
-
kind,
|
|
577
|
-
lastRun,
|
|
578
|
-
due: computeRoutineDue(doc, stateEntry, enabled, now),
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
// interval / trigger + 現在時刻 + 状態(last_run / last_scheduled_for)から due を機械的に判定する。
|
|
582
|
-
export function computeRoutineDue(doc, stateEntry, enabled, now) {
|
|
583
|
-
if (!enabled)
|
|
584
|
-
return "disabled";
|
|
585
|
-
if (doc.trigger) {
|
|
586
|
-
const occurrences = cronOccurrences(doc, stateEntry?.last_scheduled_for, now);
|
|
587
|
-
return occurrences.length > 0 ? "due" : "-";
|
|
588
|
-
}
|
|
589
|
-
if (doc.interval) {
|
|
590
|
-
return isRoutineDue(doc, stateEntry?.last_run, now) ? "due" : "-";
|
|
591
|
-
}
|
|
592
|
-
return "-";
|
|
593
|
-
}
|
|
594
|
-
// interval / trigger を表すラベル。interval 優先、なければ trigger.cron。
|
|
595
|
-
function routineScheduleLabel(doc) {
|
|
596
|
-
if (typeof doc.interval === "string")
|
|
597
|
-
return doc.interval;
|
|
598
|
-
const trigger = doc.trigger;
|
|
599
|
-
if (trigger && typeof trigger.cron === "string")
|
|
600
|
-
return `cron: ${trigger.cron}`;
|
|
601
|
-
return "-";
|
|
602
|
-
}
|
|
181
|
+
export { buildDailyRoutineRows, collapseFrequentRoutineRows, computeRoutineDue, formatZonedDateTime, readRoutineRunHistory, } from "./routines.js";
|
|
603
182
|
// ================================
|
|
604
183
|
// Markdown rendering
|
|
605
184
|
// ================================
|
|
606
|
-
|
|
607
|
-
// dashboard の表へは event や subprocess 由来の文字列も入る。表へ埋める直前に
|
|
608
|
-
// ターミナル制御シーケンスと改行類を除き、列区切りをエスケープして長さを制限する。
|
|
609
|
-
export function sanitizeDashboardCell(text) {
|
|
610
|
-
const singleLine = stripTerminalControlSequences(text)
|
|
611
|
-
.replace(/[\t\r\n]+/g, " ")
|
|
612
|
-
.replace(/ +/g, " ")
|
|
613
|
-
.trim();
|
|
614
|
-
const truncated = singleLine.length <= MAX_DASHBOARD_CELL_LENGTH
|
|
615
|
-
? singleLine
|
|
616
|
-
: `${singleLine.slice(0, MAX_DASHBOARD_CELL_LENGTH)}…`;
|
|
617
|
-
return truncated.replace(/\|/g, "\\|");
|
|
618
|
-
}
|
|
185
|
+
export { sanitizeDashboardCell };
|
|
619
186
|
const STATUS_ORDER = [
|
|
620
187
|
"open",
|
|
621
188
|
"in-progress",
|
|
@@ -896,107 +463,7 @@ function renderAttentionSection(paths) {
|
|
|
896
463
|
// ================================
|
|
897
464
|
// 9. Exec records (plan / result 一覧)
|
|
898
465
|
// ================================
|
|
899
|
-
export
|
|
900
|
-
function readSpecdojoFrontmatter(filePath) {
|
|
901
|
-
try {
|
|
902
|
-
const content = readFileSync(filePath, "utf8");
|
|
903
|
-
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
904
|
-
if (!match)
|
|
905
|
-
return {};
|
|
906
|
-
const parsed = yaml.load(match[1]);
|
|
907
|
-
if (typeof parsed !== "object" || parsed === null)
|
|
908
|
-
return {};
|
|
909
|
-
const specdojo = parsed.specdojo;
|
|
910
|
-
return typeof specdojo === "object" && specdojo !== null && !Array.isArray(specdojo)
|
|
911
|
-
? specdojo
|
|
912
|
-
: {};
|
|
913
|
-
}
|
|
914
|
-
catch {
|
|
915
|
-
// 壊れた frontmatter の記録も一覧から辿れるよう、属性なしの行として残す。
|
|
916
|
-
return {};
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
function frontmatterText(value) {
|
|
920
|
-
if (typeof value === "string" && value.trim())
|
|
921
|
-
return value.trim();
|
|
922
|
-
if (value instanceof Date)
|
|
923
|
-
return value.toISOString();
|
|
924
|
-
return undefined;
|
|
925
|
-
}
|
|
926
|
-
function listMarkdownFiles(dir, suffix) {
|
|
927
|
-
if (!existsSync(dir))
|
|
928
|
-
return [];
|
|
929
|
-
return readdirSync(dir)
|
|
930
|
-
.filter((name) => name.endsWith(suffix))
|
|
931
|
-
.sort();
|
|
932
|
-
}
|
|
933
|
-
// execution/exec/{plans,results} の記録を実行単位(ファイル名の stem)でまとめる。
|
|
934
|
-
// 並びは開始日時の新しい順、開始日時が無いものは後ろに stem 順で置く。
|
|
935
|
-
export function collectExecRecords(execPath) {
|
|
936
|
-
const rows = new Map();
|
|
937
|
-
const rowFor = (stem) => {
|
|
938
|
-
const existing = rows.get(stem);
|
|
939
|
-
if (existing)
|
|
940
|
-
return existing;
|
|
941
|
-
const created = { stem };
|
|
942
|
-
rows.set(stem, created);
|
|
943
|
-
return created;
|
|
944
|
-
};
|
|
945
|
-
for (const name of listMarkdownFiles(join(execPath, "plans"), "-plan.md")) {
|
|
946
|
-
const row = rowFor(name.slice(0, -"-plan.md".length));
|
|
947
|
-
const fm = readSpecdojoFrontmatter(join(execPath, "plans", name));
|
|
948
|
-
row.planFile = name;
|
|
949
|
-
row.taskId ??= frontmatterText(fm.task_id);
|
|
950
|
-
row.mode ??= frontmatterText(fm.mode);
|
|
951
|
-
}
|
|
952
|
-
for (const name of listMarkdownFiles(join(execPath, "results"), "-result.md")) {
|
|
953
|
-
const row = rowFor(name.slice(0, -"-result.md".length));
|
|
954
|
-
const fm = readSpecdojoFrontmatter(join(execPath, "results", name));
|
|
955
|
-
row.resultFile = name;
|
|
956
|
-
row.taskId = frontmatterText(fm.task_id) ?? row.taskId;
|
|
957
|
-
row.mode = frontmatterText(fm.mode) ?? row.mode;
|
|
958
|
-
row.status = frontmatterText(fm.status);
|
|
959
|
-
row.startedAt = frontmatterText(fm.started_at);
|
|
960
|
-
}
|
|
961
|
-
return [...rows.values()].sort((a, b) => {
|
|
962
|
-
if (a.startedAt && b.startedAt && a.startedAt !== b.startedAt) {
|
|
963
|
-
return a.startedAt < b.startedAt ? 1 : -1;
|
|
964
|
-
}
|
|
965
|
-
if (a.startedAt && !b.startedAt)
|
|
966
|
-
return -1;
|
|
967
|
-
if (!a.startedAt && b.startedAt)
|
|
968
|
-
return 1;
|
|
969
|
-
return a.stem.localeCompare(b.stem);
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
function execRecordLink(dir, file, label) {
|
|
973
|
-
return file ? `[${label}](../exec/${dir}/${file})` : "-";
|
|
974
|
-
}
|
|
975
|
-
export function buildExecRecordsMarkdown(projectId, rows) {
|
|
976
|
-
const lines = [
|
|
977
|
-
"# 実行記録一覧",
|
|
978
|
-
"",
|
|
979
|
-
`- project_id: \`${projectId}\``,
|
|
980
|
-
`- 再生成: \`specdojo dashboard build --project ${projectId}\``,
|
|
981
|
-
"",
|
|
982
|
-
"> このページは `specdojo dashboard build` が生成した派生ビューです。正本は `execution/exec/` 配下の plan / result であり、このページを手編集しても次回のビルドで失われます。実行記録はサイドバーに載せないため、このページから辿ります。",
|
|
983
|
-
"",
|
|
984
|
-
];
|
|
985
|
-
if (rows.length === 0) {
|
|
986
|
-
lines.push("- 実行記録はまだありません。");
|
|
987
|
-
return lines.join("\n");
|
|
988
|
-
}
|
|
989
|
-
lines.push(`- 件数: ${rows.length}`, "");
|
|
990
|
-
lines.push("| 開始日時 | task | mode | status | plan | result |");
|
|
991
|
-
lines.push("| --- | --- | --- | --- | --- | --- |");
|
|
992
|
-
for (const row of rows) {
|
|
993
|
-
const task = row.taskId ? `\`${sanitizeDashboardCell(row.taskId)}\`` : "-";
|
|
994
|
-
const mode = row.mode ? `\`${sanitizeDashboardCell(row.mode)}\`` : "-";
|
|
995
|
-
const status = row.status ? `\`${sanitizeDashboardCell(row.status)}\`` : "-";
|
|
996
|
-
lines.push(`| ${row.startedAt ? sanitizeDashboardCell(row.startedAt) : "-"} | ${task} | ${mode} | ${status} | ${execRecordLink("plans", row.planFile, "plan")} | ${execRecordLink("results", row.resultFile, "result")} |`);
|
|
997
|
-
}
|
|
998
|
-
return lines.join("\n");
|
|
999
|
-
}
|
|
466
|
+
export { buildExecRecordsMarkdown, collectExecRecords, EXEC_RECORDS_FILE };
|
|
1000
467
|
function execRecordsPath(paths) {
|
|
1001
468
|
return join(paths.executionGeneratedPath, "..", "exec");
|
|
1002
469
|
}
|