specdojo 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/agents/specdojo-orchestrator.md +61 -2
- package/CHANGELOG.md +90 -0
- package/README.md +85 -25
- package/dist/{catalog-build-references.js → catalog/build-references.js} +4 -4
- package/dist/catalog/build-render.js +32 -0
- package/dist/{catalog-build.js → catalog/build.js} +9 -9
- package/dist/{catalog.js → catalog/catalog.js} +10 -10
- package/dist/{catalog-generate.js → catalog/generate.js} +8 -8
- package/dist/catalog/paths.js +1 -0
- package/dist/{catalog-plan-generate.js → catalog/plan-generate.js} +4 -4
- package/dist/{catalog-plan.js → catalog/plan.js} +4 -4
- package/dist/{catalog-scaffold.js → catalog/scaffold.js} +3 -3
- 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} +168 -45
- package/dist/commands/night-orchestrator.js +287 -0
- package/dist/{orchestrator.js → commands/orchestrator.js} +12 -5
- package/dist/{watch.js → commands/watch.js} +3 -3
- package/dist/{dashboard-timeline.js → dashboard/dashboard-timeline.js} +2 -2
- package/dist/{dashboard.js → dashboard/dashboard.js} +11 -10
- package/dist/{dashboard-exec-records.js → dashboard/exec-records.js} +2 -2
- package/dist/{dashboard-routines.js → dashboard/routines.js} +6 -5
- package/dist/{dashboard-shared.js → dashboard/shared.js} +1 -1
- 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} +5 -5
- package/dist/{devcontainer-command.js → devcontainer/command.js} +8 -4
- package/dist/devcontainer/scaffold.js +418 -0
- package/dist/{doc-index.js → docs/doc-index.js} +1 -1
- package/dist/{frontmatter-namespace.js → docs/frontmatter-namespace.js} +1 -1
- 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} +1 -1
- package/dist/{yaml-pages-command.js → docs/yaml-pages-command.js} +1 -1
- package/dist/{yaml-pages.js → docs/yaml-pages.js} +2 -2
- package/dist/{exec-agent-config.js → exec/agent-config.js} +92 -5
- 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-commands.js → exec/commands.js} +22 -18
- package/dist/{exec-core.js → exec/core.js} +11 -11
- 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} +18 -4
- package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +29 -2
- package/dist/{exec-plans-core.js → exec/plans-core.js} +68 -114
- package/dist/{exec-plans-generation.js → exec/plans-generation.js} +53 -10
- package/dist/{exec-plans-storage.js → exec/plans-storage.js} +5 -5
- package/dist/{exec-plans.js → exec/plans.js} +3 -3
- 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} +114 -9
- package/dist/{exec-repo-integration-git.js → exec/repo-integration-git.js} +2 -2
- package/dist/{exec-repo-integration-sync.js → exec/repo-integration-sync.js} +4 -4
- package/dist/{exec-repo-integration.js → exec/repo-integration.js} +14 -11
- package/dist/{exec-repo-trace.js → exec/repo-trace.js} +3 -3
- package/dist/{exec-reporter-output.js → exec/reporter-output.js} +2 -2
- package/dist/{exec-reporter.js → exec/reporter.js} +142 -25
- package/dist/{exec-results.js → exec/results.js} +287 -31
- package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +35 -12
- package/dist/{exec-run-agent.js → exec/run/agent.js} +115 -28
- package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
- package/dist/{exec-run-job.js → exec/run/job.js} +65 -36
- package/dist/{exec-run-lifecycle-commands.js → exec/run/lifecycle-commands.js} +30 -22
- package/dist/{exec-run-lock.js → exec/run/lock.js} +4 -3
- package/dist/{exec-run-mode-shared.js → exec/run/mode-shared.js} +3 -3
- package/dist/{exec-run-register-command.js → exec/run/register-command.js} +38 -11
- package/dist/{exec-run-register-core.js → exec/run/register-core.js} +63 -21
- package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +58 -31
- package/dist/exec/run/register-post-review.js +420 -0
- package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +48 -27
- package/dist/{exec-run-register-state.js → exec/run/register-state.js} +13 -10
- package/dist/{exec-run-register-worktree.js → exec/run/register-worktree.js} +119 -24
- package/dist/{exec-run.js → exec/run/run.js} +11 -11
- package/dist/{exec-run-schedule-mode.js → exec/run/schedule-mode.js} +17 -17
- package/dist/{exec-run-schedule-prepare.js → exec/run/schedule-prepare.js} +31 -18
- package/dist/{exec-run-schedule-task.js → exec/run/schedule-task.js} +45 -18
- package/dist/{exec-run-shared.js → exec/run/shared.js} +78 -30
- 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} +104 -17
- package/dist/{exec-task-view.js → exec/task-view.js} +4 -4
- package/dist/{exec-trial-commands.js → exec/trial-commands.js} +20 -22
- package/dist/{exec-trial-core.js → exec/trial-core.js} +6 -6
- package/dist/{exec-trial.js → exec/trial.js} +2 -2
- package/dist/{exec-worktree-command.js → exec/worktree-command.js} +25 -23
- package/dist/{exec-worktree-ops-commit.js → exec/worktree-ops-commit.js} +25 -60
- package/dist/{exec-worktree-ops-lifecycle.js → exec/worktree-ops-lifecycle.js} +13 -8
- package/dist/{exec-worktree-ops-merge.js → exec/worktree-ops-merge.js} +48 -7
- package/dist/{exec-worktree-ops.js → exec/worktree-ops.js} +3 -3
- package/dist/exec/worktree.js +305 -0
- package/dist/{grade-apply.js → grade/apply.js} +9 -9
- package/dist/{grade-command-apply.js → grade/command-apply.js} +7 -7
- package/dist/{grade-command-inspect.js → grade/command-inspect.js} +6 -6
- package/dist/{grade-command-plan.js → grade/command-plan.js} +5 -5
- package/dist/{grade-core.js → grade/core.js} +3 -3
- package/dist/grade/grade.js +19 -0
- package/dist/{grade-markdown.js → grade/markdown.js} +6 -6
- package/dist/{grade-pipeline-state.js → grade/pipeline-state.js} +4 -4
- package/dist/{grade-plan.js → grade/plan.js} +5 -5
- package/dist/{grade-result.js → grade/result.js} +5 -94
- package/dist/{grade-target-discovery.js → grade/target-discovery.js} +7 -7
- package/dist/{grade-targets.js → grade/targets.js} +11 -8
- package/dist/{job-definition.js → job/definition.js} +25 -6
- package/dist/{job.js → job/job.js} +12 -11
- package/dist/{kata-command.js → kata/command.js} +3 -3
- package/dist/{kata.js → kata/kata.js} +5 -5
- package/dist/register/approach.js +134 -0
- package/dist/{register-core.js → register/core.js} +26 -8
- package/dist/{register-create-commands.js → register/create-commands.js} +171 -8
- 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} +44 -3
- package/dist/{register-events.js → register/events.js} +13 -3
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +32 -5
- package/dist/register/lifecycle-lock.js +5 -0
- package/dist/{register-maintenance-commands.js → register/maintenance-commands.js} +13 -7
- package/dist/{register-migrate-timestamps.js → register/migrate-timestamps.js} +3 -3
- package/dist/{register-migration.js → register/migration.js} +5 -4
- package/dist/{register.js → register/register.js} +32 -27
- package/dist/{register-renumber.js → register/renumber.js} +38 -11
- package/dist/{register-transition-commands.js → register/transition-commands.js} +3 -3
- package/dist/{register-update.js → register/update.js} +5 -5
- package/dist/{register-views.js → register/views.js} +47 -7
- package/dist/{review-grade.js → review/grade.js} +2 -2
- package/dist/{review-plan.js → review/plan.js} +3 -3
- package/dist/{routine-definition.js → routine/definition.js} +2 -2
- package/dist/{routine.js → routine/routine.js} +49 -22
- package/dist/{schedule-approach.js → schedule/approach.js} +8 -8
- package/dist/{schedule-build.js → schedule/build.js} +7 -4
- package/dist/{schedule.js → schedule/schedule.js} +6 -6
- package/dist/{schedule-strategy-generate-document.js → schedule/strategy-generate-document.js} +2 -2
- package/dist/{schedule-strategy-generate-scope.js → schedule/strategy-generate-scope.js} +4 -4
- package/dist/{schedule-strategy-generate.js → schedule/strategy-generate.js} +10 -10
- 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/{catalog-build-render.js → shared/catalog-render.js} +3 -32
- 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 +346 -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} +6 -3
- 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} +162 -21
- package/dist/{exec-shared.js → shared/text.js} +4 -135
- package/dist/shared/time.js +28 -0
- package/dist/shared/workspace-scaffold.js +69 -0
- package/dist/specdojo.js +22 -22
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +31 -18
- package/docs/ja/specdojo/exec-templates/xep-register-investigate-template.md +1 -2
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +3 -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/exec-templates/xrp-register-post-run-template.md +46 -0
- package/docs/ja/specdojo/guides/branch-workflow-guide.md +34 -1
- package/docs/ja/specdojo/guides/docs-structure-guide.md +2 -0
- package/docs/ja/specdojo/guides/exec-config-guide.md +169 -26
- package/docs/ja/specdojo/guides/exec-operation-guide.md +184 -13
- package/docs/ja/specdojo/guides/exec-worktree-guide.md +2 -0
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +40 -3
- package/docs/ja/specdojo/guides/quick-start-guide.md +89 -21
- package/docs/ja/specdojo/guides/register-operation-guide.md +44 -1
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +61 -6
- package/docs/ja/specdojo/guides/review-guide.md +1 -1
- package/docs/ja/specdojo/guides/routine-operation-guide.md +5 -5
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +1 -1
- package/docs/ja/specdojo/guides/use-case-guide.md +1 -1
- package/docs/ja/specdojo/guides/waza-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +124 -55
- package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +22 -13
- 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 +111 -17
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +28 -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 +38 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +5 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +91 -7
- package/docs/specdojo/schemas/v1/routine-run.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +36 -1
- package/package.json +17 -17
- package/templates/antigravity/README.md +6 -2
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +8 -13
- package/templates/antigravity/orchestrator.md +61 -2
- 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/claude/agents/specdojo-orchestrator.md +61 -2
- package/templates/codex/README.md +40 -4
- package/templates/codex/agents/specdojo-orchestrator.toml +61 -2
- package/templates/codex/orchestrator.md +61 -2
- package/templates/devcontainer/devcontainer.json +5 -2
- package/templates/devcontainer/post-create.sh +15 -7
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +102 -0
- package/templates/devcontainer/remote-host/ssh-config.sample +19 -0
- package/templates/devcontainer/vim/vimrc +37 -0
- package/templates/init-agent-members.yaml +75 -25
- package/templates/init-exec-defaults.yaml +44 -9
- 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/templates/opencode/agents/specdojo-orchestrator.md +61 -2
- package/dist/devcontainer-scaffold.js +0 -165
- package/dist/exec-schedule-gantt-chart.js +0 -2
- package/dist/exec-worktree.js +0 -474
- package/dist/exec.js +0 -2
- package/dist/grade.js +0 -19
- 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/{grade-command-shared.js → grade/command-shared.js} +0 -0
- /package/dist/{register-command-types.js → register/command-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
- /package/dist/{yaml.js → shared/yaml.js} +0 -0
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { randomInt, randomUUID } from "node:crypto";
|
|
2
2
|
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
3
3
|
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
-
import { inlineCodeAnglePlaceholders } from "
|
|
5
|
-
import { appendRegisterEvent, registerEventFilePath
|
|
6
|
-
import { REGISTER_TIMESTAMP_RE, resolveRegisterDateTimeZone, timestampFromDateInTimeZone, } from "./
|
|
7
|
-
import { applyRegisterItemFields, CELL_NONE, CELL_TODO, isPlaceholderCell, PJR_ID_ALPHABET, PJR_ID_RE, registerItemFieldsFromItem, setRegisterItemDescription, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "./
|
|
8
|
-
import { getProjectExecutionPath, getProjectRegisterPath, loadConfig, loadEnv, specdojoRootDir, } from "
|
|
9
|
-
import { flattenTemplateFrontmatter } from "
|
|
4
|
+
import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
5
|
+
import { appendRegisterEvent, registerEventFilePath } from "./events.js";
|
|
6
|
+
import { REGISTER_TIMESTAMP_RE, resolveRegisterDateTimeZone, timestampFromDateInTimeZone, } from "./date.js";
|
|
7
|
+
import { applyRegisterItemFields, CELL_NONE, CELL_TODO, isPlaceholderCell, PJR_ID_ALPHABET, PJR_ID_RE, registerItemFieldsFromItem, setRegisterItemDescription, toCell, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "./item.js";
|
|
8
|
+
import { getProjectExecutionPath, getProjectRegisterPath, loadConfig, loadEnv, loadMemberRoster, resolveRegisterActor, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
9
|
+
import { flattenTemplateFrontmatter } from "../docs/template-frontmatter.js";
|
|
10
10
|
export function registerEventActor(opts) {
|
|
11
|
-
|
|
11
|
+
const actor = opts.by?.trim() || process.env.SPECDOJO_ACTOR?.trim() || "SpecDojo";
|
|
12
|
+
const { config } = loadConfig();
|
|
13
|
+
if (!config)
|
|
14
|
+
throw new Error("register commands require specdojo.config.json");
|
|
15
|
+
const projectId = opts.project?.trim() ||
|
|
16
|
+
process.env.SPECDOJO_PROJECT?.trim() ||
|
|
17
|
+
Object.keys(config.projects)[0] ||
|
|
18
|
+
"";
|
|
19
|
+
const project = config.projects[projectId];
|
|
20
|
+
if (!project)
|
|
21
|
+
throw new Error(`Unknown project: ${projectId}`);
|
|
22
|
+
return resolveRegisterActor(actor, loadMemberRoster(specdojoRootDir(), project));
|
|
12
23
|
}
|
|
13
24
|
export function atomicWriteFile(path, content) {
|
|
14
25
|
mkdirSync(dirname(path), { recursive: true });
|
|
@@ -230,6 +241,7 @@ export function generatePjrId(existingIds, nextCandidate = defaultPjrCandidate,
|
|
|
230
241
|
}
|
|
231
242
|
export function formatTableRow(item) {
|
|
232
243
|
// frontmatter・本文由来を問わず、表へ展開する全セルを同じ規則で無害化する。
|
|
244
|
+
// 列区切りの `|` と改行をエスケープし、山括弧プレースホルダをインラインコード化する。
|
|
233
245
|
// 既存コードスパンは変換処理が保持するため、再生成しても二重に囲まれない。
|
|
234
246
|
const cells = [
|
|
235
247
|
item.id,
|
|
@@ -244,7 +256,9 @@ export function formatTableRow(item) {
|
|
|
244
256
|
item.completed,
|
|
245
257
|
item.conclusion,
|
|
246
258
|
item.ticket,
|
|
247
|
-
]
|
|
259
|
+
]
|
|
260
|
+
.map(toCell)
|
|
261
|
+
.map(inlineCodeAnglePlaceholders);
|
|
248
262
|
return `| ${cells.join(" | ")} |`;
|
|
249
263
|
}
|
|
250
264
|
// ================================
|
|
@@ -353,11 +367,15 @@ export function buildRegisterItemContent(opts) {
|
|
|
353
367
|
description: opts.fields.description,
|
|
354
368
|
type: opts.fields.type,
|
|
355
369
|
priority: opts.fields.priority,
|
|
370
|
+
...(opts.fields.difficulty ? { difficulty: opts.fields.difficulty } : {}),
|
|
356
371
|
owner: opts.fields.owner,
|
|
357
372
|
registeredAt: opts.fields.registeredAt,
|
|
358
373
|
due: opts.fields.due,
|
|
359
374
|
completedAt: opts.fields.completedAt,
|
|
360
375
|
conclusion: opts.fields.conclusion,
|
|
361
376
|
ticket: "-",
|
|
377
|
+
...(opts.fields.approach ? { approach: opts.fields.approach } : {}),
|
|
378
|
+
...(opts.fields.targets ? { targets: opts.fields.targets } : {}),
|
|
379
|
+
...(opts.fields.derivedFrom ? { derivedFrom: opts.fields.derivedFrom } : {}),
|
|
362
380
|
}));
|
|
363
381
|
}
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import { existsSync, mkdirSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { inlineCodeAnglePlaceholders } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
4
|
+
import { APPROACHES } from "../shared/agent-types.js";
|
|
5
|
+
import { appendRegisterEvent, buildRegisterEvent, registerEventFilePath } from "./events.js";
|
|
6
|
+
import { nowUtcTimestamp } from "./date.js";
|
|
7
|
+
import { CELL_NONE, CELL_TODO, REMOVE_REGISTER_ITEM_FIELD, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, } from "./item.js";
|
|
8
|
+
import { resolveSpecdojoTemplatePath } from "../docs/template-resolution.js";
|
|
9
|
+
import { validateRegisterApproachTargetsForProject } from "./approach.js";
|
|
10
|
+
import { normalizeDerivedFrom, validateDerivedFrom } from "./derivation.js";
|
|
11
|
+
function collectTarget(value, previous = []) {
|
|
12
|
+
return [...previous, value];
|
|
13
|
+
}
|
|
14
|
+
function normalizedTargets(values) {
|
|
15
|
+
if (values === undefined)
|
|
16
|
+
return undefined;
|
|
17
|
+
const targets = [...new Set(values.map((value) => value.trim()).filter(Boolean))];
|
|
18
|
+
if (targets.includes("-")) {
|
|
19
|
+
if (targets.length !== 1)
|
|
20
|
+
throw new Error("--target - cannot be combined with other targets");
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
if (targets.length === 0)
|
|
24
|
+
throw new Error("--target must contain a document id");
|
|
25
|
+
return targets;
|
|
26
|
+
}
|
|
8
27
|
export function registerCreateCommands(reg, dependencies) {
|
|
9
28
|
const { addProjectOption, addRegisterCommitOptions, atomicWriteFile, buildRegisterItemContent, derivedTopicNeedsWarning, generateDerivedViewFiles, loadRegisterItems, parseRegisterTimestampOption, planRegisterItem, printCommandError, printDerivedTopicWarning, registerEventActor, registerTopicPattern, resolveRegisterPaths, runRegisterMutation, slugify, writeDerivedViews, } = dependencies;
|
|
10
29
|
// --- scaffold ---
|
|
@@ -39,12 +58,16 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
39
58
|
addCmd.requiredOption("--title <title>", "Short title for the item");
|
|
40
59
|
addCmd.option("--description <text>", "Description shown in the list", "_TODO_");
|
|
41
60
|
addCmd.option("--priority <priority>", `Priority: ${VALID_PRIORITIES.join(" | ")}`, "medium");
|
|
61
|
+
addCmd.option("--difficulty <difficulty>", `Difficulty: ${VALID_DIFFICULTIES.join(" | ")}`);
|
|
42
62
|
addCmd.option("--status <status>", `Status: ${VALID_STATUSES.join(" | ")}`, "open");
|
|
43
63
|
addCmd.option("--owner <owner>", "Owner or role", "_TODO_");
|
|
44
64
|
addCmd.option("--registered <datetime>", "Registration date-time (RFC 3339 with time zone, or _TODO_; defaults to now in UTC)");
|
|
45
65
|
addCmd.option("--due <date>", "Due date (YYYY-MM-DD, -, or _TODO_)", "_TODO_");
|
|
46
66
|
addCmd.option("--completed <datetime>", "Completion date-time (RFC 3339 with time zone, or -)", "-");
|
|
47
67
|
addCmd.option("--conclusion <text>", "Conclusion or resolution summary", "-");
|
|
68
|
+
addCmd.option("--approach <approach>", `Execution approach: ${APPROACHES.join(" | ")}`);
|
|
69
|
+
addCmd.option("--target <doc-id>", "Target document id (repeatable; approach requires exactly one)", collectTarget);
|
|
70
|
+
addCmd.option("--from <item-id>", "Register item this item derives from (repeatable)", collectTarget);
|
|
48
71
|
addCmd.option("--id <id>", "Display ID (e.g., PJR-0061); auto-incremented if omitted");
|
|
49
72
|
addCmd.option("--topic <topic>", "Topic slug for ticket filename; derived from --title if omitted");
|
|
50
73
|
addCmd.option("--by <actor>", "Actor recorded in the append-only register event");
|
|
@@ -62,17 +85,34 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
62
85
|
}
|
|
63
86
|
const registeredAt = parseRegisterTimestampOption(opts.registered, "registered", CELL_TODO);
|
|
64
87
|
const completedAt = parseRegisterTimestampOption(opts.completed, "completed", CELL_NONE);
|
|
88
|
+
if (opts.difficulty !== undefined &&
|
|
89
|
+
!VALID_DIFFICULTIES.includes(opts.difficulty)) {
|
|
90
|
+
throw new Error(`Invalid difficulty: "${opts.difficulty}". Must be one of: ${VALID_DIFFICULTIES.join(", ")}`);
|
|
91
|
+
}
|
|
92
|
+
if (opts.target?.some((target) => target.trim() === "-")) {
|
|
93
|
+
throw new Error("--target - is only valid with register update");
|
|
94
|
+
}
|
|
95
|
+
const targets = normalizedTargets(opts.target);
|
|
96
|
+
validateRegisterApproachTargetsForProject({
|
|
97
|
+
projectId: paths.projectId,
|
|
98
|
+
...(opts.approach !== undefined ? { approach: opts.approach } : {}),
|
|
99
|
+
...(targets !== undefined ? { targets } : {}),
|
|
100
|
+
validateTargetsWithoutApproach: opts.target !== undefined,
|
|
101
|
+
});
|
|
65
102
|
const fields = {
|
|
66
103
|
type: opts.type,
|
|
67
104
|
title: opts.title,
|
|
68
105
|
description: opts.description,
|
|
69
106
|
priority: opts.priority,
|
|
107
|
+
...(opts.difficulty !== undefined ? { difficulty: opts.difficulty } : {}),
|
|
70
108
|
status: opts.status,
|
|
71
109
|
owner: opts.owner,
|
|
72
110
|
registeredAt: registeredAt ?? nowUtcTimestamp(),
|
|
73
111
|
due: opts.due,
|
|
74
112
|
completedAt: completedAt ?? CELL_NONE,
|
|
75
113
|
conclusion: opts.conclusion,
|
|
114
|
+
...(opts.approach !== undefined ? { approach: opts.approach } : {}),
|
|
115
|
+
...(targets !== undefined ? { targets } : {}),
|
|
76
116
|
};
|
|
77
117
|
const templatePath = resolveSpecdojoTemplatePath(`pjr-${opts.type}-template.md`);
|
|
78
118
|
const { assignedId: displayId, ticketFilename } = planRegisterItem({
|
|
@@ -81,6 +121,14 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
81
121
|
fields,
|
|
82
122
|
topic,
|
|
83
123
|
});
|
|
124
|
+
const derivedFrom = normalizeDerivedFrom(opts.from, { allowRemove: false });
|
|
125
|
+
validateDerivedFrom({
|
|
126
|
+
projectId: paths.projectId,
|
|
127
|
+
itemId: displayId,
|
|
128
|
+
derivedFrom,
|
|
129
|
+
});
|
|
130
|
+
if (derivedFrom !== undefined)
|
|
131
|
+
fields.derivedFrom = derivedFrom;
|
|
84
132
|
const ticketPath = join(paths.projectRegisterPath, ticketFilename);
|
|
85
133
|
const content = buildRegisterItemContent({
|
|
86
134
|
projectId: paths.projectId,
|
|
@@ -140,10 +188,15 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
140
188
|
updateCmd.option("--title <title>", "Update title");
|
|
141
189
|
updateCmd.option("--description <text>", "Update description");
|
|
142
190
|
updateCmd.option("--priority <priority>", `Update priority: ${VALID_PRIORITIES.join(" | ")}`);
|
|
191
|
+
updateCmd.option("--difficulty <difficulty>", `Update difficulty: ${VALID_DIFFICULTIES.join(" | ")}; use - to remove`);
|
|
143
192
|
updateCmd.option("--owner <owner>", "Update owner or role");
|
|
144
193
|
updateCmd.option("--due <date>", "Update due date (YYYY-MM-DD, -, or _TODO_)");
|
|
145
194
|
updateCmd.option("--conclusion <text>", "Update conclusion or use - to remove it");
|
|
146
195
|
updateCmd.option("--block-reason <text>", "Update the waiting reason or use - to remove it");
|
|
196
|
+
updateCmd.option("--autopilot <approval>", "Night orchestrator approval: approved, or - to revoke");
|
|
197
|
+
updateCmd.option("--approach <approach>", `Update execution approach (${APPROACHES.join(" | ")}; use - to remove)`);
|
|
198
|
+
updateCmd.option("--target <doc-id>", "Replace target document ids (repeatable; use - to remove)", collectTarget);
|
|
199
|
+
updateCmd.option("--from <item-id>", "Replace source register item IDs (repeatable; use - to remove)", collectTarget);
|
|
147
200
|
updateCmd.option("--topic <topic>", "Update the topic slug in the ticket filename and document ID");
|
|
148
201
|
updateCmd.option("--by <actor>", "Actor recorded in the append-only register event");
|
|
149
202
|
updateCmd.option("--reason <text>", "Reason recorded in the append-only register event");
|
|
@@ -158,19 +211,29 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
158
211
|
"title",
|
|
159
212
|
"description",
|
|
160
213
|
"priority",
|
|
214
|
+
"difficulty",
|
|
161
215
|
"owner",
|
|
162
216
|
"due",
|
|
163
217
|
"conclusion",
|
|
164
218
|
"blockReason",
|
|
219
|
+
"autopilot",
|
|
220
|
+
"approach",
|
|
221
|
+
"target",
|
|
222
|
+
"from",
|
|
165
223
|
"topic",
|
|
166
224
|
].some((key) => opts[key] !== undefined);
|
|
167
225
|
if (!hasUpdates) {
|
|
168
|
-
throw new Error("At least one field option must be specified (--title, --description, --priority, --owner, --due, --conclusion, --block-reason, --topic)");
|
|
226
|
+
throw new Error("At least one field option must be specified (--title, --description, --priority, --difficulty, --owner, --due, --conclusion, --block-reason, --autopilot, --approach, --target, --from, --topic)");
|
|
169
227
|
}
|
|
170
228
|
if (opts.priority !== undefined &&
|
|
171
229
|
!VALID_PRIORITIES.includes(opts.priority)) {
|
|
172
230
|
throw new Error(`Invalid priority: "${opts.priority}". Must be one of: ${VALID_PRIORITIES.join(", ")}`);
|
|
173
231
|
}
|
|
232
|
+
if (opts.difficulty !== undefined &&
|
|
233
|
+
opts.difficulty !== "-" &&
|
|
234
|
+
!VALID_DIFFICULTIES.includes(opts.difficulty)) {
|
|
235
|
+
throw new Error(`Invalid difficulty: "${opts.difficulty}". Must be one of: ${VALID_DIFFICULTIES.join(", ")}, -`);
|
|
236
|
+
}
|
|
174
237
|
if (opts.due !== undefined && !/^(\d{4}-\d{2}-\d{2}|-|_TODO_)$/.test(opts.due)) {
|
|
175
238
|
throw new Error(`Invalid due: "${opts.due}". Must be YYYY-MM-DD, -, or _TODO_`);
|
|
176
239
|
}
|
|
@@ -192,15 +255,97 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
192
255
|
? REMOVE_REGISTER_ITEM_FIELD
|
|
193
256
|
: inlineCodeAnglePlaceholders(blockReason),
|
|
194
257
|
};
|
|
258
|
+
if (opts.autopilot !== undefined && !["approved", "-"].includes(opts.autopilot)) {
|
|
259
|
+
throw new Error('Invalid autopilot approval. Use "approved" or "-".');
|
|
260
|
+
}
|
|
261
|
+
if (opts.autopilot === "approved" && item.type !== "todo" && item.type !== "issue") {
|
|
262
|
+
throw new Error(`Cannot approve ${item.id} for night autopilot: type is "${item.type}" (expected todo or issue).`);
|
|
263
|
+
}
|
|
264
|
+
const autopilotUpdates = opts.autopilot === undefined
|
|
265
|
+
? undefined
|
|
266
|
+
: {
|
|
267
|
+
autopilot: opts.autopilot === "-" ? REMOVE_REGISTER_ITEM_FIELD : "approved",
|
|
268
|
+
};
|
|
269
|
+
const nextApproach = opts.approach === undefined
|
|
270
|
+
? item.approach
|
|
271
|
+
: opts.approach.trim() === "-"
|
|
272
|
+
? undefined
|
|
273
|
+
: opts.approach.trim();
|
|
274
|
+
const nextTargets = opts.target === undefined ? item.targets : normalizedTargets(opts.target);
|
|
275
|
+
const nextDerivedFrom = opts.from === undefined
|
|
276
|
+
? item.derivedFrom
|
|
277
|
+
: normalizeDerivedFrom(opts.from, { allowRemove: true });
|
|
278
|
+
validateDerivedFrom({
|
|
279
|
+
projectId: paths.projectId,
|
|
280
|
+
itemId: item.id,
|
|
281
|
+
derivedFrom: nextDerivedFrom,
|
|
282
|
+
});
|
|
283
|
+
validateRegisterApproachTargetsForProject({
|
|
284
|
+
projectId: paths.projectId,
|
|
285
|
+
...(nextApproach !== undefined ? { approach: nextApproach } : {}),
|
|
286
|
+
...(nextTargets !== undefined ? { targets: nextTargets } : {}),
|
|
287
|
+
validateTargetsWithoutApproach: opts.target !== undefined,
|
|
288
|
+
});
|
|
289
|
+
const approachTargetUpdates = {
|
|
290
|
+
...(opts.difficulty !== undefined
|
|
291
|
+
? {
|
|
292
|
+
difficulty: opts.difficulty === "-" ? REMOVE_REGISTER_ITEM_FIELD : opts.difficulty,
|
|
293
|
+
}
|
|
294
|
+
: {}),
|
|
295
|
+
...(opts.approach !== undefined
|
|
296
|
+
? {
|
|
297
|
+
approach: nextApproach === undefined ? REMOVE_REGISTER_ITEM_FIELD : nextApproach,
|
|
298
|
+
}
|
|
299
|
+
: {}),
|
|
300
|
+
...(opts.target !== undefined
|
|
301
|
+
? {
|
|
302
|
+
targets: nextTargets ?? REMOVE_REGISTER_ITEM_FIELD,
|
|
303
|
+
}
|
|
304
|
+
: {}),
|
|
305
|
+
...(opts.from !== undefined
|
|
306
|
+
? {
|
|
307
|
+
derived_from: nextDerivedFrom ?? REMOVE_REGISTER_ITEM_FIELD,
|
|
308
|
+
}
|
|
309
|
+
: {}),
|
|
310
|
+
};
|
|
195
311
|
const updated = {
|
|
196
312
|
...item,
|
|
197
313
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
198
314
|
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
199
315
|
...(opts.priority !== undefined ? { priority: opts.priority } : {}),
|
|
316
|
+
...(opts.difficulty !== undefined && opts.difficulty !== "-"
|
|
317
|
+
? { difficulty: opts.difficulty }
|
|
318
|
+
: {}),
|
|
200
319
|
...(opts.owner !== undefined ? { owner: opts.owner } : {}),
|
|
201
320
|
...(opts.due !== undefined ? { due: opts.due } : {}),
|
|
202
321
|
...(opts.conclusion !== undefined ? { conclusion: opts.conclusion } : {}),
|
|
203
322
|
};
|
|
323
|
+
if (opts.difficulty === "-")
|
|
324
|
+
delete updated.difficulty;
|
|
325
|
+
if (opts.autopilot !== undefined) {
|
|
326
|
+
if (opts.autopilot === "-")
|
|
327
|
+
delete updated.autopilot;
|
|
328
|
+
else
|
|
329
|
+
updated.autopilot = "approved";
|
|
330
|
+
}
|
|
331
|
+
if (opts.approach !== undefined) {
|
|
332
|
+
if (nextApproach === undefined)
|
|
333
|
+
delete updated.approach;
|
|
334
|
+
else
|
|
335
|
+
updated.approach = nextApproach;
|
|
336
|
+
}
|
|
337
|
+
if (opts.target !== undefined) {
|
|
338
|
+
if (nextTargets === undefined)
|
|
339
|
+
delete updated.targets;
|
|
340
|
+
else
|
|
341
|
+
updated.targets = nextTargets;
|
|
342
|
+
}
|
|
343
|
+
if (opts.from !== undefined) {
|
|
344
|
+
if (nextDerivedFrom === undefined)
|
|
345
|
+
delete updated.derivedFrom;
|
|
346
|
+
else
|
|
347
|
+
updated.derivedFrom = nextDerivedFrom;
|
|
348
|
+
}
|
|
204
349
|
const currentTopic = view.ticketFilename
|
|
205
350
|
? ticketTopicFromFilename(opts.id, view.ticketFilename)
|
|
206
351
|
: undefined;
|
|
@@ -217,7 +362,17 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
217
362
|
topic,
|
|
218
363
|
updated,
|
|
219
364
|
dryRun: opts.dryRun,
|
|
220
|
-
...(blockReasonUpdates
|
|
365
|
+
...(blockReasonUpdates ||
|
|
366
|
+
autopilotUpdates ||
|
|
367
|
+
Object.keys(approachTargetUpdates).length > 0
|
|
368
|
+
? {
|
|
369
|
+
fieldUpdates: {
|
|
370
|
+
...blockReasonUpdates,
|
|
371
|
+
...autopilotUpdates,
|
|
372
|
+
...approachTargetUpdates,
|
|
373
|
+
},
|
|
374
|
+
}
|
|
375
|
+
: {}),
|
|
221
376
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
222
377
|
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
223
378
|
actor: registerEventActor(opts),
|
|
@@ -234,7 +389,15 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
234
389
|
action: "fields updated",
|
|
235
390
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
236
391
|
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
237
|
-
...(blockReasonUpdates
|
|
392
|
+
...(blockReasonUpdates || autopilotUpdates || Object.keys(approachTargetUpdates).length > 0
|
|
393
|
+
? {
|
|
394
|
+
fieldUpdates: {
|
|
395
|
+
...blockReasonUpdates,
|
|
396
|
+
...autopilotUpdates,
|
|
397
|
+
...approachTargetUpdates,
|
|
398
|
+
},
|
|
399
|
+
}
|
|
400
|
+
: {}),
|
|
238
401
|
eventAction: "update",
|
|
239
402
|
eventActor: registerEventActor(opts),
|
|
240
403
|
eventReason: opts.reason?.trim() || "fields updated",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_REGISTER_DATE_TIMEZONE } from "
|
|
1
|
+
import { DEFAULT_REGISTER_DATE_TIMEZONE } from "../shared/specdojo-config.js";
|
|
2
2
|
// 登録項目の日時(registered_at / completed_at)と、そこから導出する表示日の共通ヘルパー。
|
|
3
3
|
//
|
|
4
4
|
// 保存形式は UTC・RFC 3339・秒精度(`YYYY-MM-DDTHH:MM:SSZ`)に固定する。瞬間そのものを
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { getProjectRegisterPath, loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
4
|
+
import { loadRegisterItemDocs, PJR_ID_RE } from "./item.js";
|
|
5
|
+
const QUALIFIED_REGISTER_ITEM_REF_RE = /^([a-z][a-z0-9-]*):(PJR-[0-9ABCDEFGHJKMNPQRSTVWXYZ]{4})$/;
|
|
6
|
+
export function parseRegisterItemRef(value, currentProjectId) {
|
|
7
|
+
if (PJR_ID_RE.test(value))
|
|
8
|
+
return { projectId: currentProjectId, itemId: value };
|
|
9
|
+
const match = QUALIFIED_REGISTER_ITEM_REF_RE.exec(value);
|
|
10
|
+
return match ? { projectId: match[1], itemId: match[2] } : undefined;
|
|
11
|
+
}
|
|
12
|
+
export function normalizeDerivedFrom(values, options) {
|
|
13
|
+
if (values === undefined)
|
|
14
|
+
return undefined;
|
|
15
|
+
const refs = [...new Set(values.map((value) => value.trim()).filter(Boolean))];
|
|
16
|
+
if (refs.includes("-")) {
|
|
17
|
+
if (!options.allowRemove)
|
|
18
|
+
throw new Error("--from - is only valid with register update");
|
|
19
|
+
if (refs.length !== 1)
|
|
20
|
+
throw new Error("--from - cannot be combined with other item IDs");
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
if (refs.length === 0)
|
|
24
|
+
throw new Error("--from must contain a register item ID");
|
|
25
|
+
return refs;
|
|
26
|
+
}
|
|
27
|
+
function configuredItemIds(config, projectId) {
|
|
28
|
+
const project = config.projects[projectId];
|
|
29
|
+
if (!project)
|
|
30
|
+
return undefined;
|
|
31
|
+
const registerPath = getProjectRegisterPath(project);
|
|
32
|
+
if (!registerPath) {
|
|
33
|
+
throw new Error(`Cannot verify derived_from item in configured project ${projectId}: project_register_path is not set`);
|
|
34
|
+
}
|
|
35
|
+
const absolutePath = resolve(specdojoRootDir(), registerPath);
|
|
36
|
+
return new Set(loadRegisterItemDocs(absolutePath).map((doc) => doc.id));
|
|
37
|
+
}
|
|
38
|
+
function validateDerivedFromWithConfig(opts, config, idsByProject) {
|
|
39
|
+
for (const ref of opts.derivedFrom) {
|
|
40
|
+
const parsed = parseRegisterItemRef(ref, opts.projectId);
|
|
41
|
+
if (!parsed) {
|
|
42
|
+
throw new Error(`Invalid --from item ID: "${ref}". Use PJR-XXXX or <project-id>:PJR-XXXX`);
|
|
43
|
+
}
|
|
44
|
+
if (parsed.projectId === opts.projectId && parsed.itemId === opts.itemId) {
|
|
45
|
+
throw new Error(`Item ${opts.itemId} cannot derive from itself`);
|
|
46
|
+
}
|
|
47
|
+
if (!config.projects[parsed.projectId])
|
|
48
|
+
continue;
|
|
49
|
+
let ids = idsByProject.get(parsed.projectId);
|
|
50
|
+
if (!idsByProject.has(parsed.projectId)) {
|
|
51
|
+
ids = configuredItemIds(config, parsed.projectId);
|
|
52
|
+
idsByProject.set(parsed.projectId, ids);
|
|
53
|
+
}
|
|
54
|
+
if (!ids?.has(parsed.itemId)) {
|
|
55
|
+
throw new Error(`Derived-from item not found: ${ref} (searched configured project ${parsed.projectId})`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function validateDerivedFrom(opts) {
|
|
60
|
+
if (!opts.derivedFrom)
|
|
61
|
+
return;
|
|
62
|
+
const { config } = loadConfig();
|
|
63
|
+
if (!config)
|
|
64
|
+
throw new Error("register commands require specdojo.config.json");
|
|
65
|
+
validateDerivedFromWithConfig({ ...opts, derivedFrom: opts.derivedFrom }, config, new Map());
|
|
66
|
+
}
|
|
67
|
+
export function validateDerivedFromDocs(paths) {
|
|
68
|
+
const docs = loadRegisterItemDocs(paths.projectRegisterPath);
|
|
69
|
+
const derivedDocs = docs.filter((doc) => doc.item.derivedFrom !== undefined);
|
|
70
|
+
if (derivedDocs.length === 0)
|
|
71
|
+
return [];
|
|
72
|
+
let config;
|
|
73
|
+
try {
|
|
74
|
+
({ config } = loadConfig());
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return [`derived_from: ${error instanceof Error ? error.message : String(error)}`];
|
|
78
|
+
}
|
|
79
|
+
if (!config)
|
|
80
|
+
return ["derived_from: register commands require specdojo.config.json"];
|
|
81
|
+
const errors = [];
|
|
82
|
+
const idsByProject = new Map([
|
|
83
|
+
[paths.projectId, new Set(docs.map((doc) => doc.id))],
|
|
84
|
+
]);
|
|
85
|
+
for (const doc of derivedDocs) {
|
|
86
|
+
try {
|
|
87
|
+
validateDerivedFromWithConfig({
|
|
88
|
+
projectId: paths.projectId,
|
|
89
|
+
itemId: doc.id,
|
|
90
|
+
derivedFrom: doc.item.derivedFrom,
|
|
91
|
+
}, config, idsByProject);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
errors.push(`${doc.filename}: ${error instanceof Error ? error.message : String(error)}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return errors;
|
|
98
|
+
}
|
|
99
|
+
function configuredExternalRegisterDirectories(paths) {
|
|
100
|
+
let config;
|
|
101
|
+
try {
|
|
102
|
+
({ config } = loadConfig());
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// `init --dry-run` may intentionally preserve an existing, non-SpecDojo config file.
|
|
106
|
+
// The current project can still produce an empty/local derivation view in that case.
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
if (!config)
|
|
110
|
+
return [];
|
|
111
|
+
const configuredCurrent = config.projects[paths.projectId];
|
|
112
|
+
const configuredCurrentPath = configuredCurrent
|
|
113
|
+
? getProjectRegisterPath(configuredCurrent)
|
|
114
|
+
: undefined;
|
|
115
|
+
if (!configuredCurrentPath ||
|
|
116
|
+
resolve(specdojoRootDir(), configuredCurrentPath) !== resolve(paths.projectRegisterPath)) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
return Object.entries(config.projects).flatMap(([projectId, project]) => {
|
|
120
|
+
if (projectId === paths.projectId)
|
|
121
|
+
return [];
|
|
122
|
+
const registerPath = getProjectRegisterPath(project);
|
|
123
|
+
if (!registerPath)
|
|
124
|
+
return [];
|
|
125
|
+
const absolutePath = resolve(specdojoRootDir(), registerPath);
|
|
126
|
+
return existsSync(absolutePath) ? [{ projectId, registerPath: absolutePath }] : [];
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
export function collectDerivedRegisterRelations(paths, currentItems) {
|
|
130
|
+
const relations = [];
|
|
131
|
+
const collect = (projectId, items) => {
|
|
132
|
+
for (const item of items) {
|
|
133
|
+
for (const ref of item.item.derivedFrom ?? []) {
|
|
134
|
+
const source = parseRegisterItemRef(ref, projectId);
|
|
135
|
+
if (!source || source.projectId !== paths.projectId)
|
|
136
|
+
continue;
|
|
137
|
+
relations.push({
|
|
138
|
+
sourceId: source.itemId,
|
|
139
|
+
derivedProjectId: projectId,
|
|
140
|
+
derivedItem: item.item,
|
|
141
|
+
derivedTicketPath: item.ticketPath,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
collect(paths.projectId, currentItems.flatMap((view) => view.ticketPath ? [{ item: view.item, ticketPath: view.ticketPath }] : []));
|
|
147
|
+
for (const project of configuredExternalRegisterDirectories(paths)) {
|
|
148
|
+
collect(project.projectId, loadRegisterItemDocs(project.registerPath).map((doc) => ({
|
|
149
|
+
item: doc.item,
|
|
150
|
+
ticketPath: doc.path,
|
|
151
|
+
})));
|
|
152
|
+
}
|
|
153
|
+
return relations.sort((left, right) => {
|
|
154
|
+
if (left.sourceId !== right.sourceId)
|
|
155
|
+
return left.sourceId < right.sourceId ? -1 : 1;
|
|
156
|
+
if (left.derivedProjectId !== right.derivedProjectId) {
|
|
157
|
+
return left.derivedProjectId < right.derivedProjectId ? -1 : 1;
|
|
158
|
+
}
|
|
159
|
+
if (left.derivedItem.id === right.derivedItem.id)
|
|
160
|
+
return 0;
|
|
161
|
+
return left.derivedItem.id < right.derivedItem.id ? -1 : 1;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// 統合 merge で登録簿の記帳ファイルが競合したときの解決処理。イベントファイルは追記型の記録なので、
|
|
2
2
|
// 両側のイベントの和集合(同一 id は 1 件)を時刻順に並べ、`previous_event_id` の連鎖を張り直す。
|
|
3
3
|
// 個票は exec branch 側を基準にし、統合先だけにあるイベントが変えたフィールドのうち、frontmatter の
|
|
4
|
-
// 単純な値へ写せるもの(type / priority / owner / due
|
|
5
|
-
|
|
6
|
-
import {
|
|
4
|
+
// 単純な値へ写せるもの(type / priority / difficulty / owner / due / approach / targets /
|
|
5
|
+
// derived_from)だけを再構築する。
|
|
6
|
+
import { readRegisterEventsFromContent, serializeRegisterEvents, } from "./events.js";
|
|
7
|
+
import { applyRegisterItemFields, CELL_NONE, CELL_TODO, REMOVE_REGISTER_ITEM_FIELD, } from "./item.js";
|
|
7
8
|
function hasStatusChange(event) {
|
|
8
9
|
return event.changes.some((change) => change.field === "status");
|
|
9
10
|
}
|
|
@@ -126,6 +127,12 @@ function fieldUpdateFromChange(change) {
|
|
|
126
127
|
return isUnset ? undefined : { item_type: value };
|
|
127
128
|
case "priority":
|
|
128
129
|
return isUnset ? undefined : { priority: value };
|
|
130
|
+
case "difficulty":
|
|
131
|
+
return isUnset
|
|
132
|
+
? { difficulty: REMOVE_REGISTER_ITEM_FIELD }
|
|
133
|
+
: ["hard", "medium", "easy"].includes(value)
|
|
134
|
+
? { difficulty: value }
|
|
135
|
+
: undefined;
|
|
129
136
|
case "owner":
|
|
130
137
|
return { owner: isUnset ? null : value };
|
|
131
138
|
case "due":
|
|
@@ -136,6 +143,40 @@ function fieldUpdateFromChange(change) {
|
|
|
136
143
|
? null
|
|
137
144
|
: value,
|
|
138
145
|
};
|
|
146
|
+
case "approach":
|
|
147
|
+
return { approach: isUnset ? REMOVE_REGISTER_ITEM_FIELD : value };
|
|
148
|
+
case "targets": {
|
|
149
|
+
if (isUnset)
|
|
150
|
+
return { targets: REMOVE_REGISTER_ITEM_FIELD };
|
|
151
|
+
try {
|
|
152
|
+
const parsed = JSON.parse(value);
|
|
153
|
+
return Array.isArray(parsed) && parsed.every((target) => typeof target === "string")
|
|
154
|
+
? { targets: parsed }
|
|
155
|
+
: undefined;
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
case "derived_from": {
|
|
162
|
+
if (isUnset)
|
|
163
|
+
return { derived_from: REMOVE_REGISTER_ITEM_FIELD };
|
|
164
|
+
try {
|
|
165
|
+
const parsed = JSON.parse(value);
|
|
166
|
+
return Array.isArray(parsed) && parsed.every((ref) => typeof ref === "string")
|
|
167
|
+
? { derived_from: parsed }
|
|
168
|
+
: undefined;
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
case "autopilot":
|
|
175
|
+
return isUnset
|
|
176
|
+
? { autopilot: REMOVE_REGISTER_ITEM_FIELD }
|
|
177
|
+
: value === "approved"
|
|
178
|
+
? { autopilot: "approved" }
|
|
179
|
+
: undefined;
|
|
139
180
|
default:
|
|
140
181
|
return undefined;
|
|
141
182
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
-
import { dump, load } from "
|
|
7
|
-
import { CELL_NONE, displayIdFromTicketFilename, readRegisterItemContent, readSpecdojoFields, toDisplayItem, updateSpecdojoFields, VALID_STATUSES, } from "./
|
|
8
|
-
import { isUtcIsoSeconds, nowUtcIsoSeconds } from "
|
|
6
|
+
import { dump, load } from "../shared/yaml.js";
|
|
7
|
+
import { CELL_NONE, displayIdFromTicketFilename, readRegisterItemContent, readSpecdojoFields, toDisplayItem, updateSpecdojoFields, VALID_STATUSES, } from "./item.js";
|
|
8
|
+
import { isUtcIsoSeconds, nowUtcIsoSeconds } from "../shared/time.js";
|
|
9
9
|
export const REGISTER_EVENTS_DIRNAME = "events";
|
|
10
10
|
export const REGISTER_EVENTS_SCHEMA_MODELINE = "# yaml-language-server: $schema=../../../../../../specdojo/schemas/v1/register-events.schema.yaml";
|
|
11
11
|
export const REGISTER_EVENT_FIELDS = [
|
|
@@ -14,12 +14,17 @@ export const REGISTER_EVENT_FIELDS = [
|
|
|
14
14
|
"description",
|
|
15
15
|
"type",
|
|
16
16
|
"priority",
|
|
17
|
+
"difficulty",
|
|
17
18
|
"owner",
|
|
18
19
|
"registered",
|
|
19
20
|
"due",
|
|
20
21
|
"completed",
|
|
21
22
|
"conclusion",
|
|
22
23
|
"block_reason",
|
|
24
|
+
"approach",
|
|
25
|
+
"targets",
|
|
26
|
+
"derived_from",
|
|
27
|
+
"autopilot",
|
|
23
28
|
];
|
|
24
29
|
export const REGISTER_EVENT_ACTIONS = [
|
|
25
30
|
"add",
|
|
@@ -62,12 +67,17 @@ export function registerEventFieldValues(content, filename, timeZone) {
|
|
|
62
67
|
description: item.description,
|
|
63
68
|
type: item.type,
|
|
64
69
|
priority: item.priority,
|
|
70
|
+
difficulty: item.difficulty ?? CELL_NONE,
|
|
65
71
|
owner: item.owner,
|
|
66
72
|
registered: item.registered,
|
|
67
73
|
due: item.due,
|
|
68
74
|
completed: item.completed,
|
|
69
75
|
conclusion: item.conclusion,
|
|
70
76
|
block_reason: parsed.blockReason,
|
|
77
|
+
approach: item.approach ?? CELL_NONE,
|
|
78
|
+
targets: item.targets ? JSON.stringify(item.targets) : CELL_NONE,
|
|
79
|
+
derived_from: item.derivedFrom ? JSON.stringify(item.derivedFrom) : CELL_NONE,
|
|
80
|
+
autopilot: item.autopilot ?? CELL_NONE,
|
|
71
81
|
};
|
|
72
82
|
}
|
|
73
83
|
function isUnsetFieldValue(value) {
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// 未移行の期間だけ Git 差分を読み、event の開始時刻より前の legacy 履歴として統合する。
|
|
3
3
|
//
|
|
4
4
|
// 比較対象は生成される登録項目一覧の列(ステータス・タイトル・説明・分類・優先度・担当・
|
|
5
|
-
//
|
|
6
|
-
//
|
|
5
|
+
// 登録日・期限・完了日・結論)に、待機時のブロック理由と approach / targets /
|
|
6
|
+
// derived_from を加える。
|
|
7
|
+
// 一覧に表示しない構造化フィールドも、個票の更新履歴として監査できるよう比較対象にする。
|
|
7
8
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
8
9
|
import { basename, join } from "node:path";
|
|
9
|
-
import { displayIdFromTicketFilename, isPlaceholderCell } from "./
|
|
10
|
-
import { gitOutput, gitResult } from "
|
|
11
|
-
import { DEFAULT_REGISTER_DATE_TIMEZONE } from "
|
|
12
|
-
import { REGISTER_EVENT_FIELDS, REGISTER_EVENTS_DIRNAME, displayIdFromRegisterEventFilename, readRegisterEventsFromContent, registerEventFieldValues, } from "./
|
|
10
|
+
import { displayIdFromTicketFilename, isPlaceholderCell } from "./item.js";
|
|
11
|
+
import { gitOutput, gitResult } from "../shared/git.js";
|
|
12
|
+
import { DEFAULT_REGISTER_DATE_TIMEZONE } from "../shared/specdojo-config.js";
|
|
13
|
+
import { REGISTER_EVENT_FIELDS, REGISTER_EVENTS_DIRNAME, displayIdFromRegisterEventFilename, readRegisterEventsFromContent, registerEventFieldValues, } from "./events.js";
|
|
13
14
|
// 比較する項目と出力順。登録項目一覧の列順(ID と個票リンクを除く)に合わせる。
|
|
14
15
|
export const REGISTER_HISTORY_FIELDS = REGISTER_EVENT_FIELDS;
|
|
15
16
|
// git log の1コミット分の区切り(レコード分離子)とヘッダー項目の区切り(単位分離子)。
|