specdojo 0.4.3 → 0.4.5

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.
Files changed (49) hide show
  1. package/.github/agents/specdojo-orchestrator.md +2 -0
  2. package/CHANGELOG.md +18 -0
  3. package/dist/catalog/build.js +8 -6
  4. package/dist/docs/doc-index.js +11 -0
  5. package/dist/exec/plans-core.js +11 -0
  6. package/dist/exec/plans-generation.js +1 -1
  7. package/dist/exec/register.js +47 -14
  8. package/dist/exec/run/in-place.js +7 -4
  9. package/dist/exec/run/register-core.js +10 -2
  10. package/dist/exec/run/register-worktree.js +4 -1
  11. package/dist/exec/task-repos.js +11 -0
  12. package/dist/kata/authoring.js +60 -14
  13. package/dist/kata/command.js +40 -28
  14. package/dist/kata/kata.js +26 -12
  15. package/dist/register/approach.js +13 -12
  16. package/dist/register/authoring-sources.js +132 -0
  17. package/dist/register/core.js +4 -3
  18. package/dist/register/create-commands.js +77 -10
  19. package/dist/register/events.js +2 -0
  20. package/dist/register/external-project.js +11 -1
  21. package/dist/register/item.js +37 -5
  22. package/dist/register/renumber.js +3 -3
  23. package/dist/shared/text.js +3 -1
  24. package/docs/ja/specdojo/exec-templates/xep-recipe-authoring-template.md +7 -7
  25. package/docs/ja/specdojo/exec-templates/xep-rulebook-authoring-template.md +7 -7
  26. package/docs/ja/specdojo/exec-templates/xep-sample-authoring-template.md +7 -7
  27. package/docs/ja/specdojo/exec-templates/xep-template-authoring-template.md +7 -7
  28. package/docs/ja/specdojo/guides/docs-structure-guide.md +1 -1
  29. package/docs/ja/specdojo/guides/kata-guide.md +6 -2
  30. package/docs/ja/specdojo/guides/practice-system-composition-guide.md +4 -0
  31. package/docs/ja/specdojo/guides/quick-start-guide.md +5 -3
  32. package/docs/ja/specdojo/references/command-reference.md +30 -25
  33. package/docs/ja/specdojo/references/specdojo-config-reference.md +1 -1
  34. package/docs/ja/specdojo/rulebooks/dct-rulebook.md +2 -1
  35. package/docs/ja/specdojo/standards/id-and-file-naming-standard.md +4 -0
  36. package/docs/ja/specdojo/standards/recipe-authoring-standard.md +3 -3
  37. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +2 -2
  38. package/docs/ja/specdojo/standards/sample-authoring-standard.md +4 -4
  39. package/docs/ja/specdojo/standards/template-authoring-standard.md +3 -3
  40. package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +4 -3
  41. package/docs/specdojo/schemas/v1/exec-result-frontmatter.schema.yaml +3 -3
  42. package/docs/specdojo/schemas/v1/register-events.schema.yaml +1 -0
  43. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +31 -3
  44. package/package.json +12 -11
  45. package/templates/antigravity/orchestrator.md +2 -0
  46. package/templates/claude/agents/specdojo-orchestrator.md +2 -0
  47. package/templates/codex/agents/specdojo-orchestrator.toml +2 -0
  48. package/templates/codex/orchestrator.md +2 -0
  49. package/templates/opencode/agents/specdojo-orchestrator.md +2 -0
@@ -10,6 +10,8 @@ model: claude-sonnet-4.6
10
10
 
11
11
  あなたは SpecDojo の対話型オーケストレーターです。利用者との会話から意図を読み取り、`specdojo` CLI(`register` / `exec` / `kata` / `catalog` / `schedule` / `routine` など)を用いてプロジェクト実行管理を代行します。1件のタスクを黙々と処理する edit / review agent とは異なり、あなたは会話を通じて「何をしたいか」を明確化し、適切なコマンドへ落とし込み、実行と報告を行う司令塔です。
12
12
 
13
+ この文書そのものがオーケストレーターへの指示の全体である。同じ名前の Skill(`SKILL.md`)や agent の定義のファイルを別に探して読まない。
14
+
13
15
  CLI は利用リポジトリへローカル導入されるため、`npx specdojo <command>` で起動する。`node_modules/.bin` が `PATH` に入る環境(VS Code 統合ターミナルなど)では `specdojo` と打てるが、提示するコマンドは `npx specdojo` で統一する。
14
16
 
15
17
  ## 基本方針
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  SpecDojo の利用者に影響する変更を記録します。
4
4
 
5
+ ## [0.4.5] - 2026-10-24
6
+
7
+ ### 追加機能
8
+
9
+ - kata authoring の手本を `register add` / `register update` の繰り返し可能な `--source` で指定できるようにしました。文書索引の doc id、プロジェクトリポジトリのファイル・ディレクトリ・glob、`repos` で宣言したプロダクトリポジトリの `<repo>:<path>` を使え、カタログがない project でも authoring plan を生成できます(PJR-ZV60)。
10
+
11
+ ## [0.4.4] - 2026-10-24
12
+
13
+ ### 変更
14
+
15
+ - 利用者が作る kata の配置を `docs/ja/kata/<種類>s/` から `docs/ja/specdojo/<種類>s/<kata_authority>/` へ変更しました。0.4.4 のあいだは旧配置も警告付きで読み、新旧に同じ ID がある場合は新配置を優先します(PJR-EKRW)。
16
+
17
+ ### 不具合修正
18
+
19
+ - `init --catalog small` が生成する、成果物がまだない領域の空の `groups` を `catalog build`・`catalog validate`・`specdojo build` が受理するようにしました。`groups` の省略や配列以外の値は引き続きエラーにします(PJR-C95G)。
20
+ - `register build` が生成する登録簿一覧・派生ビュー・PM ログで、自由記述セルの素の HTTP(S) URL を autolink にするようにしました。全角の括弧や句読点、半角の閉じ括弧は URL の外へ残し、既存の autolink・Markdown link・コードスパンは保持するため、markdownlint(MD034)で止まりません(PJR-4J4A)。
21
+ - 同梱のオーケストレーターの本文の冒頭に、この文書そのものが指示の全体であり、同じ名前の Skill や agent の定義のファイルを別に探さないことを加えました。codex で起動したときに、存在しない `SKILL.md` を読もうとして警告が出ていました(PJR-YYSD)。
22
+
5
23
  ## [0.4.3] - 2026-10-23
6
24
 
7
25
  ### 追加機能
@@ -417,9 +417,13 @@ export function validateDctDoc(doc, filePath, knownLocalIds, repoRoot) {
417
417
  errors.push(`${filePath}: missing required field: project_id`);
418
418
  if (!doc.domain)
419
419
  errors.push(`${filePath}: missing required field: domain`);
420
- if (!doc.groups || !Array.isArray(doc.groups) || doc.groups.length === 0) {
421
- errors.push(`${filePath}: groups must be a non-empty array`);
420
+ if (!Object.hasOwn(doc, "groups")) {
421
+ errors.push(`${filePath}: missing required field: groups`);
422
+ }
423
+ else if (!Array.isArray(doc.groups)) {
424
+ errors.push(`${filePath}: groups must be an array`);
422
425
  }
426
+ const groups = Array.isArray(doc.groups) ? doc.groups : [];
423
427
  const localIds = new Set();
424
428
  function collectIds(sections) {
425
429
  for (const section of sections) {
@@ -515,8 +519,7 @@ export function validateDctDoc(doc, filePath, knownLocalIds, repoRoot) {
515
519
  collectIds(section.groups);
516
520
  }
517
521
  }
518
- if (doc.groups)
519
- collectIds(doc.groups);
522
+ collectIds(groups);
520
523
  const depLookup = knownLocalIds ?? localIds;
521
524
  const depScope = knownLocalIds ? "catalog" : "this file";
522
525
  function checkDeps(sections) {
@@ -536,8 +539,7 @@ export function validateDctDoc(doc, filePath, knownLocalIds, repoRoot) {
536
539
  checkDeps(section.groups);
537
540
  }
538
541
  }
539
- if (doc.groups)
540
- checkDeps(doc.groups);
542
+ checkDeps(groups);
541
543
  return { ok: errors.length === 0, errors, warnings };
542
544
  }
543
545
  export { collectResolvedDeliverables, validateBasedOn };
@@ -3,6 +3,7 @@ import { dirname, join, relative, resolve } from "node:path";
3
3
  import { load } from "../shared/yaml.js";
4
4
  import { readSpecdojoNamespace } from "./frontmatter-namespace.js";
5
5
  import { specdojoDirectoryPaths, specdojoReferencePath, } from "./template-resolution.js";
6
+ import { parsePracticeId } from "../shared/practice-id.js";
6
7
  const SKIP_DIRS = new Set(["node_modules", "dist", ".vitepress", "out"]);
7
8
  const FILE_RE = /\.(md|yaml|yml)$/;
8
9
  const DOC_ID_RE = /^[a-z][a-z0-9:_-]+$/;
@@ -335,6 +336,16 @@ export function collectDocIndex(rootDir, repoRoot, configPath, options = {}) {
335
336
  }
336
337
  }
337
338
  }
339
+ for (const id of packageCollector.keys()) {
340
+ try {
341
+ const authority = parsePracticeId(id).authority;
342
+ if (authority && authority !== "specdojo")
343
+ packageCollector.delete(id);
344
+ }
345
+ catch {
346
+ packageCollector.delete(id);
347
+ }
348
+ }
338
349
  assertNoDuplicateIds(packageCollector);
339
350
  // 同一 ID が両スコープにある場合は eject 済みの利用リポジトリ側を採用する。
340
351
  // 走査順ではなくスコープで優先順位を決めるため、結果は決定的になる。
@@ -149,6 +149,17 @@ export function resolveDeliverableByDocId(catalogPath, projectId, targetId) {
149
149
  }
150
150
  return matches[0];
151
151
  }
152
+ /** Resolve a project-repository-relative file path to its catalog entry, if any. */
153
+ export function findDeliverableByPath(catalogPath, targetPath) {
154
+ const normalized = targetPath.replaceAll("\\", "/").replace(/^\/+/, "");
155
+ const matches = resolvedDeliverablesInCatalog(catalogPath).filter((target) => target.info.resolvedPath.replaceAll("\\", "/").replace(/^\/+/, "") === normalized);
156
+ if (matches.length > 1) {
157
+ throw new Error(`ambiguous catalog deliverable target for path ${targetPath}: ${matches
158
+ .map((match) => match.localId)
159
+ .join(", ")}`);
160
+ }
161
+ return matches[0] ?? null;
162
+ }
152
163
  // A kata may be declared by zero, one, or several deliverables. Only a unique declaration is
153
164
  // used as the maintenance plan's evidence context; otherwise the explicitly targeted kata remains
154
165
  // executable without selecting an arbitrary deliverable.
@@ -65,7 +65,7 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
65
65
  _AUTHORING_STANDARD_ID_: planOverrides?.authoring?.standardId ?? MISSING,
66
66
  _AUTHORING_STANDARD_PATH_: planOverrides?.authoring?.standardPath ?? MISSING,
67
67
  _AUTHORING_EXEMPLARS_: planOverrides?.authoring?.exemplars
68
- .map((example) => `- \`${example.id}\`: ${example.name}(\`${example.path}\`、現在の参照: \`${example.currentReference}\`)`)
68
+ .map((example) => `- \`${example.id}\`: ${example.name}(\`${example.path}\`、${example.catalog ? "現在の参照" : "参照更新"}: \`${example.currentReference}\`)`)
69
69
  .join("\n") || "- なし(kata だけを新規作成する)",
70
70
  };
71
71
  const body = expandTemplate(template, values);
@@ -1,9 +1,9 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
- import { extname, join, relative, resolve } from "node:path";
2
+ import { basename, extname, join, relative, resolve } from "node:path";
3
3
  import { findRegisterItem, loadRegisterItems, PJR_ID_RE, resolveRegisterPaths, TERMINAL_STATUSES_SET, VALID_PRIORITIES, VALID_STATUSES, VALID_TYPES, } from "../register/register.js";
4
4
  import { execTemplatePath, injectCommonConventions, MISSING, registerGradeFindingsText, } from "./plans.js";
5
5
  import { generateRegisterApproachPlan } from "./plans-generation.js";
6
- import { findUniqueDeliverableForKataTarget, resolveDeliverableByDocId, } from "./plans-core.js";
6
+ import { findUniqueDeliverableForKataTarget, findDeliverableByPath, resolveDeliverableByDocId, } from "./plans-core.js";
7
7
  import { collectDocIndexEntries } from "../docs/doc-index.js";
8
8
  import { loadRulebookRefs, resolveKataRefs } from "../kata/kata.js";
9
9
  import { authoredKataPath, authoringKind, authoringStandardId, authoringStandardPath, } from "../kata/authoring.js";
@@ -11,7 +11,9 @@ import { validateRegisterApproachTargets } from "../register/approach.js";
11
11
  import { buildSpecdojoFrontmatter } from "../docs/frontmatter-namespace.js";
12
12
  import { escapeMarkdownInline, expandTemplate, inlineCodeAnglePlaceholders, stripTerminalControlSequences, } from "./shared.js";
13
13
  import { formatMarkdownFile } from "./format.js";
14
- import { specdojoRootDir } from "../shared/specdojo-config.js";
14
+ import { loadConfig, specdojoRootDir } from "../shared/specdojo-config.js";
15
+ import { resolveAuthoringSources, } from "../register/authoring-sources.js";
16
+ import { repoEnvironmentVariableName } from "./task-repos.js";
15
17
  const EDIT_TYPES = new Set(["todo", "issue", "change-request"]);
16
18
  const INVESTIGATE_TYPES = new Set(["question", "risk"]);
17
19
  export function registerItemCategory(itemType) {
@@ -302,6 +304,26 @@ function indexedDocumentPath(targetId) {
302
304
  const withoutLine = indexed.replace(/:\d+$/, "");
303
305
  return relative(repoRoot, resolve(repoRoot, withoutLine)).replace(/\\/g, "/");
304
306
  }
307
+ function authoringSourcePlanPath(source) {
308
+ return source.repo ? `$${repoEnvironmentVariableName(source.repo)}/${source.path}` : source.path;
309
+ }
310
+ function catalogSource(catalogPath, projectId, source) {
311
+ if (!catalogPath || source.repo)
312
+ return null;
313
+ if (source.documentId) {
314
+ try {
315
+ return resolveDeliverableByDocId(catalogPath, projectId, source.documentId);
316
+ }
317
+ catch (error) {
318
+ if (error instanceof Error &&
319
+ error.message.startsWith("catalog deliverable target not found")) {
320
+ return null;
321
+ }
322
+ throw error;
323
+ }
324
+ }
325
+ return findDeliverableByPath(catalogPath, source.path);
326
+ }
305
327
  export async function generateRegisterPlan(opts) {
306
328
  const { item } = opts;
307
329
  const category = requireRunnableRegisterItem(item);
@@ -313,6 +335,7 @@ export async function generateRegisterPlan(opts) {
313
335
  ...(opts.catalogPath ? { catalogPath: opts.catalogPath } : {}),
314
336
  approach: item.approach,
315
337
  targets: item.targets,
338
+ sources: item.sources,
316
339
  });
317
340
  const [targetId] = item.targets ?? [];
318
341
  if (!targetId)
@@ -323,14 +346,22 @@ export async function generateRegisterPlan(opts) {
323
346
  let refs;
324
347
  let authoring;
325
348
  if (newKataKind) {
326
- const examples = (item.targets ?? []).slice(1).map((exampleId) => {
327
- if (!opts.catalogPath) {
328
- throw new Error(`Register item ${item.id} approach requires catalog_path to resolve ${exampleId}.`);
329
- }
330
- const resolved = resolveDeliverableByDocId(opts.catalogPath, opts.projectId, exampleId).info;
331
- const rulebookId = resolved.deliverable.rulebook;
349
+ const sourceRefs = [...(item.targets ?? []).slice(1), ...(item.sources ?? [])];
350
+ const project = loadConfig(specdojoRootDir()).config?.projects[opts.projectId] ?? {};
351
+ const resolvedSources = resolveAuthoringSources({
352
+ repoRoot: specdojoRootDir(),
353
+ project,
354
+ sources: sourceRefs,
355
+ });
356
+ const examples = resolvedSources.map((source) => {
357
+ const catalogEntry = catalogSource(opts.catalogPath, opts.projectId, source);
358
+ const resolved = catalogEntry?.info;
359
+ const rulebookId = resolved?.deliverable.rulebook;
332
360
  let currentReference;
333
- if (newKataKind === "rulebook") {
361
+ if (!resolved) {
362
+ currentReference = "カタログ外のため参照の付け替え対象外";
363
+ }
364
+ else if (newKataKind === "rulebook") {
334
365
  currentReference = rulebookId ?? "未記入";
335
366
  }
336
367
  else if (!rulebookId ||
@@ -345,11 +376,13 @@ export async function generateRegisterPlan(opts) {
345
376
  ? declaredReference.join(", ")
346
377
  : (declaredReference ?? "未記入");
347
378
  }
379
+ const planPath = authoringSourcePlanPath(source);
348
380
  return {
349
- id: exampleId,
350
- name: resolved.deliverable.name,
351
- path: resolved.resolvedPath,
381
+ id: source.documentId ?? (source.repo ? `${source.repo}:${source.path}` : source.path),
382
+ name: resolved?.deliverable.name ?? basename(source.path),
383
+ path: planPath,
352
384
  currentReference,
385
+ catalog: resolved !== undefined,
353
386
  };
354
387
  });
355
388
  const exemplarExtension = extname(examples[0]?.path ?? "").slice(1);
@@ -396,7 +429,7 @@ export async function generateRegisterPlan(opts) {
396
429
  description: item.description,
397
430
  ...(item.owner && item.owner !== "-" && item.owner !== "_TODO_" ? { owner: item.owner } : {}),
398
431
  approach: item.approach,
399
- targets: item.targets ?? [],
432
+ targets: targetId ? [targetId] : [],
400
433
  deliverable,
401
434
  ...(refs ? { refs } : {}),
402
435
  ...(authoring ? { authoring } : {}),
@@ -20,6 +20,7 @@ import { pinnedExecutor, pinnedReporter, resolvePinnedRateLimitRunOptions, resol
20
20
  import { appendParentValidationsToExecutorEvidence, buildExecutorPrompt, executorRequirements, expandPromptRefs, extractBlockReason, loadRosterForExecutionPath, reportProtectionHandoffRecord, resolveReporterAgentCandidates, runWithRetry, } from "./agent.js";
21
21
  import { gradeBeforeReviewPlan } from "./schedule-prepare.js";
22
22
  import { pipelineRecoveryMeta, spawnBlock, spawnClaim, spawnComplete } from "./mode-shared.js";
23
+ import { configuredProductCheckouts, productRepoEnvironment, withoutInheritedRepoEnvironment, withAgentExtraRoots, } from "../task-repos.js";
23
24
  // Resolve the agent command and the actor for an in-place run, ignoring task state. Unlike the
24
25
  // worktree flow, this never requires the task to be claimable. The actor is derived the same way
25
26
  // as the worktree path (`prepareTask`): explicit --by wins, otherwise the resolved member's
@@ -102,15 +103,17 @@ export function resolveInPlaceAgentPipeline(task, roster, opts, source) {
102
103
  }
103
104
  return undefined;
104
105
  }
105
- export async function spawnAgentInPlace(command, prompt, cwd, schedulePath, executionPath, resultPath) {
106
+ export async function spawnAgentInPlace(command, prompt, cwd, schedulePath, executionPath, resultPath, provider) {
106
107
  const protectedConfigBefore = captureAgentProtectedConfigSnapshot(cwd);
107
108
  const gitStateBefore = captureAgentGitStateSnapshot(cwd);
108
- const child = spawn(command, {
109
+ const products = configuredProductCheckouts(schedulePath);
110
+ const child = spawn(withAgentExtraRoots(command, provider, products.map((product) => product.path)), {
109
111
  cwd,
110
112
  env: {
111
- ...gitEnvironment(),
113
+ ...withoutInheritedRepoEnvironment(gitEnvironment()),
112
114
  SPECDOJO_SCHEDULE_PATH: schedulePath,
113
115
  SPECDOJO_EXECUTION_PATH: executionPath,
116
+ ...productRepoEnvironment(cwd, products),
114
117
  },
115
118
  shell: true,
116
119
  stdio: ["pipe", "inherit", "inherit"],
@@ -518,7 +521,7 @@ export async function runInPlaceMode(opts) {
518
521
  }
519
522
  }
520
523
  else {
521
- exitCode = await spawnAgentInPlace(command, prompt, repoRoot, schedulePath, executionPath, resultPath);
524
+ exitCode = await spawnAgentInPlace(command, prompt, repoRoot, schedulePath, executionPath, resultPath, provider);
522
525
  }
523
526
  // Some agents (notably `claude -p`) exit 0 even when they conclude they are blocked: a
524
527
  // permission-denied tool call is fed back as a tool error and the model ends its turn
@@ -14,6 +14,8 @@ import { expandPromptRefs } from "./agent.js";
14
14
  import { runAgentPipeline } from "./agent-pipeline.js";
15
15
  import { spawnAgentInPlace } from "./in-place.js";
16
16
  import { commitSubject, repoRelativePath, spawnSelf } from "./mode-shared.js";
17
+ import { isAuthoringApproach } from "../../kata/authoring.js";
18
+ import { configuredProductCheckouts } from "../task-repos.js";
17
19
  // CLI choices are the highest-priority layer. A difficulty route only supplies omitted stage and
18
20
  // recovery options; without a matching route the historical priority-based selection is kept.
19
21
  export function applyRegisterDifficultyRouting(item, opts, execDefaults) {
@@ -254,6 +256,9 @@ export async function runSingleRegisterItem(context, opts, pjrId) {
254
256
  const { command, actor } = pipelineAgents
255
257
  ? { command: pipelineAgents.executor.command, actor: pipelineAgents.executor.actor }
256
258
  : resolveRegisterCommand(item, context.roster, opts, context.execDefaults);
259
+ const resolvedProvider = pipelineAgents
260
+ ? pipelineAgents.executor.provider
261
+ : resolveAgentMember(context.roster, actor)?.provider;
257
262
  const stem = buildInPlaceStem(pjrId.toLowerCase());
258
263
  // ID単位 commit のため、この項目が変更を生じる前の作業ツリー状態を記録する。
259
264
  const preexisting = context.registerCommit ? worktreeStatusPaths(repoRoot) : [];
@@ -285,7 +290,9 @@ export async function runSingleRegisterItem(context, opts, pjrId) {
285
290
  startedAt: new Date().toISOString(),
286
291
  stem,
287
292
  ...(item.approach ? { approach: item.approach } : {}),
288
- ...(item.targets && item.targets.length > 0 ? { targets: item.targets } : {}),
293
+ ...(item.targets && item.targets.length > 0
294
+ ? { targets: isAuthoringApproach(item.approach) ? item.targets.slice(0, 1) : item.targets }
295
+ : {}),
289
296
  });
290
297
  const resultScaffold = readResultFrontmatterSnapshot(resultPath);
291
298
  process.stdout.write(`Register item: ${item.id} — ${item.title} [${item.type}]\n`);
@@ -314,6 +321,7 @@ export async function runSingleRegisterItem(context, opts, pjrId) {
314
321
  resultPath,
315
322
  registerPaths: registerReporterManagedPaths(registerPaths),
316
323
  execDefaults: context.execDefaults,
324
+ productWorktrees: configuredProductCheckouts(schedulePath),
317
325
  providerConcurrencyGate: context.providerConcurrencyGate,
318
326
  executorRateLimitOptions: opts.executorBy
319
327
  ? resolvePinnedRateLimitRunOptions(opts, context.execDefaults, context.roster, "executor", pipelineAgents.executor)
@@ -331,7 +339,7 @@ export async function runSingleRegisterItem(context, opts, pjrId) {
331
339
  }
332
340
  else {
333
341
  process.stdout.write(`Running ${item.id} in place: ${command}\n`);
334
- exitCode = await spawnAgentInPlace(command, prompt, repoRoot, schedulePath, executionPath, resultPath);
342
+ exitCode = await spawnAgentInPlace(command, prompt, repoRoot, schedulePath, executionPath, resultPath, resolvedProvider);
335
343
  }
336
344
  // in-place 実行と同じ補助判定: agent が result 必須節を埋めずに終了コード 0 で
337
345
  // 終わった場合は block として扱う(runInPlaceMode と同じ理由)。pipeline モードでは
@@ -12,6 +12,7 @@ import { commitProductWorktrees, integrateTaskRepositories, projectMergeBlockers
12
12
  import { productIntegrationTrace, recordResultTrace, refsTrailer, registerProjectMergeMessage, traceKey, withCommitTrailers, } from "../repo-trace.js";
13
13
  import { pipelineStateLocation, readPipelineState } from "../pipeline-state.js";
14
14
  import { findResumableRegisterRun } from "../register-resume.js";
15
+ import { isAuthoringApproach } from "../../kata/authoring.js";
15
16
  import { resolvePinnedRateLimitRunOptions, rateLimitRecoveryReason, } from "./shared.js";
16
17
  import { agentEnvironment, expandPromptRefs, extractBlockReason, pathInsideWorktree, reportProductWorktrees, runWithRetry, } from "./agent.js";
17
18
  import { runAgentPipeline } from "./agent-pipeline.js";
@@ -464,7 +465,9 @@ export async function runSingleRegisterItemWorktree(context, opts, pjrId, lifecy
464
465
  startedAt: new Date().toISOString(),
465
466
  stem,
466
467
  ...(item.approach ? { approach: item.approach } : {}),
467
- ...(item.targets && item.targets.length > 0 ? { targets: item.targets } : {}),
468
+ ...(item.targets && item.targets.length > 0
469
+ ? { targets: isAuthoringApproach(item.approach) ? item.targets.slice(0, 1) : item.targets }
470
+ : {}),
468
471
  });
469
472
  const resultScaffold = readResultFrontmatterSnapshot(resultPath);
470
473
  process.stdout.write(`Register item: ${item.id} — ${item.title} [${item.type}]\n`);
@@ -92,6 +92,17 @@ export function configuredProductRepos(schedulePath, integrationBranches) {
92
92
  }
93
93
  return [];
94
94
  }
95
+ /** Declared product repositories represented as their current in-place checkouts. */
96
+ export function configuredProductCheckouts(schedulePath) {
97
+ return configuredProductRepos(schedulePath).map((product) => ({
98
+ name: product.name,
99
+ repoRoot: product.repoRoot,
100
+ path: product.repoRoot,
101
+ branch: productIntegrationTarget(product),
102
+ created: false,
103
+ ...(product.integrationBranch ? { integrationBranch: product.integrationBranch } : {}),
104
+ }));
105
+ }
95
106
  /**
96
107
  * Run-scoped `--integration-branch` values recorded in the run checkpoint (`integration_branches`).
97
108
  * Only explicit overrides are recorded, so a run without the option keeps resolving its targets
@@ -1,11 +1,12 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
- import { extname, join, resolve } from "node:path";
2
+ import { extname, resolve } from "node:path";
3
3
  import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
4
4
  import { getKataAuthority, isSpecdojoSourceRepository, loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
5
5
  import { parsePracticeId, practiceLocalId } from "../shared/practice-id.js";
6
6
  import { load } from "../shared/yaml.js";
7
7
  import { resolveSpecdojoReferencePathIfExists } from "../docs/template-resolution.js";
8
- export const KATA_AUTHORING_BASE = "docs/ja/kata";
8
+ export const KATA_AUTHORING_BASE = "docs/ja/specdojo";
9
+ export const LEGACY_KATA_AUTHORING_BASE = "docs/ja/kata";
9
10
  export const AUTHORING_KINDS = ["rulebook", "recipe", "sample", "template"];
10
11
  const KIND_DIR = {
11
12
  rulebook: "rulebooks",
@@ -26,14 +27,63 @@ export function isAuthoringApproach(approach) {
26
27
  return (approach !== undefined &&
27
28
  Object.prototype.hasOwnProperty.call(AUTHORING_KIND_BY_APPROACH, approach));
28
29
  }
29
- export function kataKindDirectory(kind, local = false) {
30
- return local ? `${KATA_AUTHORING_BASE}/${KIND_DIR[kind]}` : `docs/ja/specdojo/${KIND_DIR[kind]}`;
30
+ export function kataKindDirectory(kind) {
31
+ return `${KATA_AUTHORING_BASE}/${KIND_DIR[kind]}`;
32
+ }
33
+ export function authoredKataDirectory(kind, authority) {
34
+ const directory = kataKindDirectory(kind);
35
+ return authority === "specdojo" ? directory : `${directory}/${authority}`;
36
+ }
37
+ export function legacyKataKindDirectory(kind) {
38
+ return `${LEGACY_KATA_AUTHORING_BASE}/${KIND_DIR[kind]}`;
31
39
  }
32
40
  export function authoredKataPath(id, kind, extension = "md") {
33
- const specdojoOwned = parsePracticeId(id).authority === "specdojo";
34
- const directory = kataKindDirectory(kind, !specdojoOwned);
41
+ const authority = parsePracticeId(id).authority;
42
+ const directory = authoredKataDirectory(kind, authority ?? "specdojo");
35
43
  return `${directory}/${practiceLocalId(id)}.${extension}`;
36
44
  }
45
+ export function legacyAuthoredKataPath(id, kind, extension = "md") {
46
+ return `${legacyKataKindDirectory(kind)}/${practiceLocalId(id)}.${extension}`;
47
+ }
48
+ const warnedLegacyPaths = new Set();
49
+ export function warnLegacyAuthoredKata(id, canonicalPath, legacyPath, rootDir, duplicate) {
50
+ const warningKey = `${resolve(rootDir, legacyPath)}:${duplicate ? "duplicate" : "legacy"}`;
51
+ if (warnedLegacyPaths.has(warningKey))
52
+ return;
53
+ warnedLegacyPaths.add(warningKey);
54
+ const detail = duplicate
55
+ ? `both ${canonicalPath} and legacy ${legacyPath} exist; using ${canonicalPath}; remove the legacy file`
56
+ : `legacy path ${legacyPath} is deprecated; move it to ${canonicalPath}`;
57
+ process.stderr.write(`warning: Kata ${id}: ${detail}.\n`);
58
+ }
59
+ export function resolveAuthoredKataPathIfExists(id, kind, extension, rootDir = specdojoRootDir()) {
60
+ const authority = parsePracticeId(id).authority;
61
+ const canonicalPath = authoredKataPath(id, kind, extension);
62
+ const canonicalAbsolutePath = resolve(rootDir, canonicalPath);
63
+ if (!authority || authority === "specdojo") {
64
+ return existsSync(canonicalAbsolutePath)
65
+ ? { relativePath: canonicalPath, absolutePath: canonicalAbsolutePath, legacy: false }
66
+ : undefined;
67
+ }
68
+ if (authority !== configuredKataAuthority(rootDir))
69
+ return undefined;
70
+ const legacyPath = legacyAuthoredKataPath(id, kind, extension);
71
+ const legacyAbsolutePath = resolve(rootDir, legacyPath);
72
+ const canonicalExists = existsSync(canonicalAbsolutePath);
73
+ const legacyExists = existsSync(legacyAbsolutePath);
74
+ if (canonicalExists && legacyExists) {
75
+ warnLegacyAuthoredKata(id, canonicalPath, legacyPath, rootDir, true);
76
+ }
77
+ else if (legacyExists) {
78
+ warnLegacyAuthoredKata(id, canonicalPath, legacyPath, rootDir, false);
79
+ }
80
+ if (canonicalExists) {
81
+ return { relativePath: canonicalPath, absolutePath: canonicalAbsolutePath, legacy: false };
82
+ }
83
+ return legacyExists
84
+ ? { relativePath: legacyPath, absolutePath: legacyAbsolutePath, legacy: true }
85
+ : undefined;
86
+ }
37
87
  export function configuredKataAuthority(rootDir = specdojoRootDir()) {
38
88
  return getKataAuthority(loadConfig(rootDir).config, rootDir);
39
89
  }
@@ -77,16 +127,12 @@ function dataFileId(path) {
77
127
  }
78
128
  }
79
129
  export function authoredKataExists(id, rootDir = specdojoRootDir()) {
80
- const localId = practiceLocalId(id);
81
130
  for (const kind of AUTHORING_KINDS) {
82
131
  const extensions = kind === "rulebook" || kind === "recipe" ? ["md"] : ["md", "yaml", "yml", "json"];
83
- for (const local of [true, false]) {
84
- const directory = resolve(rootDir, kataKindDirectory(kind, local));
85
- for (const extension of extensions) {
86
- const candidate = join(directory, `${localId}.${extension}`);
87
- if (existsSync(candidate) && dataFileId(candidate) === id)
88
- return true;
89
- }
132
+ for (const extension of extensions) {
133
+ const resolved = resolveAuthoredKataPathIfExists(id, kind, extension, rootDir);
134
+ if (resolved && dataFileId(resolved.absolutePath) === id)
135
+ return true;
90
136
  }
91
137
  }
92
138
  return false;
@@ -5,7 +5,7 @@ import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
5
5
  import { specdojoResourceCandidates, } from "../docs/template-resolution.js";
6
6
  import { getKataAuthority, loadConfig, specdojoRootDir } from "../shared/specdojo-config.js";
7
7
  import { parsePracticeId } from "../shared/practice-id.js";
8
- import { AUTHORING_KINDS, kataKindDirectory } from "./authoring.js";
8
+ import { AUTHORING_KINDS, authoredKataDirectory, legacyKataKindDirectory, warnLegacyAuthoredKata, } from "./authoring.js";
9
9
  export const KATA_RESOURCE_KINDS = [
10
10
  "rulebook",
11
11
  "standard",
@@ -128,34 +128,46 @@ function enumerateAuthoredResources(roots) {
128
128
  const repositoryRoot = roots.repositoryRoot ?? specdojoRootDir();
129
129
  const configuredAuthority = getKataAuthority(loadConfig(repositoryRoot).config, repositoryRoot);
130
130
  return AUTHORING_KINDS.flatMap((kind) => {
131
- const relativeDir = kataKindDirectory(kind, true);
132
- const absoluteDir = resolve(repositoryRoot, relativeDir);
133
- return relativeFiles(absoluteDir).flatMap((filePath) => {
134
- const resolvedPath = resolve(absoluteDir, filePath);
135
- const id = resourceId(resolvedPath);
136
- let authority;
137
- try {
138
- authority = parsePracticeId(id).authority;
139
- }
140
- catch {
141
- return [];
142
- }
143
- if (authority !== configuredAuthority)
144
- return [];
145
- return [
146
- {
147
- id,
148
- kind,
149
- ejectable: false,
150
- relativePath: normalizeRelativePath(join(relativeDir, filePath)),
151
- repositoryPath: resolvedPath,
152
- resolvedPath,
153
- source: "repository",
154
- state: "ejected",
155
- difference: "-",
156
- },
157
- ];
131
+ const canonicalDir = authoredKataDirectory(kind, configuredAuthority);
132
+ const legacyDir = legacyKataKindDirectory(kind);
133
+ const resourcesFrom = (relativeDir) => {
134
+ const absoluteDir = resolve(repositoryRoot, relativeDir);
135
+ return relativeFiles(absoluteDir).flatMap((filePath) => {
136
+ const resolvedPath = resolve(absoluteDir, filePath);
137
+ const id = resourceId(resolvedPath);
138
+ let authority;
139
+ try {
140
+ authority = parsePracticeId(id).authority;
141
+ }
142
+ catch {
143
+ return [];
144
+ }
145
+ if (authority !== configuredAuthority)
146
+ return [];
147
+ return [
148
+ {
149
+ id,
150
+ kind,
151
+ ejectable: false,
152
+ relativePath: normalizeRelativePath(join(relativeDir, filePath)),
153
+ repositoryPath: resolvedPath,
154
+ resolvedPath,
155
+ source: "repository",
156
+ state: "ejected",
157
+ difference: "-",
158
+ },
159
+ ];
160
+ });
161
+ };
162
+ const canonical = resourcesFrom(canonicalDir);
163
+ const canonicalIds = new Set(canonical.map((resource) => resource.id));
164
+ const legacy = resourcesFrom(legacyDir).flatMap((resource) => {
165
+ const canonicalPath = normalizeRelativePath(join(canonicalDir, relative(legacyDir, resource.relativePath)));
166
+ const duplicate = canonicalIds.has(resource.id);
167
+ warnLegacyAuthoredKata(resource.id, canonicalPath, resource.relativePath, repositoryRoot, duplicate);
168
+ return duplicate ? [] : [resource];
158
169
  });
170
+ return [...canonical, ...legacy];
159
171
  });
160
172
  }
161
173
  function specdojoOwnedResource(resource) {
package/dist/kata/kata.js CHANGED
@@ -3,7 +3,7 @@ import { resolve } from "node:path";
3
3
  import { specdojoRootDir } from "../shared/specdojo-config.js";
4
4
  import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
5
5
  import { parsePracticeId, practiceLocalId } from "../shared/practice-id.js";
6
- import { authoredKataPath, configuredKataAuthority } from "./authoring.js";
6
+ import { authoredKataPath, configuredKataAuthority, resolveAuthoredKataPathIfExists, } from "./authoring.js";
7
7
  import { resolveSpecdojoPathIfExists, resolveSpecdojoReferencePathIfExists, specdojoResourceCandidates, } from "../docs/template-resolution.js";
8
8
  import { readYamlSchemaModelineRef } from "./yaml-schema-modeline.js";
9
9
  // 実践の型(rulebook / recipe / sample / template)の解決を 1 か所に集約する。
@@ -18,11 +18,13 @@ const KIND_DIR = {
18
18
  template: "templates",
19
19
  };
20
20
  function rulebookFsPath(rulebookId) {
21
- const relativePath = practiceRepoPath("rulebook", rulebookId, "md");
22
21
  const authority = parsePracticeId(rulebookId).authority;
23
22
  if (authority && authority !== "specdojo") {
24
- return resolve(specdojoRootDir(), relativePath);
23
+ const rootDir = specdojoRootDir();
24
+ return (resolveAuthoredKataPathIfExists(rulebookId, "rulebook", "md", rootDir)?.absolutePath ??
25
+ resolve(rootDir, practiceRepoPath("rulebook", rulebookId, "md", rootDir)));
25
26
  }
27
+ const relativePath = practiceRepoPath("rulebook", rulebookId, "md");
26
28
  return (resolveSpecdojoPathIfExists(relativePath) ??
27
29
  specdojoResourceCandidates(relativePath).repositoryPath);
28
30
  }
@@ -70,9 +72,15 @@ function kataReferencePath(relativePath, id) {
70
72
  return relativePath;
71
73
  return resolveSpecdojoReferencePathIfExists(relativePath) ?? relativePath;
72
74
  }
73
- function kataFsPath(relativePath, id) {
74
- if (!isSpecdojoResourceId(id))
75
- return resolve(specdojoRootDir(), relativePath);
75
+ function kataFsPath(kind, relativePath, id) {
76
+ if (!isSpecdojoResourceId(id)) {
77
+ const rootDir = specdojoRootDir();
78
+ const extension = relativePath.split(".").pop();
79
+ if (extension && ["md", "yaml", "yml", "json"].includes(extension)) {
80
+ return (resolveAuthoredKataPathIfExists(id, kind, extension, rootDir)?.absolutePath ?? resolve(rootDir, relativePath));
81
+ }
82
+ return resolve(rootDir, relativePath);
83
+ }
76
84
  return (resolveSpecdojoPathIfExists(relativePath) ??
77
85
  specdojoResourceCandidates(relativePath).repositoryPath);
78
86
  }
@@ -94,9 +102,9 @@ export function resolveKataDocumentPathIfExists(kind, id, extension, roots = {})
94
102
  if (authority && authority !== "specdojo") {
95
103
  if (authority !== configuredKataAuthority(repositoryRoot))
96
104
  return undefined;
97
- const relativePath = practiceRepoPath(kind, id, extension, repositoryRoot);
98
- const absolutePath = resolve(repositoryRoot, relativePath);
99
- return existsSync(absolutePath) ? absolutePath : undefined;
105
+ if (!["md", "yaml", "yml", "json"].includes(extension))
106
+ return undefined;
107
+ return resolveAuthoredKataPathIfExists(id, kind, extension, repositoryRoot)?.absolutePath;
100
108
  }
101
109
  return resolveSpecdojoPathIfExists(practiceRepoPath(kind, id, extension, repositoryRoot), roots);
102
110
  }
@@ -119,7 +127,10 @@ function resolveRef(kind, declaredId, ext) {
119
127
  return MISSING;
120
128
  }
121
129
  if (primaryId) {
122
- const relativePath = repoPath(kind, primaryId, declaredRefExt(kind, primaryId, ext));
130
+ const resolvedExt = declaredRefExt(kind, primaryId, ext);
131
+ const relativePath = !isSpecdojoResourceId(primaryId)
132
+ ? (resolveAuthoredKataPathIfExists(primaryId, kind, resolvedExt)?.relativePath ?? repoPath(kind, primaryId, resolvedExt))
133
+ : repoPath(kind, primaryId, resolvedExt);
123
134
  return kataReferencePath(relativePath, primaryId);
124
135
  }
125
136
  return MISSING;
@@ -151,7 +162,10 @@ export function resolveKataRefs(rulebookId, targetKind) {
151
162
  }
152
163
  // rulebook の repo 相対パス(先頭スラッシュ無し)。
153
164
  function rulebookRepoPath(rulebookId) {
154
- return practiceRepoPath("rulebook", rulebookId, "md");
165
+ return !isSpecdojoResourceId(rulebookId)
166
+ ? (resolveAuthoredKataPathIfExists(rulebookId, "rulebook", "md")?.relativePath ??
167
+ practiceRepoPath("rulebook", rulebookId, "md"))
168
+ : practiceRepoPath("rulebook", rulebookId, "md");
155
169
  }
156
170
  // 主 rulebook の frontmatter `includes` から、併せて適用する rulebook の宣言順・重複除去済み
157
171
  // ID 一覧を返す。自己参照は除外する。単一段のみ(include 先の include はたどらない)。
@@ -219,7 +233,7 @@ export function declaredKata(rulebookId) {
219
233
  out.push({
220
234
  kind,
221
235
  id,
222
- fsPath: kataFsPath(relativePath, id),
236
+ fsPath: kataFsPath(kind, relativePath, id),
223
237
  });
224
238
  }
225
239
  };