specdojo 0.3.1 → 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 +47 -0
- package/README.md +77 -18
- 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} +98 -32
- package/dist/{orchestrator.js → commands/orchestrator.js} +2 -2
- 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} +5 -3
- package/dist/{devcontainer-scaffold.js → devcontainer/scaffold.js} +94 -2
- 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} +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-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} +4 -4
- package/dist/{exec-pipeline-state.js → exec/pipeline-state.js} +16 -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} +92 -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} +13 -10
- 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} +29 -12
- package/dist/{exec-results.js → exec/results.js} +256 -22
- package/dist/{exec-run-agent-pipeline.js → exec/run/agent-pipeline.js} +32 -12
- package/dist/{exec-run-agent.js → exec/run/agent.js} +79 -27
- package/dist/{exec-run-in-place.js → exec/run/in-place.js} +56 -27
- package/dist/{exec-run-job.js → exec/run/job.js} +64 -35
- 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} +18 -10
- package/dist/{exec-run-register-core.js → exec/run/register-core.js} +46 -21
- package/dist/{exec-run-register-mode.js → exec/run/register-mode.js} +20 -16
- package/dist/{exec-run-register-resume.js → exec/run/register-resume.js} +22 -17
- 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} +54 -23
- 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} +61 -11
- 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-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} +13 -7
- package/dist/{register-create-commands.js → register/create-commands.js} +115 -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} +32 -3
- package/dist/{register-events.js → register/events.js} +9 -3
- package/dist/{register-history.js → register/history.js} +7 -6
- package/dist/{register-item.js → register/item.js} +23 -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} +4 -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/{exec-worktree.js → shared/git.js} +83 -241
- 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} +93 -5
- package/dist/{exec-shared.js → shared/text.js} +0 -134
- package/dist/shared/time.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 +91 -16
- 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 +31 -0
- 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 +5 -5
- 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 +1 -1
- package/templates/antigravity/README.md +5 -1
- package/templates/antigravity/agent-members-snippet.yaml +108 -12
- package/templates/antigravity/exec-defaults-snippet.yaml +8 -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 +24 -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-schedule-gantt-chart.js +0 -2
- 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,14 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { extname, isAbsolute, join, relative, resolve } from "node:path";
|
|
4
|
-
import { load } from "
|
|
5
|
-
import { collectResolvedDeliverables, loadCatalogDocs } from "
|
|
6
|
-
import { isTrashedPath, resolveBasePath } from "
|
|
7
|
-
import { listFilesRecursive } from "
|
|
8
|
-
import { gradeContentHash } from "./
|
|
9
|
-
import { GRADE_TARGETS, KATA_DIRS, KATA_REFERENCE_EXTENSIONS, KATA_REFERENCE_FIELDS, gradedViewpoints, isRecord, parseMarkdown, } from "./
|
|
10
|
-
import { resolveViewpointsDoc } from "
|
|
11
|
-
import { assertValidActor, getProjectCatalogPath, getProjectMembersPath, getProjectRolesPath, getProjectSchedulePath, getProjectViewpointsPath, loadConfig, specdojoRootDir, } from "
|
|
4
|
+
import { load } from "../shared/yaml.js";
|
|
5
|
+
import { collectResolvedDeliverables, loadCatalogDocs } from "../catalog/build.js";
|
|
6
|
+
import { isTrashedPath, resolveBasePath } from "../catalog/paths.js";
|
|
7
|
+
import { listFilesRecursive } from "../shared/fs.js";
|
|
8
|
+
import { gradeContentHash } from "./result.js";
|
|
9
|
+
import { GRADE_TARGETS, KATA_DIRS, KATA_REFERENCE_EXTENSIONS, KATA_REFERENCE_FIELDS, gradedViewpoints, isRecord, parseMarkdown, } from "./core.js";
|
|
10
|
+
import { resolveViewpointsDoc } from "../review/plan.js";
|
|
11
|
+
import { assertValidActor, getProjectCatalogPath, getProjectMembersPath, getProjectRolesPath, getProjectSchedulePath, getProjectViewpointsPath, loadConfig, resolveAgentMember, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
12
12
|
export function resolveProject(projectOption) {
|
|
13
13
|
const { config } = loadConfig();
|
|
14
14
|
if (!config)
|
|
@@ -39,6 +39,9 @@ export function resolveGradeActor(actor, roster) {
|
|
|
39
39
|
throw new Error("--by must be a non-empty agent-members.yaml nickname");
|
|
40
40
|
if (!roster)
|
|
41
41
|
throw new Error("members_path is required for grade apply --by");
|
|
42
|
+
const resolvedAgent = resolveAgentMember(roster, normalized);
|
|
43
|
+
if (resolvedAgent)
|
|
44
|
+
return resolvedAgent.nickname;
|
|
42
45
|
assertValidActor(normalized, roster);
|
|
43
46
|
if (roster.members.filter((member) => member.nickname === normalized).length !== 1) {
|
|
44
47
|
throw new Error(`Duplicate actor nickname in members_path: ${normalized}`);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { basename, join, resolve } from "node:path";
|
|
3
|
-
import { load } from "
|
|
4
|
-
import { listFilesRecursive, readJson } from "
|
|
5
|
-
import { getProjectExecutionPath, getProjectJobsPath, loadConfig, loadEnv, specdojoRootDir, } from "
|
|
3
|
+
import { load } from "../shared/yaml.js";
|
|
4
|
+
import { listFilesRecursive, readJson } from "../shared/fs.js";
|
|
5
|
+
import { getProjectExecutionPath, getProjectJobsPath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
6
6
|
function isRecord(value) {
|
|
7
7
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
8
|
}
|
|
@@ -117,7 +117,11 @@ export function jobRunUsesReviewedIntegration(definition, opts) {
|
|
|
117
117
|
return jobDeclaresReview(definition) || !!opts.worktree;
|
|
118
118
|
}
|
|
119
119
|
function isJobRunState(value) {
|
|
120
|
-
return value === "running" ||
|
|
120
|
+
return (value === "running" ||
|
|
121
|
+
value === "succeeded" ||
|
|
122
|
+
value === "partial" ||
|
|
123
|
+
value === "failed" ||
|
|
124
|
+
value === "noop");
|
|
121
125
|
}
|
|
122
126
|
function isJobTaskDefinition(value) {
|
|
123
127
|
if (!isRecord(value))
|
|
@@ -130,6 +134,10 @@ function isJobTaskDefinition(value) {
|
|
|
130
134
|
return false;
|
|
131
135
|
if (value.mode === "command") {
|
|
132
136
|
return (typeof value.command === "string" &&
|
|
137
|
+
(value.partial_exit_code === undefined ||
|
|
138
|
+
(Number.isSafeInteger(value.partial_exit_code) &&
|
|
139
|
+
Number(value.partial_exit_code) >= 1 &&
|
|
140
|
+
Number(value.partial_exit_code) <= 255)) &&
|
|
133
141
|
(value.precondition === undefined ||
|
|
134
142
|
(isRecord(value.precondition) &&
|
|
135
143
|
typeof value.precondition.command === "string" &&
|
|
@@ -371,6 +379,13 @@ export function parseJobDefinition(value, fileName) {
|
|
|
371
379
|
const command = typeof value.task.command === "string" ? value.task.command.trim() : "";
|
|
372
380
|
if (!command)
|
|
373
381
|
errors.push("task.command is required for command mode");
|
|
382
|
+
const partialExitCode = value.task.partial_exit_code;
|
|
383
|
+
if (partialExitCode !== undefined &&
|
|
384
|
+
(!Number.isSafeInteger(partialExitCode) ||
|
|
385
|
+
Number(partialExitCode) < 1 ||
|
|
386
|
+
Number(partialExitCode) > 255)) {
|
|
387
|
+
errors.push("task.partial_exit_code must be an exit code from 1 to 255");
|
|
388
|
+
}
|
|
374
389
|
let precondition;
|
|
375
390
|
if (value.task.precondition !== undefined) {
|
|
376
391
|
if (!isRecord(value.task.precondition)) {
|
|
@@ -438,6 +453,9 @@ export function parseJobDefinition(value, fileName) {
|
|
|
438
453
|
mode: "command",
|
|
439
454
|
...(precondition ? { precondition } : {}),
|
|
440
455
|
command,
|
|
456
|
+
...(Number.isSafeInteger(partialExitCode)
|
|
457
|
+
? { partial_exit_code: Number(partialExitCode) }
|
|
458
|
+
: {}),
|
|
441
459
|
...(analysis ? { analysis } : {}),
|
|
442
460
|
...common,
|
|
443
461
|
};
|
|
@@ -460,8 +478,9 @@ export function parseJobDefinition(value, fileName) {
|
|
|
460
478
|
}
|
|
461
479
|
if (value.task.analysis !== undefined ||
|
|
462
480
|
value.task.command !== undefined ||
|
|
463
|
-
value.task.precondition !== undefined
|
|
464
|
-
|
|
481
|
+
value.task.precondition !== undefined ||
|
|
482
|
+
value.task.partial_exit_code !== undefined) {
|
|
483
|
+
errors.push("task.command, task.precondition, task.partial_exit_code, and task.analysis are only allowed in command mode");
|
|
465
484
|
}
|
|
466
485
|
if (value.task.capabilities !== undefined && !validStringList(value.task.capabilities)) {
|
|
467
486
|
errors.push("task.capabilities must be a non-empty string list");
|
|
@@ -2,15 +2,16 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import { spawn, spawnSync } from "node:child_process";
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { join, relative, resolve } from "node:path";
|
|
5
|
-
import { buildSpecdojoFrontmatter } from "
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
5
|
+
import { buildSpecdojoFrontmatter } from "../docs/frontmatter-namespace.js";
|
|
6
|
+
import { listFilesRecursive, writeJson } from "../shared/fs.js";
|
|
7
|
+
import { gitEnvironment } from "../shared/git.js";
|
|
8
|
+
import { formatMarkdownFile } from "../shared/markdown-format.js";
|
|
9
|
+
import { execTemplatePath, injectCommonConventions, MISSING } from "../shared/plan-templates.js";
|
|
10
|
+
import { expandTemplate } from "../shared/text.js";
|
|
11
|
+
import { isJobAgentTask, isJobCommandTask, getPath, loadAllJobs, loadJobDefinition, loadJobRunRecord, parseInputValue, parseJobInputs, renderJobTemplate, resolveJobPaths, validateJobInputValue, } from "./definition.js";
|
|
12
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
13
|
+
import { selfRunCommand } from "../shared/spawn-self.js";
|
|
14
|
+
export { isJobAgentTask, isJobCommandTask, jobDeclaresReview, jobRunUsesReviewedIntegration, loadAllJobs, loadJobDefinition, loadJobRunRecord, parseJobDefinition, parseJobInputs, renderJobTemplate, resolveJobPaths, resolveJobReviewAgentNominations, } from "./definition.js";
|
|
14
15
|
export function jobCheckpoint(paths, jobId) {
|
|
15
16
|
return deriveJobState(paths).jobs[jobId]?.checkpoint ?? {};
|
|
16
17
|
}
|
|
@@ -255,7 +256,7 @@ export async function generateJobPlan(paths, definition, record) {
|
|
|
255
256
|
"```",
|
|
256
257
|
"",
|
|
257
258
|
commandTask.analysis
|
|
258
|
-
? "
|
|
259
|
+
? "コマンドが成功または設定済みの部分成功になった場合、上記の判断を reporter agent が evidence に基づいて行う。"
|
|
259
260
|
: "コマンドの終了コードから Run の成否を直接決定する。",
|
|
260
261
|
].join("\n")
|
|
261
262
|
: "",
|
|
@@ -380,7 +381,7 @@ export async function materializeJobRun(opts) {
|
|
|
380
381
|
if (record.idempotency_key !== idempotencyKey || record.job_id !== definition.id) {
|
|
381
382
|
throw new Error(`Job Run identity collision: ${runId}`);
|
|
382
383
|
}
|
|
383
|
-
if (record.state === "succeeded" || record.state === "noop") {
|
|
384
|
+
if (record.state === "succeeded" || record.state === "partial" || record.state === "noop") {
|
|
384
385
|
return {
|
|
385
386
|
definition,
|
|
386
387
|
record,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, extname, join, relative, resolve } from "node:path";
|
|
3
|
-
import { load } from "
|
|
4
|
-
import { readSpecdojoNamespace } from "
|
|
5
|
-
import { specdojoResourceCandidates } from "
|
|
3
|
+
import { load } from "../shared/yaml.js";
|
|
4
|
+
import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
|
|
5
|
+
import { specdojoResourceCandidates, } from "../docs/template-resolution.js";
|
|
6
6
|
export const KATA_RESOURCE_KINDS = [
|
|
7
7
|
"rulebook",
|
|
8
8
|
"standard",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { specdojoRootDir } from "
|
|
3
|
-
import { readSpecdojoNamespace } from "
|
|
4
|
-
import { practiceLocalId } from "
|
|
5
|
-
import { resolveSpecdojoPathIfExists, resolveSpecdojoReferencePathIfExists, specdojoResourceCandidates, } from "
|
|
6
|
-
import { readYamlSchemaModelineRef } from "
|
|
2
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
3
|
+
import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
|
|
4
|
+
import { practiceLocalId } from "../shared/practice-id.js";
|
|
5
|
+
import { resolveSpecdojoPathIfExists, resolveSpecdojoReferencePathIfExists, specdojoResourceCandidates, } from "../docs/template-resolution.js";
|
|
6
|
+
import { readYamlSchemaModelineRef } from "../shared/yaml-schema-modeline.js";
|
|
7
7
|
// 実践の型(rulebook / recipe / sample / template)の解決を 1 か所に集約する。
|
|
8
8
|
// plan 生成(明示パスの注入)と validate(参照先の存在確認)の両方から使う。
|
|
9
9
|
const MISSING = "_MISSING_";
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, resolve } from "node:path";
|
|
3
|
+
import { collectResolvedDeliverables, loadCatalogDocs } from "../catalog/build.js";
|
|
4
|
+
import { resolveBasePath } from "../catalog/paths.js";
|
|
5
|
+
import { collectDocIndexEntries } from "../docs/doc-index.js";
|
|
6
|
+
import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
|
|
7
|
+
import { getProjectCatalogPath, loadConfig, specdojoRootDir } from "../shared/specdojo-config.js";
|
|
8
|
+
import { APPROACHES } from "../shared/agent-types.js";
|
|
9
|
+
import { load } from "../shared/yaml.js";
|
|
10
|
+
const MAINTENANCE_TARGET_KIND = {
|
|
11
|
+
"rulebook-maintenance": "rulebook",
|
|
12
|
+
"recipe-maintenance": "recipe",
|
|
13
|
+
"sample-maintenance": "sample",
|
|
14
|
+
"template-maintenance": "template",
|
|
15
|
+
};
|
|
16
|
+
function resolvedIndexPath(repoRoot, indexedPath) {
|
|
17
|
+
const withoutLine = indexedPath.replace(/:\d+$/, "");
|
|
18
|
+
return resolve(isAbsolute(withoutLine) ? withoutLine : resolve(repoRoot, withoutLine));
|
|
19
|
+
}
|
|
20
|
+
function catalogDeliverableDocIds(catalogPath, repoRoot, projectId) {
|
|
21
|
+
const ids = new Set();
|
|
22
|
+
if (!existsSync(catalogPath))
|
|
23
|
+
return ids;
|
|
24
|
+
for (const loaded of loadCatalogDocs(catalogPath)) {
|
|
25
|
+
const deliverables = [];
|
|
26
|
+
collectResolvedDeliverables(loaded.doc.groups, resolveBasePath("", loaded.doc.base_path), deliverables);
|
|
27
|
+
for (const deliverable of deliverables) {
|
|
28
|
+
// register の対象指定では、PJR-H72A が定める成果物 local_id の canonical 形式も
|
|
29
|
+
// 受け付ける。文書が既にあれば、その frontmatter の実 ID も同じ成果物として扱う。
|
|
30
|
+
ids.add(`${projectId}:${deliverable.item.local_id}`);
|
|
31
|
+
const path = resolve(repoRoot, deliverable.resolvedPath);
|
|
32
|
+
if (existsSync(path)) {
|
|
33
|
+
try {
|
|
34
|
+
const id = readSpecdojoNamespace(readFileSync(path, "utf8")).id;
|
|
35
|
+
if (typeof id === "string" && id.trim()) {
|
|
36
|
+
ids.add(id.trim());
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// 読み取り不能・不正 frontmatter は配置規約による ID へフォールバックする。
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const normalizedPath = deliverable.resolvedPath.replaceAll("\\", "/").replace(/^\/+/, "");
|
|
45
|
+
if (/^docs\/[a-z]{2}\/product(?:\/|$)/.test(normalizedPath)) {
|
|
46
|
+
ids.add(deliverable.item.local_id);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return ids;
|
|
51
|
+
}
|
|
52
|
+
function targetDocumentType(path) {
|
|
53
|
+
if (!existsSync(path))
|
|
54
|
+
return undefined;
|
|
55
|
+
const content = readFileSync(path, "utf8");
|
|
56
|
+
if (path.endsWith(".md")) {
|
|
57
|
+
const type = readSpecdojoNamespace(content).type;
|
|
58
|
+
return typeof type === "string" ? type : undefined;
|
|
59
|
+
}
|
|
60
|
+
const parsed = load(content);
|
|
61
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
62
|
+
return undefined;
|
|
63
|
+
const type = parsed.type;
|
|
64
|
+
return typeof type === "string" ? type : undefined;
|
|
65
|
+
}
|
|
66
|
+
// register の個票に approach を書く時点で、対象が一意かつ実行方式に合うことを保証する。
|
|
67
|
+
// kata は都度 docs から収集した索引、成果物は DCT を正本として解決し、生成済みの
|
|
68
|
+
// .specdojo/doc-index.json の鮮度や成果物文書の作成済み・未作成には依存しない。
|
|
69
|
+
export function validateRegisterApproachTargets(opts) {
|
|
70
|
+
const approachText = opts.approach?.trim();
|
|
71
|
+
const targets = [...new Set((opts.targets ?? []).map((target) => target.trim()).filter(Boolean))];
|
|
72
|
+
let approach;
|
|
73
|
+
if (approachText !== undefined) {
|
|
74
|
+
if (!APPROACHES.includes(approachText)) {
|
|
75
|
+
throw new Error(`Invalid approach: "${approachText}". Must be one of: ${APPROACHES.join(", ")}`);
|
|
76
|
+
}
|
|
77
|
+
approach = approachText;
|
|
78
|
+
if (targets.length !== 1) {
|
|
79
|
+
throw new Error(`Approach "${approach}" requires exactly one --target doc id (received ${targets.length})`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (!approach && !opts.validateTargetsWithoutApproach)
|
|
83
|
+
return;
|
|
84
|
+
if (targets.length === 0)
|
|
85
|
+
return;
|
|
86
|
+
const entries = collectDocIndexEntries(resolve(opts.repoRoot, "docs"), opts.repoRoot);
|
|
87
|
+
if (!approach) {
|
|
88
|
+
for (const target of targets) {
|
|
89
|
+
if (!entries[target]) {
|
|
90
|
+
throw new Error(`Target document id is not resolvable via the document index: ${target}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const expectedKind = MAINTENANCE_TARGET_KIND[approach];
|
|
96
|
+
const [targetId] = targets;
|
|
97
|
+
if (expectedKind) {
|
|
98
|
+
const indexedPath = entries[targetId];
|
|
99
|
+
if (!indexedPath) {
|
|
100
|
+
throw new Error(`Target document id is not resolvable via the document index: ${targetId}`);
|
|
101
|
+
}
|
|
102
|
+
const actualKind = targetDocumentType(resolvedIndexPath(opts.repoRoot, indexedPath));
|
|
103
|
+
if (actualKind !== expectedKind) {
|
|
104
|
+
throw new Error(`Approach "${approach}" requires a ${expectedKind} document target, but ${targetId} has type "${actualKind ?? "unknown"}"`);
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (!opts.catalogPath) {
|
|
109
|
+
throw new Error(`Approach "${approach}" requires a deliverable target, but catalog_path is not configured for project ${opts.projectId}`);
|
|
110
|
+
}
|
|
111
|
+
const deliverableDocIds = catalogDeliverableDocIds(opts.catalogPath, opts.repoRoot, opts.projectId);
|
|
112
|
+
if (!deliverableDocIds.has(targetId)) {
|
|
113
|
+
throw new Error(`Approach "${approach}" requires a deliverable document from the project catalog, but ${targetId} is not a catalog deliverable`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export function validateRegisterApproachTargetsForProject(opts) {
|
|
117
|
+
const repoRoot = specdojoRootDir();
|
|
118
|
+
const { config, configPath } = loadConfig();
|
|
119
|
+
const project = config?.projects[opts.projectId];
|
|
120
|
+
if (!project) {
|
|
121
|
+
throw new Error(`Unknown project: ${opts.projectId} (check ${configPath})`);
|
|
122
|
+
}
|
|
123
|
+
const catalogPath = getProjectCatalogPath(project);
|
|
124
|
+
validateRegisterApproachTargets({
|
|
125
|
+
repoRoot,
|
|
126
|
+
projectId: opts.projectId,
|
|
127
|
+
...(catalogPath ? { catalogPath: resolve(repoRoot, catalogPath) } : {}),
|
|
128
|
+
...(opts.approach !== undefined ? { approach: opts.approach } : {}),
|
|
129
|
+
...(opts.targets !== undefined ? { targets: opts.targets } : {}),
|
|
130
|
+
...(opts.validateTargetsWithoutApproach !== undefined
|
|
131
|
+
? { validateTargetsWithoutApproach: opts.validateTargetsWithoutApproach }
|
|
132
|
+
: {}),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
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, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
9
|
+
import { flattenTemplateFrontmatter } from "../docs/template-frontmatter.js";
|
|
10
10
|
export function registerEventActor(opts) {
|
|
11
11
|
return opts.by?.trim() || process.env.SPECDOJO_ACTOR?.trim() || "manual";
|
|
12
12
|
}
|
|
@@ -230,6 +230,7 @@ export function generatePjrId(existingIds, nextCandidate = defaultPjrCandidate,
|
|
|
230
230
|
}
|
|
231
231
|
export function formatTableRow(item) {
|
|
232
232
|
// frontmatter・本文由来を問わず、表へ展開する全セルを同じ規則で無害化する。
|
|
233
|
+
// 列区切りの `|` と改行をエスケープし、山括弧プレースホルダをインラインコード化する。
|
|
233
234
|
// 既存コードスパンは変換処理が保持するため、再生成しても二重に囲まれない。
|
|
234
235
|
const cells = [
|
|
235
236
|
item.id,
|
|
@@ -244,7 +245,9 @@ export function formatTableRow(item) {
|
|
|
244
245
|
item.completed,
|
|
245
246
|
item.conclusion,
|
|
246
247
|
item.ticket,
|
|
247
|
-
]
|
|
248
|
+
]
|
|
249
|
+
.map(toCell)
|
|
250
|
+
.map(inlineCodeAnglePlaceholders);
|
|
248
251
|
return `| ${cells.join(" | ")} |`;
|
|
249
252
|
}
|
|
250
253
|
// ================================
|
|
@@ -359,5 +362,8 @@ export function buildRegisterItemContent(opts) {
|
|
|
359
362
|
completedAt: opts.fields.completedAt,
|
|
360
363
|
conclusion: opts.fields.conclusion,
|
|
361
364
|
ticket: "-",
|
|
365
|
+
...(opts.fields.approach ? { approach: opts.fields.approach } : {}),
|
|
366
|
+
...(opts.fields.targets ? { targets: opts.fields.targets } : {}),
|
|
367
|
+
...(opts.fields.derivedFrom ? { derivedFrom: opts.fields.derivedFrom } : {}),
|
|
362
368
|
}));
|
|
363
369
|
}
|
|
@@ -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_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 ---
|
|
@@ -45,6 +64,9 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
45
64
|
addCmd.option("--due <date>", "Due date (YYYY-MM-DD, -, or _TODO_)", "_TODO_");
|
|
46
65
|
addCmd.option("--completed <datetime>", "Completion date-time (RFC 3339 with time zone, or -)", "-");
|
|
47
66
|
addCmd.option("--conclusion <text>", "Conclusion or resolution summary", "-");
|
|
67
|
+
addCmd.option("--approach <approach>", `Execution approach: ${APPROACHES.join(" | ")}`);
|
|
68
|
+
addCmd.option("--target <doc-id>", "Target document id (repeatable; approach requires exactly one)", collectTarget);
|
|
69
|
+
addCmd.option("--from <item-id>", "Register item this item derives from (repeatable)", collectTarget);
|
|
48
70
|
addCmd.option("--id <id>", "Display ID (e.g., PJR-0061); auto-incremented if omitted");
|
|
49
71
|
addCmd.option("--topic <topic>", "Topic slug for ticket filename; derived from --title if omitted");
|
|
50
72
|
addCmd.option("--by <actor>", "Actor recorded in the append-only register event");
|
|
@@ -62,6 +84,16 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
62
84
|
}
|
|
63
85
|
const registeredAt = parseRegisterTimestampOption(opts.registered, "registered", CELL_TODO);
|
|
64
86
|
const completedAt = parseRegisterTimestampOption(opts.completed, "completed", CELL_NONE);
|
|
87
|
+
if (opts.target?.some((target) => target.trim() === "-")) {
|
|
88
|
+
throw new Error("--target - is only valid with register update");
|
|
89
|
+
}
|
|
90
|
+
const targets = normalizedTargets(opts.target);
|
|
91
|
+
validateRegisterApproachTargetsForProject({
|
|
92
|
+
projectId: paths.projectId,
|
|
93
|
+
...(opts.approach !== undefined ? { approach: opts.approach } : {}),
|
|
94
|
+
...(targets !== undefined ? { targets } : {}),
|
|
95
|
+
validateTargetsWithoutApproach: opts.target !== undefined,
|
|
96
|
+
});
|
|
65
97
|
const fields = {
|
|
66
98
|
type: opts.type,
|
|
67
99
|
title: opts.title,
|
|
@@ -73,6 +105,8 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
73
105
|
due: opts.due,
|
|
74
106
|
completedAt: completedAt ?? CELL_NONE,
|
|
75
107
|
conclusion: opts.conclusion,
|
|
108
|
+
...(opts.approach !== undefined ? { approach: opts.approach } : {}),
|
|
109
|
+
...(targets !== undefined ? { targets } : {}),
|
|
76
110
|
};
|
|
77
111
|
const templatePath = resolveSpecdojoTemplatePath(`pjr-${opts.type}-template.md`);
|
|
78
112
|
const { assignedId: displayId, ticketFilename } = planRegisterItem({
|
|
@@ -81,6 +115,14 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
81
115
|
fields,
|
|
82
116
|
topic,
|
|
83
117
|
});
|
|
118
|
+
const derivedFrom = normalizeDerivedFrom(opts.from, { allowRemove: false });
|
|
119
|
+
validateDerivedFrom({
|
|
120
|
+
projectId: paths.projectId,
|
|
121
|
+
itemId: displayId,
|
|
122
|
+
derivedFrom,
|
|
123
|
+
});
|
|
124
|
+
if (derivedFrom !== undefined)
|
|
125
|
+
fields.derivedFrom = derivedFrom;
|
|
84
126
|
const ticketPath = join(paths.projectRegisterPath, ticketFilename);
|
|
85
127
|
const content = buildRegisterItemContent({
|
|
86
128
|
projectId: paths.projectId,
|
|
@@ -144,6 +186,9 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
144
186
|
updateCmd.option("--due <date>", "Update due date (YYYY-MM-DD, -, or _TODO_)");
|
|
145
187
|
updateCmd.option("--conclusion <text>", "Update conclusion or use - to remove it");
|
|
146
188
|
updateCmd.option("--block-reason <text>", "Update the waiting reason or use - to remove it");
|
|
189
|
+
updateCmd.option("--approach <approach>", `Update execution approach (${APPROACHES.join(" | ")}; use - to remove)`);
|
|
190
|
+
updateCmd.option("--target <doc-id>", "Replace target document ids (repeatable; use - to remove)", collectTarget);
|
|
191
|
+
updateCmd.option("--from <item-id>", "Replace source register item IDs (repeatable; use - to remove)", collectTarget);
|
|
147
192
|
updateCmd.option("--topic <topic>", "Update the topic slug in the ticket filename and document ID");
|
|
148
193
|
updateCmd.option("--by <actor>", "Actor recorded in the append-only register event");
|
|
149
194
|
updateCmd.option("--reason <text>", "Reason recorded in the append-only register event");
|
|
@@ -162,10 +207,13 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
162
207
|
"due",
|
|
163
208
|
"conclusion",
|
|
164
209
|
"blockReason",
|
|
210
|
+
"approach",
|
|
211
|
+
"target",
|
|
212
|
+
"from",
|
|
165
213
|
"topic",
|
|
166
214
|
].some((key) => opts[key] !== undefined);
|
|
167
215
|
if (!hasUpdates) {
|
|
168
|
-
throw new Error("At least one field option must be specified (--title, --description, --priority, --owner, --due, --conclusion, --block-reason, --topic)");
|
|
216
|
+
throw new Error("At least one field option must be specified (--title, --description, --priority, --owner, --due, --conclusion, --block-reason, --approach, --target, --from, --topic)");
|
|
169
217
|
}
|
|
170
218
|
if (opts.priority !== undefined &&
|
|
171
219
|
!VALID_PRIORITIES.includes(opts.priority)) {
|
|
@@ -192,6 +240,43 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
192
240
|
? REMOVE_REGISTER_ITEM_FIELD
|
|
193
241
|
: inlineCodeAnglePlaceholders(blockReason),
|
|
194
242
|
};
|
|
243
|
+
const nextApproach = opts.approach === undefined
|
|
244
|
+
? item.approach
|
|
245
|
+
: opts.approach.trim() === "-"
|
|
246
|
+
? undefined
|
|
247
|
+
: opts.approach.trim();
|
|
248
|
+
const nextTargets = opts.target === undefined ? item.targets : normalizedTargets(opts.target);
|
|
249
|
+
const nextDerivedFrom = opts.from === undefined
|
|
250
|
+
? item.derivedFrom
|
|
251
|
+
: normalizeDerivedFrom(opts.from, { allowRemove: true });
|
|
252
|
+
validateDerivedFrom({
|
|
253
|
+
projectId: paths.projectId,
|
|
254
|
+
itemId: item.id,
|
|
255
|
+
derivedFrom: nextDerivedFrom,
|
|
256
|
+
});
|
|
257
|
+
validateRegisterApproachTargetsForProject({
|
|
258
|
+
projectId: paths.projectId,
|
|
259
|
+
...(nextApproach !== undefined ? { approach: nextApproach } : {}),
|
|
260
|
+
...(nextTargets !== undefined ? { targets: nextTargets } : {}),
|
|
261
|
+
validateTargetsWithoutApproach: opts.target !== undefined,
|
|
262
|
+
});
|
|
263
|
+
const approachTargetUpdates = {
|
|
264
|
+
...(opts.approach !== undefined
|
|
265
|
+
? {
|
|
266
|
+
approach: nextApproach === undefined ? REMOVE_REGISTER_ITEM_FIELD : nextApproach,
|
|
267
|
+
}
|
|
268
|
+
: {}),
|
|
269
|
+
...(opts.target !== undefined
|
|
270
|
+
? {
|
|
271
|
+
targets: nextTargets ?? REMOVE_REGISTER_ITEM_FIELD,
|
|
272
|
+
}
|
|
273
|
+
: {}),
|
|
274
|
+
...(opts.from !== undefined
|
|
275
|
+
? {
|
|
276
|
+
derived_from: nextDerivedFrom ?? REMOVE_REGISTER_ITEM_FIELD,
|
|
277
|
+
}
|
|
278
|
+
: {}),
|
|
279
|
+
};
|
|
195
280
|
const updated = {
|
|
196
281
|
...item,
|
|
197
282
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
@@ -201,6 +286,24 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
201
286
|
...(opts.due !== undefined ? { due: opts.due } : {}),
|
|
202
287
|
...(opts.conclusion !== undefined ? { conclusion: opts.conclusion } : {}),
|
|
203
288
|
};
|
|
289
|
+
if (opts.approach !== undefined) {
|
|
290
|
+
if (nextApproach === undefined)
|
|
291
|
+
delete updated.approach;
|
|
292
|
+
else
|
|
293
|
+
updated.approach = nextApproach;
|
|
294
|
+
}
|
|
295
|
+
if (opts.target !== undefined) {
|
|
296
|
+
if (nextTargets === undefined)
|
|
297
|
+
delete updated.targets;
|
|
298
|
+
else
|
|
299
|
+
updated.targets = nextTargets;
|
|
300
|
+
}
|
|
301
|
+
if (opts.from !== undefined) {
|
|
302
|
+
if (nextDerivedFrom === undefined)
|
|
303
|
+
delete updated.derivedFrom;
|
|
304
|
+
else
|
|
305
|
+
updated.derivedFrom = nextDerivedFrom;
|
|
306
|
+
}
|
|
204
307
|
const currentTopic = view.ticketFilename
|
|
205
308
|
? ticketTopicFromFilename(opts.id, view.ticketFilename)
|
|
206
309
|
: undefined;
|
|
@@ -217,7 +320,9 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
217
320
|
topic,
|
|
218
321
|
updated,
|
|
219
322
|
dryRun: opts.dryRun,
|
|
220
|
-
...(blockReasonUpdates
|
|
323
|
+
...(blockReasonUpdates || Object.keys(approachTargetUpdates).length > 0
|
|
324
|
+
? { fieldUpdates: { ...blockReasonUpdates, ...approachTargetUpdates } }
|
|
325
|
+
: {}),
|
|
221
326
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
222
327
|
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
223
328
|
actor: registerEventActor(opts),
|
|
@@ -234,7 +339,9 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
234
339
|
action: "fields updated",
|
|
235
340
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
236
341
|
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
237
|
-
...(blockReasonUpdates
|
|
342
|
+
...(blockReasonUpdates || Object.keys(approachTargetUpdates).length > 0
|
|
343
|
+
? { fieldUpdates: { ...blockReasonUpdates, ...approachTargetUpdates } }
|
|
344
|
+
: {}),
|
|
238
345
|
eventAction: "update",
|
|
239
346
|
eventActor: registerEventActor(opts),
|
|
240
347
|
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`)に固定する。瞬間そのものを
|