specdojo 0.4.2 → 0.4.3

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 (63) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/catalog/build.js +7 -7
  3. package/dist/catalog/generate.js +27 -12
  4. package/dist/commands/init.js +10 -7
  5. package/dist/commands/orchestrator.js +9 -2
  6. package/dist/devcontainer/command.js +1 -1
  7. package/dist/devcontainer/scaffold.js +24 -9
  8. package/dist/exec/core.js +4 -0
  9. package/dist/exec/plans-core.js +10 -1
  10. package/dist/exec/plans-generation.js +13 -0
  11. package/dist/exec/plans-storage.js +4 -0
  12. package/dist/exec/register.js +64 -6
  13. package/dist/exec/results.js +5 -1
  14. package/dist/exec/strategy.js +4 -0
  15. package/dist/kata/authoring.js +100 -0
  16. package/dist/kata/command.js +52 -2
  17. package/dist/kata/kata.js +54 -11
  18. package/dist/register/approach.js +29 -1
  19. package/dist/register/create-commands.js +9 -0
  20. package/dist/register/cross-project.js +9 -2
  21. package/dist/register/external-project.js +136 -0
  22. package/dist/schedule/strategy-profiles.js +3 -0
  23. package/dist/shared/agent-types.js +4 -0
  24. package/dist/shared/provider-scaffold.js +3 -3
  25. package/dist/shared/specdojo-config.js +109 -2
  26. package/docs/ja/specdojo/exec-templates/xep-recipe-authoring-template.md +45 -0
  27. package/docs/ja/specdojo/exec-templates/xep-rulebook-authoring-template.md +45 -0
  28. package/docs/ja/specdojo/exec-templates/xep-sample-authoring-template.md +45 -0
  29. package/docs/ja/specdojo/exec-templates/xep-template-authoring-template.md +45 -0
  30. package/docs/ja/specdojo/guides/docs-editing-guide.md +32 -0
  31. package/docs/ja/specdojo/guides/docs-structure-guide.md +1 -1
  32. package/docs/ja/specdojo/guides/exec-config-guide.md +13 -6
  33. package/docs/ja/specdojo/guides/kata-guide.md +4 -0
  34. package/docs/ja/specdojo/guides/quick-start-guide.md +352 -68
  35. package/docs/ja/specdojo/guides/register-operation-guide.md +18 -0
  36. package/docs/ja/specdojo/guides/remote-host-development-guide.md +10 -2
  37. package/docs/ja/specdojo/guides/ryu-guide.md +18 -4
  38. package/docs/ja/specdojo/guides/use-case-guide.md +2 -2
  39. package/docs/ja/specdojo/references/command-reference.md +39 -20
  40. package/docs/ja/specdojo/references/specdojo-config-reference.md +33 -7
  41. package/docs/ja/specdojo/standards/recipe-authoring-standard.md +10 -10
  42. package/docs/ja/specdojo/standards/rulebook-authoring-standard.md +13 -13
  43. package/docs/ja/specdojo/standards/sample-authoring-standard.md +4 -4
  44. package/docs/ja/specdojo/standards/template-authoring-standard.md +4 -4
  45. package/docs/specdojo/schemas/v1/exec-common.schema.yaml +6 -0
  46. package/docs/specdojo/schemas/v1/exec-plan-frontmatter.schema.yaml +6 -6
  47. package/docs/specdojo/schemas/v1/register-item-frontmatter.schema.yaml +21 -4
  48. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +29 -0
  49. package/package.json +2 -2
  50. package/templates/antigravity/README.md +1 -1
  51. package/templates/antigravity/settings.global.json +5 -0
  52. package/templates/claude/README.md +11 -8
  53. package/templates/claude/settings.edit.json +10 -1
  54. package/templates/claude/settings.orchestrator.json +90 -0
  55. package/templates/claude/settings.report.json +14 -1
  56. package/templates/claude/settings.review.json +13 -1
  57. package/templates/codex/README.md +7 -5
  58. package/templates/codex/rules/specdojo.rules +48 -0
  59. package/templates/devcontainer/devcontainer.json +1 -4
  60. package/templates/opencode/README.md +2 -1
  61. package/templates/opencode/agents/opencode-executor.md +2 -0
  62. package/templates/opencode/agents/opencode-review-executor.md +2 -0
  63. package/templates/opencode/agents/specdojo-orchestrator.md +59 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  SpecDojo の利用者に影響する変更を記録します。
4
4
 
5
+ ## [0.4.3] - 2026-10-23
6
+
7
+ ### 追加機能
8
+
9
+ - 既存成果物を手本に kata だけを新規作成する `rulebook-authoring` / `recipe-authoring` / `sample-authoring` / `template-authoring` approach を追加しました。利用者の kata はリポジトリ単位の `kata_authority` と `docs/ja/kata/` 配置で同梱 kata から分離し、手本の未決参照は同じ実行で新しい ID へ更新します(PJR-CT6G)。
10
+ - Dev Container の preset に、provider の CLI と最低限だけを入れる `minimal` と、推奨構成に開発ツール・Ollama 接続・cron を加える `full` を追加しました。`specdojo init` では `minimal` / `recommended` / `full` を選択でき、既定は従来どおり `recommended`、従来の `none` は `minimal` の別名として利用できます(PJR-47S6)。
11
+ - Dev Container の推奨 preset に GitHub CLI(`gh`)を加え、コンテナ内で行ったログインをリポジトリ別の名前付き volume に保存するようにしました。ホストの認証情報はマウントせず、自動ログインもしません。共有された認証を agent が使ってリモートを書き換えないよう、Claude Code・Codex・OpenCode・Antigravity の配布権限では `git push` と `gh` の書き込みを拒否します。pipeline executor と reporter は全 `gh` を拒否し、Claude Code と OpenCode の対話型オーケストレーターだけは専用権限で読み取りを許可します(PJR-ZH7Q)。
12
+ - `specdojo.config.json` の `external_projects` で別リポジトリの project を別名付きで宣言し、`register add --project <別名> --commit` から相手にインストールされた SpecDojo へ起票を委譲できるようにしました。`--from <別名>:PJR-XXXX` は相手の実 project ID へ変換し、`orchestrator launch` は宣言した外部リポジトリにも編集許可を付けます(PJR-5B42)。
13
+
14
+ ### 変更
15
+
16
+ - ドキュメントサイトの Mermaid 12 で既定のレイアウトを Dagre から ELK へ切り替え、複雑な図を層状・直角配線で描くようにしました。日本語と絵文字のフォントを描画環境へ揃え、図中の絵文字が欠けないようにしました。文書編集ガイドには、辺が多い図の分割、中心へ矢印を集める `architecture` 図、格子状に並べる `block` 図の書き方を追加しました(PJR-QF45)。
17
+
18
+ ### 文書
19
+
20
+ - Quick Start ガイドを register のユースケース別の実行例を中心に組み替え、`difficulty` と approach、統合後 review、夜間実行、再開、別 project への起票を「こんなとき」「チャットでの頼み方」「コマンド」の順で追加しました。成果物カタログ、Schedule、worktree、routine は発展手順として後段にまとめました(PJR-98SQ)。
21
+
5
22
  ## [0.4.2] - 2026-10-22
6
23
 
7
24
  ### 追加機能
@@ -2,13 +2,13 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from
2
2
  import { join } from "node:path";
3
3
  import { load } from "../shared/yaml.js";
4
4
  import { isDctCatalogFileName } from "./types.js";
5
- import { declaredIncludes, declaredKata } from "../kata/kata.js";
5
+ import { declaredIncludes, declaredKata, resolveKataDocumentPathIfExists } from "../kata/kata.js";
6
6
  import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
7
7
  import { flattenTemplateFrontmatter } from "../docs/template-frontmatter.js";
8
8
  import { specdojoRootDir } from "../shared/specdojo-config.js";
9
9
  import { buildMarkdown, isRecord, isDctTemplateCatalog, renderCatalogTemplateBody, } from "./build-render.js";
10
10
  import { collectResolvedDeliverables, validateBasedOn } from "./build-references.js";
11
- import { resolveSpecdojoPath, resolveSpecdojoPathIfExists, specdojoDirectoryPaths, specdojoResourceCandidates, } from "../docs/template-resolution.js";
11
+ import { resolveSpecdojoPath, resolveSpecdojoPathIfExists, specdojoDirectoryPaths, } from "../docs/template-resolution.js";
12
12
  const CATALOG_RULEBOOK_ID_PATTERN = /^(?:[a-z][a-z0-9-]*:)?[a-z0-9][a-z0-9-]*-rulebook$/;
13
13
  const CATALOG_KATA_DIRS = {
14
14
  rulebook: "rulebooks",
@@ -17,12 +17,12 @@ const CATALOG_KATA_DIRS = {
17
17
  template: "templates",
18
18
  };
19
19
  function declaredKataCandidates(repoRoot, kind, id) {
20
- const localId = id.includes(":") ? id.split(":").slice(1).join(":") : id;
21
20
  const extensions = kind === "rulebook" || kind === "recipe" ? ["md"] : ["md", "yaml", "json"];
22
- return extensions.map((extension) => {
23
- const relativePath = `docs/ja/specdojo/${CATALOG_KATA_DIRS[kind]}/${localId}.${extension}`;
24
- return (resolveSpecdojoPathIfExists(relativePath, { repositoryRoot: repoRoot }) ??
25
- specdojoResourceCandidates(relativePath, { repositoryRoot: repoRoot }).repositoryPath);
21
+ return extensions.flatMap((extension) => {
22
+ const resolved = resolveKataDocumentPathIfExists(kind, id, extension, {
23
+ repositoryRoot: repoRoot,
24
+ });
25
+ return resolved ? [resolved] : [];
26
26
  });
27
27
  }
28
28
  function readPracticeDocumentId(filePath) {
@@ -4,7 +4,8 @@ import { dump, load } from "../shared/yaml.js";
4
4
  import { collectResolvedDeliverables } from "./build.js";
5
5
  import { resolveBasePath } from "./paths.js";
6
6
  import { buildSpecdojoFrontmatter, readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
7
- import { practiceLocalId } from "../shared/practice-id.js";
7
+ import { parsePracticeId, practiceLocalId } from "../shared/practice-id.js";
8
+ import { resolveKataDocumentPathIfExists } from "../kata/kata.js";
8
9
  import { flattenTemplateFrontmatter } from "../docs/template-frontmatter.js";
9
10
  import { isDctCatalogFileName } from "./types.js";
10
11
  import { resolveSpecdojoPathIfExists, } from "../docs/template-resolution.js";
@@ -64,7 +65,7 @@ function normalizeDctName(name) {
64
65
  // Resolve a deliverable template from the rulebook frontmatter declaration. The declaration is
65
66
  // the SSOT, so local_id naming conventions are deliberately not used as a fallback. This lets
66
67
  // every deliverable in one rulebook lineage share a single template.
67
- function findTemplate(templatesPath, rulebooksPath, rulebookId, ext, resourceRoots) {
68
+ function findTemplate(templatesPath, rulebooksPath, repoRoot, rulebookId, ext, resourceRoots) {
68
69
  if (!rulebookId ||
69
70
  rulebookId === "none" ||
70
71
  rulebookId === "not-needed" ||
@@ -72,9 +73,16 @@ function findTemplate(templatesPath, rulebooksPath, rulebookId, ext, resourceRoo
72
73
  return null;
73
74
  }
74
75
  const rulebookFileName = `${practiceLocalId(rulebookId)}.md`;
75
- const rulebookPath = resourceRoots
76
- ? resolveSpecdojoPathIfExists(`docs/ja/specdojo/rulebooks/${rulebookFileName}`, resourceRoots)
77
- : join(rulebooksPath, rulebookFileName);
76
+ const rulebookAuthority = parsePracticeId(rulebookId).authority;
77
+ const localRulebook = rulebookAuthority !== undefined && rulebookAuthority !== "specdojo";
78
+ const rulebookPath = localRulebook
79
+ ? resolveKataDocumentPathIfExists("rulebook", rulebookId, "md", {
80
+ ...resourceRoots,
81
+ repositoryRoot: repoRoot,
82
+ })
83
+ : resourceRoots
84
+ ? resolveSpecdojoPathIfExists(`docs/ja/specdojo/rulebooks/${rulebookFileName}`, resourceRoots)
85
+ : join(rulebooksPath, rulebookFileName);
78
86
  if (!rulebookPath)
79
87
  return null;
80
88
  if (!existsSync(rulebookPath))
@@ -87,9 +95,16 @@ function findTemplate(templatesPath, rulebooksPath, rulebookId, ext, resourceRoo
87
95
  return null;
88
96
  }
89
97
  const templateFileName = `${practiceLocalId(templateId)}${ext}`;
90
- const candidate = resourceRoots
91
- ? resolveSpecdojoPathIfExists(`docs/ja/specdojo/templates/${templateFileName}`, resourceRoots)
92
- : join(templatesPath, templateFileName);
98
+ const templateAuthority = parsePracticeId(templateId).authority;
99
+ const localTemplate = templateAuthority !== undefined && templateAuthority !== "specdojo";
100
+ const candidate = localTemplate
101
+ ? resolveKataDocumentPathIfExists("template", templateId, ext.slice(1), {
102
+ ...resourceRoots,
103
+ repositoryRoot: repoRoot,
104
+ })
105
+ : resourceRoots
106
+ ? resolveSpecdojoPathIfExists(`docs/ja/specdojo/templates/${templateFileName}`, resourceRoots)
107
+ : join(templatesPath, templateFileName);
93
108
  if (!candidate)
94
109
  return null;
95
110
  return existsSync(candidate) ? candidate : null;
@@ -138,12 +153,12 @@ function expandYamlTemplate(templatePath, item, projectId) {
138
153
  const doc = replaceGeneratedPlaceholders(merged, item, projectId);
139
154
  return dump(doc, { lineWidth: 120, noRefs: true });
140
155
  }
141
- function generateContent(item, resolvedPath, projectId, templatesPath, rulebooksPath, resourceRoots) {
156
+ function generateContent(item, resolvedPath, projectId, templatesPath, rulebooksPath, repoRoot, resourceRoots) {
142
157
  if (isYamlPath(resolvedPath)) {
143
- const template = findTemplate(templatesPath, rulebooksPath, item.rulebook, ".yaml", resourceRoots);
158
+ const template = findTemplate(templatesPath, rulebooksPath, repoRoot, item.rulebook, ".yaml", resourceRoots);
144
159
  return template ? expandYamlTemplate(template, item, projectId) : fallbackYaml(item, projectId);
145
160
  }
146
- const template = findTemplate(templatesPath, rulebooksPath, item.rulebook, ".md", resourceRoots);
161
+ const template = findTemplate(templatesPath, rulebooksPath, repoRoot, item.rulebook, ".md", resourceRoots);
147
162
  if (template) {
148
163
  const raw = readFileSync(template, "utf8");
149
164
  return replaceGeneratedPlaceholders(flattenTemplateFrontmatter(raw), item, projectId);
@@ -207,7 +222,7 @@ export function runGenerate(opts) {
207
222
  continue;
208
223
  }
209
224
  try {
210
- const content = generateContent(item, resolvedPath, projectId, templatesPath, rulebooksPath, resourceRoots);
225
+ const content = generateContent(item, resolvedPath, projectId, templatesPath, rulebooksPath, repoRoot, resourceRoots);
211
226
  if (!dryRun) {
212
227
  mkdirSync(dirname(outputPath), { recursive: true });
213
228
  writeFileSync(outputPath, content, "utf8");
@@ -68,11 +68,14 @@ function parseCatalog(value) {
68
68
  }
69
69
  function parseDevcontainerPreset(value) {
70
70
  const normalized = value?.trim().toLowerCase();
71
- if (!normalized || normalized === "none" || normalized === "-")
71
+ if (!normalized)
72
72
  return undefined;
73
- if (normalized === "recommended")
73
+ if (normalized === "none" || normalized === "-")
74
+ return "minimal";
75
+ if (normalized === "minimal" || normalized === "recommended" || normalized === "full") {
74
76
  return normalized;
75
- throw new Error(`Invalid Dev Container preset: ${value}. Must be recommended or none`);
77
+ }
78
+ throw new Error(`Invalid Dev Container preset: ${value}. Must be minimal, recommended, full, or none`);
76
79
  }
77
80
  function validateProjectId(projectId) {
78
81
  if (!/^prj-[0-9]{4,}$/.test(projectId)) {
@@ -190,7 +193,7 @@ export async function collectInitAnswers(options, prompter) {
190
193
  const catalog = parseCatalog(options.catalog);
191
194
  const devcontainer = await promptUntilValid(prompter, `Create a Dev Container? [${devcontainerDefault ? "Y/n" : "y/N"}]: `, (answer) => parseBoolean(answer, devcontainerDefault));
192
195
  const devcontainerPreset = devcontainer && options.devcontainerPreset === undefined
193
- ? await promptUntilValid(prompter, "Add the recommended Dev Container settings? [Y/n]: ", (answer) => (parseBoolean(answer, true) ? "recommended" : undefined))
196
+ ? await promptUntilValid(prompter, "Dev Container preset (minimal, recommended, full) [recommended]: ", (answer) => parseDevcontainerPreset(answer.trim() || "recommended"))
194
197
  : explicitDevcontainerPreset;
195
198
  const lefthook = await promptUntilValid(prompter, `Create Git hooks with lefthook? [${lefthookDefault ? "Y/n" : "y/N"}]: `, (answer) => parseBoolean(answer, lefthookDefault));
196
199
  return validateAnswers({
@@ -516,9 +519,9 @@ export async function runInit(options, deps) {
516
519
  preset: answers.devcontainerPreset,
517
520
  providers: answers.providers,
518
521
  editors: [],
519
- ollama: answers.providers.includes("opencode"),
522
+ ollama: false,
520
523
  cron: false,
521
- tmux: true,
524
+ tmux: false,
522
525
  force: false,
523
526
  dryRun,
524
527
  });
@@ -567,7 +570,7 @@ export function registerInitCommand(program) {
567
570
  .option("--catalog <size>", "Create a deliverables catalog (small|medium|large)")
568
571
  .option("--devcontainer", "Create a Dev Container for the selected providers", false)
569
572
  .option("--lefthook", "Create pre-commit hooks for SpecDojo repositories", false)
570
- .option("--devcontainer-preset <name>", "Apply a Dev Container preset when creating it (recommended|none)")
573
+ .option("--devcontainer-preset <name>", "Apply a Dev Container preset when creating it (minimal|recommended|full; none aliases minimal)")
571
574
  .option("--workspace-name <name>", "Override the Dev Container workspace parent name used under /workspaces")
572
575
  .option("--dry-run", "Show planned files and changes without writing", false)
573
576
  .action(async (options) => {
@@ -2,7 +2,7 @@ import { spawn } from "node:child_process";
2
2
  import { constants as osConstants } from "node:os";
3
3
  import { resolve } from "node:path";
4
4
  import { agentExtraRootArguments, resolveProductRepos } from "../exec/task-repos.js";
5
- import { loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
5
+ import { loadConfig, resolveExternalProjects, specdojoRootDir, } from "../shared/specdojo-config.js";
6
6
  import { registerNightOrchestratorCommand } from "./night-orchestrator.js";
7
7
  const ORCHESTRATOR_EXECUTABLES = {
8
8
  claude: "claude",
@@ -131,10 +131,17 @@ export function resolveOrchestratorLaunch(options) {
131
131
  throw new Error(`No config found: ${configPath}`);
132
132
  const projectId = resolveOrchestratorProjectId(config, options.project, env);
133
133
  const repos = resolveProductRepos(configRootDir, config.projects[projectId]);
134
+ const externalProjects = resolveExternalProjects(configRootDir, config);
135
+ const repoRoots = [
136
+ ...new Set([
137
+ ...repos.map((repo) => repo.repoRoot),
138
+ ...externalProjects.map((project) => project.repoRoot),
139
+ ]),
140
+ ];
134
141
  const launch = buildOrchestratorLaunch({
135
142
  provider: options.provider,
136
143
  providerArgs: options.providerArgs,
137
- repoRoots: repos.map((repo) => repo.repoRoot),
144
+ repoRoots,
138
145
  cwd: rootDir,
139
146
  env,
140
147
  });
@@ -5,7 +5,7 @@ export function registerDevcontainerCommands(program) {
5
5
  const dc = program.command("devcontainer").description("Dev Container helpers");
6
6
  dc.command("scaffold")
7
7
  .description("Scaffold .devcontainer/ configuration for the repository")
8
- .option("--preset <name>", "Apply a bundled preset (available: recommended)")
8
+ .option("--preset <name>", "Apply a bundled preset (minimal|recommended|full)")
9
9
  .option("--provider <names>", "Comma-separated list of agent providers to install (e.g. claude,codex,opencode,antigravity)", "")
10
10
  .option("--editor <names>", "Comma-separated list of editors to install and configure (emacs,vim)", "")
11
11
  .option("--ollama", "Add Ollama connection settings", false)
@@ -1,6 +1,7 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import { readFile, writeFile, mkdir } from "node:fs/promises";
3
3
  import * as path from "node:path";
4
+ export const DEVCONTAINER_PRESETS = ["minimal", "recommended", "full"];
4
5
  const RECOMMENDED_VSCODE_EXTENSIONS = [
5
6
  "mhutchie.git-graph",
6
7
  "davidanson.vscode-markdownlint",
@@ -150,12 +151,15 @@ export function generateSshConfigSample(ports) {
150
151
  }
151
152
  export async function runDevcontainerScaffold(opts) {
152
153
  const { packageRoot, repoRoot, workspaceName: workspaceNameOverride, preset, providers, editors, ollama, cron, tmux, force, dryRun, } = opts;
153
- if (preset !== undefined && preset !== "recommended") {
154
- throw new Error(`Unknown Dev Container preset: ${preset}. Available: recommended`);
154
+ if (preset !== undefined && !DEVCONTAINER_PRESETS.includes(preset)) {
155
+ throw new Error(`Unknown Dev Container preset: ${preset}. Available: ${DEVCONTAINER_PRESETS.join(", ")}`);
155
156
  }
156
- const recommended = preset === "recommended";
157
- const effectiveEditors = unique([...editors, ...(recommended ? ["emacs", "vim"] : [])]);
158
- const effectiveTmux = tmux || recommended;
157
+ const includesRecommended = preset === "recommended" || preset === "full";
158
+ const full = preset === "full";
159
+ const effectiveEditors = unique([...editors, ...(includesRecommended ? ["emacs", "vim"] : [])]);
160
+ const effectiveTmux = tmux || includesRecommended;
161
+ const effectiveOllama = ollama || full;
162
+ const effectiveCron = cron || full;
159
163
  const devcontainerDir = path.join(repoRoot, ".devcontainer");
160
164
  const workspaceName = resolveWorkspaceName(repoRoot, workspaceNameOverride);
161
165
  if (existsSync(devcontainerDir) && !force) {
@@ -188,10 +192,21 @@ export async function runDevcontainerScaffold(opts) {
188
192
  const extraScripts = [];
189
193
  let emacsInitTemplate;
190
194
  let vimrcTemplate;
195
+ if (includesRecommended) {
196
+ aptPackages.push("gh");
197
+ devcontainer.mounts.push(`source=${volumeName("gh")},target=/home/node/.config/gh,type=volume`);
198
+ }
199
+ if (full) {
200
+ aptPackages.push("ripgrep", "fd-find", "fzf", "yq", "shellcheck", "shfmt");
201
+ extraScripts.push(`# Debian installs fd as fdfind. Expose the upstream command name as well.
202
+ if command -v fdfind >/dev/null 2>&1 && ! command -v fd >/dev/null 2>&1; then
203
+ sudo ln -s "$(command -v fdfind)" /usr/local/bin/fd
204
+ fi`);
205
+ }
191
206
  if (effectiveTmux) {
192
207
  aptPackages.push("tmux");
193
208
  }
194
- if (cron) {
209
+ if (effectiveCron) {
195
210
  aptPackages.push("cron");
196
211
  devcontainer.postAttachCommand = "sudo service cron start";
197
212
  }
@@ -258,7 +273,7 @@ fi`);
258
273
  }
259
274
  let vscodeExtensions = [];
260
275
  let extensionsFile;
261
- if (recommended) {
276
+ if (includesRecommended) {
262
277
  vscodeExtensions = unique([...RECOMMENDED_VSCODE_EXTENSIONS, ...providerExtensions(providers)]);
263
278
  const customizations = (devcontainer.customizations ??= {});
264
279
  const vscode = (customizations.vscode ??= {});
@@ -292,11 +307,11 @@ fi`);
292
307
  }
293
308
  if (aptPackages.length > 0) {
294
309
  devcontainer.features["ghcr.io/rocker-org/devcontainer-features/apt-packages:1"] = {
295
- packages: aptPackages.join(","),
310
+ packages: unique(aptPackages).join(","),
296
311
  upgradePackages: false,
297
312
  };
298
313
  }
299
- if (ollama) {
314
+ if (effectiveOllama) {
300
315
  devcontainer.containerEnv["OLLAMA_BASE_URL"] = "http://host.docker.internal:11434";
301
316
  devcontainer.containerEnv["LOCAL_OPENAI_BASE_URL"] = "http://host.docker.internal:11434/v1";
302
317
  }
package/dist/exec/core.js CHANGED
@@ -16,6 +16,10 @@ const KNOWN_APPROACHES = [
16
16
  "recipe-guided",
17
17
  "freeform",
18
18
  "bootstrap",
19
+ "rulebook-authoring",
20
+ "recipe-authoring",
21
+ "sample-authoring",
22
+ "template-authoring",
19
23
  "retrofit",
20
24
  "cross-deliverable-dedup",
21
25
  "rulebook-maintenance",
@@ -276,7 +276,8 @@ export function gradeFindingTargetPath(approach, deliverable, refs) {
276
276
  }
277
277
  // grade の --target。実践の型メンテナンス系は実践の型そのものを評価対象にする。
278
278
  export function gradeTargetKind(approach) {
279
- return approach === "rulebook-maintenance" ||
279
+ return approach?.endsWith("-authoring") ||
280
+ approach === "rulebook-maintenance" ||
280
281
  approach === "recipe-maintenance" ||
281
282
  approach === "sample-maintenance" ||
282
283
  approach === "template-maintenance"
@@ -343,6 +344,10 @@ export function deliverableDependsOn(deliverable, projectId, catalogPath) {
343
344
  }
344
345
  const PROJECT_CONTEXT_EXCLUDED_APPROACHES = new Set([
345
346
  "cross-deliverable-dedup",
347
+ "rulebook-authoring",
348
+ "recipe-authoring",
349
+ "sample-authoring",
350
+ "template-authoring",
346
351
  "rulebook-maintenance",
347
352
  "recipe-maintenance",
348
353
  "sample-maintenance",
@@ -449,6 +454,10 @@ function refDocIdFromPath(refPath) {
449
454
  // approach ごとに、成果物に加えて変更・確定の対象になる実践の型の種別。
450
455
  const TARGET_REF_KINDS = {
451
456
  bootstrap: ["rulebook", "recipe", "sample", "template"],
457
+ "rulebook-authoring": ["rulebook"],
458
+ "recipe-authoring": ["recipe"],
459
+ "sample-authoring": ["sample"],
460
+ "template-authoring": ["template"],
452
461
  "bootstrap-finalize": ["rulebook", "recipe", "sample", "template"],
453
462
  "rulebook-maintenance": ["rulebook"],
454
463
  "recipe-maintenance": ["recipe"],
@@ -4,6 +4,7 @@ import { DEFAULT_PROJECT_CONTEXT } from "../shared/specdojo-config.js";
4
4
  import { resolveDeliverableSchemaRef, resolveKataRefs } from "../kata/kata.js";
5
5
  import { formatMarkdownFile } from "./format.js";
6
6
  import { expandTemplate } from "./shared.js";
7
+ import { isAuthoringApproach } from "../kata/authoring.js";
7
8
  import { MISSING, applicableReviewCriteria, crossDeliverableTargetDetails, deliverableDependsOn, deliverableName, deliverableOverview, deliverablePath, doneCriteriaChecklist, doneCriteriaGoals, doneCriteriaItems, execDocId, findDeliverableInfo, frontmatter, gradeFindingsText, gradeFindingTargetPath, gradeResultRef, gradeTargetKind, implementationEvidence, injectCommonConventions, kataRefState, loadPlanTemplate, loadRoles, loadViewpoints, ownerRoleFields, phaseDescriptionText, projectContextSection, repoRelativePath, reviewDoneCriteriaRows, reviewGradeSummaryText, rulebookIncludesText, targetDocIds, targetDocIdsForTask, } from "./plans-core.js";
8
9
  function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, projectId, catalogPath, projectContext, resultRef, stem, crossDeliverables = new Map(), planOverrides) {
9
10
  const cpm = task.cpm;
@@ -58,6 +59,14 @@ function buildEditPlanMarkdown(template, task, deliverable, roleMap, vpMap, proj
58
59
  _DONE_CRITERIA_ITEMS_: doneCriteriaItems(criteria),
59
60
  _GRADE_FINDINGS_: gradeFindingsText(projectId, gradeFindingTargetPath(task.approach, deliverable, refs)),
60
61
  _TARGET_DELIVERABLES_: crossDeliverableTargetDetails(projectId, task.target_local_ids ?? [], crossDeliverables, catalogPath),
62
+ _AUTHORING_KATA_ID_: planOverrides?.authoring?.id ?? MISSING,
63
+ _AUTHORING_KATA_KIND_: planOverrides?.authoring?.kind ?? MISSING,
64
+ _AUTHORING_KATA_PATH_: planOverrides?.authoring?.path ?? MISSING,
65
+ _AUTHORING_STANDARD_ID_: planOverrides?.authoring?.standardId ?? MISSING,
66
+ _AUTHORING_STANDARD_PATH_: planOverrides?.authoring?.standardPath ?? MISSING,
67
+ _AUTHORING_EXEMPLARS_: planOverrides?.authoring?.exemplars
68
+ .map((example) => `- \`${example.id}\`: ${example.name}(\`${example.path}\`、現在の参照: \`${example.currentReference}\`)`)
69
+ .join("\n") || "- なし(kata だけを新規作成する)",
61
70
  };
62
71
  const body = expandTemplate(template, values);
63
72
  if (!planOverrides?.additionalConditions)
@@ -123,6 +132,9 @@ function buildReviewPlanMarkdown(template, task, deliverable, criteria, vpMap, p
123
132
  }
124
133
  async function writeTaskPlan(ctx, task, override) {
125
134
  const mode = task.mode ?? "edit";
135
+ if (isAuthoringApproach(task.approach) && override?.origin !== "register") {
136
+ throw new Error(`Approach ${task.approach} is register-only because schedule targets cannot express a new kata id followed by exemplar deliverables`);
137
+ }
126
138
  const localId = task.local_id;
127
139
  const targetLocalIds = [...new Set(task.target_local_ids ?? [])];
128
140
  const crossDeliverables = new Map();
@@ -220,6 +232,7 @@ export async function generateRegisterApproachPlan(opts) {
220
232
  origin: "register",
221
233
  targets: opts.targets,
222
234
  ...(opts.refs ? { refs: opts.refs } : {}),
235
+ ...(opts.authoring ? { authoring: opts.authoring } : {}),
223
236
  additionalConditions: opts.additionalConditions,
224
237
  ...(opts.outPath ? { outPath: opts.outPath } : {}),
225
238
  stem: opts.stem,
@@ -43,6 +43,10 @@ const PLAN_APPROACHES = [
43
43
  "recipe-guided",
44
44
  "freeform",
45
45
  "bootstrap",
46
+ "rulebook-authoring",
47
+ "recipe-authoring",
48
+ "sample-authoring",
49
+ "template-authoring",
46
50
  "retrofit",
47
51
  "cross-deliverable-dedup",
48
52
  "rulebook-maintenance",
@@ -1,11 +1,13 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
- import { join, relative, resolve } from "node:path";
2
+ import { 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
6
  import { findUniqueDeliverableForKataTarget, resolveDeliverableByDocId, } from "./plans-core.js";
7
7
  import { collectDocIndexEntries } from "../docs/doc-index.js";
8
- import { resolveKataRefs } from "../kata/kata.js";
8
+ import { loadRulebookRefs, resolveKataRefs } from "../kata/kata.js";
9
+ import { authoredKataPath, authoringKind, authoringStandardId, authoringStandardPath, } from "../kata/authoring.js";
10
+ import { validateRegisterApproachTargets } from "../register/approach.js";
9
11
  import { buildSpecdojoFrontmatter } from "../docs/frontmatter-namespace.js";
10
12
  import { escapeMarkdownInline, expandTemplate, inlineCodeAnglePlaceholders, stripTerminalControlSequences, } from "./shared.js";
11
13
  import { formatMarkdownFile } from "./format.js";
@@ -305,14 +307,69 @@ export async function generateRegisterPlan(opts) {
305
307
  const category = requireRunnableRegisterItem(item);
306
308
  const ticketPath = ticketPathFromItem(item, opts.registerPaths.projectRegisterPath);
307
309
  if (item.approach) {
310
+ validateRegisterApproachTargets({
311
+ repoRoot: specdojoRootDir(),
312
+ projectId: opts.projectId,
313
+ ...(opts.catalogPath ? { catalogPath: opts.catalogPath } : {}),
314
+ approach: item.approach,
315
+ targets: item.targets,
316
+ });
308
317
  const [targetId] = item.targets ?? [];
309
- if (!targetId || (item.targets?.length ?? 0) !== 1) {
310
- throw new Error(`Register item ${item.id} approach requires exactly one target document id.`);
311
- }
318
+ if (!targetId)
319
+ throw new Error(`Register item ${item.id} approach requires a target.`);
320
+ const newKataKind = authoringKind(item.approach);
312
321
  const maintenanceKind = MAINTENANCE_TARGET_KIND[item.approach];
313
322
  let deliverable = null;
314
323
  let refs;
315
- if (maintenanceKind) {
324
+ let authoring;
325
+ 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;
332
+ let currentReference;
333
+ if (newKataKind === "rulebook") {
334
+ currentReference = rulebookId ?? "未記入";
335
+ }
336
+ else if (!rulebookId ||
337
+ rulebookId === "undecided" ||
338
+ rulebookId === "not-needed" ||
339
+ rulebookId === "none") {
340
+ currentReference = `rulebook が ${rulebookId ?? "未記入"} のため参照を更新できない`;
341
+ }
342
+ else {
343
+ const declaredReference = loadRulebookRefs(rulebookId)[newKataKind];
344
+ currentReference = Array.isArray(declaredReference)
345
+ ? declaredReference.join(", ")
346
+ : (declaredReference ?? "未記入");
347
+ }
348
+ return {
349
+ id: exampleId,
350
+ name: resolved.deliverable.name,
351
+ path: resolved.resolvedPath,
352
+ currentReference,
353
+ };
354
+ });
355
+ const exemplarExtension = extname(examples[0]?.path ?? "").slice(1);
356
+ const authoredExtension = (newKataKind === "sample" || newKataKind === "template") &&
357
+ (exemplarExtension === "yaml" || exemplarExtension === "json")
358
+ ? exemplarExtension
359
+ : "md";
360
+ const kataPath = authoredKataPath(targetId, newKataKind, authoredExtension);
361
+ refs = { rulebook: MISSING, recipe: MISSING, sample: MISSING, template: MISSING };
362
+ refs[newKataKind] = kataPath;
363
+ authoring = {
364
+ id: targetId,
365
+ kind: newKataKind,
366
+ path: kataPath,
367
+ standardId: authoringStandardId(newKataKind),
368
+ standardPath: authoringStandardPath(newKataKind),
369
+ exemplars: examples,
370
+ };
371
+ }
372
+ else if (maintenanceKind) {
316
373
  deliverable = opts.catalogPath
317
374
  ? findUniqueDeliverableForKataTarget(opts.catalogPath, targetId, maintenanceKind)
318
375
  : null;
@@ -342,6 +399,7 @@ export async function generateRegisterPlan(opts) {
342
399
  targets: item.targets ?? [],
343
400
  deliverable,
344
401
  ...(refs ? { refs } : {}),
402
+ ...(authoring ? { authoring } : {}),
345
403
  additionalConditions: [
346
404
  registerCompletionConditions(item, ticketPath),
347
405
  registerAutopilotConstraints(item),
@@ -160,7 +160,7 @@ async function supersedePriorResults(resultsDir, taskId, nextResultPath, superse
160
160
  const APPROACH_SECTION_WITH_APPROACH = [
161
161
  "## 4. 進め方と実践の型の適用",
162
162
  "",
163
- "_TODO_: `approach` に従ってどう進めたか、その進め方の中で実践の型(rulebook / recipe / sample / template)をどう適用したかを記入する(`fully-guided` で rulebook / recipe / sample / template をどう使い分けたか、`recipe-guided` で recipe のみを基準にした内容、`freeform` で実践の型より優先した実例やプロジェクト文脈、`retrofit` で実際に参照した実装パス・抽出した現在動作・反映/新設判断・未反映の乖離・未確認範囲、`rulebook-maintenance` などの maintenance 系で見直した実践の型とその根拠、など)。実践の型を基準にしなかった場合は、その判断と代わりに根拠にした内容も記入する。複数文書間に矛盾があり rulebook を正として判断した箇所、参照範囲から外れていた文書とその代わりに根拠にした内容があれば、あわせて記録する。",
163
+ "_TODO_: `approach` に従ってどう進めたか、その進め方の中で実践の型(rulebook / recipe / sample / template)をどう適用したかを記入する(`fully-guided` で rulebook / recipe / sample / template をどう使い分けたか、`recipe-guided` で recipe のみを基準にした内容、`freeform` で実践の型より優先した実例やプロジェクト文脈、`retrofit` で実際に参照した実装パス・抽出した現在動作・反映/新設判断・未反映の乖離・未確認範囲、`rulebook-authoring` などの authoring 系で手本から一般化した内容・変更しなかった手本・参照の付け替えまたは見送り、`rulebook-maintenance` などの maintenance 系で見直した実践の型とその根拠、など)。実践の型を基準にしなかった場合は、その判断と代わりに根拠にした内容も記入する。複数文書間に矛盾があり rulebook を正として判断した箇所、参照範囲から外れていた文書とその代わりに根拠にした内容があれば、あわせて記録する。",
164
164
  ].join("\n");
165
165
  const APPROACH_SECTION_WITHOUT_APPROACH = [
166
166
  "## 4. 進め方",
@@ -774,6 +774,10 @@ export function parseResultTaskIdentity(resultContent) {
774
774
  "recipe-guided",
775
775
  "freeform",
776
776
  "bootstrap",
777
+ "rulebook-authoring",
778
+ "recipe-authoring",
779
+ "sample-authoring",
780
+ "template-authoring",
777
781
  "retrofit",
778
782
  "cross-deliverable-dedup",
779
783
  "rulebook-maintenance",
@@ -8,6 +8,10 @@ function isApproach(value) {
8
8
  value === "recipe-guided" ||
9
9
  value === "freeform" ||
10
10
  value === "bootstrap" ||
11
+ value === "rulebook-authoring" ||
12
+ value === "recipe-authoring" ||
13
+ value === "sample-authoring" ||
14
+ value === "template-authoring" ||
11
15
  value === "retrofit" ||
12
16
  value === "cross-deliverable-dedup" ||
13
17
  value === "rulebook-maintenance" ||
@@ -0,0 +1,100 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { extname, join, resolve } from "node:path";
3
+ import { readSpecdojoNamespace } from "../docs/frontmatter-namespace.js";
4
+ import { getKataAuthority, isSpecdojoSourceRepository, loadConfig, specdojoRootDir, } from "../shared/specdojo-config.js";
5
+ import { parsePracticeId, practiceLocalId } from "../shared/practice-id.js";
6
+ import { load } from "../shared/yaml.js";
7
+ import { resolveSpecdojoReferencePathIfExists } from "../docs/template-resolution.js";
8
+ export const KATA_AUTHORING_BASE = "docs/ja/kata";
9
+ export const AUTHORING_KINDS = ["rulebook", "recipe", "sample", "template"];
10
+ const KIND_DIR = {
11
+ rulebook: "rulebooks",
12
+ recipe: "recipes",
13
+ sample: "samples",
14
+ template: "templates",
15
+ };
16
+ const AUTHORING_KIND_BY_APPROACH = {
17
+ "rulebook-authoring": "rulebook",
18
+ "recipe-authoring": "recipe",
19
+ "sample-authoring": "sample",
20
+ "template-authoring": "template",
21
+ };
22
+ export function authoringKind(approach) {
23
+ return approach ? AUTHORING_KIND_BY_APPROACH[approach] : undefined;
24
+ }
25
+ export function isAuthoringApproach(approach) {
26
+ return (approach !== undefined &&
27
+ Object.prototype.hasOwnProperty.call(AUTHORING_KIND_BY_APPROACH, approach));
28
+ }
29
+ export function kataKindDirectory(kind, local = false) {
30
+ return local ? `${KATA_AUTHORING_BASE}/${KIND_DIR[kind]}` : `docs/ja/specdojo/${KIND_DIR[kind]}`;
31
+ }
32
+ export function authoredKataPath(id, kind, extension = "md") {
33
+ const specdojoOwned = parsePracticeId(id).authority === "specdojo";
34
+ const directory = kataKindDirectory(kind, !specdojoOwned);
35
+ return `${directory}/${practiceLocalId(id)}.${extension}`;
36
+ }
37
+ export function configuredKataAuthority(rootDir = specdojoRootDir()) {
38
+ return getKataAuthority(loadConfig(rootDir).config, rootDir);
39
+ }
40
+ export function assertAuthorableKataId(id, kind, rootDir = specdojoRootDir()) {
41
+ const parsed = parsePracticeId(id);
42
+ const expectedSuffix = `-${kind}`;
43
+ if (!parsed.localId.endsWith(expectedSuffix)) {
44
+ throw new Error(`Kata id ${id} must end with ${expectedSuffix} for ${kind}-authoring`);
45
+ }
46
+ if (!parsed.authority) {
47
+ throw new Error(`Kata id ${id} must include a repository authority`);
48
+ }
49
+ if (parsed.authority === "specdojo") {
50
+ if (!isSpecdojoSourceRepository(rootDir)) {
51
+ throw new Error(`Kata authority "specdojo" is reserved for the SpecDojo repository; use ${configuredKataAuthority(rootDir)}:${parsed.localId}`);
52
+ }
53
+ }
54
+ else {
55
+ const expected = configuredKataAuthority(rootDir);
56
+ if (parsed.authority !== expected) {
57
+ throw new Error(`Kata id ${id} must use this repository's kata_authority "${expected}"`);
58
+ }
59
+ }
60
+ }
61
+ function dataFileId(path) {
62
+ try {
63
+ const content = readFileSync(path, "utf8");
64
+ const extension = extname(path).toLowerCase();
65
+ if (extension === ".md" || extension === ".mdx") {
66
+ const id = readSpecdojoNamespace(content).id;
67
+ return typeof id === "string" ? id : undefined;
68
+ }
69
+ const parsed = extension === ".json" ? JSON.parse(content) : load(content);
70
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
71
+ return undefined;
72
+ const id = parsed.id;
73
+ return typeof id === "string" ? id : undefined;
74
+ }
75
+ catch {
76
+ return undefined;
77
+ }
78
+ }
79
+ export function authoredKataExists(id, rootDir = specdojoRootDir()) {
80
+ const localId = practiceLocalId(id);
81
+ for (const kind of AUTHORING_KINDS) {
82
+ 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
+ }
90
+ }
91
+ }
92
+ return false;
93
+ }
94
+ export function authoringStandardId(kind) {
95
+ return `specdojo:${kind}-authoring-standard`;
96
+ }
97
+ export function authoringStandardPath(kind) {
98
+ const path = `docs/ja/specdojo/standards/${kind}-authoring-standard.md`;
99
+ return resolveSpecdojoReferencePathIfExists(path) ?? path;
100
+ }