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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
SpecDojo の利用者に影響する変更を記録します。
|
|
4
4
|
|
|
5
|
+
## [0.4.7] - 2026-10-26
|
|
6
|
+
|
|
7
|
+
### 追加機能
|
|
8
|
+
|
|
9
|
+
- カタログのない project でも、既存文書の索引・frontmatter、または個票の `--target-path`・`--target-rulebook` から成果物の approach plan を作れるようにしました。`fully-guided` などの kata 不足は起票時に検証し、`bootstrap` の未作成 kata と `finalize` 系の個票からのチェック表にも対応します。`cross-deliverable-dedup` は引き続きカタログが必要です(PJR-6WQY)。
|
|
10
|
+
|
|
11
|
+
- `projects.<id>.run.parent_validations_exclude` で、共有 `exec-defaults.yaml` の親検証から ID と実行先が一致する検証を project ごとに除外できるようにしました。除外後に既存の `parent_validations` を追記し、指定のない project の検証は維持します。未知の ID、共有一覧にない組の除外、重複する組は agent 起動前にエラーになります(PJR-P14M)。
|
|
12
|
+
|
|
13
|
+
- npm package に `specdojo grade run` を追加しました。文書の選択、評価 plan、名簿に基づく agent 実行、marker の機械変換とサイドカー反映を単段で実行し、同じ `--run-id` で未完了の文書だけを再開します。`--by` の別名は実体名で記録し、`--dry-run` で選択と actor を確認できます(PJR-K87Y)。
|
|
14
|
+
|
|
15
|
+
### 不具合修正
|
|
16
|
+
|
|
17
|
+
- review 前の grade を CLI 本体で実行し、開発用の `tools/grade/run-per-document.sh` への依存を解消しました。宣言済み `project.repos` の相対パスを grade で扱い、grade 結果・完了条件サイドカーを worktree 分岐前の checkpoint に含めます。`exec scaffold --project` の共通観点を `defaults/` から解決し、観点未設定時は同梱定義を使います。review plan の完了条件表を MD060 に適合させました(PJR-K87Y)。
|
|
18
|
+
- OpenCode の scaffold でローカル Ollama の接続・モデル設定を含む `opencode.json`(provider: `ollama-local`)をリポジトリ直下に配置するようにしました。配布する名簿の雛形・agent 定義・接続設定のモデル指定を整合させ、Gemma および Qwen は文脈長 64k を確保するローカル派生タグ(`*-mlx-work-64k`)を標準としました。派生タグ作成手順、接続先設定手順、既存環境の修正手順を OpenCode テンプレートの README および設定ガイドに追記しました(PJR-MB92)。
|
|
19
|
+
- `devcontainer scaffold` で生成する `devcontainer.json` の雛形に `shutdownAction: "none"` を追加し、VS Code などのクライアント切断時にコンテナが停止しないようにしました。既存環境の修正手順を常時稼働ホスト運用ガイドに追記しました(PJR-TVGA)。
|
|
20
|
+
|
|
5
21
|
## [0.4.6] - 2026-10-25
|
|
6
22
|
|
|
7
23
|
### 追加機能
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { basename, resolve } from "node:path";
|
|
3
|
+
import { collectResolvedDeliverables } from "./build.js";
|
|
4
|
+
import { resolveBasePath } from "./paths.js";
|
|
5
|
+
import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
|
|
6
|
+
import { load } from "../shared/yaml.js";
|
|
7
|
+
import { listFilesRecursive } from "../shared/fs.js";
|
|
8
|
+
import { isDctPlanFileName } from "./plan.js";
|
|
9
|
+
import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
10
|
+
// Existing document metadata is authoritative; uncreated product docs use a bare id.
|
|
11
|
+
export function deliverableDocId(projectId, localId, resolvedPath, repoRoot = specdojoRootDir()) {
|
|
12
|
+
if (resolvedPath) {
|
|
13
|
+
const absolutePath = resolve(repoRoot, resolvedPath);
|
|
14
|
+
if (existsSync(absolutePath)) {
|
|
15
|
+
try {
|
|
16
|
+
const id = readSpecdojoNamespace(readFileSync(absolutePath, "utf8")).id;
|
|
17
|
+
if (typeof id === "string" && id.trim())
|
|
18
|
+
return id.trim();
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// Invalid metadata falls back to the placement convention.
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const normalized = resolvedPath.replaceAll("\\", "/").replace(/^\/+/, "");
|
|
25
|
+
if (/^docs\/[a-z]{2}\/product(?:\/|$)/.test(normalized))
|
|
26
|
+
return localId;
|
|
27
|
+
}
|
|
28
|
+
return projectId ? `${projectId}:${localId}` : localId;
|
|
29
|
+
}
|
|
30
|
+
export function loadPlanCatalogDocs(catalogPath) {
|
|
31
|
+
if (!catalogPath || !existsSync(catalogPath))
|
|
32
|
+
return [];
|
|
33
|
+
// Catalog scans walk subdirectories, so agent judgment plans (plans/dct-plan-*.yaml)
|
|
34
|
+
// must be excluded; they share the dct- prefix but carry no catalog structure.
|
|
35
|
+
const files = listFilesRecursive(catalogPath)
|
|
36
|
+
.filter((f) => {
|
|
37
|
+
const name = basename(f);
|
|
38
|
+
return /^dct-.+\.ya?ml$/i.test(name) && !isDctPlanFileName(name);
|
|
39
|
+
})
|
|
40
|
+
.sort();
|
|
41
|
+
const docs = [];
|
|
42
|
+
for (const filePath of files) {
|
|
43
|
+
try {
|
|
44
|
+
docs.push(load(readFileSync(filePath, "utf8")));
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return docs;
|
|
51
|
+
}
|
|
52
|
+
export function resolveDeliverableByDocId(catalogPath, projectId, targetId, repoRoot = specdojoRootDir()) {
|
|
53
|
+
const matches = [];
|
|
54
|
+
for (const doc of loadPlanCatalogDocs(catalogPath)) {
|
|
55
|
+
const deliverables = [];
|
|
56
|
+
collectResolvedDeliverables(doc.groups, resolveBasePath("", doc.base_path), deliverables);
|
|
57
|
+
for (const { item, resolvedPath } of deliverables) {
|
|
58
|
+
if (targetId === deliverableDocId(projectId, item.local_id, resolvedPath, repoRoot) ||
|
|
59
|
+
targetId === item.local_id ||
|
|
60
|
+
targetId === `${projectId}:${item.local_id}`) {
|
|
61
|
+
matches.push({
|
|
62
|
+
domain: doc.domain,
|
|
63
|
+
localId: item.local_id,
|
|
64
|
+
slug: item.local_id,
|
|
65
|
+
info: { deliverable: item, resolvedPath },
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (matches.length === 0)
|
|
71
|
+
throw new Error(`catalog deliverable target not found for document id: ${targetId}`);
|
|
72
|
+
if (matches.length > 1)
|
|
73
|
+
throw new Error(`ambiguous catalog deliverable target for document id ${targetId}: ${matches.map((match) => match.localId).join(", ")}`);
|
|
74
|
+
return matches[0];
|
|
75
|
+
}
|
package/dist/commands/agent.js
CHANGED
|
@@ -1,83 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { defaultExecDefaultsPath, loadExecDefaultsConfig, resolveMemberCommand, resolveRateLimitDetection, resolveRateLimitPolicy, } from "../exec/agent-config.js";
|
|
4
|
-
import { resolveProjectPaths } from "../exec/project.js";
|
|
5
|
-
import { executeAgent, loadRosterForExecutionPath } from "../exec/run/run.js";
|
|
6
|
-
import { gitEnvironment } from "../shared/git-environment.js";
|
|
7
|
-
import { resolveAgentMember as resolveRosterAgentMember, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
8
|
-
// Rate limit は通常失敗と異なり、呼び出し側が処理済みにせず中断・再開する必要がある。
|
|
9
|
-
// shell script が出力文字列を解析せず分岐できるよう、一時失敗を表す専用コードにする。
|
|
10
|
-
export const AGENT_RUN_RATE_LIMIT_EXIT_CODE = 75;
|
|
11
|
-
export function resolveAgentMember(roster, nickname) {
|
|
12
|
-
const directMembers = roster?.members.filter((candidate) => {
|
|
13
|
-
return candidate.type === "agent" && candidate.nickname === nickname;
|
|
14
|
-
});
|
|
15
|
-
if (directMembers && directMembers.length > 1) {
|
|
16
|
-
return { error: `--by agent nickname is not unique in agent-members.yaml: ${nickname}` };
|
|
17
|
-
}
|
|
18
|
-
const member = resolveRosterAgentMember(roster, nickname);
|
|
19
|
-
if (!member) {
|
|
20
|
-
return { error: `--by agent nickname not found in agent-members.yaml: ${nickname}` };
|
|
21
|
-
}
|
|
22
|
-
if (member.disabled) {
|
|
23
|
-
return { error: `--by agent is disabled in agent-members.yaml: ${nickname}` };
|
|
24
|
-
}
|
|
25
|
-
return { member };
|
|
26
|
-
}
|
|
27
|
-
export function resolveAgentCommand(execDefaults, member) {
|
|
28
|
-
let command;
|
|
29
|
-
try {
|
|
30
|
-
command = resolveMemberCommand(execDefaults, member);
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
return { error: error instanceof Error ? error.message : String(error) };
|
|
34
|
-
}
|
|
35
|
-
if (!command) {
|
|
36
|
-
return { error: `--by agent has no resolvable command: ${member.nickname}` };
|
|
37
|
-
}
|
|
38
|
-
return { command };
|
|
39
|
-
}
|
|
40
|
-
export function readAgentPlan(planPath) {
|
|
41
|
-
const absolutePath = resolve(planPath);
|
|
42
|
-
if (!existsSync(absolutePath)) {
|
|
43
|
-
throw new Error(`--plan not found: ${planPath}`);
|
|
44
|
-
}
|
|
45
|
-
const prompt = readFileSync(absolutePath, "utf8");
|
|
46
|
-
if (!prompt.trim()) {
|
|
47
|
-
throw new Error(`--plan is empty: ${planPath}`);
|
|
48
|
-
}
|
|
49
|
-
return prompt;
|
|
50
|
-
}
|
|
51
|
-
export function writeAgentOutput(outPath, stdout) {
|
|
52
|
-
const absolutePath = resolve(outPath);
|
|
53
|
-
mkdirSync(dirname(absolutePath), { recursive: true });
|
|
54
|
-
writeFileSync(absolutePath, stdout, "utf8");
|
|
55
|
-
return absolutePath;
|
|
56
|
-
}
|
|
57
|
-
export async function runAgentPlan(opts) {
|
|
58
|
-
const prompt = readAgentPlan(opts.planPath);
|
|
59
|
-
const paths = resolveProjectPaths({ project: opts.project });
|
|
60
|
-
const roster = loadRosterForExecutionPath(paths.executionPath);
|
|
61
|
-
const memberResult = resolveAgentMember(roster, opts.nickname);
|
|
62
|
-
if ("error" in memberResult)
|
|
63
|
-
throw new Error(memberResult.error);
|
|
64
|
-
const { member } = memberResult;
|
|
65
|
-
const execDefaults = loadExecDefaultsConfig(opts.execDefaultsPath ?? defaultExecDefaultsPath(), paths.executionPath);
|
|
66
|
-
const commandResult = resolveAgentCommand(execDefaults, member);
|
|
67
|
-
if ("error" in commandResult)
|
|
68
|
-
throw new Error(commandResult.error);
|
|
69
|
-
const { command } = commandResult;
|
|
70
|
-
if (opts.dryRun) {
|
|
71
|
-
process.stdout.write(`${command}\n`);
|
|
72
|
-
return { command, actor: member.nickname };
|
|
73
|
-
}
|
|
74
|
-
const execution = await executeAgent(command, prompt, resolveRateLimitDetection(execDefaults, member.provider), member.provider, resolveRateLimitPolicy(execDefaults, member.provider)?.cooldown_seconds, specdojoRootDir(), {
|
|
75
|
-
...gitEnvironment(),
|
|
76
|
-
SPECDOJO_SCHEDULE_PATH: paths.schedulePath,
|
|
77
|
-
SPECDOJO_EXECUTION_PATH: paths.executionPath,
|
|
78
|
-
}, opts.quiet);
|
|
79
|
-
return { execution, command, actor: member.nickname };
|
|
80
|
-
}
|
|
1
|
+
import { AGENT_RUN_RATE_LIMIT_EXIT_CODE, runAgentPlan, writeAgentOutput, } from "../exec/agent-plan.js";
|
|
2
|
+
export { AGENT_RUN_RATE_LIMIT_EXIT_CODE, resolveAgentMember, resolveAgentCommand, readAgentPlan, writeAgentOutput, runAgentPlan, } from "../exec/agent-plan.js";
|
|
81
3
|
export function registerAgentCommands(program) {
|
|
82
4
|
const agent = program.command("agent").description("Run a plan with a specific agent");
|
|
83
5
|
agent
|
|
@@ -3,7 +3,7 @@ import { isAbsolute, join, resolve } from "node:path";
|
|
|
3
3
|
import { listFilesRecursive, readYaml } from "./shared.js";
|
|
4
4
|
import { acquirePoolSlot, releaseLock } from "./slot-lock.js";
|
|
5
5
|
import { getProjectExecutionPath, loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
6
|
-
import { resolveParentValidationConcurrency, resolveParentValidationDefinitions, } from "./parent-validation.js";
|
|
6
|
+
import { resolveParentValidationConcurrency, resolveParentValidationAssignments, resolveParentValidationDefinitions, } from "./parent-validation.js";
|
|
7
7
|
const PLACEHOLDER_PATTERN = /\{([a-z][a-z0-9_]*)\}/g;
|
|
8
8
|
const BUILTIN_VARIABLE_NAMES = new Set(["nickname", "mode", "proficiency"]);
|
|
9
9
|
// Mirror of the nickname pattern in docs/specdojo/schemas/v1/agent-members.schema.yaml.
|
|
@@ -283,12 +283,12 @@ function loadLegacyRateLimitPolicy(executionPath) {
|
|
|
283
283
|
}
|
|
284
284
|
return undefined;
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function projectParentValidationOverrides(executionPath) {
|
|
287
287
|
if (!executionPath)
|
|
288
|
-
return
|
|
288
|
+
return {};
|
|
289
289
|
const { config } = loadConfig();
|
|
290
290
|
if (!config)
|
|
291
|
-
return
|
|
291
|
+
return {};
|
|
292
292
|
const rootDir = specdojoRootDir();
|
|
293
293
|
const targetExecutionPath = resolve(executionPath);
|
|
294
294
|
const normalizedTarget = targetExecutionPath.replaceAll("\\", "/");
|
|
@@ -303,16 +303,18 @@ function projectParentValidations(executionPath) {
|
|
|
303
303
|
normalizedTarget.endsWith(`/${normalizedConfigured.replace(/^\.\//, "")}`);
|
|
304
304
|
if (resolvedExecutionPath !== targetExecutionPath && !isProjectWorktreePath)
|
|
305
305
|
continue;
|
|
306
|
-
const
|
|
307
|
-
?.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
throw new Error(`Invalid .specdojo/specdojo.config.json: projects.${projectId}.run.parent_validations must be an array`);
|
|
306
|
+
for (const key of ["parent_validations", "parent_validations_exclude"]) {
|
|
307
|
+
const entries = project.run?.[key];
|
|
308
|
+
if (entries !== undefined && !Array.isArray(entries)) {
|
|
309
|
+
throw new Error(`Invalid .specdojo/specdojo.config.json: projects.${projectId}.run.${key} must be an array`);
|
|
310
|
+
}
|
|
312
311
|
}
|
|
313
|
-
return
|
|
312
|
+
return {
|
|
313
|
+
append: project.run?.parent_validations,
|
|
314
|
+
exclude: project.run?.parent_validations_exclude,
|
|
315
|
+
};
|
|
314
316
|
}
|
|
315
|
-
return
|
|
317
|
+
return {};
|
|
316
318
|
}
|
|
317
319
|
export function loadExecDefaultsConfig(configPath, executionPath) {
|
|
318
320
|
const path = configPath ?? defaultExecDefaultsPath();
|
|
@@ -331,15 +333,25 @@ export function loadExecDefaultsConfig(configPath, executionPath) {
|
|
|
331
333
|
if (legacyPolicy)
|
|
332
334
|
defaults.rate_limit_policy = legacyPolicy;
|
|
333
335
|
}
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
336
|
+
const overrides = projectParentValidationOverrides(executionPath);
|
|
337
|
+
if (overrides.exclude?.length || overrides.append?.length) {
|
|
338
|
+
const sharedEntries = defaults.pipeline?.parent_validations ?? [];
|
|
339
|
+
// Validate the shared list before filtering so an exclusion cannot hide invalid defaults.
|
|
340
|
+
const sharedAssignments = resolveParentValidationAssignments(sharedEntries);
|
|
341
|
+
const sharedLabels = new Set(sharedAssignments.map(({ label }) => label));
|
|
342
|
+
const excludedLabels = new Set(resolveParentValidationAssignments(overrides.exclude).map(({ label }) => label));
|
|
343
|
+
for (const label of excludedLabels) {
|
|
344
|
+
if (!sharedLabels.has(label)) {
|
|
345
|
+
throw new Error(`Invalid run.parent_validations_exclude: ${label} is not present in shared pipeline.parent_validations`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
336
348
|
defaults = {
|
|
337
349
|
...defaults,
|
|
338
350
|
pipeline: {
|
|
339
351
|
...defaults.pipeline,
|
|
340
352
|
parent_validations: [
|
|
341
|
-
...(
|
|
342
|
-
...
|
|
353
|
+
...sharedEntries.filter((_, index) => !excludedLabels.has(sharedAssignments[index].label)),
|
|
354
|
+
...(overrides.append ?? []),
|
|
343
355
|
],
|
|
344
356
|
},
|
|
345
357
|
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { defaultExecDefaultsPath, loadExecDefaultsConfig, resolveMemberCommand, resolveRateLimitDetection, resolveRateLimitPolicy, } from "./agent-config.js";
|
|
4
|
+
import { resolveProjectPaths } from "./project.js";
|
|
5
|
+
import { selectCandidates } from "./run/shared.js";
|
|
6
|
+
import { executeAgent, loadRosterForExecutionPath } from "./run/agent.js";
|
|
7
|
+
import { gitEnvironment } from "../shared/git-environment.js";
|
|
8
|
+
import { resolveAgentMember as resolveRosterAgentMember, specdojoRootDir, loadMemberRoster, getProjectExecutionPath, loadConfig, } from "../shared/specdojo-config.js";
|
|
9
|
+
// Rate limit は通常失敗と異なり、呼び出し側が処理済みにせず中断・再開する必要がある。
|
|
10
|
+
// shell script が出力文字列を解析せず分岐できるよう、一時失敗を表す専用コードにする。
|
|
11
|
+
export const AGENT_RUN_RATE_LIMIT_EXIT_CODE = 75;
|
|
12
|
+
/** Select a grading executor using the same roster eligibility and priority as exec. */
|
|
13
|
+
export function resolveGradingPlanActor(opts) {
|
|
14
|
+
const { config } = loadConfig();
|
|
15
|
+
const projectId = opts.project ?? config?.current_project ?? Object.keys(config?.projects ?? {})[0];
|
|
16
|
+
const project = projectId ? config?.projects[projectId] : undefined;
|
|
17
|
+
if (!project)
|
|
18
|
+
throw new Error(`Unknown project: ${projectId}`);
|
|
19
|
+
const roster = loadMemberRoster(specdojoRootDir(), project);
|
|
20
|
+
const defaults = loadExecDefaultsConfig(opts.execDefaultsPath ?? defaultExecDefaultsPath(), getProjectExecutionPath(project));
|
|
21
|
+
let nickname = opts.by;
|
|
22
|
+
if (!nickname) {
|
|
23
|
+
const candidates = selectCandidates({ capabilities: [], stage_role: "executor" }, roster, "review", undefined, defaults);
|
|
24
|
+
const legacy = selectCandidates({ capabilities: [] }, roster, "review", undefined, defaults);
|
|
25
|
+
nickname = (candidates[0] ?? legacy[0])?.nickname;
|
|
26
|
+
}
|
|
27
|
+
if (!nickname)
|
|
28
|
+
throw new Error("No runnable grading agent in agent-members.yaml; supply --by");
|
|
29
|
+
const found = resolveAgentMember(roster, nickname);
|
|
30
|
+
if ("error" in found)
|
|
31
|
+
throw new Error(found.error);
|
|
32
|
+
if (found.member.stage_role === "reporter" || found.member.mode === "report")
|
|
33
|
+
throw new Error(`Grading agent must be an executor: ${nickname}`);
|
|
34
|
+
const command = resolveAgentCommand(defaults, found.member);
|
|
35
|
+
if ("error" in command)
|
|
36
|
+
throw new Error(command.error);
|
|
37
|
+
return found.member.nickname;
|
|
38
|
+
}
|
|
39
|
+
export function resolveAgentMember(roster, nickname) {
|
|
40
|
+
const directMembers = roster?.members.filter((candidate) => {
|
|
41
|
+
return candidate.type === "agent" && candidate.nickname === nickname;
|
|
42
|
+
});
|
|
43
|
+
if (directMembers && directMembers.length > 1) {
|
|
44
|
+
return { error: `--by agent nickname is not unique in agent-members.yaml: ${nickname}` };
|
|
45
|
+
}
|
|
46
|
+
const member = resolveRosterAgentMember(roster, nickname);
|
|
47
|
+
if (!member) {
|
|
48
|
+
return { error: `--by agent nickname not found in agent-members.yaml: ${nickname}` };
|
|
49
|
+
}
|
|
50
|
+
if (member.disabled) {
|
|
51
|
+
return { error: `--by agent is disabled in agent-members.yaml: ${nickname}` };
|
|
52
|
+
}
|
|
53
|
+
return { member };
|
|
54
|
+
}
|
|
55
|
+
export function resolveAgentCommand(execDefaults, member) {
|
|
56
|
+
let command;
|
|
57
|
+
try {
|
|
58
|
+
command = resolveMemberCommand(execDefaults, member);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return { error: error instanceof Error ? error.message : String(error) };
|
|
62
|
+
}
|
|
63
|
+
if (!command) {
|
|
64
|
+
return { error: `--by agent has no resolvable command: ${member.nickname}` };
|
|
65
|
+
}
|
|
66
|
+
return { command };
|
|
67
|
+
}
|
|
68
|
+
export function readAgentPlan(planPath) {
|
|
69
|
+
const absolutePath = resolve(planPath);
|
|
70
|
+
if (!existsSync(absolutePath)) {
|
|
71
|
+
throw new Error(`--plan not found: ${planPath}`);
|
|
72
|
+
}
|
|
73
|
+
const prompt = readFileSync(absolutePath, "utf8");
|
|
74
|
+
if (!prompt.trim()) {
|
|
75
|
+
throw new Error(`--plan is empty: ${planPath}`);
|
|
76
|
+
}
|
|
77
|
+
return prompt;
|
|
78
|
+
}
|
|
79
|
+
export function writeAgentOutput(outPath, stdout) {
|
|
80
|
+
const absolutePath = resolve(outPath);
|
|
81
|
+
mkdirSync(dirname(absolutePath), { recursive: true });
|
|
82
|
+
writeFileSync(absolutePath, stdout, "utf8");
|
|
83
|
+
return absolutePath;
|
|
84
|
+
}
|
|
85
|
+
export async function runAgentPlan(opts) {
|
|
86
|
+
const prompt = readAgentPlan(opts.planPath);
|
|
87
|
+
const paths = resolveProjectPaths({ project: opts.project });
|
|
88
|
+
const roster = loadRosterForExecutionPath(paths.executionPath);
|
|
89
|
+
const memberResult = resolveAgentMember(roster, opts.nickname);
|
|
90
|
+
if ("error" in memberResult)
|
|
91
|
+
throw new Error(memberResult.error);
|
|
92
|
+
const { member } = memberResult;
|
|
93
|
+
const execDefaults = loadExecDefaultsConfig(opts.execDefaultsPath ?? defaultExecDefaultsPath(), paths.executionPath);
|
|
94
|
+
const commandResult = resolveAgentCommand(execDefaults, member);
|
|
95
|
+
if ("error" in commandResult)
|
|
96
|
+
throw new Error(commandResult.error);
|
|
97
|
+
const { command } = commandResult;
|
|
98
|
+
if (opts.dryRun) {
|
|
99
|
+
process.stdout.write(`${command}\n`);
|
|
100
|
+
return { command, actor: member.nickname };
|
|
101
|
+
}
|
|
102
|
+
const execution = await executeAgent(command, prompt, resolveRateLimitDetection(execDefaults, member.provider), member.provider, resolveRateLimitPolicy(execDefaults, member.provider)?.cooldown_seconds, specdojoRootDir(), {
|
|
103
|
+
...gitEnvironment(),
|
|
104
|
+
SPECDOJO_SCHEDULE_PATH: paths.schedulePath,
|
|
105
|
+
SPECDOJO_EXECUTION_PATH: paths.executionPath,
|
|
106
|
+
}, opts.quiet);
|
|
107
|
+
return { execution, command, actor: member.nickname };
|
|
108
|
+
}
|
package/dist/exec/commands.js
CHANGED
|
@@ -10,7 +10,7 @@ import { displayWidth, nowUtcIsoSeconds, padEndDisplay, requireNonEmpty } from "
|
|
|
10
10
|
import { archivePlan, buildInPlaceStem, generateDeliverablePlan, generateSinglePlan, resolveDeliverableTarget, stemFromPlanPath, } from "./plans.js";
|
|
11
11
|
import { runProviderScaffold, specdojoPackageRootDir } from "../shared/provider-scaffold.js";
|
|
12
12
|
import { generateRegisterPlan, normalizePjrId, resolveRegisterRunTarget } from "./register.js";
|
|
13
|
-
import { scaffoldViewpoints } from "../review/plan.js";
|
|
13
|
+
import { commonViewpointsPath, scaffoldViewpoints } from "../review/plan.js";
|
|
14
14
|
import { registerCycleCommand, registerResumeCommand, registerRunCommand, registerSlotsCommand, } from "./run/run.js";
|
|
15
15
|
import { buildTaskView } from "./task-view.js";
|
|
16
16
|
import { registerExecWorktreeCommands } from "./worktree-command.js";
|
|
@@ -466,7 +466,7 @@ export function registerExecCommands(program) {
|
|
|
466
466
|
if (!project)
|
|
467
467
|
throw new Error(`Unknown project: ${projectId}`);
|
|
468
468
|
const baseDir = specdojoRootDir();
|
|
469
|
-
const commonPath =
|
|
469
|
+
const commonPath = commonViewpointsPath();
|
|
470
470
|
const viewpointsRel = getProjectViewpointsPath(project);
|
|
471
471
|
if (viewpointsRel) {
|
|
472
472
|
const outputPath = pathResolve(baseDir, viewpointsRel);
|
|
@@ -484,7 +484,7 @@ export function registerExecCommands(program) {
|
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
else {
|
|
487
|
-
process.stdout.write(`viewpoints_path not set for project '${projectId}'
|
|
487
|
+
process.stdout.write(`viewpoints_path not set for project '${projectId}'; using specdojo:pm-review-viewpoints (${commonPath}).\n`);
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
490
|
catch (error) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { repoRelative, worktreeStatusPaths } from "../shared/git.js";
|
|
3
|
+
/** Include canonical grade sidecars, including deletions, in the execution checkpoint. */
|
|
4
|
+
export function gradeCheckpointPaths(context) {
|
|
5
|
+
const execution = repoRelative(context.repoRoot, context.executionPath);
|
|
6
|
+
return worktreeStatusPaths(context.repoRoot)
|
|
7
|
+
.filter((path) => isGradeCheckpointPath(path, execution))
|
|
8
|
+
.map((path) => resolve(context.repoRoot, path));
|
|
9
|
+
}
|
|
10
|
+
export function isGradeCheckpointPath(path, execution) {
|
|
11
|
+
return ["results", "criteria", "pipeline"].some((kind) => path.startsWith(`${execution}/grade/${kind}/`));
|
|
12
|
+
}
|
package/dist/exec/plans-core.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { deliverableDocId, loadPlanCatalogDocs as loadCatalogDocs, } from "../catalog/document-target.js";
|
|
2
|
+
export { deliverableDocId, resolveDeliverableByDocId, loadPlanCatalogDocs as loadCatalogDocs, } from "../catalog/document-target.js";
|
|
1
3
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
4
|
import { basename, join, relative, resolve } from "node:path";
|
|
3
5
|
import { load } from "../shared/yaml.js";
|
|
@@ -5,7 +7,7 @@ import { specdojoRootDir } from "../shared/specdojo-config.js";
|
|
|
5
7
|
import { kataDirsForKinds, resolveIncludedRulebooks, resolveKataRefs } from "../kata/kata.js";
|
|
6
8
|
import { resolveBasePath, resolveDeliverablePath } from "../catalog/paths.js";
|
|
7
9
|
import { isDctPlanFileName } from "../catalog/plan.js";
|
|
8
|
-
import { buildSpecdojoFrontmatter
|
|
10
|
+
import { buildSpecdojoFrontmatter } from "../docs/frontmatter-namespace.js";
|
|
9
11
|
import { qualifyPracticeId, SPECDOJO_PRACTICE_AUTHORITY } from "../shared/practice-id.js";
|
|
10
12
|
import { MISSING } from "../shared/plan-templates.js";
|
|
11
13
|
export { MISSING, execTemplatePath, execTemplatesDir, injectCommonConventions, loadPlanTemplate, } from "../shared/plan-templates.js";
|
|
@@ -84,28 +86,6 @@ export function findDeliverableInfo(catalogPath, localId) {
|
|
|
84
86
|
}
|
|
85
87
|
return null;
|
|
86
88
|
}
|
|
87
|
-
export function loadCatalogDocs(catalogPath) {
|
|
88
|
-
if (!catalogPath || !existsSync(catalogPath))
|
|
89
|
-
return [];
|
|
90
|
-
// Catalog scans walk subdirectories, so agent judgment plans (plans/dct-plan-*.yaml)
|
|
91
|
-
// must be excluded; they share the dct- prefix but carry no catalog structure.
|
|
92
|
-
const files = listFilesRecursive(catalogPath)
|
|
93
|
-
.filter((f) => {
|
|
94
|
-
const name = f.split("/").pop() ?? "";
|
|
95
|
-
return /^dct-.+\.ya?ml$/i.test(name) && !isDctPlanFileName(name);
|
|
96
|
-
})
|
|
97
|
-
.sort();
|
|
98
|
-
const docs = [];
|
|
99
|
-
for (const filePath of files) {
|
|
100
|
-
try {
|
|
101
|
-
docs.push(load(readFileSync(filePath, "utf8")));
|
|
102
|
-
}
|
|
103
|
-
catch {
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return docs;
|
|
108
|
-
}
|
|
109
89
|
function resolvedDeliverablesInCatalog(catalogPath) {
|
|
110
90
|
const deliverables = [];
|
|
111
91
|
const visit = (sections, parentBase, domain) => {
|
|
@@ -130,25 +110,6 @@ function resolvedDeliverablesInCatalog(catalogPath) {
|
|
|
130
110
|
}
|
|
131
111
|
return deliverables;
|
|
132
112
|
}
|
|
133
|
-
// Register targets use document IDs rather than schedule local_ids. Resolve the document ID
|
|
134
|
-
// back to its catalog entry so register-originated approach plans can share schedule rendering.
|
|
135
|
-
export function resolveDeliverableByDocId(catalogPath, projectId, targetId) {
|
|
136
|
-
const matches = resolvedDeliverablesInCatalog(catalogPath).filter((target) => {
|
|
137
|
-
const docId = deliverableDocId(projectId, target.info.deliverable.local_id, target.info.resolvedPath);
|
|
138
|
-
return (targetId === docId ||
|
|
139
|
-
targetId === target.localId ||
|
|
140
|
-
targetId === qualifiedDocId(projectId, target.localId));
|
|
141
|
-
});
|
|
142
|
-
if (matches.length === 0) {
|
|
143
|
-
throw new Error(`catalog deliverable target not found for document id: ${targetId}`);
|
|
144
|
-
}
|
|
145
|
-
if (matches.length > 1) {
|
|
146
|
-
throw new Error(`ambiguous catalog deliverable target for document id ${targetId}: ${matches
|
|
147
|
-
.map((match) => match.localId)
|
|
148
|
-
.join(", ")}`);
|
|
149
|
-
}
|
|
150
|
-
return matches[0];
|
|
151
|
-
}
|
|
152
113
|
/** Resolve a project-repository-relative file path to its catalog entry, if any. */
|
|
153
114
|
export function findDeliverableByPath(catalogPath, targetPath) {
|
|
154
115
|
const normalized = targetPath.replaceAll("\\", "/").replace(/^\/+/, "");
|
|
@@ -333,7 +294,7 @@ export function gradeResultRef(projectId, subjectPath) {
|
|
|
333
294
|
export function kataRefState(refPath) {
|
|
334
295
|
if (refPath === MISSING)
|
|
335
296
|
return "unresolved";
|
|
336
|
-
return existsSync(
|
|
297
|
+
return existsSync(resolve(specdojoRootDir(), refPath)) ? "existing" : "missing";
|
|
337
298
|
}
|
|
338
299
|
// 対象成果物の depends_on を、依存先 doc の [[id]] 参照の入れ子リストで提示する。
|
|
339
300
|
// id は依存先の frontmatter、未作成なら配置規約から解決する。agent へ plan を渡すときに
|
|
@@ -478,28 +439,6 @@ const TARGET_REF_KINDS = {
|
|
|
478
439
|
function qualifiedDocId(projectId, localId) {
|
|
479
440
|
return projectId ? `${projectId}:${localId}` : localId;
|
|
480
441
|
}
|
|
481
|
-
// 成果物の doc id は、既存文書では frontmatter を正本とする。author 前など文書が
|
|
482
|
-
// 未作成の場合は配置規約に従い、product 配下だけをローカル ID、projects 配下を含む
|
|
483
|
-
// その他の配置を従来どおり project 修飾 ID とする。
|
|
484
|
-
export function deliverableDocId(projectId, localId, resolvedPath) {
|
|
485
|
-
if (resolvedPath) {
|
|
486
|
-
const absolutePath = resolve(specdojoRootDir(), resolvedPath);
|
|
487
|
-
if (existsSync(absolutePath)) {
|
|
488
|
-
try {
|
|
489
|
-
const id = readSpecdojoNamespace(readFileSync(absolutePath, "utf8")).id;
|
|
490
|
-
if (typeof id === "string" && id.trim())
|
|
491
|
-
return id.trim();
|
|
492
|
-
}
|
|
493
|
-
catch {
|
|
494
|
-
// 読み取り不能・不正 frontmatter は配置によるフォールバックへ進む。
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
const normalizedPath = resolvedPath.replaceAll("\\", "/").replace(/^\/+/, "");
|
|
498
|
-
if (/^docs\/[a-z]{2}\/product(?:\/|$)/.test(normalizedPath))
|
|
499
|
-
return localId;
|
|
500
|
-
}
|
|
501
|
-
return qualifiedDocId(projectId, localId);
|
|
502
|
-
}
|
|
503
442
|
// タスクが対象とする文書の doc id リスト。先頭は対象成果物(配置に対応する doc id)、
|
|
504
443
|
// 以降は approach に応じて変更・確定しうる実践の型の doc id。いずれも doc-index で
|
|
505
444
|
// パスへ解決できる id にし、schedule やファイル名の命名規約に依存せず対象を機械的に
|
|
@@ -39,7 +39,9 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
39
39
|
_DELIVERABLE_DEPENDS_ON_: deliverableDependsOn(deliverable, projectId, catalogPath),
|
|
40
40
|
_PROJECT_CONTEXT_: projectContextSection(projectContext, deliverable, task.approach, projectId),
|
|
41
41
|
_DELIVERABLE_OVERVIEW_: deliverableOverview(deliverable),
|
|
42
|
-
_IMPLEMENTATION_EVIDENCE_:
|
|
42
|
+
_IMPLEMENTATION_EVIDENCE_: deliverable?.catalogless
|
|
43
|
+
? "個票に指定された実装のパスを読み取り専用の調査入力とする。パスが未指定なら実装反映の前に個票へ明記する。"
|
|
44
|
+
: implementationEvidence(deliverable),
|
|
43
45
|
_DELIVERABLE_PATH_: deliverablePath(deliverable),
|
|
44
46
|
_RESULT_REF_: resultRef,
|
|
45
47
|
_RULEBOOK_REF_: refs.rulebook,
|
|
@@ -54,7 +56,9 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
54
56
|
_OWNER_ROLE_LABEL_: ownerRole.label,
|
|
55
57
|
_OWNER_ROLE_NOTE_: ownerRole.note,
|
|
56
58
|
_OWNER_ROLE_VIEWPOINTS_: ownerRole.viewpoints,
|
|
57
|
-
_DONE_CRITERIA_GOALS_:
|
|
59
|
+
_DONE_CRITERIA_GOALS_: deliverable?.catalogless
|
|
60
|
+
? "カタログの `done_criteria` はない。個票の完了条件と rulebook を完了基準とする。"
|
|
61
|
+
: doneCriteriaGoals(criteria, task.owner),
|
|
58
62
|
_DONE_CRITERIA_CHECKLIST_: doneCriteriaChecklist(criteria),
|
|
59
63
|
_DONE_CRITERIA_ITEMS_: doneCriteriaItems(criteria),
|
|
60
64
|
_GRADE_FINDINGS_: gradeFindingsText(projectId, gradeFindingTargetPath(task.approach, deliverable, refs)),
|
|
@@ -68,13 +72,24 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
|
|
|
68
72
|
.map((example) => `- \`${example.id}\`: ${example.name}(\`${example.path}\`、${example.catalog ? "現在の参照" : "参照更新"}: \`${example.currentReference}\`)`)
|
|
69
73
|
.join("\n") || "- なし(kata だけを新規作成する)",
|
|
70
74
|
};
|
|
71
|
-
const
|
|
75
|
+
const effectiveTemplate = deliverable?.catalogless
|
|
76
|
+
? template
|
|
77
|
+
.split("\n")
|
|
78
|
+
.filter((line) => !["recipe", "sample", "template"].some((kind) => refs[kind] === MISSING && line.includes(`_${kind.toUpperCase()}_REF_`)))
|
|
79
|
+
.join("\n")
|
|
80
|
+
: template;
|
|
81
|
+
let body = expandTemplate(effectiveTemplate, values);
|
|
82
|
+
if (deliverable?.catalogless && task.approach === "retrofit") {
|
|
83
|
+
body = body.replace("成果物カタログの `evidence_refs` から展開した", "個票に明記する");
|
|
84
|
+
}
|
|
72
85
|
if (!planOverrides?.additionalConditions)
|
|
73
86
|
return body;
|
|
74
87
|
const section = [
|
|
75
88
|
"## 個票の追加完了条件",
|
|
76
89
|
"",
|
|
77
|
-
|
|
90
|
+
deliverable?.catalogless
|
|
91
|
+
? "個票が定める次の条件と rulebook を満たす。"
|
|
92
|
+
: "成果物カタログの `done_criteria` に加え、登録簿の個票が定める次の条件も満たす。",
|
|
78
93
|
"",
|
|
79
94
|
planOverrides.additionalConditions.trim(),
|
|
80
95
|
"",
|
|
@@ -158,7 +173,9 @@ async function writeTaskPlan(ctx, task, override) {
|
|
|
158
173
|
throw new Error(`Task ${task.id} has execution: human; claim it to create and use its result instead of a plan.`);
|
|
159
174
|
}
|
|
160
175
|
const planTask = { ...task, mode };
|
|
161
|
-
if (task.approach === "retrofit" &&
|
|
176
|
+
if (task.approach === "retrofit" &&
|
|
177
|
+
!deliverable?.catalogless &&
|
|
178
|
+
implementationEvidence(deliverable) === MISSING) {
|
|
162
179
|
throw new Error(`Task ${task.id} uses approach: retrofit but the target deliverable has no evidence_refs.`);
|
|
163
180
|
}
|
|
164
181
|
const template = loadPlanTemplate(mode, task.approach, ctx.templateCache);
|
package/dist/exec/project.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { join, resolve } from "node:path";
|
|
2
2
|
import { getProjectCatalogPath, getProjectContext, getProjectExecutionPath, getProjectRolesPath, getProjectSchedulePath, getProjectViewpointsPath, loadConfig, loadEnv, specdojoRootDir, } from "../shared/specdojo-config.js";
|
|
3
|
+
import { commonViewpointsPath } from "../review/plan.js";
|
|
3
4
|
function projectBaseDir() {
|
|
4
5
|
return specdojoRootDir();
|
|
5
6
|
}
|
|
@@ -65,7 +66,9 @@ export function resolveProjectPaths(opts) {
|
|
|
65
66
|
executionPath: resolveProjectRelative(baseDir, getProjectExecutionPath(project)),
|
|
66
67
|
catalogPath: catalogPath ? resolveProjectRelative(baseDir, catalogPath) : undefined,
|
|
67
68
|
rolesPath: rolesPath ? resolveProjectRelative(baseDir, rolesPath) : undefined,
|
|
68
|
-
viewpointsPath: viewpointsPath
|
|
69
|
+
viewpointsPath: viewpointsPath
|
|
70
|
+
? resolveProjectRelative(baseDir, viewpointsPath)
|
|
71
|
+
: commonViewpointsPath(),
|
|
69
72
|
projectContext: getProjectContext(project),
|
|
70
73
|
};
|
|
71
74
|
}
|