specdojo 0.6.0 → 0.7.0

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 (60) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +2 -2
  3. package/dist/commands/agent.js +33 -0
  4. package/dist/commands/init.js +1 -0
  5. package/dist/commands/orchestrator.js +10 -1
  6. package/dist/devcontainer/command.js +18 -0
  7. package/dist/devcontainer/host-script.js +21 -0
  8. package/dist/devcontainer/scaffold.js +4 -3
  9. package/dist/exec/antigravity-session.js +154 -0
  10. package/dist/exec/parent-validation.js +7 -0
  11. package/dist/exec/plan-markdownlint.js +89 -0
  12. package/dist/exec/plans-generation.js +6 -2
  13. package/dist/exec/register-resume.js +28 -0
  14. package/dist/exec/run/lifecycle-commands.js +85 -16
  15. package/dist/exec/run/register-command.js +6 -0
  16. package/dist/exec/run/schedule-mode.js +22 -2
  17. package/dist/exec/run/schedule-prepare.js +42 -1
  18. package/dist/exec/run/schedule-task.js +3 -0
  19. package/dist/exec/worktree-ops-commit.js +1 -13
  20. package/dist/exec/worktree-ops-lifecycle.js +40 -36
  21. package/dist/register/register.js +31 -23
  22. package/dist/shared/git.js +7 -0
  23. package/dist/shared/provider-scaffold.js +2 -0
  24. package/dist/shared/specdojo-gitignore.js +1 -0
  25. package/docs/ja/specdojo/defaults/pm-review-viewpoints.yaml +2 -0
  26. package/docs/ja/specdojo/guides/docs-editing-guide.md +36 -0
  27. package/docs/ja/specdojo/guides/exec-config-guide.md +14 -12
  28. package/docs/ja/specdojo/guides/exec-operation-guide.md +20 -8
  29. package/docs/ja/specdojo/guides/orchestrator-operation-guide.md +4 -2
  30. package/docs/ja/specdojo/guides/quick-start-guide.md +597 -871
  31. package/docs/ja/specdojo/guides/register-operation-guide.md +2 -0
  32. package/docs/ja/specdojo/guides/remote-host-development-guide.md +31 -4
  33. package/docs/ja/specdojo/guides/schedule-operation-guide.md +14 -0
  34. package/docs/ja/specdojo/guides/use-case-guide.md +537 -77
  35. package/docs/ja/specdojo/recipes/cdfd-overview-recipe.md +88 -86
  36. package/docs/ja/specdojo/recipes/cdfd-uc-recipe.md +96 -122
  37. package/docs/ja/specdojo/references/command-reference.md +69 -37
  38. package/docs/ja/specdojo/rulebooks/cdfd-d2-rulebook.md +367 -0
  39. package/docs/ja/specdojo/rulebooks/cdfd-mermaid-rulebook.md +6 -5
  40. package/docs/ja/specdojo/rulebooks/cdfd-overview-rulebook.md +96 -100
  41. package/docs/ja/specdojo/rulebooks/cdfd-rulebook.md +38 -47
  42. package/docs/ja/specdojo/rulebooks/cdfd-uc-rulebook.md +108 -103
  43. package/docs/ja/specdojo/samples/cdfd-overview-sample.md +248 -140
  44. package/docs/ja/specdojo/samples/cdfd-uc-sample.md +128 -97
  45. package/docs/ja/specdojo/templates/cdfd-overview-template.md +161 -83
  46. package/docs/ja/specdojo/templates/cdfd-uc-template.md +127 -90
  47. package/docs/specdojo/schemas/v1/exec-defaults.schema.yaml +1 -0
  48. package/docs/specdojo/schemas/v1/specdojo-config.schema.yaml +1 -0
  49. package/package.json +5 -2
  50. package/templates/antigravity/README.md +19 -46
  51. package/templates/antigravity/exec-defaults-snippet.yaml +5 -6
  52. package/templates/antigravity/settings.edit.json +73 -0
  53. package/templates/antigravity/settings.orchestrator.json +15 -0
  54. package/templates/antigravity/settings.report.json +7 -0
  55. package/templates/antigravity/settings.review.json +7 -0
  56. package/templates/devcontainer/remote-host/devcontainer-tmux.sh +217 -0
  57. package/templates/devcontainer/remote-host/specdojo-tmux.sh.sample +8 -96
  58. package/templates/devcontainer/remote-host/ssh-config.sample +3 -1
  59. package/templates/init-agent-members.yaml +1 -0
  60. package/templates/init-exec-defaults.yaml +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,46 @@
2
2
 
3
3
  SpecDojo の利用者に影響する変更を記録します。
4
4
 
5
+ ## [Unreleased]
6
+
7
+ ## [0.7.0] - 2026-11-03
8
+
9
+ 同梱パッケージは `@specdojo/docs-site` 0.4.0 を同時に公開します。docs-site 0.4.0 は、D2 コードブロックの SVG 生成と配信(`specdojo-docs-site d2`、PJR-6NEM)と、サイドメニューへの Kata(rulebook・recipe・sample・template)の掲載(PJR-PQG3)を含みます。`@specdojo/docs-lint` は変更がないため 0.4.0 のままです。
10
+
11
+ この版に破壊的変更はありません。
12
+
13
+ ### 追加機能
14
+
15
+ - `exec run --auto --track <track>` を追加しました。`--parallel`・`--loop`・`--dry-run` と併用でき、失敗後や次の枠の補充でも指定した track だけから選びます。存在しない track は claim 前にエラーで停止し、省略時は全 track から選ぶ従来の動作を維持します(PJR-561Q)。
16
+
17
+ - Antigravity 向けの対話型オーケストレーター起動スクリプトとして `orch:argon`(`gemini-4-argon-medium`)と `orch:argon:work`(worktree `argon-work`)を追加しました。`specdojo init` と `config scaffold` が Antigravity 選択時に配布します。既存の `orch:flash`・`orch:flash:work`(`gemini-3.8-flash-high`)も維持されます(PJR-EWHQ)。
18
+
19
+ - schedule の `exec resume --task <task-id> --resume-from executor` を追加しました。executor が成功し reporter で止まった `blocked`/中断した `doing` の pipeline を、既存 worktree と変更、worktree で編集した plan を引き継いで executor から再実行できます(PJR-RKHR)。
20
+
21
+ - docs-site に D2 コードブロックの SVG 生成と配信、`specdojo-docs-site d2` を追加しました。D2 CLI v0.9.0 と既定 ELK を使い、構文検査 `node tools/lint-d2.mjs` と親検証 ID `lint-d2` を用意しました。Dev Container の CLI 導入は版と SHA-256 を固定します。`lint:d2`・`check`・commit hook・親検証設定および CI への組み込みは、保護された設定の承認後に反映します(PJR-6NEM)。
22
+
23
+ - `devcontainer host-script` コマンドを追加しました。常時稼働ホストから devcontainer 内の tmux セッションへ入るためのスクリプト本体(`devcontainer-tmux.sh`)を workspace の `.specdojo/host/` へ書き出します。ホスト側のスクリプト(`specdojo-tmux.sh`)は workspace のパスを渡して本体を呼び出す数行のみとなり、稼働中または停止中のコンテナへの接続ではホスト側に Node.js が不要になります。コンテナ未作成時のみ `devcontainer up` を動かし、`SPECDOJO_NODE_BIN` による PATH 上書きやログインシェル経由の起動に対応します。対応 OS は macOS、Linux、Windows の WSL2 です(PJR-Q8KP)。
24
+
25
+ ### 変更
26
+
27
+ - 概念データフロー図の Kata を見直しました。全体概要(`cdfd-overview`)の rulebook・recipe・sample・template は、目的を全体像として書き、プロセス領域の区分を代表ノードとする図(区分の位置をそろえる、線のない区分を置かない、調整役の指示の図を分ける、区分の間の実行要求の線を認める、業務の言葉の題)を定め、sample と template の図を D2 の縦の流れにしました(PJR-6QTK・PJR-BC45)。ユースケース別(`cdfd-uc`)の Kata は、「引き渡し」と「例外時の戻り先」の章をなくして渡す情報を図の線で表し、図から調整役を外し、イベントを 1 ノード 1 出来事の短い文にし、deprecated の文書を参照しないことを定め、sample と template の図を D2 の縦の流れにしました(PJR-PRYZ)。eject している場合は、差分を確かめて取り込んでください。
28
+
29
+ - docs-site のサイドメニューに、非推奨でない Kata(rulebook・recipe・sample・template)をすべて載せました。「サンプル」と「テンプレート」のメニューを新設し、載っていない Kata を検出するテストを追加しました(PJR-PQG3)。
30
+
31
+ - agy 1.4.12 のセッション別権限に対応する `agent launch --provider antigravity --role <edit|review|report>` と、対話型 orchestrator の専用設定を追加しました。scaffold は役割別プロファイルを配置し、宣言済みプロダクト worktree の編集許可と各リポジトリの保護ルールを一つの `--settings` JSON にまとめます。通常導入ではグローバル設定を書き換えません。既存の起動設定は配布スニペットへ移行し、設定マージ・許可/拒否の実機確認後に適用してください(PJR-B0B8)。
32
+
33
+ - `devcontainer scaffold` が生成する `specdojo-tmux.sh.sample` を、`.specdojo/host/devcontainer-tmux.sh` を呼び出す数行のラッパースクリプトへ置き換えました。あわせて `ssh-config.sample` の接続説明を新しい起動方式に合わせて更新しました(PJR-Q8KP)。
34
+
35
+ ### 不具合修正
36
+
37
+ - checkpoint の stage 後の検査失敗と、`register --commit` の commit・amend 失敗時に、処理対象だけを unstage するようにしました。作業ツリーの内容と無関係な staged 変更を保持し、register の初回 commit と amend は対象パスだけを記録します(PJR-W7YX)。
38
+
39
+ - schedule の phase の説明に含まれる Markdown の誤りを、checkpoint commit より前の plan 生成時に検出するようにしました。`exec plan --task` と `exec run --auto`(`--dry-run` を含む)が markdownlint の違反をタスク ID・plan のパス・行番号とともに報告し、既存 plan の上書き前に停止します。検査には利用リポジトリまたは SpecDojo 側の markdownlint が必要です(PJR-FVRZ)。
40
+
41
+ - SSH 経由の非対話シェルで `devcontainer-tmux.sh` が Docker を見つけられない問題を修正しました。`SPECDOJO_DOCKER_BIN`、現在の PATH、ログインシェル、代表的な配置先の順に探索し、見つかった場所を `devcontainer up` にも引き継ぎます。Docker が見つからない場合や `docker info` に失敗した場合は、macOS・WSL2・Linux に合った対処方法を表示して停止します(PJR-DWHZ)。
42
+
43
+ - ホストから devcontainer 内の tmux セッションへ入るスクリプト本体(`devcontainer-tmux.sh`)で、`docker inspect` のマウント情報のうち `bind` マウントのみを対象とし、ホスト側のディレクトリパスを正規化してからワークスペースパスと照合するように修正しました。Docker Desktop for Mac などでマウント元のパスが `<親>/<repo>/..` の形式で返る環境でもコンテナ内の作業ディレクトリを正しく特定できるようにします。あわせてマウントパスの前方一致判定における変数展開のクォート漏れ(SC2295)および未使用変数(SC2034)を修正し、サンプルのラッパースクリプト(`specdojo-tmux.sh.sample`)では本体スクリプトの実行権限の有無に関わらず起動できるよう `bash` 経由で呼び出すようにしました(PJR-NV5T)。
44
+
5
45
  ## [0.6.0] - 2026-10-31
6
46
 
7
47
  同梱パッケージは `@specdojo/docs-lint` 0.4.0 を同時に公開します。docs-lint 0.4.0 は、成果物の文脈の目印 `_CONTEXT_:` の検出(`status: ready` の文書ではエラー、それ以外は情報。PJR-JRSY・PJR-D0GB)を含みます。`remark/md-content` を options なしで読み込むと失敗する問題の修正(PJR-5EN3)と、0.3.1(2026-10-29 公開)の rulebook 一覧のキャッシュ(PJR-SC8T)も含みます。`@specdojo/docs-site` は変更がないため 0.3.0 のままです。
package/README.md CHANGED
@@ -6,7 +6,7 @@ SpecDojo は、Spec道(仕様道)の道場です。
6
6
  **記して、形にして、磨き続ける。**
7
7
 
8
8
  **記帳ひとつから始められます。** 設定 2 行で使い始め、必要になった分だけ広げられます。
9
- 迷いを question として起票し、decision で決め、仕様書に書き、後日 change-request で直すまでを 10 分で体験できます。kata(型)を事前に用意する必要はありません。手順は [Quick Start ガイド](https://specdojo.github.io/specdojo/ja/specdojo/guides/quick-start-guide.html) 冒頭の「10分で体験する — 仕様の判断台帳」を参照してください。
9
+ 導入と Git flow の初期設定、register での起票と AI 実行、schedule・routine による運用までを対話で体験できます。手順は [Quick Start ガイド](https://specdojo.github.io/specdojo/ja/specdojo/guides/quick-start-guide.html) を参照してください。
10
10
 
11
11
  | 道場の言葉 | SpecDojo の仕組み |
12
12
  | ---------- | ------------------------------------------------------------------------------------------------------- |
@@ -105,7 +105,7 @@ npm run orch:opus
105
105
  | `claude` | `.claude/agents/specdojo-orchestrator.md` | `npm run orch:opus` ほか |
106
106
  | `opencode` | `.opencode/agents/specdojo-orchestrator.md` | `npm run orch:opencode` |
107
107
  | `codex` | `.specdojo/codex/orchestrator.md` | `npm run orch:sol` ほか |
108
- | `antigravity` | `.specdojo/antigravity/orchestrator.md` | `npm run orch:flash` |
108
+ | `antigravity` | `.specdojo/antigravity/orchestrator.md` | `npm run orch:argon` ほか |
109
109
 
110
110
  各設定を個別に管理したい場合は、後述の「設定を個別に行う場合」にある `config init` と `config scaffold` を使います。
111
111
 
@@ -1,7 +1,40 @@
1
+ import { antigravityRole, antigravitySessionArguments } from "../exec/antigravity-session.js";
2
+ import { productRootsFromEnvironment } from "../exec/task-repos.js";
3
+ import { runOrchestratorLaunch } from "./orchestrator.js";
1
4
  import { AGENT_RUN_RATE_LIMIT_EXIT_CODE, runAgentPlan, writeAgentOutput, } from "../exec/agent-plan.js";
2
5
  export { AGENT_RUN_RATE_LIMIT_EXIT_CODE, resolveAgentMember, resolveAgentCommand, readAgentPlan, writeAgentOutput, runAgentPlan, } from "../exec/agent-plan.js";
3
6
  export function registerAgentCommands(program) {
4
7
  const agent = program.command("agent").description("Run a plan with a specific agent");
8
+ agent
9
+ .command("launch")
10
+ .description("Launch agy with role-specific session permissions and runner-declared roots")
11
+ .requiredOption("--provider <name>", "Provider CLI (antigravity)")
12
+ .requiredOption("--role <role>", "Pipeline role (edit|review|report)")
13
+ .argument("[providerArgs...]", "agy arguments after --")
14
+ .action(async (providerArgs, options) => {
15
+ try {
16
+ if (options.provider !== "antigravity" || options.role === "orchestrator") {
17
+ throw new Error("agent launch requires antigravity and a pipeline role (edit|review|report)");
18
+ }
19
+ const cwd = process.cwd();
20
+ const args = antigravitySessionArguments({
21
+ role: antigravityRole(options.role),
22
+ cwd,
23
+ repoRoots: productRootsFromEnvironment(process.env).map((repo) => repo.path),
24
+ providerArgs,
25
+ });
26
+ process.exitCode = await runOrchestratorLaunch({
27
+ command: "agy",
28
+ args,
29
+ cwd,
30
+ env: { ...process.env },
31
+ });
32
+ }
33
+ catch (error) {
34
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
35
+ process.exitCode = 1;
36
+ }
37
+ });
5
38
  agent
6
39
  .command("run")
7
40
  .description("Feed a plan to one agent and capture its stdout")
@@ -18,6 +18,7 @@ const PARENT_VALIDATION_SCRIPTS = {
18
18
  "lint-fm": "lint:fm",
19
19
  "lint-md": "lint:md",
20
20
  "lint-mermaid": "lint:mermaid",
21
+ "lint-d2": "lint:d2",
21
22
  "test-integration": "test:integration",
22
23
  "validate-schema": "validate:schema",
23
24
  typecheck: "typecheck",
@@ -2,6 +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 { antigravitySessionArguments } from "../exec/antigravity-session.js";
5
6
  import { loadConfig, resolveExternalProjects, specdojoRootDir, } from "../shared/specdojo-config.js";
6
7
  import { registerNightOrchestratorCommand } from "./night-orchestrator.js";
7
8
  const ORCHESTRATOR_EXECUTABLES = {
@@ -108,7 +109,15 @@ function inlineOpenCodeConfig(current, agentName, repoRoots) {
108
109
  export function buildOrchestratorLaunch(options) {
109
110
  const env = { ...(options.env ?? process.env) };
110
111
  const args = [...options.providerArgs];
111
- if (options.provider === "opencode" && options.repoRoots.length > 0) {
112
+ if (options.provider === "antigravity") {
113
+ args.splice(0, args.length, ...antigravitySessionArguments({
114
+ role: "orchestrator",
115
+ cwd: options.cwd,
116
+ repoRoots: options.repoRoots,
117
+ providerArgs: args,
118
+ }));
119
+ }
120
+ else if (options.provider === "opencode" && options.repoRoots.length > 0) {
112
121
  env.OPENCODE_CONFIG_CONTENT = inlineOpenCodeConfig(env.OPENCODE_CONFIG_CONTENT, opencodeAgentName(args), options.repoRoots);
113
122
  }
114
123
  else {
@@ -1,4 +1,5 @@
1
1
  import { runDevcontainerScaffold } from "./scaffold.js";
2
+ import { runDevcontainerHostScript } from "./host-script.js";
2
3
  import { specdojoPackageRootDir } from "../shared/package-paths.js";
3
4
  import { specdojoRootDir } from "../shared/specdojo-config.js";
4
5
  export function registerDevcontainerCommands(program) {
@@ -44,4 +45,21 @@ export function registerDevcontainerCommands(program) {
44
45
  process.exitCode = 1;
45
46
  }
46
47
  });
48
+ dc.command("host-script")
49
+ .description("Write the devcontainer tmux host script into .specdojo/host/")
50
+ .option("--dry-run", "Show planned files without writing", false)
51
+ .action(async (opts) => {
52
+ try {
53
+ await runDevcontainerHostScript({
54
+ packageRoot: specdojoPackageRootDir(),
55
+ repoRoot: specdojoRootDir(),
56
+ dryRun: !!opts.dryRun,
57
+ });
58
+ }
59
+ catch (error) {
60
+ const message = error instanceof Error ? error.message : String(error);
61
+ process.stderr.write(`${message}\n`);
62
+ process.exitCode = 1;
63
+ }
64
+ });
47
65
  }
@@ -0,0 +1,21 @@
1
+ import { existsSync } from "node:fs";
2
+ import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import * as path from "node:path";
4
+ export async function runDevcontainerHostScript(opts) {
5
+ const { packageRoot, repoRoot, dryRun } = opts;
6
+ const templatePath = path.join(packageRoot, "templates", "devcontainer", "remote-host", "devcontainer-tmux.sh");
7
+ if (!existsSync(templatePath)) {
8
+ throw new Error(`Host script template not found: ${templatePath}`);
9
+ }
10
+ const hostScriptContent = await readFile(templatePath, "utf8");
11
+ const hostDir = path.join(repoRoot, ".specdojo", "host");
12
+ const destPath = path.join(hostDir, "devcontainer-tmux.sh");
13
+ if (dryRun) {
14
+ process.stdout.write(`[dry-run] would write: .specdojo/host/devcontainer-tmux.sh\n`);
15
+ return;
16
+ }
17
+ await mkdir(hostDir, { recursive: true });
18
+ await writeFile(destPath, hostScriptContent, "utf8");
19
+ await chmod(destPath, 0o755);
20
+ process.stdout.write(`Written: .specdojo/host/devcontainer-tmux.sh\n`);
21
+ }
@@ -130,8 +130,10 @@ export function generateSshConfigSample(ports) {
130
130
  "",
131
131
  "# devcontainer 内の tmux セッションへ直接入る接続用",
132
132
  "# RemoteCommand は非対話シェルで動くため、接続先端末の ~/.zshrc などの PATH 設定は読み込まれません。",
133
+ "# 通常の接続(コンテナ稼働中または停止中)では Node.js は不要です(docker のみ使用)。",
134
+ "# コンテナ未作成時のみ Dev Container CLI が自動起動されます。",
133
135
  "# 接続元から「ssh <host> 'command -v devcontainer'」を実行して Dev Container CLI が見つかるか確認できます。",
134
- "# 見つからない場合は、ホスト側の ~/bin/specdojo-tmux.sh の node_bin_dir を設定してください。",
136
+ "# 見つからない場合は、ホストの環境変数 SPECDOJO_NODE_BIN を設定するか、ログインシェルの PATH を確認してください。",
135
137
  "Host <host>-tmux",
136
138
  " HostName <host>",
137
139
  " User <user>",
@@ -355,7 +357,7 @@ fi`);
355
357
  postCreateScript = postCreateScript.replace("npm install", extraScripts.join("\n\n") + "\n\nnpm install");
356
358
  }
357
359
  const specdojoTmuxTemplatePath = path.join(templateDir, "remote-host", "specdojo-tmux.sh.sample");
358
- let specdojoTmuxScript = await readFile(specdojoTmuxTemplatePath, "utf8");
360
+ const specdojoTmuxScript = await readFile(specdojoTmuxTemplatePath, "utf8");
359
361
  const remoteUser = typeof devcontainer.remoteUser === "string" && devcontainer.remoteUser.trim()
360
362
  ? devcontainer.remoteUser.trim()
361
363
  : "node";
@@ -379,7 +381,6 @@ fi`);
379
381
  ...existingRemoteEnv,
380
382
  PATH: remotePath,
381
383
  };
382
- specdojoTmuxScript = specdojoTmuxScript.replace('container_user="node"', `container_user="${remoteUser}"`);
383
384
  const publishedPorts = extractPublishedPorts(devcontainer);
384
385
  const sshConfigScript = generateSshConfigSample(publishedPorts);
385
386
  if (dryRun) {
@@ -0,0 +1,154 @@
1
+ import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
2
+ import { join, resolve } from "node:path";
3
+ import { specdojoPackageRootDir } from "../shared/package-paths.js";
4
+ import { isAgentProtectedConfigPath, PROTECTED_DIRECTORY_PREFIXES, PROTECTED_EXACT_PATHS, } from "./agent-protected-config.js";
5
+ export function antigravityRole(value) {
6
+ if (["edit", "review", "report", "orchestrator"].includes(value)) {
7
+ return value;
8
+ }
9
+ throw new Error(`Invalid Antigravity role: ${value}`);
10
+ }
11
+ function canonicalRoot(root) {
12
+ const absolute = resolve(root);
13
+ const normalized = (existsSync(absolute) ? realpathSync(absolute) : absolute).replaceAll("\\", "/");
14
+ // The permission syntax has no escaping for parentheses or the global wildcard.
15
+ if (/[()*\r\n]/u.test(normalized)) {
16
+ throw new Error(`Unsupported Antigravity workspace path: ${normalized}`);
17
+ }
18
+ return normalized.replace(/\/$/u, "") + "/";
19
+ }
20
+ /** One settings object per launch: never read or modify the user's global settings. */
21
+ export function buildAntigravitySession(options) {
22
+ const { role, cwd } = options;
23
+ const roots = [...new Set([cwd, ...options.repoRoots].map(canonicalRoot))];
24
+ const localProfile = join(cwd, ".specdojo", "antigravity", `settings.${role}.json`);
25
+ const profilePath = existsSync(localProfile)
26
+ ? localProfile
27
+ : join(specdojoPackageRootDir(), "templates", "antigravity", `settings.${role}.json`);
28
+ const profile = JSON.parse(readFileSync(profilePath, "utf8"));
29
+ if (!profile || typeof profile !== "object" || Array.isArray(profile)) {
30
+ throw new Error(`Invalid Antigravity settings: ${profilePath}`);
31
+ }
32
+ const settings = profile;
33
+ const permissions = { allow: [], deny: [], ask: [] };
34
+ if (settings.permissions !== undefined) {
35
+ if (!settings.permissions ||
36
+ typeof settings.permissions !== "object" ||
37
+ Array.isArray(settings.permissions)) {
38
+ throw new Error(`Invalid permissions in ${profilePath}`);
39
+ }
40
+ for (const name of ["allow", "deny", "ask"]) {
41
+ const rules = settings.permissions[name] ?? [];
42
+ if (!Array.isArray(rules) || rules.some((rule) => typeof rule !== "string")) {
43
+ throw new Error(`Invalid permissions.${name} in ${profilePath}`);
44
+ }
45
+ permissions[name] = [...rules];
46
+ }
47
+ }
48
+ for (const root of roots) {
49
+ permissions.allow.push(`read_file(${root})`);
50
+ if (role === "edit" || role === "orchestrator")
51
+ permissions.allow.push(`write_file(${root})`);
52
+ for (const secret of [
53
+ ".env",
54
+ ".env.local",
55
+ ".env.development",
56
+ ".env.production",
57
+ ".env.test",
58
+ ".env.staging",
59
+ ".envrc",
60
+ "secrets/",
61
+ ".ssh/",
62
+ ".aws/",
63
+ ".gemini/",
64
+ ]) {
65
+ permissions.deny.push(`read_file(${root}${secret})`);
66
+ }
67
+ permissions.deny.push(`write_file(${root}.git)`);
68
+ if (role !== "orchestrator") {
69
+ const discovered = existsSync(root)
70
+ ? readdirSync(root).filter(isAgentProtectedConfigPath)
71
+ : [];
72
+ for (const protectedPath of new Set([
73
+ ...PROTECTED_DIRECTORY_PREFIXES,
74
+ ...PROTECTED_EXACT_PATHS,
75
+ ...discovered,
76
+ ])) {
77
+ if (/[()*\r\n]/u.test(protectedPath)) {
78
+ throw new Error(`Unsupported Antigravity protected path: ${protectedPath}`);
79
+ }
80
+ permissions.deny.push(`write_file(${root}${protectedPath})`);
81
+ }
82
+ }
83
+ }
84
+ if (role === "review" || role === "report") {
85
+ // A command or MCP tool can write independently of write_file permissions.
86
+ permissions.deny.push("write_file(*)", "command(*)", "unsandboxed(*)", "mcp(*)", "execute_url(*)");
87
+ }
88
+ permissions.deny.push("command(sudo)", "command(rm -rf)");
89
+ for (const bin of ["", "/usr/bin/", "/usr/local/bin/"]) {
90
+ permissions.deny.push(`command(${bin}git push)`, `command(${bin}gh)`);
91
+ if (role !== "orchestrator") {
92
+ for (const action of ["add", "commit", "config", "reset"])
93
+ permissions.deny.push(`command(${bin}git ${action})`);
94
+ }
95
+ }
96
+ for (const name of ["allow", "deny", "ask"])
97
+ permissions[name] = [...new Set(permissions[name])];
98
+ return {
99
+ roots,
100
+ settings: { ...settings, agentMode: "", toolPermission: "request-review", permissions },
101
+ };
102
+ }
103
+ export function antigravitySessionArguments(options) {
104
+ const { roots, settings } = buildAntigravitySession(options);
105
+ const args = [];
106
+ for (let index = 0; index < options.providerArgs.length; index++) {
107
+ const arg = options.providerArgs[index];
108
+ // Go-style flag parsers may also accept a single dash for long options.
109
+ const flag = arg.startsWith("-") && !arg.startsWith("--") && arg.length > 2 ? `-${arg}` : arg;
110
+ if (arg === "--")
111
+ throw new Error("Antigravity provider argument terminator is not supported");
112
+ if ([
113
+ "-p",
114
+ "-i",
115
+ "--print",
116
+ "--prompt",
117
+ "--prompt-interactive",
118
+ "--model",
119
+ "--effort",
120
+ "--input-format",
121
+ "--output-format",
122
+ "--json-schema",
123
+ "--print-timeout",
124
+ "--log-file",
125
+ ].includes(flag)) {
126
+ const value = options.providerArgs[++index];
127
+ if (value === undefined)
128
+ throw new Error(`Missing value for ${arg}`);
129
+ args.push(arg, value);
130
+ continue;
131
+ }
132
+ if (flag === "--add-dir" || flag.startsWith("--add-dir=")) {
133
+ const dir = flag === "--add-dir" ? options.providerArgs[++index] : flag.slice("--add-dir=".length);
134
+ if (!dir || !roots.includes(canonicalRoot(resolve(options.cwd, dir)))) {
135
+ throw new Error(`Undeclared Antigravity workspace: ${dir ?? "(missing)"}`);
136
+ }
137
+ continue;
138
+ }
139
+ if (/^--(?:settings|dangerously-skip-permissions|mode|project|new-project|continue|conversation|agent)(?:=|$)/u.test(flag) ||
140
+ arg === "-c") {
141
+ throw new Error(`Antigravity session permissions cannot be overridden: ${arg}`);
142
+ }
143
+ if (!arg.startsWith("-")) {
144
+ throw new Error(`Use -p or -i for Antigravity prompts; unexpected argument: ${arg}`);
145
+ }
146
+ args.push(arg);
147
+ }
148
+ return [
149
+ ...args,
150
+ ...roots.flatMap((root) => ["--add-dir", root.replace(/\/$/u, "") || "/"]),
151
+ "--settings",
152
+ JSON.stringify(settings),
153
+ ];
154
+ }
@@ -64,6 +64,13 @@ const PARENT_VALIDATION_REGISTRY = {
64
64
  displayCommand: "npm run lint:mermaid",
65
65
  timeoutMs: 10 * 60 * 1_000,
66
66
  },
67
+ "lint-d2": {
68
+ id: "lint-d2",
69
+ command: process.platform === "win32" ? "npm.cmd" : "npm",
70
+ args: ["run", "lint:d2"],
71
+ displayCommand: "npm run lint:d2",
72
+ timeoutMs: 10 * 60 * 1_000,
73
+ },
67
74
  build: {
68
75
  id: "build",
69
76
  command: process.platform === "win32" ? "npm.cmd" : "npm",
@@ -0,0 +1,89 @@
1
+ import { existsSync } from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import { dirname, join, relative } from "node:path";
4
+ import { pathToFileURL } from "node:url";
5
+ import { load } from "../shared/yaml.js";
6
+ import { DEFAULT_MARKDOWNLINT_CONFIG } from "../shared/markdownlint-config.js";
7
+ async function markdownlintApi(repoRoot) {
8
+ // Prefer the consumer's installation, then SpecDojo's development installation.
9
+ // Resolve from markdownlint-cli as well, for package managers without hoisting.
10
+ for (let require of [
11
+ createRequire(join(repoRoot, "package.json")),
12
+ createRequire(import.meta.url),
13
+ ]) {
14
+ try {
15
+ try {
16
+ require = createRequire(require.resolve("markdownlint-cli/markdownlint.js"));
17
+ }
18
+ catch {
19
+ // A direct markdownlint installation is sufficient too.
20
+ }
21
+ const api = (await import(pathToFileURL(require.resolve("markdownlint/sync")).href));
22
+ const parsers = [];
23
+ try {
24
+ const jsonc = require("jsonc-parser");
25
+ parsers.push((text) => {
26
+ const errors = [];
27
+ const value = jsonc.parse(text, errors, { allowTrailingComma: true });
28
+ if (errors.length)
29
+ throw new Error("Invalid JSONC configuration");
30
+ return value;
31
+ });
32
+ }
33
+ catch {
34
+ // JSON and YAML remain supported without markdownlint-cli's JSONC parser.
35
+ }
36
+ parsers.push((text) => load(text));
37
+ return { ...api, parsers };
38
+ }
39
+ catch {
40
+ // Try the next installation without downloading a package.
41
+ }
42
+ }
43
+ throw new Error("markdownlint not available; install markdownlint-cli in the project to validate plans.");
44
+ }
45
+ function planLintConfig(repoRoot, api) {
46
+ let config;
47
+ // Merge ancestor .markdownlintrc files from outermost to nearest, like the CLI.
48
+ const rcPaths = [];
49
+ for (let dir = repoRoot;; dir = dirname(dir)) {
50
+ const candidate = join(dir, ".markdownlintrc");
51
+ if (existsSync(candidate))
52
+ rcPaths.unshift(candidate);
53
+ if (dirname(dir) === dir)
54
+ break;
55
+ }
56
+ for (const file of rcPaths)
57
+ config = { ...config, ...api.readConfig(file, api.parsers) };
58
+ for (const ext of ["jsonc", "json", "yaml", "yml"]) {
59
+ const file = join(repoRoot, `.markdownlint.${ext}`);
60
+ if (existsSync(file)) {
61
+ config = { ...config, ...api.readConfig(file, api.parsers) };
62
+ break;
63
+ }
64
+ }
65
+ return config ?? DEFAULT_MARKDOWNLINT_CONFIG;
66
+ }
67
+ // Lint rendered source before formatting or replacing an existing schedule plan.
68
+ // A string input bypasses ignore globs for generated history directories.
69
+ export async function assertPlanMarkdownlint(repoRoot, taskId, outPath, content) {
70
+ const planPath = relative(repoRoot, outPath);
71
+ const label = `Task ${taskId}, plan ${planPath}`;
72
+ let errors;
73
+ try {
74
+ const api = await markdownlintApi(repoRoot);
75
+ const issues = api.lint({
76
+ strings: { [planPath]: content },
77
+ config: planLintConfig(repoRoot, api),
78
+ configParsers: api.parsers,
79
+ })[planPath] ?? [];
80
+ errors = issues
81
+ .map((issue) => `${planPath}: ${issue.lineNumber} ${issue.ruleNames.join("/")} ${issue.ruleDescription}${issue.errorDetail ? ` [${issue.errorDetail}]` : ""}`)
82
+ .join("\n");
83
+ }
84
+ catch (error) {
85
+ throw new Error(`${label}: Failed to run markdownlint before plan generation: ${error instanceof Error ? error.message : String(error)}`);
86
+ }
87
+ if (errors)
88
+ throw new Error(`${label}: Plan Markdown notation violation before generation\n${errors}`);
89
+ }
@@ -1,9 +1,10 @@
1
1
  import { registerInputSection } from "../register/input.js";
2
2
  import { mkdirSync, writeFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
- import { DEFAULT_PROJECT_CONTEXT } from "../shared/specdojo-config.js";
4
+ import { DEFAULT_PROJECT_CONTEXT, specdojoRootDir } from "../shared/specdojo-config.js";
5
5
  import { resolveDeliverableSchemaRef, resolveKataRefs } from "../kata/kata.js";
6
6
  import { formatMarkdownFile } from "./format.js";
7
+ import { assertPlanMarkdownlint } from "./plan-markdownlint.js";
7
8
  import { expandTemplate } from "./shared.js";
8
9
  import { isAuthoringApproach } from "../kata/authoring.js";
9
10
  import { isPlanningApproach } from "../register/planning.js";
@@ -222,7 +223,10 @@ async function writeTaskPlan(ctx, task, override) {
222
223
  ? buildReviewPlanMarkdown(template, planTask, deliverable, criteria, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, ctx.reviewGradeOutcome)
223
224
  : buildEditPlanMarkdown(template, planTask, deliverable, ctx.roleMap, ctx.vpMap, ctx.projectId, ctx.catalogPath, ctx.projectContext, resultRef, stem, crossDeliverables, override);
224
225
  const schemaRef = resolveDeliverableSchemaRef(deliverable?.resolvedPath);
225
- const content = injectCommonConventions(body, schemaRef, ctx.templateCache, mode);
226
+ const content = `${injectCommonConventions(body, schemaRef, ctx.templateCache, mode).replace(/[\r\n]+$/u, "")}\n`;
227
+ if (task.schedule_file && override?.origin !== "register") {
228
+ await assertPlanMarkdownlint(specdojoRootDir(), task.id, outPath, content);
229
+ }
226
230
  writeFileSync(outPath, content, "utf8");
227
231
  await formatMarkdownFile(outPath);
228
232
  return outPath;
@@ -197,6 +197,34 @@ export function selectResumableRegisterRun(candidates, options = {}) {
197
197
  export function findResumableRegisterRun(input) {
198
198
  return selectResumableRegisterRun(loadRegisterResumeCandidates(input), input.resumeFrom ? { resumeFrom: input.resumeFrom } : {});
199
199
  }
200
+ // Schedule の明示的な executor 再開は、成功済み executor から reporter へ進んだ run に限る。
201
+ // run の選択・変更一覧・申し送りの復元は register と同じ規則を使う。
202
+ export function selectScheduleExecutorResume(candidates) {
203
+ const lookup = selectResumableRegisterRun(candidates, { resumeFrom: "executor" });
204
+ if (lookup.kind !== "resumable")
205
+ return lookup;
206
+ const { state } = lookup.target;
207
+ if (state.stages.executor.status !== "succeeded") {
208
+ return {
209
+ kind: "not-resumable",
210
+ reason: `--resume-from executor requires a succeeded executor stage for run ${state.run_id} (status: ${state.stages.executor.status})`,
211
+ };
212
+ }
213
+ const candidate = candidates.find((entry) => entry.runId === lookup.target.runId && entry.stateRef === lookup.target.stateRef);
214
+ if ((candidate?.executorEvidence ?? candidate?.evidence)?.stage.status !== "succeeded") {
215
+ return {
216
+ kind: "not-resumable",
217
+ reason: `succeeded executor evidence is missing or invalid for run ${state.run_id}`,
218
+ };
219
+ }
220
+ if (state.stages.reporter.status === "succeeded" || (state.stages.integrate?.attempts ?? 0) > 0) {
221
+ return {
222
+ kind: "not-resumable",
223
+ reason: `cannot resume the executor from the integrate stage of run ${state.run_id}`,
224
+ };
225
+ }
226
+ return lookup;
227
+ }
200
228
  // plan / result のファイル名は `<pjr-id>-<UTC>-<rand>-(plan|result).md`(buildInPlaceStem)。
201
229
  // state に artifacts が無い旧 run のために、worktree の result 一覧から最新の stem を復元する。
202
230
  export function selectLatestRegisterResultStem(fileNames, pjrId) {