specdojo 0.4.6 → 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/CHANGELOG.md +16 -0
- package/dist/catalog/document-target.js +75 -0
- package/dist/commands/agent.js +2 -80
- 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/grade-checkpoint.js +12 -0
- package/dist/exec/plans-core.js +4 -65
- package/dist/exec/plans-generation.js +22 -5
- package/dist/exec/project.js +4 -1
- package/dist/exec/register.js +66 -5
- package/dist/exec/run/lifecycle-commands.js +2 -0
- package/dist/exec/run/register-resume.js +1 -0
- package/dist/exec/run/register-state.js +4 -1
- package/dist/exec/run/register-worktree.js +5 -1
- package/dist/exec/run/schedule-prepare.js +7 -1
- package/dist/exec/worktree-command.js +8 -1
- 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/register/approach.js +16 -0
- package/dist/register/core.js +2 -0
- package/dist/register/create-commands.js +49 -1
- package/dist/register/deliverable-target.js +215 -0
- package/dist/register/events.js +4 -0
- package/dist/register/item.js +8 -0
- package/dist/review/grade.js +19 -17
- package/dist/shared/agent-plan.js +1 -0
- package/dist/shared/provider-scaffold.js +5 -3
- package/dist/specdojo.js +5 -1
- 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 +44 -12
- package/docs/ja/specdojo/guides/exec-operation-guide.md +4 -0
- 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/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 +52 -27
- package/docs/ja/specdojo/references/specdojo-config-reference.md +29 -8
- package/docs/ja/specdojo/rulebooks/pjr-rulebook.md +28 -22
- 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 +1 -1
- package/templates/devcontainer/devcontainer.json +1 -0
- package/templates/init-agent-members.yaml +46 -3
- package/templates/opencode/README.md +118 -14
- package/templates/opencode/agents/specdojo-orchestrator.md +1 -1
- package/templates/opencode/opencode.json +25 -0
package/dist/exec/register.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveRegisterDeliverableTarget, } from "../register/deliverable-target.js";
|
|
1
2
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { basename, extname, join, relative, resolve } from "node:path";
|
|
3
4
|
import { findRegisterItem, loadRegisterItems, PJR_ID_RE, resolveRegisterPaths, TERMINAL_STATUSES_SET, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "../register/register.js";
|
|
@@ -324,6 +325,51 @@ function catalogSource(catalogPath, projectId, source) {
|
|
|
324
325
|
}
|
|
325
326
|
return findDeliverableByPath(catalogPath, source.path);
|
|
326
327
|
}
|
|
328
|
+
function cataloglessPlanFields(resolved, item, targetId, ticketPath) {
|
|
329
|
+
let targets = [targetId];
|
|
330
|
+
let conditionsText = "";
|
|
331
|
+
if (resolved.catalogless) {
|
|
332
|
+
conditionsText =
|
|
333
|
+
"カタログの `done_criteria` はない。個票の完了条件と rulebook を完了基準とする。";
|
|
334
|
+
if (item.approach === "bootstrap") {
|
|
335
|
+
targets = [targetId, ...(resolved.kataIds ?? [])];
|
|
336
|
+
conditionsText += `\n\n成果物の frontmatter に \`specdojo.id: ${targetId}\` と \`specdojo.rulebook: ${resolved.info.deliverable.rulebook}\` を記入する。未作成の kata は次の ID とパスで整備し、recipe・sample・template の ID を rulebook frontmatter に宣言する。不要な型は作らず \`not-needed\` と宣言する。\n\n`;
|
|
337
|
+
conditionsText += (resolved.kataIds ?? [])
|
|
338
|
+
.map((id, index) => {
|
|
339
|
+
const kind = ["rulebook", "recipe", "sample", "template"][index];
|
|
340
|
+
return `- \`${id}\`: \`${kind ? resolved.refs?.[kind] : ""}\`(未作成 / missing)`;
|
|
341
|
+
})
|
|
342
|
+
.join("\n");
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
conditionsText += `\n\n成果物の frontmatter に \`specdojo.id: ${targetId}\` と \`specdojo.rulebook: ${resolved.info.deliverable.rulebook}\` を維持・記入する。`;
|
|
346
|
+
}
|
|
347
|
+
if (item.approach === "finalize" || item.approach === "bootstrap-finalize") {
|
|
348
|
+
if (item.approach === "bootstrap-finalize")
|
|
349
|
+
targets = [targetId, ...(resolved.kataIds ?? [])];
|
|
350
|
+
const conditions = registerCompletionConditions(item, ticketPath);
|
|
351
|
+
const checklist = conditions
|
|
352
|
+
.split(/\r?\n/)
|
|
353
|
+
.filter((line) => line.trim())
|
|
354
|
+
.map((line) => {
|
|
355
|
+
const text = line.replace(/^\s*(?:[-*+]\s+(?:\[[ xX]\]\s*)?|\d+\.\s*)/, "");
|
|
356
|
+
return `- [ ] ${text}`;
|
|
357
|
+
})
|
|
358
|
+
.join("\n");
|
|
359
|
+
conditionsText += `\n\n### 人による確定のチェック表\n\n${checklist}\n\n### 確定対象\n\n- [ ] 成果物: \`${resolved.info.resolvedPath}\``;
|
|
360
|
+
if (item.approach === "bootstrap-finalize") {
|
|
361
|
+
conditionsText +=
|
|
362
|
+
"\n" +
|
|
363
|
+
(resolved.kataTargets ?? [])
|
|
364
|
+
.map(({ id, path }) => `- [ ] \`${id}\`: \`${path}\`(frontmatter から辿った kata)`)
|
|
365
|
+
.join("\n");
|
|
366
|
+
}
|
|
367
|
+
conditionsText +=
|
|
368
|
+
"\n\n人が各条件と確定対象を確認する。agent は成果物の `status` を `ready` へ変更しない。";
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return { targets, conditions: conditionsText };
|
|
372
|
+
}
|
|
327
373
|
export async function generateRegisterPlan(opts) {
|
|
328
374
|
const { item } = opts;
|
|
329
375
|
const category = requireRunnableRegisterItem(item);
|
|
@@ -336,6 +382,8 @@ export async function generateRegisterPlan(opts) {
|
|
|
336
382
|
approach: item.approach,
|
|
337
383
|
targets: item.targets,
|
|
338
384
|
sources: item.sources,
|
|
385
|
+
targetPath: item.targetPath,
|
|
386
|
+
targetRulebook: item.targetRulebook,
|
|
339
387
|
});
|
|
340
388
|
const [targetId] = item.targets ?? [];
|
|
341
389
|
if (!targetId)
|
|
@@ -344,6 +392,8 @@ export async function generateRegisterPlan(opts) {
|
|
|
344
392
|
const maintenanceKind = MAINTENANCE_TARGET_KIND[item.approach];
|
|
345
393
|
let deliverable = null;
|
|
346
394
|
let refs;
|
|
395
|
+
let cataloglessConditions = "";
|
|
396
|
+
let planTargets = [targetId];
|
|
347
397
|
let authoring;
|
|
348
398
|
if (newKataKind) {
|
|
349
399
|
const sourceRefs = [...(item.targets ?? []).slice(1), ...(item.sources ?? [])];
|
|
@@ -412,10 +462,20 @@ export async function generateRegisterPlan(opts) {
|
|
|
412
462
|
refs = { ...refs, [maintenanceKind]: indexedDocumentPath(targetId) };
|
|
413
463
|
}
|
|
414
464
|
else {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
465
|
+
const resolved = resolveRegisterDeliverableTarget({
|
|
466
|
+
repoRoot: specdojoRootDir(),
|
|
467
|
+
projectId: opts.projectId,
|
|
468
|
+
catalogPath: opts.catalogPath,
|
|
469
|
+
approach: item.approach,
|
|
470
|
+
targetId,
|
|
471
|
+
targetPath: item.targetPath,
|
|
472
|
+
targetRulebook: item.targetRulebook,
|
|
473
|
+
});
|
|
474
|
+
deliverable = resolved.info;
|
|
475
|
+
refs = resolved.refs;
|
|
476
|
+
const fields = cataloglessPlanFields(resolved, item, targetId, ticketPath);
|
|
477
|
+
planTargets = fields.targets;
|
|
478
|
+
cataloglessConditions = fields.conditions;
|
|
419
479
|
}
|
|
420
480
|
const planPath = await generateRegisterApproachPlan({
|
|
421
481
|
executionPath: opts.executionPath,
|
|
@@ -429,11 +489,12 @@ export async function generateRegisterPlan(opts) {
|
|
|
429
489
|
description: item.description,
|
|
430
490
|
...(item.owner && item.owner !== "-" && item.owner !== "_TODO_" ? { owner: item.owner } : {}),
|
|
431
491
|
approach: item.approach,
|
|
432
|
-
targets:
|
|
492
|
+
targets: planTargets,
|
|
433
493
|
deliverable,
|
|
434
494
|
...(refs ? { refs } : {}),
|
|
435
495
|
...(authoring ? { authoring } : {}),
|
|
436
496
|
additionalConditions: [
|
|
497
|
+
cataloglessConditions,
|
|
437
498
|
registerCompletionConditions(item, ticketPath),
|
|
438
499
|
registerAutopilotConstraints(item),
|
|
439
500
|
]
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { gradeCheckpointPaths } from "../grade-checkpoint.js";
|
|
1
2
|
import { existsSync } from "node:fs";
|
|
2
3
|
import { join } from "node:path";
|
|
3
4
|
import { loadExecDefaultsConfig, providerSlotPoolPath, resolveMaxConcurrency, resolveMaxConcurrentRuns, } from "../agent-config.js";
|
|
@@ -277,6 +278,7 @@ export function prepareScheduleIntegrationResume(params) {
|
|
|
277
278
|
join(executionPath, "exec", "plans", `${task.id}-plan.md`),
|
|
278
279
|
resultPath,
|
|
279
280
|
...(claimEventPath ? [claimEventPath] : []),
|
|
281
|
+
...gradeCheckpointPaths({ repoRoot, executionPath }),
|
|
280
282
|
];
|
|
281
283
|
return {
|
|
282
284
|
task,
|
|
@@ -214,6 +214,7 @@ export async function resumeSingleRegisterItemWorktree(context, opts, pjrId, lif
|
|
|
214
214
|
// 再開開始前に集合を固定せず finalize の直前に評価する。
|
|
215
215
|
const bookkeepingPaths = () => registerBookkeepingPaths({
|
|
216
216
|
repoRoot,
|
|
217
|
+
executionPath,
|
|
217
218
|
registerPaths,
|
|
218
219
|
planPath: resolve(repoRoot, artifacts.planRef),
|
|
219
220
|
resultPath: resolve(repoRoot, artifacts.resultRef),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { gradeCheckpointPaths } from "../grade-checkpoint.js";
|
|
1
2
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { basename, dirname, resolve } from "node:path";
|
|
3
4
|
import { sanitizeRegisterConclusion, } from "../register.js";
|
|
@@ -157,7 +158,9 @@ export function registerTransitionPaths(registerPaths, ticketPath) {
|
|
|
157
158
|
// runner 管理パスとして扱う。この集合を失敗時の wait commit、merge 前の root 解放で使う。
|
|
158
159
|
export function registerBookkeepingPaths(params) {
|
|
159
160
|
const { repoRoot, registerPaths, planPath, resultPath, ticketPath } = params;
|
|
160
|
-
return registerRunnerManagedPaths(repoRoot, registerPaths, planPath, resultPath, worktreeStatusPaths(repoRoot), ticketPath)
|
|
161
|
+
return registerRunnerManagedPaths(repoRoot, registerPaths, planPath, resultPath, worktreeStatusPaths(repoRoot), ticketPath)
|
|
162
|
+
.map((path) => resolve(repoRoot, path))
|
|
163
|
+
.concat(gradeCheckpointPaths(params));
|
|
161
164
|
}
|
|
162
165
|
// root の登録簿派生ビュー(pjr-index / generated)は非追跡の生成物で、merge や複製では更新され
|
|
163
166
|
// ない。個票の状態を root 側へ反映したあとに再生成して、root の表示を個票と揃える。失敗しても
|
|
@@ -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,
|
|
@@ -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,
|
|
@@ -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,
|