specdojo 0.4.5 → 0.4.7
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 +4 -4
- package/CHANGELOG.md +41 -0
- package/dist/catalog/document-target.js +75 -0
- package/dist/commands/agent.js +2 -80
- package/dist/commands/init.js +33 -7
- package/dist/devcontainer/scaffold.js +5 -1
- package/dist/exec/agent-config.js +28 -16
- package/dist/exec/agent-plan.js +108 -0
- package/dist/exec/commands.js +3 -3
- package/dist/exec/evidence.js +35 -3
- package/dist/exec/grade-checkpoint.js +12 -0
- package/dist/exec/pipeline-state.js +1 -0
- package/dist/exec/plans-core.js +11 -67
- package/dist/exec/plans-generation.js +22 -5
- package/dist/exec/project.js +4 -1
- package/dist/exec/register-resume.js +8 -4
- package/dist/exec/register.js +66 -5
- package/dist/exec/reporter.js +8 -1
- package/dist/exec/results.js +1 -1
- package/dist/exec/run/agent-pipeline.js +7 -5
- package/dist/exec/run/agent.js +14 -1
- package/dist/exec/run/lifecycle-commands.js +2 -0
- package/dist/exec/run/register-resume.js +2 -0
- package/dist/exec/run/register-state.js +4 -1
- package/dist/exec/run/register-worktree.js +8 -1
- package/dist/exec/run/schedule-prepare.js +7 -1
- package/dist/exec/worktree-command.js +8 -1
- package/dist/exec/worktree-ops-lifecycle.js +4 -2
- package/dist/exec/worktree-ops-merge.js +40 -1
- package/dist/grade/apply.js +7 -5
- package/dist/grade/command-inspect.js +2 -1
- package/dist/grade/command-run.js +39 -0
- package/dist/grade/grade.js +3 -1
- package/dist/grade/markdown.js +4 -4
- package/dist/grade/pipeline-state.js +8 -6
- package/dist/grade/plan.js +8 -6
- package/dist/grade/run.js +307 -0
- package/dist/grade/target-discovery.js +1 -1
- package/dist/grade/targets.js +44 -22
- package/dist/kata/command.js +54 -9
- package/dist/register/approach.js +16 -0
- package/dist/register/core.js +2 -0
- package/dist/register/create-commands.js +57 -7
- package/dist/register/deliverable-target.js +215 -0
- package/dist/register/events.js +4 -0
- package/dist/register/external-project.js +18 -7
- package/dist/register/item.js +8 -0
- package/dist/register/views.js +3 -0
- package/dist/review/grade.js +19 -17
- package/dist/shared/agent-plan.js +1 -0
- package/dist/shared/git.js +3 -2
- package/dist/shared/lefthook-scaffold.js +5 -22
- package/dist/shared/markdownlint-scaffold.js +67 -0
- package/dist/shared/provider-scaffold.js +7 -5
- package/dist/shared/slidev-scaffold.js +102 -0
- package/dist/shared/specdojo-config.js +9 -3
- package/dist/specdojo.js +5 -1
- package/docs/ja/specdojo/exec-templates/xep-register-template.md +5 -4
- package/docs/ja/specdojo/exec-templates/xrp-freeform-template.md +2 -2
- package/docs/ja/specdojo/exec-templates/xrp-fully-guided-template.md +2 -2
- package/docs/ja/specdojo/exec-templates/xrp-recipe-guided-template.md +2 -2
- package/docs/ja/specdojo/exec-templates/xrp-recipe-maintenance-template.md +2 -2
- package/docs/ja/specdojo/exec-templates/xrp-retrofit-template.md +2 -2
- package/docs/ja/specdojo/exec-templates/xrp-rulebook-maintenance-template.md +2 -2
- package/docs/ja/specdojo/exec-templates/xrp-sample-maintenance-template.md +2 -2
- package/docs/ja/specdojo/exec-templates/xrp-template-maintenance-template.md +2 -2
- package/docs/ja/specdojo/exec-templates/xrp-template.md +2 -2
- package/docs/ja/specdojo/guides/exec-config-guide.md +81 -19
- package/docs/ja/specdojo/guides/exec-operation-guide.md +4 -0
- package/docs/ja/specdojo/guides/kata-guide.md +108 -1
- package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +6 -6
- package/docs/ja/specdojo/guides/plan-result-lifecycle-guide.md +3 -1
- package/docs/ja/specdojo/guides/quick-start-guide.md +22 -2
- package/docs/ja/specdojo/guides/register-operation-guide.md +2 -0
- package/docs/ja/specdojo/guides/remote-host-development-guide.md +15 -1
- package/docs/ja/specdojo/guides/review-guide.md +2 -2
- package/docs/ja/specdojo/guides/ryu-guide.md +12 -0
- package/docs/ja/specdojo/references/command-reference.md +178 -62
- package/docs/ja/specdojo/references/specdojo-config-reference.md +31 -8
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +28 -22
- package/docs/specdojo/schemas/v1/exec-evidence.schema.yaml +17 -1
- package/docs/specdojo/schemas/v1/grade-pipeline-state.schema.yaml +1 -1
- package/docs/specdojo/schemas/v1/register-events.schema.yaml +2 -0
- package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +33 -1
- package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +16 -3
- package/package.json +5 -5
- package/templates/antigravity/orchestrator.md +4 -4
- package/templates/claude/README.md +2 -0
- package/templates/claude/agents/specdojo-orchestrator.md +4 -4
- package/templates/codex/README.md +38 -9
- package/templates/codex/agents/codex-executor.toml +1 -1
- package/templates/codex/agents/codex-expert-executor.toml +1 -1
- package/templates/codex/agents/codex-expert-review-executor.toml +1 -1
- package/templates/codex/agents/codex-review-executor.toml +1 -1
- package/templates/codex/agents/specdojo-orchestrator.toml +5 -5
- package/templates/codex/orchestrator.md +4 -4
- package/templates/devcontainer/devcontainer.json +1 -0
- package/templates/init-agent-members.yaml +131 -16
- package/templates/opencode/README.md +118 -14
- package/templates/opencode/agents/specdojo-orchestrator.md +5 -5
- package/templates/opencode/opencode.json +25 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { gradeCheckpointPaths } from "../grade-checkpoint.js";
|
|
1
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
4
|
import { qualifyTaskId, randomHex } from "../shared.js";
|
|
@@ -476,7 +477,10 @@ export async function runSingleRegisterItemWorktree(context, opts, pjrId, lifecy
|
|
|
476
477
|
throw new Error(`register start failed: ${item.id}`);
|
|
477
478
|
}
|
|
478
479
|
const checkpointRel = registerRunnerManagedPaths(repoRoot, registerPaths, planPath, resultPath, worktreeStatusPaths(repoRoot), ticketPath, supersededPaths);
|
|
479
|
-
const checkpointPaths =
|
|
480
|
+
const checkpointPaths = [
|
|
481
|
+
...checkpointRel.map((rel) => resolve(repoRoot, rel)),
|
|
482
|
+
...gradeCheckpointPaths({ repoRoot, executionPath }),
|
|
483
|
+
];
|
|
480
484
|
const checkpointFailureLogPath = pipelineRunId
|
|
481
485
|
? integrateLogPath(pipelineStateLocation({
|
|
482
486
|
repoRoot,
|
|
@@ -539,6 +543,7 @@ export async function runSingleRegisterItemWorktree(context, opts, pjrId, lifecy
|
|
|
539
543
|
let stderr = "";
|
|
540
544
|
// pipeline 実行のみ run state を持つ。統合段の記録先として Phase 3 へ渡す。
|
|
541
545
|
let pipelineStatePath;
|
|
546
|
+
let pipelineBlockReason;
|
|
542
547
|
let transitionReason;
|
|
543
548
|
let completionActor = actor;
|
|
544
549
|
if (pipelineAgents) {
|
|
@@ -570,6 +575,7 @@ export async function runSingleRegisterItemWorktree(context, opts, pjrId, lifecy
|
|
|
570
575
|
});
|
|
571
576
|
agentResult = pipelineOutcome.runResult;
|
|
572
577
|
stderr = pipelineOutcome.blockReason ?? "";
|
|
578
|
+
pipelineBlockReason = pipelineOutcome.blockReason;
|
|
573
579
|
pipelineStatePath = resolve(worktree.path, pipelineOutcome.stateRef);
|
|
574
580
|
transitionReason = rateLimitRecoveryReason(pipelineOutcome.rateLimitEvents) || undefined;
|
|
575
581
|
}
|
|
@@ -601,6 +607,7 @@ export async function runSingleRegisterItemWorktree(context, opts, pjrId, lifecy
|
|
|
601
607
|
actor: completionActor,
|
|
602
608
|
bookkeepingPaths,
|
|
603
609
|
pipelineStatePath,
|
|
610
|
+
runnerBlockReason: pipelineBlockReason,
|
|
604
611
|
transitionReason,
|
|
605
612
|
});
|
|
606
613
|
return lifecycleLock ? lifecycleLock.runExclusive(finalize) : finalize();
|
|
@@ -6,12 +6,13 @@ import { buildInitialStateFromStrategy } from "../schedule/initial.js";
|
|
|
6
6
|
import { qualifyTaskId, randomHex } from "../shared.js";
|
|
7
7
|
import { generateSinglePlan, finalizeResultSectionsForDeliverable, targetDocIdsForScheduledTask, reviewGradeSubject, } from "../plans.js";
|
|
8
8
|
import { ensureReviewGrade } from "../../review/grade.js";
|
|
9
|
+
import { gradeCheckpointPaths } from "../grade-checkpoint.js";
|
|
9
10
|
import { isResultUnfilled, readResultFrontmatterSnapshot, scaffoldResult } from "../results.js";
|
|
10
11
|
import { worktreeNameFromTaskId } from "../worktree.js";
|
|
11
12
|
import { configuredProductRepos, plannedProjectWorktreePath } from "../task-repos.js";
|
|
12
13
|
import { checkpointAndEnsureWorktree, discardStaleExecWorktree } from "../worktree-ops.js";
|
|
13
14
|
import { pipelineStateLocation } from "../pipeline-state.js";
|
|
14
|
-
import { collectBusyActors, pinnedExecutor, pinnedReporter, resolveAgentOverride, resolvePinnedRateLimitRunOptions, resolveTaskPhaseContext, selectCandidates, } from "./shared.js";
|
|
15
|
+
import { collectBusyActors, pinnedExecutor, pinnedReporter, resolveAgentOverride, resolveExecDefaultsPath, resolvePinnedRateLimitRunOptions, resolveTaskPhaseContext, selectCandidates, } from "./shared.js";
|
|
15
16
|
import { buildExecutorPrompt, executorRequirements, loadPrompt, reportProductWorktrees, reporterRequirements, resolveReporterAgentCandidates, } from "./agent.js";
|
|
16
17
|
import { integrateLogPath, spawnClaim, spawnRelease } from "./mode-shared.js";
|
|
17
18
|
export function findClaimEventPath(schedulePath, taskId) {
|
|
@@ -38,6 +39,8 @@ export async function gradeBeforeReviewPlan(params) {
|
|
|
38
39
|
target: subject.target,
|
|
39
40
|
repoRoot: params.repoRoot,
|
|
40
41
|
dryRun: params.dryRun,
|
|
42
|
+
by: params.by,
|
|
43
|
+
execDefaultsPath: params.execDefaultsPath,
|
|
41
44
|
});
|
|
42
45
|
const summary = outcome.action === "skipped"
|
|
43
46
|
? "skipped: content_hash matches the stored grade"
|
|
@@ -165,6 +168,8 @@ export async function prepareSingleTask(task, projectId, repoRoot, schedulePath,
|
|
|
165
168
|
catalogPath: planGenPaths.catalogPath,
|
|
166
169
|
repoRoot,
|
|
167
170
|
dryRun,
|
|
171
|
+
by: agentCandidates[0]?.actor,
|
|
172
|
+
execDefaultsPath: resolveExecDefaultsPath(rateLimitOverrides, schedulePath),
|
|
168
173
|
});
|
|
169
174
|
// Plans are generated on demand here; `exec refresh` does not manage them.
|
|
170
175
|
await generateSinglePlan({
|
|
@@ -279,6 +284,7 @@ export async function prepareSingleTask(task, projectId, repoRoot, schedulePath,
|
|
|
279
284
|
join(executionPath, "exec", "plans", `${task.id}-plan.md`),
|
|
280
285
|
resultPath,
|
|
281
286
|
claimEventPath,
|
|
287
|
+
...gradeCheckpointPaths({ repoRoot, executionPath }),
|
|
282
288
|
];
|
|
283
289
|
const checkpointFailureLogPath = pipelineRunId
|
|
284
290
|
? integrateLogPath(pipelineStateLocation({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { gradeCheckpointPaths } from "./grade-checkpoint.js";
|
|
1
2
|
import { spawn } from "node:child_process";
|
|
2
3
|
import { existsSync } from "node:fs";
|
|
3
4
|
import { join, resolve } from "node:path";
|
|
@@ -190,7 +191,12 @@ async function prepare(opts) {
|
|
|
190
191
|
context,
|
|
191
192
|
worktreeTaskId,
|
|
192
193
|
base,
|
|
193
|
-
checkpointPaths: [
|
|
194
|
+
checkpointPaths: [
|
|
195
|
+
planPath,
|
|
196
|
+
resultPath,
|
|
197
|
+
lockedState.claimEventPath,
|
|
198
|
+
...gradeCheckpointPaths(context),
|
|
199
|
+
],
|
|
194
200
|
commitMessage: `exec(${opts.task}): prepare execution`,
|
|
195
201
|
products,
|
|
196
202
|
});
|
|
@@ -332,6 +338,7 @@ function merge(opts) {
|
|
|
332
338
|
join(context.executionPath, "exec", "plans", `${opts.task}-plan.md`),
|
|
333
339
|
join(context.executionPath, "exec", "results", `${opts.task}-result.md`),
|
|
334
340
|
...(claimEventPath ? [claimEventPath] : []),
|
|
341
|
+
...gradeCheckpointPaths(context),
|
|
335
342
|
];
|
|
336
343
|
mergeWorktreeIntoCurrent({
|
|
337
344
|
context,
|
|
@@ -287,8 +287,10 @@ function checkpointAndEnsureProjectWorktree(params, repoDirName, ensureSiblingWo
|
|
|
287
287
|
typeof committed.stderr === "string" ? committed.stderr : "",
|
|
288
288
|
"",
|
|
289
289
|
]);
|
|
290
|
-
throw new Error(
|
|
291
|
-
|
|
290
|
+
throw new Error(
|
|
291
|
+
// register の短い block_reason にも step とエラーが残るよう、補足より先に要約を置く。
|
|
292
|
+
`Checkpoint commit failed: ${summarizeGitHookFailure(output)} ` +
|
|
293
|
+
`(${params.commitMessage}; staged changes rolled back; likely a failing git hook)`);
|
|
292
294
|
}
|
|
293
295
|
}
|
|
294
296
|
return worktree;
|
|
@@ -5,6 +5,7 @@ import { acquireSchedulerLock, releaseSchedulerLock } from "./events.js";
|
|
|
5
5
|
import { rebuildRegisterTicketFromEvents, unionRegisterEventLogs, } from "../register/event-merge.js";
|
|
6
6
|
import { displayIdFromRegisterEventFilename, REGISTER_EVENTS_DIRNAME } from "../register/events.js";
|
|
7
7
|
import { displayIdFromTicketFilename } from "../register/item.js";
|
|
8
|
+
import { isGradeCheckpointPath } from "./grade-checkpoint.js";
|
|
8
9
|
import { appendGitFailureLog, gitOutput, gitResult, summarizeGitHookFailure, } from "./worktree.js";
|
|
9
10
|
import { commitTargetPaths, currentBranch, repoRelative, rootDirtyPaths, zeroSeparatedPaths, } from "./worktree-ops-commit.js";
|
|
10
11
|
const DEFAULT_LOCK_TIMEOUT_MS = 10_000;
|
|
@@ -198,7 +199,7 @@ export function mergeWorktreeIntoCurrent(params) {
|
|
|
198
199
|
let lockDir = "";
|
|
199
200
|
let released = [];
|
|
200
201
|
let merged = false;
|
|
201
|
-
|
|
202
|
+
let releasePaths = (params.releaseRootPaths ?? []).map((path) => repoRelative(context.repoRoot, path));
|
|
202
203
|
const releasePathSet = new Set(releasePaths);
|
|
203
204
|
try {
|
|
204
205
|
if (!params.dryRun) {
|
|
@@ -207,6 +208,44 @@ export function mergeWorktreeIntoCurrent(params) {
|
|
|
207
208
|
lockTimeoutMs: DEFAULT_LOCK_TIMEOUT_MS,
|
|
208
209
|
lockStaleMs: DEFAULT_LOCK_STALE_MS,
|
|
209
210
|
});
|
|
211
|
+
// Canonical grades may have been refreshed in the root after branching. Release only
|
|
212
|
+
// the checkpoint copies; refuse to discard a newer root-side evaluation.
|
|
213
|
+
const gradePaths = releasePaths.filter((path) => isGradeCheckpointPath(path, repoRelative(context.repoRoot, context.executionPath)));
|
|
214
|
+
if (gradePaths.length > 0) {
|
|
215
|
+
const base = gitOutput(context.repoRoot, ["merge-base", "HEAD", worktree.branch]).trim();
|
|
216
|
+
const branchPaths = new Set(zeroSeparatedPaths(context.repoRoot, [
|
|
217
|
+
"diff",
|
|
218
|
+
"--no-renames",
|
|
219
|
+
"--name-only",
|
|
220
|
+
"-z",
|
|
221
|
+
`${base}..${worktree.branch}`,
|
|
222
|
+
]));
|
|
223
|
+
// A grade for a different document may have appeared while the task was running.
|
|
224
|
+
// Leave such root-side work in place; only release grades this branch will merge.
|
|
225
|
+
const gradePathSet = new Set(gradePaths);
|
|
226
|
+
releasePaths = releasePaths.filter((path) => !gradePathSet.has(path) || branchPaths.has(path));
|
|
227
|
+
const sharedGradePaths = gradePaths.filter((path) => branchPaths.has(path));
|
|
228
|
+
if (sharedGradePaths.length > 0) {
|
|
229
|
+
const checkpoint = gitOutput(context.repoRoot, [
|
|
230
|
+
"rev-list",
|
|
231
|
+
"--reverse",
|
|
232
|
+
"--first-parent",
|
|
233
|
+
`${base}..${worktree.branch}`,
|
|
234
|
+
])
|
|
235
|
+
.trim()
|
|
236
|
+
.split("\n")[0];
|
|
237
|
+
if (!checkpoint)
|
|
238
|
+
throw new Error("Cannot identify grade checkpoint before merge");
|
|
239
|
+
for (const path of sharedGradePaths) {
|
|
240
|
+
const expected = gitResult(context.repoRoot, ["show", `${checkpoint}:${path}`]);
|
|
241
|
+
const absolute = resolve(context.repoRoot, path);
|
|
242
|
+
const current = existsSync(absolute) ? readFileSync(absolute, "utf8") : undefined;
|
|
243
|
+
if ((expected.status === 0 ? expected.stdout : undefined) !== current) {
|
|
244
|
+
throw new Error(`Grade sidecar changed after checkpoint; reconcile before merge: ${path}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
210
249
|
released = releaseRootWorkingCopies(context.repoRoot, releasePaths);
|
|
211
250
|
}
|
|
212
251
|
const dirty = commitTargetPaths(context, worktree, taskId);
|
package/dist/grade/apply.js
CHANGED
|
@@ -532,8 +532,8 @@ export function validateGradeSubmission(submission, doc, target, options = {}) {
|
|
|
532
532
|
}
|
|
533
533
|
// 詳細ファイルは成果物ごとに1件で、再評価のたびに上書きする。時点の記録は git 履歴が担う。
|
|
534
534
|
// grade 本体と同じ方式であり、実行ごとにファイルを増やすと最新の評価を判別できなくなる。
|
|
535
|
-
export function doneCriteriaDetailPath(criteriaDirectory, documentPath) {
|
|
536
|
-
const absolute = resolveSafeMarkdownPath(documentPath);
|
|
535
|
+
export function doneCriteriaDetailPath(criteriaDirectory, documentPath, project) {
|
|
536
|
+
const absolute = resolveSafeMarkdownPath(documentPath, specdojoRootDir(), project);
|
|
537
537
|
const directory = resolveSafeRepositoryPath(criteriaDirectory, "criteria directory");
|
|
538
538
|
return join(directory, gradePlanFilename(absolute).replace(/-grade-plan\.md$/, "-done-criteria.yaml"));
|
|
539
539
|
}
|
|
@@ -563,12 +563,12 @@ export function applyGradeSubmission(opts) {
|
|
|
563
563
|
? createGradeSourceContext(opts.project, specdojoRootDir())
|
|
564
564
|
: undefined;
|
|
565
565
|
for (const input of opts.submission.documents) {
|
|
566
|
-
const absolute = resolveSafeMarkdownPath(input.path);
|
|
566
|
+
const absolute = resolveSafeMarkdownPath(input.path, specdojoRootDir(), opts.project);
|
|
567
567
|
const rel = repoRelativePath(absolute);
|
|
568
568
|
const current = readFileSync(absolute, "utf8");
|
|
569
569
|
const definitions = opts.doneCriteriaByPath?.get(rel);
|
|
570
570
|
const detailPath = definitions && input.done_criteria && opts.criteriaDirectory
|
|
571
|
-
? doneCriteriaDetailPath(opts.criteriaDirectory, absolute)
|
|
571
|
+
? doneCriteriaDetailPath(opts.criteriaDirectory, absolute, opts.project)
|
|
572
572
|
: undefined;
|
|
573
573
|
if (definitions && input.done_criteria && !detailPath) {
|
|
574
574
|
throw new Error(`${rel}: criteriaDirectory is required to record done_criteria`);
|
|
@@ -641,7 +641,9 @@ export function applyGradeSubmission(opts) {
|
|
|
641
641
|
path: rel,
|
|
642
642
|
target: opts.target,
|
|
643
643
|
rubric: rubric.id,
|
|
644
|
-
...(opts.reference
|
|
644
|
+
...(opts.reference
|
|
645
|
+
? { reference: resolveGradeReferenceId(opts.reference, opts.project) }
|
|
646
|
+
: {}),
|
|
645
647
|
verdict: summary.verdict,
|
|
646
648
|
score: summary.score,
|
|
647
649
|
graded_at: gradedAt,
|
|
@@ -4,6 +4,7 @@ import { listExhaustedGradePipelineStates, readGradePipelineState, recordGradePi
|
|
|
4
4
|
import { migrateInlineGrades, validateGradeResultForDocument } from "./markdown.js";
|
|
5
5
|
import { readGradeResultForDocument } from "./result.js";
|
|
6
6
|
import { repoRelativePath, resolveSafeMarkdownPath } from "./targets.js";
|
|
7
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
7
8
|
export function registerGradeInspectionCommands(grade) {
|
|
8
9
|
addSelection(grade.command("validate").description("Validate stored grade hashes and finding counts")).action((options) => {
|
|
9
10
|
try {
|
|
@@ -41,7 +42,7 @@ export function registerGradeInspectionCommands(grade) {
|
|
|
41
42
|
.option("--project <projectId>", "Project id in specdojo.config.json")
|
|
42
43
|
.action((options) => {
|
|
43
44
|
try {
|
|
44
|
-
const absolute = resolveSafeMarkdownPath(options.path);
|
|
45
|
+
const absolute = resolveSafeMarkdownPath(options.path, specdojoRootDir(), options.project);
|
|
45
46
|
const rel = repoRelativePath(absolute);
|
|
46
47
|
const result = readGradeResultForDocument({ documentPath: rel, project: options.project });
|
|
47
48
|
if (result)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { addGradeSelectionOptions, commandError, requirePositiveInteger, requireTarget, } from "./command-shared.js";
|
|
2
|
+
import { runGrade } from "./run.js";
|
|
3
|
+
export function registerGradeRunCommand(grade, runtime) {
|
|
4
|
+
addGradeSelectionOptions(grade
|
|
5
|
+
.command("run")
|
|
6
|
+
.description("Grade selected documents with the native single-stage pipeline; reuse run-id to resume"))
|
|
7
|
+
.requiredOption("--run-id <id>", "Stable id for persisted selection and completed stages")
|
|
8
|
+
.option("--kind <kind>", "Kata kind: rulebook, recipe, sample, template, all")
|
|
9
|
+
.option("--by <nickname>", "Grading executor (default: roster auto-selection)")
|
|
10
|
+
.option("--stage-1-executor <nickname>", "Alias for --by")
|
|
11
|
+
.option("--stages <count>", "Native pipeline stage count (1)", "1")
|
|
12
|
+
.option("--work-dir <directory>", "Repository-relative run state directory")
|
|
13
|
+
.option("--reference <path>", "Comparison reference document")
|
|
14
|
+
.option("--embed-documents", "Embed target and reference contents", false)
|
|
15
|
+
.option("--max-stage-failures <count>", "Consecutive failure limit", requirePositiveInteger, 3)
|
|
16
|
+
.option("--limit <count>", "Maximum number of documents", requirePositiveInteger)
|
|
17
|
+
.option("--exec-defaults <path>", "Override exec-defaults.yaml")
|
|
18
|
+
.option("--dry-run", "Print selection and actual actor without writing or running an agent", false)
|
|
19
|
+
.action(async (options) => {
|
|
20
|
+
try {
|
|
21
|
+
if (!runtime)
|
|
22
|
+
throw new Error("Grade agent runtime is not configured");
|
|
23
|
+
if (options.stages !== "1")
|
|
24
|
+
throw new Error("grade run supports --stages 1");
|
|
25
|
+
if (options.by && options.stage1Executor)
|
|
26
|
+
throw new Error("Use either --by or --stage-1-executor");
|
|
27
|
+
await runGrade({
|
|
28
|
+
...options,
|
|
29
|
+
target: requireTarget(options.target),
|
|
30
|
+
paths: options.path,
|
|
31
|
+
by: options.by ?? options.stage1Executor,
|
|
32
|
+
execDefaultsPath: options.execDefaults,
|
|
33
|
+
}, runtime);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
commandError(error);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
package/dist/grade/grade.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { registerGradeApplyCommands } from "./command-apply.js";
|
|
2
2
|
import { registerGradeInspectionCommands } from "./command-inspect.js";
|
|
3
3
|
import { registerGradePlanCommands } from "./command-plan.js";
|
|
4
|
+
import { registerGradeRunCommand } from "./command-run.js";
|
|
4
5
|
export * from "./apply.js";
|
|
5
6
|
export { renderGradeFindingTranslationPlan } from "./command-apply.js";
|
|
6
7
|
export * from "./core.js";
|
|
@@ -9,11 +10,12 @@ export * from "./pipeline-state.js";
|
|
|
9
10
|
export * from "./plan.js";
|
|
10
11
|
export * from "./target-discovery.js";
|
|
11
12
|
export * from "./targets.js";
|
|
12
|
-
export function registerGradeCommand(program) {
|
|
13
|
+
export function registerGradeCommand(program, runtime) {
|
|
13
14
|
const grade = program
|
|
14
15
|
.command("grade")
|
|
15
16
|
.description("Continuously assess Kata and deliverable content quality");
|
|
16
17
|
registerGradePlanCommands(grade);
|
|
17
18
|
registerGradeApplyCommands(grade);
|
|
18
19
|
registerGradeInspectionCommands(grade);
|
|
20
|
+
registerGradeRunCommand(grade, runtime);
|
|
19
21
|
}
|
package/dist/grade/markdown.js
CHANGED
|
@@ -39,11 +39,11 @@ export function scoreDocument(input, rubric, doc, target) {
|
|
|
39
39
|
}
|
|
40
40
|
// 比較リファレンスは ID で保存する。パスで保存すると文書を移動したときに参照が壊れる。
|
|
41
41
|
// 引数にはパスと ID のどちらも渡せる。パスの場合は Frontmatter の id を読み取る。
|
|
42
|
-
export function resolveGradeReferenceId(pathOrId) {
|
|
42
|
+
export function resolveGradeReferenceId(pathOrId, project) {
|
|
43
43
|
const trimmed = pathOrId.trim();
|
|
44
44
|
if (!trimmed.endsWith(".md"))
|
|
45
45
|
return trimmed;
|
|
46
|
-
const absolute = resolveSafeMarkdownPath(trimmed);
|
|
46
|
+
const absolute = resolveSafeMarkdownPath(trimmed, specdojoRootDir(), project);
|
|
47
47
|
const document = parseMarkdown(readFileSync(absolute, "utf8"), repoRelativePath(absolute));
|
|
48
48
|
const metadata = document.data.specdojo;
|
|
49
49
|
if (!isRecord(metadata) || typeof metadata.id !== "string" || metadata.id.length === 0) {
|
|
@@ -144,7 +144,7 @@ export function validateGradedDocument(path) {
|
|
|
144
144
|
return validateGradedMarkdown(readFileSync(absolute, "utf8"), rel);
|
|
145
145
|
}
|
|
146
146
|
export function validateGradeResultForDocument(opts) {
|
|
147
|
-
const absolute = resolveSafeMarkdownPath(opts.path);
|
|
147
|
+
const absolute = resolveSafeMarkdownPath(opts.path, specdojoRootDir(), opts.project);
|
|
148
148
|
const rel = repoRelativePath(absolute);
|
|
149
149
|
const content = readFileSync(absolute, "utf8");
|
|
150
150
|
const result = readGradeResultForDocument({ documentPath: rel, project: opts.project });
|
|
@@ -174,7 +174,7 @@ export function validateGradedMarkdown(content, path) {
|
|
|
174
174
|
export function migrateInlineGrades(opts) {
|
|
175
175
|
const rootDir = specdojoRootDir();
|
|
176
176
|
const candidates = opts.paths && opts.paths.length > 0
|
|
177
|
-
? opts.paths.map((path) => resolveSafeMarkdownPath(path, rootDir))
|
|
177
|
+
? opts.paths.map((path) => resolveSafeMarkdownPath(path, rootDir, opts.project))
|
|
178
178
|
: [
|
|
179
179
|
...(opts.target !== "deliverable"
|
|
180
180
|
? discoverGradeTargets({ target: "kata", project: opts.project }, rootDir)
|
|
@@ -59,10 +59,8 @@ function parseGradePipelineState(value, path) {
|
|
|
59
59
|
if (!/^[a-f0-9]{64}$/.test(state.content_hash)) {
|
|
60
60
|
throw new Error(`${path}: content_hash must be a SHA-256 hex digest`);
|
|
61
61
|
}
|
|
62
|
-
if (isAbsolute(state.document) ||
|
|
63
|
-
|
|
64
|
-
state.document.split("/").includes("..")) {
|
|
65
|
-
throw new Error(`${path}: document must be a repository-relative path below docs/`);
|
|
62
|
+
if (isAbsolute(state.document) || !state.document.endsWith(".md")) {
|
|
63
|
+
throw new Error(`${path}: document must be a relative Markdown path`);
|
|
66
64
|
}
|
|
67
65
|
if (state.stage_completed >= state.stage_total) {
|
|
68
66
|
throw new Error(`${path}: completed pipeline state must be removed`);
|
|
@@ -86,6 +84,9 @@ export function loadGradePipelineStates(projectOption, rootDir = specdojoRootDir
|
|
|
86
84
|
if (state.project_id !== projectId) {
|
|
87
85
|
throw new Error(`${relativePathFromRoot(path, rootDir)}: project_id must be ${projectId}`);
|
|
88
86
|
}
|
|
87
|
+
const documentPath = resolve(rootDir, state.document);
|
|
88
|
+
if (existsSync(documentPath))
|
|
89
|
+
resolveSafeMarkdownPath(state.document, rootDir, projectOption);
|
|
89
90
|
states.set(state.document, state);
|
|
90
91
|
}
|
|
91
92
|
return states;
|
|
@@ -100,7 +101,7 @@ export function isIncompleteGradePipelineState(state) {
|
|
|
100
101
|
return state !== undefined && state.consecutive_failures < state.max_failures;
|
|
101
102
|
}
|
|
102
103
|
export function readGradePipelineState(opts) {
|
|
103
|
-
const absolute = resolveSafeMarkdownPath(opts.path);
|
|
104
|
+
const absolute = resolveSafeMarkdownPath(opts.path, specdojoRootDir(), opts.project);
|
|
104
105
|
const relativeDocument = repoRelativePath(absolute);
|
|
105
106
|
const statePath = gradePipelineStatePath(relativeDocument, opts.project);
|
|
106
107
|
if (!existsSync(statePath))
|
|
@@ -122,13 +123,14 @@ export function listExhaustedGradePipelineStates(opts) {
|
|
|
122
123
|
const absolute = resolve(specdojoRootDir(), state.document);
|
|
123
124
|
if (!existsSync(absolute))
|
|
124
125
|
return false;
|
|
126
|
+
resolveSafeMarkdownPath(state.document, specdojoRootDir(), opts.project);
|
|
125
127
|
const document = parseMarkdown(readFileSync(absolute, "utf8"), state.document);
|
|
126
128
|
return currentGradePipelineState(document, state.document, state, opts.target) !== undefined;
|
|
127
129
|
})
|
|
128
130
|
.sort((left, right) => left.document.localeCompare(right.document));
|
|
129
131
|
}
|
|
130
132
|
export function recordGradePipelineStage(opts) {
|
|
131
|
-
const absolute = resolveSafeMarkdownPath(opts.path);
|
|
133
|
+
const absolute = resolveSafeMarkdownPath(opts.path, specdojoRootDir(), opts.project);
|
|
132
134
|
const relativeDocument = repoRelativePath(absolute);
|
|
133
135
|
const statePath = gradePipelineStatePath(relativeDocument, opts.project);
|
|
134
136
|
if (opts.status === "complete") {
|
package/dist/grade/plan.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
3
4
|
import { basename, extname, join } from "node:path";
|
|
4
5
|
import { dump } from "../shared/yaml.js";
|
|
5
6
|
import { GRADE_PLAN_EMBEDDED_DOCUMENT_CHARACTER_LIMIT, agentViewpoints, gradedViewpoints, levelCapForFindings, parseMarkdown, } from "./core.js";
|
|
@@ -138,7 +139,7 @@ function gradePlanEmbedding(opts) {
|
|
|
138
139
|
}
|
|
139
140
|
function renderGradePlanWithEmbedding(opts) {
|
|
140
141
|
const rubric = assertRubric(opts.viewpoints);
|
|
141
|
-
const absolute = resolveSafeMarkdownPath(opts.path);
|
|
142
|
+
const absolute = resolveSafeMarkdownPath(opts.path, specdojoRootDir(), opts.projectId);
|
|
142
143
|
const rel = repoRelativePath(absolute);
|
|
143
144
|
const document = parseMarkdown(readFileSync(absolute, "utf8"), rel);
|
|
144
145
|
const metadata = document.data.specdojo;
|
|
@@ -151,7 +152,7 @@ function renderGradePlanWithEmbedding(opts) {
|
|
|
151
152
|
const taskId = `GRADE-${opts.target.toUpperCase()}-${taskHash}`;
|
|
152
153
|
const references = (opts.references ?? []).map((reference) => repoRelativePath(resolveSafeRepositoryPath(reference, "reference")));
|
|
153
154
|
const referenceExample = opts.referenceExample
|
|
154
|
-
? repoRelativePath(resolveSafeMarkdownPath(opts.referenceExample))
|
|
155
|
+
? repoRelativePath(resolveSafeMarkdownPath(opts.referenceExample, specdojoRootDir(), opts.projectId))
|
|
155
156
|
: undefined;
|
|
156
157
|
const embedding = gradePlanEmbedding({
|
|
157
158
|
requested: opts.embedDocuments ?? false,
|
|
@@ -331,7 +332,7 @@ export function renderGradePlan(opts) {
|
|
|
331
332
|
}
|
|
332
333
|
export function renderGradeReporterPlan(opts) {
|
|
333
334
|
const rubric = assertRubric(opts.viewpoints);
|
|
334
|
-
const absolute = resolveSafeMarkdownPath(opts.path);
|
|
335
|
+
const absolute = resolveSafeMarkdownPath(opts.path, specdojoRootDir(), opts.projectId);
|
|
335
336
|
const rel = repoRelativePath(absolute);
|
|
336
337
|
const document = parseMarkdown(readFileSync(absolute, "utf8"), rel);
|
|
337
338
|
const metadata = document.data.specdojo;
|
|
@@ -449,17 +450,18 @@ export function writeGradePlans(opts) {
|
|
|
449
450
|
mkdirSync(outputDirectory, { recursive: true });
|
|
450
451
|
const kataReferences = loadKataReferences();
|
|
451
452
|
const referenceExamples = opts.referenceExampleCandidates.flatMap((candidate) => {
|
|
452
|
-
const parsed = parseGradeReferenceExample(candidate, opts.target);
|
|
453
|
+
const parsed = parseGradeReferenceExample(candidate, opts.target, opts.projectId);
|
|
453
454
|
return parsed ? [parsed] : [];
|
|
454
455
|
});
|
|
455
456
|
return opts.paths.map((path) => {
|
|
456
|
-
const absolute = resolveSafeMarkdownPath(path);
|
|
457
|
+
const absolute = resolveSafeMarkdownPath(path, specdojoRootDir(), opts.projectId);
|
|
457
458
|
const output = join(outputDirectory, gradePlanFilename(absolute));
|
|
458
459
|
const reporterOutput = join(outputDirectory, gradeReporterPlanFilename(absolute));
|
|
459
460
|
const referenceExample = opts.referenceExampleOverride ??
|
|
460
461
|
selectGradeReferenceExampleFromCatalog({
|
|
461
462
|
target: opts.target,
|
|
462
463
|
path: absolute,
|
|
464
|
+
project: opts.projectId,
|
|
463
465
|
candidates: referenceExamples,
|
|
464
466
|
random: opts.random,
|
|
465
467
|
});
|
|
@@ -467,7 +469,7 @@ export function writeGradePlans(opts) {
|
|
|
467
469
|
const rendered = renderGradePlanWithEmbedding({
|
|
468
470
|
target: opts.target,
|
|
469
471
|
path: absolute,
|
|
470
|
-
references: resolveGradeReferencePathsFromCatalog(absolute, kataReferences),
|
|
472
|
+
references: resolveGradeReferencePathsFromCatalog(absolute, kataReferences, opts.projectId),
|
|
471
473
|
referenceExample,
|
|
472
474
|
viewpoints: opts.viewpoints,
|
|
473
475
|
projectId: opts.projectId,
|