specdojo 0.4.0 → 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 +43 -0
- package/README.md +8 -7
- package/dist/commands/init.js +72 -15
- package/dist/commands/night-orchestrator.js +287 -0
- package/dist/commands/orchestrator.js +10 -3
- package/dist/devcontainer/command.js +3 -1
- package/dist/devcontainer/scaffold.js +166 -5
- package/dist/exec/agent-config.js +60 -2
- package/dist/exec/parent-validation.js +14 -0
- package/dist/exec/pipeline-state.js +13 -0
- package/dist/exec/register.js +23 -1
- package/dist/exec/repo-integration.js +1 -1
- package/dist/exec/reporter.js +113 -13
- package/dist/exec/results.js +36 -14
- package/dist/exec/run/agent-pipeline.js +3 -0
- package/dist/exec/run/agent.js +40 -5
- package/dist/exec/run/job.js +2 -2
- package/dist/exec/run/lifecycle-commands.js +2 -2
- package/dist/exec/run/register-command.js +23 -4
- package/dist/exec/run/register-core.js +17 -0
- package/dist/exec/run/register-mode.js +39 -16
- package/dist/exec/run/register-post-review.js +420 -0
- package/dist/exec/run/register-resume.js +27 -11
- package/dist/exec/run/register-worktree.js +66 -2
- package/dist/exec/run/run.js +1 -1
- package/dist/exec/run/shared.js +22 -24
- package/dist/exec/task-repos.js +102 -15
- package/dist/register/core.js +14 -2
- package/dist/register/create-commands.js +62 -6
- package/dist/register/event-merge.js +13 -1
- package/dist/register/events.js +4 -0
- package/dist/register/item.js +9 -0
- package/dist/register/migration.js +1 -0
- package/dist/register/register.js +2 -2
- package/dist/shared/git.js +45 -15
- package/dist/shared/provider-scaffold.js +3 -2
- package/dist/shared/specdojo-config.js +69 -16
- package/dist/shared/text.js +4 -1
- package/dist/shared/workspace-scaffold.js +69 -0
- package/docs/ja/specdojo/exec-templates/xep-common-conventions-template.md +2 -1
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +2 -0
- 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 +79 -11
- package/docs/ja/specdojo/guides/exec-operation-guide.md +39 -1
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +9 -3
- package/docs/ja/specdojo/guides/quick-start-guide.md +9 -6
- package/docs/ja/specdojo/guides/register-operation-guide.md +42 -0
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +52 -6
- package/docs/ja/specdojo/guides/specdojo-overview-guide.md +1 -1
- package/docs/ja/specdojo/guides/waza-guide.md +1 -1
- package/docs/ja/specdojo/references/command-reference.md +101 -56
- package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +5 -2
- package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +92 -18
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +6 -1
- package/docs/specdojo/schemas/v1/pipeline-state.schema.yaml +12 -0
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +21 -0
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +35 -0
- package/package.json +17 -17
- package/templates/antigravity/README.md +1 -1
- package/templates/antigravity/orchestrator.md +61 -2
- package/templates/claude/agents/specdojo-orchestrator.md +61 -2
- package/templates/codex/README.md +17 -0
- package/templates/codex/agents/specdojo-orchestrator.toml +61 -2
- package/templates/codex/orchestrator.md +61 -2
- package/templates/devcontainer/devcontainer.json +3 -0
- package/templates/devcontainer/post-create.sh +15 -7
- package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +38 -5
- package/templates/devcontainer/remote-host/ssh-config.sample +3 -0
- package/templates/devcontainer/vim/vimrc +37 -0
- package/templates/init-agent-members.yaml +3 -3
- package/templates/init-exec-defaults.yaml +20 -1
- package/templates/opencode/agents/specdojo-orchestrator.md +61 -2
package/dist/exec/run/shared.js
CHANGED
|
@@ -13,16 +13,18 @@ export function rateLimitRecoveryReason(events) {
|
|
|
13
13
|
return events
|
|
14
14
|
.map((event) => event.action === "wait"
|
|
15
15
|
? `rate limit wait: ${event.to_actor} resumed at ${event.resumed_at}`
|
|
16
|
-
:
|
|
16
|
+
: event.trigger === "connection_error"
|
|
17
|
+
? `connection error fallback: ${event.from_actor} -> ${event.to_actor} at ${event.resumed_at}`
|
|
18
|
+
: `rate limit fallback: ${event.from_actor} -> ${event.to_actor} at ${event.resumed_at}`)
|
|
17
19
|
.join("; ");
|
|
18
20
|
}
|
|
19
21
|
export function isPinnedRateLimitAction(value) {
|
|
20
22
|
return value === "stop" || value === "wait" || value === "fallback";
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
|
-
* Resolve CLI-over-config recovery for one pinned pipeline stage. A fallback
|
|
24
|
-
*
|
|
25
|
-
*
|
|
25
|
+
* Resolve CLI-over-config recovery for one pinned pipeline stage. A fallback nickname is resolved
|
|
26
|
+
* independently of --on-rate-limit because the same candidate also handles configured connection
|
|
27
|
+
* failures. A rate-limit fallback action without a nickname still degrades to stop.
|
|
26
28
|
*/
|
|
27
29
|
export function resolvePinnedRateLimitRunOptions(opts, execDefaults, roster, stageRole, primary) {
|
|
28
30
|
const configured = resolvePinnedRateLimitPolicy(execDefaults, primary.provider);
|
|
@@ -34,7 +36,7 @@ export function resolvePinnedRateLimitRunOptions(opts, execDefaults, roster, sta
|
|
|
34
36
|
const nickname = stageRole === "executor"
|
|
35
37
|
? (opts.fallbackExecutorBy ?? configured.fallbackExecutorBy)
|
|
36
38
|
: (opts.fallbackReporterBy ?? configured.fallbackReporterBy);
|
|
37
|
-
if (
|
|
39
|
+
if (!nickname) {
|
|
38
40
|
return {
|
|
39
41
|
action: action === "fallback" ? "stop" : action,
|
|
40
42
|
maxWaitSeconds: configured.maxWaitSeconds,
|
|
@@ -302,30 +304,26 @@ export function collectBusyActors(schedulePath) {
|
|
|
302
304
|
return busy;
|
|
303
305
|
}
|
|
304
306
|
export function isRateLimitError(exitCode, output, detection) {
|
|
307
|
+
// `output` is combined stdout+stderr because some CLIs print failures to stdout. Successful
|
|
308
|
+
// output is ignored by default so quoted configuration/examples do not become false positives.
|
|
309
|
+
return isConfiguredAgentError(exitCode, output, detection);
|
|
310
|
+
}
|
|
311
|
+
export function isConnectionError(exitCode, output, detection) {
|
|
312
|
+
return isConfiguredAgentError(exitCode, output, detection);
|
|
313
|
+
}
|
|
314
|
+
function isConfiguredAgentError(exitCode, output, detection) {
|
|
305
315
|
if (!detection)
|
|
306
316
|
return false;
|
|
307
|
-
// exit_codes is a standalone signal: an exact configured code identifies a rate limit
|
|
308
|
-
// on its own. Keep this list minimal (see exec-defaults.yaml) since generic codes like 1
|
|
309
|
-
// also mean ordinary failure.
|
|
310
317
|
if (detection.exit_codes && exitCode !== null && detection.exit_codes.includes(exitCode)) {
|
|
311
318
|
return true;
|
|
312
319
|
}
|
|
313
|
-
if (detection.stderr_patterns)
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (!requireNonzeroExit || exitCode !== 0) {
|
|
321
|
-
const lower = output.toLowerCase();
|
|
322
|
-
for (const pattern of detection.stderr_patterns) {
|
|
323
|
-
if (lower.includes(pattern.toLowerCase()))
|
|
324
|
-
return true;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return false;
|
|
320
|
+
if (!detection.stderr_patterns)
|
|
321
|
+
return false;
|
|
322
|
+
const requireNonzeroExit = detection.stderr_requires_nonzero_exit ?? true;
|
|
323
|
+
if (requireNonzeroExit && exitCode === 0)
|
|
324
|
+
return false;
|
|
325
|
+
const lower = output.toLowerCase();
|
|
326
|
+
return detection.stderr_patterns.some((pattern) => lower.includes(pattern.toLowerCase()));
|
|
329
327
|
}
|
|
330
328
|
export function resolveExecDefaultsPath(opts, schedulePath) {
|
|
331
329
|
if (opts.execDefaults)
|
package/dist/exec/task-repos.js
CHANGED
|
@@ -6,30 +6,117 @@ import { ensureExecWorktree, execBranchExists, execWorktreePath, findExecWorktre
|
|
|
6
6
|
// 変更する場合の worktree を扱う。`repos` を持たない project では、ここの関数はどれも空の結果を
|
|
7
7
|
// 返し、既存の 1 リポジトリ・`<worktree_base>/<task-id>/` 直下の配置を変えない。
|
|
8
8
|
export { PROJECT_REPO_WORKTREE_DIRNAME };
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
/** Parse repeatable `<repo>=<branch>` values used by `exec run --integration-branch`. */
|
|
10
|
+
export function parseIntegrationBranchOverrides(values) {
|
|
11
|
+
const entries = values === undefined ? [] : typeof values === "string" ? [values] : values;
|
|
12
|
+
const overrides = new Map();
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
const separator = entry.indexOf("=");
|
|
15
|
+
const repo = separator > 0 ? entry.slice(0, separator).trim() : "";
|
|
16
|
+
const branch = separator > 0 ? entry.slice(separator + 1).trim() : "";
|
|
17
|
+
if (!repo || !branch) {
|
|
18
|
+
throw new Error(`--integration-branch must use <repo>=<branch> with non-empty values: ${entry}`);
|
|
19
|
+
}
|
|
20
|
+
if (overrides.has(repo)) {
|
|
21
|
+
throw new Error(`--integration-branch specifies repository "${repo}" more than once`);
|
|
22
|
+
}
|
|
23
|
+
overrides.set(repo, branch);
|
|
24
|
+
}
|
|
25
|
+
return overrides;
|
|
26
|
+
}
|
|
27
|
+
function isIntegrationBranchOverrides(value) {
|
|
28
|
+
return value instanceof Map;
|
|
29
|
+
}
|
|
30
|
+
function toIntegrationBranchOverrides(value) {
|
|
31
|
+
return isIntegrationBranchOverrides(value) ? value : parseIntegrationBranchOverrides(value);
|
|
32
|
+
}
|
|
33
|
+
function assertLocalIntegrationBranch(product, branch) {
|
|
34
|
+
if (!existsSync(product.repoRoot)) {
|
|
35
|
+
throw new Error(`Product repository "${product.name}" does not exist: ${product.repoRoot} (check repos[].path)`);
|
|
36
|
+
}
|
|
37
|
+
const validName = gitResult(product.repoRoot, ["check-ref-format", "--branch", branch]);
|
|
38
|
+
if (validName.status !== 0) {
|
|
39
|
+
throw new Error(`--integration-branch for repository "${product.name}" is not a valid branch name: ${branch}`);
|
|
40
|
+
}
|
|
41
|
+
const exists = gitResult(product.repoRoot, [
|
|
42
|
+
"show-ref",
|
|
43
|
+
"--verify",
|
|
44
|
+
"--quiet",
|
|
45
|
+
`refs/heads/${branch}`,
|
|
46
|
+
]);
|
|
47
|
+
if (exists.status !== 0) {
|
|
48
|
+
throw new Error(`--integration-branch for repository "${product.name}" is not a local branch: ${branch}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Resolve the configured target; undefined deliberately means "use the current branch". */
|
|
52
|
+
export function resolveProductIntegrationBranch(repo, overrides) {
|
|
53
|
+
const configuredBranch = repo.integration_branch?.trim();
|
|
54
|
+
return overrides.get(repo.name) ?? (configuredBranch || undefined);
|
|
55
|
+
}
|
|
56
|
+
export function resolveProductRepos(rootDir, project, integrationBranches) {
|
|
57
|
+
const overrides = toIntegrationBranchOverrides(integrationBranches);
|
|
58
|
+
// Priority: run-scoped override → repos[].integration_branch → current branch (at use time).
|
|
59
|
+
const configured = getProjectRepos(project);
|
|
60
|
+
const configuredNames = new Set(configured.map((repo) => repo.name));
|
|
61
|
+
const unknown = [...overrides.keys()].filter((name) => !configuredNames.has(name));
|
|
62
|
+
if (unknown.length > 0) {
|
|
63
|
+
throw new Error(`--integration-branch references undeclared product repositories: ${unknown.join(", ")}`);
|
|
64
|
+
}
|
|
65
|
+
return configured.map((repo) => {
|
|
66
|
+
const override = overrides.get(repo.name);
|
|
67
|
+
const integrationBranch = resolveProductIntegrationBranch(repo, overrides);
|
|
68
|
+
const product = {
|
|
69
|
+
name: repo.name,
|
|
70
|
+
repoRoot: resolveRepoRoot(rootDir, repo),
|
|
71
|
+
...(integrationBranch ? { integrationBranch } : {}),
|
|
72
|
+
install: repo.setup?.install ?? true,
|
|
73
|
+
build: repo.setup?.build ?? true,
|
|
74
|
+
};
|
|
75
|
+
if (override)
|
|
76
|
+
assertLocalIntegrationBranch(product, override);
|
|
77
|
+
return product;
|
|
78
|
+
});
|
|
19
79
|
}
|
|
20
80
|
/** Product repositories of the project whose schedule path is `schedulePath` ([] when none). */
|
|
21
|
-
export function configuredProductRepos(schedulePath) {
|
|
81
|
+
export function configuredProductRepos(schedulePath, integrationBranches) {
|
|
82
|
+
const overrides = toIntegrationBranchOverrides(integrationBranches);
|
|
22
83
|
const { config } = loadConfig();
|
|
23
|
-
if (!config)
|
|
24
|
-
return [];
|
|
25
84
|
const rootDir = specdojoRootDir();
|
|
26
|
-
for (const project of Object.values(config
|
|
85
|
+
for (const project of Object.values(config?.projects ?? {})) {
|
|
27
86
|
if (resolve(rootDir, getProjectSchedulePath(project)) === resolve(schedulePath)) {
|
|
28
|
-
return resolveProductRepos(rootDir, project);
|
|
87
|
+
return resolveProductRepos(rootDir, project, overrides);
|
|
29
88
|
}
|
|
30
89
|
}
|
|
90
|
+
if (overrides.size > 0) {
|
|
91
|
+
throw new Error(`--integration-branch references undeclared product repositories: ${[...overrides.keys()].join(", ")}`);
|
|
92
|
+
}
|
|
31
93
|
return [];
|
|
32
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Run-scoped `--integration-branch` values recorded in the run checkpoint (`integration_branches`).
|
|
97
|
+
* Only explicit overrides are recorded, so a run without the option keeps resolving its targets
|
|
98
|
+
* from `repos[].integration_branch` or the current branch exactly as before.
|
|
99
|
+
*/
|
|
100
|
+
export function integrationBranchOverrideRecord(values) {
|
|
101
|
+
const overrides = parseIntegrationBranchOverrides(values);
|
|
102
|
+
return overrides.size > 0 ? Object.fromEntries(overrides) : undefined;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Integration branch overrides for a resumed run. The checkpoint's overrides are reused so the
|
|
106
|
+
* option does not have to be repeated; an explicit value must match the checkpoint, because a
|
|
107
|
+
* run cannot change or add its integration target midway through execution.
|
|
108
|
+
*/
|
|
109
|
+
export function resumeIntegrationBranches(persisted, requested) {
|
|
110
|
+
const requestedOverrides = parseIntegrationBranchOverrides(requested);
|
|
111
|
+
for (const [repo, branch] of requestedOverrides) {
|
|
112
|
+
const original = persisted?.[repo];
|
|
113
|
+
if (original !== branch) {
|
|
114
|
+
throw new Error(`--integration-branch cannot change the resumed run target for "${repo}" ` +
|
|
115
|
+
`(checkpoint: ${original ?? "not specified"}, requested: ${branch})`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return new Map(Object.entries(persisted ?? {}));
|
|
119
|
+
}
|
|
33
120
|
/** Product repositories of the project `projectId` ([] when none or unknown). */
|
|
34
121
|
export function configuredProductReposForProject(projectId) {
|
|
35
122
|
if (!projectId)
|
package/dist/register/core.js
CHANGED
|
@@ -5,10 +5,21 @@ import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
|
5
5
|
import { appendRegisterEvent, registerEventFilePath } from "./events.js";
|
|
6
6
|
import { REGISTER_TIMESTAMP_RE, resolveRegisterDateTimeZone, timestampFromDateInTimeZone, } from "./date.js";
|
|
7
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";
|
|
8
|
+
import { getProjectExecutionPath, getProjectRegisterPath, loadConfig, loadEnv, loadMemberRoster, resolveRegisterActor, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
9
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 });
|
|
@@ -356,6 +367,7 @@ export function buildRegisterItemContent(opts) {
|
|
|
356
367
|
description: opts.fields.description,
|
|
357
368
|
type: opts.fields.type,
|
|
358
369
|
priority: opts.fields.priority,
|
|
370
|
+
...(opts.fields.difficulty ? { difficulty: opts.fields.difficulty } : {}),
|
|
359
371
|
owner: opts.fields.owner,
|
|
360
372
|
registeredAt: opts.fields.registeredAt,
|
|
361
373
|
due: opts.fields.due,
|
|
@@ -4,7 +4,7 @@ import { inlineCodeAnglePlaceholders } from "../shared/text.js";
|
|
|
4
4
|
import { APPROACHES } from "../shared/agent-types.js";
|
|
5
5
|
import { appendRegisterEvent, buildRegisterEvent, registerEventFilePath } from "./events.js";
|
|
6
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";
|
|
7
|
+
import { CELL_NONE, CELL_TODO, REMOVE_REGISTER_ITEM_FIELD, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, } from "./item.js";
|
|
8
8
|
import { resolveSpecdojoTemplatePath } from "../docs/template-resolution.js";
|
|
9
9
|
import { validateRegisterApproachTargetsForProject } from "./approach.js";
|
|
10
10
|
import { normalizeDerivedFrom, validateDerivedFrom } from "./derivation.js";
|
|
@@ -58,6 +58,7 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
58
58
|
addCmd.requiredOption("--title <title>", "Short title for the item");
|
|
59
59
|
addCmd.option("--description <text>", "Description shown in the list", "_TODO_");
|
|
60
60
|
addCmd.option("--priority <priority>", `Priority: ${VALID_PRIORITIES.join(" | ")}`, "medium");
|
|
61
|
+
addCmd.option("--difficulty <difficulty>", `Difficulty: ${VALID_DIFFICULTIES.join(" | ")}`);
|
|
61
62
|
addCmd.option("--status <status>", `Status: ${VALID_STATUSES.join(" | ")}`, "open");
|
|
62
63
|
addCmd.option("--owner <owner>", "Owner or role", "_TODO_");
|
|
63
64
|
addCmd.option("--registered <datetime>", "Registration date-time (RFC 3339 with time zone, or _TODO_; defaults to now in UTC)");
|
|
@@ -84,6 +85,10 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
84
85
|
}
|
|
85
86
|
const registeredAt = parseRegisterTimestampOption(opts.registered, "registered", CELL_TODO);
|
|
86
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
|
+
}
|
|
87
92
|
if (opts.target?.some((target) => target.trim() === "-")) {
|
|
88
93
|
throw new Error("--target - is only valid with register update");
|
|
89
94
|
}
|
|
@@ -99,6 +104,7 @@ export function registerCreateCommands(reg, dependencies) {
|
|
|
99
104
|
title: opts.title,
|
|
100
105
|
description: opts.description,
|
|
101
106
|
priority: opts.priority,
|
|
107
|
+
...(opts.difficulty !== undefined ? { difficulty: opts.difficulty } : {}),
|
|
102
108
|
status: opts.status,
|
|
103
109
|
owner: opts.owner,
|
|
104
110
|
registeredAt: registeredAt ?? nowUtcTimestamp(),
|
|
@@ -182,10 +188,12 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
182
188
|
updateCmd.option("--title <title>", "Update title");
|
|
183
189
|
updateCmd.option("--description <text>", "Update description");
|
|
184
190
|
updateCmd.option("--priority <priority>", `Update priority: ${VALID_PRIORITIES.join(" | ")}`);
|
|
191
|
+
updateCmd.option("--difficulty <difficulty>", `Update difficulty: ${VALID_DIFFICULTIES.join(" | ")}; use - to remove`);
|
|
185
192
|
updateCmd.option("--owner <owner>", "Update owner or role");
|
|
186
193
|
updateCmd.option("--due <date>", "Update due date (YYYY-MM-DD, -, or _TODO_)");
|
|
187
194
|
updateCmd.option("--conclusion <text>", "Update conclusion or use - to remove it");
|
|
188
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");
|
|
189
197
|
updateCmd.option("--approach <approach>", `Update execution approach (${APPROACHES.join(" | ")}; use - to remove)`);
|
|
190
198
|
updateCmd.option("--target <doc-id>", "Replace target document ids (repeatable; use - to remove)", collectTarget);
|
|
191
199
|
updateCmd.option("--from <item-id>", "Replace source register item IDs (repeatable; use - to remove)", collectTarget);
|
|
@@ -203,22 +211,29 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
203
211
|
"title",
|
|
204
212
|
"description",
|
|
205
213
|
"priority",
|
|
214
|
+
"difficulty",
|
|
206
215
|
"owner",
|
|
207
216
|
"due",
|
|
208
217
|
"conclusion",
|
|
209
218
|
"blockReason",
|
|
219
|
+
"autopilot",
|
|
210
220
|
"approach",
|
|
211
221
|
"target",
|
|
212
222
|
"from",
|
|
213
223
|
"topic",
|
|
214
224
|
].some((key) => opts[key] !== undefined);
|
|
215
225
|
if (!hasUpdates) {
|
|
216
|
-
throw new Error("At least one field option must be specified (--title, --description, --priority, --owner, --due, --conclusion, --block-reason, --approach, --target, --from, --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)");
|
|
217
227
|
}
|
|
218
228
|
if (opts.priority !== undefined &&
|
|
219
229
|
!VALID_PRIORITIES.includes(opts.priority)) {
|
|
220
230
|
throw new Error(`Invalid priority: "${opts.priority}". Must be one of: ${VALID_PRIORITIES.join(", ")}`);
|
|
221
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
|
+
}
|
|
222
237
|
if (opts.due !== undefined && !/^(\d{4}-\d{2}-\d{2}|-|_TODO_)$/.test(opts.due)) {
|
|
223
238
|
throw new Error(`Invalid due: "${opts.due}". Must be YYYY-MM-DD, -, or _TODO_`);
|
|
224
239
|
}
|
|
@@ -240,6 +255,17 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
240
255
|
? REMOVE_REGISTER_ITEM_FIELD
|
|
241
256
|
: inlineCodeAnglePlaceholders(blockReason),
|
|
242
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
|
+
};
|
|
243
269
|
const nextApproach = opts.approach === undefined
|
|
244
270
|
? item.approach
|
|
245
271
|
: opts.approach.trim() === "-"
|
|
@@ -261,6 +287,11 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
261
287
|
validateTargetsWithoutApproach: opts.target !== undefined,
|
|
262
288
|
});
|
|
263
289
|
const approachTargetUpdates = {
|
|
290
|
+
...(opts.difficulty !== undefined
|
|
291
|
+
? {
|
|
292
|
+
difficulty: opts.difficulty === "-" ? REMOVE_REGISTER_ITEM_FIELD : opts.difficulty,
|
|
293
|
+
}
|
|
294
|
+
: {}),
|
|
264
295
|
...(opts.approach !== undefined
|
|
265
296
|
? {
|
|
266
297
|
approach: nextApproach === undefined ? REMOVE_REGISTER_ITEM_FIELD : nextApproach,
|
|
@@ -282,10 +313,21 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
282
313
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
283
314
|
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
284
315
|
...(opts.priority !== undefined ? { priority: opts.priority } : {}),
|
|
316
|
+
...(opts.difficulty !== undefined && opts.difficulty !== "-"
|
|
317
|
+
? { difficulty: opts.difficulty }
|
|
318
|
+
: {}),
|
|
285
319
|
...(opts.owner !== undefined ? { owner: opts.owner } : {}),
|
|
286
320
|
...(opts.due !== undefined ? { due: opts.due } : {}),
|
|
287
321
|
...(opts.conclusion !== undefined ? { conclusion: opts.conclusion } : {}),
|
|
288
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
|
+
}
|
|
289
331
|
if (opts.approach !== undefined) {
|
|
290
332
|
if (nextApproach === undefined)
|
|
291
333
|
delete updated.approach;
|
|
@@ -320,8 +362,16 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
320
362
|
topic,
|
|
321
363
|
updated,
|
|
322
364
|
dryRun: opts.dryRun,
|
|
323
|
-
...(blockReasonUpdates ||
|
|
324
|
-
|
|
365
|
+
...(blockReasonUpdates ||
|
|
366
|
+
autopilotUpdates ||
|
|
367
|
+
Object.keys(approachTargetUpdates).length > 0
|
|
368
|
+
? {
|
|
369
|
+
fieldUpdates: {
|
|
370
|
+
...blockReasonUpdates,
|
|
371
|
+
...autopilotUpdates,
|
|
372
|
+
...approachTargetUpdates,
|
|
373
|
+
},
|
|
374
|
+
}
|
|
325
375
|
: {}),
|
|
326
376
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
327
377
|
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
@@ -339,8 +389,14 @@ export function registerUpdateCommand(reg, dependencies) {
|
|
|
339
389
|
action: "fields updated",
|
|
340
390
|
...(opts.title !== undefined ? { title: opts.title } : {}),
|
|
341
391
|
...(opts.description !== undefined ? { description: opts.description } : {}),
|
|
342
|
-
...(blockReasonUpdates || Object.keys(approachTargetUpdates).length > 0
|
|
343
|
-
? {
|
|
392
|
+
...(blockReasonUpdates || autopilotUpdates || Object.keys(approachTargetUpdates).length > 0
|
|
393
|
+
? {
|
|
394
|
+
fieldUpdates: {
|
|
395
|
+
...blockReasonUpdates,
|
|
396
|
+
...autopilotUpdates,
|
|
397
|
+
...approachTargetUpdates,
|
|
398
|
+
},
|
|
399
|
+
}
|
|
344
400
|
: {}),
|
|
345
401
|
eventAction: "update",
|
|
346
402
|
eventActor: registerEventActor(opts),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// 統合 merge で登録簿の記帳ファイルが競合したときの解決処理。イベントファイルは追記型の記録なので、
|
|
2
2
|
// 両側のイベントの和集合(同一 id は 1 件)を時刻順に並べ、`previous_event_id` の連鎖を張り直す。
|
|
3
3
|
// 個票は exec branch 側を基準にし、統合先だけにあるイベントが変えたフィールドのうち、frontmatter の
|
|
4
|
-
// 単純な値へ写せるもの(type / priority / owner / due / approach / targets /
|
|
4
|
+
// 単純な値へ写せるもの(type / priority / difficulty / owner / due / approach / targets /
|
|
5
5
|
// derived_from)だけを再構築する。
|
|
6
6
|
import { readRegisterEventsFromContent, serializeRegisterEvents, } from "./events.js";
|
|
7
7
|
import { applyRegisterItemFields, CELL_NONE, CELL_TODO, REMOVE_REGISTER_ITEM_FIELD, } from "./item.js";
|
|
@@ -127,6 +127,12 @@ function fieldUpdateFromChange(change) {
|
|
|
127
127
|
return isUnset ? undefined : { item_type: value };
|
|
128
128
|
case "priority":
|
|
129
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;
|
|
130
136
|
case "owner":
|
|
131
137
|
return { owner: isUnset ? null : value };
|
|
132
138
|
case "due":
|
|
@@ -165,6 +171,12 @@ function fieldUpdateFromChange(change) {
|
|
|
165
171
|
return undefined;
|
|
166
172
|
}
|
|
167
173
|
}
|
|
174
|
+
case "autopilot":
|
|
175
|
+
return isUnset
|
|
176
|
+
? { autopilot: REMOVE_REGISTER_ITEM_FIELD }
|
|
177
|
+
: value === "approved"
|
|
178
|
+
? { autopilot: "approved" }
|
|
179
|
+
: undefined;
|
|
168
180
|
default:
|
|
169
181
|
return undefined;
|
|
170
182
|
}
|
package/dist/register/events.js
CHANGED
|
@@ -14,6 +14,7 @@ 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",
|
|
@@ -23,6 +24,7 @@ export const REGISTER_EVENT_FIELDS = [
|
|
|
23
24
|
"approach",
|
|
24
25
|
"targets",
|
|
25
26
|
"derived_from",
|
|
27
|
+
"autopilot",
|
|
26
28
|
];
|
|
27
29
|
export const REGISTER_EVENT_ACTIONS = [
|
|
28
30
|
"add",
|
|
@@ -65,6 +67,7 @@ export function registerEventFieldValues(content, filename, timeZone) {
|
|
|
65
67
|
description: item.description,
|
|
66
68
|
type: item.type,
|
|
67
69
|
priority: item.priority,
|
|
70
|
+
difficulty: item.difficulty ?? CELL_NONE,
|
|
68
71
|
owner: item.owner,
|
|
69
72
|
registered: item.registered,
|
|
70
73
|
due: item.due,
|
|
@@ -74,6 +77,7 @@ export function registerEventFieldValues(content, filename, timeZone) {
|
|
|
74
77
|
approach: item.approach ?? CELL_NONE,
|
|
75
78
|
targets: item.targets ? JSON.stringify(item.targets) : CELL_NONE,
|
|
76
79
|
derived_from: item.derivedFrom ? JSON.stringify(item.derivedFrom) : CELL_NONE,
|
|
80
|
+
autopilot: item.autopilot ?? CELL_NONE,
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
function isUnsetFieldValue(value) {
|
package/dist/register/item.js
CHANGED
|
@@ -28,6 +28,7 @@ export const VALID_TYPES = [
|
|
|
28
28
|
"note",
|
|
29
29
|
];
|
|
30
30
|
export const VALID_PRIORITIES = ["high", "medium", "low"];
|
|
31
|
+
export const VALID_DIFFICULTIES = ["hard", "medium", "easy"];
|
|
31
32
|
export const TERMINAL_STATUSES_SET = new Set(["done", "decided", "rejected", "deferred"]);
|
|
32
33
|
// PJR-ID の乱数部分に使う 32 文字セット。曖昧文字(`I` / `L` / `O` / `U`)を除いた
|
|
33
34
|
// 英大文字(単一ケース)と数字で構成し、目視・手入力時の誤読を避ける。
|
|
@@ -58,6 +59,7 @@ const SPECDOJO_KEY_ORDER = [
|
|
|
58
59
|
"item_type",
|
|
59
60
|
"item_status",
|
|
60
61
|
"priority",
|
|
62
|
+
"difficulty",
|
|
61
63
|
"owner",
|
|
62
64
|
"registered_at",
|
|
63
65
|
"due_on",
|
|
@@ -65,6 +67,7 @@ const SPECDOJO_KEY_ORDER = [
|
|
|
65
67
|
"block_reason",
|
|
66
68
|
"conclusion",
|
|
67
69
|
"derived_from",
|
|
70
|
+
"autopilot",
|
|
68
71
|
"approach",
|
|
69
72
|
"targets",
|
|
70
73
|
];
|
|
@@ -172,6 +175,8 @@ export function readRegisterItemContent(content, filename) {
|
|
|
172
175
|
const derivedFrom = Array.isArray(fields.derived_from)
|
|
173
176
|
? fields.derived_from.filter((entry) => typeof entry === "string" && entry.trim() !== "")
|
|
174
177
|
: undefined;
|
|
178
|
+
const autopilot = fields.autopilot === "approved" ? "approved" : undefined;
|
|
179
|
+
const difficulty = asString(fields.difficulty);
|
|
175
180
|
const item = {
|
|
176
181
|
id,
|
|
177
182
|
status: asString(fields.item_status) ?? "open",
|
|
@@ -179,6 +184,7 @@ export function readRegisterItemContent(content, filename) {
|
|
|
179
184
|
description: descriptionFromBody(body),
|
|
180
185
|
type: asString(fields.item_type) ?? CELL_TODO,
|
|
181
186
|
priority: asString(fields.priority) ?? "medium",
|
|
187
|
+
...(difficulty ? { difficulty } : {}),
|
|
182
188
|
owner: asString(fields.owner) ?? CELL_TODO,
|
|
183
189
|
registeredAt: asString(fields.registered_at) ?? CELL_TODO,
|
|
184
190
|
due: fields.due_on === null
|
|
@@ -191,6 +197,7 @@ export function readRegisterItemContent(content, filename) {
|
|
|
191
197
|
...(approach ? { approach } : {}),
|
|
192
198
|
...(targets && targets.length > 0 ? { targets } : {}),
|
|
193
199
|
...(derivedFrom && derivedFrom.length > 0 ? { derivedFrom } : {}),
|
|
200
|
+
...(autopilot ? { autopilot } : {}),
|
|
194
201
|
};
|
|
195
202
|
return {
|
|
196
203
|
id,
|
|
@@ -299,6 +306,7 @@ export function registerItemFieldsFromItem(item) {
|
|
|
299
306
|
item_type: item.type,
|
|
300
307
|
item_status: item.status,
|
|
301
308
|
priority: item.priority,
|
|
309
|
+
...(item.difficulty ? { difficulty: item.difficulty } : {}),
|
|
302
310
|
owner: isPlaceholderCell(item.owner) ? null : item.owner.trim(),
|
|
303
311
|
registered_at: isPlaceholderCell(item.registeredAt) ? null : item.registeredAt.trim(),
|
|
304
312
|
due_on: item.due.trim() === CELL_TODO
|
|
@@ -313,6 +321,7 @@ export function registerItemFieldsFromItem(item) {
|
|
|
313
321
|
...(item.approach ? { approach: item.approach } : {}),
|
|
314
322
|
...(item.targets && item.targets.length > 0 ? { targets: item.targets } : {}),
|
|
315
323
|
...(item.derivedFrom && item.derivedFrom.length > 0 ? { derived_from: item.derivedFrom } : {}),
|
|
324
|
+
...(item.autopilot ? { autopilot: item.autopilot } : {}),
|
|
316
325
|
};
|
|
317
326
|
}
|
|
318
327
|
function orderSpecdojoKeys(fields) {
|
|
@@ -144,6 +144,7 @@ export function planRegisterMigration(paths) {
|
|
|
144
144
|
title: tableCellToBody(source.item.title),
|
|
145
145
|
description: tableCellToBody(source.item.description),
|
|
146
146
|
priority: source.item.priority,
|
|
147
|
+
...(source.item.difficulty ? { difficulty: source.item.difficulty } : {}),
|
|
147
148
|
status: source.item.status,
|
|
148
149
|
owner: source.item.owner,
|
|
149
150
|
registeredAt: source.item.registeredAt,
|
|
@@ -9,7 +9,7 @@ import { normalizeRegisterTimestamp } from "./date.js";
|
|
|
9
9
|
import { validateDerivedFromDocs } from "./derivation.js";
|
|
10
10
|
import { appendRegisterEvent, deterministicRegisterEventId, readEmbeddedRegisterEvents, readRegisterEventsFromContent, registerEventFilePath, removeEmbeddedRegisterEvents, serializeRegisterEvents, validateRegisterEventDocs, } from "./events.js";
|
|
11
11
|
import { collectRegisterHistoryEvents } from "./history.js";
|
|
12
|
-
import { loadRegisterItemDocs, PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, toCell, validateRegisterItemDocs, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "./item.js";
|
|
12
|
+
import { loadRegisterItemDocs, PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, toCell, validateRegisterItemDocs, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, } from "./item.js";
|
|
13
13
|
import { registerMaintenanceCommands } from "./maintenance-commands.js";
|
|
14
14
|
import { applyRegisterMigrationPlan, planRegisterMigration } from "./migration.js";
|
|
15
15
|
import { planRenumber, planRetopic, renumberPjrItem, retopicPjrItem, ticketTopicFromFilename, } from "./renumber.js";
|
|
@@ -18,7 +18,7 @@ import { applyItemUpdate, assertTerminalOperationAllowed, loadItemForUpdate, upd
|
|
|
18
18
|
import { generateDerivedViewFiles, loadRegisterItems, VALID_BUILD_SCOPES, writeDerivedViews, } from "./views.js";
|
|
19
19
|
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
20
20
|
import { registerLifecyclePoolPath } from "./lifecycle-lock.js";
|
|
21
|
-
export { PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, toCell, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, };
|
|
21
|
+
export { PJR_ID_ALPHABET, PJR_ID_RE, TERMINAL_STATUSES_SET, toCell, VALID_PRIORITIES, VALID_DIFFICULTIES, VALID_STATUSES, VALID_TYPES, };
|
|
22
22
|
export { REGISTER_TOPIC_RE, VALID_TICKET_STATUSES, buildRegisterItemContent, extractTableHeading, findMarkdownReferenceFiles, generatePjrId, injectRegisterRows, parsePjrIndex, resolveRegisterPaths, } from "./core.js";
|
|
23
23
|
export { applyRegisterMigrationPlan, planRegisterMigration, } from "./migration.js";
|
|
24
24
|
export { findItemById, findRegisterItem, generateDerivedViewFiles, injectViewSlots, loadRegisterItems, sortByRegisteredDesc, } from "./views.js";
|